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
This commit is contained in:
André Silva
2021-04-21 21:31:06 +01:00
committed by GitHub
parent 142a0aec2f
commit c25e79d8c4
5 changed files with 23 additions and 121 deletions
-2
View File
@@ -11190,7 +11190,6 @@ dependencies = [
"pallet-authorship", "pallet-authorship",
"pallet-babe", "pallet-babe",
"pallet-balances", "pallet-balances",
"pallet-beefy",
"pallet-collective", "pallet-collective",
"pallet-democracy", "pallet-democracy",
"pallet-election-provider-multi-phase", "pallet-election-provider-multi-phase",
@@ -11200,7 +11199,6 @@ dependencies = [
"pallet-im-online", "pallet-im-online",
"pallet-indices", "pallet-indices",
"pallet-membership", "pallet-membership",
"pallet-mmr",
"pallet-mmr-primitives", "pallet-mmr-primitives",
"pallet-multisig", "pallet-multisig",
"pallet-nicks", "pallet-nicks",
+3 -19
View File
@@ -155,7 +155,6 @@ fn westend_session_keys(
para_validator: ValidatorId, para_validator: ValidatorId,
para_assignment: AssignmentId, para_assignment: AssignmentId,
authority_discovery: AuthorityDiscoveryId, authority_discovery: AuthorityDiscoveryId,
beefy: BeefyId,
) -> westend::SessionKeys { ) -> westend::SessionKeys {
westend::SessionKeys { westend::SessionKeys {
babe, babe,
@@ -164,7 +163,6 @@ fn westend_session_keys(
para_validator, para_validator,
para_assignment, para_assignment,
authority_discovery, authority_discovery,
beefy,
} }
} }
@@ -306,7 +304,6 @@ fn westend_staging_testnet_config_genesis(wasm_binary: &[u8]) -> westend::Genesi
ValidatorId, ValidatorId,
AssignmentId, AssignmentId,
AuthorityDiscoveryId, AuthorityDiscoveryId,
BeefyId,
)> = vec![ )> = vec![
( (
//5FZoQhgUCmqBxnkHX7jCqThScS2xQWiwiF61msg63CFL3Y8f //5FZoQhgUCmqBxnkHX7jCqThScS2xQWiwiF61msg63CFL3Y8f
@@ -325,8 +322,6 @@ fn westend_staging_testnet_config_genesis(wasm_binary: &[u8]) -> westend::Genesi
hex!["0810d2113438bb14856b06383a4f0da4e5cc2f92a3fc18ef03a54b34c6007662"].unchecked_into(), hex!["0810d2113438bb14856b06383a4f0da4e5cc2f92a3fc18ef03a54b34c6007662"].unchecked_into(),
//5CkAdj1MpkMtQikrGXuzgzrRLvUnfLQH2JsnZa16u4cK2Xhf //5CkAdj1MpkMtQikrGXuzgzrRLvUnfLQH2JsnZa16u4cK2Xhf
hex!["1e18b5a9f872727189934a6988ff2a6732c87b9e31e2d694dd011aff9dfb2332"].unchecked_into(), hex!["1e18b5a9f872727189934a6988ff2a6732c87b9e31e2d694dd011aff9dfb2332"].unchecked_into(),
//5E6ogZEZyc5YZ3ijWUPB9M6Xtx6E9FabhmP9J4rwcEH6pLGv
hex!["0293be7cdb81f25039dfd01aac905da8a5e50113366bc4b5dc5eb888cf5552b8a9"].unchecked_into(),
), ),
( (
//5G1ojzh47Yt8KoYhuAjXpHcazvsoCXe3G8LZchKDvumozJJJ //5G1ojzh47Yt8KoYhuAjXpHcazvsoCXe3G8LZchKDvumozJJJ
@@ -345,8 +340,6 @@ fn westend_staging_testnet_config_genesis(wasm_binary: &[u8]) -> westend::Genesi
hex!["d6a113804a98728bb2af4f3721ab31a3644731292bffe0268995d8f8fb073b57"].unchecked_into(), hex!["d6a113804a98728bb2af4f3721ab31a3644731292bffe0268995d8f8fb073b57"].unchecked_into(),
//5DUrcztb1pRz6DfA8Vo8JSUSpoQVr27Yo6gjPmnumhhubLeN //5DUrcztb1pRz6DfA8Vo8JSUSpoQVr27Yo6gjPmnumhhubLeN
hex!["3ea7a06009d1b9b1d4233dea3e6bb6494b9aeda91edc443629a28afa9fab8c62"].unchecked_into(), hex!["3ea7a06009d1b9b1d4233dea3e6bb6494b9aeda91edc443629a28afa9fab8c62"].unchecked_into(),
//5HUYyVYXjm5mdEpDiykmhxZGzQjY4LLxyTPD7hfMjfLUy3VT
hex!["020e0ba5e112f0d3356ff8c78a37e2d7f76f90ab8dc9ed2eac98c87c5ffb2b0ebe"].unchecked_into(),
), ),
( (
//5HYYWyhyUQ7Ae11f8fCid58bhJ7ikLHM9bU8A6Ynwoc3dStR //5HYYWyhyUQ7Ae11f8fCid58bhJ7ikLHM9bU8A6Ynwoc3dStR
@@ -365,8 +358,6 @@ fn westend_staging_testnet_config_genesis(wasm_binary: &[u8]) -> westend::Genesi
hex!["0e5e1fb2c0fa7db11cd83fef3493900292badf02f35812ba738efeab9978a46c"].unchecked_into(), hex!["0e5e1fb2c0fa7db11cd83fef3493900292badf02f35812ba738efeab9978a46c"].unchecked_into(),
//5GvKehGrFVea8rywSeJhTopmpBDNHSFBoZp32g3CecppYa3V //5GvKehGrFVea8rywSeJhTopmpBDNHSFBoZp32g3CecppYa3V
hex!["d6c8735316211321cd85ccd7c583222ab024393b8c86c7c8d1192a1d4f35bb2e"].unchecked_into(), hex!["d6c8735316211321cd85ccd7c583222ab024393b8c86c7c8d1192a1d4f35bb2e"].unchecked_into(),
//5FpX3V5qCGehdTBRxkpHzGjwK9nvihLYj6gwR4NWn8DjbAoL
hex!["020b4bc2972761bd1abf20d5f83f79ff546ef63094e193d21758566c58dea9642f"].unchecked_into(),
), ),
( (
//5CFPcUJgYgWryPaV1aYjSbTpbTLu42V32Ytw1L9rfoMAsfGh //5CFPcUJgYgWryPaV1aYjSbTpbTLu42V32Ytw1L9rfoMAsfGh
@@ -385,8 +376,6 @@ fn westend_staging_testnet_config_genesis(wasm_binary: &[u8]) -> westend::Genesi
hex!["c4390ca0274f0262a4ef7cd4d3aa6cab0875a6efdd40d38c21be4f770b6c4b1a"].unchecked_into(), hex!["c4390ca0274f0262a4ef7cd4d3aa6cab0875a6efdd40d38c21be4f770b6c4b1a"].unchecked_into(),
//5CZd519gfE3gALMtFWa283VHikXwoGFmT92B3Nu3iN7YGcaR //5CZd519gfE3gALMtFWa283VHikXwoGFmT92B3Nu3iN7YGcaR
hex!["160e0049b62d368c59d286275697e8d5e68d34ee8663ac4c3da646b0abb4a86f"].unchecked_into(), 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))) .chain(initial_authorities.iter().map(|x| (x.0.clone(), STASH)))
.collect(), .collect(),
}, },
pallet_beefy: Default::default(),
pallet_indices: westend::IndicesConfig { indices: vec![] }, pallet_indices: westend::IndicesConfig { indices: vec![] },
pallet_session: westend::SessionConfig { pallet_session: westend::SessionConfig {
keys: initial_authorities keys: initial_authorities
@@ -422,7 +410,6 @@ fn westend_staging_testnet_config_genesis(wasm_binary: &[u8]) -> westend::Genesi
x.5.clone(), x.5.clone(),
x.6.clone(), x.6.clone(),
x.7.clone(), x.7.clone(),
x.8.clone(),
), ),
) )
}) })
@@ -1311,7 +1298,6 @@ pub fn westend_testnet_genesis(
ValidatorId, ValidatorId,
AssignmentId, AssignmentId,
AuthorityDiscoveryId, AuthorityDiscoveryId,
BeefyId,
)>, )>,
root_key: AccountId, root_key: AccountId,
endowed_accounts: Option<Vec<AccountId>>, endowed_accounts: Option<Vec<AccountId>>,
@@ -1333,7 +1319,6 @@ pub fn westend_testnet_genesis(
.map(|k| (k.clone(), ENDOWMENT)) .map(|k| (k.clone(), ENDOWMENT))
.collect(), .collect(),
}, },
pallet_beefy: Default::default(),
pallet_session: westend::SessionConfig { pallet_session: westend::SessionConfig {
keys: initial_authorities keys: initial_authorities
.iter() .iter()
@@ -1348,7 +1333,6 @@ pub fn westend_testnet_genesis(
x.5.clone(), x.5.clone(),
x.6.clone(), x.6.clone(),
x.7.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 { fn westend_development_config_genesis(wasm_binary: &[u8]) -> westend::GenesisConfig {
westend_testnet_genesis( westend_testnet_genesis(
wasm_binary, wasm_binary,
vec![get_authority_keys_from_seed("Alice")], vec![get_authority_keys_from_seed_no_beefy("Alice")],
get_account_id_from_seed::<sr25519::Public>("Alice"), get_account_id_from_seed::<sr25519::Public>("Alice"),
None, None,
) )
@@ -1634,8 +1618,8 @@ fn westend_local_testnet_genesis(wasm_binary: &[u8]) -> westend::GenesisConfig {
westend_testnet_genesis( westend_testnet_genesis(
wasm_binary, wasm_binary,
vec![ vec![
get_authority_keys_from_seed("Alice"), get_authority_keys_from_seed_no_beefy("Alice"),
get_authority_keys_from_seed("Bob"), get_authority_keys_from_seed_no_beefy("Bob"),
], ],
get_account_id_from_seed::<sr25519::Public>("Alice"), get_account_id_from_seed::<sr25519::Public>("Alice"),
None, None,
+4 -13
View File
@@ -715,7 +715,7 @@ pub fn new_full<RuntimeApi, Executor>(
// Substrate nodes. // Substrate nodes.
config.network.extra_sets.push(grandpa::grandpa_peers_set_config()); 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()); config.network.extra_sets.push(beefy_gadget::beefy_peers_set_config());
} }
@@ -921,29 +921,20 @@ pub fn new_full<RuntimeApi, Executor>(
task_manager.spawn_essential_handle().spawn_blocking("babe", babe); task_manager.spawn_essential_handle().spawn_blocking("babe", babe);
} }
// We currently only run the BEEFY gadget on Rococo and Westend test // We currently only run the BEEFY gadget on Rococo.
// networks. On Rococo we start the BEEFY gadget as a normal (non-essential) if chain_spec.is_rococo() {
// 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() {
let gadget = beefy_gadget::start_beefy_gadget::<_, beefy_primitives::ecdsa::AuthorityPair, _, _, _, _>( let gadget = beefy_gadget::start_beefy_gadget::<_, beefy_primitives::ecdsa::AuthorityPair, _, _, _, _>(
client.clone(), client.clone(),
keystore_container.sync_keystore(), keystore_container.sync_keystore(),
network.clone(), network.clone(),
beefy_link, beefy_link,
network.clone(), network.clone(),
if chain_spec.is_westend() { 4 } else { 8 }, 8,
prometheus_registry.clone() 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 // if the node isn't actively participating in consensus then it doesn't
// need a keystore, regardless of which protocol we use below. // need a keystore, regardless of which protocol we use below.
-5
View File
@@ -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-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-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-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-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 = { 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 } 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-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-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-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-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-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 } pallet-nicks = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
@@ -128,8 +126,6 @@ std = [
"pallet-im-online/std", "pallet-im-online/std",
"pallet-indices/std", "pallet-indices/std",
"pallet-membership/std", "pallet-membership/std",
"pallet-beefy/std",
"pallet-mmr/std",
"pallet-mmr-primitives/std", "pallet-mmr-primitives/std",
"beefy-primitives/std", "beefy-primitives/std",
"pallet-multisig/std", "pallet-multisig/std",
@@ -179,7 +175,6 @@ runtime-benchmarks = [
"pallet-identity/runtime-benchmarks", "pallet-identity/runtime-benchmarks",
"pallet-im-online/runtime-benchmarks", "pallet-im-online/runtime-benchmarks",
"pallet-indices/runtime-benchmarks", "pallet-indices/runtime-benchmarks",
"pallet-mmr/runtime-benchmarks",
"pallet-multisig/runtime-benchmarks", "pallet-multisig/runtime-benchmarks",
"pallet-proxy/runtime-benchmarks", "pallet-proxy/runtime-benchmarks",
"pallet-scheduler/runtime-benchmarks", "pallet-scheduler/runtime-benchmarks",
+15 -81
View File
@@ -31,7 +31,6 @@ use primitives::v1::{
InboundDownwardMessage, InboundHrmpMessage, SessionInfo, InboundDownwardMessage, InboundHrmpMessage, SessionInfo,
}; };
use runtime_common::{ use runtime_common::{
mmr as mmr_common,
SlowAdjustingFeeUpdate, CurrencyToVote, SlowAdjustingFeeUpdate, CurrencyToVote,
impls::ToAuthor, impls::ToAuthor,
BlockHashCount, BlockWeights, BlockLength, RocksDbWeight, BlockHashCount, BlockWeights, BlockLength, RocksDbWeight,
@@ -43,7 +42,7 @@ use sp_runtime::{
ApplyExtrinsicResult, KeyTypeId, Perbill, curve::PiecewiseLinear, ApplyExtrinsicResult, KeyTypeId, Perbill, curve::PiecewiseLinear,
transaction_validity::{TransactionValidity, TransactionSource, TransactionPriority}, transaction_validity::{TransactionValidity, TransactionSource, TransactionPriority},
traits::{ traits::{
Keccak256, BlakeTwo256, Block as BlockT, OpaqueKeys, ConvertInto, AccountIdLookup, BlakeTwo256, Block as BlockT, OpaqueKeys, ConvertInto, AccountIdLookup,
Extrinsic as ExtrinsicT, SaturatedConversion, Verify, Extrinsic as ExtrinsicT, SaturatedConversion, Verify,
}, },
}; };
@@ -91,7 +90,6 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("westend"), spec_name: create_runtime_str!("westend"),
impl_name: create_runtime_str!("parity-westend"), impl_name: create_runtime_str!("parity-westend"),
authoring_version: 2, authoring_version: 2,
// NOTE: see https://github.com/paritytech/polkadot/wiki/Westend
spec_version: 51, spec_version: 51,
impl_version: 0, impl_version: 0,
#[cfg(not(feature = "disable-runtime-api"))] #[cfg(not(feature = "disable-runtime-api"))]
@@ -269,18 +267,6 @@ parameter_types! {
pub const Offset: BlockNumber = 0; 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<Runtime>,
pub para_assignment: AssignmentSessionKeyPlaceholder<Runtime>,
pub authority_discovery: AuthorityDiscovery,
}
}
impl_opaque_keys! { impl_opaque_keys! {
pub struct SessionKeys { pub struct SessionKeys {
pub grandpa: Grandpa, pub grandpa: Grandpa,
@@ -289,28 +275,6 @@ impl_opaque_keys! {
pub para_validator: ParachainSessionKeyPlaceholder<Runtime>, pub para_validator: ParachainSessionKeyPlaceholder<Runtime>,
pub para_assignment: AssignmentSessionKeyPlaceholder<Runtime>, pub para_assignment: AssignmentSessionKeyPlaceholder<Runtime>,
pub authority_discovery: AuthorityDiscovery, 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::<OldSessionKeys, _>(transform_session_keys);
Perbill::from_percent(50) * BlockWeights::get().max_block
} }
} }
@@ -622,24 +586,6 @@ impl pallet_sudo::Config for Runtime {
type Call = Call; 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 = <Keccak256 as sp_runtime::traits::Hash>::Output;
type OnNewRoot = mmr_common::DepositBeefyDigest<Runtime>;
type WeightInfo = ();
type LeafData = mmr_common::Pallet<Runtime>;
}
impl mmr_common::Config for Runtime {
type BeefyAuthorityToMerkleLeaf = mmr_common::UncompressBeefyEcdsaKeys;
type ParachainHeads = ();
}
parameter_types! { parameter_types! {
// One storage item; key size 32, value size 8; . // One storage item; key size 32, value size 8; .
pub const ProxyDepositBase: Balance = deposit(1, 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. // Election pallet. Only works with staking, but placed here to maintain indices.
ElectionProviderMultiPhase: pallet_election_provider_multi_phase::{Pallet, Call, Storage, Event<T>, ValidateUnsigned} = 24, ElectionProviderMultiPhase: pallet_election_provider_multi_phase::{Pallet, Call, Storage, Event<T>, ValidateUnsigned} = 24,
// Bridges support.
Mmr: pallet_mmr::{Pallet, Call, Storage} = 28,
Beefy: pallet_beefy::{Pallet, Config<T>, Storage} = 29,
MmrLeaf: mmr_common::{Pallet, Storage} = 30,
} }
} }
@@ -841,7 +782,7 @@ pub type Executive = frame_executive::Executive<
frame_system::ChainContext<Runtime>, frame_system::ChainContext<Runtime>,
Runtime, Runtime,
AllPallets, AllPallets,
UpgradeSessionKeys, (),
>; >;
/// The payload being signed in transactions. /// The payload being signed in transactions.
pub type SignedPayload = generic::SignedPayload<Call, SignedExtra>; pub type SignedPayload = generic::SignedPayload<Call, SignedExtra>;
@@ -976,40 +917,33 @@ sp_api::impl_runtime_apis! {
impl beefy_primitives::BeefyApi<Block, BeefyId> for Runtime { impl beefy_primitives::BeefyApi<Block, BeefyId> for Runtime {
fn validator_set() -> beefy_primitives::ValidatorSet<BeefyId> { fn validator_set() -> beefy_primitives::ValidatorSet<BeefyId> {
Beefy::validator_set() // dummy implementation due to lack of BEEFY pallet.
beefy_primitives::ValidatorSet { validators: Vec::new(), id: 0 }
} }
} }
impl pallet_mmr_primitives::MmrApi<Block, Hash> for Runtime { impl pallet_mmr_primitives::MmrApi<Block, Hash> for Runtime {
fn generate_proof(leaf_index: u64) fn generate_proof(_leaf_index: u64)
-> Result<(mmr::EncodableOpaqueLeaf, mmr::Proof<Hash>), mmr::Error> -> Result<(mmr::EncodableOpaqueLeaf, mmr::Proof<Hash>), mmr::Error>
{ {
Mmr::generate_proof(leaf_index) // dummy implementation due to lack of MMR pallet.
.map(|(leaf, proof)| (mmr::EncodableOpaqueLeaf::from_leaf(&leaf), proof)) Err(mmr::Error::GenerateProof)
} }
fn verify_proof(leaf: mmr::EncodableOpaqueLeaf, proof: mmr::Proof<Hash>) fn verify_proof(_leaf: mmr::EncodableOpaqueLeaf, _proof: mmr::Proof<Hash>)
-> Result<(), mmr::Error> -> Result<(), mmr::Error>
{ {
pub type Leaf = < // dummy implementation due to lack of MMR pallet.
<Runtime as pallet_mmr::Config>::LeafData as mmr::LeafDataProvider Err(mmr::Error::Verify)
>::LeafData;
let leaf: Leaf = leaf
.into_opaque_leaf()
.try_decode()
.ok_or(mmr::Error::Verify)?;
Mmr::verify_leaf(leaf, proof)
} }
fn verify_proof_stateless( fn verify_proof_stateless(
root: Hash, _root: Hash,
leaf: mmr::EncodableOpaqueLeaf, _leaf: mmr::EncodableOpaqueLeaf,
proof: mmr::Proof<Hash> _proof: mmr::Proof<Hash>
) -> Result<(), mmr::Error> { ) -> Result<(), mmr::Error> {
type MmrHashing = <Runtime as pallet_mmr::Config>::Hashing; // dummy implementation due to lack of MMR pallet.
let node = mmr::DataOrHash::Data(leaf.into_opaque_leaf()); Err(mmr::Error::Verify)
pallet_mmr::verify_leaf_proof::<MmrHashing, _>(root, node, proof)
} }
} }