Skip to content

Commit

Permalink
rename etna (ava-labs#632)
Browse files Browse the repository at this point in the history
  • Loading branch information
ceyonur authored and oxbee committed Nov 6, 2024
1 parent 28d76e7 commit 6b65339
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 61 deletions.
8 changes: 4 additions & 4 deletions consensus/dummy/dynamic_fees.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ var (
ApricotPhase4MinBaseFee = big.NewInt(params.ApricotPhase4MinBaseFee)
ApricotPhase4MaxBaseFee = big.NewInt(params.ApricotPhase4MaxBaseFee)
ApricotPhase3InitialBaseFee = big.NewInt(params.ApricotPhase3InitialBaseFee)
EUpgradeMinBaseFee = big.NewInt(params.EUpgradeMinBaseFee)
EtnaMinBaseFee = big.NewInt(params.EtnaMinBaseFee)

ApricotPhase4BaseFeeChangeDenominator = new(big.Int).SetUint64(params.ApricotPhase4BaseFeeChangeDenominator)
ApricotPhase5BaseFeeChangeDenominator = new(big.Int).SetUint64(params.ApricotPhase5BaseFeeChangeDenominator)
Expand All @@ -46,7 +46,7 @@ func CalcBaseFee(config *params.ChainConfig, parent *types.Header, timestamp uin
isApricotPhase3 = config.IsApricotPhase3(parent.Time)
isApricotPhase4 = config.IsApricotPhase4(parent.Time)
isApricotPhase5 = config.IsApricotPhase5(parent.Time)
isEUpgrade = config.IsEUpgrade(parent.Time)
isEtna = config.IsEtna(parent.Time)
)
if !isApricotPhase3 || parent.Number.Cmp(common.Big0) == 0 {
initialSlice := make([]byte, params.DynamicFeeExtraDataSize)
Expand Down Expand Up @@ -179,8 +179,8 @@ func CalcBaseFee(config *params.ChainConfig, parent *types.Header, timestamp uin

// Ensure that the base fee does not increase/decrease outside of the bounds
switch {
case isEUpgrade:
baseFee = selectBigWithinBounds(EUpgradeMinBaseFee, baseFee, nil)
case isEtna:
baseFee = selectBigWithinBounds(EtnaMinBaseFee, baseFee, nil)
case isApricotPhase5:
baseFee = selectBigWithinBounds(ApricotPhase4MinBaseFee, baseFee, nil)
case isApricotPhase4:
Expand Down
8 changes: 4 additions & 4 deletions consensus/dummy/dynamic_fees_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -539,14 +539,14 @@ func TestCalcBlockGasCost(t *testing.T) {
}
}

func TestDynamicFeesEUpgrade(t *testing.T) {
func TestDynamicFeesEtna(t *testing.T) {
require := require.New(t)
header := &types.Header{
Number: big.NewInt(0),
}

timestamp := uint64(1)
extra, nextBaseFee, err := CalcBaseFee(params.TestEUpgradeChainConfig, header, timestamp)
extra, nextBaseFee, err := CalcBaseFee(params.TestEtnaChainConfig, header, timestamp)
require.NoError(err)
// Genesis matches the initial base fee
require.Equal(params.ApricotPhase3InitialBaseFee, nextBaseFee.Int64())
Expand All @@ -558,9 +558,9 @@ func TestDynamicFeesEUpgrade(t *testing.T) {
BaseFee: nextBaseFee,
Extra: extra,
}
_, nextBaseFee, err = CalcBaseFee(params.TestEUpgradeChainConfig, header, timestamp)
_, nextBaseFee, err = CalcBaseFee(params.TestEtnaChainConfig, header, timestamp)
require.NoError(err)
// After some time has passed in the EUpgrade phase, the base fee should drop
// After some time has passed in the Etna phase, the base fee should drop
// lower than the prior base fee minimum.
require.Less(nextBaseFee.Int64(), params.ApricotPhase4MinBaseFee)
}
6 changes: 3 additions & 3 deletions core/txpool/blobpool/blobpool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ func init() {

// overrideMinFee sets the minimum base fee to 1 wei for the duration of the test.
func overrideMinFee(t *testing.T) {
orig := dummy.EUpgradeMinBaseFee
dummy.EUpgradeMinBaseFee = big.NewInt(1)
t.Cleanup(func() { dummy.EUpgradeMinBaseFee = orig })
orig := dummy.EtnaMinBaseFee
dummy.EtnaMinBaseFee = big.NewInt(1)
t.Cleanup(func() { dummy.EtnaMinBaseFee = orig })
}

// testBlockChain is a mock of the live chain for testing the pool.
Expand Down
2 changes: 1 addition & 1 deletion params/avalanche_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const (
ApricotPhase4BaseFeeChangeDenominator uint64 = 12
ApricotPhase5TargetGas uint64 = 15_000_000
ApricotPhase5BaseFeeChangeDenominator uint64 = 36
EUpgradeMinBaseFee int64 = GWei
EtnaMinBaseFee int64 = GWei

DynamicFeeExtraDataSize = 80
RollupWindow uint64 = 10
Expand Down
50 changes: 25 additions & 25 deletions params/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ var (
BanffBlockTimestamp: utils.NewUint64(0),
CortinaBlockTimestamp: utils.NewUint64(0),
DurangoBlockTimestamp: utils.NewUint64(0),
EUpgradeTime: utils.NewUint64(0),
EtnaTime: utils.NewUint64(0),
}

TestLaunchConfig = &ChainConfig{
Expand Down Expand Up @@ -117,7 +117,7 @@ var (
BanffBlockTimestamp: nil,
CortinaBlockTimestamp: nil,
DurangoBlockTimestamp: nil,
EUpgradeTime: nil,
EtnaTime: nil,
}

TestApricotPhase1Config = &ChainConfig{
Expand Down Expand Up @@ -145,7 +145,7 @@ var (
BanffBlockTimestamp: nil,
CortinaBlockTimestamp: nil,
DurangoBlockTimestamp: nil,
EUpgradeTime: nil,
EtnaTime: nil,
}

TestApricotPhase2Config = &ChainConfig{
Expand Down Expand Up @@ -173,7 +173,7 @@ var (
BanffBlockTimestamp: nil,
CortinaBlockTimestamp: nil,
DurangoBlockTimestamp: nil,
EUpgradeTime: nil,
EtnaTime: nil,
}

TestApricotPhase3Config = &ChainConfig{
Expand Down Expand Up @@ -201,7 +201,7 @@ var (
BanffBlockTimestamp: nil,
CortinaBlockTimestamp: nil,
DurangoBlockTimestamp: nil,
EUpgradeTime: nil,
EtnaTime: nil,
}

TestApricotPhase4Config = &ChainConfig{
Expand Down Expand Up @@ -229,7 +229,7 @@ var (
BanffBlockTimestamp: nil,
CortinaBlockTimestamp: nil,
DurangoBlockTimestamp: nil,
EUpgradeTime: nil,
EtnaTime: nil,
}

TestApricotPhase5Config = &ChainConfig{
Expand Down Expand Up @@ -257,7 +257,7 @@ var (
BanffBlockTimestamp: nil,
CortinaBlockTimestamp: nil,
DurangoBlockTimestamp: nil,
EUpgradeTime: nil,
EtnaTime: nil,
}

TestApricotPhasePre6Config = &ChainConfig{
Expand Down Expand Up @@ -285,7 +285,7 @@ var (
BanffBlockTimestamp: nil,
CortinaBlockTimestamp: nil,
DurangoBlockTimestamp: nil,
EUpgradeTime: nil,
EtnaTime: nil,
}

TestApricotPhase6Config = &ChainConfig{
Expand Down Expand Up @@ -313,7 +313,7 @@ var (
BanffBlockTimestamp: nil,
CortinaBlockTimestamp: nil,
DurangoBlockTimestamp: nil,
EUpgradeTime: nil,
EtnaTime: nil,
}

TestApricotPhasePost6Config = &ChainConfig{
Expand Down Expand Up @@ -341,7 +341,7 @@ var (
BanffBlockTimestamp: nil,
CortinaBlockTimestamp: nil,
DurangoBlockTimestamp: nil,
EUpgradeTime: nil,
EtnaTime: nil,
}

TestBanffChainConfig = &ChainConfig{
Expand Down Expand Up @@ -369,7 +369,7 @@ var (
BanffBlockTimestamp: utils.NewUint64(0),
CortinaBlockTimestamp: nil,
DurangoBlockTimestamp: nil,
EUpgradeTime: nil,
EtnaTime: nil,
}

TestCortinaChainConfig = &ChainConfig{
Expand Down Expand Up @@ -397,7 +397,7 @@ var (
BanffBlockTimestamp: utils.NewUint64(0),
CortinaBlockTimestamp: utils.NewUint64(0),
DurangoBlockTimestamp: nil,
EUpgradeTime: nil,
EtnaTime: nil,
}

TestDurangoChainConfig = &ChainConfig{
Expand Down Expand Up @@ -425,10 +425,10 @@ var (
BanffBlockTimestamp: utils.NewUint64(0),
CortinaBlockTimestamp: utils.NewUint64(0),
DurangoBlockTimestamp: utils.NewUint64(0),
EUpgradeTime: nil,
EtnaTime: nil,
}

TestEUpgradeChainConfig = &ChainConfig{
TestEtnaChainConfig = &ChainConfig{
AvalancheContext: AvalancheContext{utils.TestSnowContext()},
ChainID: big.NewInt(1),
HomesteadBlock: big.NewInt(0),
Expand All @@ -453,7 +453,7 @@ var (
BanffBlockTimestamp: utils.NewUint64(0),
CortinaBlockTimestamp: utils.NewUint64(0),
DurangoBlockTimestamp: utils.NewUint64(0),
EUpgradeTime: utils.NewUint64(0),
EtnaTime: utils.NewUint64(0),
}

TestRules = TestChainConfig.Rules(new(big.Int), 0)
Expand Down Expand Up @@ -485,7 +485,7 @@ func getChainConfig(networkID uint32, chainID *big.Int) *ChainConfig {
BanffBlockTimestamp: utils.TimeToNewUint64(agoUpgrade.BanffTime),
CortinaBlockTimestamp: utils.TimeToNewUint64(agoUpgrade.CortinaTime),
DurangoBlockTimestamp: utils.TimeToNewUint64(agoUpgrade.DurangoTime),
EUpgradeTime: utils.TimeToNewUint64(agoUpgrade.EtnaTime),
EtnaTime: utils.TimeToNewUint64(agoUpgrade.EtnaTime),
}
}

Expand Down Expand Up @@ -540,11 +540,11 @@ type ChainConfig struct {
// and Avalanche Warp Messaging. (nil = no fork, 0 = already activated)
// Note: EIP-4895 is excluded since withdrawals are not relevant to the Avalanche C-Chain or Subnets running the EVM.
DurangoBlockTimestamp *uint64 `json:"durangoBlockTimestamp,omitempty"`
// EUpgrade activates Cancun from Ethereum (https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/cancun.md#included-eips)
// Etna activates Cancun from Ethereum (https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/cancun.md#included-eips)
// and reduces the min base fee. (nil = no fork, 0 = already activated)
// Note: EIP-4844 BlobTxs are not enabled in the mempool and blocks are not
// allowed to contain them. For details see https://github.com/avalanche-foundation/ACPs/pull/131
EUpgradeTime *uint64 `json:"eUpgradeTime,omitempty"`
EtnaTime *uint64 `json:"etnaTime,omitempty"`

// Cancun activates the Cancun upgrade from Ethereum. (nil = no fork, 0 = already activated)
CancunTime *uint64 `json:"cancunTime,omitempty"`
Expand Down Expand Up @@ -596,7 +596,7 @@ func (c *ChainConfig) Description() string {
banner += fmt.Sprintf(" - Banff Timestamp: @%-10v (https://github.com/ava-labs/avalanchego/releases/tag/v1.9.0)\n", ptrToString(c.BanffBlockTimestamp))
banner += fmt.Sprintf(" - Cortina Timestamp: @%-10v (https://github.com/ava-labs/avalanchego/releases/tag/v1.10.0)\n", ptrToString(c.CortinaBlockTimestamp))
banner += fmt.Sprintf(" - Durango Timestamp: @%-10v (https://github.com/ava-labs/avalanchego/releases/tag/v1.11.0)\n", ptrToString(c.DurangoBlockTimestamp))
banner += fmt.Sprintf(" - EUpgrade Timestamp: @%-10v (https://github.com/ava-labs/avalanchego/releases/tag/v1.12.0)\n", ptrToString(c.EUpgradeTime))
banner += fmt.Sprintf(" - Etna Timestamp: @%-10v (https://github.com/ava-labs/avalanchego/releases/tag/v1.12.0)\n", ptrToString(c.EtnaTime))
banner += "\n"

upgradeConfigBytes, err := json.Marshal(c.UpgradeConfig)
Expand Down Expand Up @@ -728,10 +728,10 @@ func (c *ChainConfig) IsDurango(time uint64) bool {
return utils.IsTimestampForked(c.DurangoBlockTimestamp, time)
}

// IsEUpgrade returns whether [time] represents a block
// with a timestamp after the EUpgrade upgrade time.
func (c *ChainConfig) IsEUpgrade(time uint64) bool {
return utils.IsTimestampForked(c.EUpgradeTime, time)
// IsEtna returns whether [time] represents a block
// with a timestamp after the Etna upgrade time.
func (c *ChainConfig) IsEtna(time uint64) bool {
return utils.IsTimestampForked(c.EtnaTime, time)
}

// IsCancun returns whether [time] represents a block
Expand Down Expand Up @@ -964,8 +964,8 @@ func (c *ChainConfig) checkCompatible(newcfg *ChainConfig, height *big.Int, time
if isForkTimestampIncompatible(c.DurangoBlockTimestamp, newcfg.DurangoBlockTimestamp, time) {
return newTimestampCompatError("Durango fork block timestamp", c.DurangoBlockTimestamp, newcfg.DurangoBlockTimestamp)
}
if isForkTimestampIncompatible(c.EUpgradeTime, newcfg.EUpgradeTime, time) {
return newTimestampCompatError("EUpgrade fork block timestamp", c.EUpgradeTime, newcfg.EUpgradeTime)
if isForkTimestampIncompatible(c.EtnaTime, newcfg.EtnaTime, time) {
return newTimestampCompatError("Etna fork block timestamp", c.EtnaTime, newcfg.EtnaTime)
}
if isForkTimestampIncompatible(c.CancunTime, newcfg.CancunTime, time) {
return newTimestampCompatError("Cancun fork block timestamp", c.CancunTime, newcfg.CancunTime)
Expand Down
4 changes: 2 additions & 2 deletions params/config_extra.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func (c *ChainConfig) ToWithUpgradesJSON() *ChainConfigWithUpgradesJSON {
// code in place of their Ethereum counterparts. The original Ethereum names
// should be restored for maintainability.
func (c *ChainConfig) SetEthUpgrades() {
if c.EUpgradeTime != nil {
c.CancunTime = utils.NewUint64(*c.EUpgradeTime)
if c.EtnaTime != nil {
c.CancunTime = utils.NewUint64(*c.EtnaTime)
}
}
6 changes: 3 additions & 3 deletions params/network_upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func (c *ChainConfig) forkOrder() []fork {
{name: "banffBlockTimestamp", timestamp: c.BanffBlockTimestamp},
{name: "cortinaBlockTimestamp", timestamp: c.CortinaBlockTimestamp},
{name: "durangoBlockTimestamp", timestamp: c.DurangoBlockTimestamp},
{name: "eUpgradeTime", timestamp: c.EUpgradeTime},
{name: "etnaTime", timestamp: c.EtnaTime},
}
}

Expand All @@ -26,7 +26,7 @@ type AvalancheRules struct {
IsBanff bool
IsCortina bool
IsDurango bool
IsEUpgrade bool
IsEtna bool
}

func (c *ChainConfig) GetAvalancheRules(timestamp uint64) AvalancheRules {
Expand All @@ -42,7 +42,7 @@ func (c *ChainConfig) GetAvalancheRules(timestamp uint64) AvalancheRules {
rules.IsBanff = c.IsBanff(timestamp)
rules.IsCortina = c.IsCortina(timestamp)
rules.IsDurango = c.IsDurango(timestamp)
rules.IsEUpgrade = c.IsEUpgrade(timestamp)
rules.IsEtna = c.IsEtna(timestamp)

return rules
}
22 changes: 11 additions & 11 deletions plugin/evm/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -702,22 +702,22 @@ func (vm *VM) initializeChain(lastAcceptedHash common.Hash) error {
// Set the gas parameters for the tx pool to the minimum gas price for the
// latest upgrade.
vm.txPool.SetGasTip(big.NewInt(0))
vm.setMinFeeAtEUpgrade()
vm.setMinFeeAtEtna()

vm.eth.Start()
return vm.initChainState(vm.blockChain.LastAcceptedBlock())
}

// TODO: remove this after EUpgrade is activated
func (vm *VM) setMinFeeAtEUpgrade() {
// TODO: remove this after Etna is activated
func (vm *VM) setMinFeeAtEtna() {
now := vm.clock.Time()
if vm.chainConfig.EUpgradeTime == nil {
// If EUpgrade is not set, set the min fee according to the latest upgrade
if vm.chainConfig.EtnaTime == nil {
// If Etna is not set, set the min fee according to the latest upgrade
vm.txPool.SetMinFee(big.NewInt(params.ApricotPhase4MinBaseFee))
return
} else if vm.chainConfig.IsEUpgrade(uint64(now.Unix())) {
// If EUpgrade is activated, set the min fee to the EUpgrade min fee
vm.txPool.SetMinFee(big.NewInt(params.EUpgradeMinBaseFee))
} else if vm.chainConfig.IsEtna(uint64(now.Unix())) {
// If Etna is activated, set the min fee to the Etna min fee
vm.txPool.SetMinFee(big.NewInt(params.EtnaMinBaseFee))
return
}

Expand All @@ -726,11 +726,11 @@ func (vm *VM) setMinFeeAtEUpgrade() {
go func() {
defer vm.shutdownWg.Done()

wait := utils.Uint64ToTime(vm.chainConfig.EUpgradeTime).Sub(now)
wait := utils.Uint64ToTime(vm.chainConfig.EtnaTime).Sub(now)
t := time.NewTimer(wait)
select {
case <-t.C: // Wait for EUpgrade to be activated
vm.txPool.SetMinFee(big.NewInt(params.EUpgradeMinBaseFee))
case <-t.C: // Wait for Etna to be activated
vm.txPool.SetMinFee(big.NewInt(params.EtnaMinBaseFee))
case <-vm.shutdownChan:
}
t.Stop()
Expand Down
16 changes: 8 additions & 8 deletions plugin/evm/vm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ var (
return &cpy
}

activateEUpgrade = func(cfg *params.ChainConfig, eUpgradeTime uint64) *params.ChainConfig {
activateEtna = func(cfg *params.ChainConfig, etnaTime uint64) *params.ChainConfig {
cpy := *cfg
cpy.EUpgradeTime = &eUpgradeTime
cpy.EtnaTime = &etnaTime
return &cpy
}

Expand All @@ -135,8 +135,8 @@ var (
genesisJSONBanff = genesisJSON(params.TestBanffChainConfig)
genesisJSONCortina = genesisJSON(params.TestCortinaChainConfig)
genesisJSONDurango = genesisJSON(params.TestDurangoChainConfig)
genesisJSONEUpgrade = genesisJSON(params.TestEUpgradeChainConfig)
genesisJSONLatest = genesisJSONEUpgrade
genesisJSONEtna = genesisJSON(params.TestEtnaChainConfig)
genesisJSONLatest = genesisJSONEtna

genesisJSONCancun = genesisJSON(activateCancun(params.TestChainConfig))

Expand Down Expand Up @@ -4138,13 +4138,13 @@ func TestNoBlobsAllowed(t *testing.T) {
require.ErrorContains(err, "blobs not enabled on avalanche networks")
}

func TestMinFeeSetAtEUpgrade(t *testing.T) {
func TestMinFeeSetAtEtna(t *testing.T) {
require := require.New(t)
now := time.Now()
eUpgradeTime := uint64(now.Add(1 * time.Second).Unix())
etnaTime := uint64(now.Add(1 * time.Second).Unix())

genesis := genesisJSON(
activateEUpgrade(params.TestEUpgradeChainConfig, eUpgradeTime),
activateEtna(params.TestEtnaChainConfig, etnaTime),
)
clock := mockable.Clock{}
clock.Set(now)
Expand All @@ -4154,7 +4154,7 @@ func TestMinFeeSetAtEUpgrade(t *testing.T) {
require.Equal(params.ApricotPhase4MinBaseFee, initial.Int64())

require.Eventually(
func() bool { return params.EUpgradeMinBaseFee == vm.txPool.MinFee().Int64() },
func() bool { return params.EtnaMinBaseFee == vm.txPool.MinFee().Int64() },
5*time.Second,
1*time.Second,
)
Expand Down

0 comments on commit 6b65339

Please sign in to comment.