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

Companion for pallet-mmr: generate historical proofs #6061

Merged
merged 12 commits into from
Oct 2, 2022
7 changes: 7 additions & 0 deletions runtime/kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1722,6 +1722,13 @@ sp_api::impl_runtime_apis! {
Err(mmr::Error::PalletNotIncluded)
}

fn generate_historical_batch_proof(
_leaf_indices: Vec<u64>,
_leaves_count: u64,
) -> Result<(Vec<mmr::EncodableOpaqueLeaf>, mmr::BatchProof<Hash>), mmr::Error> {
Err(mmr::Error::PalletNotIncluded)
}

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

fn generate_historical_batch_proof(
_leaf_indices: Vec<u64>,
_leaves_count: u64,
) -> Result<(Vec<mmr::EncodableOpaqueLeaf>, mmr::BatchProof<Hash>), mmr::Error> {
Err(mmr::Error::PalletNotIncluded)
}

fn verify_batch_proof(_leaves: Vec<mmr::EncodableOpaqueLeaf>, _proof: mmr::BatchProof<Hash>)
-> Result<(), mmr::Error>
{
Expand Down
17 changes: 17 additions & 0 deletions runtime/rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1723,6 +1723,23 @@ sp_api::impl_runtime_apis! {
.map(|(leaves, proof)| (leaves.into_iter().map(|leaf| mmr::EncodableOpaqueLeaf::from_leaf(&leaf)).collect(), proof))
}

fn generate_historical_batch_proof(
leaf_indices: Vec<mmr::LeafIndex>,
leaves_count: mmr::LeafIndex,
) -> Result<(Vec<mmr::EncodableOpaqueLeaf>, mmr::BatchProof<Hash>), mmr::Error> {
Mmr::generate_historical_batch_proof(leaf_indices, leaves_count).map(
|(leaves, proof)| {
(
leaves
.into_iter()
.map(|leaf| mmr::EncodableOpaqueLeaf::from_leaf(&leaf))
.collect(),
proof,
)
},
)
}

fn verify_batch_proof(leaves: Vec<mmr::EncodableOpaqueLeaf>, proof: mmr::BatchProof<Hash>)
-> Result<(), mmr::Error>
{
Expand Down
7 changes: 7 additions & 0 deletions runtime/test-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -947,6 +947,13 @@ sp_api::impl_runtime_apis! {
Err(mmr::Error::PalletNotIncluded)
}

fn generate_historical_batch_proof(
_leaf_indices: Vec<u64>,
_leaves_count: u64,
) -> Result<(Vec<mmr::EncodableOpaqueLeaf>, mmr::BatchProof<Hash>), mmr::Error> {
Err(mmr::Error::PalletNotIncluded)
}

fn verify_batch_proof(_leaves: Vec<mmr::EncodableOpaqueLeaf>, _proof: mmr::BatchProof<Hash>)
-> Result<(), mmr::Error>
{
Expand Down
6 changes: 6 additions & 0 deletions runtime/westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1458,7 +1458,13 @@ sp_api::impl_runtime_apis! {
fn generate_batch_proof(_leaf_indices: Vec<u64>)
-> Result<(Vec<mmr::EncodableOpaqueLeaf>, mmr::BatchProof<Hash>), mmr::Error>
{
Err(mmr::Error::PalletNotIncluded)
}

fn generate_historical_batch_proof(
_leaf_indices: Vec<u64>,
_leaves_count: u64,
) -> Result<(Vec<mmr::EncodableOpaqueLeaf>, mmr::BatchProof<Hash>), mmr::Error> {
Err(mmr::Error::PalletNotIncluded)
}

Expand Down