Skip to content

Commit da12fae

Browse files
rakitaclaude
andauthored
refactor: re-export statetest-types from revm crate behind test-types feature (#3247)
- Update statetest-types to depend on individual revm crates (primitives, bytecode, state, context, context-interface, database) instead of revm to avoid circular dependency - Add statetest-types as optional dependency to revm crate - Add test-types feature flag to revm that enables statetest-types - Update revme to import statetest_types from revm instead of directly 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 18bb8c0 commit da12fae

19 files changed

Lines changed: 57 additions & 50 deletions

File tree

Cargo.lock

Lines changed: 7 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bins/revme/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ revm = { workspace = true, features = [
1717
"blst",
1818
"tracer",
1919
"parse",
20+
"test-types",
2021
] }
21-
statetest-types.workspace = true
2222

2323
# criterion
2424
criterion.workspace = true

bins/revme/src/cmd/blockchaintest.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ pub mod pre_block;
33

44
use clap::Parser;
55

6+
use revm::statetest_types::blockchain::{
7+
Account, BlockchainTest, BlockchainTestCase, ForkSpec, Withdrawal,
8+
};
69
use revm::{
710
bytecode::Bytecode,
811
context::{cfg::CfgEnv, ContextTr},
@@ -15,9 +18,6 @@ use revm::{
1518
Context, Database, ExecuteCommitEvm, ExecuteEvm, InspectEvm, MainBuilder, MainContext,
1619
};
1720
use serde_json::json;
18-
use statetest_types::blockchain::{
19-
Account, BlockchainTest, BlockchainTestCase, ForkSpec, Withdrawal,
20-
};
2121
use std::{
2222
collections::BTreeMap,
2323
fs,

bins/revme/src/cmd/blockchaintest/post_block.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ use revm::{
22
context::{Block, ContextTr, JournalTr},
33
handler::EvmTr,
44
primitives::{address, hardfork::SpecId, Address, Bytes, ONE_ETHER, ONE_GWEI, U256},
5+
statetest_types::blockchain::Withdrawal,
56
Database, DatabaseCommit, SystemCallCommitEvm,
67
};
7-
use statetest_types::blockchain::Withdrawal;
88

99
/// Post block transition that includes:
1010
/// * Block and uncle rewards before the Merge/Paris hardfork.

bins/revme/src/cmd/statetest/runner.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ use revm::{
1010
database_interface::EmptyDB,
1111
inspector::{inspectors::TracerEip3155, InspectCommitEvm},
1212
primitives::{hardfork::SpecId, Bytes, B256, U256},
13+
statetest_types::{SpecName, Test, TestSuite, TestUnit},
1314
Context, ExecuteCommitEvm, MainBuilder, MainContext,
1415
};
1516
use serde_json::json;
16-
use statetest_types::{SpecName, Test, TestSuite, TestUnit};
1717
use std::{
1818
convert::Infallible,
1919
fmt::Debug,

crates/revm/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ interpreter.workspace = true
3030
precompile.workspace = true
3131
primitives.workspace = true
3232
state.workspace = true
33+
statetest-types = { workspace = true, optional = true }
3334

3435
[dev-dependencies]
3536
serde_json = { workspace = true, features = ["alloc", "preserve_order"] }
@@ -117,3 +118,6 @@ portable = ["precompile/portable"]
117118
# use gmp for modexp precompile.
118119
# It is faster library but licenced as GPL code, if enabled please make sure to follow the license.
119120
gmp = ["precompile/gmp"]
121+
122+
# Statetest types for running ethereum tests
123+
test-types = ["dep:statetest-types"]

crates/revm/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ pub use primitives;
2626
#[doc(inline)]
2727
pub use state;
2828

29+
#[cfg(feature = "test-types")]
30+
#[doc(inline)]
31+
pub use statetest_types;
32+
2933
// Export items.
3034

3135
pub use context::{

crates/statetest-types/Cargo.toml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,18 @@ rustdoc-args = ["--cfg", "docsrs"]
1818
workspace = true
1919

2020
[dependencies]
21-
# revm
22-
revm = { workspace = true, features = ["std", "serde"] }
21+
# revm crates
22+
primitives = { workspace = true, features = ["std", "serde"] }
23+
bytecode = { workspace = true, features = ["std", "serde"] }
24+
state = { workspace = true, features = ["std", "serde"] }
25+
context = { workspace = true, features = ["std", "serde"] }
26+
context-interface = { workspace = true, features = ["std", "serde"] }
27+
database = { workspace = true, features = ["std", "serde"] }
28+
2329
serde = { workspace = true, features = ["derive", "rc"] }
2430
serde_json = { workspace = true, features = ["preserve_order"] }
2531
k256 = { workspace = true }
2632
thiserror = { workspace = true }
27-
alloy-eips = { workspace = true }
2833

2934
# alloy
3035
alloy-eip7928 = { workspace = true, features = ["std", "serde", "rlp"] }

crates/statetest-types/src/account_info.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use revm::primitives::{Bytes, HashMap, StorageKey, StorageValue, U256};
1+
use primitives::{Bytes, HashMap, StorageKey, StorageValue, U256};
22
use serde::Deserialize;
33

44
use crate::deserializer::deserialize_str_as_u64;

crates/statetest-types/src/blockchain.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@
55
66
use crate::{deserialize_maybe_empty, AccountInfo, TestAuthorization};
77
use alloy_eip7928::BlockAccessList;
8-
use revm::{
9-
context::{transaction::AccessList, BlockEnv, TxEnv},
10-
context_interface::block::BlobExcessGasAndPrice,
11-
primitives::{Address, Bytes, FixedBytes, TxKind, B256, U256},
12-
};
8+
use context::{transaction::AccessList, BlockEnv, TxEnv};
9+
use context_interface::block::BlobExcessGasAndPrice;
10+
use primitives::{Address, Bytes, FixedBytes, TxKind, B256, U256};
1311
use serde::Deserialize;
1412
use std::collections::BTreeMap;
1513

@@ -444,7 +442,7 @@ impl BlockchainTestCase {
444442

445443
#[cfg(test)]
446444
mod test {
447-
use revm::primitives::address;
445+
use primitives::address;
448446

449447
use super::*;
450448

@@ -519,7 +517,7 @@ mod test {
519517
#[test]
520518
fn test_transaction_conversion() {
521519
use crate::blockchain::Transaction;
522-
use revm::primitives::{Bytes, U256};
520+
use primitives::{Bytes, U256};
523521

524522
let tx = Transaction {
525523
transaction_type: Some(U256::from(0)),

0 commit comments

Comments
 (0)