This repository has been 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.6k
BlockId removal: refactor: Backend::append_justification #12551
Merged
paritytech-processbot
merged 5 commits into
master
from
mku-blockid-append-justification
Oct 30, 2022
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
c43f308
BlockId removal: refactor: Backend::append_justification
michalkucharczyk fd55fb7
Error message improved
michalkucharczyk 4930349
single error message in beefy::finalize
michalkucharczyk 0ae7f17
println removed
michalkucharczyk 389e3b1
Merge remote-tracking branch 'origin/master' into mku-blockid-append-…
michalkucharczyk 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
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -500,19 +500,27 @@ where | |||||||||||||||
|
||||||||||||||||
self.on_demand_justifications.cancel_requests_older_than(block_num); | ||||||||||||||||
|
||||||||||||||||
if let Err(e) = self.backend.append_justification( | ||||||||||||||||
BlockId::Number(block_num), | ||||||||||||||||
(BEEFY_ENGINE_ID, finality_proof.encode()), | ||||||||||||||||
) { | ||||||||||||||||
error!(target: "beefy", "🥩 Error {:?} on appending justification: {:?}", e, finality_proof); | ||||||||||||||||
} | ||||||||||||||||
let maybe_block_hash = | ||||||||||||||||
self.backend.blockchain().expect_block_hash_from_id(&BlockId::Number(block_num)); | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Would make the code a little bit easier. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. reworked in 4930349 |
||||||||||||||||
|
||||||||||||||||
match maybe_block_hash { | ||||||||||||||||
Ok(hash) => { | ||||||||||||||||
if let Err(err) = self | ||||||||||||||||
.backend | ||||||||||||||||
.append_justification(&hash, (BEEFY_ENGINE_ID, finality_proof.encode())) | ||||||||||||||||
{ | ||||||||||||||||
error!(target: "beefy", "🥩 Error {:?} on appending justification: {:?}", err, finality_proof); | ||||||||||||||||
}; | ||||||||||||||||
|
||||||||||||||||
self.backend.blockchain().hash(block_num).ok().flatten().map(|hash| { | ||||||||||||||||
self.links | ||||||||||||||||
.to_rpc_best_block_sender | ||||||||||||||||
.notify(|| Ok::<_, ()>(hash)) | ||||||||||||||||
.expect("forwards closure result; the closure always returns Ok; qed.") | ||||||||||||||||
}); | ||||||||||||||||
self.links | ||||||||||||||||
.to_rpc_best_block_sender | ||||||||||||||||
.notify(|| Ok::<_, ()>(hash)) | ||||||||||||||||
.expect("forwards closure result; the closure always returns Ok; qed."); | ||||||||||||||||
}, | ||||||||||||||||
Err(err) => { | ||||||||||||||||
error!(target: "beefy", "🥩 Error {:?} hash not know for given block_num: {:?}", err, finality_proof); | ||||||||||||||||
michalkucharczyk marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||
}, | ||||||||||||||||
}; | ||||||||||||||||
michalkucharczyk marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||
|
||||||||||||||||
self.links | ||||||||||||||||
.to_rpc_justif_sender | ||||||||||||||||
|
@@ -1546,8 +1554,10 @@ pub(crate) mod tests { | |||||||||||||||
commitment, | ||||||||||||||||
signatures: vec![None], | ||||||||||||||||
}); | ||||||||||||||||
let hashof10 = | ||||||||||||||||
backend.blockchain().expect_block_hash_from_id(&BlockId::Number(10)).unwrap(); | ||||||||||||||||
backend | ||||||||||||||||
.append_justification(BlockId::Number(10), (BEEFY_ENGINE_ID, justif.encode())) | ||||||||||||||||
.append_justification(&hashof10, (BEEFY_ENGINE_ID, justif.encode())) | ||||||||||||||||
.unwrap(); | ||||||||||||||||
|
||||||||||||||||
// initialize voter at block 13, expect rounds initialized at last beefy finalized 10 | ||||||||||||||||
|
@@ -1580,8 +1590,10 @@ pub(crate) mod tests { | |||||||||||||||
commitment, | ||||||||||||||||
signatures: vec![None], | ||||||||||||||||
}); | ||||||||||||||||
let hashof12 = | ||||||||||||||||
backend.blockchain().expect_block_hash_from_id(&BlockId::Number(12)).unwrap(); | ||||||||||||||||
backend | ||||||||||||||||
.append_justification(BlockId::Number(12), (BEEFY_ENGINE_ID, justif.encode())) | ||||||||||||||||
.append_justification(&hashof12, (BEEFY_ENGINE_ID, justif.encode())) | ||||||||||||||||
.unwrap(); | ||||||||||||||||
|
||||||||||||||||
// initialize voter at block 13, expect rounds initialized at last beefy finalized 12 | ||||||||||||||||
|
This file contains 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.
Something for @acatangiu. Why do we use the block number here as part of the commitment and not the block hash?
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.
All BEEFY voting and justifications/proofs happen on GRANDPA-finalized blocks, therefore block numbers are enough to uniquely identify blocks. (My best guess) block numbers were initially used instead of hashes to lower cognitive complexity when following BEEFY proofs/progress.
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.
Yeah I know.
Hmm okay :P