@@ -97,10 +97,10 @@ type Message interface {
97
97
// ExecutionResult includes all output after executing given evm
98
98
// message no matter the execution itself is successful or not.
99
99
type ExecutionResult struct {
100
- UsedGas uint64 // Total used gas, not including the refunded gas
101
- RefundedGas uint64 // Total gas refunded after execution
102
- Err error // Any error encountered during the execution(listed in core/vm/errors.go)
103
- ReturnData []byte // Returned data from evm(function result or data supplied with revert opcode)
100
+ UsedGas uint64 // Total used gas, not including the refunded gas
101
+ MaxUsedGas uint64 // Maximum gas consumed during execution, excluding gas refunds.
102
+ Err error // Any error encountered during the execution(listed in core/vm/errors.go)
103
+ ReturnData []byte // Returned data from evm(function result or data supplied with revert opcode)
104
104
}
105
105
106
106
// Unwrap returns the internal evm error which allows us for further
@@ -502,16 +502,22 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) {
502
502
ret , st .gas , vmerr = st .evm .Call (sender , st .to (), st .data , st .gas , st .value )
503
503
}
504
504
505
- var gasRefund uint64
505
+ var peakGasUsed uint64
506
506
if ! st .evm .Config .IsSystemTransaction {
507
+ // Record the gas used excluding gas refunds. This value represents the actual
508
+ // gas allowance required to complete execution.
509
+ peakGasUsed = st .gasUsed ()
510
+
507
511
// Compute refund counter, capped to a refund quotient.
508
- gasRefund = st .calcRefund ()
509
- st .gas += gasRefund
512
+ st .gas += st .calcRefund ()
510
513
if rules .IsPrague {
511
514
// After EIP-7623: Data-heavy transactions pay the floor gas.
512
515
if st .gasUsed () < floorDataGas {
513
516
st .gas = st .initialGas - floorDataGas
514
517
}
518
+ if peakGasUsed < floorDataGas {
519
+ peakGasUsed = floorDataGas
520
+ }
515
521
}
516
522
st .returnGas ()
517
523
@@ -539,10 +545,10 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) {
539
545
}
540
546
541
547
return & ExecutionResult {
542
- UsedGas : st .gasUsed (),
543
- RefundedGas : gasRefund ,
544
- Err : vmerr ,
545
- ReturnData : ret ,
548
+ UsedGas : st .gasUsed (),
549
+ MaxUsedGas : peakGasUsed ,
550
+ Err : vmerr ,
551
+ ReturnData : ret ,
546
552
}, nil
547
553
}
548
554
0 commit comments