From c25e79d8c467171764f204a08dc3a088e25505bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Silva?= <123550+andresilva@users.noreply.github.com> Date: Wed, 21 Apr 2021 21:31:06 +0100 Subject: [PATCH] runtime: remove mmr and beefy from westend runtime (#2916) * runtime: remove mmr and beefy from westend runtime * runtime: westend: remove pallet_beefy config * node: only start beefy gadget on rococo * node: remove beefy keys from westend chain spec --- polkadot/Cargo.lock | 2 - polkadot/node/service/src/chain_spec.rs | 22 +----- polkadot/node/service/src/lib.rs | 19 ++--- polkadot/runtime/westend/Cargo.toml | 5 -- polkadot/runtime/westend/src/lib.rs | 96 ++++--------------------- 5 files changed, 23 insertions(+), 121 deletions(-) diff --git a/polkadot/Cargo.lock b/polkadot/Cargo.lock index 6e90fc301b..647e2fe401 100644 --- a/polkadot/Cargo.lock +++ b/polkadot/Cargo.lock @@ -11190,7 +11190,6 @@ dependencies = [ "pallet-authorship", "pallet-babe", "pallet-balances", - "pallet-beefy", "pallet-collective", "pallet-democracy", "pallet-election-provider-multi-phase", @@ -11200,7 +11199,6 @@ dependencies = [ "pallet-im-online", "pallet-indices", "pallet-membership", - "pallet-mmr", "pallet-mmr-primitives", "pallet-multisig", "pallet-nicks", diff --git a/polkadot/node/service/src/chain_spec.rs b/polkadot/node/service/src/chain_spec.rs index 9b84ef6237..a806866c33 100644 --- a/polkadot/node/service/src/chain_spec.rs +++ b/polkadot/node/service/src/chain_spec.rs @@ -155,7 +155,6 @@ fn westend_session_keys( para_validator: ValidatorId, para_assignment: AssignmentId, authority_discovery: AuthorityDiscoveryId, - beefy: BeefyId, ) -> westend::SessionKeys { westend::SessionKeys { babe, @@ -164,7 +163,6 @@ fn westend_session_keys( para_validator, para_assignment, authority_discovery, - beefy, } } @@ -306,7 +304,6 @@ fn westend_staging_testnet_config_genesis(wasm_binary: &[u8]) -> westend::Genesi ValidatorId, AssignmentId, AuthorityDiscoveryId, - BeefyId, )> = vec![ ( //5FZoQhgUCmqBxnkHX7jCqThScS2xQWiwiF61msg63CFL3Y8f @@ -325,8 +322,6 @@ fn westend_staging_testnet_config_genesis(wasm_binary: &[u8]) -> westend::Genesi hex!["0810d2113438bb14856b06383a4f0da4e5cc2f92a3fc18ef03a54b34c6007662"].unchecked_into(), //5CkAdj1MpkMtQikrGXuzgzrRLvUnfLQH2JsnZa16u4cK2Xhf hex!["1e18b5a9f872727189934a6988ff2a6732c87b9e31e2d694dd011aff9dfb2332"].unchecked_into(), - //5E6ogZEZyc5YZ3ijWUPB9M6Xtx6E9FabhmP9J4rwcEH6pLGv - hex!["0293be7cdb81f25039dfd01aac905da8a5e50113366bc4b5dc5eb888cf5552b8a9"].unchecked_into(), ), ( //5G1ojzh47Yt8KoYhuAjXpHcazvsoCXe3G8LZchKDvumozJJJ @@ -345,8 +340,6 @@ fn westend_staging_testnet_config_genesis(wasm_binary: &[u8]) -> westend::Genesi hex!["d6a113804a98728bb2af4f3721ab31a3644731292bffe0268995d8f8fb073b57"].unchecked_into(), //5DUrcztb1pRz6DfA8Vo8JSUSpoQVr27Yo6gjPmnumhhubLeN hex!["3ea7a06009d1b9b1d4233dea3e6bb6494b9aeda91edc443629a28afa9fab8c62"].unchecked_into(), - //5HUYyVYXjm5mdEpDiykmhxZGzQjY4LLxyTPD7hfMjfLUy3VT - hex!["020e0ba5e112f0d3356ff8c78a37e2d7f76f90ab8dc9ed2eac98c87c5ffb2b0ebe"].unchecked_into(), ), ( //5HYYWyhyUQ7Ae11f8fCid58bhJ7ikLHM9bU8A6Ynwoc3dStR @@ -365,8 +358,6 @@ fn westend_staging_testnet_config_genesis(wasm_binary: &[u8]) -> westend::Genesi hex!["0e5e1fb2c0fa7db11cd83fef3493900292badf02f35812ba738efeab9978a46c"].unchecked_into(), //5GvKehGrFVea8rywSeJhTopmpBDNHSFBoZp32g3CecppYa3V hex!["d6c8735316211321cd85ccd7c583222ab024393b8c86c7c8d1192a1d4f35bb2e"].unchecked_into(), - //5FpX3V5qCGehdTBRxkpHzGjwK9nvihLYj6gwR4NWn8DjbAoL - hex!["020b4bc2972761bd1abf20d5f83f79ff546ef63094e193d21758566c58dea9642f"].unchecked_into(), ), ( //5CFPcUJgYgWryPaV1aYjSbTpbTLu42V32Ytw1L9rfoMAsfGh @@ -385,8 +376,6 @@ fn westend_staging_testnet_config_genesis(wasm_binary: &[u8]) -> westend::Genesi hex!["c4390ca0274f0262a4ef7cd4d3aa6cab0875a6efdd40d38c21be4f770b6c4b1a"].unchecked_into(), //5CZd519gfE3gALMtFWa283VHikXwoGFmT92B3Nu3iN7YGcaR hex!["160e0049b62d368c59d286275697e8d5e68d34ee8663ac4c3da646b0abb4a86f"].unchecked_into(), - //5Fnu4YYBx9V71ihCBkJyFGsKw9Q2jjNzRQL9kRNpKTPNSAhc - hex!["03e9393ee30ae95fc2b7864230f53e45409a807949390140ce2bc77756cdb4bb83"].unchecked_into(), ), ]; @@ -406,7 +395,6 @@ fn westend_staging_testnet_config_genesis(wasm_binary: &[u8]) -> westend::Genesi .chain(initial_authorities.iter().map(|x| (x.0.clone(), STASH))) .collect(), }, - pallet_beefy: Default::default(), pallet_indices: westend::IndicesConfig { indices: vec![] }, pallet_session: westend::SessionConfig { keys: initial_authorities @@ -422,7 +410,6 @@ fn westend_staging_testnet_config_genesis(wasm_binary: &[u8]) -> westend::Genesi x.5.clone(), x.6.clone(), x.7.clone(), - x.8.clone(), ), ) }) @@ -1311,7 +1298,6 @@ pub fn westend_testnet_genesis( ValidatorId, AssignmentId, AuthorityDiscoveryId, - BeefyId, )>, root_key: AccountId, endowed_accounts: Option>, @@ -1333,7 +1319,6 @@ pub fn westend_testnet_genesis( .map(|k| (k.clone(), ENDOWMENT)) .collect(), }, - pallet_beefy: Default::default(), pallet_session: westend::SessionConfig { keys: initial_authorities .iter() @@ -1348,7 +1333,6 @@ pub fn westend_testnet_genesis( x.5.clone(), x.6.clone(), x.7.clone(), - x.8.clone(), ), ) }) @@ -1515,7 +1499,7 @@ fn kusama_development_config_genesis(wasm_binary: &[u8]) -> kusama::GenesisConfi fn westend_development_config_genesis(wasm_binary: &[u8]) -> westend::GenesisConfig { westend_testnet_genesis( wasm_binary, - vec![get_authority_keys_from_seed("Alice")], + vec![get_authority_keys_from_seed_no_beefy("Alice")], get_account_id_from_seed::("Alice"), None, ) @@ -1634,8 +1618,8 @@ fn westend_local_testnet_genesis(wasm_binary: &[u8]) -> westend::GenesisConfig { westend_testnet_genesis( wasm_binary, vec![ - get_authority_keys_from_seed("Alice"), - get_authority_keys_from_seed("Bob"), + get_authority_keys_from_seed_no_beefy("Alice"), + get_authority_keys_from_seed_no_beefy("Bob"), ], get_account_id_from_seed::("Alice"), None, diff --git a/polkadot/node/service/src/lib.rs b/polkadot/node/service/src/lib.rs index 784210f8a5..da6f9bb0f2 100644 --- a/polkadot/node/service/src/lib.rs +++ b/polkadot/node/service/src/lib.rs @@ -715,7 +715,7 @@ pub fn new_full( // Substrate nodes. config.network.extra_sets.push(grandpa::grandpa_peers_set_config()); - if config.chain_spec.is_westend() || config.chain_spec.is_rococo() { + if config.chain_spec.is_rococo() { config.network.extra_sets.push(beefy_gadget::beefy_peers_set_config()); } @@ -921,28 +921,19 @@ pub fn new_full( task_manager.spawn_essential_handle().spawn_blocking("babe", babe); } - // We currently only run the BEEFY gadget on Rococo and Westend test - // networks. On Rococo we start the BEEFY gadget as a normal (non-essential) - // task for now, since BEEFY is still experimental and we don't want a - // failure to bring down the whole node. Westend test network is less used - // than Rococo and therefore a failure there will be less problematic, this - // will be the main testing target for BEEFY for now. - if chain_spec.is_westend() || chain_spec.is_rococo() { + // We currently only run the BEEFY gadget on Rococo. + if chain_spec.is_rococo() { let gadget = beefy_gadget::start_beefy_gadget::<_, beefy_primitives::ecdsa::AuthorityPair, _, _, _, _>( client.clone(), keystore_container.sync_keystore(), network.clone(), beefy_link, network.clone(), - if chain_spec.is_westend() { 4 } else { 8 }, + 8, prometheus_registry.clone() ); - if chain_spec.is_westend() { - task_manager.spawn_essential_handle().spawn_blocking("beefy-gadget", gadget); - } else { - task_manager.spawn_handle().spawn_blocking("beefy-gadget", gadget); - } + task_manager.spawn_handle().spawn_blocking("beefy-gadget", gadget); } // if the node isn't actively participating in consensus then it doesn't diff --git a/polkadot/runtime/westend/Cargo.toml b/polkadot/runtime/westend/Cargo.toml index 93cc15d10b..58ba26445e 100644 --- a/polkadot/runtime/westend/Cargo.toml +++ b/polkadot/runtime/westend/Cargo.toml @@ -35,7 +35,6 @@ sp-npos-elections = { git = "https://github.com/paritytech/substrate", branch = pallet-authority-discovery = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-authorship = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-babe = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } -pallet-beefy = { git = "https://github.com/paritytech/grandpa-bridge-gadget", branch = "master", default-features = false } pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } @@ -49,7 +48,6 @@ pallet-identity = { git = "https://github.com/paritytech/substrate", branch = "m pallet-im-online = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-indices = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-membership = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } -pallet-mmr = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-mmr-primitives = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-multisig = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-nicks = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } @@ -128,8 +126,6 @@ std = [ "pallet-im-online/std", "pallet-indices/std", "pallet-membership/std", - "pallet-beefy/std", - "pallet-mmr/std", "pallet-mmr-primitives/std", "beefy-primitives/std", "pallet-multisig/std", @@ -179,7 +175,6 @@ runtime-benchmarks = [ "pallet-identity/runtime-benchmarks", "pallet-im-online/runtime-benchmarks", "pallet-indices/runtime-benchmarks", - "pallet-mmr/runtime-benchmarks", "pallet-multisig/runtime-benchmarks", "pallet-proxy/runtime-benchmarks", "pallet-scheduler/runtime-benchmarks", diff --git a/polkadot/runtime/westend/src/lib.rs b/polkadot/runtime/westend/src/lib.rs index 32af630a11..9ae097ae31 100644 --- a/polkadot/runtime/westend/src/lib.rs +++ b/polkadot/runtime/westend/src/lib.rs @@ -31,7 +31,6 @@ use primitives::v1::{ InboundDownwardMessage, InboundHrmpMessage, SessionInfo, }; use runtime_common::{ - mmr as mmr_common, SlowAdjustingFeeUpdate, CurrencyToVote, impls::ToAuthor, BlockHashCount, BlockWeights, BlockLength, RocksDbWeight, @@ -43,7 +42,7 @@ use sp_runtime::{ ApplyExtrinsicResult, KeyTypeId, Perbill, curve::PiecewiseLinear, transaction_validity::{TransactionValidity, TransactionSource, TransactionPriority}, traits::{ - Keccak256, BlakeTwo256, Block as BlockT, OpaqueKeys, ConvertInto, AccountIdLookup, + BlakeTwo256, Block as BlockT, OpaqueKeys, ConvertInto, AccountIdLookup, Extrinsic as ExtrinsicT, SaturatedConversion, Verify, }, }; @@ -91,7 +90,6 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("westend"), impl_name: create_runtime_str!("parity-westend"), authoring_version: 2, - // NOTE: see https://github.com/paritytech/polkadot/wiki/Westend spec_version: 51, impl_version: 0, #[cfg(not(feature = "disable-runtime-api"))] @@ -269,18 +267,6 @@ parameter_types! { pub const Offset: BlockNumber = 0; } -// TODO [ToDr] Remove while BEEFY runtime upgrade is done. -impl_opaque_keys! { - pub struct OldSessionKeys { - pub grandpa: Grandpa, - pub babe: Babe, - pub im_online: ImOnline, - pub para_validator: ParachainSessionKeyPlaceholder, - pub para_assignment: AssignmentSessionKeyPlaceholder, - pub authority_discovery: AuthorityDiscovery, - } -} - impl_opaque_keys! { pub struct SessionKeys { pub grandpa: Grandpa, @@ -289,28 +275,6 @@ impl_opaque_keys! { pub para_validator: ParachainSessionKeyPlaceholder, pub para_assignment: AssignmentSessionKeyPlaceholder, pub authority_discovery: AuthorityDiscovery, - pub beefy: Beefy, - } -} - -fn transform_session_keys(v: AccountId, old: OldSessionKeys) -> SessionKeys { - SessionKeys { - grandpa: old.grandpa, - babe: old.babe, - im_online: old.im_online, - para_validator: old.para_validator, - para_assignment: old.para_assignment, - authority_discovery: old.authority_discovery, - beefy: runtime_common::dummy_beefy_id_from_account_id(v), - } -} - -// When this is removed, should also remove `OldSessionKeys`. -pub struct UpgradeSessionKeys; -impl frame_support::traits::OnRuntimeUpgrade for UpgradeSessionKeys { - fn on_runtime_upgrade() -> frame_support::weights::Weight { - Session::upgrade_keys::(transform_session_keys); - Perbill::from_percent(50) * BlockWeights::get().max_block } } @@ -622,24 +586,6 @@ impl pallet_sudo::Config for Runtime { type Call = Call; } -impl pallet_beefy::Config for Runtime { - type AuthorityId = BeefyId; -} - -impl pallet_mmr::Config for Runtime { - const INDEXING_PREFIX: &'static [u8] = b"mmr"; - type Hashing = Keccak256; - type Hash = ::Output; - type OnNewRoot = mmr_common::DepositBeefyDigest; - type WeightInfo = (); - type LeafData = mmr_common::Pallet; -} - -impl mmr_common::Config for Runtime { - type BeefyAuthorityToMerkleLeaf = mmr_common::UncompressBeefyEcdsaKeys; - type ParachainHeads = (); -} - parameter_types! { // One storage item; key size 32, value size 8; . pub const ProxyDepositBase: Balance = deposit(1, 8); @@ -798,11 +744,6 @@ construct_runtime! { // Election pallet. Only works with staking, but placed here to maintain indices. ElectionProviderMultiPhase: pallet_election_provider_multi_phase::{Pallet, Call, Storage, Event, ValidateUnsigned} = 24, - - // Bridges support. - Mmr: pallet_mmr::{Pallet, Call, Storage} = 28, - Beefy: pallet_beefy::{Pallet, Config, Storage} = 29, - MmrLeaf: mmr_common::{Pallet, Storage} = 30, } } @@ -841,7 +782,7 @@ pub type Executive = frame_executive::Executive< frame_system::ChainContext, Runtime, AllPallets, - UpgradeSessionKeys, + (), >; /// The payload being signed in transactions. pub type SignedPayload = generic::SignedPayload; @@ -976,40 +917,33 @@ sp_api::impl_runtime_apis! { impl beefy_primitives::BeefyApi for Runtime { fn validator_set() -> beefy_primitives::ValidatorSet { - Beefy::validator_set() + // dummy implementation due to lack of BEEFY pallet. + beefy_primitives::ValidatorSet { validators: Vec::new(), id: 0 } } } impl pallet_mmr_primitives::MmrApi for Runtime { - fn generate_proof(leaf_index: u64) + fn generate_proof(_leaf_index: u64) -> Result<(mmr::EncodableOpaqueLeaf, mmr::Proof), mmr::Error> { - Mmr::generate_proof(leaf_index) - .map(|(leaf, proof)| (mmr::EncodableOpaqueLeaf::from_leaf(&leaf), proof)) + // dummy implementation due to lack of MMR pallet. + Err(mmr::Error::GenerateProof) } - fn verify_proof(leaf: mmr::EncodableOpaqueLeaf, proof: mmr::Proof) + fn verify_proof(_leaf: mmr::EncodableOpaqueLeaf, _proof: mmr::Proof) -> Result<(), mmr::Error> { - pub type Leaf = < - ::LeafData as mmr::LeafDataProvider - >::LeafData; - - let leaf: Leaf = leaf - .into_opaque_leaf() - .try_decode() - .ok_or(mmr::Error::Verify)?; - Mmr::verify_leaf(leaf, proof) + // dummy implementation due to lack of MMR pallet. + Err(mmr::Error::Verify) } fn verify_proof_stateless( - root: Hash, - leaf: mmr::EncodableOpaqueLeaf, - proof: mmr::Proof + _root: Hash, + _leaf: mmr::EncodableOpaqueLeaf, + _proof: mmr::Proof ) -> Result<(), mmr::Error> { - type MmrHashing = ::Hashing; - let node = mmr::DataOrHash::Data(leaf.into_opaque_leaf()); - pallet_mmr::verify_leaf_proof::(root, node, proof) + // dummy implementation due to lack of MMR pallet. + Err(mmr::Error::Verify) } }