Skip to content

Commit 58a95fc

Browse files
authored
fix(eip8037): keep eip7702 reservoir refund out of gross tx state gas (#3633)
Per the spec, tx_state_gas = intrinsic_state_gas + execution_state_gas. The EIP-7702 reservoir refund is added back to the state gas reservoir at tx start, so it must not also be subtracted from the gross state gas reported in the result.
1 parent 3ed3bdf commit 58a95fc

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

crates/handler/src/post_execution.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,12 @@ pub fn build_result_gas(gas: &Gas, init_and_floor_gas: InitialAndFloorGas) -> Re
5151
// negative on 0→x→0 restoration; at the top level, post-reconciliation it
5252
// is expected to be >= 0 and is clamped defensively before combining with
5353
// intrinsic state gas.
54+
//
55+
// Per the spec, tx_state_gas = intrinsic_state_gas + execution_state_gas.
56+
// The EIP-7702 reservoir refund is added back to the reservoir budget at
57+
// tx start; it does not reduce the gross state gas spent reported here.
5458
let state_gas = (gas.state_gas_spent().max(0) as u64)
55-
.saturating_add(init_and_floor_gas.initial_state_gas)
56-
.saturating_sub(init_and_floor_gas.eip7702_reservoir_refund);
59+
.saturating_add(init_and_floor_gas.initial_state_gas);
5760

5861
ResultGas::default()
5962
.with_total_gas_spent(

0 commit comments

Comments
 (0)