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

* histor. batch proof: make best block arg optional

* make generate_batch_proof stub for historical

* merge generate_{historical_}batch_proof functions

* merge generate_{batch_}proof functions

* merge verify_{batch_}proof functions

* merge verify_{batch_}proof_stateless functions

* rename BatchProof->Proof

* update lockfile for {"substrate"}

Co-authored-by: parity-processbot <>
This commit is contained in:
Robert Hambrock
2022-11-09 17:04:48 +01:00
committed by GitHub
parent 7ccc92414a
commit 20965b4e64
6 changed files with 229 additions and 371 deletions
+10 -36
View File
@@ -1691,53 +1691,27 @@ sp_api::impl_runtime_apis! {
}
impl mmr::MmrApi<Block, Hash, BlockNumber> for Runtime {
fn generate_proof(_block_number: BlockNumber)
-> Result<(mmr::EncodableOpaqueLeaf, mmr::Proof<Hash>), mmr::Error>
{
fn mmr_root() -> Result<Hash, mmr::Error> {
Err(mmr::Error::PalletNotIncluded)
}
fn verify_proof(_leaf: mmr::EncodableOpaqueLeaf, _proof: mmr::Proof<Hash>)
fn generate_proof(
_block_numbers: Vec<BlockNumber>,
_best_known_block_number: Option<BlockNumber>,
) -> Result<(Vec<mmr::EncodableOpaqueLeaf>, mmr::Proof<Hash>), mmr::Error> {
Err(mmr::Error::PalletNotIncluded)
}
fn verify_proof(_leaves: Vec<mmr::EncodableOpaqueLeaf>, _proof: mmr::Proof<Hash>)
-> Result<(), mmr::Error>
{
Err(mmr::Error::PalletNotIncluded)
}
fn verify_proof_stateless(
_root: Hash,
_leaf: mmr::EncodableOpaqueLeaf,
_proof: mmr::Proof<Hash>
) -> Result<(), mmr::Error> {
Err(mmr::Error::PalletNotIncluded)
}
fn mmr_root() -> Result<Hash, mmr::Error> {
Err(mmr::Error::PalletNotIncluded)
}
fn generate_batch_proof(_block_numbers: Vec<BlockNumber>)
-> Result<(Vec<mmr::EncodableOpaqueLeaf>, mmr::BatchProof<Hash>), mmr::Error>
{
Err(mmr::Error::PalletNotIncluded)
}
fn generate_historical_batch_proof(
_block_numbers: Vec<BlockNumber>,
_best_known_block_number: BlockNumber,
) -> 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>
{
Err(mmr::Error::PalletNotIncluded)
}
fn verify_batch_proof_stateless(
_root: Hash,
_leaves: Vec<mmr::EncodableOpaqueLeaf>,
_proof: mmr::BatchProof<Hash>
_proof: mmr::Proof<Hash>
) -> Result<(), mmr::Error> {
Err(mmr::Error::PalletNotIncluded)
}