74
74
context : & Self :: Context ,
75
75
) -> Result < InitialAndFloorGas , Self :: Error > {
76
76
let spec = context. cfg ( ) . spec ( ) . into ( ) ;
77
- validate_initial_tx_gas :: < & Self :: Context , InvalidTransaction > ( context, spec)
78
- . map_err ( Into :: into)
77
+ validate_initial_tx_gas ( context. tx ( ) , spec) . map_err ( From :: from)
79
78
}
80
79
}
81
80
@@ -333,16 +332,13 @@ where
333
332
}
334
333
335
334
/// Validate initial transaction gas.
336
- pub fn validate_initial_tx_gas < CTX , Error > (
337
- context : CTX ,
335
+ pub fn validate_initial_tx_gas < TransactionT > (
336
+ tx : TransactionT ,
338
337
spec_id : SpecId ,
339
- ) -> Result < InitialAndFloorGas , Error >
338
+ ) -> Result < InitialAndFloorGas , InvalidTransaction >
340
339
where
341
- CTX : TransactionGetter + CfgGetter ,
342
- Error : From < InvalidTransaction > ,
340
+ TransactionT : Transaction ,
343
341
{
344
- let spec = context. cfg ( ) . spec ( ) . into ( ) ;
345
- let tx = context. tx ( ) ;
346
342
let ( accounts, storages) = tx. access_list_nums ( ) . unwrap_or_default ( ) ;
347
343
348
344
let gas = gas:: calculate_initial_tx_gas (
@@ -356,13 +352,13 @@ where
356
352
357
353
// Additional check to see if limit is big enough to cover initial gas.
358
354
if gas. initial_gas > tx. gas_limit ( ) {
359
- return Err ( InvalidTransaction :: CallGasCostMoreThanGasLimit . into ( ) ) ;
355
+ return Err ( InvalidTransaction :: CallGasCostMoreThanGasLimit ) ;
360
356
}
361
357
362
358
// EIP-7623: Increase calldata cost
363
359
// floor gas should be less than gas limit.
364
- if spec . is_enabled_in ( SpecId :: PRAGUE ) && gas. floor_gas > tx. gas_limit ( ) {
365
- return Err ( InvalidTransaction :: GasFloorMoreThanGasLimit . into ( ) ) ;
360
+ if spec_id . is_enabled_in ( SpecId :: PRAGUE ) && gas. floor_gas > tx. gas_limit ( ) {
361
+ return Err ( InvalidTransaction :: GasFloorMoreThanGasLimit ) ;
366
362
} ;
367
363
368
364
Ok ( gas)
0 commit comments