referrerpolicy=no-referrer-when-downgrade

Trait sp_runtime::proving_trie::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<Hashing, Key, Value> ProofToHashes for sp_runtime::proving_trie::base2::BasicProvingTrie<Hashing, Key, Value>
where Hashing: Hasher, Hashing::Out: MaxEncodedLen + Decode, Key: Decode, Value: Decode,

§

type Proof = [u8]

source§

impl<Hashing, Key, Value> ProofToHashes for sp_runtime::proving_trie::base16::BasicProvingTrie<Hashing, Key, Value>
where Hashing: Hasher, Hashing::Out: MaxEncodedLen,

§

type Proof = [u8]