referrerpolicy=no-referrer-when-downgrade

Trait frame_support::traits::ProofToHashes

source ·
pub trait ProofToHashes {
    type Proof: ?Sized;

    // Required method
    fn proof_to_hashes(proof: &Self::Proof) -> Result<u32, DispatchError>;
}
Expand description

This trait is one strategy that can be used to benchmark a trie proof verification for the runtime. This strategy assumes that the majority complexity of verifying a merkle proof comes from computing hashes to recreate the merkle root. This trait converts the the proof, some bytes, to the number of hashes we expect to execute to verify that proof.

Required Associated Types§

source

type Proof: ?Sized

The Proof type we will use to determine the number of hashes.

Required Methods§

source

fn proof_to_hashes(proof: &Self::Proof) -> Result<u32, DispatchError>

This function returns the number of hashes we expect to calculate based on the size of the proof. This is used for benchmarking, so for worst case scenario, we should round up.

The major complexity of doing a verify_proof is computing the hashes needed to calculate the merkle root. For tries, it should be easy to predict the depth of the trie (which is equivalent to the hashes), by looking at the length of the proof.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<H: Hasher> ProofToHashes for BinaryMerkleTreeProver<H>

§

type Proof = MerkleProof<<H as Hasher>::Out, Vec<u8>>

source§

impl<H: Hasher> ProofToHashes for SixteenPatriciaMerkleTreeProver<H>

source§

impl<Hashing, Key, Value> ProofToHashes for frame_support::traits::base2::BasicProvingTrie<Hashing, Key, Value>
where Hashing: Hasher, <Hashing as Hasher>::Out: MaxEncodedLen + Decode, Key: Decode, Value: Decode,

§

type Proof = [u8]

source§

impl<Hashing, Key, Value> ProofToHashes for frame_support::traits::base16::BasicProvingTrie<Hashing, Key, Value>
where Hashing: Hasher, <Hashing as Hasher>::Out: MaxEncodedLen,

§

type Proof = [u8]