Skip to content

Commit

Permalink
cleanup and doc
Browse files Browse the repository at this point in the history
  • Loading branch information
rakita committed Dec 31, 2024
1 parent 8ec7d3d commit e75be11
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 34 deletions.
2 changes: 0 additions & 2 deletions Cargo.lock

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

6 changes: 0 additions & 6 deletions examples/erc20_gas/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ all = "warn"
[dependencies]
revm.workspace = true
database = { workspace = true, features = ["std", "alloydb"] }
specification.workspace = true


# tokio
tokio = { version = "1.40", features = ["rt-multi-thread", "macros"] }
Expand All @@ -35,11 +33,7 @@ tokio = { version = "1.40", features = ["rt-multi-thread", "macros"] }
alloy-sol-types = { version = "0.8.2", default-features = false, features = [
"std",
] }
alloy-eips = "0.6"
alloy-transport-http = "0.6"
alloy-provider = "0.6"
reqwest = { version = "0.12" }
anyhow = "1.0.89"



8 changes: 4 additions & 4 deletions examples/erc20_gas/src/handlers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ pub mod post_execution;
pub mod pre_execution;
pub mod validation;

pub use post_execution::Erc20PostExecution;
pub use pre_execution::Erc20PreExecution;
pub use validation::Erc20Validation;

use revm::{
context::{block::BlockEnv, tx::TxEnv, CfgEnv, Context},
context_interface::result::{EVMError, InvalidTransaction},
Expand All @@ -10,10 +14,6 @@ use revm::{
Evm,
};

pub use post_execution::Erc20PostExecution;
pub use pre_execution::Erc20PreExecution;
pub use validation::Erc20Validation;

pub type Erc20GasError<DB> = EVMError<<DB as Database>::Error, InvalidTransaction>;

pub type Erc20GasContext<DB> = Context<BlockEnv, TxEnv, CfgEnv, DB>;
Expand Down
11 changes: 4 additions & 7 deletions examples/erc20_gas/src/handlers/post_execution.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
use crate::{token_operation, TREASURY};
use revm::context_interface::result::{HaltReasonTrait, InvalidHeader, InvalidTransaction};
use revm::context_interface::JournalDBError;
use revm::handler::{EthPostExecutionContext, EthPostExecutionError};
use revm::precompile::PrecompileErrors;
use revm::{
context::Cfg,
context_interface::{
result::{HaltReason, ResultAndState},
Block, Transaction, TransactionGetter,
result::{HaltReason, HaltReasonTrait, InvalidHeader, InvalidTransaction, ResultAndState},
Block, JournalDBError, Transaction, TransactionGetter,
},
handler::{EthPostExecution, FrameResult},
handler::{EthPostExecution, EthPostExecutionContext, EthPostExecutionError, FrameResult},
handler_interface::PostExecutionHandler,
precompile::PrecompileErrors,
primitives::U256,
specification::hardfork::SpecId,
};
Expand Down
15 changes: 8 additions & 7 deletions examples/erc20_gas/src/handlers/pre_execution.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
use crate::{token_operation, TREASURY};
use revm::context_interface::result::InvalidHeader;
use revm::context_interface::transaction::Eip4844Tx;
use revm::context_interface::{Block, Transaction, TransactionGetter};
use revm::handler::{EthPreExecutionContext, EthPreExecutionError};
use revm::precompile::PrecompileErrors;
use revm::{
context_interface::TransactionType, handler::EthPreExecution,
handler_interface::PreExecutionHandler, primitives::U256,
context_interface::{
result::InvalidHeader, transaction::Eip4844Tx, Block, Transaction, TransactionGetter,
TransactionType,
},
handler::{EthPreExecution, EthPreExecutionContext, EthPreExecutionError},
handler_interface::PreExecutionHandler,
precompile::PrecompileErrors,
primitives::U256,
};

pub struct Erc20PreExecution<CTX, ERROR> {
Expand Down
14 changes: 6 additions & 8 deletions examples/erc20_gas/src/handlers/validation.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
use crate::keccak256;
use crate::TOKEN;
use alloy_sol_types::SolValue;
use revm::context_interface::Journal;
use revm::context_interface::{Transaction, TransactionGetter};
use revm::handler::EthValidationContext;
use revm::handler::EthValidationError;
use revm::{
context::Cfg,
context_interface::{result::InvalidTransaction, transaction::Eip4844Tx, TransactionType},
handler::EthValidation,
context_interface::{
result::InvalidTransaction, transaction::Eip4844Tx, Journal, Transaction,
TransactionGetter, TransactionType,
},
handler::{EthValidation, EthValidationContext, EthValidationError},
handler_interface::ValidationHandler,
primitives::U256,
primitives::{keccak256, U256},
};
use std::cmp::Ordering;

Expand Down
6 changes: 6 additions & 0 deletions examples/erc20_gas/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
//! Example of a custom handler for ERC20 gas calculation.
//!
//! Gas is going to be deducted from ERC20 token.
#![cfg_attr(not(test), warn(unused_crate_dependencies))]

use alloy_provider::{network::Ethereum, ProviderBuilder, RootProvider};
use alloy_sol_types::{sol, SolCall, SolValue};
use alloy_transport_http::Http;
Expand Down

0 comments on commit e75be11

Please sign in to comment.