Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
10 changes: 7 additions & 3 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion bins/revme/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ revm = { workspace = true, features = [
"blst",
"tracer",
"parse",
"test-types",
] }
statetest-types.workspace = true

# criterion
criterion.workspace = true
Expand Down
6 changes: 3 additions & 3 deletions bins/revme/src/cmd/blockchaintest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ pub mod pre_block;

use clap::Parser;

use revm::statetest_types::blockchain::{
Account, BlockchainTest, BlockchainTestCase, ForkSpec, Withdrawal,
};
use revm::{
bytecode::Bytecode,
context::{cfg::CfgEnv, ContextTr},
Expand All @@ -15,9 +18,6 @@ use revm::{
Context, Database, ExecuteCommitEvm, ExecuteEvm, InspectEvm, MainBuilder, MainContext,
};
use serde_json::json;
use statetest_types::blockchain::{
Account, BlockchainTest, BlockchainTestCase, ForkSpec, Withdrawal,
};
use std::{
collections::BTreeMap,
fs,
Expand Down
2 changes: 1 addition & 1 deletion bins/revme/src/cmd/blockchaintest/post_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ use revm::{
context::{Block, ContextTr, JournalTr},
handler::EvmTr,
primitives::{address, hardfork::SpecId, Address, Bytes, ONE_ETHER, ONE_GWEI, U256},
statetest_types::blockchain::Withdrawal,
Database, DatabaseCommit, SystemCallCommitEvm,
};
use statetest_types::blockchain::Withdrawal;

/// Post block transition that includes:
/// * Block and uncle rewards before the Merge/Paris hardfork.
Expand Down
2 changes: 1 addition & 1 deletion bins/revme/src/cmd/statetest/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ use revm::{
database_interface::EmptyDB,
inspector::{inspectors::TracerEip3155, InspectCommitEvm},
primitives::{hardfork::SpecId, Bytes, B256, U256},
statetest_types::{SpecName, Test, TestSuite, TestUnit},
Context, ExecuteCommitEvm, MainBuilder, MainContext,
};
use serde_json::json;
use statetest_types::{SpecName, Test, TestSuite, TestUnit};
use std::{
convert::Infallible,
fmt::Debug,
Expand Down
4 changes: 4 additions & 0 deletions crates/revm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ interpreter.workspace = true
precompile.workspace = true
primitives.workspace = true
state.workspace = true
statetest-types = { workspace = true, optional = true }

[dev-dependencies]
serde_json = { workspace = true, features = ["alloc", "preserve_order"] }
Expand Down Expand Up @@ -117,3 +118,6 @@ portable = ["precompile/portable"]
# use gmp for modexp precompile.
# It is faster library but licenced as GPL code, if enabled please make sure to follow the license.
gmp = ["precompile/gmp"]

# Statetest types for running ethereum tests
test-types = ["dep:statetest-types"]
4 changes: 4 additions & 0 deletions crates/revm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ pub use primitives;
#[doc(inline)]
pub use state;

#[cfg(feature = "test-types")]
#[doc(inline)]
pub use statetest_types;
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only part that touched revm lib, other changes are revme related and not consensus sensitive.


// Export items.

pub use context::{
Expand Down
11 changes: 8 additions & 3 deletions crates/statetest-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,18 @@ rustdoc-args = ["--cfg", "docsrs"]
workspace = true

[dependencies]
# revm
revm = { workspace = true, features = ["std", "serde"] }
# revm crates
primitives = { workspace = true, features = ["std", "serde"] }
bytecode = { workspace = true, features = ["std", "serde"] }
state = { workspace = true, features = ["std", "serde"] }
context = { workspace = true, features = ["std", "serde"] }
context-interface = { workspace = true, features = ["std", "serde"] }
database = { workspace = true, features = ["std", "serde"] }

serde = { workspace = true, features = ["derive", "rc"] }
serde_json = { workspace = true, features = ["preserve_order"] }
k256 = { workspace = true }
thiserror = { workspace = true }
alloy-eips = { workspace = true }

# alloy
alloy-eip7928 = { workspace = true, features = ["std", "serde", "rlp"] }
2 changes: 1 addition & 1 deletion crates/statetest-types/src/account_info.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use revm::primitives::{Bytes, HashMap, StorageKey, StorageValue, U256};
use primitives::{Bytes, HashMap, StorageKey, StorageValue, U256};
use serde::Deserialize;

use crate::deserializer::deserialize_str_as_u64;
Expand Down
12 changes: 5 additions & 7 deletions crates/statetest-types/src/blockchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@

use crate::{deserialize_maybe_empty, AccountInfo, TestAuthorization};
use alloy_eip7928::BlockAccessList;
use revm::{
context::{transaction::AccessList, BlockEnv, TxEnv},
context_interface::block::BlobExcessGasAndPrice,
primitives::{Address, Bytes, FixedBytes, TxKind, B256, U256},
};
use context::{transaction::AccessList, BlockEnv, TxEnv};
use context_interface::block::BlobExcessGasAndPrice;
use primitives::{Address, Bytes, FixedBytes, TxKind, B256, U256};
use serde::Deserialize;
use std::collections::BTreeMap;

Expand Down Expand Up @@ -444,7 +442,7 @@ impl BlockchainTestCase {

#[cfg(test)]
mod test {
use revm::primitives::address;
use primitives::address;

use super::*;

Expand Down Expand Up @@ -519,7 +517,7 @@ mod test {
#[test]
fn test_transaction_conversion() {
use crate::blockchain::Transaction;
use revm::primitives::{Bytes, U256};
use primitives::{Bytes, U256};

let tx = Transaction {
transaction_type: Some(U256::from(0)),
Expand Down
2 changes: 1 addition & 1 deletion crates/statetest-types/src/deserializer.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use revm::primitives::Address;
use primitives::Address;
use serde::{de, Deserialize};

/// Deserializes a [string][String] as a [u64].
Expand Down
2 changes: 1 addition & 1 deletion crates/statetest-types/src/env.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use revm::primitives::{Address, B256, U256};
use primitives::{Address, B256, U256};
use serde::Deserialize;

/// Environment variables
Expand Down
2 changes: 1 addition & 1 deletion crates/statetest-types/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use revm::primitives::B256;
use primitives::B256;
use thiserror::Error;

/// Errors that can occur during test setup and execution
Expand Down
2 changes: 1 addition & 1 deletion crates/statetest-types/src/spec.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use revm::primitives::hardfork::SpecId;
use primitives::hardfork::SpecId;
use serde::Deserialize;

/// Ethereum specification names
Expand Down
8 changes: 3 additions & 5 deletions crates/statetest-types/src/test.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
use revm::{
context::tx::TxEnv,
primitives::{Address, Bytes, HashMap, TxKind, B256},
};
use context::tx::TxEnv;
use primitives::{Address, Bytes, HashMap, TxKind, B256};
use serde::Deserialize;

use crate::{
Expand Down Expand Up @@ -119,7 +117,7 @@ impl Test {
.map(|auth_list| {
auth_list
.into_iter()
.map(|i| revm::context::either::Either::Left(i.into()))
.map(|i| context::either::Either::Left(i.into()))
.collect::<Vec<_>>()
})
.unwrap_or_default(),
Expand Down
2 changes: 1 addition & 1 deletion crates/statetest-types/src/test_authorization.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use revm::context_interface::transaction::SignedAuthorization;
use context_interface::transaction::SignedAuthorization;
use serde::{de::Error, Deserialize, Deserializer, Serialize};

/// Struct for test authorization
Expand Down
22 changes: 9 additions & 13 deletions crates/statetest-types/src/test_unit.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
use crate::{AccountInfo, Env, SpecName, Test, TransactionParts};
use revm::{
context::{block::BlockEnv, cfg::CfgEnv},
database::CacheState,
primitives::{hardfork::SpecId, keccak256, Address, Bytes, HashMap, B256},
state::Bytecode,
};
use context::{block::BlockEnv, cfg::CfgEnv};
use database::CacheState;
use primitives::{hardfork::SpecId, keccak256, Address, Bytes, HashMap, B256};
use serde::Deserialize;
use state::Bytecode;
use std::collections::BTreeMap;

/// Single test unit struct
Expand Down Expand Up @@ -71,7 +69,7 @@ impl TestUnit {
let code_hash = keccak256(&info.code);
let bytecode = Bytecode::new_raw_checked(info.code.clone())
.unwrap_or(Bytecode::new_legacy(info.code.clone()));
let acc_info = revm::state::AccountInfo {
let acc_info = state::AccountInfo {
balance: info.balance,
code_hash,
code: Some(bytecode),
Expand Down Expand Up @@ -133,12 +131,10 @@ impl TestUnit {
#[cfg(test)]
mod tests {
use super::*;
use revm::{
context_interface::block::calc_blob_gasprice,
primitives::{
eip4844::{BLOB_BASE_FEE_UPDATE_FRACTION_CANCUN, BLOB_BASE_FEE_UPDATE_FRACTION_PRAGUE},
U256,
},
use context_interface::block::calc_blob_gasprice;
use primitives::{
eip4844::{BLOB_BASE_FEE_UPDATE_FRACTION_CANCUN, BLOB_BASE_FEE_UPDATE_FRACTION_PRAGUE},
U256,
};

/// Creates a minimal TestUnit with excess blob gas set for testing blob fee calculation
Expand Down
8 changes: 3 additions & 5 deletions crates/statetest-types/src/transaction.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
use crate::{deserializer::deserialize_maybe_empty, TestAuthorization};
use revm::{
context::TransactionType,
context_interface::transaction::AccessList,
primitives::{Address, Bytes, B256, U256},
};
use context::TransactionType;
use context_interface::transaction::AccessList;
use primitives::{Address, Bytes, B256, U256};
use serde::{Deserialize, Serialize};

/// Transaction parts.
Expand Down
4 changes: 2 additions & 2 deletions crates/statetest-types/src/utils.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use k256::ecdsa::SigningKey;
use revm::primitives::Address;
use primitives::Address;

/// Recover the address from a private key ([SigningKey]).
pub fn recover_address(private_key: &[u8]) -> Option<Address> {
Expand All @@ -11,7 +11,7 @@ pub fn recover_address(private_key: &[u8]) -> Option<Address> {
#[cfg(test)]
mod tests {
use super::*;
use revm::primitives::{address, hex};
use primitives::{address, hex};

#[test]
fn sanity_test() {
Expand Down
Loading