1- use std:: { collections:: HashMap , path:: PathBuf } ;
1+ use std:: { collections:: HashMap , path:: PathBuf , str :: FromStr } ;
22
3- use edr_primitives:: { Address , U256 } ;
3+ use edr_chain_spec:: EvmSpecId ;
4+ use edr_primitives:: { Address , UnknownHardfork , U256 } ;
45use edr_solidity_tests:: {
56 backend:: Predeploy ,
67 evm_context:: HardforkTr ,
@@ -117,6 +118,8 @@ pub struct TestRunnerConfig {
117118 /// The value of the `chainid` opcode in tests.
118119 /// Defaults to `31337`.
119120 pub chain_id : Option < u64 > ,
121+ /// The hardfork to use for EVM execution.
122+ pub hardfork : String ,
120123 /// The gas limit for each test case.
121124 /// Defaults to `9_223_372_036_854_775_807` (`i64::MAX`).
122125 pub gas_limit : Option < u64 > ,
@@ -141,6 +144,9 @@ pub struct TestRunnerConfig {
141144 /// Whether to disable the block gas limit.
142145 /// Defaults to false.
143146 pub disable_block_gas_limit : Option < bool > ,
147+ /// Whether to enable the EIP-7825 (Osaka) transaction gas limit cap.
148+ /// Defaults to false.
149+ pub enable_tx_gas_limit_cap : Option < bool > ,
144150 /// The memory limit of the EVM in bytes.
145151 /// Defaults to `33_554_432` (2^25 = 32MiB).
146152 pub memory_limit : Option < u64 > ,
@@ -180,7 +186,22 @@ pub struct TestRunnerConfig {
180186 Option < HashMap < TestFunctionIdentifier , TestFunctionConfigOverride > > ,
181187}
182188
183- impl < HardforkT : HardforkTr > TryFrom < TestRunnerConfig > for SolidityTestRunnerConfig < HardforkT > {
189+ fn parse_hardfork < HardforkT > ( hardfork : String ) -> napi:: Result < HardforkT >
190+ where
191+ HardforkT : FromStr < Err = UnknownHardfork > + Into < EvmSpecId > ,
192+ {
193+ hardfork. parse ( ) . map_err ( |UnknownHardfork | {
194+ napi:: Error :: new (
195+ napi:: Status :: InvalidArg ,
196+ format ! ( "Unknown hardfork: {hardfork}" ) ,
197+ )
198+ } )
199+ }
200+
201+ impl < HardforkT > TryFrom < TestRunnerConfig > for SolidityTestRunnerConfig < HardforkT >
202+ where
203+ HardforkT : HardforkTr + FromStr < Err = UnknownHardfork > + Into < EvmSpecId > ,
204+ {
184205 type Error = napi:: Error ;
185206
186207 fn try_from ( value : TestRunnerConfig ) -> Result < Self , Self :: Error > {
@@ -193,6 +214,7 @@ impl<HardforkT: HardforkTr> TryFrom<TestRunnerConfig> for SolidityTestRunnerConf
193214 initial_balance,
194215 block_number,
195216 chain_id,
217+ hardfork,
196218 gas_limit,
197219 gas_price,
198220 block_base_fee_per_gas,
@@ -201,6 +223,7 @@ impl<HardforkT: HardforkTr> TryFrom<TestRunnerConfig> for SolidityTestRunnerConf
201223 block_difficulty,
202224 block_gas_limit,
203225 disable_block_gas_limit,
226+ enable_tx_gas_limit_cap,
204227 memory_limit,
205228 local_predeploys,
206229 fork_url,
@@ -224,6 +247,8 @@ impl<HardforkT: HardforkTr> TryFrom<TestRunnerConfig> for SolidityTestRunnerConf
224247
225248 evm_opts. env . chain_id = chain_id;
226249
250+ evm_opts. spec = parse_hardfork ( hardfork) ?;
251+
227252 evm_opts. env . gas_price = gas_price;
228253
229254 if let Some ( block_base_fee_per_gas) = block_base_fee_per_gas {
@@ -280,6 +305,10 @@ impl<HardforkT: HardforkTr> TryFrom<TestRunnerConfig> for SolidityTestRunnerConf
280305 evm_opts. disable_block_gas_limit = disable_block_gas_limit;
281306 }
282307
308+ if let Some ( enable_tx_gas_limit_cap) = enable_tx_gas_limit_cap {
309+ evm_opts. enable_tx_gas_limit_cap = enable_tx_gas_limit_cap;
310+ }
311+
283312 let local_predeploys = local_predeploys. unwrap_or_default ( ) ;
284313
285314 let generate_gas_report = generate_gas_report. unwrap_or ( false ) ;
0 commit comments