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
3 changes: 1 addition & 2 deletions Cargo.lock

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

4 changes: 1 addition & 3 deletions crates/anvil/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ alloy-transport.workspace = true
alloy-chains.workspace = true
alloy-genesis.workspace = true
alloy-trie.workspace = true
alloy-hardforks.workspace = true
alloy-op-hardforks.workspace = true
op-alloy-consensus = { workspace = true, features = ["serde"] }

# revm
Expand Down Expand Up @@ -105,7 +103,7 @@ clap = { version = "4", features = [
"env",
"wrap_help",
], optional = true }
clap_complete = { workspace = true, optional = true}
clap_complete = { workspace = true, optional = true }
chrono.workspace = true
ctrlc = { version = "3", optional = true }
fdlimit = { version = "0.3", optional = true }
Expand Down
4 changes: 2 additions & 2 deletions crates/anvil/src/cmd.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
use crate::{
AccountGenerator, CHAIN_ID, EthereumHardfork, NodeConfig,
AccountGenerator, CHAIN_ID, NodeConfig,
config::{DEFAULT_MNEMONIC, ForkChoice},
eth::{EthApi, backend::db::SerializableState, pool::transactions::TransactionOrder},
};
use alloy_genesis::Genesis;
use alloy_op_hardforks::OpHardfork;
use alloy_primitives::{B256, U256, utils::Unit};
use alloy_signer_local::coins_bip39::{English, Mnemonic};
use anvil_server::ServerConfig;
use clap::Parser;
use core::fmt;
use foundry_common::shell;
use foundry_config::{Chain, Config, FigmentProviders};
use foundry_evm::hardfork::{EthereumHardfork, OpHardfork};
use foundry_evm_networks::NetworkConfigs;
use futures::FutureExt;
use rand_08::{SeedableRng, rngs::StdRng};
Expand Down
14 changes: 8 additions & 6 deletions crates/anvil/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use crate::{
fees::{INITIAL_BASE_FEE, INITIAL_GAS_PRICE},
pool::transactions::{PoolTransaction, TransactionOrder},
},
hardfork::{ChainHardfork, ethereum_hardfork_from_block_tag, spec_id_from_ethereum_hardfork},
mem::{self, in_memory_db::MemDb},
};
use alloy_chains::Chain;
Expand All @@ -21,7 +20,6 @@ use alloy_eips::eip7840::BlobParams;
use alloy_evm::EvmEnv;
use alloy_genesis::Genesis;
use alloy_network::{AnyNetwork, TransactionResponse};
use alloy_op_hardforks::OpHardfork;
use alloy_primitives::{BlockNumber, TxHash, U256, hex, map::HashMap, utils::Unit};
use alloy_provider::Provider;
use alloy_rpc_types::{Block, BlockNumberOrTag};
Expand All @@ -42,6 +40,10 @@ use foundry_evm::{
backend::{BlockchainDb, BlockchainDbMeta, SharedBackend},
constants::DEFAULT_CREATE2_DEPLOYER,
core::AsEnvMut,
hardfork::{
FoundryHardfork, OpHardfork, ethereum_hardfork_from_block_tag,
spec_id_from_ethereum_hardfork,
},
utils::{apply_chain_and_block_specific_env_changes, get_blob_base_fee_update_fraction},
};
use itertools::Itertools;
Expand Down Expand Up @@ -115,7 +117,7 @@ pub struct NodeConfig {
/// Default blob excess gas and price
pub blob_excess_gas_and_price: Option<BlobExcessGasAndPrice>,
/// The hardfork to use
pub hardfork: Option<ChainHardfork>,
pub hardfork: Option<FoundryHardfork>,
/// Signer accounts that will be initialised with `genesis_balance` in the genesis block
pub genesis_accounts: Vec<PrivateKeySigner>,
/// Native token balance of every genesis account in the genesis block
Expand Down Expand Up @@ -547,7 +549,7 @@ impl NodeConfig {
}

/// Returns the hardfork to use
pub fn get_hardfork(&self) -> ChainHardfork {
pub fn get_hardfork(&self) -> FoundryHardfork {
if let Some(hardfork) = self.hardfork {
return hardfork;
}
Expand Down Expand Up @@ -728,7 +730,7 @@ impl NodeConfig {

/// Sets the hardfork
#[must_use]
pub fn with_hardfork(mut self, hardfork: Option<ChainHardfork>) -> Self {
pub fn with_hardfork(mut self, hardfork: Option<FoundryHardfork>) -> Self {
self.hardfork = hardfork;
self
}
Expand Down Expand Up @@ -1237,7 +1239,7 @@ impl NodeConfig {
ethereum_hardfork_from_block_tag(fork_block_number);

env.evm_env.cfg_env.spec = spec_id_from_ethereum_hardfork(hardfork);
self.hardfork = Some(ChainHardfork::Ethereum(hardfork));
self.hardfork = Some(FoundryHardfork::Ethereum(hardfork));
}
Some(U256::from(chain_id))
} else {
Expand Down
3 changes: 1 addition & 2 deletions crates/anvil/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ use alloy_signer_local::PrivateKeySigner;
use eth::backend::fork::ClientFork;
use eyre::Result;
use foundry_common::provider::{ProviderBuilder, RetryProvider};
pub use foundry_evm::hardfork::EthereumHardfork;
use futures::{FutureExt, TryFutureExt};
use parking_lot::Mutex;
use revm::primitives::hardfork::SpecId;
Expand All @@ -49,8 +50,6 @@ pub use config::{
AccountGenerator, CHAIN_ID, DEFAULT_GAS_LIMIT, ForkChoice, NodeConfig, VERSION_MESSAGE,
};

mod hardfork;
pub use alloy_hardforks::EthereumHardfork;
mod error;
/// ethereum related implementations
pub mod eth;
Expand Down
2 changes: 1 addition & 1 deletion crates/anvil/tests/it/anvil.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

use alloy_consensus::EMPTY_ROOT_HASH;
use alloy_eips::BlockNumberOrTag;
use alloy_hardforks::EthereumHardfork;
use alloy_network::{ReceiptResponse, TransactionBuilder};
use alloy_primitives::{Address, B256, U256, bytes, hex};
use alloy_provider::Provider;
use alloy_rpc_types::TransactionRequest;
use alloy_sol_types::SolCall;
use anvil::{NodeConfig, spawn};
use foundry_evm::hardfork::EthereumHardfork;

#[tokio::test(flavor = "multi_thread")]
async fn test_can_change_mining_mode() {
Expand Down
2 changes: 1 addition & 1 deletion crates/anvil/tests/it/anvil_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use crate::{
utils::http_provider_with_signer,
};
use alloy_consensus::{SignableTransaction, TxEip1559};
use alloy_hardforks::EthereumHardfork;
use alloy_network::{EthereumWallet, TransactionBuilder, TxSignerSync};
use alloy_primitives::{Address, Bytes, TxKind, U256, address, fixed_bytes};
use alloy_provider::{Provider, ext::TxPoolApi};
Expand All @@ -22,6 +21,7 @@ use anvil_core::{
eth::EthRequest,
types::{ReorgOptions, TransactionData},
};
use foundry_evm::hardfork::EthereumHardfork;

use revm::primitives::hardfork::SpecId;
use std::{
Expand Down
2 changes: 1 addition & 1 deletion crates/anvil/tests/it/beacon_api.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use crate::utils::http_provider;
use alloy_consensus::{Blob, SidecarBuilder, SimpleCoder, Transaction};
use alloy_hardforks::EthereumHardfork;
use alloy_network::{TransactionBuilder, TransactionBuilder4844};
use alloy_primitives::{B256, FixedBytes, U256, b256};
use alloy_provider::Provider;
use alloy_rpc_types::TransactionRequest;
use alloy_rpc_types_beacon::{genesis::GenesisResponse, sidecar::GetBlobsResponse};
use alloy_serde::WithOtherFields;
use anvil::{NodeConfig, spawn};
use foundry_evm::hardfork::EthereumHardfork;
use ssz::Decode;

#[tokio::test(flavor = "multi_thread")]
Expand Down
2 changes: 1 addition & 1 deletion crates/anvil/tests/it/eip4844.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ use alloy_eips::{
Typed2718,
eip4844::{BLOB_TX_MIN_BLOB_GASPRICE, DATA_GAS_PER_BLOB, MAX_DATA_GAS_PER_BLOCK_DENCUN},
};
use alloy_hardforks::EthereumHardfork;
use alloy_network::{EthereumWallet, ReceiptResponse, TransactionBuilder, TransactionBuilder4844};
use alloy_primitives::{Address, U256, b256};
use alloy_provider::{Provider, ProviderBuilder};
use alloy_rpc_types::{BlockId, TransactionRequest};
use alloy_serde::WithOtherFields;
use anvil::{NodeConfig, spawn};
use foundry_evm::hardfork::EthereumHardfork;
use foundry_test_utils::rpc;

#[tokio::test(flavor = "multi_thread")]
Expand Down
2 changes: 1 addition & 1 deletion crates/anvil/tests/it/eip7702.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use crate::utils::http_provider;
use alloy_consensus::{SignableTransaction, transaction::TxEip7702};
use alloy_hardforks::EthereumHardfork;
use alloy_network::{ReceiptResponse, TransactionBuilder, TxSignerSync};
use alloy_primitives::{U256, bytes};
use alloy_provider::{PendingTransactionConfig, Provider};
use alloy_rpc_types::{Authorization, TransactionRequest};
use alloy_serde::WithOtherFields;
use alloy_signer::{Signature, SignerSync};
use anvil::{NodeConfig, spawn};
use foundry_evm::hardfork::EthereumHardfork;

#[tokio::test(flavor = "multi_thread")]
async fn can_send_eip7702_tx() {
Expand Down
2 changes: 1 addition & 1 deletion crates/anvil/tests/it/otterscan.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//! Tests for otterscan endpoints.

use crate::abi::Multicall;
use alloy_hardforks::EthereumHardfork;
use alloy_network::TransactionResponse;
use alloy_primitives::{Address, Bytes, U256, address};
use alloy_provider::Provider;
Expand All @@ -12,6 +11,7 @@ use alloy_rpc_types::{
use alloy_serde::WithOtherFields;
use alloy_sol_types::{SolCall, SolError, SolValue, sol};
use anvil::{NodeConfig, spawn};
use foundry_evm::hardfork::EthereumHardfork;
use std::collections::VecDeque;

#[tokio::test(flavor = "multi_thread")]
Expand Down
2 changes: 1 addition & 1 deletion crates/anvil/tests/it/traces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use crate::{
utils::http_provider_with_signer,
};
use alloy_eips::BlockId;
use alloy_hardforks::EthereumHardfork;
use alloy_network::{EthereumWallet, TransactionBuilder};
use alloy_primitives::{
Address, Bytes, U256,
Expand All @@ -32,6 +31,7 @@ use alloy_rpc_types::{
use alloy_serde::WithOtherFields;
use alloy_sol_types::sol;
use anvil::{NodeConfig, spawn};
use foundry_evm::hardfork::EthereumHardfork;

#[tokio::test(flavor = "multi_thread")]
async fn test_get_transfer_parity_traces() {
Expand Down
2 changes: 1 addition & 1 deletion crates/anvil/tests/it/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use crate::{
utils::{connect_pubsub, http_provider_with_signer},
};
use alloy_consensus::Transaction;
use alloy_hardforks::EthereumHardfork;
use alloy_network::{EthereumWallet, TransactionBuilder, TransactionResponse};
use alloy_primitives::{Address, Bytes, FixedBytes, U256, address, hex, map::B256HashSet};
use alloy_provider::{Provider, WsConnect};
Expand All @@ -16,6 +15,7 @@ use alloy_serde::WithOtherFields;
use alloy_sol_types::SolValue;
use anvil::{NodeConfig, spawn};
use eyre::Ok;
use foundry_evm::hardfork::EthereumHardfork;
use futures::{FutureExt, StreamExt, future::join_all};
use revm::primitives::eip7825::TX_GAS_LIMIT_CAP;
use std::{str::FromStr, time::Duration};
Expand Down
1 change: 1 addition & 0 deletions crates/evm/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ alloy-dyn-abi = { workspace = true, features = ["arbitrary", "eip712"] }
alloy-evm.workspace = true
alloy-genesis.workspace = true
alloy-hardforks.workspace = true
alloy-op-hardforks.workspace = true
alloy-json-abi.workspace = true
alloy-primitives = { workspace = true, features = [
"serde",
Expand Down
30 changes: 20 additions & 10 deletions crates/anvil/src/hardfork.rs → crates/evm/core/src/hardfork.rs
Original file line number Diff line number Diff line change
@@ -1,33 +1,43 @@
use alloy_hardforks::EthereumHardfork;
use alloy_op_hardforks::OpHardfork::{self};
use alloy_rpc_types::BlockNumberOrTag;

use op_revm::OpSpecId;
use revm::primitives::hardfork::SpecId;

pub use alloy_hardforks::EthereumHardfork;
pub use alloy_op_hardforks::OpHardfork;

#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum ChainHardfork {
pub enum FoundryHardfork {
Ethereum(EthereumHardfork),
Optimism(OpHardfork),
}

impl From<EthereumHardfork> for ChainHardfork {
impl FoundryHardfork {
pub fn ethereum(h: EthereumHardfork) -> Self {
Self::Ethereum(h)
}

pub fn optimism(h: OpHardfork) -> Self {
Self::Optimism(h)
}
}

impl From<EthereumHardfork> for FoundryHardfork {
fn from(value: EthereumHardfork) -> Self {
Self::Ethereum(value)
}
}

impl From<OpHardfork> for ChainHardfork {
impl From<OpHardfork> for FoundryHardfork {
fn from(value: OpHardfork) -> Self {
Self::Optimism(value)
}
}

impl From<ChainHardfork> for SpecId {
fn from(fork: ChainHardfork) -> Self {
impl From<FoundryHardfork> for SpecId {
fn from(fork: FoundryHardfork) -> Self {
match fork {
ChainHardfork::Ethereum(hardfork) => spec_id_from_ethereum_hardfork(hardfork),
ChainHardfork::Optimism(hardfork) => spec_id_from_optimism_hardfork(hardfork).into(),
FoundryHardfork::Ethereum(hardfork) => spec_id_from_ethereum_hardfork(hardfork),
FoundryHardfork::Optimism(hardfork) => spec_id_from_optimism_hardfork(hardfork).into(),
}
}
}
Expand Down
1 change: 1 addition & 0 deletions crates/evm/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ pub mod decode;
pub mod either_evm;
pub mod evm;
pub mod fork;
pub mod hardfork;
pub mod ic;
pub mod opts;
pub mod precompiles;
Expand Down
2 changes: 1 addition & 1 deletion crates/evm/evm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub mod inspectors;

pub use foundry_evm_core as core;
pub use foundry_evm_core::{
Env, EnvMut, EvmEnv, InspectorExt, backend, constants, decode, fork, opts, utils,
Env, EnvMut, EvmEnv, InspectorExt, backend, constants, decode, fork, hardfork, opts, utils,
};
pub use foundry_evm_coverage as coverage;
pub use foundry_evm_fuzz as fuzz;
Expand Down
Loading