mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 00:41:08 +00:00
Move BEEFY code to consensus (#13484)
* Move beefy primitives to consensus dir * Move beefy gadget to client consensus folder * Rename beefy crates
This commit is contained in:
Generated
+87
-87
@@ -493,69 +493,6 @@ dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "beefy-gadget"
|
||||
version = "4.0.0-dev"
|
||||
dependencies = [
|
||||
"array-bytes",
|
||||
"async-trait",
|
||||
"fnv",
|
||||
"futures",
|
||||
"log",
|
||||
"parity-scale-codec",
|
||||
"parking_lot 0.12.1",
|
||||
"sc-block-builder",
|
||||
"sc-client-api",
|
||||
"sc-consensus",
|
||||
"sc-keystore",
|
||||
"sc-network",
|
||||
"sc-network-common",
|
||||
"sc-network-gossip",
|
||||
"sc-network-test",
|
||||
"sc-utils",
|
||||
"serde",
|
||||
"sp-api",
|
||||
"sp-application-crypto",
|
||||
"sp-arithmetic",
|
||||
"sp-beefy",
|
||||
"sp-blockchain",
|
||||
"sp-consensus",
|
||||
"sp-consensus-grandpa",
|
||||
"sp-core",
|
||||
"sp-keyring",
|
||||
"sp-keystore",
|
||||
"sp-mmr-primitives",
|
||||
"sp-runtime",
|
||||
"sp-tracing",
|
||||
"substrate-prometheus-endpoint",
|
||||
"substrate-test-runtime-client",
|
||||
"tempfile",
|
||||
"thiserror",
|
||||
"tokio",
|
||||
"wasm-timer",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "beefy-gadget-rpc"
|
||||
version = "4.0.0-dev"
|
||||
dependencies = [
|
||||
"beefy-gadget",
|
||||
"futures",
|
||||
"jsonrpsee",
|
||||
"log",
|
||||
"parity-scale-codec",
|
||||
"parking_lot 0.12.1",
|
||||
"sc-rpc",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"sp-beefy",
|
||||
"sp-core",
|
||||
"sp-runtime",
|
||||
"substrate-test-runtime-client",
|
||||
"thiserror",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "binary-merkle-tree"
|
||||
version = "4.0.0-dev"
|
||||
@@ -4492,9 +4429,9 @@ dependencies = [
|
||||
"sc-client-api",
|
||||
"sc-offchain",
|
||||
"sp-api",
|
||||
"sp-beefy",
|
||||
"sp-blockchain",
|
||||
"sp-consensus",
|
||||
"sp-consensus-beefy",
|
||||
"sp-core",
|
||||
"sp-mmr-primitives",
|
||||
"sp-runtime",
|
||||
@@ -5555,7 +5492,7 @@ dependencies = [
|
||||
"parity-scale-codec",
|
||||
"scale-info",
|
||||
"serde",
|
||||
"sp-beefy",
|
||||
"sp-consensus-beefy",
|
||||
"sp-core",
|
||||
"sp-io",
|
||||
"sp-runtime",
|
||||
@@ -5580,7 +5517,7 @@ dependencies = [
|
||||
"scale-info",
|
||||
"serde",
|
||||
"sp-api",
|
||||
"sp-beefy",
|
||||
"sp-consensus-beefy",
|
||||
"sp-core",
|
||||
"sp-io",
|
||||
"sp-runtime",
|
||||
@@ -8333,6 +8270,69 @@ dependencies = [
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sc-consensus-beefy"
|
||||
version = "4.0.0-dev"
|
||||
dependencies = [
|
||||
"array-bytes",
|
||||
"async-trait",
|
||||
"fnv",
|
||||
"futures",
|
||||
"log",
|
||||
"parity-scale-codec",
|
||||
"parking_lot 0.12.1",
|
||||
"sc-block-builder",
|
||||
"sc-client-api",
|
||||
"sc-consensus",
|
||||
"sc-keystore",
|
||||
"sc-network",
|
||||
"sc-network-common",
|
||||
"sc-network-gossip",
|
||||
"sc-network-test",
|
||||
"sc-utils",
|
||||
"serde",
|
||||
"sp-api",
|
||||
"sp-application-crypto",
|
||||
"sp-arithmetic",
|
||||
"sp-blockchain",
|
||||
"sp-consensus",
|
||||
"sp-consensus-beefy",
|
||||
"sp-consensus-grandpa",
|
||||
"sp-core",
|
||||
"sp-keyring",
|
||||
"sp-keystore",
|
||||
"sp-mmr-primitives",
|
||||
"sp-runtime",
|
||||
"sp-tracing",
|
||||
"substrate-prometheus-endpoint",
|
||||
"substrate-test-runtime-client",
|
||||
"tempfile",
|
||||
"thiserror",
|
||||
"tokio",
|
||||
"wasm-timer",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sc-consensus-beefy-rpc"
|
||||
version = "4.0.0-dev"
|
||||
dependencies = [
|
||||
"futures",
|
||||
"jsonrpsee",
|
||||
"log",
|
||||
"parity-scale-codec",
|
||||
"parking_lot 0.12.1",
|
||||
"sc-consensus-beefy",
|
||||
"sc-rpc",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"sp-consensus-beefy",
|
||||
"sp-core",
|
||||
"sp-runtime",
|
||||
"substrate-test-runtime-client",
|
||||
"thiserror",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sc-consensus-epochs"
|
||||
version = "0.10.0-dev"
|
||||
@@ -9829,26 +9829,6 @@ dependencies = [
|
||||
"sp-std",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sp-beefy"
|
||||
version = "4.0.0-dev"
|
||||
dependencies = [
|
||||
"array-bytes",
|
||||
"lazy_static",
|
||||
"parity-scale-codec",
|
||||
"scale-info",
|
||||
"serde",
|
||||
"sp-api",
|
||||
"sp-application-crypto",
|
||||
"sp-core",
|
||||
"sp-io",
|
||||
"sp-keystore",
|
||||
"sp-mmr-primitives",
|
||||
"sp-runtime",
|
||||
"sp-std",
|
||||
"strum",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sp-block-builder"
|
||||
version = "4.0.0-dev"
|
||||
@@ -9934,6 +9914,26 @@ dependencies = [
|
||||
"sp-timestamp",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sp-consensus-beefy"
|
||||
version = "4.0.0-dev"
|
||||
dependencies = [
|
||||
"array-bytes",
|
||||
"lazy_static",
|
||||
"parity-scale-codec",
|
||||
"scale-info",
|
||||
"serde",
|
||||
"sp-api",
|
||||
"sp-application-crypto",
|
||||
"sp-core",
|
||||
"sp-io",
|
||||
"sp-keystore",
|
||||
"sp-mmr-primitives",
|
||||
"sp-runtime",
|
||||
"sp-std",
|
||||
"strum",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sp-consensus-grandpa"
|
||||
version = "4.0.0-dev"
|
||||
@@ -10837,11 +10837,11 @@ dependencies = [
|
||||
"serde",
|
||||
"sp-api",
|
||||
"sp-application-crypto",
|
||||
"sp-beefy",
|
||||
"sp-block-builder",
|
||||
"sp-consensus",
|
||||
"sp-consensus-aura",
|
||||
"sp-consensus-babe",
|
||||
"sp-consensus-beefy",
|
||||
"sp-consensus-grandpa",
|
||||
"sp-core",
|
||||
"sp-externalities",
|
||||
|
||||
@@ -18,8 +18,6 @@ members = [
|
||||
"client/api",
|
||||
"client/authority-discovery",
|
||||
"client/basic-authorship",
|
||||
"client/beefy",
|
||||
"client/beefy/rpc",
|
||||
"client/block-builder",
|
||||
"client/chain-spec",
|
||||
"client/chain-spec/derive",
|
||||
@@ -27,6 +25,8 @@ members = [
|
||||
"client/consensus/aura",
|
||||
"client/consensus/babe",
|
||||
"client/consensus/babe/rpc",
|
||||
"client/consensus/beefy",
|
||||
"client/consensus/beefy/rpc",
|
||||
"client/consensus/common",
|
||||
"client/consensus/epochs",
|
||||
"client/consensus/grandpa",
|
||||
@@ -178,11 +178,11 @@ members = [
|
||||
"primitives/arithmetic",
|
||||
"primitives/arithmetic/fuzzer",
|
||||
"primitives/authority-discovery",
|
||||
"primitives/beefy",
|
||||
"primitives/block-builder",
|
||||
"primitives/blockchain",
|
||||
"primitives/consensus/aura",
|
||||
"primitives/consensus/babe",
|
||||
"primitives/consensus/beefy",
|
||||
"primitives/consensus/common",
|
||||
"primitives/consensus/grandpa",
|
||||
"primitives/consensus/pow",
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
[package]
|
||||
name = "beefy-gadget"
|
||||
version = "4.0.0-dev"
|
||||
authors = ["Parity Technologies <admin@parity.io>"]
|
||||
edition = "2021"
|
||||
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
||||
repository = "https://github.com/paritytech/substrate"
|
||||
description = "BEEFY Client gadget for substrate"
|
||||
homepage = "https://substrate.io"
|
||||
|
||||
[dependencies]
|
||||
array-bytes = "4.1"
|
||||
async-trait = "0.1.57"
|
||||
codec = { package = "parity-scale-codec", version = "3.2.2", features = ["derive"] }
|
||||
fnv = "1.0.6"
|
||||
futures = "0.3"
|
||||
log = "0.4"
|
||||
parking_lot = "0.12.1"
|
||||
thiserror = "1.0"
|
||||
wasm-timer = "0.2.5"
|
||||
beefy-primitives = { version = "4.0.0-dev", path = "../../primitives/beefy", package = "sp-beefy" }
|
||||
prometheus = { package = "substrate-prometheus-endpoint", version = "0.10.0-dev", path = "../../utils/prometheus" }
|
||||
sc-client-api = { version = "4.0.0-dev", path = "../api" }
|
||||
sc-consensus = { version = "0.10.0-dev", path = "../consensus/common" }
|
||||
sc-keystore = { version = "4.0.0-dev", path = "../keystore" }
|
||||
sc-network = { version = "0.10.0-dev", path = "../network" }
|
||||
sc-network-common = { version = "0.10.0-dev", path = "../network/common" }
|
||||
sc-network-gossip = { version = "0.10.0-dev", path = "../network-gossip" }
|
||||
sc-utils = { version = "4.0.0-dev", path = "../utils" }
|
||||
sp-api = { version = "4.0.0-dev", path = "../../primitives/api" }
|
||||
sp-application-crypto = { version = "7.0.0", path = "../../primitives/application-crypto" }
|
||||
sp-arithmetic = { version = "6.0.0", path = "../../primitives/arithmetic" }
|
||||
sp-blockchain = { version = "4.0.0-dev", path = "../../primitives/blockchain" }
|
||||
sp-consensus = { version = "0.10.0-dev", path = "../../primitives/consensus/common" }
|
||||
sp-core = { version = "7.0.0", path = "../../primitives/core" }
|
||||
sp-keystore = { version = "0.13.0", path = "../../primitives/keystore" }
|
||||
sp-mmr-primitives = { version = "4.0.0-dev", path = "../../primitives/merkle-mountain-range" }
|
||||
sp-runtime = { version = "7.0.0", path = "../../primitives/runtime" }
|
||||
|
||||
[dev-dependencies]
|
||||
serde = "1.0.136"
|
||||
tempfile = "3.1.0"
|
||||
tokio = "1.22.0"
|
||||
sc-block-builder = { version = "0.10.0-dev", path = "../block-builder" }
|
||||
sc-network-test = { version = "0.8.0", path = "../network/test" }
|
||||
sp-consensus-grandpa = { version = "4.0.0-dev", path = "../../primitives/consensus/grandpa" }
|
||||
sp-keyring = { version = "7.0.0", path = "../../primitives/keyring" }
|
||||
sp-tracing = { version = "6.0.0", path = "../../primitives/tracing" }
|
||||
substrate-test-runtime-client = { version = "2.0.0", path = "../../test-utils/runtime/client" }
|
||||
@@ -0,0 +1,49 @@
|
||||
[package]
|
||||
name = "sc-consensus-beefy"
|
||||
version = "4.0.0-dev"
|
||||
authors = ["Parity Technologies <admin@parity.io>"]
|
||||
edition = "2021"
|
||||
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
||||
repository = "https://github.com/paritytech/substrate"
|
||||
description = "BEEFY Client gadget for substrate"
|
||||
homepage = "https://substrate.io"
|
||||
|
||||
[dependencies]
|
||||
array-bytes = "4.1"
|
||||
async-trait = "0.1.57"
|
||||
codec = { package = "parity-scale-codec", version = "3.2.2", features = ["derive"] }
|
||||
fnv = "1.0.6"
|
||||
futures = "0.3"
|
||||
log = "0.4"
|
||||
parking_lot = "0.12.1"
|
||||
thiserror = "1.0"
|
||||
wasm-timer = "0.2.5"
|
||||
prometheus = { package = "substrate-prometheus-endpoint", version = "0.10.0-dev", path = "../../../utils/prometheus" }
|
||||
sc-client-api = { version = "4.0.0-dev", path = "../../api" }
|
||||
sc-consensus = { version = "0.10.0-dev", path = "../../consensus/common" }
|
||||
sc-keystore = { version = "4.0.0-dev", path = "../../keystore" }
|
||||
sc-network = { version = "0.10.0-dev", path = "../../network" }
|
||||
sc-network-common = { version = "0.10.0-dev", path = "../../network/common" }
|
||||
sc-network-gossip = { version = "0.10.0-dev", path = "../../network-gossip" }
|
||||
sc-utils = { version = "4.0.0-dev", path = "../../utils" }
|
||||
sp-api = { version = "4.0.0-dev", path = "../../../primitives/api" }
|
||||
sp-application-crypto = { version = "7.0.0", path = "../../../primitives/application-crypto" }
|
||||
sp-arithmetic = { version = "6.0.0", path = "../../../primitives/arithmetic" }
|
||||
sp-blockchain = { version = "4.0.0-dev", path = "../../../primitives/blockchain" }
|
||||
sp-consensus = { version = "0.10.0-dev", path = "../../../primitives/consensus/common" }
|
||||
sp-consensus-beefy = { version = "4.0.0-dev", path = "../../../primitives/consensus/beefy" }
|
||||
sp-core = { version = "7.0.0", path = "../../../primitives/core" }
|
||||
sp-keystore = { version = "0.13.0", path = "../../../primitives/keystore" }
|
||||
sp-mmr-primitives = { version = "4.0.0-dev", path = "../../../primitives/merkle-mountain-range" }
|
||||
sp-runtime = { version = "7.0.0", path = "../../../primitives/runtime" }
|
||||
|
||||
[dev-dependencies]
|
||||
serde = "1.0.136"
|
||||
tempfile = "3.1.0"
|
||||
tokio = "1.22.0"
|
||||
sc-block-builder = { version = "0.10.0-dev", path = "../../block-builder" }
|
||||
sc-network-test = { version = "0.8.0", path = "../../network/test" }
|
||||
sp-consensus-grandpa = { version = "4.0.0-dev", path = "../../../primitives/consensus/grandpa" }
|
||||
sp-keyring = { version = "7.0.0", path = "../../../primitives/keyring" }
|
||||
sp-tracing = { version = "6.0.0", path = "../../../primitives/tracing" }
|
||||
substrate-test-runtime-client = { version = "2.0.0", path = "../../../test-utils/runtime/client" }
|
||||
+8
-10
@@ -1,5 +1,5 @@
|
||||
[package]
|
||||
name = "beefy-gadget-rpc"
|
||||
name = "sc-consensus-beefy-rpc"
|
||||
version = "4.0.0-dev"
|
||||
authors = ["Parity Technologies <admin@parity.io>"]
|
||||
edition = "2021"
|
||||
@@ -16,16 +16,14 @@ log = "0.4"
|
||||
parking_lot = "0.12.1"
|
||||
serde = { version = "1.0.136", features = ["derive"] }
|
||||
thiserror = "1.0"
|
||||
beefy-gadget = { version = "4.0.0-dev", path = "../." }
|
||||
beefy-primitives = { version = "4.0.0-dev", path = "../../../primitives/beefy", package = "sp-beefy" }
|
||||
sc-rpc = { version = "4.0.0-dev", path = "../../rpc" }
|
||||
sp-core = { version = "7.0.0", path = "../../../primitives/core" }
|
||||
sp-runtime = { version = "7.0.0", path = "../../../primitives/runtime" }
|
||||
sc-consensus-beefy = { version = "4.0.0-dev", path = "../" }
|
||||
sp-consensus-beefy = { version = "4.0.0-dev", path = "../../../../primitives/consensus/beefy" }
|
||||
sc-rpc = { version = "4.0.0-dev", path = "../../../rpc" }
|
||||
sp-core = { version = "7.0.0", path = "../../../../primitives/core" }
|
||||
sp-runtime = { version = "7.0.0", path = "../../../../primitives/runtime" }
|
||||
|
||||
[dev-dependencies]
|
||||
serde_json = "1.0.85"
|
||||
sc-rpc = { version = "4.0.0-dev", features = [
|
||||
"test-helpers",
|
||||
], path = "../../rpc" }
|
||||
substrate-test-runtime-client = { version = "2.0.0", path = "../../../test-utils/runtime/client" }
|
||||
sc-rpc = { version = "4.0.0-dev", features = ["test-helpers"], path = "../../../rpc" }
|
||||
substrate-test-runtime-client = { version = "2.0.0", path = "../../../../test-utils/runtime/client" }
|
||||
tokio = { version = "1.22.0", features = ["macros"] }
|
||||
+6
-6
@@ -35,7 +35,7 @@ use jsonrpsee::{
|
||||
};
|
||||
use log::warn;
|
||||
|
||||
use beefy_gadget::communication::notification::{
|
||||
use sc_consensus_beefy::communication::notification::{
|
||||
BeefyBestBlockStream, BeefyVersionedFinalityProofStream,
|
||||
};
|
||||
|
||||
@@ -166,13 +166,13 @@ where
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
use beefy_gadget::{
|
||||
use codec::{Decode, Encode};
|
||||
use jsonrpsee::{types::EmptyServerParams as EmptyParams, RpcModule};
|
||||
use sc_consensus_beefy::{
|
||||
communication::notification::BeefyVersionedFinalityProofSender,
|
||||
justification::BeefyVersionedFinalityProof,
|
||||
};
|
||||
use beefy_primitives::{known_payloads, Payload, SignedCommitment};
|
||||
use codec::{Decode, Encode};
|
||||
use jsonrpsee::{types::EmptyServerParams as EmptyParams, RpcModule};
|
||||
use sp_consensus_beefy::{known_payloads, Payload, SignedCommitment};
|
||||
use sp_runtime::traits::{BlakeTwo256, Hash};
|
||||
use substrate_test_runtime_client::runtime::Block;
|
||||
|
||||
@@ -269,7 +269,7 @@ mod tests {
|
||||
let payload =
|
||||
Payload::from_single_entry(known_payloads::MMR_ROOT_ID, "Hello World!".encode());
|
||||
BeefyVersionedFinalityProof::<Block>::V1(SignedCommitment {
|
||||
commitment: beefy_primitives::Commitment {
|
||||
commitment: sp_consensus_beefy::Commitment {
|
||||
payload,
|
||||
block_number: 5,
|
||||
validator_set_id: 0,
|
||||
+2
-2
@@ -23,13 +23,13 @@ use sp_runtime::traits::Block as BlockT;
|
||||
|
||||
/// An encoded finality proof proving that the given header has been finalized.
|
||||
/// The given bytes should be the SCALE-encoded representation of a
|
||||
/// `beefy_primitives::VersionedFinalityProof`.
|
||||
/// `sp_consensus_beefy::VersionedFinalityProof`.
|
||||
#[derive(Clone, Serialize, Deserialize)]
|
||||
pub struct EncodedVersionedFinalityProof(sp_core::Bytes);
|
||||
|
||||
impl EncodedVersionedFinalityProof {
|
||||
pub fn new<Block>(
|
||||
finality_proof: beefy_gadget::justification::BeefyVersionedFinalityProof<Block>,
|
||||
finality_proof: sc_consensus_beefy::justification::BeefyVersionedFinalityProof<Block>,
|
||||
) -> Self
|
||||
where
|
||||
Block: BlockT,
|
||||
+2
-2
@@ -29,7 +29,7 @@ use parking_lot::{Mutex, RwLock};
|
||||
use wasm_timer::Instant;
|
||||
|
||||
use crate::{communication::peers::KnownPeers, keystore::BeefyKeystore, LOG_TARGET};
|
||||
use beefy_primitives::{
|
||||
use sp_consensus_beefy::{
|
||||
crypto::{Public, Signature},
|
||||
VoteMessage,
|
||||
};
|
||||
@@ -243,7 +243,7 @@ mod tests {
|
||||
use sp_keystore::{SyncCryptoStore, SyncCryptoStorePtr};
|
||||
|
||||
use crate::keystore::BeefyKeystore;
|
||||
use beefy_primitives::{
|
||||
use sp_consensus_beefy::{
|
||||
crypto::Signature, known_payloads, Commitment, Keyring, MmrRootHash, Payload, VoteMessage,
|
||||
KEY_TYPE,
|
||||
};
|
||||
+1
-1
@@ -16,7 +16,6 @@
|
||||
|
||||
//! Helper for handling (i.e. answering) BEEFY justifications requests from a remote peer.
|
||||
|
||||
use beefy_primitives::BEEFY_ENGINE_ID;
|
||||
use codec::Decode;
|
||||
use futures::{
|
||||
channel::{mpsc, oneshot},
|
||||
@@ -26,6 +25,7 @@ use log::{debug, trace};
|
||||
use sc_client_api::BlockBackend;
|
||||
use sc_network::{config as netconfig, config::RequestResponseConfig, PeerId, ReputationChange};
|
||||
use sc_network_common::protocol::ProtocolName;
|
||||
use sp_consensus_beefy::BEEFY_ENGINE_ID;
|
||||
use sp_runtime::traits::Block;
|
||||
use std::{marker::PhantomData, sync::Arc};
|
||||
|
||||
+1
-1
@@ -18,7 +18,6 @@
|
||||
|
||||
//! Generating request logic for request/response protocol for syncing BEEFY justifications.
|
||||
|
||||
use beefy_primitives::{crypto::AuthorityId, ValidatorSet};
|
||||
use codec::Encode;
|
||||
use futures::channel::{oneshot, oneshot::Canceled};
|
||||
use log::{debug, warn};
|
||||
@@ -28,6 +27,7 @@ use sc_network_common::{
|
||||
request_responses::{IfDisconnected, RequestFailure},
|
||||
service::NetworkRequest,
|
||||
};
|
||||
use sp_consensus_beefy::{crypto::AuthorityId, ValidatorSet};
|
||||
use sp_runtime::traits::{Block, NumberFor};
|
||||
use std::{collections::VecDeque, result::Result, sync::Arc};
|
||||
|
||||
+1
-1
@@ -16,8 +16,8 @@
|
||||
// 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::{BeefyApi, BEEFY_ENGINE_ID};
|
||||
use log::debug;
|
||||
use sp_consensus_beefy::{BeefyApi, BEEFY_ENGINE_ID};
|
||||
use std::{collections::HashMap, sync::Arc};
|
||||
|
||||
use sp_api::{ProvideRuntimeApi, TransactionFor};
|
||||
+5
-5
@@ -17,17 +17,17 @@
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::keystore::BeefyKeystore;
|
||||
use beefy_primitives::{
|
||||
use codec::{Decode, Encode};
|
||||
use sp_consensus::Error as ConsensusError;
|
||||
use sp_consensus_beefy::{
|
||||
crypto::{AuthorityId, Signature},
|
||||
ValidatorSet, VersionedFinalityProof,
|
||||
};
|
||||
use codec::{Decode, Encode};
|
||||
use sp_consensus::Error as ConsensusError;
|
||||
use sp_runtime::traits::{Block as BlockT, NumberFor};
|
||||
|
||||
/// A finality proof with matching BEEFY authorities' signatures.
|
||||
pub type BeefyVersionedFinalityProof<Block> =
|
||||
beefy_primitives::VersionedFinalityProof<NumberFor<Block>, Signature>;
|
||||
sp_consensus_beefy::VersionedFinalityProof<NumberFor<Block>, Signature>;
|
||||
|
||||
/// Decode and verify a Beefy FinalityProof.
|
||||
pub(crate) fn decode_and_verify_finality_proof<Block: BlockT>(
|
||||
@@ -80,7 +80,7 @@ fn verify_with_validator_set<Block: BlockT>(
|
||||
|
||||
#[cfg(test)]
|
||||
pub(crate) mod tests {
|
||||
use beefy_primitives::{
|
||||
use sp_consensus_beefy::{
|
||||
known_payloads, Commitment, Keyring, Payload, SignedCommitment, VersionedFinalityProof,
|
||||
};
|
||||
use substrate_test_runtime_client::runtime::Block;
|
||||
+4
-4
@@ -22,7 +22,7 @@ use sp_keystore::{SyncCryptoStore, SyncCryptoStorePtr};
|
||||
|
||||
use log::warn;
|
||||
|
||||
use beefy_primitives::{
|
||||
use sp_consensus_beefy::{
|
||||
crypto::{Public, Signature},
|
||||
BeefyAuthorityId, KEY_TYPE,
|
||||
};
|
||||
@@ -89,8 +89,8 @@ impl BeefyKeystore {
|
||||
Ok(sig)
|
||||
}
|
||||
|
||||
/// Returns a vector of [`beefy_primitives::crypto::Public`] keys which are currently supported
|
||||
/// (i.e. found in the keystore).
|
||||
/// Returns a vector of [`sp_consensus_beefy::crypto::Public`] keys which are currently
|
||||
/// supported (i.e. found in the keystore).
|
||||
pub fn public_keys(&self) -> Result<Vec<Public>, error::Error> {
|
||||
let store = self.0.clone().ok_or_else(|| error::Error::Keystore("no Keystore".into()))?;
|
||||
|
||||
@@ -123,7 +123,7 @@ pub mod tests {
|
||||
use sc_keystore::LocalKeystore;
|
||||
use sp_core::{ecdsa, Pair};
|
||||
|
||||
use beefy_primitives::{crypto, Keyring};
|
||||
use sp_consensus_beefy::{crypto, Keyring};
|
||||
|
||||
use super::*;
|
||||
use crate::error::Error;
|
||||
@@ -32,10 +32,6 @@ use crate::{
|
||||
round::Rounds,
|
||||
worker::PersistedState,
|
||||
};
|
||||
use beefy_primitives::{
|
||||
crypto::AuthorityId, BeefyApi, MmrRootHash, PayloadProvider, ValidatorSet, BEEFY_ENGINE_ID,
|
||||
GENESIS_AUTHORITY_SET_ID,
|
||||
};
|
||||
use futures::{stream::Fuse, StreamExt};
|
||||
use log::{error, info};
|
||||
use parking_lot::Mutex;
|
||||
@@ -50,6 +46,10 @@ use sp_blockchain::{
|
||||
Backend as BlockchainBackend, Error as ClientError, HeaderBackend, Result as ClientResult,
|
||||
};
|
||||
use sp_consensus::{Error as ConsensusError, SyncOracle};
|
||||
use sp_consensus_beefy::{
|
||||
crypto::AuthorityId, BeefyApi, MmrRootHash, PayloadProvider, ValidatorSet, BEEFY_ENGINE_ID,
|
||||
GENESIS_AUTHORITY_SET_ID,
|
||||
};
|
||||
use sp_keystore::SyncCryptoStorePtr;
|
||||
use sp_mmr_primitives::MmrApi;
|
||||
use sp_runtime::traits::{Block, Zero};
|
||||
@@ -18,12 +18,12 @@
|
||||
|
||||
use crate::LOG_TARGET;
|
||||
|
||||
use beefy_primitives::{
|
||||
use codec::{Decode, Encode};
|
||||
use log::debug;
|
||||
use sp_consensus_beefy::{
|
||||
crypto::{AuthorityId, Public, Signature},
|
||||
Commitment, EquivocationProof, SignedCommitment, ValidatorSet, ValidatorSetId, VoteMessage,
|
||||
};
|
||||
use codec::{Decode, Encode};
|
||||
use log::debug;
|
||||
use sp_runtime::traits::{Block, NumberFor};
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
@@ -198,7 +198,7 @@ where
|
||||
mod tests {
|
||||
use sc_network_test::Block;
|
||||
|
||||
use beefy_primitives::{
|
||||
use sp_consensus_beefy::{
|
||||
crypto::Public, known_payloads::MMR_ROOT_ID, Commitment, EquivocationProof, Keyring,
|
||||
Payload, SignedCommitment, ValidatorSet, VoteMessage,
|
||||
};
|
||||
@@ -29,14 +29,6 @@ use crate::{
|
||||
load_or_init_voter_state, wait_for_runtime_pallet, BeefyRPCLinks, BeefyVoterLinks, KnownPeers,
|
||||
PersistedState,
|
||||
};
|
||||
use beefy_primitives::{
|
||||
crypto::{AuthorityId, Signature},
|
||||
known_payloads,
|
||||
mmr::MmrRootProvider,
|
||||
BeefyApi, Commitment, ConsensusLog, EquivocationProof, Keyring as BeefyKeyring, MmrRootHash,
|
||||
OpaqueKeyOwnershipProof, Payload, SignedCommitment, ValidatorSet, ValidatorSetId,
|
||||
VersionedFinalityProof, BEEFY_ENGINE_ID, KEY_TYPE as BeefyKeyType,
|
||||
};
|
||||
use futures::{future, stream::FuturesUnordered, Future, StreamExt};
|
||||
use parking_lot::Mutex;
|
||||
use sc_client_api::{Backend as BackendT, BlockchainEvents, FinalityNotifications, HeaderBackend};
|
||||
@@ -53,6 +45,14 @@ use sc_utils::notification::NotificationReceiver;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use sp_api::{ApiRef, ProvideRuntimeApi};
|
||||
use sp_consensus::BlockOrigin;
|
||||
use sp_consensus_beefy::{
|
||||
crypto::{AuthorityId, Signature},
|
||||
known_payloads,
|
||||
mmr::MmrRootProvider,
|
||||
BeefyApi, Commitment, ConsensusLog, EquivocationProof, Keyring as BeefyKeyring, MmrRootHash,
|
||||
OpaqueKeyOwnershipProof, Payload, SignedCommitment, ValidatorSet, ValidatorSetId,
|
||||
VersionedFinalityProof, BEEFY_ENGINE_ID, KEY_TYPE as BeefyKeyType,
|
||||
};
|
||||
use sp_core::H256;
|
||||
use sp_keystore::{testing::KeyStore as TestKeystore, SyncCryptoStore, SyncCryptoStorePtr};
|
||||
use sp_mmr_primitives::{Error as MmrError, MmrApi};
|
||||
@@ -484,7 +484,7 @@ async fn wait_for_beefy_signed_commitments(
|
||||
let expected = expected.next();
|
||||
async move {
|
||||
let signed_commitment = match versioned_finality_proof {
|
||||
beefy_primitives::VersionedFinalityProof::V1(sc) => sc,
|
||||
sp_consensus_beefy::VersionedFinalityProof::V1(sc) => sc,
|
||||
};
|
||||
let commitment_block_num = signed_commitment.commitment.block_number;
|
||||
assert_eq!(expected, Some(commitment_block_num).as_ref());
|
||||
+10
-10
@@ -29,12 +29,6 @@ use crate::{
|
||||
round::{Rounds, VoteImportResult},
|
||||
BeefyVoterLinks, LOG_TARGET,
|
||||
};
|
||||
use beefy_primitives::{
|
||||
check_equivocation_proof,
|
||||
crypto::{AuthorityId, Signature},
|
||||
BeefyApi, Commitment, ConsensusLog, EquivocationProof, PayloadProvider, ValidatorSet,
|
||||
VersionedFinalityProof, VoteMessage, BEEFY_ENGINE_ID,
|
||||
};
|
||||
use codec::{Codec, Decode, Encode};
|
||||
use futures::{stream::Fuse, FutureExt, StreamExt};
|
||||
use log::{debug, error, info, log_enabled, trace, warn};
|
||||
@@ -45,6 +39,12 @@ use sc_utils::notification::NotificationReceiver;
|
||||
use sp_api::{BlockId, ProvideRuntimeApi};
|
||||
use sp_arithmetic::traits::{AtLeast32Bit, Saturating};
|
||||
use sp_consensus::SyncOracle;
|
||||
use sp_consensus_beefy::{
|
||||
check_equivocation_proof,
|
||||
crypto::{AuthorityId, Signature},
|
||||
BeefyApi, Commitment, ConsensusLog, EquivocationProof, PayloadProvider, ValidatorSet,
|
||||
VersionedFinalityProof, VoteMessage, BEEFY_ENGINE_ID,
|
||||
};
|
||||
use sp_runtime::{
|
||||
generic::OpaqueDigestItemId,
|
||||
traits::{Block, ConstU32, Header, NumberFor, Zero},
|
||||
@@ -1062,10 +1062,6 @@ pub(crate) mod tests {
|
||||
},
|
||||
BeefyRPCLinks, KnownPeers,
|
||||
};
|
||||
use beefy_primitives::{
|
||||
generate_equivocation_proof, known_payloads, known_payloads::MMR_ROOT_ID,
|
||||
mmr::MmrRootProvider, Keyring, Payload, SignedCommitment,
|
||||
};
|
||||
use futures::{future::poll_fn, task::Poll};
|
||||
use parking_lot::Mutex;
|
||||
use sc_client_api::{Backend as BackendT, HeaderBackend};
|
||||
@@ -1073,6 +1069,10 @@ pub(crate) mod tests {
|
||||
use sc_network_test::TestNetFactory;
|
||||
use sp_api::HeaderT;
|
||||
use sp_blockchain::Backend as BlockchainBackendT;
|
||||
use sp_consensus_beefy::{
|
||||
generate_equivocation_proof, known_payloads, known_payloads::MMR_ROOT_ID,
|
||||
mmr::MmrRootProvider, Keyring, Payload, SignedCommitment,
|
||||
};
|
||||
use sp_runtime::traits::One;
|
||||
use substrate_test_runtime_client::{
|
||||
runtime::{Block, Digest, DigestItem, Header, H256},
|
||||
@@ -14,10 +14,10 @@ homepage = "https://substrate.io"
|
||||
codec = { package = "parity-scale-codec", version = "3.2.2" }
|
||||
futures = "0.3"
|
||||
log = "0.4"
|
||||
beefy-primitives = { version = "4.0.0-dev", path = "../../primitives/beefy", package = "sp-beefy" }
|
||||
sc-client-api = { version = "4.0.0-dev", path = "../api" }
|
||||
sp-api = { version = "4.0.0-dev", path = "../../primitives/api" }
|
||||
sp-blockchain = { version = "4.0.0-dev", path = "../../primitives/blockchain" }
|
||||
sc-client-api = { version = "4.0.0-dev", path = "../api" }
|
||||
sp-consensus-beefy = { version = "4.0.0-dev", path = "../../primitives/consensus/beefy" }
|
||||
sp-consensus = { version = "0.10.0-dev", path = "../../primitives/consensus/common" }
|
||||
sp-core = { version = "7.0.0", path = "../../primitives/core" }
|
||||
sp-mmr-primitives = { version = "4.0.0-dev", path = "../../primitives/merkle-mountain-range" }
|
||||
|
||||
@@ -43,13 +43,13 @@ mod offchain_mmr;
|
||||
pub mod test_utils;
|
||||
|
||||
use crate::offchain_mmr::OffchainMmr;
|
||||
use beefy_primitives::MmrRootHash;
|
||||
use futures::StreamExt;
|
||||
use log::{debug, error, trace, warn};
|
||||
use sc_client_api::{Backend, BlockchainEvents, FinalityNotification, FinalityNotifications};
|
||||
use sc_offchain::OffchainDb;
|
||||
use sp_api::ProvideRuntimeApi;
|
||||
use sp_blockchain::{HeaderBackend, HeaderMetadata};
|
||||
use sp_consensus_beefy::MmrRootHash;
|
||||
use sp_mmr_primitives::{utils, LeafIndex, MmrApi};
|
||||
use sp_runtime::traits::{Block, Header, NumberFor};
|
||||
use std::{marker::PhantomData, sync::Arc};
|
||||
|
||||
@@ -22,11 +22,11 @@
|
||||
#![warn(missing_docs)]
|
||||
|
||||
use crate::{aux_schema, MmrClient, LOG_TARGET};
|
||||
use beefy_primitives::MmrRootHash;
|
||||
use log::{debug, error, info, warn};
|
||||
use sc_client_api::{Backend, FinalityNotification};
|
||||
use sc_offchain::OffchainDb;
|
||||
use sp_blockchain::{CachedHeaderMetadata, ForkBackend};
|
||||
use sp_consensus_beefy::MmrRootHash;
|
||||
use sp_core::offchain::{DbExternalities, StorageKind};
|
||||
use sp_mmr_primitives::{utils, utils::NodesUtils, MmrApi, NodeIndex};
|
||||
use sp_runtime::{
|
||||
|
||||
@@ -15,12 +15,12 @@ log = { version = "0.4.17", default-features = false }
|
||||
scale-info = { version = "2.1.1", default-features = false, features = ["derive"] }
|
||||
serde = { version = "1.0.136", optional = true }
|
||||
binary-merkle-tree = { version = "4.0.0-dev", default-features = false, path = "../../utils/binary-merkle-tree" }
|
||||
beefy-primitives = { version = "4.0.0-dev", default-features = false, path = "../../primitives/beefy", package = "sp-beefy" }
|
||||
frame-support = { version = "4.0.0-dev", default-features = false, path = "../support" }
|
||||
frame-system = { version = "4.0.0-dev", default-features = false, path = "../system" }
|
||||
pallet-beefy = { version = "4.0.0-dev", default-features = false, path = "../beefy" }
|
||||
pallet-mmr = { version = "4.0.0-dev", default-features = false, path = "../merkle-mountain-range" }
|
||||
pallet-session = { version = "4.0.0-dev", default-features = false, path = "../session" }
|
||||
sp-consensus-beefy = { version = "4.0.0-dev", default-features = false, path = "../../primitives/consensus/beefy" }
|
||||
sp-core = { version = "7.0.0", default-features = false, path = "../../primitives/core" }
|
||||
sp-io = { version = "7.0.0", default-features = false, path = "../../primitives/io" }
|
||||
sp-runtime = { version = "7.0.0", default-features = false, path = "../../primitives/runtime" }
|
||||
@@ -36,7 +36,6 @@ default = ["std"]
|
||||
std = [
|
||||
"array-bytes",
|
||||
"binary-merkle-tree/std",
|
||||
"beefy-primitives/std",
|
||||
"codec/std",
|
||||
"frame-support/std",
|
||||
"frame-system/std",
|
||||
@@ -46,6 +45,7 @@ std = [
|
||||
"pallet-session/std",
|
||||
"scale-info/std",
|
||||
"serde",
|
||||
"sp-consensus-beefy/std",
|
||||
"sp-core/std",
|
||||
"sp-io/std",
|
||||
"sp-runtime/std",
|
||||
|
||||
@@ -36,11 +36,11 @@
|
||||
use sp_runtime::traits::{Convert, Member};
|
||||
use sp_std::prelude::*;
|
||||
|
||||
use beefy_primitives::{
|
||||
use pallet_mmr::{LeafDataProvider, ParentNumberAndHash};
|
||||
use sp_consensus_beefy::{
|
||||
mmr::{BeefyAuthoritySet, BeefyDataProvider, BeefyNextAuthoritySet, MmrLeaf, MmrLeafVersion},
|
||||
ValidatorSet as BeefyValidatorSet,
|
||||
};
|
||||
use pallet_mmr::{LeafDataProvider, ParentNumberAndHash};
|
||||
|
||||
use frame_support::{crypto::ecdsa::ECDSAExt, traits::Get};
|
||||
|
||||
@@ -54,15 +54,15 @@ mod tests;
|
||||
/// A BEEFY consensus digest item with MMR root hash.
|
||||
pub struct DepositBeefyDigest<T>(sp_std::marker::PhantomData<T>);
|
||||
|
||||
impl<T> pallet_mmr::primitives::OnNewRoot<beefy_primitives::MmrRootHash> for DepositBeefyDigest<T>
|
||||
impl<T> pallet_mmr::primitives::OnNewRoot<sp_consensus_beefy::MmrRootHash> for DepositBeefyDigest<T>
|
||||
where
|
||||
T: pallet_mmr::Config<Hash = beefy_primitives::MmrRootHash>,
|
||||
T: pallet_mmr::Config<Hash = sp_consensus_beefy::MmrRootHash>,
|
||||
T: pallet_beefy::Config,
|
||||
{
|
||||
fn on_new_root(root: &<T as pallet_mmr::Config>::Hash) {
|
||||
let digest = sp_runtime::generic::DigestItem::Consensus(
|
||||
beefy_primitives::BEEFY_ENGINE_ID,
|
||||
codec::Encode::encode(&beefy_primitives::ConsensusLog::<
|
||||
sp_consensus_beefy::BEEFY_ENGINE_ID,
|
||||
codec::Encode::encode(&sp_consensus_beefy::ConsensusLog::<
|
||||
<T as pallet_beefy::Config>::BeefyId,
|
||||
>::MmrRoot(*root)),
|
||||
);
|
||||
@@ -72,8 +72,8 @@ where
|
||||
|
||||
/// Convert BEEFY secp256k1 public keys into Ethereum addresses
|
||||
pub struct BeefyEcdsaToEthereum;
|
||||
impl Convert<beefy_primitives::crypto::AuthorityId, Vec<u8>> for BeefyEcdsaToEthereum {
|
||||
fn convert(beefy_id: beefy_primitives::crypto::AuthorityId) -> Vec<u8> {
|
||||
impl Convert<sp_consensus_beefy::crypto::AuthorityId, Vec<u8>> for BeefyEcdsaToEthereum {
|
||||
fn convert(beefy_id: sp_consensus_beefy::crypto::AuthorityId) -> Vec<u8> {
|
||||
sp_core::ecdsa::Public::from(beefy_id)
|
||||
.to_eth_address()
|
||||
.map(|v| v.to_vec())
|
||||
@@ -156,7 +156,7 @@ impl<T: Config> LeafDataProvider for Pallet<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> beefy_primitives::OnNewValidatorSet<<T as pallet_beefy::Config>::BeefyId> for Pallet<T>
|
||||
impl<T> sp_consensus_beefy::OnNewValidatorSet<<T as pallet_beefy::Config>::BeefyId> for Pallet<T>
|
||||
where
|
||||
T: pallet::Config,
|
||||
{
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
|
||||
use std::vec;
|
||||
|
||||
use beefy_primitives::mmr::MmrLeafVersion;
|
||||
use codec::Encode;
|
||||
use frame_support::{
|
||||
construct_runtime, parameter_types,
|
||||
@@ -25,6 +24,7 @@ use frame_support::{
|
||||
traits::{ConstU16, ConstU32, ConstU64, GenesisBuild, KeyOwnerProofSystem},
|
||||
BasicExternalities,
|
||||
};
|
||||
use sp_consensus_beefy::mmr::MmrLeafVersion;
|
||||
use sp_core::{crypto::KeyTypeId, Hasher, H256};
|
||||
use sp_runtime::{
|
||||
app_crypto::ecdsa::Public,
|
||||
@@ -35,7 +35,7 @@ use sp_runtime::{
|
||||
|
||||
use crate as pallet_beefy_mmr;
|
||||
|
||||
pub use beefy_primitives::{
|
||||
pub use sp_consensus_beefy::{
|
||||
crypto::AuthorityId as BeefyId, mmr::BeefyDataProvider, ConsensusLog, BEEFY_ENGINE_ID,
|
||||
};
|
||||
|
||||
@@ -101,7 +101,7 @@ impl pallet_session::Config for Test {
|
||||
type WeightInfo = ();
|
||||
}
|
||||
|
||||
pub type MmrLeaf = beefy_primitives::mmr::MmrLeaf<
|
||||
pub type MmrLeaf = sp_consensus_beefy::mmr::MmrLeaf<
|
||||
<Test as frame_system::Config>::BlockNumber,
|
||||
<Test as frame_system::Config>::Hash,
|
||||
<Test as pallet_mmr::Config>::Hash,
|
||||
|
||||
@@ -17,11 +17,11 @@
|
||||
|
||||
use std::vec;
|
||||
|
||||
use beefy_primitives::{
|
||||
use codec::{Decode, Encode};
|
||||
use sp_consensus_beefy::{
|
||||
mmr::{BeefyNextAuthoritySet, MmrLeafVersion},
|
||||
ValidatorSet,
|
||||
};
|
||||
use codec::{Decode, Encode};
|
||||
|
||||
use sp_core::H256;
|
||||
use sp_io::TestExternalities;
|
||||
|
||||
@@ -12,11 +12,11 @@ homepage = "https://substrate.io"
|
||||
codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] }
|
||||
scale-info = { version = "2.1.1", default-features = false, features = ["derive"] }
|
||||
serde = { version = "1.0.136", optional = true }
|
||||
beefy-primitives = { version = "4.0.0-dev", default-features = false, path = "../../primitives/beefy", package = "sp-beefy" }
|
||||
frame-support = { version = "4.0.0-dev", default-features = false, path = "../support" }
|
||||
frame-system = { version = "4.0.0-dev", default-features = false, path = "../system" }
|
||||
pallet-authorship = { version = "4.0.0-dev", default-features = false, path = "../authorship" }
|
||||
pallet-session = { version = "4.0.0-dev", default-features = false, path = "../session" }
|
||||
sp-consensus-beefy = { version = "4.0.0-dev", default-features = false, path = "../../primitives/consensus/beefy" }
|
||||
sp-runtime = { version = "7.0.0", default-features = false, path = "../../primitives/runtime" }
|
||||
sp-session = { version = "4.0.0-dev", default-features = false, path = "../../primitives/session" }
|
||||
sp-staking = { version = "4.0.0-dev", default-features = false, path = "../../primitives/staking" }
|
||||
@@ -36,7 +36,6 @@ sp-staking = { version = "4.0.0-dev", path = "../../primitives/staking" }
|
||||
[features]
|
||||
default = ["std"]
|
||||
std = [
|
||||
"beefy-primitives/std",
|
||||
"codec/std",
|
||||
"frame-support/std",
|
||||
"frame-system/std",
|
||||
@@ -44,6 +43,7 @@ std = [
|
||||
"pallet-session/std",
|
||||
"scale-info/std",
|
||||
"serde",
|
||||
"sp-consensus-beefy/std",
|
||||
"sp-runtime/std",
|
||||
"sp-session/std",
|
||||
"sp-staking/std",
|
||||
|
||||
@@ -36,13 +36,13 @@
|
||||
|
||||
use sp_std::prelude::*;
|
||||
|
||||
use beefy_primitives::{EquivocationProof, ValidatorSetId};
|
||||
use codec::{self as codec, Decode, Encode};
|
||||
use frame_support::{
|
||||
log,
|
||||
traits::{Get, KeyOwnerProofSystem},
|
||||
};
|
||||
use frame_system::pallet_prelude::BlockNumberFor;
|
||||
use sp_consensus_beefy::{EquivocationProof, ValidatorSetId};
|
||||
use sp_runtime::{
|
||||
transaction_validity::{
|
||||
InvalidTransaction, TransactionPriority, TransactionSource, TransactionValidity,
|
||||
@@ -271,7 +271,7 @@ fn is_known_offence<T: Config>(
|
||||
) -> Result<(), TransactionValidityError> {
|
||||
// check the membership proof to extract the offender's id,
|
||||
// equivocation validity will be fully checked during the call.
|
||||
let key = (beefy_primitives::KEY_TYPE, equivocation_proof.offender_id().clone());
|
||||
let key = (sp_consensus_beefy::KEY_TYPE, equivocation_proof.offender_id().clone());
|
||||
|
||||
let offender = T::KeyOwnerProofSystem::check_proof(key, key_owner_proof.clone())
|
||||
.ok_or(InvalidTransaction::BadProof)?;
|
||||
|
||||
@@ -40,7 +40,7 @@ use sp_session::{GetSessionNumber, GetValidatorCount};
|
||||
use sp_staking::SessionIndex;
|
||||
use sp_std::prelude::*;
|
||||
|
||||
use beefy_primitives::{
|
||||
use sp_consensus_beefy::{
|
||||
AuthorityIndex, BeefyAuthorityId, ConsensusLog, EquivocationProof, OnNewValidatorSet,
|
||||
ValidatorSet, BEEFY_ENGINE_ID, GENESIS_AUTHORITY_SET_ID,
|
||||
};
|
||||
@@ -135,7 +135,7 @@ pub mod pallet {
|
||||
#[pallet::storage]
|
||||
#[pallet::getter(fn validator_set_id)]
|
||||
pub(super) type ValidatorSetId<T: Config> =
|
||||
StorageValue<_, beefy_primitives::ValidatorSetId, ValueQuery>;
|
||||
StorageValue<_, sp_consensus_beefy::ValidatorSetId, ValueQuery>;
|
||||
|
||||
/// Authorities set scheduled to be used with the next session
|
||||
#[pallet::storage]
|
||||
@@ -156,7 +156,7 @@ pub mod pallet {
|
||||
#[pallet::storage]
|
||||
#[pallet::getter(fn session_for_set)]
|
||||
pub(super) type SetIdSession<T: Config> =
|
||||
StorageMap<_, Twox64Concat, beefy_primitives::ValidatorSetId, SessionIndex>;
|
||||
StorageMap<_, Twox64Concat, sp_consensus_beefy::ValidatorSetId, SessionIndex>;
|
||||
|
||||
/// Block number where BEEFY consensus is enabled/started.
|
||||
/// If changing this, make sure `Self::ValidatorSetId` is also reset to
|
||||
@@ -280,7 +280,7 @@ impl<T: Config> Pallet<T> {
|
||||
/// Return the current active BEEFY validator set.
|
||||
pub fn validator_set() -> Option<ValidatorSet<T::BeefyId>> {
|
||||
let validators: BoundedVec<T::BeefyId, T::MaxAuthorities> = Self::authorities();
|
||||
let id: beefy_primitives::ValidatorSetId = Self::validator_set_id();
|
||||
let id: sp_consensus_beefy::ValidatorSetId = Self::validator_set_id();
|
||||
ValidatorSet::<T::BeefyId>::new(validators, id)
|
||||
}
|
||||
|
||||
@@ -390,13 +390,13 @@ impl<T: Config> Pallet<T> {
|
||||
|
||||
// validate the key ownership proof extracting the id of the offender.
|
||||
let offender = T::KeyOwnerProofSystem::check_proof(
|
||||
(beefy_primitives::KEY_TYPE, offender_id),
|
||||
(sp_consensus_beefy::KEY_TYPE, offender_id),
|
||||
key_owner_proof,
|
||||
)
|
||||
.ok_or(Error::<T>::InvalidKeyOwnershipProof)?;
|
||||
|
||||
// validate equivocation proof (check votes are different and signatures are valid).
|
||||
if !beefy_primitives::check_equivocation_proof(&equivocation_proof) {
|
||||
if !sp_consensus_beefy::check_equivocation_proof(&equivocation_proof) {
|
||||
return Err(Error::<T>::InvalidEquivocationProof.into())
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ use sp_staking::{EraIndex, SessionIndex};
|
||||
|
||||
use crate as pallet_beefy;
|
||||
|
||||
pub use beefy_primitives::{
|
||||
pub use sp_consensus_beefy::{
|
||||
crypto::{AuthorityId as BeefyId, AuthoritySignature as BeefySignature},
|
||||
ConsensusLog, EquivocationProof, BEEFY_ENGINE_ID,
|
||||
};
|
||||
|
||||
@@ -17,11 +17,11 @@
|
||||
|
||||
use std::vec;
|
||||
|
||||
use beefy_primitives::{
|
||||
use codec::Encode;
|
||||
use sp_consensus_beefy::{
|
||||
check_equivocation_proof, generate_equivocation_proof, known_payloads::MMR_ROOT_ID,
|
||||
Keyring as BeefyKeyring, Payload, ValidatorSet,
|
||||
};
|
||||
use codec::Encode;
|
||||
|
||||
use sp_runtime::DigestItem;
|
||||
|
||||
@@ -298,7 +298,7 @@ fn report_equivocation_current_set_works() {
|
||||
|
||||
// create the key ownership proof
|
||||
let key_owner_proof =
|
||||
Historical::prove((beefy_primitives::KEY_TYPE, &equivocation_key)).unwrap();
|
||||
Historical::prove((sp_consensus_beefy::KEY_TYPE, &equivocation_key)).unwrap();
|
||||
|
||||
// report the equivocation and the tx should be dispatched successfully
|
||||
assert_ok!(Beefy::report_equivocation_unsigned(
|
||||
@@ -355,7 +355,7 @@ fn report_equivocation_old_set_works() {
|
||||
|
||||
// create the key ownership proof in the "old" set
|
||||
let key_owner_proof =
|
||||
Historical::prove((beefy_primitives::KEY_TYPE, &equivocation_key)).unwrap();
|
||||
Historical::prove((sp_consensus_beefy::KEY_TYPE, &equivocation_key)).unwrap();
|
||||
|
||||
start_era(2);
|
||||
|
||||
@@ -437,7 +437,7 @@ fn report_equivocation_invalid_set_id() {
|
||||
let equivocation_keyring = BeefyKeyring::from_public(equivocation_key).unwrap();
|
||||
|
||||
let key_owner_proof =
|
||||
Historical::prove((beefy_primitives::KEY_TYPE, &equivocation_key)).unwrap();
|
||||
Historical::prove((sp_consensus_beefy::KEY_TYPE, &equivocation_key)).unwrap();
|
||||
|
||||
let payload1 = Payload::from_single_entry(MMR_ROOT_ID, vec![42]);
|
||||
let payload2 = Payload::from_single_entry(MMR_ROOT_ID, vec![128]);
|
||||
@@ -476,7 +476,7 @@ fn report_equivocation_invalid_session() {
|
||||
|
||||
// generate a key ownership proof at current era set id
|
||||
let key_owner_proof =
|
||||
Historical::prove((beefy_primitives::KEY_TYPE, &equivocation_key)).unwrap();
|
||||
Historical::prove((sp_consensus_beefy::KEY_TYPE, &equivocation_key)).unwrap();
|
||||
|
||||
start_era(2);
|
||||
|
||||
@@ -520,7 +520,7 @@ fn report_equivocation_invalid_key_owner_proof() {
|
||||
|
||||
// generate a key ownership proof for the authority at index 1
|
||||
let invalid_key_owner_proof =
|
||||
Historical::prove((beefy_primitives::KEY_TYPE, &invalid_owner_key)).unwrap();
|
||||
Historical::prove((sp_consensus_beefy::KEY_TYPE, &invalid_owner_key)).unwrap();
|
||||
|
||||
let equivocation_authority_index = 0;
|
||||
let equivocation_key = &authorities[equivocation_authority_index];
|
||||
@@ -569,7 +569,7 @@ fn report_equivocation_invalid_equivocation_proof() {
|
||||
|
||||
// generate a key ownership proof at set id in era 1
|
||||
let key_owner_proof =
|
||||
Historical::prove((beefy_primitives::KEY_TYPE, &equivocation_key)).unwrap();
|
||||
Historical::prove((sp_consensus_beefy::KEY_TYPE, &equivocation_key)).unwrap();
|
||||
|
||||
let assert_invalid_equivocation_proof = |equivocation_proof| {
|
||||
assert_err!(
|
||||
@@ -650,7 +650,7 @@ fn report_equivocation_validate_unsigned_prevents_duplicates() {
|
||||
);
|
||||
|
||||
let key_owner_proof =
|
||||
Historical::prove((beefy_primitives::KEY_TYPE, &equivocation_key)).unwrap();
|
||||
Historical::prove((sp_consensus_beefy::KEY_TYPE, &equivocation_key)).unwrap();
|
||||
|
||||
let call = Call::report_equivocation_unsigned {
|
||||
equivocation_proof: Box::new(equivocation_proof.clone()),
|
||||
@@ -756,7 +756,7 @@ fn valid_equivocation_reports_dont_pay_fees() {
|
||||
|
||||
// create the key ownership proof.
|
||||
let key_owner_proof =
|
||||
Historical::prove((beefy_primitives::KEY_TYPE, &equivocation_key)).unwrap();
|
||||
Historical::prove((sp_consensus_beefy::KEY_TYPE, &equivocation_key)).unwrap();
|
||||
|
||||
// check the dispatch info for the call.
|
||||
let info = Call::<Test>::report_equivocation_unsigned {
|
||||
|
||||
+9
-9
@@ -1,5 +1,5 @@
|
||||
[package]
|
||||
name = "sp-beefy"
|
||||
name = "sp-consensus-beefy"
|
||||
version = "4.0.0-dev"
|
||||
authors = ["Parity Technologies <admin@parity.io>"]
|
||||
edition = "2021"
|
||||
@@ -15,19 +15,19 @@ targets = ["x86_64-unknown-linux-gnu"]
|
||||
codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] }
|
||||
serde = { version = "1.0.136", optional = true, features = ["derive"] }
|
||||
scale-info = { version = "2.1.1", default-features = false, features = ["derive"] }
|
||||
sp-api = { version = "4.0.0-dev", default-features = false, path = "../api" }
|
||||
sp-application-crypto = { version = "7.0.0", default-features = false, path = "../application-crypto" }
|
||||
sp-core = { version = "7.0.0", default-features = false, path = "../core" }
|
||||
sp-io = { version = "7.0.0", default-features = false, path = "../io" }
|
||||
sp-mmr-primitives = { version = "4.0.0-dev", default-features = false, path = "../merkle-mountain-range" }
|
||||
sp-runtime = { version = "7.0.0", default-features = false, path = "../runtime" }
|
||||
sp-std = { version = "5.0.0", default-features = false, path = "../std" }
|
||||
sp-api = { version = "4.0.0-dev", default-features = false, path = "../../api" }
|
||||
sp-application-crypto = { version = "7.0.0", default-features = false, path = "../../application-crypto" }
|
||||
sp-core = { version = "7.0.0", default-features = false, path = "../../core" }
|
||||
sp-io = { version = "7.0.0", default-features = false, path = "../../io" }
|
||||
sp-mmr-primitives = { version = "4.0.0-dev", default-features = false, path = "../../merkle-mountain-range" }
|
||||
sp-runtime = { version = "7.0.0", default-features = false, path = "../../runtime" }
|
||||
sp-std = { version = "5.0.0", default-features = false, path = "../../std" }
|
||||
strum = { version = "0.24.1", features = ["derive"], default-features = false }
|
||||
lazy_static = "1.4.0"
|
||||
|
||||
[dev-dependencies]
|
||||
array-bytes = "4.1"
|
||||
sp-keystore = { version = "0.13.0", path = "../keystore" }
|
||||
sp-keystore = { version = "0.13.0", path = "../../keystore" }
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
@@ -13,11 +13,11 @@ publish = false
|
||||
targets = ["x86_64-unknown-linux-gnu"]
|
||||
|
||||
[dependencies]
|
||||
beefy-primitives = { version = "4.0.0-dev", default-features = false, path = "../../primitives/beefy", package = "sp-beefy" }
|
||||
pallet-beefy-mmr = { version = "4.0.0-dev", default-features = false, path = "../../frame/beefy-mmr" }
|
||||
sp-application-crypto = { version = "7.0.0", default-features = false, path = "../../primitives/application-crypto" }
|
||||
sp-consensus-aura = { version = "0.10.0-dev", default-features = false, path = "../../primitives/consensus/aura" }
|
||||
sp-consensus-babe = { version = "0.10.0-dev", default-features = false, path = "../../primitives/consensus/babe" }
|
||||
sp-consensus-beefy = { version = "4.0.0-dev", default-features = false, path = "../../primitives/consensus/beefy" }
|
||||
sp-block-builder = { version = "4.0.0-dev", default-features = false, path = "../../primitives/block-builder" }
|
||||
codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] }
|
||||
scale-info = { version = "2.1.1", default-features = false, features = ["derive"] }
|
||||
@@ -66,11 +66,11 @@ default = [
|
||||
"std",
|
||||
]
|
||||
std = [
|
||||
"beefy-primitives/std",
|
||||
"pallet-beefy-mmr/std",
|
||||
"sp-application-crypto/std",
|
||||
"sp-consensus-aura/std",
|
||||
"sp-consensus-babe/std",
|
||||
"sp-consensus-beefy/std",
|
||||
"sp-block-builder/std",
|
||||
"codec/std",
|
||||
"scale-info/std",
|
||||
|
||||
@@ -972,36 +972,36 @@ cfg_if! {
|
||||
}
|
||||
}
|
||||
|
||||
impl beefy_primitives::BeefyApi<Block> for Runtime {
|
||||
impl sp_consensus_beefy::BeefyApi<Block> for Runtime {
|
||||
fn beefy_genesis() -> Option<BlockNumber> {
|
||||
None
|
||||
}
|
||||
|
||||
fn validator_set() -> Option<beefy_primitives::ValidatorSet<beefy_primitives::crypto::AuthorityId>> {
|
||||
fn validator_set() -> Option<sp_consensus_beefy::ValidatorSet<sp_consensus_beefy::crypto::AuthorityId>> {
|
||||
None
|
||||
}
|
||||
|
||||
fn submit_report_equivocation_unsigned_extrinsic(
|
||||
_equivocation_proof: beefy_primitives::EquivocationProof<
|
||||
_equivocation_proof: sp_consensus_beefy::EquivocationProof<
|
||||
NumberFor<Block>,
|
||||
beefy_primitives::crypto::AuthorityId,
|
||||
beefy_primitives::crypto::Signature
|
||||
sp_consensus_beefy::crypto::AuthorityId,
|
||||
sp_consensus_beefy::crypto::Signature
|
||||
>,
|
||||
_key_owner_proof: beefy_primitives::OpaqueKeyOwnershipProof,
|
||||
_key_owner_proof: sp_consensus_beefy::OpaqueKeyOwnershipProof,
|
||||
) -> Option<()> { None }
|
||||
|
||||
fn generate_key_ownership_proof(
|
||||
_set_id: beefy_primitives::ValidatorSetId,
|
||||
_authority_id: beefy_primitives::crypto::AuthorityId,
|
||||
) -> Option<beefy_primitives::OpaqueKeyOwnershipProof> { None }
|
||||
_set_id: sp_consensus_beefy::ValidatorSetId,
|
||||
_authority_id: sp_consensus_beefy::crypto::AuthorityId,
|
||||
) -> Option<sp_consensus_beefy::OpaqueKeyOwnershipProof> { None }
|
||||
}
|
||||
|
||||
impl pallet_beefy_mmr::BeefyMmrApi<Block, beefy_primitives::MmrRootHash> for Runtime {
|
||||
fn authority_set_proof() -> beefy_primitives::mmr::BeefyAuthoritySet<beefy_primitives::MmrRootHash> {
|
||||
impl pallet_beefy_mmr::BeefyMmrApi<Block, sp_consensus_beefy::MmrRootHash> for Runtime {
|
||||
fn authority_set_proof() -> sp_consensus_beefy::mmr::BeefyAuthoritySet<sp_consensus_beefy::MmrRootHash> {
|
||||
Default::default()
|
||||
}
|
||||
|
||||
fn next_authority_set_proof() -> beefy_primitives::mmr::BeefyNextAuthoritySet<beefy_primitives::MmrRootHash> {
|
||||
fn next_authority_set_proof() -> sp_consensus_beefy::mmr::BeefyNextAuthoritySet<sp_consensus_beefy::MmrRootHash> {
|
||||
Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user