Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(light-client): could not check MMR for fork chains #4171

Merged

Conversation

yangby-cryptape
Copy link
Collaborator

@yangby-cryptape yangby-cryptape commented Sep 26, 2023

What problem does this PR solve?

Problem Summary:

The MMR data are saved as key-value format and the keys are positions (= block_number - MMR_enabled_block_number).

let position: packed::Uint64 = position_u64.pack();
self.insert_raw(
COLUMN_CHAIN_ROOT_MMR,
position.as_slice(),
header_digest.as_slice(),
)

So, only the MMR data for main chain could be fetched from the storage.
let mmr = self.snapshot.chain_root_mmr(*number - 1);

What is changed and how it works?

What's Changed:

  • CKB node sends the hash of block H to light client.
  • Then CKB node changes to a fork chain which tip is block G.
  • Light client asks CKB node for proof of the chain whose tip is block H.
  • Difference:
    • Before the bugfix:
      • CKB node sends a proof base on block H with a incorrect MMR proof to light client.
      • Light client checks the incorrect MMR proof, then ban CKB node for 300 seconds.
    • After this bugfix:
      • CKB node sends the hash of block G to light client.

Check List

Tests

  • Unit test
  • Integration test

Release note

Title Only: Include only the PR title in the release note.

@yangby-cryptape yangby-cryptape requested a review from a team as a code owner September 26, 2023 09:17
@yangby-cryptape yangby-cryptape requested review from quake and removed request for a team September 26, 2023 09:17
@quake quake added this pull request to the merge queue Sep 28, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Sep 28, 2023
@quake quake added this pull request to the merge queue Sep 29, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Sep 29, 2023
@yangby-cryptape
Copy link
Collaborator Author

Waiting for #4172 merged.

@quake quake added this pull request to the merge queue Oct 5, 2023
Merged via the queue into nervosnetwork:develop with commit 45104e0 Oct 5, 2023
36 checks passed
@doitian doitian mentioned this pull request Oct 9, 2023
@yangby-cryptape yangby-cryptape deleted the bugfix/no-mmr-for-fork-chains branch October 18, 2023 10:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants