Skip to content

chore: activate prague hardfork by default and use 0.8.30 for tests #10565

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
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
5 changes: 5 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -392,4 +392,5 @@ op-revm = { git = "https://github.com/bluealloy/revm.git", rev = "b5808253" }
# revm-inspectors = { git = "https://github.com/paradigmxyz/revm-inspectors.git", rev = "a625c04" }

## foundry
foundry-compilers = { git = "https://github.com/foundry-rs/compilers.git", rev = "898bcbb" }
# foundry-fork-db = { git = "https://github.com/foundry-rs/foundry-fork-db", rev = "811a61a" }
2 changes: 1 addition & 1 deletion crates/anvil/src/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ pub struct NodeArgs {

/// The EVM hardfork to use.
///
/// Choose the hardfork by name, e.g. `cancun`, `shanghai`, `paris`, `london`, etc...
/// Choose the hardfork by name, e.g. `prague`, `cancun`, `shanghai`, `paris`, `london`, etc...
/// [default: latest]
#[arg(long)]
pub hardfork: Option<String>,
Expand Down
14 changes: 10 additions & 4 deletions crates/anvil/src/eth/backend/mem/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -780,11 +780,17 @@ impl Backend {

/// Returns [`BlobParams`] corresponding to the current spec.
pub fn blob_params(&self) -> BlobParams {
if self.env.read().evm_env.cfg_env.spec >= SpecId::PRAGUE {
BlobParams::prague()
} else {
BlobParams::cancun()
let spec_id = self.env.read().evm_env.cfg_env.spec;

if spec_id >= SpecId::OSAKA {
return BlobParams::osaka();
}

if spec_id >= SpecId::PRAGUE {
return BlobParams::prague();
}

BlobParams::cancun()
}

/// Returns an error if EIP1559 is not active (pre Berlin)
Expand Down
19 changes: 17 additions & 2 deletions crates/anvil/src/eth/fees.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ pub fn calculate_next_block_base_fee(gas_used: u64, gas_limit: u64, base_fee: u6

/// An async service that takes care of the `FeeHistory` cache
pub struct FeeHistoryService {
/// Hardfork identifier
spec_id: SpecId,
/// incoming notifications about new blocks
new_blocks: NewBlockNotifications,
/// contains all fee history related entries
Expand All @@ -204,11 +206,18 @@ pub struct FeeHistoryService {

impl FeeHistoryService {
pub fn new(
spec_id: SpecId,
new_blocks: NewBlockNotifications,
cache: FeeHistoryCache,
storage_info: StorageInfo,
) -> Self {
Self { new_blocks, cache, fee_history_limit: MAX_FEE_HISTORY_CACHE_SIZE, storage_info }
Self {
spec_id,
new_blocks,
cache,
fee_history_limit: MAX_FEE_HISTORY_CACHE_SIZE,
storage_info,
}
}

/// Returns the configured history limit
Expand Down Expand Up @@ -245,7 +254,13 @@ impl FeeHistoryService {
let base_fee = header.base_fee_per_gas.map(|g| g as u128).unwrap_or_default();
let excess_blob_gas = header.excess_blob_gas.map(|g| g as u128);
let blob_gas_used = header.blob_gas_used.map(|g| g as u128);
let base_fee_per_blob_gas = header.blob_fee(BlobParams::cancun());

let base_fee_per_blob_gas = match self.spec_id {
SpecId::OSAKA => header.blob_fee(BlobParams::osaka()),
SpecId::PRAGUE => header.blob_fee(BlobParams::prague()),
_ => header.blob_fee(BlobParams::cancun()),
};

let mut item = FeeHistoryCacheItem {
base_fee,
gas_used_ratio: 0f64,
Expand Down
8 changes: 4 additions & 4 deletions crates/anvil/src/hardfork.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ impl EthereumHardfork {
Self::GrayGlacier => 15050000,
Self::Paris => 15537394,
Self::Shanghai => 17034870,
Self::Cancun | Self::Latest => 19426587,
Self::Prague => 22431084,
Self::Cancun => 19426587,
Self::Prague | Self::Latest => 22431084,
}
}
}
Expand Down Expand Up @@ -131,8 +131,8 @@ impl From<EthereumHardfork> for SpecId {
EthereumHardfork::GrayGlacier => Self::GRAY_GLACIER,
EthereumHardfork::Paris => Self::MERGE,
EthereumHardfork::Shanghai => Self::SHANGHAI,
EthereumHardfork::Cancun | EthereumHardfork::Latest => Self::CANCUN,
EthereumHardfork::Prague => Self::PRAGUE,
EthereumHardfork::Cancun => Self::CANCUN,
EthereumHardfork::Prague | EthereumHardfork::Latest => Self::PRAGUE,
}
}
}
Expand Down
1 change: 1 addition & 0 deletions crates/anvil/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ pub async fn try_spawn(mut config: NodeConfig) -> Result<(EthApi, NodeHandle)> {

let fee_history_cache = Arc::new(Mutex::new(Default::default()));
let fee_history_service = FeeHistoryService::new(
backend.spec_id(),
backend.new_block_notifications(),
Arc::clone(&fee_history_cache),
StorageInfo::new(Arc::clone(&backend)),
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 @@ -448,7 +448,7 @@ async fn can_get_node_info() {

let block_number = provider.get_block_number().await.unwrap();
let block = provider.get_block(BlockId::from(block_number)).await.unwrap().unwrap();
let hard_fork: &str = SpecId::CANCUN.into();
let hard_fork: &str = SpecId::PRAGUE.into();

let expected_node_info = NodeInfo {
current_block_number: 0_u64,
Expand Down
2 changes: 1 addition & 1 deletion crates/cast/src/cmd/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ impl RunArgs {
if evm_version.is_none() {
// if the block has the excess_blob_gas field, we assume it's a Cancun block
if block.header.excess_blob_gas.is_some() {
evm_version = Some(EvmVersion::Cancun);
evm_version = Some(EvmVersion::Prague);
}
}
apply_chain_and_block_specific_env_changes::<AnyNetwork>(env.as_env_mut(), block);
Expand Down
2 changes: 1 addition & 1 deletion crates/config/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ allow_paths = []
# additional solc include paths
include_paths = []
force = false
evm_version = 'shanghai'
evm_version = 'prague'
gas_reports = ['*']
gas_reports_ignore = []
## Sets the concrete solc version to use, this overrides the `auto_detect_solc` value
Expand Down
2 changes: 1 addition & 1 deletion crates/config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2309,7 +2309,7 @@ impl Default for Config {
allow_paths: vec![],
include_paths: vec![],
force: false,
evm_version: EvmVersion::Cancun,
evm_version: EvmVersion::Prague,
gas_reports: vec!["*".to_string()],
gas_reports_ignore: vec![],
gas_reports_include_tests: false,
Expand Down
2 changes: 1 addition & 1 deletion crates/forge/tests/cli/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3673,7 +3673,7 @@ forgetest_init!(can_inspect_standard_json, |prj, cmd| {
]
}
},
"evmVersion": "cancun",
"evmVersion": "prague",
"viaIR": false,
"libraries": {}
}
Expand Down
10 changes: 5 additions & 5 deletions crates/forge/tests/cli/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -982,7 +982,7 @@ allow_paths = []
include_paths = []
skip = []
force = false
evm_version = "cancun"
evm_version = "prague"
gas_reports = ["*"]
gas_reports_ignore = []
gas_reports_include_tests = false
Expand Down Expand Up @@ -1140,7 +1140,7 @@ exclude = []
"include_paths": [],
"skip": [],
"force": false,
"evm_version": "cancun",
"evm_version": "prague",
"gas_reports": [
"*"
],
Expand Down Expand Up @@ -1787,19 +1787,19 @@ contract Counter {

let (via_ir, evm_version, enabled, runs) = artifact_settings("Counter.sol/Counter.json");
assert_eq!(None, via_ir);
assert_eq!("\"cancun\"", evm_version.unwrap().to_string());
assert_eq!("\"prague\"", evm_version.unwrap().to_string());
assert_eq!("false", enabled.unwrap().to_string());
assert_eq!("200", runs.unwrap().to_string());

let (via_ir, evm_version, enabled, runs) = artifact_settings("v1/Counter.sol/Counter.json");
assert_eq!("true", via_ir.unwrap().to_string());
assert_eq!("\"cancun\"", evm_version.unwrap().to_string());
assert_eq!("\"prague\"", evm_version.unwrap().to_string());
assert_eq!("true", enabled.unwrap().to_string());
assert_eq!("44444444", runs.unwrap().to_string());

let (via_ir, evm_version, enabled, runs) = artifact_settings("v2/Counter.sol/Counter.json");
assert_eq!("true", via_ir.unwrap().to_string());
assert_eq!("\"cancun\"", evm_version.unwrap().to_string());
assert_eq!("\"prague\"", evm_version.unwrap().to_string());
assert_eq!("true", enabled.unwrap().to_string());
assert_eq!("111", runs.unwrap().to_string());

Expand Down
2 changes: 1 addition & 1 deletion crates/forge/tests/cli/script.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2575,7 +2575,7 @@ Chain 31337

accessList []
chainId 31337
gasLimit 228231
gasLimit [..]
gasPrice
input [..]
maxFeePerBlobGas
Expand Down
2 changes: 1 addition & 1 deletion crates/test-utils/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ static TEMPLATE_LOCK: LazyLock<PathBuf> =
static NEXT_ID: AtomicUsize = AtomicUsize::new(0);

/// The default Solc version used when compiling tests.
pub const SOLC_VERSION: &str = "0.8.27";
pub const SOLC_VERSION: &str = "0.8.30";

/// Another Solc version used when compiling tests.
///
Expand Down
Loading