Skip to content

Commit

Permalink
Refactor upgrade schedule (#613)
Browse files Browse the repository at this point in the history
* Update to use ago upgrade struct

* Update EtnaUpgradeTime -> EtnaTime

* Bump ago

---------

Co-authored-by: Darioush Jalali <darioush.jalali@avalabs.org>
  • Loading branch information
aaronbuchwald and darioush authored Aug 7, 2024
1 parent 6726136 commit 015611b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 23 deletions.
27 changes: 14 additions & 13 deletions params/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ import (
"fmt"
"math/big"

"github.com/ava-labs/avalanchego/upgrade"
"github.com/ava-labs/avalanchego/utils/constants"
"github.com/ava-labs/avalanchego/version"
"github.com/ava-labs/coreth/precompile/modules"
"github.com/ava-labs/coreth/precompile/precompileconfig"
"github.com/ava-labs/coreth/utils"
Expand Down Expand Up @@ -460,6 +460,7 @@ var (
)

func getChainConfig(networkID uint32, chainID *big.Int) *ChainConfig {
agoUpgrade := upgrade.GetConfig(networkID)
return &ChainConfig{
ChainID: chainID,
HomesteadBlock: big.NewInt(0),
Expand All @@ -473,18 +474,18 @@ func getChainConfig(networkID uint32, chainID *big.Int) *ChainConfig {
PetersburgBlock: big.NewInt(0),
IstanbulBlock: big.NewInt(0),
MuirGlacierBlock: big.NewInt(0),
ApricotPhase1BlockTimestamp: getUpgradeTime(networkID, version.ApricotPhase1Times),
ApricotPhase2BlockTimestamp: getUpgradeTime(networkID, version.ApricotPhase2Times),
ApricotPhase3BlockTimestamp: getUpgradeTime(networkID, version.ApricotPhase3Times),
ApricotPhase4BlockTimestamp: getUpgradeTime(networkID, version.ApricotPhase4Times),
ApricotPhase5BlockTimestamp: getUpgradeTime(networkID, version.ApricotPhase5Times),
ApricotPhasePre6BlockTimestamp: getUpgradeTime(networkID, version.ApricotPhasePre6Times),
ApricotPhase6BlockTimestamp: getUpgradeTime(networkID, version.ApricotPhase6Times),
ApricotPhasePost6BlockTimestamp: getUpgradeTime(networkID, version.ApricotPhasePost6Times),
BanffBlockTimestamp: getUpgradeTime(networkID, version.BanffTimes),
CortinaBlockTimestamp: getUpgradeTime(networkID, version.CortinaTimes),
DurangoBlockTimestamp: getUpgradeTime(networkID, version.DurangoTimes),
EUpgradeTime: getUpgradeTime(networkID, version.EUpgradeTimes),
ApricotPhase1BlockTimestamp: utils.TimeToNewUint64(agoUpgrade.ApricotPhase1Time),
ApricotPhase2BlockTimestamp: utils.TimeToNewUint64(agoUpgrade.ApricotPhase2Time),
ApricotPhase3BlockTimestamp: utils.TimeToNewUint64(agoUpgrade.ApricotPhase3Time),
ApricotPhase4BlockTimestamp: utils.TimeToNewUint64(agoUpgrade.ApricotPhase4Time),
ApricotPhase5BlockTimestamp: utils.TimeToNewUint64(agoUpgrade.ApricotPhase5Time),
ApricotPhasePre6BlockTimestamp: utils.TimeToNewUint64(agoUpgrade.ApricotPhasePre6Time),
ApricotPhase6BlockTimestamp: utils.TimeToNewUint64(agoUpgrade.ApricotPhase6Time),
ApricotPhasePost6BlockTimestamp: utils.TimeToNewUint64(agoUpgrade.ApricotPhasePost6Time),
BanffBlockTimestamp: utils.TimeToNewUint64(agoUpgrade.BanffTime),
CortinaBlockTimestamp: utils.TimeToNewUint64(agoUpgrade.CortinaTime),
DurangoBlockTimestamp: utils.TimeToNewUint64(agoUpgrade.DurangoTime),
EUpgradeTime: utils.TimeToNewUint64(agoUpgrade.EtnaTime),
}
}

Expand Down
10 changes: 0 additions & 10 deletions params/config_extra.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package params
import (
"encoding/json"
"errors"
"time"

"github.com/ava-labs/avalanchego/snow"
"github.com/ava-labs/coreth/utils"
Expand Down Expand Up @@ -121,15 +120,6 @@ func (c *ChainConfig) ToWithUpgradesJSON() *ChainConfigWithUpgradesJSON {
}
}

func getUpgradeTime(networkID uint32, upgradeTimes map[uint32]time.Time) *uint64 {
if upgradeTime, ok := upgradeTimes[networkID]; ok {
return utils.TimeToNewUint64(upgradeTime)
}
// If the upgrade time isn't specified, default being enabled in the
// genesis.
return utils.NewUint64(0)
}

// SetEthUpgrades enables Etheruem network upgrades using the same time as
// the Avalanche network upgrade that enables them.
//
Expand Down

0 comments on commit 015611b

Please # to comment.