referrerpolicy=no-referrer-when-downgrade

Trait polkadot_sdk_frame::traits::ProofToHashes

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§

type Proof: ?Sized

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

Required Methods§

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§

§

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

§

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

§

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

§

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

§

type Proof = [u8]

§

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

§

type Proof = [u8]