Skip to content

Commit d4f4ad4

Browse files
authoredApr 21, 2021
runtime: remove mmr and beefy from westend runtime (paritytech#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
1 parent 89e7b9c commit d4f4ad4

File tree

5 files changed

+23
-121
lines changed

5 files changed

+23
-121
lines changed
 

‎Cargo.lock

-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎node/service/src/chain_spec.rs

+3-19
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,6 @@ fn westend_session_keys(
155155
para_validator: ValidatorId,
156156
para_assignment: AssignmentId,
157157
authority_discovery: AuthorityDiscoveryId,
158-
beefy: BeefyId,
159158
) -> westend::SessionKeys {
160159
westend::SessionKeys {
161160
babe,
@@ -164,7 +163,6 @@ fn westend_session_keys(
164163
para_validator,
165164
para_assignment,
166165
authority_discovery,
167-
beefy,
168166
}
169167
}
170168

@@ -306,7 +304,6 @@ fn westend_staging_testnet_config_genesis(wasm_binary: &[u8]) -> westend::Genesi
306304
ValidatorId,
307305
AssignmentId,
308306
AuthorityDiscoveryId,
309-
BeefyId,
310307
)> = vec![
311308
(
312309
//5FZoQhgUCmqBxnkHX7jCqThScS2xQWiwiF61msg63CFL3Y8f
@@ -325,8 +322,6 @@ fn westend_staging_testnet_config_genesis(wasm_binary: &[u8]) -> westend::Genesi
325322
hex!["0810d2113438bb14856b06383a4f0da4e5cc2f92a3fc18ef03a54b34c6007662"].unchecked_into(),
326323
//5CkAdj1MpkMtQikrGXuzgzrRLvUnfLQH2JsnZa16u4cK2Xhf
327324
hex!["1e18b5a9f872727189934a6988ff2a6732c87b9e31e2d694dd011aff9dfb2332"].unchecked_into(),
328-
//5E6ogZEZyc5YZ3ijWUPB9M6Xtx6E9FabhmP9J4rwcEH6pLGv
329-
hex!["0293be7cdb81f25039dfd01aac905da8a5e50113366bc4b5dc5eb888cf5552b8a9"].unchecked_into(),
330325
),
331326
(
332327
//5G1ojzh47Yt8KoYhuAjXpHcazvsoCXe3G8LZchKDvumozJJJ
@@ -345,8 +340,6 @@ fn westend_staging_testnet_config_genesis(wasm_binary: &[u8]) -> westend::Genesi
345340
hex!["d6a113804a98728bb2af4f3721ab31a3644731292bffe0268995d8f8fb073b57"].unchecked_into(),
346341
//5DUrcztb1pRz6DfA8Vo8JSUSpoQVr27Yo6gjPmnumhhubLeN
347342
hex!["3ea7a06009d1b9b1d4233dea3e6bb6494b9aeda91edc443629a28afa9fab8c62"].unchecked_into(),
348-
//5HUYyVYXjm5mdEpDiykmhxZGzQjY4LLxyTPD7hfMjfLUy3VT
349-
hex!["020e0ba5e112f0d3356ff8c78a37e2d7f76f90ab8dc9ed2eac98c87c5ffb2b0ebe"].unchecked_into(),
350343
),
351344
(
352345
//5HYYWyhyUQ7Ae11f8fCid58bhJ7ikLHM9bU8A6Ynwoc3dStR
@@ -365,8 +358,6 @@ fn westend_staging_testnet_config_genesis(wasm_binary: &[u8]) -> westend::Genesi
365358
hex!["0e5e1fb2c0fa7db11cd83fef3493900292badf02f35812ba738efeab9978a46c"].unchecked_into(),
366359
//5GvKehGrFVea8rywSeJhTopmpBDNHSFBoZp32g3CecppYa3V
367360
hex!["d6c8735316211321cd85ccd7c583222ab024393b8c86c7c8d1192a1d4f35bb2e"].unchecked_into(),
368-
//5FpX3V5qCGehdTBRxkpHzGjwK9nvihLYj6gwR4NWn8DjbAoL
369-
hex!["020b4bc2972761bd1abf20d5f83f79ff546ef63094e193d21758566c58dea9642f"].unchecked_into(),
370361
),
371362
(
372363
//5CFPcUJgYgWryPaV1aYjSbTpbTLu42V32Ytw1L9rfoMAsfGh
@@ -385,8 +376,6 @@ fn westend_staging_testnet_config_genesis(wasm_binary: &[u8]) -> westend::Genesi
385376
hex!["c4390ca0274f0262a4ef7cd4d3aa6cab0875a6efdd40d38c21be4f770b6c4b1a"].unchecked_into(),
386377
//5CZd519gfE3gALMtFWa283VHikXwoGFmT92B3Nu3iN7YGcaR
387378
hex!["160e0049b62d368c59d286275697e8d5e68d34ee8663ac4c3da646b0abb4a86f"].unchecked_into(),
388-
//5Fnu4YYBx9V71ihCBkJyFGsKw9Q2jjNzRQL9kRNpKTPNSAhc
389-
hex!["03e9393ee30ae95fc2b7864230f53e45409a807949390140ce2bc77756cdb4bb83"].unchecked_into(),
390379
),
391380

392381
];
@@ -406,7 +395,6 @@ fn westend_staging_testnet_config_genesis(wasm_binary: &[u8]) -> westend::Genesi
406395
.chain(initial_authorities.iter().map(|x| (x.0.clone(), STASH)))
407396
.collect(),
408397
},
409-
pallet_beefy: Default::default(),
410398
pallet_indices: westend::IndicesConfig { indices: vec![] },
411399
pallet_session: westend::SessionConfig {
412400
keys: initial_authorities
@@ -422,7 +410,6 @@ fn westend_staging_testnet_config_genesis(wasm_binary: &[u8]) -> westend::Genesi
422410
x.5.clone(),
423411
x.6.clone(),
424412
x.7.clone(),
425-
x.8.clone(),
426413
),
427414
)
428415
})
@@ -1311,7 +1298,6 @@ pub fn westend_testnet_genesis(
13111298
ValidatorId,
13121299
AssignmentId,
13131300
AuthorityDiscoveryId,
1314-
BeefyId,
13151301
)>,
13161302
root_key: AccountId,
13171303
endowed_accounts: Option<Vec<AccountId>>,
@@ -1333,7 +1319,6 @@ pub fn westend_testnet_genesis(
13331319
.map(|k| (k.clone(), ENDOWMENT))
13341320
.collect(),
13351321
},
1336-
pallet_beefy: Default::default(),
13371322
pallet_session: westend::SessionConfig {
13381323
keys: initial_authorities
13391324
.iter()
@@ -1348,7 +1333,6 @@ pub fn westend_testnet_genesis(
13481333
x.5.clone(),
13491334
x.6.clone(),
13501335
x.7.clone(),
1351-
x.8.clone(),
13521336
),
13531337
)
13541338
})
@@ -1515,7 +1499,7 @@ fn kusama_development_config_genesis(wasm_binary: &[u8]) -> kusama::GenesisConfi
15151499
fn westend_development_config_genesis(wasm_binary: &[u8]) -> westend::GenesisConfig {
15161500
westend_testnet_genesis(
15171501
wasm_binary,
1518-
vec![get_authority_keys_from_seed("Alice")],
1502+
vec![get_authority_keys_from_seed_no_beefy("Alice")],
15191503
get_account_id_from_seed::<sr25519::Public>("Alice"),
15201504
None,
15211505
)
@@ -1634,8 +1618,8 @@ fn westend_local_testnet_genesis(wasm_binary: &[u8]) -> westend::GenesisConfig {
16341618
westend_testnet_genesis(
16351619
wasm_binary,
16361620
vec![
1637-
get_authority_keys_from_seed("Alice"),
1638-
get_authority_keys_from_seed("Bob"),
1621+
get_authority_keys_from_seed_no_beefy("Alice"),
1622+
get_authority_keys_from_seed_no_beefy("Bob"),
16391623
],
16401624
get_account_id_from_seed::<sr25519::Public>("Alice"),
16411625
None,

‎node/service/src/lib.rs

+5-14
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,7 @@ pub fn new_full<RuntimeApi, Executor>(
715715
// Substrate nodes.
716716
config.network.extra_sets.push(grandpa::grandpa_peers_set_config());
717717

718-
if config.chain_spec.is_westend() || config.chain_spec.is_rococo() {
718+
if config.chain_spec.is_rococo() {
719719
config.network.extra_sets.push(beefy_gadget::beefy_peers_set_config());
720720
}
721721

@@ -921,28 +921,19 @@ pub fn new_full<RuntimeApi, Executor>(
921921
task_manager.spawn_essential_handle().spawn_blocking("babe", babe);
922922
}
923923

924-
// We currently only run the BEEFY gadget on Rococo and Westend test
925-
// networks. On Rococo we start the BEEFY gadget as a normal (non-essential)
926-
// task for now, since BEEFY is still experimental and we don't want a
927-
// failure to bring down the whole node. Westend test network is less used
928-
// than Rococo and therefore a failure there will be less problematic, this
929-
// will be the main testing target for BEEFY for now.
930-
if chain_spec.is_westend() || chain_spec.is_rococo() {
924+
// We currently only run the BEEFY gadget on Rococo.
925+
if chain_spec.is_rococo() {
931926
let gadget = beefy_gadget::start_beefy_gadget::<_, beefy_primitives::ecdsa::AuthorityPair, _, _, _, _>(
932927
client.clone(),
933928
keystore_container.sync_keystore(),
934929
network.clone(),
935930
beefy_link,
936931
network.clone(),
937-
if chain_spec.is_westend() { 4 } else { 8 },
932+
8,
938933
prometheus_registry.clone()
939934
);
940935

941-
if chain_spec.is_westend() {
942-
task_manager.spawn_essential_handle().spawn_blocking("beefy-gadget", gadget);
943-
} else {
944-
task_manager.spawn_handle().spawn_blocking("beefy-gadget", gadget);
945-
}
936+
task_manager.spawn_handle().spawn_blocking("beefy-gadget", gadget);
946937
}
947938

948939
// if the node isn't actively participating in consensus then it doesn't

‎runtime/westend/Cargo.toml

-5
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ sp-npos-elections = { git = "https://github.com/paritytech/substrate", branch =
3535
pallet-authority-discovery = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
3636
pallet-authorship = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
3737
pallet-babe = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
38-
pallet-beefy = { git = "https://github.com/paritytech/grandpa-bridge-gadget", branch = "master", default-features = false }
3938
pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
4039
pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
4140
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
4948
pallet-im-online = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
5049
pallet-indices = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
5150
pallet-membership = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
52-
pallet-mmr = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
5351
pallet-mmr-primitives = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
5452
pallet-multisig = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
5553
pallet-nicks = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
@@ -128,8 +126,6 @@ std = [
128126
"pallet-im-online/std",
129127
"pallet-indices/std",
130128
"pallet-membership/std",
131-
"pallet-beefy/std",
132-
"pallet-mmr/std",
133129
"pallet-mmr-primitives/std",
134130
"beefy-primitives/std",
135131
"pallet-multisig/std",
@@ -179,7 +175,6 @@ runtime-benchmarks = [
179175
"pallet-identity/runtime-benchmarks",
180176
"pallet-im-online/runtime-benchmarks",
181177
"pallet-indices/runtime-benchmarks",
182-
"pallet-mmr/runtime-benchmarks",
183178
"pallet-multisig/runtime-benchmarks",
184179
"pallet-proxy/runtime-benchmarks",
185180
"pallet-scheduler/runtime-benchmarks",

‎runtime/westend/src/lib.rs

+15-81
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ use primitives::v1::{
3131
InboundDownwardMessage, InboundHrmpMessage, SessionInfo,
3232
};
3333
use runtime_common::{
34-
mmr as mmr_common,
3534
SlowAdjustingFeeUpdate, CurrencyToVote,
3635
impls::ToAuthor,
3736
BlockHashCount, BlockWeights, BlockLength, RocksDbWeight,
@@ -43,7 +42,7 @@ use sp_runtime::{
4342
ApplyExtrinsicResult, KeyTypeId, Perbill, curve::PiecewiseLinear,
4443
transaction_validity::{TransactionValidity, TransactionSource, TransactionPriority},
4544
traits::{
46-
Keccak256, BlakeTwo256, Block as BlockT, OpaqueKeys, ConvertInto, AccountIdLookup,
45+
BlakeTwo256, Block as BlockT, OpaqueKeys, ConvertInto, AccountIdLookup,
4746
Extrinsic as ExtrinsicT, SaturatedConversion, Verify,
4847
},
4948
};
@@ -91,7 +90,6 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
9190
spec_name: create_runtime_str!("westend"),
9291
impl_name: create_runtime_str!("parity-westend"),
9392
authoring_version: 2,
94-
// NOTE: see https://github.com/paritytech/polkadot/wiki/Westend
9593
spec_version: 51,
9694
impl_version: 0,
9795
#[cfg(not(feature = "disable-runtime-api"))]
@@ -269,18 +267,6 @@ parameter_types! {
269267
pub const Offset: BlockNumber = 0;
270268
}
271269

272-
// TODO [ToDr] Remove while BEEFY runtime upgrade is done.
273-
impl_opaque_keys! {
274-
pub struct OldSessionKeys {
275-
pub grandpa: Grandpa,
276-
pub babe: Babe,
277-
pub im_online: ImOnline,
278-
pub para_validator: ParachainSessionKeyPlaceholder<Runtime>,
279-
pub para_assignment: AssignmentSessionKeyPlaceholder<Runtime>,
280-
pub authority_discovery: AuthorityDiscovery,
281-
}
282-
}
283-
284270
impl_opaque_keys! {
285271
pub struct SessionKeys {
286272
pub grandpa: Grandpa,
@@ -289,28 +275,6 @@ impl_opaque_keys! {
289275
pub para_validator: ParachainSessionKeyPlaceholder<Runtime>,
290276
pub para_assignment: AssignmentSessionKeyPlaceholder<Runtime>,
291277
pub authority_discovery: AuthorityDiscovery,
292-
pub beefy: Beefy,
293-
}
294-
}
295-
296-
fn transform_session_keys(v: AccountId, old: OldSessionKeys) -> SessionKeys {
297-
SessionKeys {
298-
grandpa: old.grandpa,
299-
babe: old.babe,
300-
im_online: old.im_online,
301-
para_validator: old.para_validator,
302-
para_assignment: old.para_assignment,
303-
authority_discovery: old.authority_discovery,
304-
beefy: runtime_common::dummy_beefy_id_from_account_id(v),
305-
}
306-
}
307-
308-
// When this is removed, should also remove `OldSessionKeys`.
309-
pub struct UpgradeSessionKeys;
310-
impl frame_support::traits::OnRuntimeUpgrade for UpgradeSessionKeys {
311-
fn on_runtime_upgrade() -> frame_support::weights::Weight {
312-
Session::upgrade_keys::<OldSessionKeys, _>(transform_session_keys);
313-
Perbill::from_percent(50) * BlockWeights::get().max_block
314278
}
315279
}
316280

@@ -622,24 +586,6 @@ impl pallet_sudo::Config for Runtime {
622586
type Call = Call;
623587
}
624588

625-
impl pallet_beefy::Config for Runtime {
626-
type AuthorityId = BeefyId;
627-
}
628-
629-
impl pallet_mmr::Config for Runtime {
630-
const INDEXING_PREFIX: &'static [u8] = b"mmr";
631-
type Hashing = Keccak256;
632-
type Hash = <Keccak256 as sp_runtime::traits::Hash>::Output;
633-
type OnNewRoot = mmr_common::DepositBeefyDigest<Runtime>;
634-
type WeightInfo = ();
635-
type LeafData = mmr_common::Pallet<Runtime>;
636-
}
637-
638-
impl mmr_common::Config for Runtime {
639-
type BeefyAuthorityToMerkleLeaf = mmr_common::UncompressBeefyEcdsaKeys;
640-
type ParachainHeads = ();
641-
}
642-
643589
parameter_types! {
644590
// One storage item; key size 32, value size 8; .
645591
pub const ProxyDepositBase: Balance = deposit(1, 8);
@@ -798,11 +744,6 @@ construct_runtime! {
798744

799745
// Election pallet. Only works with staking, but placed here to maintain indices.
800746
ElectionProviderMultiPhase: pallet_election_provider_multi_phase::{Pallet, Call, Storage, Event<T>, ValidateUnsigned} = 24,
801-
802-
// Bridges support.
803-
Mmr: pallet_mmr::{Pallet, Call, Storage} = 28,
804-
Beefy: pallet_beefy::{Pallet, Config<T>, Storage} = 29,
805-
MmrLeaf: mmr_common::{Pallet, Storage} = 30,
806747
}
807748
}
808749

@@ -841,7 +782,7 @@ pub type Executive = frame_executive::Executive<
841782
frame_system::ChainContext<Runtime>,
842783
Runtime,
843784
AllPallets,
844-
UpgradeSessionKeys,
785+
(),
845786
>;
846787
/// The payload being signed in transactions.
847788
pub type SignedPayload = generic::SignedPayload<Call, SignedExtra>;
@@ -976,40 +917,33 @@ sp_api::impl_runtime_apis! {
976917

977918
impl beefy_primitives::BeefyApi<Block, BeefyId> for Runtime {
978919
fn validator_set() -> beefy_primitives::ValidatorSet<BeefyId> {
979-
Beefy::validator_set()
920+
// dummy implementation due to lack of BEEFY pallet.
921+
beefy_primitives::ValidatorSet { validators: Vec::new(), id: 0 }
980922
}
981923
}
982924

983925
impl pallet_mmr_primitives::MmrApi<Block, Hash> for Runtime {
984-
fn generate_proof(leaf_index: u64)
926+
fn generate_proof(_leaf_index: u64)
985927
-> Result<(mmr::EncodableOpaqueLeaf, mmr::Proof<Hash>), mmr::Error>
986928
{
987-
Mmr::generate_proof(leaf_index)
988-
.map(|(leaf, proof)| (mmr::EncodableOpaqueLeaf::from_leaf(&leaf), proof))
929+
// dummy implementation due to lack of MMR pallet.
930+
Err(mmr::Error::GenerateProof)
989931
}
990932

991-
fn verify_proof(leaf: mmr::EncodableOpaqueLeaf, proof: mmr::Proof<Hash>)
933+
fn verify_proof(_leaf: mmr::EncodableOpaqueLeaf, _proof: mmr::Proof<Hash>)
992934
-> Result<(), mmr::Error>
993935
{
994-
pub type Leaf = <
995-
<Runtime as pallet_mmr::Config>::LeafData as mmr::LeafDataProvider
996-
>::LeafData;
997-
998-
let leaf: Leaf = leaf
999-
.into_opaque_leaf()
1000-
.try_decode()
1001-
.ok_or(mmr::Error::Verify)?;
1002-
Mmr::verify_leaf(leaf, proof)
936+
// dummy implementation due to lack of MMR pallet.
937+
Err(mmr::Error::Verify)
1003938
}
1004939

1005940
fn verify_proof_stateless(
1006-
root: Hash,
1007-
leaf: mmr::EncodableOpaqueLeaf,
1008-
proof: mmr::Proof<Hash>
941+
_root: Hash,
942+
_leaf: mmr::EncodableOpaqueLeaf,
943+
_proof: mmr::Proof<Hash>
1009944
) -> Result<(), mmr::Error> {
1010-
type MmrHashing = <Runtime as pallet_mmr::Config>::Hashing;
1011-
let node = mmr::DataOrHash::Data(leaf.into_opaque_leaf());
1012-
pallet_mmr::verify_leaf_proof::<MmrHashing, _>(root, node, proof)
945+
// dummy implementation due to lack of MMR pallet.
946+
Err(mmr::Error::Verify)
1013947
}
1014948
}
1015949

0 commit comments

Comments
 (0)
Please sign in to comment.