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§
Required Methods§
fn proof_to_hashes(proof: &Self::Proof) -> Result<u32, DispatchError>
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.