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
Integrate BEEFY #9833
Merged
Merged
Integrate BEEFY #9833
Changes from 109 commits
Commits
Show all changes
111 commits
Select commit
Hold shift + click to select a range
9aa1f2a
Initial project setup and skeleton (#4)
andresilva 539c62d
CI stuff (#5)
tomusdrw f3ab45d
Primitives & Light Client examples (#8)
tomusdrw ea541f9
Update to substrate master (#22)
andresilva cbda281
Add beefy pallet (#25)
andresilva 89c151d
Signed commitments rpc pubsub (#26)
andresilva 3a4cfa8
Integrate MMR and deposit root into the digest. (#24)
tomusdrw e34daee
use new mmr root as commitment payload (#27)
andresilva 0b8fb24
Bump serde_json from 1.0.59 to 1.0.60 (#28)
dependabot-preview[bot] 7aef40c
Update to latest substrate. (#32)
tomusdrw 4b021a2
Bump serde from 1.0.117 to 1.0.118 (#29)
dependabot-preview[bot] 741eb29
Remove transition flag (#35)
tomusdrw 04faa42
Bump futures from 0.3.9 to 0.3.12 (#50)
dependabot-preview[bot] d81a358
Bump log from 0.4.11 to 0.4.13 (#52)
dependabot-preview[bot] a1ed94a
Bump Substrate and Deps (#57)
adoerr e1f86a4
Update README (#58)
adoerr 4f9bd95
Add validator set to the pallet. (#65)
tomusdrw 7bd2795
Bump Substrate and Deps (#71)
adoerr 85d81b2
Beefy pallet test (#74)
adoerr ad86b0e
Beefy node cleanup (#75)
adoerr 162cc4c
Migrate beefy-pallet to FRAMEv2 (#76)
adoerr bb093c9
Run BEEFY worker as non-validator (#77)
adoerr a0706aa
Bump Substrate and Deps (#79)
adoerr 152e588
Add BEEFY gadget as extra peer set (#80)
adoerr 442c741
Add ValidatorSetId to BEEFY digest (#85)
adoerr 66b2b8d
Bump Substrate and Deps (#91)
adoerr 5aef902
Bump serde_json from 1.0.63 to 1.0.64 (#93)
dependabot-preview[bot] 639790a
Track BEEFY validator set (#94)
adoerr 314fa20
Ad 92 (#97)
adoerr 4e2f63a
Add error type (#99)
adoerr ab1039d
Extract worker and round logic (#104)
adoerr 80eaa52
Bump serde from 1.0.123 to 1.0.124 (#106)
dependabot-preview[bot] 64799ea
Rework BeefyAPI (#110)
adoerr e1b3f9b
Initialize BeefyWorker with current validator set (#111)
adoerr 87e5f0d
Update toolchain (#115)
adoerr 7120b62
Bump Substrate and Deps (#117)
adoerr c010f95
Delayed BEEFY worker initialization (#121)
adoerr e343d47
Bump substrate. (#123)
tomusdrw 9e28469
Lower log-level for a missing validator set (#124)
adoerr c88af04
Setup Prometheus metrics (#125)
adoerr 9450b54
Make Client convenience trait public (#126)
adoerr 58fa17c
Bump serde from 1.0.124 to 1.0.125 (#131)
dependabot-preview[bot] 1983235
Reset rounds on new validator set. (#133)
tomusdrw 0092db3
Bump Substrate and Deps (#134)
adoerr 0c02f26
beefy: authority set changes fixes (#139)
andresilva 6ecfeb8
gadget: remove superfluous signature type (#140)
andresilva 69f1f46
gadget: reduce gossip spam (#141)
andresilva 1d94b0f
gadget: verify SignedCommitment message signature (#142)
andresilva d3dd36e
Bump futures from 0.3.13 to 0.3.14 (#145)
dependabot-preview[bot] 75ea15d
Milestone 1 (#144)
adoerr 9da8233
Extract BeefyGossipValidator (#147)
adoerr 40e81a6
Add block_delta parameter to start_beefy_gadget (#151)
adoerr bd3a85f
Add additional metrics (#152)
adoerr 2e9b4bf
don't log under info for every concluded round (#156)
andresilva 6b6a467
don't log error on missing validator keys (#157)
andresilva 11786fc
Fix validator set change handling (#158)
andresilva 5fb0be3
Fix should_vote_on() (#160)
adoerr 8f7f4e2
Make KeyStore optional (#173)
adoerr 532c858
Use builder pattern for NonDefaultSetConfig (#178)
tomaka 088fa19
Append SignedCommitment to block justifications (#177)
adoerr 45acbe1
Bump serde from 1.0.125 to 1.0.126 (#184)
dependabot[bot] bff1de1
Bump strum from 0.20.0 to 0.21.0 (#195)
dependabot[bot] 31043a7
Make concluded round an info log (#200)
adoerr 386855b
Remove external crypto trait bounds (#207)
adoerr 7da9470
Rename AuthorityId to BeefyId to avoid type conflict in UI (#211)
tomusdrw 600f286
Add trace points; Reduce MAX_LIVE_GOSSIP_ROUNDS (#210)
adoerr 8676c10
Additional initial authority id's (#217)
adoerr 2edf07c
Fix note_round() (#219)
adoerr e08e656
Use LocalKeystore for tests (#224)
adoerr b0e0cdb
Cache known votes in gossip (#227)
tomusdrw 9234d02
Some key store sanity checks (#232)
adoerr 9a8773f
Use Binary Merkle Tree instead of a trie (#225)
tomusdrw 5a89c81
Bump Substrate and Deps (#235)
adoerr 3f5de10
BEEFY+MMR pallet (#236)
tomusdrw 40f23ab
Fix noting rounds for non-authorities (#238)
adoerr 03092f8
Bump env_logger from 0.8.4 to 0.9.0 (#242)
dependabot[bot] 66a2ada
gadget: add global timeout for rebroadcasting messages (#243)
andresilva 7114147
Bump Substrate and Deps (#245)
adoerr 90bd59c
Bump futures from 0.3.15 to 0.3.16 (#247)
dependabot[bot] af8bb2e
Bump libsecp256k1 from 0.5.0 to 0.6.0 (#249)
dependabot[bot] b0ac09f
Derive `scale_info::TypeInfo` for types used in polkadot (#218)
ascjones bddaf98
Bump serde from 1.0.126 to 1.0.127 (#260)
dependabot[bot] ef89227
Bump Substrate and Deps (#262)
adoerr a0cc00e
Update jsonrpc (#265)
bkchr ccc148c
bump Substrate and Deps (#268)
adoerr 4274bea
Bump serde from 1.0.127 to 1.0.128 (#272)
dependabot[bot] 6b062b5
Fix spelling (#271)
drewstone 79663a7
Bump serde from 1.0.128 to 1.0.130 (#276)
dependabot[bot] 39fbb7a
Bump scale-info from 0.10.0 to 0.12.0 (#275)
dependabot[bot] 3dd7ea3
Update to scale-info 1.0 (#278)
ascjones 5a271ad
bump substrate (#282)
ordian 81a2d86
Update worker.rs (#287)
drewstone a54f151
Bump anyhow from 1.0.43 to 1.0.44 (#290)
dependabot[bot] b2a2f7f
Remove optional `scale-info` feature (#292)
ascjones fde16c2
prune .git suffix (#294)
JoshOrndorff ec91dc1
remove unused deps (#295)
gilescope 1afb853
Bump libsecp256k1 from 0.6.0 to 0.7.0 (#296)
dependabot[bot] 9dbda20
Merge BEEFY master
adoerr 2ecebb4
clean compile
adoerr 2068171
use path dependencies
adoerr aacad37
beefy-gadget license header
adoerr 9ee380b
pallet-beefy license header
adoerr 144ad93
pallet-beefy-mmr license header
adoerr d256dc4
beefy-primitves license header
adoerr 74eb9cc
carg fmt
adoerr bedf6f3
more formatting
adoerr 0c57822
shorten line
adoerr c41f050
Merge Substrate master
adoerr 41d4774
downgrade parity-scale-codec to 2.2.0
adoerr 4b5e690
use path dependency for Prometheus endpoint
adoerr ea2fd96
remove clippy annotations
adoerr 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
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| [package] | ||
| name = "beefy-gadget" | ||
| version = "4.0.0-dev" | ||
| authors = ["Parity Technologies <[email protected]>"] | ||
| edition = "2018" | ||
| license = "GPL-3.0-or-later WITH Classpath-exception-2.0" | ||
|
|
||
| [dependencies] | ||
| fnv = "1.0.6" | ||
| futures = "0.3" | ||
| log = "0.4" | ||
| parking_lot = "0.11" | ||
| thiserror = "1.0" | ||
| wasm-timer = "0.2.5" | ||
|
|
||
| codec = { version = "2.2.0", package = "parity-scale-codec", features = ["derive"] } | ||
| prometheus = { package = "substrate-prometheus-endpoint", git = "https://github.com/paritytech/substrate", branch = "master" } | ||
|
|
||
| sp-api = { version = "4.0.0-dev", path = "../../primitives/api" } | ||
| sp-application-crypto = { version = "4.0.0-dev", path = "../../primitives/application-crypto" } | ||
| sp-arithmetic = { version = "4.0.0-dev", path = "../../primitives/arithmetic" } | ||
| sp-blockchain = { version = "4.0.0-dev", path = "../../primitives/blockchain" } | ||
| sp-core = { version = "4.0.0-dev", path = "../../primitives/core" } | ||
| sp-keystore = { version = "0.10.0-dev", path = "../../primitives/keystore" } | ||
| sp-runtime = { version = "4.0.0-dev", path = "../../primitives/runtime" } | ||
|
|
||
| sc-utils = { version = "4.0.0-dev", path = "../utils" } | ||
| sc-client-api = { version = "4.0.0-dev", path = "../api" } | ||
| sc-keystore = { version = "4.0.0-dev", path = "../keystore" } | ||
| sc-network = { version = "0.10.0-dev", path = "../network" } | ||
| sc-network-gossip = { version = "0.10.0-dev", path = "../network-gossip" } | ||
|
|
||
| beefy-primitives = { version = "4.0.0-dev", path = "../../primitives/beefy" } | ||
|
|
||
| [dev-dependencies] | ||
| sc-network-test = { version = "0.8.0", path = "../network/test" } | ||
|
|
||
| strum = { version = "0.21", features = ["derive"] } | ||
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 |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| [package] | ||
| name = "beefy-gadget-rpc" | ||
| version = "4.0.0-dev" | ||
| authors = ["Parity Technologies <[email protected]>"] | ||
| edition = "2018" | ||
| license = "GPL-3.0-or-later WITH Classpath-exception-2.0" | ||
|
|
||
| [dependencies] | ||
| futures = "0.3.16" | ||
| log = "0.4" | ||
| serde = { version = "1.0.130", features = ["derive"] } | ||
|
|
||
| jsonrpc-core = "18.0.0" | ||
| jsonrpc-core-client = "18.0.0" | ||
| jsonrpc-derive = "18.0.0" | ||
| jsonrpc-pubsub = "18.0.0" | ||
|
|
||
| codec = { version = "2.2.0", package = "parity-scale-codec", features = ["derive"] } | ||
|
|
||
| sc-rpc = { version = "4.0.0-dev", path = "../../rpc" } | ||
|
|
||
| sp-core = { version = "4.0.0-dev", path = "../../../primitives/core" } | ||
| sp-runtime = { versin = "4.0.0-dev", path = "../../../primitives/runtime" } | ||
|
|
||
| beefy-gadget = { version = "4.0.0-dev", path = "../." } | ||
| beefy-primitives = { version = "4.0.0-dev", path = "../../../primitives/beefy" } |
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 |
|---|---|---|
| @@ -0,0 +1,115 @@ | ||
| // This file is part of Substrate. | ||
|
|
||
| // Copyright (C) 2021 Parity Technologies (UK) Ltd. | ||
| // SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 | ||
|
|
||
| // This program is free software: you can redistribute it and/or modify | ||
| // it under the terms of the GNU General Public License as published by | ||
| // the Free Software Foundation, either version 3 of the License, or | ||
| // (at your option) any later version. | ||
|
|
||
| // This program is distributed in the hope that it will be useful, | ||
| // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| // GNU General Public License for more details. | ||
|
|
||
| // You should have received a copy of the GNU General Public License | ||
| // along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
|
|
||
| //! RPC API for BEEFY. | ||
|
|
||
| #![warn(missing_docs)] | ||
|
|
||
| use std::sync::Arc; | ||
|
|
||
| use sp_runtime::traits::Block as BlockT; | ||
|
|
||
| use futures::{FutureExt, SinkExt, StreamExt}; | ||
| use jsonrpc_derive::rpc; | ||
| use jsonrpc_pubsub::{manager::SubscriptionManager, typed::Subscriber, SubscriptionId}; | ||
| use log::warn; | ||
|
|
||
| use beefy_gadget::notification::BeefySignedCommitmentStream; | ||
|
|
||
| mod notification; | ||
|
|
||
| /// Provides RPC methods for interacting with BEEFY. | ||
| #[allow(clippy::needless_return)] | ||
| #[rpc] | ||
| pub trait BeefyApi<Notification, Hash> { | ||
| /// RPC Metadata | ||
| type Metadata; | ||
|
|
||
| /// Returns the block most recently finalized by BEEFY, alongside side its justification. | ||
| #[pubsub( | ||
| subscription = "beefy_justifications", | ||
| subscribe, | ||
| name = "beefy_subscribeJustifications" | ||
| )] | ||
| fn subscribe_justifications( | ||
| &self, | ||
| metadata: Self::Metadata, | ||
| subscriber: Subscriber<Notification>, | ||
| ); | ||
|
|
||
| /// Unsubscribe from receiving notifications about recently finalized blocks. | ||
| #[pubsub( | ||
| subscription = "beefy_justifications", | ||
| unsubscribe, | ||
| name = "beefy_unsubscribeJustifications" | ||
| )] | ||
| fn unsubscribe_justifications( | ||
| &self, | ||
| metadata: Option<Self::Metadata>, | ||
| id: SubscriptionId, | ||
| ) -> jsonrpc_core::Result<bool>; | ||
| } | ||
|
|
||
| /// Implements the BeefyApi RPC trait for interacting with BEEFY. | ||
| pub struct BeefyRpcHandler<Block: BlockT> { | ||
| signed_commitment_stream: BeefySignedCommitmentStream<Block>, | ||
| manager: SubscriptionManager, | ||
| } | ||
|
|
||
| impl<Block: BlockT> BeefyRpcHandler<Block> { | ||
| /// Creates a new BeefyRpcHandler instance. | ||
| pub fn new<E>(signed_commitment_stream: BeefySignedCommitmentStream<Block>, executor: E) -> Self | ||
| where | ||
| E: futures::task::Spawn + Send + Sync + 'static, | ||
| { | ||
| let manager = SubscriptionManager::new(Arc::new(executor)); | ||
| Self { signed_commitment_stream, manager } | ||
| } | ||
| } | ||
|
|
||
| impl<Block> BeefyApi<notification::SignedCommitment, Block> for BeefyRpcHandler<Block> | ||
| where | ||
| Block: BlockT, | ||
| { | ||
| type Metadata = sc_rpc::Metadata; | ||
|
|
||
| fn subscribe_justifications( | ||
| &self, | ||
| _metadata: Self::Metadata, | ||
| subscriber: Subscriber<notification::SignedCommitment>, | ||
| ) { | ||
| let stream = self | ||
| .signed_commitment_stream | ||
| .subscribe() | ||
| .map(|x| Ok::<_, ()>(Ok(notification::SignedCommitment::new::<Block>(x)))); | ||
|
|
||
| self.manager.add(subscriber, |sink| { | ||
| stream | ||
| .forward(sink.sink_map_err(|e| warn!("Error sending notifications: {:?}", e))) | ||
| .map(|_| ()) | ||
| }); | ||
| } | ||
|
|
||
| fn unsubscribe_justifications( | ||
| &self, | ||
| _metadata: Option<Self::Metadata>, | ||
| id: SubscriptionId, | ||
| ) -> jsonrpc_core::Result<bool> { | ||
| Ok(self.manager.cancel(id)) | ||
| } | ||
| } |
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 |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| // This file is part of Substrate. | ||
|
|
||
| // Copyright (C) 2021 Parity Technologies (UK) Ltd. | ||
| // SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 | ||
|
|
||
| // This program is free software: you can redistribute it and/or modify | ||
| // it under the terms of the GNU General Public License as published by | ||
| // the Free Software Foundation, either version 3 of the License, or | ||
| // (at your option) any later version. | ||
|
|
||
| // This program is distributed in the hope that it will be useful, | ||
| // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| // GNU General Public License for more details. | ||
|
|
||
| // 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 codec::Encode; | ||
| use serde::{Deserialize, Serialize}; | ||
|
|
||
| use sp_runtime::traits::Block as BlockT; | ||
|
|
||
| /// An encoded signed commitment proving that the given header has been finalized. | ||
| /// The given bytes should be the SCALE-encoded representation of a | ||
| /// `beefy_primitives::SignedCommitment`. | ||
| #[derive(Clone, Serialize, Deserialize)] | ||
| pub struct SignedCommitment(sp_core::Bytes); | ||
|
|
||
| impl SignedCommitment { | ||
| pub fn new<Block>( | ||
| signed_commitment: beefy_gadget::notification::SignedCommitment<Block>, | ||
| ) -> Self | ||
| where | ||
| Block: BlockT, | ||
| { | ||
| SignedCommitment(signed_commitment.encode().into()) | ||
| } | ||
| } |
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 |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| // This file is part of Substrate. | ||
|
|
||
| // Copyright (C) 2021 Parity Technologies (UK) Ltd. | ||
| // SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 | ||
|
|
||
| // This program is free software: you can redistribute it and/or modify | ||
| // it under the terms of the GNU General Public License as published by | ||
| // the Free Software Foundation, either version 3 of the License, or | ||
| // (at your option) any later version. | ||
|
|
||
| // This program is distributed in the hope that it will be useful, | ||
| // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| // GNU General Public License for more details. | ||
|
|
||
| // You should have received a copy of the GNU General Public License | ||
| // along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
|
|
||
| //! BEEFY gadget specific errors | ||
| //! | ||
| //! Used for BEEFY gadget interal error handling only | ||
|
|
||
| use std::fmt::Debug; | ||
|
|
||
| #[derive(Debug, thiserror::Error, PartialEq)] | ||
| pub enum Error { | ||
| #[error("Keystore error: {0}")] | ||
| Keystore(String), | ||
| #[error("Signature error: {0}")] | ||
| Signature(String), | ||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.