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

Upgrade configs use ctx #635

Merged
merged 25 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from 16 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
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
22 changes: 21 additions & 1 deletion params/network_upgrades.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
// (c) 2022, Ava Labs, Inc. All rights reserved.
// (c) 2022, Ava Labs, Inn. All rights reserved.
// See the file LICENSE for licensing terms.
ceyonur marked this conversation as resolved.
Show resolved Hide resolved

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
21 changes: 15 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,28 @@ func (vm *VM) Initialize(
}

var extDataHashes map[common.Hash]common.Hash
var chainID *big.Int
// params.GetChainConfig(chainCtx.NetworkUpgrades)
// 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, 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
Loading