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

Commit

Permalink
Address feedback again
Browse files Browse the repository at this point in the history
  • Loading branch information
Lldenaurois committed Aug 20, 2021
1 parent 7b7bd4b commit 5eb17d3
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions node/primitives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ pub use disputes::{
// For a 16-ary Merkle Prefix Trie, we can expect at most 16 32-byte hashes per node.
const MERKLE_NODE_MAX_SIZE: usize = 512;
// 16-ary Merkle Prefix Trie for 32-bit ValidatorIndex has depth at most 8.
// Merkle Prefix Tries use the key in order to determine Proof structure.
// To that effect, at every depth we require 4-bit nibbles from the key in
// order to determine the Trie node of that key.
// In this case, the key is a 32-bit validator index, and 32/4 = 8, the max
// proof depth.
const MERKLE_PROOF_MAX_DEPTH: usize = 8;

/// The bomb limit for decompressing code blobs.
Expand Down Expand Up @@ -305,7 +310,7 @@ impl Proof {
}

#[derive(thiserror::Error, Debug)]
///
/// This is a convenience error type to adequately handle erronious Merkle Proofs
pub enum MerkleProofError {
#[error("Merkle max proof depth exceeded {0} > {} .", MERKLE_PROOF_MAX_DEPTH)]
/// This error signifies that the Proof length exceeds the trie's max depth
Expand All @@ -330,7 +335,7 @@ impl TryFrom<Vec<Vec<u8>>> for Proof {
.map_err(|_| Self::Error::MerkleProofNodeSizeExceeded(length))?;
out.push(data);
}
Ok(Proof(BoundedVec::from_vec(out).expect("Buffer size is deterined above. qed")))
Ok(Proof(BoundedVec::from_vec(out).expect("Buffer size is determined above. qed")))
}
}

Expand Down

0 comments on commit 5eb17d3

Please sign in to comment.