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

Consolidate and deduplicate MMR API methods #12530

Merged
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
2ccf7c0
histor. batch proof: make best block arg optional
Lederstrumpf Oct 17, 2022
019d5cd
correct testing range
Lederstrumpf Oct 17, 2022
deb12a4
make generate_batch_proof stub for historical
Lederstrumpf Oct 18, 2022
5ffff01
merge generate_{historical_}batch_proof functions
Lederstrumpf Oct 18, 2022
ed0f1fa
merge generate_{batch_}proof functions
Lederstrumpf Oct 18, 2022
0730e9a
merge verify_{batch_}proof functions
Lederstrumpf Oct 18, 2022
e617095
merge verify_{batch_}proof_stateless functions
Lederstrumpf Oct 18, 2022
f08f6f0
remove {Leaf}Proof
Lederstrumpf Oct 19, 2022
2657723
rename BatchProof->Proof
Lederstrumpf Oct 19, 2022
f0454e5
cleanup
Lederstrumpf Oct 19, 2022
e77bcd9
expose verify_proof rpc api
Lederstrumpf Nov 6, 2022
1c599ef
document verify_proof
Lederstrumpf Nov 6, 2022
159712e
expose verify_proof_stateless rpc api
Lederstrumpf Nov 6, 2022
d576d3a
add optional BlockHash to mmr_root rpc api
Lederstrumpf Nov 7, 2022
087c77e
fixup! expose verify_proof rpc api
Lederstrumpf Nov 7, 2022
39f3676
fix documentation phrasing
Lederstrumpf Nov 7, 2022
212161d
documentation grammar
Lederstrumpf Nov 7, 2022
5ae856a
Merge remote-tracking branch 'origin/master' into consolidate-and-ded…
Nov 8, 2022
d5f4cf7
define mmr error msgs together with error enum
Lederstrumpf Nov 8, 2022
a7069fd
fixup! define mmr error msgs together with error enum
Lederstrumpf Nov 8, 2022
63d7694
map decoding errors to CallError::InvalidParams
Lederstrumpf Nov 8, 2022
95aa689
fixup! map decoding errors to CallError::InvalidParams
Lederstrumpf Nov 8, 2022
bfaaa06
Merge remote-tracking branch 'origin/master' into consolidate-and-ded…
Nov 9, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add optional BlockHash to mmr_root rpc api
Lederstrumpf committed Nov 7, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit d576d3aa73a0038a136a7c0639d6c5326ed88e1b
16 changes: 10 additions & 6 deletions frame/merkle-mountain-range/rpc/src/lib.rs
Original file line number Diff line number Diff line change
@@ -79,7 +79,8 @@ impl<BlockHash> LeavesProof<BlockHash> {
pub trait MmrApi<BlockHash, BlockNumber, MmrHash> {
/// Get the MMR root hash for the current best block.
#[method(name = "mmr_root")]
fn mmr_root(&self) -> RpcResult<MmrHash>;
fn mmr_root(&self, at: Option<BlockHash>) -> RpcResult<MmrHash>;

/// Generate an MMR proof for the given `block_numbers`.
Lederstrumpf marked this conversation as resolved.
Show resolved Hide resolved
///
/// This method calls into a runtime with MMR pallet included and attempts to generate
@@ -155,12 +156,15 @@ where
Client::Api: MmrRuntimeApi<Block, MmrHash, NumberFor<Block>>,
MmrHash: Codec + Send + Sync + 'static,
{
fn mmr_root(&self) -> RpcResult<MmrHash> {
let best_block_hash = self.client.info().best_hash;
fn mmr_root(&self, at: Option<<Block as BlockT>::Hash>) -> RpcResult<MmrHash> {
let block_hash = at.unwrap_or_else(||
// If the block hash is not supplied assume the best block.
self.client.info().best_hash);
let api = self.client.runtime_api();
let mmr_root = api.mmr_root(&BlockId::Hash(best_block_hash))
.map_err(runtime_error_into_rpc_error)?
.map_err(mmr_error_into_rpc_error)?;
let mmr_root = api
.mmr_root(&BlockId::Hash(block_hash))
.map_err(runtime_error_into_rpc_error)?
.map_err(mmr_error_into_rpc_error)?;
Ok(mmr_root)
}