mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 20:21:03 +00:00
Consolidate and deduplicate MMR API methods (#12530)
* histor. batch proof: make best block arg optional
* correct testing range
* 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
* remove {Leaf}Proof
Not utilized by API anymore, so superfluous.
Removal consistent with prior changes to just use "batch" proof API.
* rename BatchProof->Proof
no need to qualify if only one universal proof type.
* cleanup
* expose verify_proof rpc api
* document verify_proof
* expose verify_proof_stateless rpc api
* add optional BlockHash to mmr_root rpc api
* fixup! expose verify_proof rpc api
* fix documentation phrasing
Co-authored-by: Adrian Catangiu <adrian@parity.io>
* documentation grammar
Co-authored-by: Adrian Catangiu <adrian@parity.io>
* define mmr error msgs together with error enum
Co-authored-by: Serban Iorga <serban@parity.io>
* fixup! define mmr error msgs together with error enum
* map decoding errors to CallError::InvalidParams
Co-authored-by: Serban Iorga <serban@parity.io>
* fixup! map decoding errors to CallError::InvalidParams
Co-authored-by: Adrian Catangiu <adrian@parity.io>
Co-authored-by: parity-processbot <>
Co-authored-by: Serban Iorga <serban@parity.io>
This commit is contained in:
@@ -43,7 +43,7 @@ use beefy_primitives::{
|
||||
KEY_TYPE as BeefyKeyType,
|
||||
};
|
||||
use sc_network::{config::RequestResponseConfig, ProtocolName};
|
||||
use sp_mmr_primitives::{BatchProof, EncodableOpaqueLeaf, Error as MmrError, MmrApi, Proof};
|
||||
use sp_mmr_primitives::{EncodableOpaqueLeaf, Error as MmrError, MmrApi, Proof};
|
||||
|
||||
use sp_api::{ApiRef, ProvideRuntimeApi};
|
||||
use sp_consensus::BlockOrigin;
|
||||
@@ -246,47 +246,25 @@ macro_rules! create_test_api {
|
||||
}
|
||||
|
||||
impl MmrApi<Block, MmrRootHash, NumberFor<Block>> for RuntimeApi {
|
||||
fn generate_proof(_block_number: u64)
|
||||
-> Result<(EncodableOpaqueLeaf, Proof<MmrRootHash>), MmrError> {
|
||||
fn mmr_root() -> Result<MmrRootHash, MmrError> {
|
||||
Ok($mmr_root)
|
||||
}
|
||||
|
||||
fn generate_proof(
|
||||
_block_numbers: Vec<u64>,
|
||||
_best_known_block_number: Option<u64>
|
||||
) -> Result<(Vec<EncodableOpaqueLeaf>, Proof<MmrRootHash>), MmrError> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn verify_proof(_leaf: EncodableOpaqueLeaf, _proof: Proof<MmrRootHash>)
|
||||
-> Result<(), MmrError> {
|
||||
fn verify_proof(_leaves: Vec<EncodableOpaqueLeaf>, _proof: Proof<MmrRootHash>) -> Result<(), MmrError> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn verify_proof_stateless(
|
||||
_root: MmrRootHash,
|
||||
_leaf: EncodableOpaqueLeaf,
|
||||
_proof: Proof<MmrRootHash>
|
||||
) -> Result<(), MmrError> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn mmr_root() -> Result<MmrRootHash, MmrError> {
|
||||
Ok($mmr_root)
|
||||
}
|
||||
|
||||
fn generate_batch_proof(_block_numbers: Vec<u64>) -> Result<(Vec<EncodableOpaqueLeaf>, BatchProof<MmrRootHash>), MmrError> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn generate_historical_batch_proof(
|
||||
_block_numbers: Vec<u64>,
|
||||
_best_known_block_number: u64
|
||||
) -> Result<(Vec<EncodableOpaqueLeaf>, BatchProof<MmrRootHash>), MmrError> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn verify_batch_proof(_leaves: Vec<EncodableOpaqueLeaf>, _proof: BatchProof<MmrRootHash>) -> Result<(), MmrError> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn verify_batch_proof_stateless(
|
||||
_root: MmrRootHash,
|
||||
_leaves: Vec<EncodableOpaqueLeaf>,
|
||||
_proof: BatchProof<MmrRootHash>
|
||||
_proof: Proof<MmrRootHash>
|
||||
) -> Result<(), MmrError> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user