Skip to content

Commit

Permalink
get upgrade configs from context (#630)
Browse files Browse the repository at this point in the history
* get upgrade configs from context

* fix chainIDs

* fix avago version

* commment out override

* Remove comment out code

* use network ID rather than chain ID

* update avago to master
  • Loading branch information
ceyonur authored Aug 13, 2024
1 parent c0f94ee commit 83eec50
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 15 deletions.
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.11-0.20240805141503-7e985b530bef
github.com/ava-labs/avalanchego v1.11.11-0.20240813180138-7520071656af
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
6 changes: 4 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,10 @@ 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.11-0.20240805141503-7e985b530bef h1:w0N/YXgNoXjDUwdFHGpWYq41uHxvBneHaJ+X0BxSj2w=
github.com/ava-labs/avalanchego v1.11.11-0.20240805141503-7e985b530bef/go.mod h1:9e0UPXJboybmgFjeTj+SFbK4ugbrdG4t68VdiUW5oQ8=
github.com/ava-labs/avalanchego v1.11.11-0.20240809105844-da3256302ab1 h1:h/09vEeKWELnlHr2Da2cXawD8Qg/9RyHy5SrODt0kkU=
github.com/ava-labs/avalanchego v1.11.11-0.20240809105844-da3256302ab1/go.mod h1:9e0UPXJboybmgFjeTj+SFbK4ugbrdG4t68VdiUW5oQ8=
github.com/ava-labs/avalanchego v1.11.11-0.20240813180138-7520071656af h1:BpAUJHH+QerXi2dMaHbaOzZHCiQAdqS+75Bqzd1alt8=
github.com/ava-labs/avalanchego v1.11.11-0.20240813180138-7520071656af/go.mod h1:8pnf2At/q0LRq5dvYJYn3CkhKzZNHRd5pjARC9psu+g=
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
9 changes: 4 additions & 5 deletions params/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ var (

var (
// AvalancheMainnetChainConfig is the configuration for Avalanche Main Network
AvalancheMainnetChainConfig = getChainConfig(constants.MainnetID, AvalancheMainnetChainID)
AvalancheMainnetChainConfig = GetChainConfig(upgrade.GetConfig(constants.MainnetID), AvalancheMainnetChainID)

// AvalancheFujiChainConfig is the configuration for the Fuji Test Network
AvalancheFujiChainConfig = getChainConfig(constants.FujiID, AvalancheFujiChainID)
AvalancheFujiChainConfig = GetChainConfig(upgrade.GetConfig(constants.FujiID), AvalancheFujiChainID)

// AvalancheLocalChainConfig is the configuration for the Avalanche Local Network
AvalancheLocalChainConfig = getChainConfig(constants.LocalID, AvalancheLocalChainID)
AvalancheLocalChainConfig = GetChainConfig(upgrade.GetConfig(constants.LocalID), AvalancheLocalChainID)

TestChainConfig = &ChainConfig{
AvalancheContext: AvalancheContext{utils.TestSnowContext()},
Expand Down Expand Up @@ -459,8 +459,7 @@ var (
TestRules = TestChainConfig.Rules(new(big.Int), 0)
)

func getChainConfig(networkID uint32, chainID *big.Int) *ChainConfig {
agoUpgrade := upgrade.GetConfig(networkID)
func GetChainConfig(agoUpgrade upgrade.Config, chainID *big.Int) *ChainConfig {
return &ChainConfig{
ChainID: chainID,
HomesteadBlock: big.NewInt(0),
Expand Down
16 changes: 10 additions & 6 deletions plugin/evm/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -449,30 +449,34 @@ func (vm *VM) Initialize(

var extDataHashes map[common.Hash]common.Hash
// Set the chain config for mainnet/fuji chain IDs
switch {
case g.Config.ChainID.Cmp(params.AvalancheMainnetChainID) == 0:
switch chainCtx.NetworkID {
case avalanchegoConstants.MainnetID:
config := *params.AvalancheMainnetChainConfig
g.Config = &config
extDataHashes = mainnetExtDataHashes
case g.Config.ChainID.Cmp(params.AvalancheFujiChainID) == 0:
case avalanchegoConstants.FujiID:
config := *params.AvalancheFujiChainConfig
g.Config = &config
extDataHashes = fujiExtDataHashes
case avalanchegoConstants.LocalID:
config := *params.AvalancheLocalChainConfig
g.Config = &config
}
// If the Durango is activated, activate the Warp Precompile at the same time
if g.Config.DurangoBlockTimestamp != nil {
g.Config.PrecompileUpgrades = append(g.Config.PrecompileUpgrades, params.PrecompileUpgrade{
Config: warpPrecompile.NewDefaultConfig(g.Config.DurangoBlockTimestamp),
})
}

// Set the Avalanche Context on the ChainConfig
g.Config.AvalancheContext = params.AvalancheContext{
SnowCtx: chainCtx,
}
vm.syntacticBlockValidator = NewBlockValidator(extDataHashes)

// Ensure that non-standard commit interval is only allowed for the local network
if g.Config.ChainID.Cmp(params.AvalancheLocalChainID) != 0 {
// Ensure that non-standard commit interval is not allowed for production networks
if avalanchegoConstants.ProductionNetworkIDs.Contains(chainCtx.NetworkID) {
if vm.config.CommitInterval != defaultCommitInterval {
return fmt.Errorf("cannot start non-local network with commit interval %d", vm.config.CommitInterval)
}
Expand Down Expand Up @@ -619,7 +623,7 @@ func (vm *VM) Initialize(
var (
bonusBlockHeights map[uint64]ids.ID
)
if vm.chainID.Cmp(params.AvalancheMainnetChainID) == 0 {
if vm.ctx.NetworkID == avalanchegoConstants.MainnetID {
bonusBlockHeights, err = readMainnetBonusBlocks()
if err != nil {
return fmt.Errorf("failed to read mainnet bonus blocks: %w", err)
Expand Down
2 changes: 1 addition & 1 deletion scripts/versions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
set -euo pipefail

# Don't export them as they're used in the context of other calls
AVALANCHE_VERSION=${AVALANCHE_VERSION:-'7e985b530beff5afe03967f5fa94a2eee998cb7a'}
AVALANCHE_VERSION=${AVALANCHE_VERSION:-'7520071656af'}

0 comments on commit 83eec50

Please sign in to comment.