Skip to content

Commit

Permalink
feat(trie): account proofs (paradigmxyz#4249)
Browse files Browse the repository at this point in the history
  • Loading branch information
rkrasiuk authored Aug 18, 2023
1 parent 849a47e commit 466934c
Show file tree
Hide file tree
Showing 6 changed files with 353 additions and 2 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/primitives/src/trie/nodes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub use self::{
/// The range of valid child indexes.
pub const CHILD_INDEX_RANGE: Range<u8> = 0..16;

/// Given an RLP encoded node, returns either RLP(Node) or RLP(keccak(RLP(node)))
/// Given an RLP encoded node, returns either RLP(node) or RLP(keccak(RLP(node)))
fn rlp_node(rlp: &[u8]) -> Vec<u8> {
if rlp.len() < H256::len_bytes() {
rlp.to_vec()
Expand Down
1 change: 1 addition & 0 deletions crates/trie/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ proptest.workspace = true
tokio = { workspace = true, default-features = false, features = ["sync", "rt", "macros"] }
tokio-stream.workspace = true
criterion = "0.5"
pretty_assertions = "1.3.0"

[features]
test-utils = ["triehash"]
Expand Down
17 changes: 17 additions & 0 deletions crates/trie/src/errors.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use reth_primitives::H256;
use thiserror::Error;

/// State root error.
Expand Down Expand Up @@ -27,3 +28,19 @@ pub enum StorageRootError {
#[error(transparent)]
DB(#[from] reth_db::DatabaseError),
}

/// Proof error.
#[derive(Error, PartialEq, Eq, Clone, Debug)]
pub enum ProofError {
/// Leaf account missing
#[error(
"Expected leaf account with key greater or equal to {0:?} is missing from the database"
)]
LeafAccountMissing(H256),
/// Storage root error.
#[error(transparent)]
StorageRootError(#[from] StorageRootError),
/// Internal database error.
#[error(transparent)]
DB(#[from] reth_db::DatabaseError),
}
5 changes: 4 additions & 1 deletion crates/trie/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ pub mod hashed_cursor;
pub mod walker;

mod errors;
pub use errors::{StateRootError, StorageRootError};
pub use errors::*;

/// Merkle proof generation.
pub mod proof;

/// The implementation of the Merkle Patricia Trie.
mod trie;
Expand Down
Loading

0 comments on commit 466934c

Please sign in to comment.