1
+ use revm_interpreter:: gas:: InitialAndFloorGas ;
2
+
1
3
use crate :: {
2
4
builder:: { EvmBuilder , HandlerStage , SetGenericStage } ,
3
5
db:: { Database , DatabaseCommit , EmptyDB } ,
@@ -195,20 +197,20 @@ impl<EXT, DB: Database> Evm<'_, EXT, DB> {
195
197
/// This function will not validate the transaction.
196
198
#[ inline]
197
199
pub fn transact_preverified ( & mut self ) -> EVMResult < DB :: Error > {
198
- let initial_gas_spend = self
200
+ let init_and_floor_gas = self
199
201
. handler
200
202
. validation ( )
201
203
. initial_tx_gas ( & self . context . evm . env )
202
204
. inspect_err ( |_e| self . clear ( ) ) ?;
203
- let output = self . transact_preverified_inner ( initial_gas_spend ) ;
205
+ let output = self . transact_preverified_inner ( init_and_floor_gas ) ;
204
206
let output = self . handler . post_execution ( ) . end ( & mut self . context , output) ;
205
207
self . clear ( ) ;
206
208
output
207
209
}
208
210
209
211
/// Pre verify transaction inner.
210
212
#[ inline]
211
- fn preverify_transaction_inner ( & mut self ) -> Result < u64 , EVMError < DB :: Error > > {
213
+ fn preverify_transaction_inner ( & mut self ) -> Result < InitialAndFloorGas , EVMError < DB :: Error > > {
212
214
self . handler . validation ( ) . env ( & self . context . evm . env ) ?;
213
215
let initial_gas_spend = self
214
216
. handler
@@ -225,11 +227,11 @@ impl<EXT, DB: Database> Evm<'_, EXT, DB> {
225
227
/// This function will validate the transaction.
226
228
#[ inline]
227
229
pub fn transact ( & mut self ) -> EVMResult < DB :: Error > {
228
- let initial_gas_spend = self
230
+ let init_and_floor_gas = self
229
231
. preverify_transaction_inner ( )
230
232
. inspect_err ( |_e| self . clear ( ) ) ?;
231
233
232
- let output = self . transact_preverified_inner ( initial_gas_spend ) ;
234
+ let output = self . transact_preverified_inner ( init_and_floor_gas ) ;
233
235
let output = self . handler . post_execution ( ) . end ( & mut self . context , output) ;
234
236
self . clear ( ) ;
235
237
output
@@ -319,7 +321,7 @@ impl<EXT, DB: Database> Evm<'_, EXT, DB> {
319
321
}
320
322
321
323
/// Transact pre-verified transaction.
322
- fn transact_preverified_inner ( & mut self , initial_gas_spend : u64 ) -> EVMResult < DB :: Error > {
324
+ fn transact_preverified_inner ( & mut self , gas : InitialAndFloorGas ) -> EVMResult < DB :: Error > {
323
325
let spec_id = self . spec_id ( ) ;
324
326
let ctx = & mut self . context ;
325
327
let pre_exec = self . handler . pre_execution ( ) ;
@@ -334,7 +336,7 @@ impl<EXT, DB: Database> Evm<'_, EXT, DB> {
334
336
// deduce caller balance with its limit.
335
337
pre_exec. deduct_caller ( ctx) ?;
336
338
337
- let gas_limit = ctx. evm . env . tx . gas_limit - initial_gas_spend ;
339
+ let gas_limit = ctx. evm . env . tx . gas_limit - gas . initial_gas ;
338
340
339
341
// apply EIP-7702 auth list.
340
342
let eip7702_gas_refund = pre_exec. apply_eip7702_auth_list ( ctx) ? as i64 ;
@@ -378,6 +380,13 @@ impl<EXT, DB: Database> Evm<'_, EXT, DB> {
378
380
. execution ( )
379
381
. last_frame_return ( ctx, & mut result) ?;
380
382
383
+ // EIP-7623: Increase calldata cost
384
+ // spend at least a gas_floor amount of gas.
385
+ let gas_result = result. gas_mut ( ) ;
386
+ if gas_result. spent ( ) < gas. floor_gas {
387
+ let _ = gas_result. record_cost ( gas. floor_gas - gas_result. spent ( ) ) ;
388
+ }
389
+
381
390
let post_exec = self . handler . post_execution ( ) ;
382
391
// calculate final refund and add EIP-7702 refund to gas.
383
392
post_exec. refund ( ctx, result. gas_mut ( ) , eip7702_gas_refund) ;
0 commit comments