mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore: move sparse errors to reth-execution-errors (#13101)
This commit is contained in:
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -9537,6 +9537,7 @@ dependencies = [
|
||||
"proptest",
|
||||
"proptest-arbitrary-interop",
|
||||
"rand 0.8.5",
|
||||
"reth-execution-errors",
|
||||
"reth-primitives-traits",
|
||||
"reth-testing-utils",
|
||||
"reth-tracing",
|
||||
|
||||
@ -10,7 +10,10 @@ use reth_trie::{
|
||||
};
|
||||
use reth_trie_db::DatabaseProof;
|
||||
use reth_trie_parallel::root::ParallelStateRootError;
|
||||
use reth_trie_sparse::{SparseStateTrie, SparseStateTrieResult, SparseTrieError};
|
||||
use reth_trie_sparse::{
|
||||
errors::{SparseStateTrieResult, SparseTrieError},
|
||||
SparseStateTrie,
|
||||
};
|
||||
use revm_primitives::{keccak256, EvmState, B256};
|
||||
use std::{
|
||||
collections::BTreeMap,
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
//! Errors when computing the state root.
|
||||
|
||||
use alloc::string::ToString;
|
||||
use alloy_primitives::B256;
|
||||
use alloc::{boxed::Box, string::ToString};
|
||||
use alloy_primitives::{Bytes, B256};
|
||||
use nybbles::Nibbles;
|
||||
use reth_storage_errors::{db::DatabaseError, provider::ProviderError};
|
||||
use thiserror::Error;
|
||||
@ -62,6 +62,61 @@ impl From<StateProofError> for ProviderError {
|
||||
}
|
||||
}
|
||||
|
||||
/// Result type with [`SparseStateTrieError`] as error.
|
||||
pub type SparseStateTrieResult<Ok> = Result<Ok, SparseStateTrieError>;
|
||||
|
||||
/// Error encountered in `SparseStateTrie`.
|
||||
#[derive(Error, Debug)]
|
||||
pub enum SparseStateTrieError {
|
||||
/// Encountered invalid root node.
|
||||
#[error("invalid root node at {path:?}: {node:?}")]
|
||||
InvalidRootNode {
|
||||
/// Path to first proof node.
|
||||
path: Nibbles,
|
||||
/// Encoded first proof node.
|
||||
node: Bytes,
|
||||
},
|
||||
/// Sparse trie error.
|
||||
#[error(transparent)]
|
||||
Sparse(#[from] SparseTrieError),
|
||||
/// RLP error.
|
||||
#[error(transparent)]
|
||||
Rlp(#[from] alloy_rlp::Error),
|
||||
}
|
||||
|
||||
/// Result type with [`SparseTrieError`] as error.
|
||||
pub type SparseTrieResult<Ok> = Result<Ok, SparseTrieError>;
|
||||
|
||||
/// Error encountered in `SparseTrie`.
|
||||
#[derive(Error, Debug)]
|
||||
pub enum SparseTrieError {
|
||||
/// Sparse trie is still blind. Thrown on attempt to update it.
|
||||
#[error("sparse trie is blind")]
|
||||
Blind,
|
||||
/// Encountered blinded node on update.
|
||||
#[error("attempted to update blind node at {path:?}: {hash}")]
|
||||
BlindedNode {
|
||||
/// Blind node path.
|
||||
path: Nibbles,
|
||||
/// Node hash
|
||||
hash: B256,
|
||||
},
|
||||
/// Encountered unexpected node at path when revealing.
|
||||
#[error("encountered an invalid node at path {path:?} when revealing: {node:?}")]
|
||||
Reveal {
|
||||
/// Path to the node.
|
||||
path: Nibbles,
|
||||
/// Node that was at the path when revealing.
|
||||
node: Box<dyn core::fmt::Debug>,
|
||||
},
|
||||
/// RLP error.
|
||||
#[error(transparent)]
|
||||
Rlp(#[from] alloy_rlp::Error),
|
||||
/// Other.
|
||||
#[error(transparent)]
|
||||
Other(#[from] Box<dyn core::error::Error>),
|
||||
}
|
||||
|
||||
/// Trie witness errors.
|
||||
#[derive(Error, PartialEq, Eq, Clone, Debug)]
|
||||
pub enum TrieWitnessError {
|
||||
|
||||
@ -15,6 +15,7 @@ workspace = true
|
||||
[dependencies]
|
||||
# reth
|
||||
reth-primitives-traits.workspace = true
|
||||
reth-execution-errors.workspace = true
|
||||
reth-trie-common.workspace = true
|
||||
reth-tracing.workspace = true
|
||||
|
||||
@ -28,9 +29,9 @@ thiserror.workspace = true
|
||||
|
||||
[dev-dependencies]
|
||||
reth-primitives-traits = { workspace = true, features = ["arbitrary"] }
|
||||
reth-testing-utils.workspace = true
|
||||
reth-trie = { workspace = true, features = ["test-utils"] }
|
||||
reth-trie-common = { workspace = true, features = ["test-utils", "arbitrary"] }
|
||||
reth-testing-utils.workspace = true
|
||||
|
||||
arbitrary.workspace = true
|
||||
assert_matches.workspace = true
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
//! Traits and default implementations related to retrieval of blinded trie nodes.
|
||||
|
||||
use crate::SparseTrieError;
|
||||
use alloy_primitives::{Bytes, B256};
|
||||
use reth_execution_errors::SparseTrieError;
|
||||
use reth_trie_common::Nibbles;
|
||||
|
||||
/// Factory for instantiating blinded node providers.
|
||||
|
||||
@ -1,61 +0,0 @@
|
||||
//! Errors for sparse trie.
|
||||
|
||||
use crate::SparseNode;
|
||||
use alloy_primitives::{Bytes, B256};
|
||||
use reth_trie_common::Nibbles;
|
||||
use thiserror::Error;
|
||||
|
||||
/// Result type with [`SparseStateTrieError`] as error.
|
||||
pub type SparseStateTrieResult<Ok> = Result<Ok, SparseStateTrieError>;
|
||||
|
||||
/// Error encountered in [`crate::SparseStateTrie`].
|
||||
#[derive(Error, Debug)]
|
||||
pub enum SparseStateTrieError {
|
||||
/// Encountered invalid root node.
|
||||
#[error("invalid root node at {path:?}: {node:?}")]
|
||||
InvalidRootNode {
|
||||
/// Path to first proof node.
|
||||
path: Nibbles,
|
||||
/// Encoded first proof node.
|
||||
node: Bytes,
|
||||
},
|
||||
/// Sparse trie error.
|
||||
#[error(transparent)]
|
||||
Sparse(#[from] SparseTrieError),
|
||||
/// RLP error.
|
||||
#[error(transparent)]
|
||||
Rlp(#[from] alloy_rlp::Error),
|
||||
}
|
||||
|
||||
/// Result type with [`SparseTrieError`] as error.
|
||||
pub type SparseTrieResult<Ok> = Result<Ok, SparseTrieError>;
|
||||
|
||||
/// Error encountered in [`crate::SparseTrie`].
|
||||
#[derive(Error, Debug)]
|
||||
pub enum SparseTrieError {
|
||||
/// Sparse trie is still blind. Thrown on attempt to update it.
|
||||
#[error("sparse trie is blind")]
|
||||
Blind,
|
||||
/// Encountered blinded node on update.
|
||||
#[error("attempted to update blind node at {path:?}: {hash}")]
|
||||
BlindedNode {
|
||||
/// Blind node path.
|
||||
path: Nibbles,
|
||||
/// Node hash
|
||||
hash: B256,
|
||||
},
|
||||
/// Encountered unexpected node at path when revealing.
|
||||
#[error("encountered an invalid node at path {path:?} when revealing: {node:?}")]
|
||||
Reveal {
|
||||
/// Path to the node.
|
||||
path: Nibbles,
|
||||
/// Node that was at the path when revealing.
|
||||
node: Box<SparseNode>,
|
||||
},
|
||||
/// RLP error.
|
||||
#[error(transparent)]
|
||||
Rlp(#[from] alloy_rlp::Error),
|
||||
/// Other.
|
||||
#[error(transparent)]
|
||||
Other(#[from] Box<dyn std::error::Error>),
|
||||
}
|
||||
@ -6,7 +6,11 @@ pub use state::*;
|
||||
mod trie;
|
||||
pub use trie::*;
|
||||
|
||||
mod errors;
|
||||
pub use errors::*;
|
||||
|
||||
pub mod blinded;
|
||||
|
||||
/// Re-export sparse trie error types.
|
||||
pub mod errors {
|
||||
pub use reth_execution_errors::{
|
||||
SparseStateTrieError, SparseStateTrieResult, SparseTrieError, SparseTrieResult,
|
||||
};
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
use crate::{
|
||||
blinded::{BlindedProvider, BlindedProviderFactory, DefaultBlindedProviderFactory},
|
||||
RevealedSparseTrie, SparseStateTrieError, SparseStateTrieResult, SparseTrie, SparseTrieError,
|
||||
RevealedSparseTrie, SparseTrie,
|
||||
};
|
||||
use alloy_primitives::{
|
||||
hex,
|
||||
@ -8,6 +8,7 @@ use alloy_primitives::{
|
||||
Bytes, B256,
|
||||
};
|
||||
use alloy_rlp::{Decodable, Encodable};
|
||||
use reth_execution_errors::{SparseStateTrieError, SparseStateTrieResult, SparseTrieError};
|
||||
use reth_primitives_traits::Account;
|
||||
use reth_tracing::tracing::trace;
|
||||
use reth_trie_common::{
|
||||
|
||||
@ -1,13 +1,11 @@
|
||||
use crate::{
|
||||
blinded::{BlindedProvider, DefaultBlindedProvider},
|
||||
SparseTrieError, SparseTrieResult,
|
||||
};
|
||||
use crate::blinded::{BlindedProvider, DefaultBlindedProvider};
|
||||
use alloy_primitives::{
|
||||
hex, keccak256,
|
||||
map::{HashMap, HashSet},
|
||||
B256,
|
||||
};
|
||||
use alloy_rlp::Decodable;
|
||||
use reth_execution_errors::{SparseTrieError, SparseTrieResult};
|
||||
use reth_tracing::tracing::trace;
|
||||
use reth_trie_common::{
|
||||
prefix_set::{PrefixSet, PrefixSetMut},
|
||||
|
||||
@ -4,11 +4,9 @@ use alloy_primitives::{
|
||||
map::{HashMap, HashSet},
|
||||
Bytes, B256,
|
||||
};
|
||||
use reth_execution_errors::SparseTrieError;
|
||||
use reth_trie_common::{prefix_set::TriePrefixSetsMut, Nibbles};
|
||||
use reth_trie_sparse::{
|
||||
blinded::{pad_path_to_key, BlindedProvider, BlindedProviderFactory},
|
||||
SparseTrieError,
|
||||
};
|
||||
use reth_trie_sparse::blinded::{pad_path_to_key, BlindedProvider, BlindedProviderFactory};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Factory for instantiating providers capable of retrieving blinded trie nodes via proofs.
|
||||
|
||||
Reference in New Issue
Block a user