From e9bdd1d9a769402758f92f03e32eaf81d5866da5 Mon Sep 17 00:00:00 2001 From: Wodann Date: Tue, 11 Aug 2026 03:26:10 +0000 Subject: [PATCH 01/10] refactor(edr_chain_l1): remove unsupported pre-Byzantium hardforks from L1Hardfork The mainnet activation schedule, the NAPI `SpecId` enum and its exported name constants follow. Discriminants of the remaining variants are unchanged, so `Byzantium` stays 6. Forking previously rejected pre-Spurious-Dragon blocks by inspecting the resolved hardfork. With those activations gone, `hardfork_at_block` returns `None` below block 4,370,000, which the old `if let Some` skipped silently. Resolving a hardfork is now mandatory for any chain that has an activation schedule, and failing to do so is `UnsupportedForkBlock`, which names the oldest hardfork the chain supports via the new `HardforkActivations::oldest_hardfork`. --- .changeset/mighty-poems-tickle.md | 9 +++++ crates/blockchain/fork/src/lib.rs | 33 +++++++++---------- crates/chain/config/src/lib.rs | 10 ++++++ crates/edr_chain_l1/src/chains.rs | 24 -------------- crates/edr_chain_l1/src/hardfork.rs | 51 ++--------------------------- crates/edr_napi/index.d.ts | 24 -------------- crates/edr_napi/index.js | 6 ---- crates/edr_napi/src/chains/l1.rs | 36 -------------------- crates/eips/1559/src/lib.rs | 6 ++-- 9 files changed, 40 insertions(+), 159 deletions(-) create mode 100644 .changeset/mighty-poems-tickle.md diff --git a/.changeset/mighty-poems-tickle.md b/.changeset/mighty-poems-tickle.md new file mode 100644 index 0000000000..448b0014f3 --- /dev/null +++ b/.changeset/mighty-poems-tickle.md @@ -0,0 +1,9 @@ +--- +"@nomicfoundation/edr": minor +--- + +Removed support for pre-Byzantium Ethereum L1 hardforks. The `SpecId` enum no longer includes `Frontier`, `FrontierThawing`, `Homestead`, `DaoFork`, `Tangerine` and `SpuriousDragon`, and the corresponding `FRONTIER`, `FRONTIER_THAWING`, `HOMESTEAD`, `DAO_FORK`, `TANGERINE` and `SPURIOUS_DRAGON` string constants are gone. Discriminants of the remaining variants are unchanged, so `Byzantium` is still `6`. + +Passing one of the removed hardfork names now throws `The provided hardfork \`\` is not supported.` + +Forking a chain from a block that precedes its oldest supported hardfork now fails with an error naming that hardfork, instead of silently skipping hardfork validation. diff --git a/crates/blockchain/fork/src/lib.rs b/crates/blockchain/fork/src/lib.rs index 95a3617e2e..06f7310f57 100644 --- a/crates/blockchain/fork/src/lib.rs +++ b/crates/blockchain/fork/src/lib.rs @@ -72,17 +72,17 @@ pub enum ForkedBlockchainCreationError { /// Latest block number latest_block_number: u64, }, - /// The detected hardfork is not supported + /// The fork block predates the chain's oldest supported hardfork #[error( - "Cannot fork {chain_name} from block {fork_block_number}. The hardfork must be at least Spurious Dragon, but {hardfork:?} was detected." + "Cannot fork {chain_name} from block {fork_block_number}. The block precedes {oldest_hardfork:?}, which is the chain's oldest supported hardfork." )] - InvalidHardfork { + UnsupportedForkBlock { /// Requested fork block number fork_block_number: u64, /// Chain name chain_name: String, - /// Detected hardfork - hardfork: HardforkT, + /// The chain's oldest supported hardfork + oldest_hardfork: HardforkT, }, /// Unsupported storage overrides #[error( @@ -303,23 +303,20 @@ impl< .expect("Block must exist since block number is less than the latest block number.") .timestamp(); - if let Some(remote_hardfork) = - hardfork_activations - .as_ref() - .and_then(|hardfork_activations| { - hardfork_activations.hardfork_at_block(fork_block_number, fork_timestamp) - }) - { - let remote_evm_spec_id = remote_hardfork.clone().into(); - if remote_evm_spec_id < EvmSpecId::SPURIOUS_DRAGON { - return Err(ForkedBlockchainCreationError::InvalidHardfork { + if let Some(hardfork_activations) = hardfork_activations.as_ref() { + let remote_hardfork = hardfork_activations + .hardfork_at_block(fork_block_number, fork_timestamp) + .ok_or_else(|| ForkedBlockchainCreationError::UnsupportedForkBlock { chain_name: chain_config .map_or("unknown".to_string(), |config| config.name.clone()), fork_block_number, - hardfork: remote_hardfork, - }); - } + oldest_hardfork: hardfork_activations + .oldest_hardfork() + .expect("Empty activation schedules are mapped to `None` above") + .clone(), + })?; + let remote_evm_spec_id = remote_hardfork.clone().into(); let local_evm_spec_id = hardfork.clone().into(); if remote_evm_spec_id < EvmSpecId::PRAGUE && local_evm_spec_id >= EvmSpecId::PRAGUE { let state_root = state_root_generator.lock().next_value(); diff --git a/crates/chain/config/src/lib.rs b/crates/chain/config/src/lib.rs index 55ac6e274f..4f3086c77a 100644 --- a/crates/chain/config/src/lib.rs +++ b/crates/chain/config/src/lib.rs @@ -22,6 +22,8 @@ pub struct HardforkActivation { } /// A struct that stores the hardforks for a chain. +/// +/// Activations are ordered from oldest to newest. #[derive(Clone, Debug, Default, serde::Deserialize, serde::Serialize)] #[serde(transparent)] pub struct HardforkActivations { @@ -54,6 +56,14 @@ impl HardforkActivations { pub fn is_empty(&self) -> bool { self.hardforks.is_empty() } + + /// Returns the oldest hardfork of the activation schedule, or `None` if it + /// is empty. + pub fn oldest_hardfork(&self) -> Option<&HardforkT> { + self.hardforks + .first() + .map(|HardforkActivation { hardfork, .. }| hardfork) + } } impl HardforkActivations { diff --git a/crates/edr_chain_l1/src/chains.rs b/crates/edr_chain_l1/src/chains.rs index 7be8d625da..bad43dde3f 100644 --- a/crates/edr_chain_l1/src/chains.rs +++ b/crates/edr_chain_l1/src/chains.rs @@ -13,30 +13,6 @@ use crate::{Hardfork, L1_BASE_FEE_PARAMS}; pub const L1_MAINNET_CHAIN_ID: u64 = 0x1; const MAINNET_HARDFORKS: &[HardforkActivation] = &[ - HardforkActivation { - condition: ForkCondition::Block(0), - hardfork: Hardfork::Frontier, - }, - HardforkActivation { - condition: ForkCondition::Block(200_000), - hardfork: Hardfork::FrontierThawing, - }, - HardforkActivation { - condition: ForkCondition::Block(1_150_000), - hardfork: Hardfork::Homestead, - }, - HardforkActivation { - condition: ForkCondition::Block(1_920_000), - hardfork: Hardfork::DaoFork, - }, - HardforkActivation { - condition: ForkCondition::Block(2_463_000), - hardfork: Hardfork::Tangerine, - }, - HardforkActivation { - condition: ForkCondition::Block(2_675_000), - hardfork: Hardfork::SpuriousDragon, - }, HardforkActivation { condition: ForkCondition::Block(4_370_000), hardfork: Hardfork::Byzantium, diff --git a/crates/edr_chain_l1/src/hardfork.rs b/crates/edr_chain_l1/src/hardfork.rs index 22a1b8adc1..f4109a5047 100644 --- a/crates/edr_chain_l1/src/hardfork.rs +++ b/crates/edr_chain_l1/src/hardfork.rs @@ -27,23 +27,8 @@ use edr_primitives::UnknownHardfork; )] #[strum(parse_err_ty = UnknownHardfork, parse_err_fn = unknown_hardfork)] pub enum L1Hardfork { - /// Frontier hardfork - Frontier = 0, - /// Frontier Thawing hardfork - #[strum(serialize = "Frontier Thawing")] - FrontierThawing, - /// Homestead hardfork - Homestead, - /// DAO Fork hardfork - #[strum(serialize = "DAO Fork")] - DaoFork, - /// Tangerine Whistle hardfork - Tangerine, - /// Spurious Dragon hardfork - #[strum(serialize = "Spurious")] - SpuriousDragon, /// Byzantium hardfork - Byzantium, + Byzantium = 6, /// Constantinople hardfork Constantinople, /// Petersburg hardfork @@ -84,12 +69,6 @@ fn unknown_hardfork(_name: &str) -> UnknownHardfork { impl From for EvmSpecId { fn from(hardfork: L1Hardfork) -> Self { match hardfork { - // revm only models EVM behavior classes; hardforks without EVM - // changes map to their EVM-equivalent predecessor. - L1Hardfork::Frontier | L1Hardfork::FrontierThawing => EvmSpecId::FRONTIER, - L1Hardfork::Homestead | L1Hardfork::DaoFork => EvmSpecId::HOMESTEAD, - L1Hardfork::Tangerine => EvmSpecId::TANGERINE, - L1Hardfork::SpuriousDragon => EvmSpecId::SPURIOUS_DRAGON, L1Hardfork::Byzantium => EvmSpecId::BYZANTIUM, // Constantinople never went live on mainnet on its own: Petersburg // (Constantinople minus EIP-1283) activated at the same block. @@ -111,18 +90,6 @@ impl From for EvmSpecId { /// String identifiers for L1 hardforks. pub mod name { - /// String identifier for the Frontier hardfork - pub const FRONTIER: &str = "Frontier"; - /// String identifier for the Frontier Thawing hardfork - pub const FRONTIER_THAWING: &str = "Frontier Thawing"; - /// String identifier for the Homestead hardfork - pub const HOMESTEAD: &str = "Homestead"; - /// String identifier for the DAO Fork hardfork - pub const DAO_FORK: &str = "DAO Fork"; - /// String identifier for the Tangerine Whistle hardfork - pub const TANGERINE: &str = "Tangerine"; - /// String identifier for the Spurious Dragon hardfork - pub const SPURIOUS_DRAGON: &str = "Spurious"; /// String identifier for the Byzantium hardfork pub const BYZANTIUM: &str = "Byzantium"; /// String identifier for the Constantinople hardfork @@ -163,13 +130,7 @@ mod tests { use super::*; - const VARIANTS: [L1Hardfork; 21] = [ - L1Hardfork::Frontier, - L1Hardfork::FrontierThawing, - L1Hardfork::Homestead, - L1Hardfork::DaoFork, - L1Hardfork::Tangerine, - L1Hardfork::SpuriousDragon, + const VARIANTS: [L1Hardfork; 15] = [ L1Hardfork::Byzantium, L1Hardfork::Constantinople, L1Hardfork::Petersburg, @@ -196,13 +157,7 @@ mod tests { /// The strings the `strum` derives emit/parse must stay in sync with the /// [`name`] module constants, which are re-exported as public API. - const NAMES: [&str; 21] = [ - name::FRONTIER, - name::FRONTIER_THAWING, - name::HOMESTEAD, - name::DAO_FORK, - name::TANGERINE, - name::SPURIOUS_DRAGON, + const NAMES: [&str; 15] = [ name::BYZANTIUM, name::CONSTANTINOPLE, name::PETERSBURG, diff --git a/crates/edr_napi/index.d.ts b/crates/edr_napi/index.d.ts index 4537ffabd6..20b10665d2 100644 --- a/crates/edr_napi/index.d.ts +++ b/crates/edr_napi/index.d.ts @@ -516,8 +516,6 @@ export interface CustomErrorStackTraceEntry { sourceReference: SourceReference } -export const DAO_FORK: string - export interface DebugTraceLogItem { /** Program Counter */ pc: bigint @@ -668,10 +666,6 @@ export interface ForkConfig { url: string } -export const FRONTIER: string - -export const FRONTIER_THAWING: string - /** * Determines the level of file system access for the given path. * * Exact path matching is used for file permissions. Prefix matching is used @@ -880,8 +874,6 @@ export interface HeuristicFailed { export const HOLOCENE: string -export const HOMESTEAD: string - export interface HttpHeader { name: string value: string @@ -1792,18 +1784,6 @@ export interface SourceReference { /** Identifier for the Ethereum spec. */ export declare enum SpecId { - /** Frontier */ - Frontier = 0, - /** Frontier Thawing */ - FrontierThawing = 1, - /** Homestead */ - Homestead = 2, - /** DAO Fork */ - DaoFork = 3, - /** Tangerine */ - Tangerine = 4, - /** Spurious Dragon */ - SpuriousDragon = 5, /** Byzantium */ Byzantium = 6, /** Constantinople */ @@ -1836,8 +1816,6 @@ export declare enum SpecId { Amsterdam = 20 } -export const SPURIOUS_DRAGON: string - /** The stack trace result */ export interface StackTrace { /** Enum tag for JS. */ @@ -1966,8 +1944,6 @@ export interface SuiteResult { warnings: Array } -export const TANGERINE: string - /** The result of a test execution. */ export declare enum TestStatus { /** Test success */ diff --git a/crates/edr_napi/index.js b/crates/edr_napi/index.js index 34380155af..196f58c7d9 100644 --- a/crates/edr_napi/index.js +++ b/crates/edr_napi/index.js @@ -729,14 +729,11 @@ module.exports.CONSTANTINOPLE = nativeBinding.CONSTANTINOPLE module.exports.CONSTRUCTOR_FUNCTION_NAME = nativeBinding.CONSTRUCTOR_FUNCTION_NAME module.exports.ContractFunctionType = nativeBinding.ContractFunctionType module.exports.COVERAGE_LIBRARY_FILE_NAME = nativeBinding.COVERAGE_LIBRARY_FILE_NAME -module.exports.DAO_FORK = nativeBinding.DAO_FORK module.exports.ECOTONE = nativeBinding.ECOTONE module.exports.ExceptionalHalt = nativeBinding.ExceptionalHalt module.exports.ExitCode = nativeBinding.ExitCode module.exports.FALLBACK_FUNCTION_NAME = nativeBinding.FALLBACK_FUNCTION_NAME module.exports.FJORD = nativeBinding.FJORD -module.exports.FRONTIER = nativeBinding.FRONTIER -module.exports.FRONTIER_THAWING = nativeBinding.FRONTIER_THAWING module.exports.FsAccessPermission = nativeBinding.FsAccessPermission module.exports.GasEstimationMode = nativeBinding.GasEstimationMode module.exports.GasReportExecutionStatus = nativeBinding.GasReportExecutionStatus @@ -745,7 +742,6 @@ module.exports.genericChainProviderFactory = nativeBinding.genericChainProviderF module.exports.GRANITE = nativeBinding.GRANITE module.exports.GRAY_GLACIER = nativeBinding.GRAY_GLACIER module.exports.HOLOCENE = nativeBinding.HOLOCENE -module.exports.HOMESTEAD = nativeBinding.HOMESTEAD module.exports.IncludeTraces = nativeBinding.IncludeTraces module.exports.ISTANBUL = nativeBinding.ISTANBUL module.exports.ISTHMUS = nativeBinding.ISTHMUS @@ -782,11 +778,9 @@ module.exports.RECEIVE_FUNCTION_NAME = nativeBinding.RECEIVE_FUNCTION_NAME module.exports.REGOLITH = nativeBinding.REGOLITH module.exports.SHANGHAI = nativeBinding.SHANGHAI module.exports.SpecId = nativeBinding.SpecId -module.exports.SPURIOUS_DRAGON = nativeBinding.SPURIOUS_DRAGON module.exports.StackTraceEntryType = nativeBinding.StackTraceEntryType module.exports.stackTraceEntryTypeToString = nativeBinding.stackTraceEntryTypeToString module.exports.SuccessReason = nativeBinding.SuccessReason -module.exports.TANGERINE = nativeBinding.TANGERINE module.exports.TestStatus = nativeBinding.TestStatus module.exports.UNKNOWN_FUNCTION_NAME = nativeBinding.UNKNOWN_FUNCTION_NAME module.exports.UNRECOGNIZED_CONTRACT_NAME = nativeBinding.UNRECOGNIZED_CONTRACT_NAME diff --git a/crates/edr_napi/src/chains/l1.rs b/crates/edr_napi/src/chains/l1.rs index 69352e9cf3..22c1a7ed12 100644 --- a/crates/edr_napi/src/chains/l1.rs +++ b/crates/edr_napi/src/chains/l1.rs @@ -98,18 +98,6 @@ pub fn l1_provider_factory() -> ProviderFactory { #[napi] #[derive(PartialEq, Eq, PartialOrd, Ord)] pub enum SpecId { - /// Frontier - Frontier = 0, - /// Frontier Thawing - FrontierThawing = 1, - /// Homestead - Homestead = 2, - /// DAO Fork - DaoFork = 3, - /// Tangerine - Tangerine = 4, - /// Spurious Dragon - SpuriousDragon = 5, /// Byzantium Byzantium = 6, /// Constantinople @@ -147,12 +135,6 @@ impl FromStr for SpecId { fn from_str(s: &str) -> Result { match s { - edr_chain_l1::chains::name::FRONTIER => Ok(SpecId::Frontier), - edr_chain_l1::chains::name::FRONTIER_THAWING => Ok(SpecId::FrontierThawing), - edr_chain_l1::chains::name::HOMESTEAD => Ok(SpecId::Homestead), - edr_chain_l1::chains::name::DAO_FORK => Ok(SpecId::DaoFork), - edr_chain_l1::chains::name::TANGERINE => Ok(SpecId::Tangerine), - edr_chain_l1::chains::name::SPURIOUS_DRAGON => Ok(SpecId::SpuriousDragon), edr_chain_l1::chains::name::BYZANTIUM => Ok(SpecId::Byzantium), edr_chain_l1::chains::name::CONSTANTINOPLE => Ok(SpecId::Constantinople), edr_chain_l1::chains::name::PETERSBURG => Ok(SpecId::Petersburg), @@ -179,12 +161,6 @@ impl FromStr for SpecId { impl From for edr_chain_l1::Hardfork { fn from(value: SpecId) -> Self { match value { - SpecId::Frontier => edr_chain_l1::Hardfork::Frontier, - SpecId::FrontierThawing => edr_chain_l1::Hardfork::FrontierThawing, - SpecId::Homestead => edr_chain_l1::Hardfork::Homestead, - SpecId::DaoFork => edr_chain_l1::Hardfork::DaoFork, - SpecId::Tangerine => edr_chain_l1::Hardfork::Tangerine, - SpecId::SpuriousDragon => edr_chain_l1::Hardfork::SpuriousDragon, SpecId::Byzantium => edr_chain_l1::Hardfork::Byzantium, SpecId::Constantinople => edr_chain_l1::Hardfork::Constantinople, SpecId::Petersburg => edr_chain_l1::Hardfork::Petersburg, @@ -215,12 +191,6 @@ pub fn l1_hardfork_from_string(hardfork: String) -> napi::Result { #[napi(catch_unwind)] pub fn l1_hardfork_to_string(hardfork: SpecId) -> &'static str { match hardfork { - SpecId::Frontier => edr_chain_l1::chains::name::FRONTIER, - SpecId::FrontierThawing => edr_chain_l1::chains::name::FRONTIER_THAWING, - SpecId::Homestead => edr_chain_l1::chains::name::HOMESTEAD, - SpecId::DaoFork => edr_chain_l1::chains::name::DAO_FORK, - SpecId::Tangerine => edr_chain_l1::chains::name::TANGERINE, - SpecId::SpuriousDragon => edr_chain_l1::chains::name::SPURIOUS_DRAGON, SpecId::Byzantium => edr_chain_l1::chains::name::BYZANTIUM, SpecId::Constantinople => edr_chain_l1::chains::name::CONSTANTINOPLE, SpecId::Petersburg => edr_chain_l1::chains::name::PETERSBURG, @@ -257,12 +227,6 @@ macro_rules! export_spec_id { } export_spec_id!( - FRONTIER, - FRONTIER_THAWING, - HOMESTEAD, - DAO_FORK, - TANGERINE, - SPURIOUS_DRAGON, BYZANTIUM, CONSTANTINOPLE, PETERSBURG, diff --git a/crates/eips/1559/src/lib.rs b/crates/eips/1559/src/lib.rs index 2e318218ff..9b280c7ee5 100644 --- a/crates/eips/1559/src/lib.rs +++ b/crates/eips/1559/src/lib.rs @@ -151,7 +151,7 @@ mod tests { fn base_fee_params_constant_at_condition_returns_constant_value() { let base_fee_params = BaseFeeParams::Constant(LONDON_PARAMS); assert_eq!( - base_fee_params.at_condition(Hardfork::Frontier, 0), + base_fee_params.at_condition(Hardfork::Byzantium, 0), Some(&LONDON_PARAMS) ); assert_eq!( @@ -173,8 +173,8 @@ mod tests { let base_fee_params = BaseFeeParams::Dynamic(variable_base_fee_params.clone()); assert_eq!( - base_fee_params.at_condition(Hardfork::Frontier, 0), - variable_base_fee_params.at_condition(Hardfork::Frontier, 0) + base_fee_params.at_condition(Hardfork::Byzantium, 0), + variable_base_fee_params.at_condition(Hardfork::Byzantium, 0) ); assert_eq!( base_fee_params.at_condition(Hardfork::London, LONDON_ACTIVATION), From e3f152b86c71b053977d94da3d1ee3070362c73c Mon Sep 17 00:00:00 2001 From: Ana Perez Ghiglia Date: Thu, 20 Aug 2026 23:25:31 +0000 Subject: [PATCH 02/10] change Hardfork constants to match HH definition --- .changeset/wise-falcons-relate.md | 7 +++++ crates/edr_chain_l1/src/hardfork.rs | 44 ++++++++++++++--------------- crates/edr_op/src/hardfork.rs | 28 +++++++++--------- 3 files changed, 44 insertions(+), 35 deletions(-) create mode 100644 .changeset/wise-falcons-relate.md diff --git a/.changeset/wise-falcons-relate.md b/.changeset/wise-falcons-relate.md new file mode 100644 index 0000000000..7717180c5a --- /dev/null +++ b/.changeset/wise-falcons-relate.md @@ -0,0 +1,7 @@ +--- +"@nomicfoundation/edr": minor +--- + +Renamed the hardfork name strings to match Hardhat's definitions: L1 names are now camelCase (e.g. `"byzantium"`, `"muirGlacier"`, `"arrowGlacier"`) and OP names lowercase (e.g. `"bedrock"`, `"isthmus"`). `l1HardforkToString`/`opHardforkToString` return the new names, `l1HardforkFromString`/`opHardforkFromString` and provider configs accept only them, and the exported string constants (`BYZANTIUM`, …, `AMSTERDAM` and `BEDROCK`, …, `INTEROP`) now hold the new values. + +Passing an old-style name (e.g. `"Byzantium"`, `"Arrow Glacier"`) now throws `The provided hardfork \`\` is not supported.` diff --git a/crates/edr_chain_l1/src/hardfork.rs b/crates/edr_chain_l1/src/hardfork.rs index f4109a5047..12bb09b38b 100644 --- a/crates/edr_chain_l1/src/hardfork.rs +++ b/crates/edr_chain_l1/src/hardfork.rs @@ -8,8 +8,8 @@ use edr_primitives::UnknownHardfork; /// Models protocol upgrades, including ones without EVM-semantics changes, /// unlike [`EvmSpecId`] which models EVM behavior classes. /// -/// The `strum(serialize = …)` strings must stay identical to the [`name`] -/// module constants. +/// The strum-derived names (`serialize_all = "camelCase"`) must stay identical +/// to the [`name`] module constants. #[repr(u8)] #[derive( Clone, @@ -25,7 +25,7 @@ use edr_primitives::UnknownHardfork; strum::EnumString, strum::IntoStaticStr, )] -#[strum(parse_err_ty = UnknownHardfork, parse_err_fn = unknown_hardfork)] +#[strum(serialize_all = "camelCase", parse_err_ty = UnknownHardfork, parse_err_fn = unknown_hardfork)] pub enum L1Hardfork { /// Byzantium hardfork Byzantium = 6, @@ -42,10 +42,8 @@ pub enum L1Hardfork { /// London hardfork London, /// Arrow Glacier hardfork - #[strum(serialize = "Arrow Glacier")] ArrowGlacier, /// Gray Glacier hardfork - #[strum(serialize = "Gray Glacier")] GrayGlacier, /// Paris/Merge hardfork Merge, @@ -91,37 +89,37 @@ impl From for EvmSpecId { /// String identifiers for L1 hardforks. pub mod name { /// String identifier for the Byzantium hardfork - pub const BYZANTIUM: &str = "Byzantium"; + pub const BYZANTIUM: &str = "byzantium"; /// String identifier for the Constantinople hardfork - pub const CONSTANTINOPLE: &str = "Constantinople"; + pub const CONSTANTINOPLE: &str = "constantinople"; /// String identifier for the Petersburg hardfork - pub const PETERSBURG: &str = "Petersburg"; + pub const PETERSBURG: &str = "petersburg"; /// String identifier for the Istanbul hardfork - pub const ISTANBUL: &str = "Istanbul"; + pub const ISTANBUL: &str = "istanbul"; /// String identifier for the Muir Glacier hardfork - pub const MUIR_GLACIER: &str = "MuirGlacier"; + pub const MUIR_GLACIER: &str = "muirGlacier"; /// String identifier for the Berlin hardfork - pub const BERLIN: &str = "Berlin"; + pub const BERLIN: &str = "berlin"; /// String identifier for the London hardfork - pub const LONDON: &str = "London"; + pub const LONDON: &str = "london"; /// String identifier for the Arrow Glacier hardfork - pub const ARROW_GLACIER: &str = "Arrow Glacier"; + pub const ARROW_GLACIER: &str = "arrowGlacier"; /// String identifier for the Gray Glacier hardfork - pub const GRAY_GLACIER: &str = "Gray Glacier"; + pub const GRAY_GLACIER: &str = "grayGlacier"; /// String identifier for the Paris/Merge hardfork - pub const MERGE: &str = "Merge"; + pub const MERGE: &str = "merge"; /// String identifier for the Shanghai hardfork - pub const SHANGHAI: &str = "Shanghai"; + pub const SHANGHAI: &str = "shanghai"; /// String identifier for the Cancun hardfork - pub const CANCUN: &str = "Cancun"; + pub const CANCUN: &str = "cancun"; /// String identifier for the Prague hardfork - pub const PRAGUE: &str = "Prague"; + pub const PRAGUE: &str = "prague"; /// String identifier for the Osaka hardfork - pub const OSAKA: &str = "Osaka"; + pub const OSAKA: &str = "osaka"; /// String identifier for the Amsterdam hardfork - pub const AMSTERDAM: &str = "Amsterdam"; + pub const AMSTERDAM: &str = "amsterdam"; /// String identifier for the latest hardfork - pub const LATEST: &str = "Latest"; + pub const LATEST: &str = "latest"; } #[cfg(test)] @@ -183,10 +181,12 @@ mod tests { assert_eq!(L1Hardfork::from_str(name), Ok(hardfork)); } - assert_eq!(L1Hardfork::from_str("Latest"), Err(UnknownHardfork)); + assert_eq!(L1Hardfork::from_str("latest"), Err(UnknownHardfork)); assert_eq!(L1Hardfork::from_str("NotAHardfork"), Err(UnknownHardfork)); // strum must not fall back to parsing variant identifiers. assert_eq!(L1Hardfork::from_str("MUIR_GLACIER"), Err(UnknownHardfork)); + // The pre-Hardhat-alignment names must no longer parse. + assert_eq!(L1Hardfork::from_str("MuirGlacier"), Err(UnknownHardfork)); } #[test] diff --git a/crates/edr_op/src/hardfork.rs b/crates/edr_op/src/hardfork.rs index 7a3bd39d69..58a7461a95 100644 --- a/crates/edr_op/src/hardfork.rs +++ b/crates/edr_op/src/hardfork.rs @@ -17,8 +17,8 @@ pub mod op; /// Models protocol upgrades, including ones without EVM-semantics changes, /// unlike [`op_revm::OpSpecId`] which models EVM behavior classes. /// -/// The `strum(serialize = …)` strings must stay identical to the [`name`] -/// module constants. +/// The strum-derived names (`serialize_all = "camelCase"`) must stay identical +/// to the [`name`] module constants. #[repr(u8)] #[derive( Clone, @@ -34,7 +34,7 @@ pub mod op; strum::EnumString, strum::IntoStaticStr, )] -#[strum(parse_err_ty = UnknownHardfork, parse_err_fn = unknown_hardfork)] +#[strum(serialize_all = "camelCase", parse_err_ty = UnknownHardfork, parse_err_fn = unknown_hardfork)] pub enum OpHardfork { /// Bedrock hardfork Bedrock = 100, @@ -89,25 +89,25 @@ impl From for EvmSpecId { /// String identifiers for OP hardforks. pub mod name { /// String identifier for the Bedrock hardfork - pub const BEDROCK: &str = "Bedrock"; + pub const BEDROCK: &str = "bedrock"; /// String identifier for the Regolith hardfork - pub const REGOLITH: &str = "Regolith"; + pub const REGOLITH: &str = "regolith"; /// String identifier for the Canyon hardfork - pub const CANYON: &str = "Canyon"; + pub const CANYON: &str = "canyon"; /// String identifier for the Ecotone hardfork - pub const ECOTONE: &str = "Ecotone"; + pub const ECOTONE: &str = "ecotone"; /// String identifier for the Fjord hardfork - pub const FJORD: &str = "Fjord"; + pub const FJORD: &str = "fjord"; /// String identifier for the Granite hardfork - pub const GRANITE: &str = "Granite"; + pub const GRANITE: &str = "granite"; /// String identifier for the Holocene hardfork - pub const HOLOCENE: &str = "Holocene"; + pub const HOLOCENE: &str = "holocene"; /// String identifier for the Isthmus hardfork - pub const ISTHMUS: &str = "Isthmus"; + pub const ISTHMUS: &str = "isthmus"; /// String identifier for the Jovian hardfork - pub const JOVIAN: &str = "Jovian"; + pub const JOVIAN: &str = "jovian"; /// String identifier for the Interop hardfork - pub const INTEROP: &str = "Interop"; + pub const INTEROP: &str = "interop"; } /// Returns the chain configurations for OP chains. @@ -193,6 +193,8 @@ mod tests { assert_eq!(OpHardfork::from_str("NotAHardfork"), Err(UnknownHardfork)); // strum must not fall back to parsing variant identifiers. assert_eq!(OpHardfork::from_str("BEDROCK"), Err(UnknownHardfork)); + // The pre-Hardhat-alignment names must no longer parse. + assert_eq!(OpHardfork::from_str("Bedrock"), Err(UnknownHardfork)); } #[test] From 58768cb2d7d32e74f3f1488a4b8a8401d620c92d Mon Sep 17 00:00:00 2001 From: Ana Perez Ghiglia Date: Fri, 21 Aug 2026 16:31:44 +0000 Subject: [PATCH 03/10] drop hardfork names form TS API --- .changeset/wise-falcons-relate.md | 4 +- crates/edr_chain_l1/src/chains.rs | 1 - crates/edr_chain_l1/src/hardfork.rs | 76 ++++------------ crates/edr_napi/index.d.ts | 48 +--------- crates/edr_napi/index.js | 23 ----- crates/edr_napi/src/chains/l1.rs | 136 +++++++++++++++------------- crates/edr_napi/src/chains/op.rs | 97 ++++++++++++-------- crates/edr_napi/test/gasReport.ts | 5 +- crates/edr_napi/test/hardforks.ts | 7 +- crates/edr_napi/test/logs.ts | 5 +- crates/edr_op/src/hardfork.rs | 46 ++-------- 11 files changed, 169 insertions(+), 279 deletions(-) diff --git a/.changeset/wise-falcons-relate.md b/.changeset/wise-falcons-relate.md index 7717180c5a..7ff876c998 100644 --- a/.changeset/wise-falcons-relate.md +++ b/.changeset/wise-falcons-relate.md @@ -2,6 +2,6 @@ "@nomicfoundation/edr": minor --- -Renamed the hardfork name strings to match Hardhat's definitions: L1 names are now camelCase (e.g. `"byzantium"`, `"muirGlacier"`, `"arrowGlacier"`) and OP names lowercase (e.g. `"bedrock"`, `"isthmus"`). `l1HardforkToString`/`opHardforkToString` return the new names, `l1HardforkFromString`/`opHardforkFromString` and provider configs accept only them, and the exported string constants (`BYZANTIUM`, …, `AMSTERDAM` and `BEDROCK`, …, `INTEROP`) now hold the new values. +Renamed the hardfork name strings to match Hardhat's definitions: names are now camelCase (e.g. `"byzantium"`, `"muirGlacier"`, `"bedrock"`). `l1HardforkToString`/`opHardforkToString` return the new names, and `l1HardforkFromString`/`opHardforkFromString` and provider configs accept only them — passing an old-style name (e.g. `"Byzantium"`) fails. -Passing an old-style name (e.g. `"Byzantium"`, `"Arrow Glacier"`) now throws `The provided hardfork \`\` is not supported.` +The exported hardfork name string constants (`BYZANTIUM`, …, `AMSTERDAM` and `BEDROCK`, …, `ISTHMUS`) were removed; convert from the enum instead, e.g. replace `OSAKA` with `l1HardforkToString(SpecId.Osaka)`. (Note that `SpecId` is a numeric enum, so `SpecId.Osaka.toString()` yields `"19"`, not the name.) diff --git a/crates/edr_chain_l1/src/chains.rs b/crates/edr_chain_l1/src/chains.rs index bad43dde3f..1f19c374ce 100644 --- a/crates/edr_chain_l1/src/chains.rs +++ b/crates/edr_chain_l1/src/chains.rs @@ -6,7 +6,6 @@ use edr_chain_config::{ChainConfig, ForkCondition, HardforkActivation}; use edr_eip7892::ScheduledBlobParams; use edr_primitives::HashMap; -pub use crate::hardfork::name; use crate::{Hardfork, L1_BASE_FEE_PARAMS}; /// Mainnet chain ID diff --git a/crates/edr_chain_l1/src/hardfork.rs b/crates/edr_chain_l1/src/hardfork.rs index 12bb09b38b..073fa112fb 100644 --- a/crates/edr_chain_l1/src/hardfork.rs +++ b/crates/edr_chain_l1/src/hardfork.rs @@ -8,8 +8,8 @@ use edr_primitives::UnknownHardfork; /// Models protocol upgrades, including ones without EVM-semantics changes, /// unlike [`EvmSpecId`] which models EVM behavior classes. /// -/// The strum-derived names (`serialize_all = "camelCase"`) must stay identical -/// to the [`name`] module constants. +/// The strum-derived names (`serialize_all = "camelCase"`) are public API; +/// the expected strings are pinned in this module's tests. #[repr(u8)] #[derive( Clone, @@ -86,42 +86,6 @@ impl From for EvmSpecId { } } -/// String identifiers for L1 hardforks. -pub mod name { - /// String identifier for the Byzantium hardfork - pub const BYZANTIUM: &str = "byzantium"; - /// String identifier for the Constantinople hardfork - pub const CONSTANTINOPLE: &str = "constantinople"; - /// String identifier for the Petersburg hardfork - pub const PETERSBURG: &str = "petersburg"; - /// String identifier for the Istanbul hardfork - pub const ISTANBUL: &str = "istanbul"; - /// String identifier for the Muir Glacier hardfork - pub const MUIR_GLACIER: &str = "muirGlacier"; - /// String identifier for the Berlin hardfork - pub const BERLIN: &str = "berlin"; - /// String identifier for the London hardfork - pub const LONDON: &str = "london"; - /// String identifier for the Arrow Glacier hardfork - pub const ARROW_GLACIER: &str = "arrowGlacier"; - /// String identifier for the Gray Glacier hardfork - pub const GRAY_GLACIER: &str = "grayGlacier"; - /// String identifier for the Paris/Merge hardfork - pub const MERGE: &str = "merge"; - /// String identifier for the Shanghai hardfork - pub const SHANGHAI: &str = "shanghai"; - /// String identifier for the Cancun hardfork - pub const CANCUN: &str = "cancun"; - /// String identifier for the Prague hardfork - pub const PRAGUE: &str = "prague"; - /// String identifier for the Osaka hardfork - pub const OSAKA: &str = "osaka"; - /// String identifier for the Amsterdam hardfork - pub const AMSTERDAM: &str = "amsterdam"; - /// String identifier for the latest hardfork - pub const LATEST: &str = "latest"; -} - #[cfg(test)] mod tests { use core::str::FromStr; @@ -153,24 +117,24 @@ mod tests { } } - /// The strings the `strum` derives emit/parse must stay in sync with the - /// [`name`] module constants, which are re-exported as public API. + /// The public hardfork name strings. Changing one is a breaking change + /// for consumers. const NAMES: [&str; 15] = [ - name::BYZANTIUM, - name::CONSTANTINOPLE, - name::PETERSBURG, - name::ISTANBUL, - name::MUIR_GLACIER, - name::BERLIN, - name::LONDON, - name::ARROW_GLACIER, - name::GRAY_GLACIER, - name::MERGE, - name::SHANGHAI, - name::CANCUN, - name::PRAGUE, - name::OSAKA, - name::AMSTERDAM, + "byzantium", + "constantinople", + "petersburg", + "istanbul", + "muirGlacier", + "berlin", + "london", + "arrowGlacier", + "grayGlacier", + "merge", + "shanghai", + "cancun", + "prague", + "osaka", + "amsterdam", ]; #[test] @@ -185,7 +149,7 @@ mod tests { assert_eq!(L1Hardfork::from_str("NotAHardfork"), Err(UnknownHardfork)); // strum must not fall back to parsing variant identifiers. assert_eq!(L1Hardfork::from_str("MUIR_GLACIER"), Err(UnknownHardfork)); - // The pre-Hardhat-alignment names must no longer parse. + // Former (PascalCase) names must no longer parse. assert_eq!(L1Hardfork::from_str("MuirGlacier"), Err(UnknownHardfork)); } diff --git a/crates/edr_napi/index.d.ts b/crates/edr_napi/index.d.ts index 20b10665d2..4c6193d07e 100644 --- a/crates/edr_napi/index.d.ts +++ b/crates/edr_napi/index.d.ts @@ -192,10 +192,6 @@ export interface AddressLabel { */ export declare function addStatementCoverageInstrumentation(sourceCode: string, sourceId: string, solidityVersion: string): InstrumentationResult -export const AMSTERDAM: string - -export const ARROW_GLACIER: string - /** A compilation artifact. */ export interface Artifact { /** The identifier of the artifact. */ @@ -247,10 +243,6 @@ export interface BaseFeeParamActivation { elasticityMultiplier: bigint } -export const BEDROCK: string - -export const BERLIN: string - /** Information about the blob gas used in a block. */ export interface BlobGas { /** @@ -278,8 +270,6 @@ export interface BuildInfoAndOutput { output: Uint8Array } -export const BYZANTIUM: string - /** What chains to cache */ export declare enum CachedChains { /** Cache all chains */ @@ -375,10 +365,6 @@ export interface CallTrace { children: Array } -export const CANCUN: string - -export const CANYON: string - /** Specification of a chain with possible overrides. */ export interface ChainOverride { /** The chain ID */ @@ -440,8 +426,6 @@ export declare enum CollectStackTraces { OnFailure = 1 } -export const CONSTANTINOPLE: string - export const CONSTRUCTOR_FUNCTION_NAME: string export interface ContractCallRunOutOfGasError { @@ -570,8 +554,6 @@ export interface DirectLibraryCallErrorStackTraceEntry { sourceReference: SourceReference } -export const ECOTONE: string - /** * Indicates that the EVM has experienced an exceptional halt. This causes * execution to immediately end with all gas being consumed. @@ -647,8 +629,6 @@ export interface FallbackNotPayableErrorStackTraceEntry { sourceReference: SourceReference } -export const FJORD: string - /** Configuration for forking a blockchain */ export interface ForkConfig { /** @@ -828,10 +808,6 @@ export const GENERIC_CHAIN_TYPE: string export declare function genericChainProviderFactory(): ProviderFactory -export const GRANITE: string - -export const GRAY_GLACIER: string - /** The result when the EVM terminates due to an exceptional halt. */ export interface HaltResult { /** The exceptional halt that occurred */ @@ -872,8 +848,6 @@ export interface HeuristicFailed { kind: "HeuristicFailed" } -export const HOLOCENE: string - export interface HttpHeader { name: string value: string @@ -1183,10 +1157,6 @@ export interface InvariantTestKind { readonly failedCorpusReplays: bigint } -export const ISTANBUL: string - -export const ISTHMUS: string - /** * Computes the Keccak-256 hash of `data`, returning the 32-byte digest. * @@ -1272,15 +1242,11 @@ export interface LogTrace { parameters: DecodedTraceParameters | Array } -export const LONDON: string - /** Configuration for the provider's mempool. */ export interface MemPoolConfig { order: MineOrdering } -export const MERGE: string - /** The type of ordering to use when selecting blocks to mine. */ export declare enum MineOrdering { /** Insertion order */ @@ -1308,8 +1274,6 @@ export interface MissingFallbackOrReceiveErrorStackTraceEntry { sourceReference: SourceReference } -export const MUIR_GLACIER: string - export interface NonContractAccountCalledErrorStackTraceEntry { type: StackTraceEntryType.NONCONTRACT_ACCOUNT_CALLED_ERROR sourceReference: SourceReference @@ -1334,7 +1298,7 @@ export const OP_CHAIN_TYPE: string export declare function opGenesisState(hardfork: OpHardfork): Array -/** Enumeration of supported OP hardforks. */ +/** Identifier for the OP hardfork. */ export declare enum OpHardfork { Bedrock = 100, Regolith = 101, @@ -1368,8 +1332,6 @@ export declare function opProviderFactory(): ProviderFactory export declare function opSolidityTestRunnerFactory(): SolidityTestRunnerFactory -export const OSAKA: string - export interface OtherExecutionErrorStackTraceEntry { type: StackTraceEntryType.OTHER_EXECUTION_ERROR sourceReference?: SourceReference @@ -1389,10 +1351,6 @@ export interface PathPermission { path: string } -export const PETERSBURG: string - -export const PRAGUE: string - export const PRECOMPILE_FUNCTION_NAME: string export interface PrecompileErrorStackTraceEntry { @@ -1490,8 +1448,6 @@ export interface ProviderConfig { export const RECEIVE_FUNCTION_NAME: string -export const REGOLITH: string - export interface ReturndataSizeErrorStackTraceEntry { type: StackTraceEntryType.RETURNDATA_SIZE_ERROR sourceReference: SourceReference @@ -1514,8 +1470,6 @@ export interface RevertResult { output: Uint8Array } -export const SHANGHAI: string - export type SolidityStackTrace = Array diff --git a/crates/edr_napi/index.js b/crates/edr_napi/index.js index 196f58c7d9..6fad2e5d81 100644 --- a/crates/edr_napi/index.js +++ b/crates/edr_napi/index.js @@ -713,38 +713,23 @@ module.exports.ReturnData = nativeBinding.ReturnData module.exports.SolidityTestRunnerFactory = nativeBinding.SolidityTestRunnerFactory module.exports.TestResult = nativeBinding.TestResult module.exports.addStatementCoverageInstrumentation = nativeBinding.addStatementCoverageInstrumentation -module.exports.AMSTERDAM = nativeBinding.AMSTERDAM -module.exports.ARROW_GLACIER = nativeBinding.ARROW_GLACIER -module.exports.BEDROCK = nativeBinding.BEDROCK -module.exports.BERLIN = nativeBinding.BERLIN -module.exports.BYZANTIUM = nativeBinding.BYZANTIUM module.exports.CachedChains = nativeBinding.CachedChains module.exports.CachedEndpoints = nativeBinding.CachedEndpoints module.exports.CallKind = nativeBinding.CallKind -module.exports.CANCUN = nativeBinding.CANCUN -module.exports.CANYON = nativeBinding.CANYON module.exports.CheatcodeErrorCode = nativeBinding.CheatcodeErrorCode module.exports.CollectStackTraces = nativeBinding.CollectStackTraces -module.exports.CONSTANTINOPLE = nativeBinding.CONSTANTINOPLE module.exports.CONSTRUCTOR_FUNCTION_NAME = nativeBinding.CONSTRUCTOR_FUNCTION_NAME module.exports.ContractFunctionType = nativeBinding.ContractFunctionType module.exports.COVERAGE_LIBRARY_FILE_NAME = nativeBinding.COVERAGE_LIBRARY_FILE_NAME -module.exports.ECOTONE = nativeBinding.ECOTONE module.exports.ExceptionalHalt = nativeBinding.ExceptionalHalt module.exports.ExitCode = nativeBinding.ExitCode module.exports.FALLBACK_FUNCTION_NAME = nativeBinding.FALLBACK_FUNCTION_NAME -module.exports.FJORD = nativeBinding.FJORD module.exports.FsAccessPermission = nativeBinding.FsAccessPermission module.exports.GasEstimationMode = nativeBinding.GasEstimationMode module.exports.GasReportExecutionStatus = nativeBinding.GasReportExecutionStatus module.exports.GENERIC_CHAIN_TYPE = nativeBinding.GENERIC_CHAIN_TYPE module.exports.genericChainProviderFactory = nativeBinding.genericChainProviderFactory -module.exports.GRANITE = nativeBinding.GRANITE -module.exports.GRAY_GLACIER = nativeBinding.GRAY_GLACIER -module.exports.HOLOCENE = nativeBinding.HOLOCENE module.exports.IncludeTraces = nativeBinding.IncludeTraces -module.exports.ISTANBUL = nativeBinding.ISTANBUL -module.exports.ISTHMUS = nativeBinding.ISTHMUS module.exports.keccak256 = nativeBinding.keccak256 module.exports.L1_CHAIN_TYPE = nativeBinding.L1_CHAIN_TYPE module.exports.l1GenesisState = nativeBinding.l1GenesisState @@ -756,10 +741,7 @@ module.exports.l1SolidityTestRunnerFactory = nativeBinding.l1SolidityTestRunnerF module.exports.latestSupportedSolidityVersion = nativeBinding.latestSupportedSolidityVersion module.exports.linkHexStringBytecode = nativeBinding.linkHexStringBytecode module.exports.LogKind = nativeBinding.LogKind -module.exports.LONDON = nativeBinding.LONDON -module.exports.MERGE = nativeBinding.MERGE module.exports.MineOrdering = nativeBinding.MineOrdering -module.exports.MUIR_GLACIER = nativeBinding.MUIR_GLACIER module.exports.OP_CHAIN_TYPE = nativeBinding.OP_CHAIN_TYPE module.exports.opGenesisState = nativeBinding.opGenesisState module.exports.OpHardfork = nativeBinding.OpHardfork @@ -768,15 +750,10 @@ module.exports.opHardforkToString = nativeBinding.opHardforkToString module.exports.opLatestHardfork = nativeBinding.opLatestHardfork module.exports.opProviderFactory = nativeBinding.opProviderFactory module.exports.opSolidityTestRunnerFactory = nativeBinding.opSolidityTestRunnerFactory -module.exports.OSAKA = nativeBinding.OSAKA -module.exports.PETERSBURG = nativeBinding.PETERSBURG -module.exports.PRAGUE = nativeBinding.PRAGUE module.exports.PRECOMPILE_FUNCTION_NAME = nativeBinding.PRECOMPILE_FUNCTION_NAME module.exports.precompileP256Verify = nativeBinding.precompileP256Verify module.exports.printStackTrace = nativeBinding.printStackTrace module.exports.RECEIVE_FUNCTION_NAME = nativeBinding.RECEIVE_FUNCTION_NAME -module.exports.REGOLITH = nativeBinding.REGOLITH -module.exports.SHANGHAI = nativeBinding.SHANGHAI module.exports.SpecId = nativeBinding.SpecId module.exports.StackTraceEntryType = nativeBinding.StackTraceEntryType module.exports.stackTraceEntryTypeToString = nativeBinding.stackTraceEntryTypeToString diff --git a/crates/edr_napi/src/chains/l1.rs b/crates/edr_napi/src/chains/l1.rs index 22c1a7ed12..8fea09b371 100644 --- a/crates/edr_napi/src/chains/l1.rs +++ b/crates/edr_napi/src/chains/l1.rs @@ -95,8 +95,11 @@ pub fn l1_provider_factory() -> ProviderFactory { } /// Identifier for the Ethereum spec. +// +// N-API projection of [`edr_chain_l1::Hardfork`], which only exists to +// generate the TS enum; string conversions delegate to the domain type. #[napi] -#[derive(PartialEq, Eq, PartialOrd, Ord)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)] pub enum SpecId { /// Byzantium Byzantium = 6, @@ -134,26 +137,41 @@ impl FromStr for SpecId { type Err = napi::Error; fn from_str(s: &str) -> Result { - match s { - edr_chain_l1::chains::name::BYZANTIUM => Ok(SpecId::Byzantium), - edr_chain_l1::chains::name::CONSTANTINOPLE => Ok(SpecId::Constantinople), - edr_chain_l1::chains::name::PETERSBURG => Ok(SpecId::Petersburg), - edr_chain_l1::chains::name::ISTANBUL => Ok(SpecId::Istanbul), - edr_chain_l1::chains::name::MUIR_GLACIER => Ok(SpecId::MuirGlacier), - edr_chain_l1::chains::name::BERLIN => Ok(SpecId::Berlin), - edr_chain_l1::chains::name::LONDON => Ok(SpecId::London), - edr_chain_l1::chains::name::ARROW_GLACIER => Ok(SpecId::ArrowGlacier), - edr_chain_l1::chains::name::GRAY_GLACIER => Ok(SpecId::GrayGlacier), - edr_chain_l1::chains::name::MERGE => Ok(SpecId::Merge), - edr_chain_l1::chains::name::SHANGHAI => Ok(SpecId::Shanghai), - edr_chain_l1::chains::name::CANCUN => Ok(SpecId::Cancun), - edr_chain_l1::chains::name::PRAGUE => Ok(SpecId::Prague), - edr_chain_l1::chains::name::OSAKA => Ok(SpecId::Osaka), - edr_chain_l1::chains::name::AMSTERDAM => Ok(SpecId::Amsterdam), - _ => Err(napi::Error::new( - napi::Status::InvalidArg, - format!("The provided hardfork `{s}` is not supported."), - )), + s.parse::() + .map(SpecId::from) + .map_err(|edr_primitives::UnknownHardfork| { + napi::Error::new( + napi::Status::InvalidArg, + format!("The provided hardfork `{s}` is not supported."), + ) + }) + } +} + +impl From for &'static str { + fn from(value: SpecId) -> Self { + edr_chain_l1::Hardfork::from(value).into() + } +} + +impl From for SpecId { + fn from(value: edr_chain_l1::Hardfork) -> Self { + match value { + edr_chain_l1::Hardfork::Byzantium => SpecId::Byzantium, + edr_chain_l1::Hardfork::Constantinople => SpecId::Constantinople, + edr_chain_l1::Hardfork::Petersburg => SpecId::Petersburg, + edr_chain_l1::Hardfork::Istanbul => SpecId::Istanbul, + edr_chain_l1::Hardfork::MuirGlacier => SpecId::MuirGlacier, + edr_chain_l1::Hardfork::Berlin => SpecId::Berlin, + edr_chain_l1::Hardfork::London => SpecId::London, + edr_chain_l1::Hardfork::ArrowGlacier => SpecId::ArrowGlacier, + edr_chain_l1::Hardfork::GrayGlacier => SpecId::GrayGlacier, + edr_chain_l1::Hardfork::Merge => SpecId::Merge, + edr_chain_l1::Hardfork::Shanghai => SpecId::Shanghai, + edr_chain_l1::Hardfork::Cancun => SpecId::Cancun, + edr_chain_l1::Hardfork::Prague => SpecId::Prague, + edr_chain_l1::Hardfork::Osaka => SpecId::Osaka, + edr_chain_l1::Hardfork::Amsterdam => SpecId::Amsterdam, } } } @@ -190,23 +208,7 @@ pub fn l1_hardfork_from_string(hardfork: String) -> napi::Result { #[napi(catch_unwind)] pub fn l1_hardfork_to_string(hardfork: SpecId) -> &'static str { - match hardfork { - SpecId::Byzantium => edr_chain_l1::chains::name::BYZANTIUM, - SpecId::Constantinople => edr_chain_l1::chains::name::CONSTANTINOPLE, - SpecId::Petersburg => edr_chain_l1::chains::name::PETERSBURG, - SpecId::Istanbul => edr_chain_l1::chains::name::ISTANBUL, - SpecId::MuirGlacier => edr_chain_l1::chains::name::MUIR_GLACIER, - SpecId::Berlin => edr_chain_l1::chains::name::BERLIN, - SpecId::London => edr_chain_l1::chains::name::LONDON, - SpecId::ArrowGlacier => edr_chain_l1::chains::name::ARROW_GLACIER, - SpecId::GrayGlacier => edr_chain_l1::chains::name::GRAY_GLACIER, - SpecId::Merge => edr_chain_l1::chains::name::MERGE, - SpecId::Shanghai => edr_chain_l1::chains::name::SHANGHAI, - SpecId::Cancun => edr_chain_l1::chains::name::CANCUN, - SpecId::Prague => edr_chain_l1::chains::name::PRAGUE, - SpecId::Osaka => edr_chain_l1::chains::name::OSAKA, - SpecId::Amsterdam => edr_chain_l1::chains::name::AMSTERDAM, - } + hardfork.into() } /// Returns the latest supported OP hardfork. @@ -217,29 +219,37 @@ pub fn l1_hardfork_latest() -> SpecId { SpecId::Osaka } -macro_rules! export_spec_id { - ($($variant:ident),*) => { - $( - #[napi] - pub const $variant: &str = edr_chain_l1::chains::name::$variant; - )* - }; +#[cfg(test)] +mod tests { + use super::*; + + const VARIANTS: [SpecId; 15] = [ + SpecId::Byzantium, + SpecId::Constantinople, + SpecId::Petersburg, + SpecId::Istanbul, + SpecId::MuirGlacier, + SpecId::Berlin, + SpecId::London, + SpecId::ArrowGlacier, + SpecId::GrayGlacier, + SpecId::Merge, + SpecId::Shanghai, + SpecId::Cancun, + SpecId::Prague, + SpecId::Osaka, + SpecId::Amsterdam, + ]; + + /// The two hand-written `From` conversion tables must be inverses of + /// each other. + #[test] + fn napi_names_parse_as_domain_hardforks() { + for spec_id in VARIANTS { + let name = l1_hardfork_to_string(spec_id); + let hardfork: edr_chain_l1::Hardfork = name.parse().unwrap(); + assert_eq!(edr_chain_l1::Hardfork::from(spec_id), hardfork); + assert_eq!(SpecId::from_str(name).unwrap(), spec_id); + } + } } - -export_spec_id!( - BYZANTIUM, - CONSTANTINOPLE, - PETERSBURG, - ISTANBUL, - MUIR_GLACIER, - BERLIN, - LONDON, - ARROW_GLACIER, - GRAY_GLACIER, - MERGE, - SHANGHAI, - CANCUN, - PRAGUE, - OSAKA, - AMSTERDAM -); diff --git a/crates/edr_napi/src/chains/op.rs b/crates/edr_napi/src/chains/op.rs index 1da343d226..f34181dda2 100644 --- a/crates/edr_napi/src/chains/op.rs +++ b/crates/edr_napi/src/chains/op.rs @@ -56,9 +56,13 @@ impl SyncProviderFactory for OpProviderFactory { } } -/// Enumeration of supported OP hardforks. +/// Identifier for the OP hardfork. +// +// N-API projection of [`edr_op::Hardfork`], which only exists to generate +// the TS enum; string conversions delegate to the domain type. Excludes +// hardforks that are not exposed over N-API yet (Jovian, Interop). #[napi] -#[derive(Clone, Copy)] +#[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum OpHardfork { Bedrock = 100, Regolith = 101, @@ -85,23 +89,37 @@ impl From for edr_op::Hardfork { } } +impl From for &'static str { + fn from(value: OpHardfork) -> Self { + edr_op::Hardfork::from(value).into() + } +} + impl FromStr for OpHardfork { type Err = napi::Error; fn from_str(s: &str) -> Result { - match s { - edr_op::hardfork::name::BEDROCK => Ok(OpHardfork::Bedrock), - edr_op::hardfork::name::REGOLITH => Ok(OpHardfork::Regolith), - edr_op::hardfork::name::CANYON => Ok(OpHardfork::Canyon), - edr_op::hardfork::name::ECOTONE => Ok(OpHardfork::Ecotone), - edr_op::hardfork::name::FJORD => Ok(OpHardfork::Fjord), - edr_op::hardfork::name::GRANITE => Ok(OpHardfork::Granite), - edr_op::hardfork::name::HOLOCENE => Ok(OpHardfork::Holocene), - edr_op::hardfork::name::ISTHMUS => Ok(OpHardfork::Isthmus), - _ => Err(napi::Error::new( + let unsupported = || { + napi::Error::new( napi::Status::InvalidArg, format!("The provided OP hardfork `{s}` is not supported."), - )), + ) + }; + + match s + .parse::() + .map_err(|edr_primitives::UnknownHardfork| unsupported())? + { + edr_op::Hardfork::Bedrock => Ok(OpHardfork::Bedrock), + edr_op::Hardfork::Regolith => Ok(OpHardfork::Regolith), + edr_op::Hardfork::Canyon => Ok(OpHardfork::Canyon), + edr_op::Hardfork::Ecotone => Ok(OpHardfork::Ecotone), + edr_op::Hardfork::Fjord => Ok(OpHardfork::Fjord), + edr_op::Hardfork::Granite => Ok(OpHardfork::Granite), + edr_op::Hardfork::Holocene => Ok(OpHardfork::Holocene), + edr_op::Hardfork::Isthmus => Ok(OpHardfork::Isthmus), + // Not exposed over N-API yet. + edr_op::Hardfork::Jovian | edr_op::Hardfork::Interop => Err(unsupported()), } } } @@ -118,16 +136,7 @@ pub fn op_hardfork_from_string(hardfork: String) -> napi::Result { /// Returns the string representation of the provided OP hardfork. #[napi(catch_unwind)] pub fn op_hardfork_to_string(hardfork: OpHardfork) -> &'static str { - match hardfork { - OpHardfork::Bedrock => edr_op::hardfork::name::BEDROCK, - OpHardfork::Regolith => edr_op::hardfork::name::REGOLITH, - OpHardfork::Canyon => edr_op::hardfork::name::CANYON, - OpHardfork::Ecotone => edr_op::hardfork::name::ECOTONE, - OpHardfork::Fjord => edr_op::hardfork::name::FJORD, - OpHardfork::Granite => edr_op::hardfork::name::GRANITE, - OpHardfork::Holocene => edr_op::hardfork::name::HOLOCENE, - OpHardfork::Isthmus => edr_op::hardfork::name::ISTHMUS, - } + hardfork.into() } /// Returns the latest supported OP hardfork. @@ -428,22 +437,30 @@ fn l1_block_code(hardfork: edr_op::Hardfork) -> Uint8Array { } } -macro_rules! export_spec_id { - ($($variant:ident,)*) => { - $( - #[napi] - pub const $variant: &str = edr_op::hardfork::name::$variant; - )* - }; -} +#[cfg(test)] +mod tests { + use super::*; + + const VARIANTS: [OpHardfork; 8] = [ + OpHardfork::Bedrock, + OpHardfork::Regolith, + OpHardfork::Canyon, + OpHardfork::Ecotone, + OpHardfork::Fjord, + OpHardfork::Granite, + OpHardfork::Holocene, + OpHardfork::Isthmus, + ]; -export_spec_id! { - BEDROCK, - REGOLITH, - CANYON, - ECOTONE, - FJORD, - GRANITE, - HOLOCENE, - ISTHMUS, + /// The `From` conversion table and the parse filter must be inverses of + /// each other on the exposed subset. + #[test] + fn napi_names_parse_as_domain_hardforks() { + for napi_hardfork in VARIANTS { + let name = op_hardfork_to_string(napi_hardfork); + let hardfork: edr_op::Hardfork = name.parse().unwrap(); + assert_eq!(edr_op::Hardfork::from(napi_hardfork), hardfork); + assert_eq!(OpHardfork::from_str(name).unwrap(), napi_hardfork); + } + } } diff --git a/crates/edr_napi/test/gasReport.ts b/crates/edr_napi/test/gasReport.ts index 1195988126..8ac1982eda 100644 --- a/crates/edr_napi/test/gasReport.ts +++ b/crates/edr_napi/test/gasReport.ts @@ -10,9 +10,10 @@ import { genericChainProviderFactory, l1GenesisState, l1HardforkFromString, + l1HardforkToString, MineOrdering, Provider, - SHANGHAI, + SpecId, SubscriptionEvent, TracingConfigWithBuffers, } from ".."; @@ -65,7 +66,7 @@ const providerConfig = { ), defaultTransactionGasLimit: 6_000_000n, genesisState, - hardfork: SHANGHAI, + hardfork: l1HardforkToString(SpecId.Shanghai), initialParentBeaconBlockRoot: Uint8Array.from( Buffer.from( "0000000000000000000000000000000000000000000000000000000000000000", diff --git a/crates/edr_napi/test/hardforks.ts b/crates/edr_napi/test/hardforks.ts index e60b084b34..28f5719e55 100644 --- a/crates/edr_napi/test/hardforks.ts +++ b/crates/edr_napi/test/hardforks.ts @@ -2,7 +2,6 @@ import chai, { assert } from "chai"; import chaiAsPromised from "chai-as-promised"; import { - AMSTERDAM, l1HardforkFromString, l1HardforkLatest, l1HardforkToString, @@ -34,13 +33,13 @@ describe("Hardforks", () => { describe("Amsterdam", () => { it("is recognized as a valid hardfork", () => { - assert.equal(l1HardforkFromString(AMSTERDAM), SpecId.Amsterdam); - assert.equal(l1HardforkToString(SpecId.Amsterdam), AMSTERDAM); + assert.equal(l1HardforkFromString("amsterdam"), SpecId.Amsterdam); + assert.equal(l1HardforkToString(SpecId.Amsterdam), "amsterdam"); }); it("can be used to configure a provider", async () => { await assert.isFulfilled( - createGenericProvider(context, { hardfork: AMSTERDAM }) + createGenericProvider(context, { hardfork: "amsterdam" }) ); }); }); diff --git a/crates/edr_napi/test/logs.ts b/crates/edr_napi/test/logs.ts index 39291d3cf2..20ed383b5e 100644 --- a/crates/edr_napi/test/logs.ts +++ b/crates/edr_napi/test/logs.ts @@ -6,11 +6,12 @@ import { ContractDecoder, l1GenesisState, l1HardforkFromString, + l1HardforkToString, MineOrdering, // @ts-ignore MockTime is absent in the testNoBuild (no test-mock) build MockTime, Provider, - SHANGHAI, + SpecId, SubscriptionEvent, } from ".."; import { @@ -226,7 +227,7 @@ const providerConfig = { ), defaultTransactionGasLimit: 6_000_000n, genesisState, - hardfork: SHANGHAI, + hardfork: l1HardforkToString(SpecId.Shanghai), initialParentBeaconBlockRoot: new Uint8Array( Buffer.from( "0000000000000000000000000000000000000000000000000000000000000000", diff --git a/crates/edr_op/src/hardfork.rs b/crates/edr_op/src/hardfork.rs index 58a7461a95..b6c3efdba0 100644 --- a/crates/edr_op/src/hardfork.rs +++ b/crates/edr_op/src/hardfork.rs @@ -17,8 +17,8 @@ pub mod op; /// Models protocol upgrades, including ones without EVM-semantics changes, /// unlike [`op_revm::OpSpecId`] which models EVM behavior classes. /// -/// The strum-derived names (`serialize_all = "camelCase"`) must stay identical -/// to the [`name`] module constants. +/// The strum-derived names (`serialize_all = "camelCase"`) are public API; +/// the expected strings are pinned in this module's tests. #[repr(u8)] #[derive( Clone, @@ -86,30 +86,6 @@ impl From for EvmSpecId { } } -/// String identifiers for OP hardforks. -pub mod name { - /// String identifier for the Bedrock hardfork - pub const BEDROCK: &str = "bedrock"; - /// String identifier for the Regolith hardfork - pub const REGOLITH: &str = "regolith"; - /// String identifier for the Canyon hardfork - pub const CANYON: &str = "canyon"; - /// String identifier for the Ecotone hardfork - pub const ECOTONE: &str = "ecotone"; - /// String identifier for the Fjord hardfork - pub const FJORD: &str = "fjord"; - /// String identifier for the Granite hardfork - pub const GRANITE: &str = "granite"; - /// String identifier for the Holocene hardfork - pub const HOLOCENE: &str = "holocene"; - /// String identifier for the Isthmus hardfork - pub const ISTHMUS: &str = "isthmus"; - /// String identifier for the Jovian hardfork - pub const JOVIAN: &str = "jovian"; - /// String identifier for the Interop hardfork - pub const INTEROP: &str = "interop"; -} - /// Returns the chain configurations for OP chains. pub fn op_chain_configs() -> &'static HashMap> { static CONFIGS: LazyLock>> = LazyLock::new(|| { @@ -167,19 +143,11 @@ mod tests { } } - /// The strings the `strum` derives emit/parse must stay in sync with the - /// [`name`] module constants, which are re-exported as public API. + /// The public hardfork name strings. Changing one is a breaking change + /// for consumers. const NAMES: [&str; 10] = [ - name::BEDROCK, - name::REGOLITH, - name::CANYON, - name::ECOTONE, - name::FJORD, - name::GRANITE, - name::HOLOCENE, - name::ISTHMUS, - name::JOVIAN, - name::INTEROP, + "bedrock", "regolith", "canyon", "ecotone", "fjord", "granite", "holocene", "isthmus", + "jovian", "interop", ]; #[test] @@ -193,7 +161,7 @@ mod tests { assert_eq!(OpHardfork::from_str("NotAHardfork"), Err(UnknownHardfork)); // strum must not fall back to parsing variant identifiers. assert_eq!(OpHardfork::from_str("BEDROCK"), Err(UnknownHardfork)); - // The pre-Hardhat-alignment names must no longer parse. + // Former (PascalCase) names must no longer parse. assert_eq!(OpHardfork::from_str("Bedrock"), Err(UnknownHardfork)); } From 22db77226d69f3d5f4949b4acb518f9f0d2337b9 Mon Sep 17 00:00:00 2001 From: Ana Perez Ghiglia Date: Fri, 21 Aug 2026 16:39:08 +0000 Subject: [PATCH 04/10] rename NAPI SpecId -> L1Hardfork --- .changeset/mighty-poems-tickle.md | 4 +- .changeset/wise-falcons-relate.md | 2 +- crates/edr_napi/index.d.ts | 80 +++++++++---------- crates/edr_napi/index.js | 2 +- crates/edr_napi/src/chains/l1.rs | 128 +++++++++++++++--------------- crates/edr_napi/test/gasReport.ts | 4 +- crates/edr_napi/test/hardforks.ts | 8 +- crates/edr_napi/test/logs.ts | 4 +- crates/edr_napi/test/provider.ts | 8 +- 9 files changed, 119 insertions(+), 121 deletions(-) diff --git a/.changeset/mighty-poems-tickle.md b/.changeset/mighty-poems-tickle.md index 448b0014f3..4fdfa322ab 100644 --- a/.changeset/mighty-poems-tickle.md +++ b/.changeset/mighty-poems-tickle.md @@ -2,8 +2,6 @@ "@nomicfoundation/edr": minor --- -Removed support for pre-Byzantium Ethereum L1 hardforks. The `SpecId` enum no longer includes `Frontier`, `FrontierThawing`, `Homestead`, `DaoFork`, `Tangerine` and `SpuriousDragon`, and the corresponding `FRONTIER`, `FRONTIER_THAWING`, `HOMESTEAD`, `DAO_FORK`, `TANGERINE` and `SPURIOUS_DRAGON` string constants are gone. Discriminants of the remaining variants are unchanged, so `Byzantium` is still `6`. - -Passing one of the removed hardfork names now throws `The provided hardfork \`\` is not supported.` +Renamed the `SpecId` enum to `L1Hardfork`, mirroring `OpHardfork`, and removed support for pre-Byzantium Ethereum L1 hardforks: the enum no longer includes `Frontier`, `FrontierThawing`, `Homestead`, `DaoFork`, `Tangerine` and `SpuriousDragon`. Discriminants of the remaining variants are unchanged, so `Byzantium` is still `6`. Forking a chain from a block that precedes its oldest supported hardfork now fails with an error naming that hardfork, instead of silently skipping hardfork validation. diff --git a/.changeset/wise-falcons-relate.md b/.changeset/wise-falcons-relate.md index 7ff876c998..28c0553eba 100644 --- a/.changeset/wise-falcons-relate.md +++ b/.changeset/wise-falcons-relate.md @@ -4,4 +4,4 @@ Renamed the hardfork name strings to match Hardhat's definitions: names are now camelCase (e.g. `"byzantium"`, `"muirGlacier"`, `"bedrock"`). `l1HardforkToString`/`opHardforkToString` return the new names, and `l1HardforkFromString`/`opHardforkFromString` and provider configs accept only them — passing an old-style name (e.g. `"Byzantium"`) fails. -The exported hardfork name string constants (`BYZANTIUM`, …, `AMSTERDAM` and `BEDROCK`, …, `ISTHMUS`) were removed; convert from the enum instead, e.g. replace `OSAKA` with `l1HardforkToString(SpecId.Osaka)`. (Note that `SpecId` is a numeric enum, so `SpecId.Osaka.toString()` yields `"19"`, not the name.) +The exported hardfork name string constants (`BYZANTIUM`, …, `AMSTERDAM` and `BEDROCK`, …, `ISTHMUS`) were removed; convert from the enum instead, e.g. replace `OSAKA` with `l1HardforkToString(L1Hardfork.Osaka)`. (Note that `L1Hardfork` is a numeric enum, so `L1Hardfork.Osaka.toString()` yields `"19"`, not the name.) diff --git a/crates/edr_napi/index.d.ts b/crates/edr_napi/index.d.ts index 4c6193d07e..68f3dd4a4d 100644 --- a/crates/edr_napi/index.d.ts +++ b/crates/edr_napi/index.d.ts @@ -1168,23 +1168,57 @@ export declare function keccak256(data: Uint8Array): Uint8Array export const L1_CHAIN_TYPE: string -export declare function l1GenesisState(hardfork: SpecId): Array +export declare function l1GenesisState(hardfork: L1Hardfork): Array + +/** Identifier for the Ethereum spec. */ +export declare enum L1Hardfork { + /** Byzantium */ + Byzantium = 6, + /** Constantinople */ + Constantinople = 7, + /** Petersburg */ + Petersburg = 8, + /** Istanbul */ + Istanbul = 9, + /** Muir Glacier */ + MuirGlacier = 10, + /** Berlin */ + Berlin = 11, + /** London */ + London = 12, + /** Arrow Glacier */ + ArrowGlacier = 13, + /** Gray Glacier */ + GrayGlacier = 14, + /** Merge */ + Merge = 15, + /** Shanghai */ + Shanghai = 16, + /** Cancun */ + Cancun = 17, + /** Prague */ + Prague = 18, + /** Osaka */ + Osaka = 19, + /** Amsterdam */ + Amsterdam = 20 +} /** - * Tries to parse the provided string to create a [`SpecId`] instance. + * Tries to parse the provided string to create an [`L1Hardfork`] instance. * * Returns an error if the string does not match any known hardfork. */ -export declare function l1HardforkFromString(hardfork: string): SpecId +export declare function l1HardforkFromString(hardfork: string): L1Hardfork /** - * Returns the latest supported OP hardfork. + * Returns the latest supported L1 hardfork. * * The returned value will be updated after each network upgrade. */ -export declare function l1HardforkLatest(): SpecId +export declare function l1HardforkLatest(): L1Hardfork -export declare function l1HardforkToString(hardfork: SpecId): string +export declare function l1HardforkToString(hardfork: L1Hardfork): string export declare function l1ProviderFactory(): ProviderFactory @@ -1736,40 +1770,6 @@ export interface SourceReference { range: Array } -/** Identifier for the Ethereum spec. */ -export declare enum SpecId { - /** Byzantium */ - Byzantium = 6, - /** Constantinople */ - Constantinople = 7, - /** Petersburg */ - Petersburg = 8, - /** Istanbul */ - Istanbul = 9, - /** Muir Glacier */ - MuirGlacier = 10, - /** Berlin */ - Berlin = 11, - /** London */ - London = 12, - /** Arrow Glacier */ - ArrowGlacier = 13, - /** Gray Glacier */ - GrayGlacier = 14, - /** Merge */ - Merge = 15, - /** Shanghai */ - Shanghai = 16, - /** Cancun */ - Cancun = 17, - /** Prague */ - Prague = 18, - /** Osaka */ - Osaka = 19, - /** Amsterdam */ - Amsterdam = 20 -} - /** The stack trace result */ export interface StackTrace { /** Enum tag for JS. */ diff --git a/crates/edr_napi/index.js b/crates/edr_napi/index.js index 6fad2e5d81..dd902f78dc 100644 --- a/crates/edr_napi/index.js +++ b/crates/edr_napi/index.js @@ -733,6 +733,7 @@ module.exports.IncludeTraces = nativeBinding.IncludeTraces module.exports.keccak256 = nativeBinding.keccak256 module.exports.L1_CHAIN_TYPE = nativeBinding.L1_CHAIN_TYPE module.exports.l1GenesisState = nativeBinding.l1GenesisState +module.exports.L1Hardfork = nativeBinding.L1Hardfork module.exports.l1HardforkFromString = nativeBinding.l1HardforkFromString module.exports.l1HardforkLatest = nativeBinding.l1HardforkLatest module.exports.l1HardforkToString = nativeBinding.l1HardforkToString @@ -754,7 +755,6 @@ module.exports.PRECOMPILE_FUNCTION_NAME = nativeBinding.PRECOMPILE_FUNCTION_NAME module.exports.precompileP256Verify = nativeBinding.precompileP256Verify module.exports.printStackTrace = nativeBinding.printStackTrace module.exports.RECEIVE_FUNCTION_NAME = nativeBinding.RECEIVE_FUNCTION_NAME -module.exports.SpecId = nativeBinding.SpecId module.exports.StackTraceEntryType = nativeBinding.StackTraceEntryType module.exports.stackTraceEntryTypeToString = nativeBinding.stackTraceEntryTypeToString module.exports.SuccessReason = nativeBinding.SuccessReason diff --git a/crates/edr_napi/src/chains/l1.rs b/crates/edr_napi/src/chains/l1.rs index 8fea09b371..4ee4099363 100644 --- a/crates/edr_napi/src/chains/l1.rs +++ b/crates/edr_napi/src/chains/l1.rs @@ -56,7 +56,7 @@ impl SyncProviderFactory for L1ProviderFactory { pub const L1_CHAIN_TYPE: &str = edr_chain_l1::CHAIN_TYPE; #[napi(catch_unwind)] -pub fn l1_genesis_state(hardfork: SpecId) -> Vec { +pub fn l1_genesis_state(hardfork: L1Hardfork) -> Vec { // Use closures for lazy execution let beacon_roots_account_constructor = || AccountOverride { address: Uint8Array::with_data_copied(BEACON_ROOTS_ADDRESS), @@ -76,9 +76,9 @@ pub fn l1_genesis_state(hardfork: SpecId) -> Vec { storage: Some(Vec::new()), }; - if hardfork < SpecId::Cancun { + if hardfork < L1Hardfork::Cancun { Vec::new() - } else if hardfork < SpecId::Prague { + } else if hardfork < L1Hardfork::Prague { vec![beacon_roots_account_constructor()] } else { vec![ @@ -100,7 +100,7 @@ pub fn l1_provider_factory() -> ProviderFactory { // generate the TS enum; string conversions delegate to the domain type. #[napi] #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)] -pub enum SpecId { +pub enum L1Hardfork { /// Byzantium Byzantium = 6, /// Constantinople @@ -133,12 +133,12 @@ pub enum SpecId { Amsterdam = 20, } -impl FromStr for SpecId { +impl FromStr for L1Hardfork { type Err = napi::Error; fn from_str(s: &str) -> Result { s.parse::() - .map(SpecId::from) + .map(L1Hardfork::from) .map_err(|edr_primitives::UnknownHardfork| { napi::Error::new( napi::Status::InvalidArg, @@ -148,97 +148,97 @@ impl FromStr for SpecId { } } -impl From for &'static str { - fn from(value: SpecId) -> Self { +impl From for &'static str { + fn from(value: L1Hardfork) -> Self { edr_chain_l1::Hardfork::from(value).into() } } -impl From for SpecId { +impl From for L1Hardfork { fn from(value: edr_chain_l1::Hardfork) -> Self { match value { - edr_chain_l1::Hardfork::Byzantium => SpecId::Byzantium, - edr_chain_l1::Hardfork::Constantinople => SpecId::Constantinople, - edr_chain_l1::Hardfork::Petersburg => SpecId::Petersburg, - edr_chain_l1::Hardfork::Istanbul => SpecId::Istanbul, - edr_chain_l1::Hardfork::MuirGlacier => SpecId::MuirGlacier, - edr_chain_l1::Hardfork::Berlin => SpecId::Berlin, - edr_chain_l1::Hardfork::London => SpecId::London, - edr_chain_l1::Hardfork::ArrowGlacier => SpecId::ArrowGlacier, - edr_chain_l1::Hardfork::GrayGlacier => SpecId::GrayGlacier, - edr_chain_l1::Hardfork::Merge => SpecId::Merge, - edr_chain_l1::Hardfork::Shanghai => SpecId::Shanghai, - edr_chain_l1::Hardfork::Cancun => SpecId::Cancun, - edr_chain_l1::Hardfork::Prague => SpecId::Prague, - edr_chain_l1::Hardfork::Osaka => SpecId::Osaka, - edr_chain_l1::Hardfork::Amsterdam => SpecId::Amsterdam, + edr_chain_l1::Hardfork::Byzantium => L1Hardfork::Byzantium, + edr_chain_l1::Hardfork::Constantinople => L1Hardfork::Constantinople, + edr_chain_l1::Hardfork::Petersburg => L1Hardfork::Petersburg, + edr_chain_l1::Hardfork::Istanbul => L1Hardfork::Istanbul, + edr_chain_l1::Hardfork::MuirGlacier => L1Hardfork::MuirGlacier, + edr_chain_l1::Hardfork::Berlin => L1Hardfork::Berlin, + edr_chain_l1::Hardfork::London => L1Hardfork::London, + edr_chain_l1::Hardfork::ArrowGlacier => L1Hardfork::ArrowGlacier, + edr_chain_l1::Hardfork::GrayGlacier => L1Hardfork::GrayGlacier, + edr_chain_l1::Hardfork::Merge => L1Hardfork::Merge, + edr_chain_l1::Hardfork::Shanghai => L1Hardfork::Shanghai, + edr_chain_l1::Hardfork::Cancun => L1Hardfork::Cancun, + edr_chain_l1::Hardfork::Prague => L1Hardfork::Prague, + edr_chain_l1::Hardfork::Osaka => L1Hardfork::Osaka, + edr_chain_l1::Hardfork::Amsterdam => L1Hardfork::Amsterdam, } } } -impl From for edr_chain_l1::Hardfork { - fn from(value: SpecId) -> Self { +impl From for edr_chain_l1::Hardfork { + fn from(value: L1Hardfork) -> Self { match value { - SpecId::Byzantium => edr_chain_l1::Hardfork::Byzantium, - SpecId::Constantinople => edr_chain_l1::Hardfork::Constantinople, - SpecId::Petersburg => edr_chain_l1::Hardfork::Petersburg, - SpecId::Istanbul => edr_chain_l1::Hardfork::Istanbul, - SpecId::MuirGlacier => edr_chain_l1::Hardfork::MuirGlacier, - SpecId::Berlin => edr_chain_l1::Hardfork::Berlin, - SpecId::London => edr_chain_l1::Hardfork::London, - SpecId::ArrowGlacier => edr_chain_l1::Hardfork::ArrowGlacier, - SpecId::GrayGlacier => edr_chain_l1::Hardfork::GrayGlacier, - SpecId::Merge => edr_chain_l1::Hardfork::Merge, - SpecId::Shanghai => edr_chain_l1::Hardfork::Shanghai, - SpecId::Cancun => edr_chain_l1::Hardfork::Cancun, - SpecId::Prague => edr_chain_l1::Hardfork::Prague, - SpecId::Osaka => edr_chain_l1::Hardfork::Osaka, - SpecId::Amsterdam => edr_chain_l1::Hardfork::Amsterdam, + L1Hardfork::Byzantium => edr_chain_l1::Hardfork::Byzantium, + L1Hardfork::Constantinople => edr_chain_l1::Hardfork::Constantinople, + L1Hardfork::Petersburg => edr_chain_l1::Hardfork::Petersburg, + L1Hardfork::Istanbul => edr_chain_l1::Hardfork::Istanbul, + L1Hardfork::MuirGlacier => edr_chain_l1::Hardfork::MuirGlacier, + L1Hardfork::Berlin => edr_chain_l1::Hardfork::Berlin, + L1Hardfork::London => edr_chain_l1::Hardfork::London, + L1Hardfork::ArrowGlacier => edr_chain_l1::Hardfork::ArrowGlacier, + L1Hardfork::GrayGlacier => edr_chain_l1::Hardfork::GrayGlacier, + L1Hardfork::Merge => edr_chain_l1::Hardfork::Merge, + L1Hardfork::Shanghai => edr_chain_l1::Hardfork::Shanghai, + L1Hardfork::Cancun => edr_chain_l1::Hardfork::Cancun, + L1Hardfork::Prague => edr_chain_l1::Hardfork::Prague, + L1Hardfork::Osaka => edr_chain_l1::Hardfork::Osaka, + L1Hardfork::Amsterdam => edr_chain_l1::Hardfork::Amsterdam, } } } -/// Tries to parse the provided string to create a [`SpecId`] instance. +/// Tries to parse the provided string to create an [`L1Hardfork`] instance. /// /// Returns an error if the string does not match any known hardfork. #[napi(catch_unwind)] -pub fn l1_hardfork_from_string(hardfork: String) -> napi::Result { +pub fn l1_hardfork_from_string(hardfork: String) -> napi::Result { hardfork.parse() } #[napi(catch_unwind)] -pub fn l1_hardfork_to_string(hardfork: SpecId) -> &'static str { +pub fn l1_hardfork_to_string(hardfork: L1Hardfork) -> &'static str { hardfork.into() } -/// Returns the latest supported OP hardfork. +/// Returns the latest supported L1 hardfork. /// /// The returned value will be updated after each network upgrade. #[napi] -pub fn l1_hardfork_latest() -> SpecId { - SpecId::Osaka +pub fn l1_hardfork_latest() -> L1Hardfork { + L1Hardfork::Osaka } #[cfg(test)] mod tests { use super::*; - const VARIANTS: [SpecId; 15] = [ - SpecId::Byzantium, - SpecId::Constantinople, - SpecId::Petersburg, - SpecId::Istanbul, - SpecId::MuirGlacier, - SpecId::Berlin, - SpecId::London, - SpecId::ArrowGlacier, - SpecId::GrayGlacier, - SpecId::Merge, - SpecId::Shanghai, - SpecId::Cancun, - SpecId::Prague, - SpecId::Osaka, - SpecId::Amsterdam, + const VARIANTS: [L1Hardfork; 15] = [ + L1Hardfork::Byzantium, + L1Hardfork::Constantinople, + L1Hardfork::Petersburg, + L1Hardfork::Istanbul, + L1Hardfork::MuirGlacier, + L1Hardfork::Berlin, + L1Hardfork::London, + L1Hardfork::ArrowGlacier, + L1Hardfork::GrayGlacier, + L1Hardfork::Merge, + L1Hardfork::Shanghai, + L1Hardfork::Cancun, + L1Hardfork::Prague, + L1Hardfork::Osaka, + L1Hardfork::Amsterdam, ]; /// The two hand-written `From` conversion tables must be inverses of @@ -249,7 +249,7 @@ mod tests { let name = l1_hardfork_to_string(spec_id); let hardfork: edr_chain_l1::Hardfork = name.parse().unwrap(); assert_eq!(edr_chain_l1::Hardfork::from(spec_id), hardfork); - assert_eq!(SpecId::from_str(name).unwrap(), spec_id); + assert_eq!(L1Hardfork::from_str(name).unwrap(), spec_id); } } } diff --git a/crates/edr_napi/test/gasReport.ts b/crates/edr_napi/test/gasReport.ts index 8ac1982eda..cbe5daa9c8 100644 --- a/crates/edr_napi/test/gasReport.ts +++ b/crates/edr_napi/test/gasReport.ts @@ -13,7 +13,7 @@ import { l1HardforkToString, MineOrdering, Provider, - SpecId, + L1Hardfork, SubscriptionEvent, TracingConfigWithBuffers, } from ".."; @@ -66,7 +66,7 @@ const providerConfig = { ), defaultTransactionGasLimit: 6_000_000n, genesisState, - hardfork: l1HardforkToString(SpecId.Shanghai), + hardfork: l1HardforkToString(L1Hardfork.Shanghai), initialParentBeaconBlockRoot: Uint8Array.from( Buffer.from( "0000000000000000000000000000000000000000000000000000000000000000", diff --git a/crates/edr_napi/test/hardforks.ts b/crates/edr_napi/test/hardforks.ts index 28f5719e55..7177d6ac9f 100644 --- a/crates/edr_napi/test/hardforks.ts +++ b/crates/edr_napi/test/hardforks.ts @@ -5,7 +5,7 @@ import { l1HardforkFromString, l1HardforkLatest, l1HardforkToString, - SpecId, + L1Hardfork, } from ".."; import { createGenericProvider, @@ -27,14 +27,14 @@ describe("Hardforks", () => { // Amsterdam is exposed for early access, but its support is incomplete, so // it must not become the latest/default hardfork until it is complete and // activated on Ethereum Mainnet. - assert.equal(l1HardforkLatest(), SpecId.Osaka); + assert.equal(l1HardforkLatest(), L1Hardfork.Osaka); }); }); describe("Amsterdam", () => { it("is recognized as a valid hardfork", () => { - assert.equal(l1HardforkFromString("amsterdam"), SpecId.Amsterdam); - assert.equal(l1HardforkToString(SpecId.Amsterdam), "amsterdam"); + assert.equal(l1HardforkFromString("amsterdam"), L1Hardfork.Amsterdam); + assert.equal(l1HardforkToString(L1Hardfork.Amsterdam), "amsterdam"); }); it("can be used to configure a provider", async () => { diff --git a/crates/edr_napi/test/logs.ts b/crates/edr_napi/test/logs.ts index 20ed383b5e..5dd0166e88 100644 --- a/crates/edr_napi/test/logs.ts +++ b/crates/edr_napi/test/logs.ts @@ -11,7 +11,7 @@ import { // @ts-ignore MockTime is absent in the testNoBuild (no test-mock) build MockTime, Provider, - SpecId, + L1Hardfork, SubscriptionEvent, } from ".."; import { @@ -227,7 +227,7 @@ const providerConfig = { ), defaultTransactionGasLimit: 6_000_000n, genesisState, - hardfork: l1HardforkToString(SpecId.Shanghai), + hardfork: l1HardforkToString(L1Hardfork.Shanghai), initialParentBeaconBlockRoot: new Uint8Array( Buffer.from( "0000000000000000000000000000000000000000000000000000000000000000", diff --git a/crates/edr_napi/test/provider.ts b/crates/edr_napi/test/provider.ts index 4dfc5bfbf3..0b85285da9 100644 --- a/crates/edr_napi/test/provider.ts +++ b/crates/edr_napi/test/provider.ts @@ -7,6 +7,7 @@ import { AccountOverride, CallOverrideResult, ContractDecoder, + L1Hardfork, l1HardforkToString, Provider, SubscriptionEvent, @@ -15,7 +16,6 @@ import { opProviderFactory, opHardforkToString, OpHardfork, - SpecId, } from ".."; import { ALCHEMY_URL, @@ -465,7 +465,7 @@ describe("Provider", () => { // the provider itself runs a pre-Osaka hardfork so the precompile is not // available by default. genesisState: fundedGenesisState(), - hardfork: l1HardforkToString(SpecId.Prague), + hardfork: l1HardforkToString(L1Hardfork.Prague), ...(enabled ? { precompileOverrides: [precompileP256Verify()] } : {}), }); @@ -780,8 +780,8 @@ describe("Provider", () => { transactionGasCap: bigint | false | undefined ): Promise { return createGenericProvider(context, { - hardfork: l1HardforkToString(SpecId.Osaka), - genesisState: fundedGenesisState(l1HardforkToString(SpecId.Osaka)), + hardfork: l1HardforkToString(L1Hardfork.Osaka), + genesisState: fundedGenesisState(l1HardforkToString(L1Hardfork.Osaka)), transactionGasCap, }); } From ea9309f3835a7959d895e7c6008f246a00dacffd Mon Sep 17 00:00:00 2001 From: Ana Perez Ghiglia Date: Fri, 21 Aug 2026 19:41:58 +0000 Subject: [PATCH 05/10] Patch Hardhat tests with breaking changes --- patches/hardhat@2.28.4.patch | 264 +++++++++++++++++++++++++++++++++-- patches/hardhat@3.4.5.patch | 199 +++++++++++++++++++++++++- pnpm-lock.yaml | 20 +-- 3 files changed, 463 insertions(+), 20 deletions(-) diff --git a/patches/hardhat@2.28.4.patch b/patches/hardhat@2.28.4.patch index d136c5eafa..20808274c5 100644 --- a/patches/hardhat@2.28.4.patch +++ b/patches/hardhat@2.28.4.patch @@ -311,18 +311,19 @@ index c2bd27290c8ceab5d014a86bd50a891aa24ab07c..623ba6268d5cfaad3ebf463b73880be2 +{"version":3,"file":"provider.js","sourceRoot":"","sources":["../../../src/internal/hardhat-network/provider/provider.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsBA,2CAAoD;AACpD,8CAA6E;AAC7E,4DAAoC;AACpC,kDAA0B;AAC1B,mCAAsC;AACtC,wDAA+B;AAC/B,yCAA2B;AAE3B,qDAA8D;AAC9D,+CAGyB;AACzB,oEAA0E;AAC1E,oFAGwD;AACxD,8DAG6C;AAC7C,0EAA2E;AAC3E,wDAKqC;AACrC,oDAA4D;AAC5D,oDAI8B;AAC9B,iEAA8D;AAC9D,qEAA2E;AAG3E,wDAAwD;AAOxD,uDAQ8B;AAC9B,6CAA4E;AAC5E,gDAA8E;AAE9E,MAAM,GAAG,GAAG,IAAA,eAAK,EAAC,uCAAuC,CAAC,CAAC;AAE3D,+EAA+E;AAElE,QAAA,gBAAgB,GAAG,4CAA4C,CAAC;AAC7E,IAAI,iBAAyC,CAAC;AAE9C,0CAA0C;AACnC,KAAK,UAAU,mBAAmB;IACvC,MAAM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QACxB,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAChD,CAAC;QAEF,YAAY,CAAC,IAAI,CAAC;YAChB,OAAO,EAAE,IAAA,uBAAgB,EAAC,UAAU,CAAC;YACrC,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC;YAChC,IAAI,EAAE,IAAI,UAAU,EAAE,EAAE,sEAAsE;SAC/F,CAAC,CAAC;QAEH,OAAO,OAAO,CAAC,UAAU,CAAC;IAC5B,CAAC,CAAC,CAAC;IAEH,OAAO,CAAC,YAAY,EAAE,aAAa,CAAC,CAAC;AACvC,CAAC"} \ No newline at end of file diff --git a/internal/hardhat-network/provider/utils/convertToEdr.d.ts b/internal/hardhat-network/provider/utils/convertToEdr.d.ts -index 69eebf11f2d8a5847ea74db738007391dde986b7..e91c521e4e420e13520f2114f1595cf0625510ba 100644 +index 69eebf11f2d8a5847ea74db738007391dde986b7..498b0c31286157833577cff91b07917f0a7a6007 100644 --- a/internal/hardhat-network/provider/utils/convertToEdr.d.ts +++ b/internal/hardhat-network/provider/utils/convertToEdr.d.ts @@ -1,13 +1,11 @@ -import type { SpecId, MineOrdering, IntervalRange, DebugTraceResult, TracingMessage, TracingMessageResult, TracingStep, HttpHeader } from "@nomicfoundation/edr"; -+import type { SpecId, MineOrdering, IntervalRange, TracingMessage, TracingMessageResult, TracingStep, HttpHeader } from "@nomicfoundation/edr"; ++import type { L1Hardfork, MineOrdering, IntervalRange, TracingMessage, TracingMessageResult, TracingStep, HttpHeader } from "@nomicfoundation/edr"; import { HardforkName } from "../../../util/hardforks"; import { IntervalMiningConfig, MempoolOrder } from "../node-types"; -import { RpcDebugTraceOutput } from "../output"; import { MinimalEVMResult, MinimalInterpreterStep, MinimalMessage } from "../vm/types"; export declare function ethereumsjsHardforkToEdrSpecId(hardfork: HardforkName): string; - export declare function edrSpecIdToEthereumHardfork(specId: SpecId): HardforkName; +-export declare function edrSpecIdToEthereumHardfork(specId: SpecId): HardforkName; ++export declare function edrSpecIdToEthereumHardfork(specId: L1Hardfork): HardforkName; export declare function ethereumjsIntervalMiningConfigToEdr(config: IntervalMiningConfig): bigint | IntervalRange | undefined; export declare function ethereumjsMempoolOrderToEdrMineOrdering(mempoolOrder: MempoolOrder): MineOrdering; -export declare function edrRpcDebugTraceToHardhat(rpcDebugTrace: DebugTraceResult): RpcDebugTraceOutput; @@ -339,18 +340,119 @@ index 23b0715c04680d560c779a40890217d96f60916f..11771582b3e38226fac624b9e10a7849 +{"version":3,"file":"convertToEdr.d.ts","sourceRoot":"","sources":["../../../../src/internal/hardhat-network/provider/utils/convertToEdr.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,MAAM,EACN,YAAY,EACZ,aAAa,EAEb,cAAc,EACd,oBAAoB,EACpB,WAAW,EACX,UAAU,EACX,MAAM,sBAAsB,CAAC;AAyB9B,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAEnE,OAAO,EACL,gBAAgB,EAChB,sBAAsB,EACtB,cAAc,EACf,MAAM,aAAa,CAAC;AAIrB,wBAAgB,8BAA8B,CAAC,QAAQ,EAAE,YAAY,GAAG,MAAM,CA8C7E;AAED,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,CAgDxE;AAED,wBAAgB,mCAAmC,CACjD,MAAM,EAAE,oBAAoB,GAC3B,MAAM,GAAG,aAAa,GAAG,SAAS,CAcpC;AAED,wBAAgB,uCAAuC,CACrD,YAAY,EAAE,YAAY,GACzB,YAAY,CAWd;AAED,wBAAgB,sCAAsC,CACpD,IAAI,EAAE,WAAW,GAChB,sBAAsB,CAexB;AAED,wBAAgB,yCAAyC,CACvD,oBAAoB,EAAE,oBAAoB,GACzC,gBAAgB,CA+BlB;AAED,wBAAgB,iCAAiC,CAC/C,OAAO,EAAE,cAAc,GACtB,cAAc,CAahB;AAED,wBAAgB,gBAAgB,CAAC,KAAK,CAAC,EAAE;IACvC,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;CACxB,GAAG,UAAU,EAAE,GAAG,SAAS,CAc3B"} \ No newline at end of file diff --git a/internal/hardhat-network/provider/utils/convertToEdr.js b/internal/hardhat-network/provider/utils/convertToEdr.js -index 9f306964d32309a3a72626fd5d522d2066758821..607ded63b8d569231d32202a368f1f6852708ba0 100644 +index 9f306964d32309a3a72626fd5d522d2066758821..53b7bcd1328b2bcf7ca82e2596ef0bc639553010 100644 --- a/internal/hardhat-network/provider/utils/convertToEdr.js +++ b/internal/hardhat-network/provider/utils/convertToEdr.js -@@ -1,6 +1,6 @@ +@@ -1,101 +1,20 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.httpHeadersToEdr = exports.edrTracingMessageToMinimalMessage = exports.edrTracingMessageResultToMinimalEVMResult = exports.edrTracingStepToMinimalInterpreterStep = exports.edrRpcDebugTraceToHardhat = exports.ethereumjsMempoolOrderToEdrMineOrdering = exports.ethereumjsIntervalMiningConfigToEdr = exports.edrSpecIdToEthereumHardfork = exports.ethereumsjsHardforkToEdrSpecId = void 0; +-const edr_1 = require("@nomicfoundation/edr"); +exports.httpHeadersToEdr = exports.edrTracingMessageToMinimalMessage = exports.edrTracingMessageResultToMinimalEVMResult = exports.edrTracingStepToMinimalInterpreterStep = exports.ethereumjsMempoolOrderToEdrMineOrdering = exports.ethereumjsIntervalMiningConfigToEdr = exports.edrSpecIdToEthereumHardfork = exports.ethereumsjsHardforkToEdrSpecId = void 0; - const edr_1 = require("@nomicfoundation/edr"); const util_1 = require("@ethereumjs/util"); const napi_rs_1 = require("../../../../common/napi-rs"); -@@ -126,50 +126,6 @@ function ethereumjsMempoolOrderToEdrMineOrdering(mempoolOrder) { + const hardforks_1 = require("../../../util/hardforks"); + /* eslint-disable @nomicfoundation/hardhat-internal-rules/only-hardhat-error */ + function ethereumsjsHardforkToEdrSpecId(hardfork) { +- switch (hardfork) { +- case hardforks_1.HardforkName.FRONTIER: +- return edr_1.FRONTIER; +- case hardforks_1.HardforkName.HOMESTEAD: +- return edr_1.HOMESTEAD; +- case hardforks_1.HardforkName.DAO: +- return edr_1.DAO_FORK; +- case hardforks_1.HardforkName.TANGERINE_WHISTLE: +- return edr_1.TANGERINE; +- case hardforks_1.HardforkName.SPURIOUS_DRAGON: +- return edr_1.SPURIOUS_DRAGON; +- case hardforks_1.HardforkName.BYZANTIUM: +- return edr_1.BYZANTIUM; +- case hardforks_1.HardforkName.CONSTANTINOPLE: +- return edr_1.CONSTANTINOPLE; +- case hardforks_1.HardforkName.PETERSBURG: +- return edr_1.PETERSBURG; +- case hardforks_1.HardforkName.ISTANBUL: +- return edr_1.ISTANBUL; +- case hardforks_1.HardforkName.MUIR_GLACIER: +- return edr_1.MUIR_GLACIER; +- case hardforks_1.HardforkName.BERLIN: +- return edr_1.BERLIN; +- case hardforks_1.HardforkName.LONDON: +- return edr_1.LONDON; +- case hardforks_1.HardforkName.ARROW_GLACIER: +- return edr_1.ARROW_GLACIER; +- case hardforks_1.HardforkName.GRAY_GLACIER: +- return edr_1.GRAY_GLACIER; +- case hardforks_1.HardforkName.MERGE: +- return edr_1.MERGE; +- case hardforks_1.HardforkName.SHANGHAI: +- return edr_1.SHANGHAI; +- case hardforks_1.HardforkName.CANCUN: +- return edr_1.CANCUN; +- case hardforks_1.HardforkName.PRAGUE: +- return edr_1.PRAGUE; +- case hardforks_1.HardforkName.OSAKA: +- return edr_1.OSAKA; +- default: +- const _exhaustiveCheck = hardfork; +- throw new Error(`Unknown hardfork name '${hardfork}', this shouldn't happen`); +- } ++ // EDR's hardfork names match Hardhat's, so no conversion is needed. Names ++ // EDR does not support (e.g. pre-Byzantium) are rejected by EDR itself. ++ return hardfork; + } + exports.ethereumsjsHardforkToEdrSpecId = ethereumsjsHardforkToEdrSpecId; + function edrSpecIdToEthereumHardfork(specId) { +- const { SpecId } = (0, napi_rs_1.requireNapiRsModule)("@nomicfoundation/edr"); +- switch (specId) { +- case SpecId.Frontier: +- return hardforks_1.HardforkName.FRONTIER; +- case SpecId.Homestead: +- return hardforks_1.HardforkName.HOMESTEAD; +- case SpecId.DaoFork: +- return hardforks_1.HardforkName.DAO; +- case SpecId.Tangerine: +- return hardforks_1.HardforkName.TANGERINE_WHISTLE; +- case SpecId.SpuriousDragon: +- return hardforks_1.HardforkName.SPURIOUS_DRAGON; +- case SpecId.Byzantium: +- return hardforks_1.HardforkName.BYZANTIUM; +- case SpecId.Constantinople: +- return hardforks_1.HardforkName.CONSTANTINOPLE; +- case SpecId.Petersburg: +- return hardforks_1.HardforkName.PETERSBURG; +- case SpecId.Istanbul: +- return hardforks_1.HardforkName.ISTANBUL; +- case SpecId.MuirGlacier: +- return hardforks_1.HardforkName.MUIR_GLACIER; +- case SpecId.Berlin: +- return hardforks_1.HardforkName.BERLIN; +- case SpecId.London: +- return hardforks_1.HardforkName.LONDON; +- case SpecId.ArrowGlacier: +- return hardforks_1.HardforkName.ARROW_GLACIER; +- case SpecId.GrayGlacier: +- return hardforks_1.HardforkName.GRAY_GLACIER; +- case SpecId.Merge: +- return hardforks_1.HardforkName.MERGE; +- case SpecId.Shanghai: +- return hardforks_1.HardforkName.SHANGHAI; +- case SpecId.Cancun: +- return hardforks_1.HardforkName.CANCUN; +- case SpecId.Prague: +- return hardforks_1.HardforkName.PRAGUE; +- case SpecId.Osaka: +- return hardforks_1.HardforkName.OSAKA; +- default: +- throw new Error(`Unknown spec id '${specId}', this shouldn't happen`); +- } ++ const { l1HardforkToString } = (0, napi_rs_1.requireNapiRsModule)("@nomicfoundation/edr"); ++ // EDR's hardfork names match Hardhat's, so no conversion is needed. ++ return l1HardforkToString(specId); + } + exports.edrSpecIdToEthereumHardfork = edrSpecIdToEthereumHardfork; + function ethereumjsIntervalMiningConfigToEdr(config) { +@@ -126,50 +45,6 @@ function ethereumjsMempoolOrderToEdrMineOrdering(mempoolOrder) { } } exports.ethereumjsMempoolOrderToEdrMineOrdering = ethereumjsMempoolOrderToEdrMineOrdering; @@ -737,10 +839,154 @@ index 7e4276a589668b96c16243f547c0a2caecdb0d46..4636477ae060c71beadf065749aaa938 const context = await getGlobalEdrContext(); diff --git a/src/internal/hardhat-network/provider/utils/convertToEdr.ts b/src/internal/hardhat-network/provider/utils/convertToEdr.ts -index 7fc17b29c0483c4f72ec471f8be60ce7d563add8..4dc5ebf3db263a281623ac2b161b7b5bb24a96a6 100644 +index 7fc17b29c0483c4f72ec471f8be60ce7d563add8..6e29625e68e2b6d45f91042bd10fbbabfe70f518 100644 --- a/src/internal/hardhat-network/provider/utils/convertToEdr.ts +++ b/src/internal/hardhat-network/provider/utils/convertToEdr.ts -@@ -174,62 +174,6 @@ export function ethereumjsMempoolOrderToEdrMineOrdering( +@@ -1,5 +1,5 @@ + import type { +- SpecId, ++ L1Hardfork, + MineOrdering, + IntervalRange, + DebugTraceResult, +@@ -8,27 +8,6 @@ import type { + TracingStep, + HttpHeader, + } from "@nomicfoundation/edr"; +-import { +- FRONTIER, +- HOMESTEAD, +- DAO_FORK, +- TANGERINE, +- SPURIOUS_DRAGON, +- BYZANTIUM, +- CONSTANTINOPLE, +- PETERSBURG, +- ISTANBUL, +- MUIR_GLACIER, +- BERLIN, +- LONDON, +- ARROW_GLACIER, +- GRAY_GLACIER, +- MERGE, +- SHANGHAI, +- CANCUN, +- PRAGUE, +- OSAKA, +-} from "@nomicfoundation/edr"; + import { Address } from "@ethereumjs/util"; + + import { requireNapiRsModule } from "../../../../common/napi-rs"; +@@ -44,101 +23,18 @@ import { + /* eslint-disable @nomicfoundation/hardhat-internal-rules/only-hardhat-error */ + + export function ethereumsjsHardforkToEdrSpecId(hardfork: HardforkName): string { +- switch (hardfork) { +- case HardforkName.FRONTIER: +- return FRONTIER; +- case HardforkName.HOMESTEAD: +- return HOMESTEAD; +- case HardforkName.DAO: +- return DAO_FORK; +- case HardforkName.TANGERINE_WHISTLE: +- return TANGERINE; +- case HardforkName.SPURIOUS_DRAGON: +- return SPURIOUS_DRAGON; +- case HardforkName.BYZANTIUM: +- return BYZANTIUM; +- case HardforkName.CONSTANTINOPLE: +- return CONSTANTINOPLE; +- case HardforkName.PETERSBURG: +- return PETERSBURG; +- case HardforkName.ISTANBUL: +- return ISTANBUL; +- case HardforkName.MUIR_GLACIER: +- return MUIR_GLACIER; +- case HardforkName.BERLIN: +- return BERLIN; +- case HardforkName.LONDON: +- return LONDON; +- case HardforkName.ARROW_GLACIER: +- return ARROW_GLACIER; +- case HardforkName.GRAY_GLACIER: +- return GRAY_GLACIER; +- case HardforkName.MERGE: +- return MERGE; +- case HardforkName.SHANGHAI: +- return SHANGHAI; +- case HardforkName.CANCUN: +- return CANCUN; +- case HardforkName.PRAGUE: +- return PRAGUE; +- case HardforkName.OSAKA: +- return OSAKA; +- default: +- const _exhaustiveCheck: never = hardfork; +- throw new Error( +- `Unknown hardfork name '${hardfork as string}', this shouldn't happen` +- ); +- } ++ // EDR's hardfork names match Hardhat's, so no conversion is needed. Names ++ // EDR does not support (e.g. pre-Byzantium) are rejected by EDR itself. ++ return hardfork; + } + +-export function edrSpecIdToEthereumHardfork(specId: SpecId): HardforkName { +- const { SpecId } = requireNapiRsModule( ++export function edrSpecIdToEthereumHardfork(specId: L1Hardfork): HardforkName { ++ const { l1HardforkToString } = requireNapiRsModule( + "@nomicfoundation/edr" + ) as typeof import("@nomicfoundation/edr"); + +- switch (specId) { +- case SpecId.Frontier: +- return HardforkName.FRONTIER; +- case SpecId.Homestead: +- return HardforkName.HOMESTEAD; +- case SpecId.DaoFork: +- return HardforkName.DAO; +- case SpecId.Tangerine: +- return HardforkName.TANGERINE_WHISTLE; +- case SpecId.SpuriousDragon: +- return HardforkName.SPURIOUS_DRAGON; +- case SpecId.Byzantium: +- return HardforkName.BYZANTIUM; +- case SpecId.Constantinople: +- return HardforkName.CONSTANTINOPLE; +- case SpecId.Petersburg: +- return HardforkName.PETERSBURG; +- case SpecId.Istanbul: +- return HardforkName.ISTANBUL; +- case SpecId.MuirGlacier: +- return HardforkName.MUIR_GLACIER; +- case SpecId.Berlin: +- return HardforkName.BERLIN; +- case SpecId.London: +- return HardforkName.LONDON; +- case SpecId.ArrowGlacier: +- return HardforkName.ARROW_GLACIER; +- case SpecId.GrayGlacier: +- return HardforkName.GRAY_GLACIER; +- case SpecId.Merge: +- return HardforkName.MERGE; +- case SpecId.Shanghai: +- return HardforkName.SHANGHAI; +- case SpecId.Cancun: +- return HardforkName.CANCUN; +- case SpecId.Prague: +- return HardforkName.PRAGUE; +- case SpecId.Osaka: +- return HardforkName.OSAKA; +- +- default: +- throw new Error(`Unknown spec id '${specId}', this shouldn't happen`); +- } ++ // EDR's hardfork names match Hardhat's, so no conversion is needed. ++ return l1HardforkToString(specId) as HardforkName; + } + + export function ethereumjsIntervalMiningConfigToEdr( +@@ -174,62 +70,6 @@ export function ethereumjsMempoolOrderToEdrMineOrdering( } } diff --git a/patches/hardhat@3.4.5.patch b/patches/hardhat@3.4.5.patch index 4b84d3f1bb..c4e88a9a62 100644 --- a/patches/hardhat@3.4.5.patch +++ b/patches/hardhat@3.4.5.patch @@ -40,6 +40,203 @@ index 991bcb9217f76c32af422acd493fa9610b1e4b3c..24858adbac67dbc65d1d2c078d69f0e4 networkId: BigInt(networkConfig.networkId), observability: { codeCoverage: coverageConfig, +diff --git a/dist/src/internal/builtin-plugins/network-manager/edr/utils/convert-to-edr.d.ts b/dist/src/internal/builtin-plugins/network-manager/edr/utils/convert-to-edr.d.ts +index f481140b7212d2e72f4623d828776567c35f8701..3306f4e5db9eae8d8cccf0effe69570fb7d7b7b1 100644 +--- a/dist/src/internal/builtin-plugins/network-manager/edr/utils/convert-to-edr.d.ts ++++ b/dist/src/internal/builtin-plugins/network-manager/edr/utils/convert-to-edr.d.ts +@@ -2,9 +2,9 @@ import type { EdrNetworkAccountConfig, EdrNetworkAccountsConfig, ChainDescriptor + import type { ChainType } from "../../../../../types/network.js"; + import type { GasMeasurement } from "../../../gas-analytics/types.js"; + import type { IntervalRange, ChainOverride, ForkConfig, GasReport } from "@nomicfoundation/edr"; +-import { MineOrdering, OpHardfork, SpecId } from "@nomicfoundation/edr"; ++import { MineOrdering, OpHardfork, L1Hardfork } from "@nomicfoundation/edr"; + import { L1HardforkName, OpHardforkName } from "../types/hardfork.js"; +-export declare function edrL1HardforkToHardhatL1HardforkName(hardfork: SpecId): L1HardforkName; ++export declare function edrL1HardforkToHardhatL1HardforkName(hardfork: L1Hardfork): L1HardforkName; + export declare function edrOpHardforkToHardhatOpHardforkName(hardfork: OpHardfork): OpHardforkName; + export declare function hardhatHardforkToEdrSpecId(hardfork: string, chainType: ChainType): string; + export declare function hardhatMiningIntervalToEdrMiningInterval(config: EdrNetworkMiningConfig["interval"]): bigint | IntervalRange | undefined; +diff --git a/dist/src/internal/builtin-plugins/network-manager/edr/utils/convert-to-edr.js b/dist/src/internal/builtin-plugins/network-manager/edr/utils/convert-to-edr.js +index 26ad9bd84e7c1a0886226d184bc577975aaf6569..68477e297c0c045a97035d6a2b6e645c8e704c6d 100644 +--- a/dist/src/internal/builtin-plugins/network-manager/edr/utils/convert-to-edr.js ++++ b/dist/src/internal/builtin-plugins/network-manager/edr/utils/convert-to-edr.js +@@ -1,4 +1,4 @@ +-import { GasReportExecutionStatus, MineOrdering, OpHardfork, SpecId, FRONTIER, HOMESTEAD, DAO_FORK, TANGERINE, SPURIOUS_DRAGON, BYZANTIUM, CONSTANTINOPLE, PETERSBURG, ISTANBUL, MUIR_GLACIER, BERLIN, LONDON, ARROW_GLACIER, GRAY_GLACIER, MERGE, SHANGHAI, CANCUN, PRAGUE, OSAKA, BEDROCK, REGOLITH, CANYON, ECOTONE, FJORD, GRANITE, HOLOCENE, ISTHMUS, } from "@nomicfoundation/edr"; ++import { GasReportExecutionStatus, l1HardforkToString, MineOrdering, opHardforkToString, } from "@nomicfoundation/edr"; + import { GENERIC_CHAIN_TYPE, L1_CHAIN_TYPE, OPTIMISM_CHAIN_TYPE, } from "../../../../constants.js"; + import { FixedValueConfigurationVariable } from "../../../../core/configuration-variables.js"; + import { derivePrivateKeys } from "../../accounts/derive-private-keys.js"; +@@ -6,80 +6,12 @@ import { DEFAULT_EDR_NETWORK_BALANCE, EDR_NETWORK_DEFAULT_PRIVATE_KEYS, isDefaul + import { L1HardforkName, OpHardforkName } from "../types/hardfork.js"; + import { getL1HardforkName, getOpHardforkName } from "./hardfork.js"; + export function edrL1HardforkToHardhatL1HardforkName(hardfork) { +- switch (hardfork) { +- case SpecId.Frontier: +- return L1HardforkName.FRONTIER; +- case SpecId.FrontierThawing: +- return L1HardforkName.FRONTIER; +- case SpecId.Homestead: +- return L1HardforkName.HOMESTEAD; +- case SpecId.DaoFork: +- return L1HardforkName.DAO; +- case SpecId.Tangerine: +- return L1HardforkName.TANGERINE_WHISTLE; +- case SpecId.SpuriousDragon: +- return L1HardforkName.SPURIOUS_DRAGON; +- case SpecId.Byzantium: +- return L1HardforkName.BYZANTIUM; +- case SpecId.Constantinople: +- return L1HardforkName.CONSTANTINOPLE; +- case SpecId.Petersburg: +- return L1HardforkName.PETERSBURG; +- case SpecId.Istanbul: +- return L1HardforkName.ISTANBUL; +- case SpecId.MuirGlacier: +- return L1HardforkName.MUIR_GLACIER; +- case SpecId.Berlin: +- return L1HardforkName.BERLIN; +- case SpecId.London: +- return L1HardforkName.LONDON; +- case SpecId.ArrowGlacier: +- return L1HardforkName.ARROW_GLACIER; +- case SpecId.GrayGlacier: +- return L1HardforkName.GRAY_GLACIER; +- case SpecId.Merge: +- return L1HardforkName.MERGE; +- case SpecId.Shanghai: +- return L1HardforkName.SHANGHAI; +- case SpecId.Cancun: +- return L1HardforkName.CANCUN; +- case SpecId.Prague: +- return L1HardforkName.PRAGUE; +- case SpecId.Osaka: +- return L1HardforkName.OSAKA; +- // eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check -- trust but verify +- default: +- const _exhaustiveCheck = hardfork; +- throw new Error( +- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- we want to print the fork +- `Unknown L1 hardfork '${hardfork}', this shouldn't happen`); +- } ++ // EDR's hardfork names match Hardhat's, so no conversion is needed. ++ return l1HardforkToString(hardfork); + } + export function edrOpHardforkToHardhatOpHardforkName(hardfork) { +- switch (hardfork) { +- case OpHardfork.Bedrock: +- return OpHardforkName.BEDROCK; +- case OpHardfork.Regolith: +- return OpHardforkName.REGOLITH; +- case OpHardfork.Canyon: +- return OpHardforkName.CANYON; +- case OpHardfork.Ecotone: +- return OpHardforkName.ECOTONE; +- case OpHardfork.Fjord: +- return OpHardforkName.FJORD; +- case OpHardfork.Granite: +- return OpHardforkName.GRANITE; +- case OpHardfork.Holocene: +- return OpHardforkName.HOLOCENE; +- case OpHardfork.Isthmus: +- return OpHardforkName.ISTHMUS; +- // eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check -- trust but verify +- default: +- const _exhaustiveCheck = hardfork; +- throw new Error( +- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- we want to print the fork +- `Unknown OP hardfork '${hardfork}', this shouldn't happen`); +- } ++ // EDR's hardfork names match Hardhat's, so no conversion is needed. ++ return opHardforkToString(hardfork); + } + export function hardhatHardforkToEdrSpecId(hardfork, chainType) { + return chainType === OPTIMISM_CHAIN_TYPE +@@ -87,80 +19,13 @@ export function hardhatHardforkToEdrSpecId(hardfork, chainType) { + : hardhatL1HardforkToEdrSpecId(hardfork); + } + function hardhatOpHardforkToEdrSpecId(hardfork) { +- const hardforkName = getOpHardforkName(hardfork); +- switch (hardforkName) { +- case OpHardforkName.BEDROCK: +- return BEDROCK; +- case OpHardforkName.REGOLITH: +- return REGOLITH; +- case OpHardforkName.CANYON: +- return CANYON; +- case OpHardforkName.ECOTONE: +- return ECOTONE; +- case OpHardforkName.FJORD: +- return FJORD; +- case OpHardforkName.GRANITE: +- return GRANITE; +- case OpHardforkName.HOLOCENE: +- return HOLOCENE; +- case OpHardforkName.ISTHMUS: +- return ISTHMUS; +- // eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check -- trust but verify +- default: +- const _exhaustiveCheck = hardforkName; +- throw new Error( +- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- we want to print the fork +- `Unknown hardfork name '${hardforkName}', this shouldn't happen`); +- } ++ // EDR's hardfork names match Hardhat's, so no conversion is needed. ++ return getOpHardforkName(hardfork); + } + function hardhatL1HardforkToEdrSpecId(hardfork) { +- const hardforkName = getL1HardforkName(hardfork); +- switch (hardforkName) { +- case L1HardforkName.FRONTIER: +- return FRONTIER; +- case L1HardforkName.HOMESTEAD: +- return HOMESTEAD; +- case L1HardforkName.DAO: +- return DAO_FORK; +- case L1HardforkName.TANGERINE_WHISTLE: +- return TANGERINE; +- case L1HardforkName.SPURIOUS_DRAGON: +- return SPURIOUS_DRAGON; +- case L1HardforkName.BYZANTIUM: +- return BYZANTIUM; +- case L1HardforkName.CONSTANTINOPLE: +- return CONSTANTINOPLE; +- case L1HardforkName.PETERSBURG: +- return PETERSBURG; +- case L1HardforkName.ISTANBUL: +- return ISTANBUL; +- case L1HardforkName.MUIR_GLACIER: +- return MUIR_GLACIER; +- case L1HardforkName.BERLIN: +- return BERLIN; +- case L1HardforkName.LONDON: +- return LONDON; +- case L1HardforkName.ARROW_GLACIER: +- return ARROW_GLACIER; +- case L1HardforkName.GRAY_GLACIER: +- return GRAY_GLACIER; +- case L1HardforkName.MERGE: +- return MERGE; +- case L1HardforkName.SHANGHAI: +- return SHANGHAI; +- case L1HardforkName.CANCUN: +- return CANCUN; +- case L1HardforkName.PRAGUE: +- return PRAGUE; +- case L1HardforkName.OSAKA: +- return OSAKA; +- // eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check -- we want to print the fork +- default: +- const _exhaustiveCheck = hardforkName; +- throw new Error( +- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- an enum can be safely cast to a string +- `Unknown hardfork name '${hardfork}', this shouldn't happen`); +- } ++ // EDR's hardfork names match Hardhat's, so no conversion is needed. Names ++ // EDR does not support (e.g. pre-Byzantium) are rejected by EDR itself. ++ return getL1HardforkName(hardfork); + } + export function hardhatMiningIntervalToEdrMiningInterval(config) { + if (typeof config === "number") { diff --git a/dist/src/internal/builtin-plugins/solidity-test/helpers.js b/dist/src/internal/builtin-plugins/solidity-test/helpers.js index 2370cd07ecb5f7913c8325b01f15302c90170ee9..17bde110d70ea1a4d5c4973af7b23e379c52b624 100644 --- a/dist/src/internal/builtin-plugins/solidity-test/helpers.js @@ -68,7 +265,7 @@ index 2370cd07ecb5f7913c8325b01f15302c90170ee9..17bde110d70ea1a4d5c4973af7b23e37 ethRpcUrl, forkBlockNumber, diff --git a/package.json b/package.json -index 6a8b5dc220db7a3c595be286bea9ad5ef515deae..dfea18b5f4bde1ca4a0279cacec6578403eddb36 100644 +index 6a8b5dc220db7a3c595be286bea9ad5ef515deae..aa6b42d41a0e3a95965110c14124cff58c800612 100644 --- a/package.json +++ b/package.json @@ -41,6 +41,9 @@ diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 58d395ee44..9b79a5e991 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8,8 +8,8 @@ overrides: hardhat>@nomicfoundation/edr: workspace:* patchedDependencies: - hardhat@2.28.4: e673aa2222bae6d08ea4b76561adbbf94ee393d74412eaea64f8837258809600 - hardhat@3.4.5: 0de38ef817bceff74a51505ab96d0c87085e888d660f71a437d879da576ba805 + hardhat@2.28.4: 276e2c5e26cd44f35e113fd047a7b0d765ae0df55b6290953b0313000449ee23 + hardhat@3.4.5: 8a85e7b193289d6932884945b9862466aab8865f5cb00e2480cee3bec5328c46 importers: @@ -215,7 +215,7 @@ importers: version: 7.0.1 hardhat: specifier: 2.28.4 - version: 2.28.4(patch_hash=e673aa2222bae6d08ea4b76561adbbf94ee393d74412eaea64f8837258809600)(supports-color@8.1.1)(ts-node@10.9.2(@types/node@22.20.1)(typescript@5.8.3))(typescript@5.8.3) + version: 2.28.4(patch_hash=276e2c5e26cd44f35e113fd047a7b0d765ae0df55b6290953b0313000449ee23)(supports-color@8.1.1)(ts-node@10.9.2(@types/node@22.20.1)(typescript@5.8.3))(typescript@5.8.3) mocha: specifier: ^11.1.0 version: 11.8.0 @@ -294,10 +294,10 @@ importers: version: 5.5.6(eslint-config-prettier@9.1.2(eslint@8.57.1(supports-color@8.1.1)))(eslint@8.57.1(supports-color@8.1.1))(prettier@3.9.6) hardhat: specifier: 3.4.5 - version: 3.4.5(patch_hash=0de38ef817bceff74a51505ab96d0c87085e888d660f71a437d879da576ba805) + version: 3.4.5(patch_hash=8a85e7b193289d6932884945b9862466aab8865f5cb00e2480cee3bec5328c46) hardhat2: specifier: npm:hardhat@2.28.4 - version: hardhat@2.28.4(patch_hash=e673aa2222bae6d08ea4b76561adbbf94ee393d74412eaea64f8837258809600)(supports-color@8.1.1)(ts-node@10.9.2(@types/node@22.20.1)(typescript@5.8.3))(typescript@5.8.3) + version: hardhat@2.28.4(patch_hash=276e2c5e26cd44f35e113fd047a7b0d765ae0df55b6290953b0313000449ee23)(supports-color@8.1.1)(ts-node@10.9.2(@types/node@22.20.1)(typescript@5.8.3))(typescript@5.8.3) lodash: specifier: ^4.17.11 version: 4.18.1 @@ -366,7 +366,7 @@ importers: version: 7.0.1 hardhat: specifier: 3.4.5 - version: 3.4.5(patch_hash=0de38ef817bceff74a51505ab96d0c87085e888d660f71a437d879da576ba805) + version: 3.4.5(patch_hash=8a85e7b193289d6932884945b9862466aab8865f5cb00e2480cee3bec5328c46) prettier: specifier: ^3.2.5 version: 3.9.6 @@ -396,7 +396,7 @@ importers: version: https://codeload.github.com/foundry-rs/forge-std/tar.gz/1801b0541f4fda118a10798fd3486bb7051c5dd6 hardhat: specifier: 3.4.5 - version: 3.4.5(patch_hash=0de38ef817bceff74a51505ab96d0c87085e888d660f71a437d879da576ba805) + version: 3.4.5(patch_hash=8a85e7b193289d6932884945b9862466aab8865f5cb00e2480cee3bec5328c46) prettier: specifier: ^3.2.5 version: 3.9.6 @@ -423,7 +423,7 @@ importers: version: https://codeload.github.com/foundry-rs/forge-std/tar.gz/1801b0541f4fda118a10798fd3486bb7051c5dd6 hardhat: specifier: ^3.4.5 - version: 3.4.5(patch_hash=0de38ef817bceff74a51505ab96d0c87085e888d660f71a437d879da576ba805) + version: 3.4.5(patch_hash=8a85e7b193289d6932884945b9862466aab8865f5cb00e2480cee3bec5328c46) tsx: specifier: ^4.19.3 version: 4.22.4 @@ -6224,7 +6224,7 @@ snapshots: graphemer@1.4.0: {} - hardhat@2.28.4(patch_hash=e673aa2222bae6d08ea4b76561adbbf94ee393d74412eaea64f8837258809600)(supports-color@8.1.1)(ts-node@10.9.2(@types/node@22.20.1)(typescript@5.8.3))(typescript@5.8.3): + hardhat@2.28.4(patch_hash=276e2c5e26cd44f35e113fd047a7b0d765ae0df55b6290953b0313000449ee23)(supports-color@8.1.1)(ts-node@10.9.2(@types/node@22.20.1)(typescript@5.8.3))(typescript@5.8.3): dependencies: '@ethereumjs/util': 9.1.0 '@ethersproject/abi': 5.8.0 @@ -6273,7 +6273,7 @@ snapshots: - supports-color - utf-8-validate - hardhat@3.4.5(patch_hash=0de38ef817bceff74a51505ab96d0c87085e888d660f71a437d879da576ba805): + hardhat@3.4.5(patch_hash=8a85e7b193289d6932884945b9862466aab8865f5cb00e2480cee3bec5328c46): dependencies: '@nomicfoundation/edr': link:crates/edr_napi '@nomicfoundation/hardhat-errors': 3.0.16 From a8bd545ba57e062abc3ac7f4b78dbaa1f26f7a5d Mon Sep 17 00:00:00 2001 From: Ana Perez Ghiglia Date: Mon, 24 Aug 2026 16:07:32 +0000 Subject: [PATCH 06/10] Fix HH-test after pre-byzantium hardforks removal --- .../hardhat-network/provider/modules/eth/hardforks.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hardhat-tests/test/internal/hardhat-network/provider/modules/eth/hardforks.ts b/hardhat-tests/test/internal/hardhat-network/provider/modules/eth/hardforks.ts index f5b27e3937..e1cf1ae3a3 100644 --- a/hardhat-tests/test/internal/hardhat-network/provider/modules/eth/hardforks.ts +++ b/hardhat-tests/test/internal/hardhat-network/provider/modules/eth/hardforks.ts @@ -115,7 +115,7 @@ describe("Eth module - hardfork dependant tests", function () { describe("Transaction, call and estimate gas validations", function () { describe("chain id validation", function () { describe("In a hardfork without access list but with EIP-155", function () { - useProviderAndCommon("spuriousDragon"); + useProviderAndCommon("byzantium"); it("Should validate the chain id if sent to eth_sendTransaction", async function () { const [sender] = await this.provider.send("eth_accounts"); @@ -129,7 +129,7 @@ describe("Eth module - hardfork dependant tests", function () { it("Should validate the chain id if an EIP-155 tx is sent with eth_sendRawTransaction", async function () { const signedTx = getSampleSignedTx( - new Common({ chain: "mainnet", hardfork: "spuriousDragon" }) + new Common({ chain: "mainnet", hardfork: "byzantium" }) ); const serialized = bufferToRpcData(signedTx.serialize()); From aefe4590384a1f9122a2d6c6e2ab36dcd0c81863 Mon Sep 17 00:00:00 2001 From: Ana Perez Ghiglia Date: Mon, 24 Aug 2026 17:38:52 +0000 Subject: [PATCH 07/10] Fix op-chain script after OpHardfork changes --- crates/tool/op_chain_config_generator/src/main.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/tool/op_chain_config_generator/src/main.rs b/crates/tool/op_chain_config_generator/src/main.rs index b7960665a3..5a4d9b2217 100644 --- a/crates/tool/op_chain_config_generator/src/main.rs +++ b/crates/tool/op_chain_config_generator/src/main.rs @@ -456,7 +456,7 @@ fn generate_hardfork_activations_for( .into_iter() .chain(superchain_activations) .map(|(hardfork, activation)| { - let hardfork_str: &'static str = hardfork.into(); + let hardfork_str = capitalize_first_letter(hardfork.into()); format!( " @@ -476,7 +476,7 @@ fn get_op_hardfork_from(hardfork_str: &str) -> anyhow::Result .map(|(before_match, _)| before_match) .ok_or(anyhow!("activation is not time based: {hardfork_str}"))?; - match OpHardfork::from_str(&capitalize_first_letter(hardfork_name)) { + match OpHardfork::from_str(hardfork_name) { Err(_) => { if !KNOWN_IGNORED_HARDFORKS.contains(&hardfork_name) { bail!("hardfork name is not supported: {hardfork_name}") From 595bb46ffb1dc18f961a900503370c84c1576760 Mon Sep 17 00:00:00 2001 From: Ana Perez Ghiglia Date: Mon, 24 Aug 2026 19:16:55 +0000 Subject: [PATCH 08/10] Fix failing issue_588 test --- crates/edr_provider/tests/integration/issues/issue_588.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/crates/edr_provider/tests/integration/issues/issue_588.rs b/crates/edr_provider/tests/integration/issues/issue_588.rs index 933702c565..4ea414ab00 100644 --- a/crates/edr_provider/tests/integration/issues/issue_588.rs +++ b/crates/edr_provider/tests/integration/issues/issue_588.rs @@ -22,22 +22,23 @@ async fn issue_588() -> anyhow::Result<()> { let logger = Box::new(NoopLogger::>::default()); let subscriber = Box::new(|_event| {}); - let early_mainnet_fork = + let mainnet_fork = create_test_config_with(MinimalProviderConfig::fork_with_accounts(ForkConfig { - block_number: Some(2_675_000), + block_number: Some(20_384_300), cache_dir: edr_defaults::CACHE_DIR.into(), chain_overrides: HashMap::default(), http_headers: None, url: json_rpc_url_provider::ethereum_mainnet(), })); + // With the clock at 1970, the forked block's timestamp is in the future. let current_time_is_1970 = Arc::new(MockTime::with_seconds(0)); let _forking_succeeds = Provider::new( runtime::Handle::current(), logger, subscriber, - early_mainnet_fork, + mainnet_fork, Arc::new(RwLock::::default()), current_time_is_1970, )?; From 5841337e282c3bf1a3551e637b0d043bb505b6f4 Mon Sep 17 00:00:00 2001 From: Ana Perez Ghiglia Date: Mon, 31 Aug 2026 15:55:36 -0300 Subject: [PATCH 09/10] Adjust changeset wording Co-authored-by: Wodann --- .changeset/mighty-poems-tickle.md | 6 +++--- .changeset/wise-falcons-relate.md | 5 ++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/.changeset/mighty-poems-tickle.md b/.changeset/mighty-poems-tickle.md index 4fdfa322ab..a048f81bb6 100644 --- a/.changeset/mighty-poems-tickle.md +++ b/.changeset/mighty-poems-tickle.md @@ -2,6 +2,6 @@ "@nomicfoundation/edr": minor --- -Renamed the `SpecId` enum to `L1Hardfork`, mirroring `OpHardfork`, and removed support for pre-Byzantium Ethereum L1 hardforks: the enum no longer includes `Frontier`, `FrontierThawing`, `Homestead`, `DaoFork`, `Tangerine` and `SpuriousDragon`. Discriminants of the remaining variants are unchanged, so `Byzantium` is still `6`. - -Forking a chain from a block that precedes its oldest supported hardfork now fails with an error naming that hardfork, instead of silently skipping hardfork validation. +- Added `L1Hardfork` enum, with all post-Byzantium L1 hardforks. Discriminants of the variants match those of `SpecId`. +- Fixed an issue for forked blockchains where a block fork block that precedes its oldest supported hardfork was silently accepted. Now it fails with an error naming the oldest supported hardfork. +- BREAKING CHANGE: Removed `SpecId`. Instead, use `L1Hardfork`. Using any of the pre-Byzantium hardforks (`Frontier`, `FrontierThawing`, `Homestead`, `DaoFork`, `Tangerine` and `SpuriousDragon`) previously resulted in a runtime error. Now, they are no longer representable. diff --git a/.changeset/wise-falcons-relate.md b/.changeset/wise-falcons-relate.md index 28c0553eba..a3cb74a1b8 100644 --- a/.changeset/wise-falcons-relate.md +++ b/.changeset/wise-falcons-relate.md @@ -2,6 +2,5 @@ "@nomicfoundation/edr": minor --- -Renamed the hardfork name strings to match Hardhat's definitions: names are now camelCase (e.g. `"byzantium"`, `"muirGlacier"`, `"bedrock"`). `l1HardforkToString`/`opHardforkToString` return the new names, and `l1HardforkFromString`/`opHardforkFromString` and provider configs accept only them — passing an old-style name (e.g. `"Byzantium"`) fails. - -The exported hardfork name string constants (`BYZANTIUM`, …, `AMSTERDAM` and `BEDROCK`, …, `ISTHMUS`) were removed; convert from the enum instead, e.g. replace `OSAKA` with `l1HardforkToString(L1Hardfork.Osaka)`. (Note that `L1Hardfork` is a numeric enum, so `L1Hardfork.Osaka.toString()` yields `"19"`, not the name.) +- Changed the hardfork name strings to match Hardhat's definitions: names are now camelCase (e.g. `"byzantium"`, `"muirGlacier"`, `"bedrock"`). `l1HardforkToString`/`opHardforkToString` return the new names, and `l1HardforkFromString`/`opHardforkFromString` and provider configs accept only them — passing an old-style name (e.g. `"Byzantium"`) fails. +- BREAKING CHANGE: Removed hardfork name string constants (`BYZANTIUM`, …, `AMSTERDAM` and `BEDROCK`, …, `ISTHMUS`). Instead, obtain them using `l1HardforkToString` (e.g. replace `OSAKA` with `l1HardforkToString(L1Hardfork.Osaka)`). From ef78b21838b819b5893b0bdd90b43d6115279102 Mon Sep 17 00:00:00 2001 From: Ana Perez Ghiglia Date: Mon, 31 Aug 2026 20:46:07 +0000 Subject: [PATCH 10/10] Apply PR review feedback --- .changeset/mighty-poems-tickle.md | 2 +- crates/edr_chain_l1/src/hardfork.rs | 5 ++--- crates/edr_op/src/hardfork.rs | 5 ++--- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/.changeset/mighty-poems-tickle.md b/.changeset/mighty-poems-tickle.md index a048f81bb6..b14bc8de11 100644 --- a/.changeset/mighty-poems-tickle.md +++ b/.changeset/mighty-poems-tickle.md @@ -3,5 +3,5 @@ --- - Added `L1Hardfork` enum, with all post-Byzantium L1 hardforks. Discriminants of the variants match those of `SpecId`. -- Fixed an issue for forked blockchains where a block fork block that precedes its oldest supported hardfork was silently accepted. Now it fails with an error naming the oldest supported hardfork. +- Fixed an issue for forked blockchains where a block that precedes its oldest supported hardfork was silently accepted. Now it fails with an error naming the oldest supported hardfork. - BREAKING CHANGE: Removed `SpecId`. Instead, use `L1Hardfork`. Using any of the pre-Byzantium hardforks (`Frontier`, `FrontierThawing`, `Homestead`, `DaoFork`, `Tangerine` and `SpuriousDragon`) previously resulted in a runtime error. Now, they are no longer representable. diff --git a/crates/edr_chain_l1/src/hardfork.rs b/crates/edr_chain_l1/src/hardfork.rs index 073fa112fb..ba7e7f503b 100644 --- a/crates/edr_chain_l1/src/hardfork.rs +++ b/crates/edr_chain_l1/src/hardfork.rs @@ -7,9 +7,8 @@ use edr_primitives::UnknownHardfork; /// /// Models protocol upgrades, including ones without EVM-semantics changes, /// unlike [`EvmSpecId`] which models EVM behavior classes. -/// -/// The strum-derived names (`serialize_all = "camelCase"`) are public API; -/// the expected strings are pinned in this module's tests. +// The strum-derived names (`serialize_all = "camelCase"`) are public API; +// the expected strings are pinned in this module's tests. #[repr(u8)] #[derive( Clone, diff --git a/crates/edr_op/src/hardfork.rs b/crates/edr_op/src/hardfork.rs index b6c3efdba0..b5c978f4a3 100644 --- a/crates/edr_op/src/hardfork.rs +++ b/crates/edr_op/src/hardfork.rs @@ -16,9 +16,8 @@ pub mod op; /// /// Models protocol upgrades, including ones without EVM-semantics changes, /// unlike [`op_revm::OpSpecId`] which models EVM behavior classes. -/// -/// The strum-derived names (`serialize_all = "camelCase"`) are public API; -/// the expected strings are pinned in this module's tests. +// The strum-derived names (`serialize_all = "camelCase"`) are public API; +// the expected strings are pinned in this module's tests. #[repr(u8)] #[derive( Clone,