Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Companion for substrate#12530: Consolidate and deduplicate MMR API methods #6167

Prev Previous commit
Next Next commit
merge verify_{batch_}proof functions
  • Loading branch information
Lederstrumpf committed Oct 18, 2022
commit eb7a29c8ee43c94635d8706d4b82af7a2b8553ed
8 changes: 1 addition & 7 deletions runtime/kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1715,12 +1715,6 @@ sp_api::impl_runtime_apis! {
}

impl mmr::MmrApi<Block, Hash, BlockNumber> for Runtime {
fn verify_proof(_leaf: mmr::EncodableOpaqueLeaf, _proof: mmr::Proof<Hash>)
-> Result<(), mmr::Error>
{
Err(mmr::Error::PalletNotIncluded)
}

fn verify_proof_stateless(
_root: Hash,
_leaf: mmr::EncodableOpaqueLeaf,
Expand All @@ -1740,7 +1734,7 @@ sp_api::impl_runtime_apis! {
Err(mmr::Error::PalletNotIncluded)
}

fn verify_batch_proof(_leaves: Vec<mmr::EncodableOpaqueLeaf>, _proof: mmr::BatchProof<Hash>)
fn verify_proof(_leaves: Vec<mmr::EncodableOpaqueLeaf>, _proof: mmr::BatchProof<Hash>)
-> Result<(), mmr::Error>
{
Err(mmr::Error::PalletNotIncluded)
Expand Down
8 changes: 1 addition & 7 deletions runtime/polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1809,12 +1809,6 @@ sp_api::impl_runtime_apis! {
}

impl mmr::MmrApi<Block, Hash, BlockNumber> for Runtime {
fn verify_proof(_leaf: mmr::EncodableOpaqueLeaf, _proof: mmr::Proof<Hash>)
-> Result<(), mmr::Error>
{
Err(mmr::Error::PalletNotIncluded)
}

fn verify_proof_stateless(
_root: Hash,
_leaf: mmr::EncodableOpaqueLeaf,
Expand All @@ -1834,7 +1828,7 @@ sp_api::impl_runtime_apis! {
Err(mmr::Error::PalletNotIncluded)
}

fn verify_batch_proof(_leaves: Vec<mmr::EncodableOpaqueLeaf>, _proof: mmr::BatchProof<Hash>)
fn verify_proof(_leaves: Vec<mmr::EncodableOpaqueLeaf>, _proof: mmr::BatchProof<Hash>)
-> Result<(), mmr::Error>
{
Err(mmr::Error::PalletNotIncluded)
Expand Down
13 changes: 1 addition & 12 deletions runtime/rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1691,17 +1691,6 @@ sp_api::impl_runtime_apis! {
}

impl mmr::MmrApi<Block, Hash, BlockNumber> for Runtime {
fn verify_proof(leaf: mmr::EncodableOpaqueLeaf, proof: mmr::Proof<Hash>)
-> Result<(), mmr::Error>
{
pub type MmrLeaf = <<Runtime as pallet_mmr::Config>::LeafData as mmr::LeafDataProvider>::LeafData;
let leaf: MmrLeaf = leaf
.into_opaque_leaf()
.try_decode()
.ok_or(mmr::Error::Verify)?;
Mmr::verify_leaves(vec![leaf], mmr::Proof::into_batch_proof(proof))
}

fn verify_proof_stateless(
root: Hash,
leaf: mmr::EncodableOpaqueLeaf,
Expand Down Expand Up @@ -1732,7 +1721,7 @@ sp_api::impl_runtime_apis! {
)
}

fn verify_batch_proof(leaves: Vec<mmr::EncodableOpaqueLeaf>, proof: mmr::BatchProof<Hash>)
fn verify_proof(leaves: Vec<mmr::EncodableOpaqueLeaf>, proof: mmr::BatchProof<Hash>)
-> Result<(), mmr::Error>
{
pub type MmrLeaf = <<Runtime as pallet_mmr::Config>::LeafData as mmr::LeafDataProvider>::LeafData;
Expand Down
8 changes: 1 addition & 7 deletions runtime/test-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -920,12 +920,6 @@ sp_api::impl_runtime_apis! {
}

impl mmr::MmrApi<Block, Hash, BlockNumber> for Runtime {
fn verify_proof(_leaf: mmr::EncodableOpaqueLeaf, _proof: mmr::Proof<Hash>)
-> Result<(), mmr::Error>
{
Err(mmr::Error::PalletNotIncluded)
}

fn verify_proof_stateless(
_root: Hash,
_leaf: mmr::EncodableOpaqueLeaf,
Expand All @@ -945,7 +939,7 @@ sp_api::impl_runtime_apis! {
Err(mmr::Error::PalletNotIncluded)
}

fn verify_batch_proof(_leaves: Vec<mmr::EncodableOpaqueLeaf>, _proof: mmr::BatchProof<Hash>)
fn verify_proof(_leaves: Vec<mmr::EncodableOpaqueLeaf>, _proof: mmr::BatchProof<Hash>)
-> Result<(), mmr::Error>
{
Err(mmr::Error::PalletNotIncluded)
Expand Down
9 changes: 1 addition & 8 deletions runtime/westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1449,13 +1449,6 @@ sp_api::impl_runtime_apis! {
}

impl mmr::MmrApi<Block, Hash, BlockNumber> for Runtime {
fn verify_proof(_leaf: mmr::EncodableOpaqueLeaf, _proof: mmr::Proof<Hash>)
-> Result<(), mmr::Error>
{

Err(mmr::Error::PalletNotIncluded)
}

fn verify_proof_stateless(
_root: Hash,
_leaf: mmr::EncodableOpaqueLeaf,
Expand All @@ -1477,7 +1470,7 @@ sp_api::impl_runtime_apis! {
Err(mmr::Error::PalletNotIncluded)
}

fn verify_batch_proof(_leaves: Vec<mmr::EncodableOpaqueLeaf>, _proof: mmr::BatchProof<Hash>)
fn verify_proof(_leaves: Vec<mmr::EncodableOpaqueLeaf>, _proof: mmr::BatchProof<Hash>)
-> Result<(), mmr::Error>
{

Expand Down