pallet-mmr: generate historical proofs (#12324)

* BEEFY: generate historical proofs

Signed-off-by: Serban Iorga <serban@parity.io>

* Update frame/merkle-mountain-range/rpc/src/lib.rs

Co-authored-by: Adrian Catangiu <adrian@parity.io>

* Update primitives/merkle-mountain-range/src/lib.rs

Co-authored-by: Adrian Catangiu <adrian@parity.io>

* Update frame/merkle-mountain-range/src/lib.rs

Co-authored-by: Adrian Catangiu <adrian@parity.io>

* cargo fmt

* fix off-by-one in leaves powerset generation

* test all possible mmr sizes for historical proofs

* remove now redundant simple_historical_proof

* cargo fmt

Signed-off-by: Serban Iorga <serban@parity.io>
Co-authored-by: Adrian Catangiu <adrian@parity.io>
Co-authored-by: Robert Hambrock <roberthambrock@gmail.com>
This commit is contained in:
Serban Iorga
2022-09-30 13:46:48 +03:00
committed by GitHub
parent 5e00d361cc
commit 54713ca17a
6 changed files with 379 additions and 25 deletions
@@ -402,6 +402,8 @@ pub enum Error {
PalletNotIncluded,
/// Cannot find the requested leaf index
InvalidLeafIndex,
/// The provided leaves count is larger than the actual leaves count.
InvalidLeavesCount,
}
impl Error {
@@ -455,7 +457,14 @@ sp_api::decl_runtime_apis! {
fn mmr_root() -> Result<Hash, Error>;
/// Generate MMR proof for a series of leaves under given indices.
fn generate_batch_proof(leaf_indices: Vec<LeafIndex>) -> Result<(Vec<EncodableOpaqueLeaf>, BatchProof<Hash>), Error>;
fn generate_batch_proof(leaf_indices: Vec<LeafIndex>)
-> Result<(Vec<EncodableOpaqueLeaf>, BatchProof<Hash>), Error>;
/// Generate MMR proof for a series of leaves under given indices, using MMR at given `leaves_count` size.
fn generate_historical_batch_proof(
leaf_indices: Vec<LeafIndex>,
leaves_count: LeafIndex
) -> Result<(Vec<EncodableOpaqueLeaf>, BatchProof<Hash>), Error>;
/// Verify MMR proof against on-chain MMR for a batch of leaves.
///