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

Upgrade configs use ctx #635

Merged
merged 25 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
6752ced
get upgrade configs from context
ceyonur Aug 9, 2024
b595ecc
fix chainIDs
ceyonur Aug 9, 2024
047d3e5
fix avago version
ceyonur Aug 9, 2024
587cbea
commment out override
ceyonur Aug 9, 2024
0c9acb5
Merge branch 'master' into upgrade-configs
ceyonur Aug 12, 2024
cfb3eab
Remove comment out code
ceyonur Aug 12, 2024
5ba190c
Merge branch 'master' into upgrade-configs
ceyonur Aug 12, 2024
d8f2963
use network ID rather than chain ID
ceyonur Aug 13, 2024
ac01fb8
Merge branch 'upgrade-configs' of github.com:ava-labs/coreth into upg…
ceyonur Aug 13, 2024
15da144
refactor params config
ceyonur Aug 13, 2024
52d0a8a
update avago
ceyonur Aug 13, 2024
163edc7
rename
ceyonur Aug 13, 2024
0c0659b
fix runtime networks
ceyonur Aug 13, 2024
ae52aa2
Merge branch 'master' into refactor-params-config
ceyonur Aug 13, 2024
3305154
override netowrk upgrades from context
ceyonur Aug 14, 2024
2260320
Merge branch 'master' into upgrade-configs-use-ctx
ceyonur Aug 14, 2024
060d3b3
Update params/network_upgrades.go
ceyonur Aug 14, 2024
ea9b959
Merge branch 'master' into upgrade-configs-use-ctx
ceyonur Aug 14, 2024
f365b86
Merge branch 'master' of github.com:ava-labs/coreth into upgrade-conf…
ceyonur Aug 15, 2024
150640e
remove comment
ceyonur Aug 15, 2024
77af180
use chainID copy
ceyonur Aug 15, 2024
003d11b
Merge branch 'upgrade-configs-use-ctx' of github.com:ava-labs/coreth …
ceyonur Aug 15, 2024
a96bc92
bump avago
ceyonur Aug 15, 2024
2b0e345
remove debug logs
ceyonur Aug 15, 2024
b28157b
update avago version
ceyonur Aug 15, 2024
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
5 changes: 4 additions & 1 deletion eth/tracers/internal/tracetest/calltrace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ import (
"strings"
"testing"

"github.com/ava-labs/avalanchego/upgrade"
"github.com/ava-labs/avalanchego/utils/constants"
"github.com/ava-labs/coreth/core"
"github.com/ava-labs/coreth/core/rawdb"
"github.com/ava-labs/coreth/core/types"
Expand Down Expand Up @@ -275,6 +277,7 @@ func benchTracer(tracerName string, test *callTracerTest, b *testing.B) {

func TestInternals(t *testing.T) {
var (
config = params.GetChainConfig(upgrade.GetConfig(constants.MainnetID), params.AvalancheMainnetChainID)
to = common.HexToAddress("0x00000000000000000000000000000000deadbeef")
origin = common.HexToAddress("0x00000000000000000000000000000000feed")
txContext = vm.TxContext{
Expand Down Expand Up @@ -388,7 +391,7 @@ func TestInternals(t *testing.T) {
}, false, rawdb.HashScheme)
defer triedb.Close()

evm := vm.NewEVM(context, txContext, statedb, params.AvalancheMainnetChainConfig, vm.Config{Tracer: tc.tracer})
evm := vm.NewEVM(context, txContext, statedb, config, vm.Config{Tracer: tc.tracer})
msg := &core.Message{
To: &to,
From: origin,
Expand Down
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.20240813203340-ab83fb41528d
github.com/ava-labs/avalanchego v1.11.11-0.20240814145500-1ac532af76df
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
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
github.com/ava-labs/avalanchego v1.11.11-0.20240813203340-ab83fb41528d h1:LyrKJL9avIIxBY3uTcS2dFtUMBFmI2QpAgG6qYTdA6s=
github.com/ava-labs/avalanchego v1.11.11-0.20240813203340-ab83fb41528d/go.mod h1:UkyrRDXK2E15Lq2abyae2Pt+JsWvgsg1pe0/AtoMyAM=
github.com/ava-labs/avalanchego v1.11.11-0.20240814145500-1ac532af76df h1:Yp9rCHpgEsPFzpx2MXxpb/T+/NbP2NpS1EDwFquffLQ=
github.com/ava-labs/avalanchego v1.11.11-0.20240814145500-1ac532af76df/go.mod h1:Kw2GKwTaCkLwq2z3zSVH4V2eiAmq2FohHmN3AIDWjvY=
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
11 changes: 0 additions & 11 deletions params/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ import (
"fmt"
"math/big"

"github.com/ava-labs/avalanchego/upgrade"
"github.com/ava-labs/avalanchego/utils/constants"
"github.com/ava-labs/coreth/precompile/modules"
"github.com/ava-labs/coreth/precompile/precompileconfig"
"github.com/ava-labs/coreth/utils"
Expand All @@ -53,15 +51,6 @@ var (
)

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

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

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

TestChainConfig = &ChainConfig{
AvalancheContext: AvalancheContext{utils.TestSnowContext()},
ChainID: big.NewInt(1),
Expand Down
15 changes: 1 addition & 14 deletions params/config_extra.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,20 +171,7 @@ func GetChainConfig(agoUpgrade upgrade.Config, chainID *big.Int) *ChainConfig {
PetersburgBlock: big.NewInt(0),
IstanbulBlock: big.NewInt(0),
MuirGlacierBlock: big.NewInt(0),
NetworkUpgrades: NetworkUpgrades{
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),
EtnaTimestamp: utils.TimeToNewUint64(agoUpgrade.EtnaTime),
},
NetworkUpgrades: getNetworkUpgrades(agoUpgrade),
}
}

Expand Down
20 changes: 20 additions & 0 deletions params/network_upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ package params
import (
"fmt"
"reflect"

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

type NetworkUpgrades struct {
Expand Down Expand Up @@ -191,6 +194,23 @@ func (n *NetworkUpgrades) Description() string {
return banner
}

func getNetworkUpgrades(agoUpgrade upgrade.Config) NetworkUpgrades {
return NetworkUpgrades{
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),
EtnaTimestamp: utils.TimeToNewUint64(agoUpgrade.EtnaTime),
}
}

type AvalancheRules struct {
IsApricotPhase1, IsApricotPhase2, IsApricotPhase3, IsApricotPhase4, IsApricotPhase5 bool
IsApricotPhasePre6, IsApricotPhase6, IsApricotPhasePost6 bool
Expand Down
20 changes: 14 additions & 6 deletions plugin/evm/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (

"github.com/ava-labs/avalanchego/network/p2p"
"github.com/ava-labs/avalanchego/network/p2p/gossip"
"github.com/ava-labs/avalanchego/upgrade"
avalanchegoConstants "github.com/ava-labs/avalanchego/utils/constants"
"github.com/prometheus/client_golang/prometheus"

Expand Down Expand Up @@ -448,20 +449,27 @@ func (vm *VM) Initialize(
}

var extDataHashes map[common.Hash]common.Hash
var chainID *big.Int
// Set the chain config for mainnet/fuji chain IDs
switch chainCtx.NetworkID {
case avalanchegoConstants.MainnetID:
config := *params.AvalancheMainnetChainConfig
g.Config = &config
chainID = params.AvalancheMainnetChainID
extDataHashes = mainnetExtDataHashes
case avalanchegoConstants.FujiID:
config := *params.AvalancheFujiChainConfig
g.Config = &config
chainID = params.AvalancheFujiChainID
extDataHashes = fujiExtDataHashes
case avalanchegoConstants.LocalID:
config := *params.AvalancheLocalChainConfig
g.Config = &config
chainID = params.AvalancheLocalChainID
default:
chainID = g.Config.ChainID
}

// if the chainCtx.NetworkUpgrades is not empty, set the chain config
// normally it should not be empty, but some tests may not set it
if chainCtx.NetworkUpgrades != (upgrade.Config{}) {
g.Config = params.GetChainConfig(chainCtx.NetworkUpgrades, new(big.Int).Set(chainID))
}

// 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{
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:-'ab83fb41528de93c1790301cdd67a07dda9299f0'}
AVALANCHE_VERSION=${AVALANCHE_VERSION:-'1ac532af76df'}
Loading