This repository was archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
fix/chain_head: Ensure correct events for finalized branch #13632
Merged
Merged
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
12c3235
chain_head/follow: Ensure correct events for finalized branch
lexnv c6f9691
Merge remote-tracking branch 'origin/master' into lexnv/fix_chainhead…
lexnv df6a438
Reenable tests
lexnv 5f4907b
Do some clean ups and add some more docs
bkchr d070b31
Merge remote-tracking branch 'origin/master' into lexnv/fix_chainhead…
bkchr 26f2e8c
Fix gramatic
bkchr c56a02a
Update client/rpc-spec-v2/src/chain_head/chain_head_follow.rs
bkchr 3d223a4
rpc/chain_head: Introduce error for absent headers
lexnv File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
chain_head/follow: Ensure correct events for finalized branch
Signed-off-by: Alexandru Vasile <[email protected]>
- Loading branch information
commit 12c323596eb3b44ea4a9fcd9a96ea03d2d8563e9
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't get this piece of code? How do you know that there wasn't any new best block event for the last finalized block?
And why do you have this as part of of the for loop while it doesn't depend on any from the loop?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey
We depend on the
pin_blockwhich returnstrueif this is the first time we "pin" the block andfalseif the block was previously pinned. We callpin_blocktwice for each block: from the import and finalized branches.substrate/client/rpc-spec-v2/src/chain_head/chain_head_follow.rs
Lines 364 to 369 in df6a438
For any blocks that we have not seen yet we want to generate the NewBlock, except for the last block for which we want to generate the
NewBlock+BestBlockevents. For the last block, I've added the extra check to make sure we catch the following case:[Block 0] - [Block 1] - [Block 2] - ... ^^^ T0: Block import branch reports block 2 for the first time ^^^^^^^^^^^^^^^ T1: Finalized branch reports 0 and 1 for the first timeWe could enter this path only if the BlockImport notification is not generated for 0, 1; but somehow we receive the BlockImport for block 2. And at the same time we get Finalized for 0 and 1 (blocks that we have not been reported by BlockImport).
This check may be an overcautious one, let me know what you think of it, thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For me the flow was a little bit hard to follow. I pushed a commit that improves the flow and adds some more docs. I hope that is okay.