Skip to content

Commit 5eab822

Browse files
alarso16ceyonur
andauthored
sync: coreth PR #1215: skip verify block fee if is 0 (#1755)
Co-authored-by: Ceyhun Onur <ceyhun.onur@avalabs.org>
1 parent 28c4c0d commit 5eab822

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

plugin/evm/customheader/block_gas_cost.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,10 @@ func VerifyBlockFee(
134134
if requiredBlockGasCost == nil || !requiredBlockGasCost.IsUint64() {
135135
return fmt.Errorf("invalid block gas cost (%d) in apricot phase 4", requiredBlockGasCost)
136136
}
137+
// If the required block gas cost is 0, we don't need to verify the block fee
138+
if requiredBlockGasCost.Sign() == 0 {
139+
return nil
140+
}
137141

138142
var (
139143
gasUsed = new(big.Int)

plugin/evm/customheader/block_gas_cost_test.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
package customheader
55

66
import (
7+
"math"
78
"math/big"
89
"testing"
910

1011
"github.com/ava-labs/libevm/common"
11-
"github.com/ava-labs/libevm/common/math"
1212
"github.com/ava-labs/libevm/core/types"
1313
"github.com/stretchr/testify/assert"
1414
"github.com/stretchr/testify/require"
@@ -456,6 +456,14 @@ func TestVerifyBlockFee(t *testing.T) {
456456
extraStateContribution: nil,
457457
shouldErr: false,
458458
},
459+
"zero block gas cost": {
460+
baseFee: big.NewInt(100),
461+
parentBlockGasCost: big.NewInt(0),
462+
timeElapsed: testFeeConfig.TargetBlockRate + 1,
463+
txs: nil,
464+
receipts: nil,
465+
extraStateContribution: nil,
466+
},
459467
}
460468

461469
for name, test := range tests {

0 commit comments

Comments
 (0)