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): do not skip the genesis block for last state proofs #3697

Conversation

yangby-cryptape
Copy link
Collaborator

@yangby-cryptape yangby-cryptape commented Nov 9, 2022

What problem does this PR solve?

Should not skip the genesis block for last state proofs.

For example, when current tip header at 1, then the last state proof have to contain the genesis block.

What is changed and how it works?

Since #3675, the genesis block will use a default struct as its parent chain root, so we don't have to skip it anymore.

let parent_chain_root = if tip_block.is_genesis() {
Default::default()
} else {

And, for more security, we should check if the parent chain root of a genesis block is a default struct.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code ci-runs-only: [ quick_checks,linters ]

Release note

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

assert!(result.is_ok(), "failed since {}", result.unwrap_err());
result.unwrap()
};
let result = proof.verify(parent_chain_root, digests_with_positions);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without the fix, this line will throw the error "Corrupted proof".

@yangby-cryptape yangby-cryptape force-pushed the pr/fix-should-not-skip-genesis-in-proof branch from 7d992be to fe07559 Compare November 9, 2022 11:21
@yangby-cryptape
Copy link
Collaborator Author

bors merge

@bors bors bot merged commit 335469a into nervosnetwork:develop Nov 10, 2022
@yangby-cryptape yangby-cryptape deleted the pr/fix-should-not-skip-genesis-in-proof branch November 10, 2022 05:13
@doitian doitian mentioned this pull request Nov 18, 2022
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