Skip to content

Commit 9c6f9cc

Browse files
ceyonurStephenButtolphrichardpringleDarioush Jalali
authored
Merge master 6a9db20 (#821)
Co-authored-by: Stephen Buttolph <[email protected]> Co-authored-by: Richard Pringle <[email protected]> Co-authored-by: Darioush Jalali <[email protected]>
1 parent d14bfd0 commit 9c6f9cc

File tree

18 files changed

+180
-70
lines changed

18 files changed

+180
-70
lines changed

consensus/dummy/dynamic_fees.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"github.com/ava-labs/coreth/params"
1313
"github.com/ava-labs/coreth/params/extras"
1414
"github.com/ava-labs/coreth/plugin/evm/ap4"
15+
"github.com/ava-labs/coreth/plugin/evm/ap5"
1516
"github.com/ava-labs/coreth/plugin/evm/header"
1617
"github.com/ava-labs/libevm/common"
1718
"github.com/ava-labs/libevm/common/math"
@@ -31,7 +32,7 @@ var (
3132
EtnaMinBaseFee = big.NewInt(params.EtnaMinBaseFee)
3233

3334
ApricotPhase3BaseFeeChangeDenominator = new(big.Int).SetUint64(params.ApricotPhase3BaseFeeChangeDenominator)
34-
ApricotPhase5BaseFeeChangeDenominator = new(big.Int).SetUint64(params.ApricotPhase5BaseFeeChangeDenominator)
35+
ApricotPhase5BaseFeeChangeDenominator = big.NewInt(ap5.BaseFeeChangeDenominator)
3536

3637
errEstimateBaseFeeWithoutActivation = errors.New("cannot estimate base fee for chain without apricot phase 3 scheduled")
3738
)
@@ -94,7 +95,7 @@ func calcBaseFeeWithWindow(config *extras.ChainConfig, parent *types.Header, tim
9495
)
9596
if isApricotPhase5 {
9697
baseFeeChangeDenominator = ApricotPhase5BaseFeeChangeDenominator
97-
parentGasTarget = params.ApricotPhase5TargetGas
98+
parentGasTarget = ap5.TargetGas
9899
}
99100

100101
// Calculate the amount of gas consumed within the rollup window.

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.23.6
44

55
require (
66
github.com/VictoriaMetrics/fastcache v1.12.1
7-
github.com/ava-labs/avalanchego v1.12.3-0.20250219020546-daac8c8bbd8c
7+
github.com/ava-labs/avalanchego v1.12.3-0.20250220150250-9e886ffca1ba
88
github.com/ava-labs/libevm v1.13.14-0.2.0.rc.3
99
github.com/crate-crypto/go-ipa v0.0.0-20231025140028-3c0104f4b233
1010
github.com/davecgh/go-spew v1.1.1

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY
5656
github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156 h1:eMwmnE/GDgah4HI848JfFxHt+iPb26b4zyfspmqY0/8=
5757
github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM=
5858
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
59-
github.com/ava-labs/avalanchego v1.12.3-0.20250219020546-daac8c8bbd8c h1:LAKh2eokSOtM5TRiMtGnl+vaTJa72dL/i/ZitSMR23w=
60-
github.com/ava-labs/avalanchego v1.12.3-0.20250219020546-daac8c8bbd8c/go.mod h1:5e246cVO15EOZp7q3Dx2wRznTXMUgLrbWgnAd1RNgKU=
59+
github.com/ava-labs/avalanchego v1.12.3-0.20250220150250-9e886ffca1ba h1:VTGpl5PwfPo9046h6x7BvtjDGxEAPreNwaWK/0dwyFk=
60+
github.com/ava-labs/avalanchego v1.12.3-0.20250220150250-9e886ffca1ba/go.mod h1:oURZGkQSIWOGBqP2Lirf768MVAePVGdvYQfmHUZS4aE=
6161
github.com/ava-labs/libevm v1.13.14-0.2.0.rc.3 h1:1CWGo2icnX9dRqGQl7CFywYGIZWxe+ucy0w8NAsVTWE=
6262
github.com/ava-labs/libevm v1.13.14-0.2.0.rc.3/go.mod h1:+Iol+sVQ1KyoBsHf3veyrBmHCXr3xXRWq6ZXkgVfNLU=
6363
github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g=

params/avalanche_params.go

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
package params
55

66
import (
7-
"math/big"
8-
97
"github.com/ava-labs/avalanchego/utils/wrappers"
108
)
119

@@ -19,27 +17,13 @@ const (
1917
ApricotPhase1GasLimit uint64 = 8_000_000
2018
CortinaGasLimit uint64 = 15_000_000
2119

22-
ApricotPhase3MinBaseFee int64 = 75 * GWei
23-
ApricotPhase3MaxBaseFee = 225 * GWei
24-
ApricotPhase3InitialBaseFee int64 = 225 * GWei
25-
ApricotPhase3TargetGas = 10_000_000
26-
ApricotPhase3BaseFeeChangeDenominator = 12
27-
ApricotPhase5TargetGas = 15_000_000
28-
ApricotPhase5BaseFeeChangeDenominator uint64 = 36
29-
EtnaMinBaseFee int64 = GWei
20+
ApricotPhase3MinBaseFee int64 = 75 * GWei
21+
ApricotPhase3MaxBaseFee = 225 * GWei
22+
ApricotPhase3InitialBaseFee int64 = 225 * GWei
23+
ApricotPhase3TargetGas = 10_000_000
24+
ApricotPhase3BaseFeeChangeDenominator = 12
25+
EtnaMinBaseFee int64 = GWei
3026

3127
RollupWindow = 10 // in seconds
3228
DynamicFeeExtraDataSize = wrappers.LongLen * RollupWindow
33-
34-
// The base cost to charge per atomic transaction. Added in Apricot Phase 5.
35-
AtomicTxBaseCost uint64 = 10_000
3629
)
37-
38-
// The atomic gas limit specifies the maximum amount of gas that can be consumed by the atomic
39-
// transactions included in a block and is enforced as of ApricotPhase5. Prior to ApricotPhase5,
40-
// a block included a single atomic transaction. As of ApricotPhase5, each block can include a set
41-
// of atomic transactions where the cumulative atomic gas consumed is capped by the atomic gas limit,
42-
// similar to the block gas limit.
43-
//
44-
// This value must always remain <= MaxUint64.
45-
var AtomicGasLimit *big.Int = big.NewInt(100_000)

plugin/evm/ap5/params.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// (c) 2025, Ava Labs, Inc. All rights reserved.
2+
// See the file LICENSE for licensing terms.
3+
4+
// AP5 defines constants used after the Apricot Phase 5 upgrade.
5+
package ap5
6+
7+
const (
8+
// BlockGasCostStep is the rate at which the block gas cost changes per
9+
// second.
10+
//
11+
// This value modifies the previously used `ap4.BlockGasCostStep`.
12+
BlockGasCostStep = 200_000
13+
14+
// TargetGas is the target amount of gas to be included in the window. The
15+
// target amount of gas per second equals [TargetGas] / `ap3.WindowLen`.
16+
//
17+
// This value modifies the previously used `ap3.TargetGas`.
18+
TargetGas = 15_000_000
19+
20+
// BaseFeeChangeDenominator is the denominator used to smoothen base fee
21+
// changes.
22+
//
23+
// This value modifies the previously used `ap3.BaseFeeChangeDenominator`.
24+
BaseFeeChangeDenominator = 36
25+
26+
// AtomicGasLimit specifies the maximum amount of gas that can be consumed
27+
// by the atomic transactions included in a block.
28+
//
29+
// Prior to Apricot Phase 5, a block included a single atomic transaction.
30+
// As of Apricot Phase 5, each block can include a set of atomic
31+
// transactions where the cumulative atomic gas consumed is capped by the
32+
// atomic gas limit, similar to the block gas limit.
33+
AtomicGasLimit = 100_000
34+
35+
// AtomicTxIntrinsicGas is the base amount of gas to charge per atomic
36+
// transaction. There are additional gas costs that can be charged per
37+
// transaction.
38+
AtomicTxIntrinsicGas = 10_000
39+
)

plugin/evm/atomic/export_tx.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"math/big"
1111

1212
"github.com/ava-labs/coreth/params/extras"
13+
"github.com/ava-labs/coreth/plugin/evm/ap5"
1314
"github.com/holiman/uint256"
1415

1516
"github.com/ava-labs/avalanchego/chains/atomic"
@@ -142,7 +143,7 @@ func (utx *UnsignedExportTx) GasUsed(fixedFee bool) (uint64, error) {
142143
return 0, err
143144
}
144145
if fixedFee {
145-
cost, err = math.Add64(cost, AtomicTxBaseCost)
146+
cost, err = math.Add64(cost, ap5.AtomicTxIntrinsicGas)
146147
if err != nil {
147148
return 0, err
148149
}

plugin/evm/atomic/import_tx.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"slices"
1212

1313
"github.com/ava-labs/coreth/params/extras"
14+
"github.com/ava-labs/coreth/plugin/evm/ap5"
1415
"github.com/holiman/uint256"
1516

1617
"github.com/ava-labs/avalanchego/chains/atomic"
@@ -150,7 +151,7 @@ func (utx *UnsignedImportTx) GasUsed(fixedFee bool) (uint64, error) {
150151
}
151152
}
152153
if fixedFee {
153-
cost, err = math.Add64(cost, AtomicTxBaseCost)
154+
cost, err = math.Add64(cost, ap5.AtomicTxIntrinsicGas)
154155
if err != nil {
155156
return 0, err
156157
}

plugin/evm/block_verification.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,16 @@ import (
99
"math/big"
1010

1111
"github.com/ava-labs/libevm/common"
12+
"github.com/ava-labs/libevm/trie"
1213

1314
safemath "github.com/ava-labs/avalanchego/utils/math"
1415

1516
"github.com/ava-labs/coreth/constants"
1617
"github.com/ava-labs/coreth/core/types"
1718
"github.com/ava-labs/coreth/params"
19+
"github.com/ava-labs/coreth/plugin/evm/ap5"
1820
"github.com/ava-labs/coreth/plugin/evm/header"
19-
"github.com/ava-labs/libevm/trie"
21+
"github.com/ava-labs/coreth/utils"
2022
)
2123

2224
var (
@@ -199,7 +201,7 @@ func (v blockValidator) SyntacticVerify(b *Block, rules params.Rules) error {
199201
return errNilExtDataGasUsedApricotPhase4
200202
}
201203
if rulesExtra.IsApricotPhase5 {
202-
if ethHeader.ExtDataGasUsed.Cmp(params.AtomicGasLimit) == 1 {
204+
if !utils.BigLessOrEqualUint64(ethHeader.ExtDataGasUsed, ap5.AtomicGasLimit) {
203205
return fmt.Errorf("too large extDataGasUsed: %d", ethHeader.ExtDataGasUsed)
204206
}
205207
} else {

plugin/evm/header/block_gas_cost.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,9 @@ import (
99
"github.com/ava-labs/coreth/core/types"
1010
"github.com/ava-labs/coreth/params/extras"
1111
"github.com/ava-labs/coreth/plugin/evm/ap4"
12+
"github.com/ava-labs/coreth/plugin/evm/ap5"
1213
)
1314

14-
// ApricotPhase5BlockGasCostStep is the rate at which the block gas cost changes
15-
// per second as of the Apricot Phase 5 upgrade.
16-
//
17-
// This value modifies the previously used [ap4.BlockGasCostStep].
18-
const ApricotPhase5BlockGasCostStep = 200_000
19-
2015
// BlockGasCost calculates the required block gas cost based on the parent
2116
// header and the timestamp of the new block.
2217
func BlockGasCost(
@@ -26,7 +21,7 @@ func BlockGasCost(
2621
) uint64 {
2722
step := uint64(ap4.BlockGasCostStep)
2823
if config.IsApricotPhase5(timestamp) {
29-
step = ApricotPhase5BlockGasCostStep
24+
step = ap5.BlockGasCostStep
3025
}
3126
// Treat an invalid parent/current time combination as 0 elapsed time.
3227
//

plugin/evm/header/block_gas_cost_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"github.com/ava-labs/coreth/core/types"
1111
"github.com/ava-labs/coreth/params/extras"
1212
"github.com/ava-labs/coreth/plugin/evm/ap4"
13+
"github.com/ava-labs/coreth/plugin/evm/ap5"
1314
"github.com/ava-labs/coreth/utils"
1415
"github.com/stretchr/testify/assert"
1516
)
@@ -36,7 +37,7 @@ func TestBlockGasCost(t *testing.T) {
3637
parentTime: 10,
3738
parentCost: big.NewInt(ap4.MaxBlockGasCost),
3839
timestamp: 10 + ap4.TargetBlockRate + 1,
39-
expected: ap4.MaxBlockGasCost - ApricotPhase5BlockGasCostStep,
40+
expected: ap4.MaxBlockGasCost - ap5.BlockGasCostStep,
4041
},
4142
{
4243
name: "negative_time_elapsed",

0 commit comments

Comments
 (0)