@@ -34,10 +34,10 @@ import (
34
34
// ExecutionResult includes all output after executing given evm
35
35
// message no matter the execution itself is successful or not.
36
36
type ExecutionResult struct {
37
- UsedGas uint64 // Total used gas, not including the refunded gas
38
- RefundedGas uint64 // Total gas refunded after execution
39
- Err error // Any error encountered during the execution(listed in core/vm/errors.go)
40
- ReturnData []byte // Returned data from evm(function result or data supplied with revert opcode)
37
+ UsedGas uint64 // Total used gas, not including the refunded gas
38
+ MaxUsedGas uint64 // Maximum gas consumed during execution, excluding gas refunds.
39
+ Err error // Any error encountered during the execution(listed in core/vm/errors.go)
40
+ ReturnData []byte // Returned data from evm(function result or data supplied with revert opcode)
41
41
}
42
42
43
43
// Unwrap returns the internal evm error which allows us for further
@@ -509,9 +509,12 @@ func (st *stateTransition) execute() (*ExecutionResult, error) {
509
509
ret , st .gasRemaining , vmerr = st .evm .Call (msg .From , st .to (), msg .Data , st .gasRemaining , value )
510
510
}
511
511
512
+ // Record the gas used excluding gas refunds. This value represents the actual
513
+ // gas allowance required to complete execution.
514
+ peakGasUsed := st .gasUsed ()
515
+
512
516
// Compute refund counter, capped to a refund quotient.
513
- gasRefund := st .calcRefund ()
514
- st .gasRemaining += gasRefund
517
+ st .gasRemaining += st .calcRefund ()
515
518
if rules .IsPrague {
516
519
// After EIP-7623: Data-heavy transactions pay the floor gas.
517
520
if st .gasUsed () < floorDataGas {
@@ -521,6 +524,9 @@ func (st *stateTransition) execute() (*ExecutionResult, error) {
521
524
t .OnGasChange (prev , st .gasRemaining , tracing .GasChangeTxDataFloor )
522
525
}
523
526
}
527
+ if peakGasUsed < floorDataGas {
528
+ peakGasUsed = floorDataGas
529
+ }
524
530
}
525
531
st .returnGas ()
526
532
@@ -549,10 +555,10 @@ func (st *stateTransition) execute() (*ExecutionResult, error) {
549
555
}
550
556
551
557
return & ExecutionResult {
552
- UsedGas : st .gasUsed (),
553
- RefundedGas : gasRefund ,
554
- Err : vmerr ,
555
- ReturnData : ret ,
558
+ UsedGas : st .gasUsed (),
559
+ MaxUsedGas : peakGasUsed ,
560
+ Err : vmerr ,
561
+ ReturnData : ret ,
556
562
}, nil
557
563
}
558
564
0 commit comments