Skip to content

Commit 48c49e4

Browse files
committed
Fixed code execution issues in examples
1 parent 55cc29e commit 48c49e4

File tree

6 files changed

+23
-17
lines changed

6 files changed

+23
-17
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [2.0.3] - 2025-2-13
9+
### Fixed
10+
- Fixed code execution issues in examples
11+
- Added option to keep state after lastest transaction in batch simulation for easier querying
812

913
## [2.0.2] - 2024-12-25
1014

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ Perfect for:
5858

5959
Add this to your `Cargo.toml`:
6060
```toml
61-
revm-trace = "2.0.2"
61+
revm-trace = "2.0.3"
6262
```
6363

6464
## Quick Start
@@ -83,16 +83,16 @@ async fn main() -> anyhow::Result<()> {
8383

8484
// Create simulation transaction
8585
let tx = SimulationTx {
86-
caller: address!("dead00000000000000000000000000000000beef"),
87-
transact_to: TxKind::Call(address!("dac17f958d2ee523a2206206994597c13d831ec7")),
88-
value: U256::from(1000000000000000000u64), // 1 ETH
86+
caller: address!("C255fC198eEdAC7AF8aF0f6e0ca781794B094A61"),
87+
transact_to: TxKind::Call(address!("d878229c9c3575F224784DE610911B5607a3ad15")),
88+
value: U256::from(120000000000000000u64), // 0.12 ETH
8989
data: vec![].into(),
9090
};
9191

9292
// Create batch with single transaction
9393
let batch = SimulationBatch {
9494
block_env: BlockEnv {
95-
number: 18000000,
95+
number: 21784863,
9696
timestamp: 1700000000,
9797
},
9898
transactions: vec![tx],

src/evm/execution.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,12 +166,13 @@ where
166166
self.reset_db();
167167

168168
// 2. Execution
169-
for input in transactions {
169+
let len = transactions.len();
170+
for (index,input) in transactions.into_iter().enumerate() {
170171
let result = self.process_transaction_internal(input)
171172
.map_err(EvmError::Runtime);
172173
results.push(result);
173174

174-
if !is_stateful {
175+
if index !=len -1 && !is_stateful {
175176
self.reset_db();
176177
}
177178
}

src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,16 @@
4141
//!
4242
//! // Create simulation transaction
4343
//! let tx = SimulationTx {
44-
//! caller: address!("dead00000000000000000000000000000000beef"),
45-
//! transact_to: TxKind::Call(address!("dac17f958d2ee523a2206206994597c13d831ec7")),
46-
//! value: U256::from(1000000000000000000u64), // 1 ETH
44+
//! caller: address!("C255fC198eEdAC7AF8aF0f6e0ca781794B094A61"),
45+
//! transact_to: TxKind::Call(address!("d878229c9c3575F224784DE610911B5607a3ad15")),
46+
//! value: U256::from(120000000000000000u64), // 0.12 ETH
4747
//! data: vec![].into(),
4848
//! };
4949
//!
5050
//! // Create batch with single transaction
5151
//! let batch = SimulationBatch {
5252
//! block_env: BlockEnv {
53-
//! number: 18000000,
53+
//! number: 21784863,
5454
//! timestamp: 1700000000,
5555
//! },
5656
//! transactions: vec![tx],

tests/readme_example.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,16 @@ async fn test_basic_usage() -> anyhow::Result<()> {
1717

1818
// Create simulation transaction
1919
let tx = SimulationTx {
20-
caller: address!("dead00000000000000000000000000000000beef"),
21-
transact_to: TxKind::Call(address!("dac17f958d2ee523a2206206994597c13d831ec7")),
22-
value: U256::from(1000000000000000000u64), // 1 ETH
20+
caller: address!("C255fC198eEdAC7AF8aF0f6e0ca781794B094A61"),
21+
transact_to: TxKind::Call(address!("d878229c9c3575F224784DE610911B5607a3ad15")),
22+
value: U256::from(120000000000000000u64), // 0.12 ETH
2323
data: vec![].into(),
2424
};
2525

2626
// Create batch with single transaction
2727
let batch = SimulationBatch {
2828
block_env: BlockEnv {
29-
number: 18000000,
29+
number: 21784863,
3030
timestamp: 1700000000,
3131
},
3232
transactions: vec![tx],

tests/trace_tests.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ const REVERT_DEMO_BYTECODE:&str = "0x608060405234801561001057600080fd5b506101098
132132
#[tokio::test(flavor = "multi_thread")]
133133
async fn test_nested_revert_with_try_catch() {
134134
let inspector = TxInspector::new();
135-
let mut evm = create_evm_with_inspector(ETH_RPC_URL,inspector).await.unwrap();
135+
let mut evm: revm_trace::evm::TraceEvm<'_, alloy::transports::http::Http<alloy::transports::http::Client>, alloy::providers::RootProvider<alloy::transports::http::Http<alloy::transports::http::Client>>, TxInspector> = create_evm_with_inspector(ETH_RPC_URL,inspector).await.unwrap();
136136
let block_env = get_block_env(ETH_RPC_URL, None).await;
137137

138138
// get current nonce to calculate contract address
@@ -141,7 +141,7 @@ async fn test_nested_revert_with_try_catch() {
141141
let revert_demo_address = SENDER.create(nonce);
142142
let owner_demo_address = SENDER.create(nonce + 1);
143143

144-
// 1. deploy ReverDemo contract
144+
// 1. deploy RevertDemo contract
145145
let tx0 = SimulationTx {
146146
caller: SENDER,
147147
transact_to: TxKind::Create,
@@ -240,6 +240,7 @@ async fn test_nested_revert_with_multicall() {
240240

241241
// get current nonce to calculate contract address
242242
let current_account = evm.db_mut().basic(SENDER).unwrap().unwrap();
243+
243244
let nonce = current_account.nonce;
244245
let revert_demo_address = SENDER.create(nonce);
245246
let owner_demo_address = SENDER.create(nonce + 1);

0 commit comments

Comments
 (0)