Skip to content

Commit ed2e4d2

Browse files
trianglesphereprotolambda
authored andcommitted
core: Include guaranteed gas in the gas pool (ethereum#21)
This now requires L1 to limit the total amount of guaranteed gas that is provided to deposits. This includes the guaranteed gas in the total gas used in order to limit the number of normal transactions in a block and enable accurate EIP-1559 basefee updates.
1 parent db3c30f commit ed2e4d2

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

core/state_transition.go

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) {
301301
// Even though we revert the state changes, always increment the nonce for the next deposit transaction
302302
st.state.SetNonce(st.msg.From(), st.state.GetNonce(st.msg.From())+1)
303303
result = &ExecutionResult{
304-
UsedGas: 0, // No gas charge on non-EVM fails like balance checks, congestion is controlled on L1
304+
UsedGas: st.msg.Gas(), // Always record the deposit using the full amount of gas
305305
Err: fmt.Errorf("failed deposit: %w", err),
306306
ReturnData: nil,
307307
}
@@ -341,17 +341,15 @@ func (st *StateTransition) innerTransitionDb() (*ExecutionResult, error) {
341341
contractCreation = msg.To() == nil
342342
)
343343

344-
if st.msg.Nonce() != types.DepositsNonce {
345-
// Check clauses 4-5, subtract intrinsic gas if everything is correct
346-
gas, err := IntrinsicGas(st.data, st.msg.AccessList(), contractCreation, rules.IsHomestead, rules.IsIstanbul)
347-
if err != nil {
348-
return nil, err
349-
}
350-
if st.gas < gas {
351-
return nil, fmt.Errorf("%w: have %d, want %d", ErrIntrinsicGas, st.gas, gas)
352-
}
353-
st.gas -= gas
344+
// Check clauses 4-5, subtract intrinsic gas if everything is correct
345+
gas, err := IntrinsicGas(st.data, st.msg.AccessList(), contractCreation, rules.IsHomestead, rules.IsIstanbul)
346+
if err != nil {
347+
return nil, err
348+
}
349+
if st.gas < gas {
350+
return nil, fmt.Errorf("%w: have %d, want %d", ErrIntrinsicGas, st.gas, gas)
354351
}
352+
st.gas -= gas
355353

356354
// Check clause 6
357355
if msg.Value().Sign() > 0 && !st.evm.Context.CanTransfer(st.state, msg.From(), msg.Value()) {
@@ -377,7 +375,7 @@ func (st *StateTransition) innerTransitionDb() (*ExecutionResult, error) {
377375
// if deposit: skip refunds, skip tipping coinbase
378376
if st.msg.Nonce() == types.DepositsNonce {
379377
return &ExecutionResult{
380-
UsedGas: 0, // Ignore actual used gas for deposits (until full deposit gas design is done)
378+
UsedGas: st.msg.Gas(), // Always record the deposit using the full amount of gas
381379
Err: vmerr,
382380
ReturnData: ret,
383381
}, nil

0 commit comments

Comments
 (0)