beefy: put not only lease parachain heads into mmr (#4751)
Short-term addresses https://github.com/paritytech/polkadot-sdk/issues/4737. - [x] Resolve benchmarking I've digged into benchmarking mentioned https://github.com/paritytech/polkadot-sdk/issues/4737#issuecomment-2155084660, but it seemed to me that this code is different proof/path. @acatangiu could you confirm? (btw, in this [bench](https://github.com/paritytech/polkadot-sdk/blob/b65313e8 /bridges/modules/parachains/src/benchmarking.rs#L57), where do you actually set the `fn parachains()` to a reasonable number? i've only seen 1) - [ ] Communicate to Snowfork team: This seems to be the relevant code: https://github.com/Snowfork/snowbridge/blob/1e18e010331777042aa7e8fff3c118094af856ba/relayer/cmd/parachain_head_proof.go#L95-L120 - [x] Is it preferred to iter() in some random order as suggested in https://github.com/paritytech/polkadot-sdk/issues/4737#issuecomment-2155084660 or take lowest para ids instead as implemented here currently? - [x] PRDoc ## Updating Polkadot and Kusama runtimes: New weights need to be generated (`pallet_mmr`) and configs updated similar to Rococo/Westend: ```patch diff --git a/polkadot/runtime/rococo/src/lib.rs b/polkadot/runtime/rococo/src/lib.rs index 5adffbd7422..c7da339b981 100644 --- a/polkadot/runtime/rococo/src/lib.rs +++ b/polkadot/runtime/rococo/src/lib.rs @@ -1307,9 +1307,11 @@ impl pallet_mmr::Config for Runtime { const INDEXING_PREFIX: &'static [u8] = mmr::INDEXING_PREFIX; type Hashing = Keccak256; type OnNewRoot = pallet_beefy_mmr::DepositBeefyDigest<Runtime>; - type WeightInfo = (); type LeafData = pallet_beefy_mmr::Pallet<Runtime>; type BlockHashProvider = pallet_mmr::DefaultBlockHashProvider<Runtime>; + type WeightInfo = weights::pallet_mmr::WeightInfo<Runtime>; + #[cfg(feature = "runtime-benchmarks")] + type BenchmarkHelper = parachains_paras::benchmarking::mmr_setup::MmrSetup<Runtime>; } parameter_types! { @@ -1319,13 +1321,8 @@ parameter_types! { pub struct ParaHeadsRootProvider; impl BeefyDataProvider<H256> for ParaHeadsRootProvider { fn extra_data() -> H256 { - let mut para_heads: Vec<(u32, Vec<u8>)> = parachains_paras::Parachains::<Runtime>::get() - .into_iter() - .filter_map(|id| { - parachains_paras::Heads::<Runtime>::get(&id).map(|head| (id.into(), head.0)) - }) - .collect(); - para_heads.sort(); + let para_heads: Vec<(u32, Vec<u8>)> = + parachains_paras::Pallet::<Runtime>::sorted_para_heads(); binary_merkle_tree::merkle_root::<mmr::Hashing, _>( para_heads.into_iter().map(|pair| pair.encode()), ) @@ -1746,6 +1743,7 @@ mod benches { [pallet_identity, Identity] [pallet_indices, Indices] [pallet_message_queue, MessageQueue] + [pallet_mmr, Mmr] [pallet_multisig, Multisig] [pallet_parameters, Parameters] [pallet_preimage, Preimage] ``` --------- Co-authored-by:Adrian Catangiu <adrian@parity.io>
parent
d16af0b8
Showing
- Cargo.lock 2 additions, 0 deletionsCargo.lock
- polkadot/runtime/parachains/Cargo.toml 7 additions, 0 deletionspolkadot/runtime/parachains/Cargo.toml
- polkadot/runtime/parachains/src/paras/benchmarking.rs 1 addition, 0 deletionspolkadot/runtime/parachains/src/paras/benchmarking.rs
- polkadot/runtime/parachains/src/paras/benchmarking/mmr_setup.rs 40 additions, 0 deletions...ot/runtime/parachains/src/paras/benchmarking/mmr_setup.rs
- polkadot/runtime/parachains/src/paras/mod.rs 20 additions, 1 deletionpolkadot/runtime/parachains/src/paras/mod.rs
- polkadot/runtime/rococo/Cargo.toml 5 additions, 1 deletionpolkadot/runtime/rococo/Cargo.toml
- polkadot/runtime/rococo/src/lib.rs 6 additions, 8 deletionspolkadot/runtime/rococo/src/lib.rs
- polkadot/runtime/rococo/src/weights/mod.rs 1 addition, 0 deletionspolkadot/runtime/rococo/src/weights/mod.rs
- polkadot/runtime/rococo/src/weights/pallet_mmr.rs 77 additions, 0 deletionspolkadot/runtime/rococo/src/weights/pallet_mmr.rs
- polkadot/runtime/westend/Cargo.toml 5 additions, 1 deletionpolkadot/runtime/westend/Cargo.toml
- polkadot/runtime/westend/src/lib.rs 6 additions, 8 deletionspolkadot/runtime/westend/src/lib.rs
- polkadot/runtime/westend/src/weights/mod.rs 1 addition, 0 deletionspolkadot/runtime/westend/src/weights/mod.rs
- polkadot/runtime/westend/src/weights/pallet_mmr.rs 76 additions, 0 deletionspolkadot/runtime/westend/src/weights/pallet_mmr.rs
- prdoc/pr_4751.prdoc 22 additions, 0 deletionsprdoc/pr_4751.prdoc
- substrate/bin/node/runtime/src/lib.rs 2 additions, 0 deletionssubstrate/bin/node/runtime/src/lib.rs
- substrate/frame/beefy-mmr/Cargo.toml 7 additions, 0 deletionssubstrate/frame/beefy-mmr/Cargo.toml
- substrate/frame/beefy-mmr/src/mock.rs 3 additions, 0 deletionssubstrate/frame/beefy-mmr/src/mock.rs
- substrate/frame/merkle-mountain-range/src/benchmarking.rs 6 additions, 3 deletionssubstrate/frame/merkle-mountain-range/src/benchmarking.rs
- substrate/frame/merkle-mountain-range/src/default_weights.rs 2 additions, 1 deletionsubstrate/frame/merkle-mountain-range/src/default_weights.rs
- substrate/frame/merkle-mountain-range/src/lib.rs 19 additions, 4 deletionssubstrate/frame/merkle-mountain-range/src/lib.rs
Please register or sign in to comment