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
Beefy: use VersionedFinalityProof instead of SignedCommitment #11962
Merged
acatangiu
merged 11 commits into
paritytech:master
from
hzy1919:beefy-use-VersionedFinalityProof-instead-of-SignedCommitment
Aug 4, 2022
Merged
Changes from 3 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
170deb8
beefy: use VersionedFinalityProof instead of SignedCommitment.
hzy1919 9f31a68
Merge branch 'master' into beefy-use-VersionedFinalityProof-instead-o…
hzy1919 5e6ecb1
fmt
hzy1919 887d74c
Update client/beefy/src/worker.rs
hzy1919 62a046c
Update client/beefy/src/worker.rs
hzy1919 987a9d0
Update client/beefy/src/worker.rs
hzy1919 e3daf7f
1.Update tests in beefy-gadget-rpc.
hzy1919 05684ed
merge
hzy1919 3291301
Merge branch 'master' into beefy-use-VersionedFinalityProof-instead-o…
hzy1919 a7a42a1
fmt
hzy1919 150a480
Merge branch 'master' into beefy-use-VersionedFinalityProof-instead-o…
hzy1919 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 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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,7 +16,7 @@ | |
| // You should have received a copy of the GNU General Public License | ||
| // along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
|
|
||
| use beefy_primitives::{crypto::Signature, BeefyApi, VersionedFinalityProof, BEEFY_ENGINE_ID}; | ||
| use beefy_primitives::{BeefyApi, BEEFY_ENGINE_ID}; | ||
| use codec::Encode; | ||
| use log::error; | ||
| use std::{collections::HashMap, sync::Arc}; | ||
|
|
@@ -34,7 +34,8 @@ use sc_client_api::backend::Backend; | |
| use sc_consensus::{BlockCheckParams, BlockImport, BlockImportParams, ImportResult}; | ||
|
|
||
| use crate::{ | ||
| justification::decode_and_verify_commitment, notification::BeefySignedCommitmentSender, | ||
| justification::{decode_and_verify_finality_proof, BeefyVersionedFinalityProof}, | ||
| notification::BeefyVersionedFinalityProofSender, | ||
| }; | ||
|
|
||
| /// A block-import handler for BEEFY. | ||
|
|
@@ -47,7 +48,7 @@ pub struct BeefyBlockImport<Block: BlockT, Backend, RuntimeApi, I> { | |
| backend: Arc<Backend>, | ||
| runtime: Arc<RuntimeApi>, | ||
| inner: I, | ||
| justification_sender: BeefySignedCommitmentSender<Block>, | ||
| justification_sender: BeefyVersionedFinalityProofSender<Block>, | ||
| } | ||
|
|
||
| impl<Block: BlockT, BE, Runtime, I: Clone> Clone for BeefyBlockImport<Block, BE, Runtime, I> { | ||
|
|
@@ -67,7 +68,7 @@ impl<Block: BlockT, BE, Runtime, I> BeefyBlockImport<Block, BE, Runtime, I> { | |
| backend: Arc<BE>, | ||
| runtime: Arc<Runtime>, | ||
| inner: I, | ||
| justification_sender: BeefySignedCommitmentSender<Block>, | ||
| justification_sender: BeefyVersionedFinalityProofSender<Block>, | ||
| ) -> BeefyBlockImport<Block, BE, Runtime, I> { | ||
| BeefyBlockImport { backend, runtime, inner, justification_sender } | ||
| } | ||
|
|
@@ -85,7 +86,7 @@ where | |
| encoded: &EncodedJustification, | ||
| number: NumberFor<Block>, | ||
| hash: <Block as BlockT>::Hash, | ||
| ) -> Result<VersionedFinalityProof<NumberFor<Block>, Signature>, ConsensusError> { | ||
| ) -> Result<BeefyVersionedFinalityProof<Block>, ConsensusError> { | ||
| let block_id = BlockId::hash(hash); | ||
| let validator_set = self | ||
| .runtime | ||
|
|
@@ -94,7 +95,7 @@ where | |
| .map_err(|e| ConsensusError::ClientImport(e.to_string()))? | ||
| .ok_or_else(|| ConsensusError::ClientImport("Unknown validator set".to_string()))?; | ||
|
|
||
| decode_and_verify_commitment::<Block>(&encoded[..], number, &validator_set) | ||
| decode_and_verify_finality_proof::<Block>(&encoded[..], number, &validator_set) | ||
| } | ||
|
|
||
| /// Import BEEFY justification: Send it to worker for processing and also append it to backend. | ||
|
|
@@ -105,7 +106,7 @@ where | |
| fn import_beefy_justification_unchecked( | ||
| &self, | ||
| number: NumberFor<Block>, | ||
| justification: VersionedFinalityProof<NumberFor<Block>, Signature>, | ||
| justification: BeefyVersionedFinalityProof<Block>, | ||
| ) { | ||
| // Append the justification to the block in the backend. | ||
| if let Err(e) = self.backend.append_justification( | ||
|
|
@@ -116,11 +117,9 @@ where | |
| } | ||
| // Send the justification to the BEEFY voter for processing. | ||
| match justification { | ||
| // TODO #11838: Should not unpack, these channels should also use | ||
| // `VersionedFinalityProof`. | ||
| VersionedFinalityProof::V1(signed_commitment) => self | ||
| BeefyVersionedFinalityProof::<Block>::V1(signed_commitment) => self | ||
| .justification_sender | ||
| .notify(|| Ok::<_, ()>(signed_commitment)) | ||
| .notify(|| Ok::<_, ()>(BeefyVersionedFinalityProof::<Block>::V1(signed_commitment))) | ||
|
||
| .expect("forwards closure result; the closure always returns Ok; qed."), | ||
| }; | ||
| } | ||
|
|
||
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
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
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
Oops, something went wrong.
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 would actually change the exposed RPCs too. User facing API should support versioning.
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'll change the exposed RPCs now.