Skip to content
This repository was archived by the owner on Nov 25, 2025. It is now read-only.

Commit b0430f8

Browse files
Improve plugin/evm/header tests (#816)
1 parent e305d2d commit b0430f8

17 files changed

+686
-355
lines changed

eth/api_backend.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ func (b *EthAPIBackend) StateAtTransaction(ctx context.Context, block *types.Blo
522522
}
523523

524524
func (b *EthAPIBackend) MinRequiredTip(ctx context.Context, header *types.Header) (*big.Int, error) {
525-
return customheader.MinRequiredTip(b.ChainConfig(), header)
525+
return customheader.EstimateRequiredTip(b.ChainConfig(), header)
526526
}
527527

528528
func (b *EthAPIBackend) isLatestAndAllowed(number rpc.BlockNumber) bool {

eth/gasprice/gasprice_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ func newTestBackend(t *testing.T, config *params.ChainConfig, numBlocks int, ext
152152
}
153153

154154
func (b *testBackend) MinRequiredTip(ctx context.Context, header *types.Header) (*big.Int, error) {
155-
return customheader.MinRequiredTip(b.chain.Config(), header)
155+
return customheader.EstimateRequiredTip(b.chain.Config(), header)
156156
}
157157

158158
func (b *testBackend) CurrentHeader() *types.Header {

plugin/evm/ap3/window.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ package ap3
77
import (
88
"math"
99

10-
"github.com/ava-labs/coreth/params"
10+
"github.com/ava-labs/coreth/utils"
1111
safemath "github.com/ethereum/go-ethereum/common/math"
1212
)
1313

@@ -19,13 +19,13 @@ const (
1919
// upgrade.
2020
//
2121
// This value was modified in Apricot Phase 4.
22-
MinBaseFee = 75 * params.GWei
22+
MinBaseFee = 75 * utils.GWei
2323

2424
// MaxBaseFee is the maximum base fee that is allowed after Apricot Phase 3
2525
// upgrade.
2626
//
2727
// This value was modified in Apricot Phase 4.
28-
MaxBaseFee = 225 * params.GWei
28+
MaxBaseFee = 225 * utils.GWei
2929

3030
// InitialBaseFee is the base fee that is used for the first Apricot Phase 3
3131
// block.

plugin/evm/ap4/cost.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"math"
1010

1111
safemath "github.com/ava-labs/avalanchego/utils/math"
12-
"github.com/ava-labs/coreth/params"
12+
"github.com/ava-labs/coreth/utils"
1313
)
1414

1515
const (
@@ -36,13 +36,13 @@ const (
3636
// This value modifies the previously used `ap3.MinBaseFee`.
3737
//
3838
// This value was modified in Etna.
39-
MinBaseFee = 25 * params.GWei
39+
MinBaseFee = 25 * utils.GWei
4040

4141
// MaxBaseFee is the maximum base fee that is allowed after Apricot Phase 3
4242
// upgrade.
4343
//
4444
// This value modifies the previously used `ap3.MaxBaseFee`.
45-
MaxBaseFee = 1_000 * params.GWei
45+
MaxBaseFee = 1_000 * utils.GWei
4646
)
4747

4848
// BlockGasCost calculates the required block gas cost.

plugin/evm/export_tx_test.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"github.com/ava-labs/avalanchego/vms/secp256k1fx"
2020
"github.com/ava-labs/coreth/params"
2121
"github.com/ava-labs/coreth/plugin/evm/atomic"
22+
"github.com/ava-labs/coreth/utils"
2223
"github.com/ethereum/go-ethereum/common"
2324
"github.com/holiman/uint256"
2425
)
@@ -1491,7 +1492,7 @@ func TestExportTxGasCost(t *testing.T) {
14911492
Keys: [][]*secp256k1.PrivateKey{{testKeys[0]}},
14921493
ExpectedGasUsed: 1230,
14931494
ExpectedFee: 30750,
1494-
BaseFee: big.NewInt(25 * params.GWei),
1495+
BaseFee: big.NewInt(25 * utils.GWei),
14951496
},
14961497
"simple export 225Gwei BaseFee": {
14971498
UnsignedExportTx: &atomic.UnsignedExportTx{
@@ -1523,7 +1524,7 @@ func TestExportTxGasCost(t *testing.T) {
15231524
Keys: [][]*secp256k1.PrivateKey{{testKeys[0]}},
15241525
ExpectedGasUsed: 1230,
15251526
ExpectedFee: 276750,
1526-
BaseFee: big.NewInt(225 * params.GWei),
1527+
BaseFee: big.NewInt(225 * utils.GWei),
15271528
},
15281529
"complex export 25Gwei BaseFee": {
15291530
UnsignedExportTx: &atomic.UnsignedExportTx{
@@ -1567,7 +1568,7 @@ func TestExportTxGasCost(t *testing.T) {
15671568
Keys: [][]*secp256k1.PrivateKey{{testKeys[0], testKeys[0], testKeys[0]}},
15681569
ExpectedGasUsed: 3366,
15691570
ExpectedFee: 84150,
1570-
BaseFee: big.NewInt(25 * params.GWei),
1571+
BaseFee: big.NewInt(25 * utils.GWei),
15711572
},
15721573
"complex export 225Gwei BaseFee": {
15731574
UnsignedExportTx: &atomic.UnsignedExportTx{
@@ -1611,7 +1612,7 @@ func TestExportTxGasCost(t *testing.T) {
16111612
Keys: [][]*secp256k1.PrivateKey{{testKeys[0], testKeys[0], testKeys[0]}},
16121613
ExpectedGasUsed: 3366,
16131614
ExpectedFee: 757350,
1614-
BaseFee: big.NewInt(225 * params.GWei),
1615+
BaseFee: big.NewInt(225 * utils.GWei),
16151616
},
16161617
}
16171618

plugin/evm/gossip_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"github.com/ava-labs/coreth/core/types"
1919
"github.com/ava-labs/coreth/core/vm"
2020
"github.com/ava-labs/coreth/params"
21+
"github.com/ava-labs/coreth/utils"
2122
"github.com/ethereum/go-ethereum/common"
2223
"github.com/ethereum/go-ethereum/crypto"
2324
"github.com/prometheus/client_golang/prometheus"
@@ -67,7 +68,7 @@ func TestGossipSubscribe(t *testing.T) {
6768
}, 10*time.Second, 500*time.Millisecond, "expected gossipTxPool to be subscribed")
6869

6970
// create eth txs
70-
ethTxs := getValidEthTxs(key, 10, big.NewInt(226*params.GWei))
71+
ethTxs := getValidEthTxs(key, 10, big.NewInt(226*utils.GWei))
7172

7273
// Notify mempool about txs
7374
errs := txPool.AddRemotesSync(ethTxs)

plugin/evm/header/base_fee.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@ var errEstimateBaseFeeWithoutActivation = errors.New("cannot estimate base fee f
1717
// calculates the expected base fee for the child block.
1818
//
1919
// Prior to AP3, the returned base fee will be nil.
20-
func BaseFee(config *params.ChainConfig, parent *types.Header, timestamp uint64) (*big.Int, error) {
20+
func BaseFee(
21+
config *params.ChainConfig,
22+
parent *types.Header,
23+
timestamp uint64,
24+
) (*big.Int, error) {
2125
switch {
2226
case config.IsApricotPhase3(timestamp):
2327
return baseFeeFromWindow(config, parent, timestamp)
@@ -35,7 +39,11 @@ func BaseFee(config *params.ChainConfig, parent *types.Header, timestamp uint64)
3539
//
3640
// Warning: This function should only be used in estimation and should not be
3741
// used when calculating the canonical base fee for a block.
38-
func EstimateNextBaseFee(config *params.ChainConfig, parent *types.Header, timestamp uint64) (*big.Int, error) {
42+
func EstimateNextBaseFee(
43+
config *params.ChainConfig,
44+
parent *types.Header,
45+
timestamp uint64,
46+
) (*big.Int, error) {
3947
if config.ApricotPhase3BlockTimestamp == nil {
4048
return nil, errEstimateBaseFeeWithoutActivation
4149
}

0 commit comments

Comments
 (0)