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 3 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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.21.12

require (
github.com/VictoriaMetrics/fastcache v1.12.1
github.com/ava-labs/avalanchego v1.11.10-prerelease
github.com/ava-labs/avalanchego v1.11.11-0.20240726180529-7c45bedc8791
github.com/cespare/cp v0.1.0
github.com/crate-crypto/go-ipa v0.0.0-20231025140028-3c0104f4b233
github.com/davecgh/go-spew v1.1.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY
github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156 h1:eMwmnE/GDgah4HI848JfFxHt+iPb26b4zyfspmqY0/8=
github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM=
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
github.com/ava-labs/avalanchego v1.11.10-prerelease h1:QUhVqvxrwDmsTvXXnKoePe5WU3Eh8GXB/QE2R2xHa0c=
github.com/ava-labs/avalanchego v1.11.10-prerelease/go.mod h1:ryRFbHr7sKmez4792NxzJS7AGiE+vd0Tez+qs2kmezE=
github.com/ava-labs/avalanchego v1.11.11-0.20240726180529-7c45bedc8791 h1:fbG/dETGp8ySG+MOlp8ehkbsiPUc/1YXd81Ahr2J/dw=
github.com/ava-labs/avalanchego v1.11.11-0.20240726180529-7c45bedc8791/go.mod h1:v2IUrIkmsbxE1Gy8odNowdTRqow1xNBHC6wCEeD4EIg=
github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
Expand Down
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
11 changes: 0 additions & 11 deletions params/config_extra.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ package params
import (
"encoding/json"
"errors"
"time"

"github.com/ava-labs/avalanchego/snow"
"github.com/ava-labs/coreth/utils"
)

// UpgradeConfig includes the following configs that may be specified in upgradeBytes:
Expand Down Expand Up @@ -120,12 +118,3 @@ func (c *ChainConfig) ToWithUpgradesJSON() *ChainConfigWithUpgradesJSON {
UpgradeConfig: c.UpgradeConfig,
}
}

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
}
Loading