Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Refactor upgrade schedule #613

Merged
merged 4 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
darioush marked this conversation as resolved.
Show resolved Hide resolved
}

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