Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions core/parallel_state_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,22 @@ func (p *ParallelStateProcessor) prepareExecResult(block *types.Block, allStateR
return cmp.Compare(a.TransactionIndex, b.TransactionIndex)
})

var cumulativeGasUsed uint64
var (
// cumulativeGasUsed tracks post-refund gas for receipt.CumulativeGasUsed
cumulativeGasUsed uint64
// blockGasUsed tracks pre-refund gas (receipt.GasUsed = MaxUsedGas for Amsterdam)
// for block header and gas limit validation per EIP-7778
blockGasUsed uint64
)
var allLogs []*types.Log
for _, receipt := range receipts {
receipt.CumulativeGasUsed = cumulativeGasUsed + receipt.GasUsed
cumulativeGasUsed += receipt.GasUsed
if receipt.CumulativeGasUsed > header.GasLimit {
// receipt.CumulativeGasUsed holds this tx's post-refund gas (result.UsedGas)
// since execTx called ApplyTransactionWithEVM with cumulativeGas=0
cumulativeGasUsed += receipt.CumulativeGasUsed
receipt.CumulativeGasUsed = cumulativeGasUsed
// receipt.GasUsed is pre-refund (MaxUsedGas for Amsterdam) for block accounting
blockGasUsed += receipt.GasUsed
if blockGasUsed > header.GasLimit {
return &ProcessResultWithMetrics{
ProcessResult: &ProcessResult{Error: fmt.Errorf("gas limit exceeded")},
}
Expand Down Expand Up @@ -148,7 +158,7 @@ func (p *ParallelStateProcessor) prepareExecResult(block *types.Block, allStateR
Receipts: receipts,
Requests: requests,
Logs: allLogs,
GasUsed: cumulativeGasUsed,
GasUsed: blockGasUsed,
},
PostProcessTime: tPostprocess,
ExecTime: tExec,
Expand Down
Loading