Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

get upgrade configs from context #630

Merged
merged 10 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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.11-0.20240805141503-7e985b530bef
github.com/ava-labs/avalanchego v1.11.11-0.20240809105844-da3256302ab1
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.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/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
15 changes: 12 additions & 3 deletions plugin/evm/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -449,22 +449,31 @@ 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
default:
// TODO: This overrides the chain config in the given genesis (in genesisBytes)
// Do we want to do this?
// config := params.GetChainConfig(chainCtx.NetworkUpgrades, new(big.Int).Set(g.Config.ChainID))
// g.Config = config
darioush marked this conversation as resolved.
Show resolved Hide resolved
}
// 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,
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:-'da3256302ab1'}
Loading