Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(l2): replace ExecutionDB from_exec() impl to use a CacheDB based approach #1709

Merged
merged 27 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions crates/vm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ revm = { version = "14.0.3", features = [
"serde-json",
"optional_no_base_fee",
"optional_block_gas_limit",
"optional_balance_check",
], default-features = false }

# These dependencies must be kept up to date with the corresponding revm version, otherwise errors may pop up because of trait implementation mismatches
Expand Down
30 changes: 27 additions & 3 deletions crates/vm/errors.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
use ethereum_types::{H160, H256};
use ethrex_core::types::BlockHash;
use ethrex_core::{types::BlockHash, Address};
use ethrex_rlp::error::RLPDecodeError;
use ethrex_storage::error::StoreError;
use ethrex_trie::TrieError;
use revm::primitives::{
result::EVMError as RevmError, Address as RevmAddress, B256 as RevmB256, U256 as RevmU256,
};
use revm_primitives::BytecodeDecodeError;
use thiserror::Error;

use crate::execution_db::index_db::IndexDBError;

#[derive(Debug, Error)]
pub enum EvmError {
#[error("Invalid Transaction: {0}")]
Expand All @@ -17,6 +21,8 @@ pub enum EvmError {
DB(#[from] StoreError),
#[error("Execution DB error: {0}")]
ExecutionDB(#[from] ExecutionDBError),
#[error("Index DB error: {0}")]
IndexDB(#[from] IndexDBError),
#[error("{0}")]
Custom(String),
#[error("{0}")]
Expand All @@ -33,6 +39,12 @@ pub enum ExecutionDBError {
Trie(#[from] TrieError),
#[error("State proofs error: {0}")]
StateProofs(#[from] StateProofsError),
#[error("{0}")]
IndexBorrow(#[from] IndexDBError),
#[error("Revm failed to decode bytecode: {0}")]
RevmBytecodeDecode(#[from] BytecodeDecodeError),
#[error("{0}")]
RLPDecode(#[from] RLPDecodeError),
#[error("Account {0} not found")]
AccountNotFound(RevmAddress),
#[error("Code by hash {0} not found")]
Expand All @@ -44,13 +56,13 @@ pub enum ExecutionDBError {
#[error("Hash of block with number {0} not found")]
BlockHashNotFound(u64),
#[error("Missing account {0} info while trying to create ExecutionDB")]
NewMissingAccountInfo(RevmAddress),
NewMissingAccountInfo(Address),
#[error("Missing state trie of block {0} while trying to create ExecutionDB")]
NewMissingStateTrie(BlockHash),
#[error(
"Missing storage trie of block {0} and address {1} while trying to create ExecutionDB"
)]
NewMissingStorageTrie(BlockHash, H160),
NewMissingStorageTrie(BlockHash, Address),
#[error("The account {0} is not included in the stored pruned state trie")]
MissingAccountInStateTrie(H160),
#[error("Missing storage trie of account {0}")]
Expand Down Expand Up @@ -105,6 +117,18 @@ impl From<RevmError<ExecutionDBError>> for EvmError {
}
}

impl From<RevmError<IndexDBError>> for EvmError {
fn from(value: RevmError<IndexDBError>) -> Self {
match value {
RevmError::Transaction(err) => EvmError::Transaction(err.to_string()),
RevmError::Header(err) => EvmError::Header(err.to_string()),
RevmError::Database(err) => EvmError::IndexDB(err),
RevmError::Custom(err) => EvmError::Custom(err),
RevmError::Precompile(err) => EvmError::Precompile(err),
}
}
}

cfg_if::cfg_if! {
if #[cfg(feature = "levm")] {
use ethrex_levm::errors::VMError;
Expand Down
Loading
Loading