From 6fdb0ccf9b5a8beb2f0785d636731f383d2854ae Mon Sep 17 00:00:00 2001 From: Aaron Buchwald Date: Fri, 19 Jul 2024 23:02:00 -0400 Subject: [PATCH 01/12] Add network upgrade config --- chains/manager.go | 12 +-- config/config.go | 8 ++ network/network.go | 3 +- network/network_test.go | 5 ++ network/peer/peer_test.go | 31 +++---- network/peer/test_peer.go | 3 +- network/test_network.go | 2 + node/config.go | 3 + node/node.go | 31 ++++--- upgrade/upgrade.go | 170 ++++++++++++++++++++++++++++++++++++ version/constants.go | 169 +---------------------------------- vms/avm/config/config.go | 3 + vms/avm/state/state_test.go | 4 +- vms/avm/vm.go | 2 +- 14 files changed, 241 insertions(+), 205 deletions(-) create mode 100644 upgrade/upgrade.go diff --git a/chains/manager.go b/chains/manager.go index bdc6d0ef018..a89834b93fb 100644 --- a/chains/manager.go +++ b/chains/manager.go @@ -50,7 +50,6 @@ import ( "github.com/ava-labs/avalanchego/utils/metric" "github.com/ava-labs/avalanchego/utils/perms" "github.com/ava-labs/avalanchego/utils/set" - "github.com/ava-labs/avalanchego/version" "github.com/ava-labs/avalanchego/vms" "github.com/ava-labs/avalanchego/vms/fx" "github.com/ava-labs/avalanchego/vms/metervm" @@ -235,6 +234,9 @@ type ManagerConfig struct { ApricotPhase4Time time.Time ApricotPhase4MinPChainHeight uint64 + CortinaTime time.Time + CortinaXChainStopVertexID ids.ID + DurangoTime time.Time // Tracks CPU/disk usage caused by each peer. ResourceTracker timetracker.ResourceTracker @@ -730,7 +732,7 @@ func (m *manager) createAvalancheChain( VM: dagVM, DB: vertexDB, Log: ctx.Log, - CortinaTime: version.GetCortinaTime(ctx.NetworkID), + CortinaTime: m.CortinaTime, }, ) @@ -795,7 +797,7 @@ func (m *manager) createAvalancheChain( vmWrappedInsideProposerVM, proposervm.Config{ ActivationTime: m.ApricotPhase4Time, - DurangoTime: version.GetDurangoTime(m.NetworkID), + DurangoTime: m.DurangoTime, MinimumPChainHeight: m.ApricotPhase4MinPChainHeight, MinBlkDelay: minBlockDelay, NumHistoricalBlocks: numHistoricalBlocks, @@ -1010,7 +1012,7 @@ func (m *manager) createAvalancheChain( VM: linearizableVM, } if ctx.ChainID == m.XChainID { - avalancheBootstrapperConfig.StopVertexID = version.CortinaXChainStopVertexID[ctx.NetworkID] + avalancheBootstrapperConfig.StopVertexID = m.CortinaXChainStopVertexID } avalancheBootstrapper, err := avbootstrap.New( @@ -1192,7 +1194,7 @@ func (m *manager) createSnowmanChain( vm, proposervm.Config{ ActivationTime: m.ApricotPhase4Time, - DurangoTime: version.GetDurangoTime(m.NetworkID), + DurangoTime: m.DurangoTime, MinimumPChainHeight: m.ApricotPhase4MinPChainHeight, MinBlkDelay: minBlockDelay, NumHistoricalBlocks: numHistoricalBlocks, diff --git a/config/config.go b/config/config.go index 422eceedb6e..2710b23bc05 100644 --- a/config/config.go +++ b/config/config.go @@ -33,6 +33,7 @@ import ( "github.com/ava-labs/avalanchego/staking" "github.com/ava-labs/avalanchego/subnets" "github.com/ava-labs/avalanchego/trace" + "github.com/ava-labs/avalanchego/upgrade" "github.com/ava-labs/avalanchego/utils/compression" "github.com/ava-labs/avalanchego/utils/constants" "github.com/ava-labs/avalanchego/utils/crypto/bls" @@ -779,6 +780,10 @@ func getTxFeeConfig(v *viper.Viper, networkID uint32) fee.StaticConfig { return genesis.GetTxFeeConfig(networkID) } +func getUpgradeConfig(v *viper.Viper, networkID uint32) upgrade.Config { + return upgrade.GetConfig(networkID) +} + func getGenesisData(v *viper.Viper, networkID uint32, stakingCfg *genesis.StakingConfig) ([]byte, ids.ID, error) { // try first loading genesis content directly from flag/env-var if v.IsSet(GenesisFileContentKey) { @@ -1294,6 +1299,9 @@ func GetNodeConfig(v *viper.Viper) (node.Config, error) { return node.Config{}, err } + // Upgrade config + nodeConfig.UpgradeConfig = getUpgradeConfig(v, nodeConfig.NetworkID) + // Network Config nodeConfig.NetworkConfig, err = getNetworkConfig( v, diff --git a/network/network.go b/network/network.go index 2aee13a910d..76cf2a9ed51 100644 --- a/network/network.go +++ b/network/network.go @@ -172,6 +172,7 @@ type network struct { // NewNetwork returns a new Network implementation with the provided parameters. func NewNetwork( config *Config, + minCompatibleTime time.Time, msgCreator message.Creator, metricsRegisterer prometheus.Registerer, log logging.Logger, @@ -261,7 +262,7 @@ func NewNetwork( InboundMsgThrottler: inboundMsgThrottler, Network: nil, // This is set below. Router: router, - VersionCompatibility: version.GetCompatibility(config.NetworkID), + VersionCompatibility: version.GetCompatibility(config.NetworkID, minCompatibleTime), MySubnets: config.TrackedSubnets, Beacons: config.Beacons, Validators: config.Validators, diff --git a/network/network_test.go b/network/network_test.go index 85390da90df..7cfdf6bf7c2 100644 --- a/network/network_test.go +++ b/network/network_test.go @@ -26,6 +26,7 @@ import ( "github.com/ava-labs/avalanchego/snow/validators" "github.com/ava-labs/avalanchego/staking" "github.com/ava-labs/avalanchego/subnets" + "github.com/ava-labs/avalanchego/upgrade" "github.com/ava-labs/avalanchego/utils" "github.com/ava-labs/avalanchego/utils/constants" "github.com/ava-labs/avalanchego/utils/crypto/bls" @@ -237,6 +238,7 @@ func newFullyConnectedTestNetwork(t *testing.T, handlers []router.InboundHandler var connected set.Set[ids.NodeID] net, err := NewNetwork( config, + upgrade.DefaultUpgradeTime, msgCreator, registry, logging.NoLog{}, @@ -466,6 +468,7 @@ func TestTrackDoesNotDialPrivateIPs(t *testing.T) { net, err := NewNetwork( config, + upgrade.DefaultUpgradeTime, msgCreator, registry, logging.NoLog{}, @@ -545,6 +548,7 @@ func TestDialDeletesNonValidators(t *testing.T) { net, err := NewNetwork( config, + upgrade.DefaultUpgradeTime, msgCreator, registry, logging.NoLog{}, @@ -699,6 +703,7 @@ func TestAllowConnectionAsAValidator(t *testing.T) { net, err := NewNetwork( config, + upgrade.DefaultUpgradeTime, msgCreator, registry, logging.NoLog{}, diff --git a/network/peer/peer_test.go b/network/peer/peer_test.go index e29edbe17ba..b9aa939cafb 100644 --- a/network/peer/peer_test.go +++ b/network/peer/peer_test.go @@ -23,6 +23,7 @@ import ( "github.com/ava-labs/avalanchego/snow/uptime" "github.com/ava-labs/avalanchego/snow/validators" "github.com/ava-labs/avalanchego/staking" + "github.com/ava-labs/avalanchego/upgrade" "github.com/ava-labs/avalanchego/utils" "github.com/ava-labs/avalanchego/utils/constants" "github.com/ava-labs/avalanchego/utils/crypto/bls" @@ -83,7 +84,7 @@ func newConfig(t *testing.T) Config { InboundMsgThrottler: throttling.NewNoInboundThrottler(), Network: TestNetwork, Router: nil, - VersionCompatibility: version.GetCompatibility(constants.LocalID), + VersionCompatibility: version.GetCompatibility(constants.LocalID, upgrade.DefaultUpgradeTime), MySubnets: nil, Beacons: validators.NewManager(), Validators: validators.NewManager(), @@ -451,7 +452,7 @@ func TestShouldDisconnect(t *testing.T) { initialPeer: &peer{ Config: &Config{ Log: logging.NoLog{}, - VersionCompatibility: version.GetCompatibility(constants.UnitTestID), + VersionCompatibility: version.GetCompatibility(constants.UnitTestID, upgrade.DefaultUpgradeTime), }, version: &version.Application{ Name: version.Client, @@ -463,7 +464,7 @@ func TestShouldDisconnect(t *testing.T) { expectedPeer: &peer{ Config: &Config{ Log: logging.NoLog{}, - VersionCompatibility: version.GetCompatibility(constants.UnitTestID), + VersionCompatibility: version.GetCompatibility(constants.UnitTestID, upgrade.DefaultUpgradeTime), }, version: &version.Application{ Name: version.Client, @@ -479,7 +480,7 @@ func TestShouldDisconnect(t *testing.T) { initialPeer: &peer{ Config: &Config{ Log: logging.NoLog{}, - VersionCompatibility: version.GetCompatibility(constants.UnitTestID), + VersionCompatibility: version.GetCompatibility(constants.UnitTestID, upgrade.DefaultUpgradeTime), Validators: validators.NewManager(), }, version: version.CurrentApp, @@ -487,7 +488,7 @@ func TestShouldDisconnect(t *testing.T) { expectedPeer: &peer{ Config: &Config{ Log: logging.NoLog{}, - VersionCompatibility: version.GetCompatibility(constants.UnitTestID), + VersionCompatibility: version.GetCompatibility(constants.UnitTestID, upgrade.DefaultUpgradeTime), Validators: validators.NewManager(), }, version: version.CurrentApp, @@ -499,7 +500,7 @@ func TestShouldDisconnect(t *testing.T) { initialPeer: &peer{ Config: &Config{ Log: logging.NoLog{}, - VersionCompatibility: version.GetCompatibility(constants.UnitTestID), + VersionCompatibility: version.GetCompatibility(constants.UnitTestID, upgrade.DefaultUpgradeTime), Validators: func() validators.Manager { vdrs := validators.NewManager() require.NoError(t, vdrs.AddStaker( @@ -518,7 +519,7 @@ func TestShouldDisconnect(t *testing.T) { expectedPeer: &peer{ Config: &Config{ Log: logging.NoLog{}, - VersionCompatibility: version.GetCompatibility(constants.UnitTestID), + VersionCompatibility: version.GetCompatibility(constants.UnitTestID, upgrade.DefaultUpgradeTime), Validators: func() validators.Manager { vdrs := validators.NewManager() require.NoError(t, vdrs.AddStaker( @@ -541,7 +542,7 @@ func TestShouldDisconnect(t *testing.T) { initialPeer: &peer{ Config: &Config{ Log: logging.NoLog{}, - VersionCompatibility: version.GetCompatibility(constants.UnitTestID), + VersionCompatibility: version.GetCompatibility(constants.UnitTestID, upgrade.DefaultUpgradeTime), Validators: func() validators.Manager { vdrs := validators.NewManager() require.NoError(t, vdrs.AddStaker( @@ -561,7 +562,7 @@ func TestShouldDisconnect(t *testing.T) { expectedPeer: &peer{ Config: &Config{ Log: logging.NoLog{}, - VersionCompatibility: version.GetCompatibility(constants.UnitTestID), + VersionCompatibility: version.GetCompatibility(constants.UnitTestID, upgrade.DefaultUpgradeTime), Validators: func() validators.Manager { vdrs := validators.NewManager() require.NoError(t, vdrs.AddStaker( @@ -585,7 +586,7 @@ func TestShouldDisconnect(t *testing.T) { initialPeer: &peer{ Config: &Config{ Log: logging.NoLog{}, - VersionCompatibility: version.GetCompatibility(constants.UnitTestID), + VersionCompatibility: version.GetCompatibility(constants.UnitTestID, upgrade.DefaultUpgradeTime), Validators: func() validators.Manager { vdrs := validators.NewManager() require.NoError(t, vdrs.AddStaker( @@ -605,7 +606,7 @@ func TestShouldDisconnect(t *testing.T) { expectedPeer: &peer{ Config: &Config{ Log: logging.NoLog{}, - VersionCompatibility: version.GetCompatibility(constants.UnitTestID), + VersionCompatibility: version.GetCompatibility(constants.UnitTestID, upgrade.DefaultUpgradeTime), Validators: func() validators.Manager { vdrs := validators.NewManager() require.NoError(t, vdrs.AddStaker( @@ -629,7 +630,7 @@ func TestShouldDisconnect(t *testing.T) { initialPeer: &peer{ Config: &Config{ Log: logging.NoLog{}, - VersionCompatibility: version.GetCompatibility(constants.UnitTestID), + VersionCompatibility: version.GetCompatibility(constants.UnitTestID, upgrade.DefaultUpgradeTime), Validators: func() validators.Manager { vdrs := validators.NewManager() require.NoError(t, vdrs.AddStaker( @@ -651,7 +652,7 @@ func TestShouldDisconnect(t *testing.T) { expectedPeer: &peer{ Config: &Config{ Log: logging.NoLog{}, - VersionCompatibility: version.GetCompatibility(constants.UnitTestID), + VersionCompatibility: version.GetCompatibility(constants.UnitTestID, upgrade.DefaultUpgradeTime), Validators: func() validators.Manager { vdrs := validators.NewManager() require.NoError(t, vdrs.AddStaker( @@ -677,7 +678,7 @@ func TestShouldDisconnect(t *testing.T) { initialPeer: &peer{ Config: &Config{ Log: logging.NoLog{}, - VersionCompatibility: version.GetCompatibility(constants.UnitTestID), + VersionCompatibility: version.GetCompatibility(constants.UnitTestID, upgrade.DefaultUpgradeTime), Validators: func() validators.Manager { vdrs := validators.NewManager() require.NoError(t, vdrs.AddStaker( @@ -699,7 +700,7 @@ func TestShouldDisconnect(t *testing.T) { expectedPeer: &peer{ Config: &Config{ Log: logging.NoLog{}, - VersionCompatibility: version.GetCompatibility(constants.UnitTestID), + VersionCompatibility: version.GetCompatibility(constants.UnitTestID, upgrade.DefaultUpgradeTime), Validators: func() validators.Manager { vdrs := validators.NewManager() require.NoError(t, vdrs.AddStaker( diff --git a/network/peer/test_peer.go b/network/peer/test_peer.go index ae03594f8e6..0961d6759ec 100644 --- a/network/peer/test_peer.go +++ b/network/peer/test_peer.go @@ -20,6 +20,7 @@ import ( "github.com/ava-labs/avalanchego/snow/uptime" "github.com/ava-labs/avalanchego/snow/validators" "github.com/ava-labs/avalanchego/staking" + "github.com/ava-labs/avalanchego/upgrade" "github.com/ava-labs/avalanchego/utils" "github.com/ava-labs/avalanchego/utils/constants" "github.com/ava-labs/avalanchego/utils/crypto/bls" @@ -113,7 +114,7 @@ func StartTestPeer( InboundMsgThrottler: throttling.NewNoInboundThrottler(), Network: TestNetwork, Router: router, - VersionCompatibility: version.GetCompatibility(networkID), + VersionCompatibility: version.GetCompatibility(networkID, upgrade.DefaultUpgradeTime), MySubnets: set.Set[ids.ID]{}, Beacons: validators.NewManager(), Validators: validators.NewManager(), diff --git a/network/test_network.go b/network/test_network.go index 8644eb359ae..4b8aba89a79 100644 --- a/network/test_network.go +++ b/network/test_network.go @@ -25,6 +25,7 @@ import ( "github.com/ava-labs/avalanchego/snow/validators" "github.com/ava-labs/avalanchego/staking" "github.com/ava-labs/avalanchego/subnets" + "github.com/ava-labs/avalanchego/upgrade" "github.com/ava-labs/avalanchego/utils" "github.com/ava-labs/avalanchego/utils/constants" "github.com/ava-labs/avalanchego/utils/crypto/bls" @@ -216,6 +217,7 @@ func NewTestNetwork( resourceTracker.DiskTracker(), ), }, + upgrade.DefaultUpgradeTime, msgCreator, metrics, log, diff --git a/node/config.go b/node/config.go index 6f8d3e1ec54..85e9962185f 100644 --- a/node/config.go +++ b/node/config.go @@ -18,6 +18,7 @@ import ( "github.com/ava-labs/avalanchego/snow/networking/tracker" "github.com/ava-labs/avalanchego/subnets" "github.com/ava-labs/avalanchego/trace" + "github.com/ava-labs/avalanchego/upgrade" "github.com/ava-labs/avalanchego/utils/crypto/bls" "github.com/ava-labs/avalanchego/utils/logging" "github.com/ava-labs/avalanchego/utils/profiler" @@ -131,6 +132,8 @@ type Config struct { BootstrapConfig `json:"bootstrapConfig"` DatabaseConfig `json:"databaseConfig"` + UpgradeConfig upgrade.Config `json:"upgradeConfig"` + // Genesis information GenesisBytes []byte `json:"-"` AvaxAssetID ids.ID `json:"avaxAssetID"` diff --git a/node/node.go b/node/node.go index fe574b17ea5..cf005ecdee1 100644 --- a/node/node.go +++ b/node/node.go @@ -77,7 +77,7 @@ import ( "github.com/ava-labs/avalanchego/vms/avm" "github.com/ava-labs/avalanchego/vms/platformvm" "github.com/ava-labs/avalanchego/vms/platformvm/signer" - "github.com/ava-labs/avalanchego/vms/platformvm/upgrade" + pupgrade "github.com/ava-labs/avalanchego/vms/platformvm/upgrade" "github.com/ava-labs/avalanchego/vms/registry" "github.com/ava-labs/avalanchego/vms/rpcchainvm/runtime" @@ -633,6 +633,7 @@ func (n *Node) initNetworking(reg prometheus.Registerer) error { n.Net, err = network.NewNetwork( &n.Config.NetworkConfig, + n.Config.UpgradeConfig.DurangoTime, n.msgCreator, reg, n.Log, @@ -1184,8 +1185,11 @@ func (n *Node) initChainManager(avaxAssetID ids.ID) error { BootstrapMaxTimeGetAncestors: n.Config.BootstrapMaxTimeGetAncestors, BootstrapAncestorsMaxContainersSent: n.Config.BootstrapAncestorsMaxContainersSent, BootstrapAncestorsMaxContainersReceived: n.Config.BootstrapAncestorsMaxContainersReceived, - ApricotPhase4Time: version.GetApricotPhase4Time(n.Config.NetworkID), - ApricotPhase4MinPChainHeight: version.ApricotPhase4MinPChainHeight[n.Config.NetworkID], + ApricotPhase4Time: n.Config.UpgradeConfig.ApricotPhase4Time, + ApricotPhase4MinPChainHeight: n.Config.UpgradeConfig.ApricotPhase4MinPChainHeight, + CortinaTime: n.Config.UpgradeConfig.CortinaTime, + CortinaXChainStopVertexID: n.Config.UpgradeConfig.CortinaXChainStopVertexID, + DurangoTime: n.Config.UpgradeConfig.DurangoTime, ResourceTracker: n.resourceTracker, StateSyncBeacons: n.Config.StateSyncIDs, TracingEnabled: n.Config.TraceConfig.Enabled, @@ -1217,7 +1221,7 @@ func (n *Node) initVMs() error { } // Register the VMs that Avalanche supports - eUpgradeTime := version.GetEUpgradeTime(n.Config.NetworkID) + eUpgradeTime := n.Config.UpgradeConfig.EtnaUpgradeTime err := errors.Join( n.VMManager.RegisterFactory(context.TODO(), constants.PlatformVMID, &platformvm.Factory{ Config: platformconfig.Config{ @@ -1236,12 +1240,12 @@ func (n *Node) initVMs() error { MinStakeDuration: n.Config.MinStakeDuration, MaxStakeDuration: n.Config.MaxStakeDuration, RewardConfig: n.Config.RewardConfig, - UpgradeConfig: upgrade.Config{ - ApricotPhase3Time: version.GetApricotPhase3Time(n.Config.NetworkID), - ApricotPhase5Time: version.GetApricotPhase5Time(n.Config.NetworkID), - BanffTime: version.GetBanffTime(n.Config.NetworkID), - CortinaTime: version.GetCortinaTime(n.Config.NetworkID), - DurangoTime: version.GetDurangoTime(n.Config.NetworkID), + UpgradeConfig: pupgrade.Config{ + ApricotPhase3Time: n.Config.UpgradeConfig.ApricotPhase3Time, + ApricotPhase5Time: n.Config.UpgradeConfig.ApricotPhase5Time, + BanffTime: n.Config.UpgradeConfig.BanffTime, + CortinaTime: n.Config.UpgradeConfig.CortinaTime, + DurangoTime: n.Config.UpgradeConfig.DurangoTime, EUpgradeTime: eUpgradeTime, }, UseCurrentHeight: n.Config.UseCurrentHeight, @@ -1249,9 +1253,10 @@ func (n *Node) initVMs() error { }), n.VMManager.RegisterFactory(context.TODO(), constants.AVMID, &avm.Factory{ Config: avmconfig.Config{ - TxFee: n.Config.TxFee, - CreateAssetTxFee: n.Config.CreateAssetTxFee, - EUpgradeTime: eUpgradeTime, + TxFee: n.Config.TxFee, + CreateAssetTxFee: n.Config.CreateAssetTxFee, + CortinaUpgradeTime: n.Config.UpgradeConfig.CortinaTime, + EUpgradeTime: eUpgradeTime, }, }), n.VMManager.RegisterFactory(context.TODO(), constants.EVMID, &coreth.Factory{}), diff --git a/upgrade/upgrade.go b/upgrade/upgrade.go new file mode 100644 index 00000000000..bf1ee6334b5 --- /dev/null +++ b/upgrade/upgrade.go @@ -0,0 +1,170 @@ +// Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. +// See the file LICENSE for licensing terms. + +package upgrade + +import ( + "time" + + "github.com/ava-labs/avalanchego/ids" + "github.com/ava-labs/avalanchego/utils/constants" +) + +var ( + DefaultUpgradeTime = time.Date(2020, time.December, 5, 5, 0, 0, 0, time.UTC) + + ApricotPhase1Times = map[uint32]time.Time{ + constants.MainnetID: time.Date(2021, time.March, 31, 14, 0, 0, 0, time.UTC), + constants.FujiID: time.Date(2021, time.March, 26, 14, 0, 0, 0, time.UTC), + } + + ApricotPhase2Times = map[uint32]time.Time{ + constants.MainnetID: time.Date(2021, time.May, 10, 11, 0, 0, 0, time.UTC), + constants.FujiID: time.Date(2021, time.May, 5, 14, 0, 0, 0, time.UTC), + } + + ApricotPhase3Times = map[uint32]time.Time{ + constants.MainnetID: time.Date(2021, time.August, 24, 14, 0, 0, 0, time.UTC), + constants.FujiID: time.Date(2021, time.August, 16, 19, 0, 0, 0, time.UTC), + } + + ApricotPhase4Times = map[uint32]time.Time{ + constants.MainnetID: time.Date(2021, time.September, 22, 21, 0, 0, 0, time.UTC), + constants.FujiID: time.Date(2021, time.September, 16, 21, 0, 0, 0, time.UTC), + } + ApricotPhase4MinPChainHeight = map[uint32]uint64{ + constants.MainnetID: 793005, + constants.FujiID: 47437, + } + + ApricotPhase5Times = map[uint32]time.Time{ + constants.MainnetID: time.Date(2021, time.December, 2, 18, 0, 0, 0, time.UTC), + constants.FujiID: time.Date(2021, time.November, 24, 15, 0, 0, 0, time.UTC), + } + + ApricotPhasePre6Times = map[uint32]time.Time{ + constants.MainnetID: time.Date(2022, time.September, 5, 1, 30, 0, 0, time.UTC), + constants.FujiID: time.Date(2022, time.September, 6, 20, 0, 0, 0, time.UTC), + } + + ApricotPhase6Times = map[uint32]time.Time{ + constants.MainnetID: time.Date(2022, time.September, 6, 20, 0, 0, 0, time.UTC), + constants.FujiID: time.Date(2022, time.September, 6, 20, 0, 0, 0, time.UTC), + } + + ApricotPhasePost6Times = map[uint32]time.Time{ + constants.MainnetID: time.Date(2022, time.September, 7, 3, 0, 0, 0, time.UTC), + constants.FujiID: time.Date(2022, time.September, 7, 6, 0, 0, 0, time.UTC), + } + + BanffTimes = map[uint32]time.Time{ + constants.MainnetID: time.Date(2022, time.October, 18, 16, 0, 0, 0, time.UTC), + constants.FujiID: time.Date(2022, time.October, 3, 14, 0, 0, 0, time.UTC), + } + + CortinaTimes = map[uint32]time.Time{ + constants.MainnetID: time.Date(2023, time.April, 25, 15, 0, 0, 0, time.UTC), + constants.FujiID: time.Date(2023, time.April, 6, 15, 0, 0, 0, time.UTC), + } + CortinaXChainStopVertexID = map[uint32]ids.ID{ + // The mainnet stop vertex is well known. It can be verified on any + // fully synced node by looking at the parentID of the genesis block. + // + // Ref: https://subnets.avax.network/x-chain/block/0 + constants.MainnetID: ids.FromStringOrPanic("jrGWDh5Po9FMj54depyunNixpia5PN4aAYxfmNzU8n752Rjga"), + // The fuji stop vertex is well known. It can be verified on any fully + // synced node by looking at the parentID of the genesis block. + // + // Ref: https://subnets-test.avax.network/x-chain/block/0 + constants.FujiID: ids.FromStringOrPanic("2D1cmbiG36BqQMRyHt4kFhWarmatA1ighSpND3FeFgz3vFVtCZ"), + } + + DurangoTimes = map[uint32]time.Time{ + constants.MainnetID: time.Date(2024, time.March, 6, 16, 0, 0, 0, time.UTC), + constants.FujiID: time.Date(2024, time.February, 13, 16, 0, 0, 0, time.UTC), + } + + EUpgradeTimes = map[uint32]time.Time{ + constants.MainnetID: time.Date(10000, time.December, 1, 0, 0, 0, 0, time.UTC), + constants.FujiID: time.Date(10000, time.December, 1, 0, 0, 0, 0, time.UTC), + } +) + +var ( + Mainnet = Config{ + ApricotPhase1Time: ApricotPhase1Times[constants.MainnetID], + ApricotPhase2Time: ApricotPhase2Times[constants.MainnetID], + ApricotPhase3Time: ApricotPhase3Times[constants.MainnetID], + ApricotPhase4Time: ApricotPhase4Times[constants.MainnetID], + ApricotPhase4MinPChainHeight: ApricotPhase4MinPChainHeight[constants.MainnetID], + ApricotPhase5Time: ApricotPhase5Times[constants.MainnetID], + ApricotPhasePre6Time: ApricotPhasePre6Times[constants.MainnetID], + ApricotPhase6Time: ApricotPhase6Times[constants.MainnetID], + ApricotPhasePost6Time: ApricotPhasePost6Times[constants.MainnetID], + BanffTime: BanffTimes[constants.MainnetID], + CortinaTime: CortinaTimes[constants.MainnetID], + CortinaXChainStopVertexID: CortinaXChainStopVertexID[constants.MainnetID], + DurangoTime: DurangoTimes[constants.MainnetID], + EtnaUpgradeTime: EUpgradeTimes[constants.MainnetID], + } + Fuji = Config{ + ApricotPhase1Time: ApricotPhase1Times[constants.FujiID], + ApricotPhase2Time: ApricotPhase2Times[constants.FujiID], + ApricotPhase3Time: ApricotPhase3Times[constants.FujiID], + ApricotPhase4Time: ApricotPhase4Times[constants.FujiID], + ApricotPhase4MinPChainHeight: ApricotPhase4MinPChainHeight[constants.FujiID], + ApricotPhase5Time: ApricotPhase5Times[constants.FujiID], + ApricotPhasePre6Time: ApricotPhasePre6Times[constants.FujiID], + ApricotPhase6Time: ApricotPhase6Times[constants.FujiID], + ApricotPhasePost6Time: ApricotPhasePost6Times[constants.FujiID], + BanffTime: BanffTimes[constants.FujiID], + CortinaTime: CortinaTimes[constants.FujiID], + CortinaXChainStopVertexID: CortinaXChainStopVertexID[constants.FujiID], + DurangoTime: DurangoTimes[constants.FujiID], + EtnaUpgradeTime: EUpgradeTimes[constants.FujiID], + } + Default = Config{ + ApricotPhase1Time: DefaultUpgradeTime, + ApricotPhase2Time: DefaultUpgradeTime, + ApricotPhase3Time: DefaultUpgradeTime, + ApricotPhase4Time: DefaultUpgradeTime, + ApricotPhase4MinPChainHeight: 0, + ApricotPhase5Time: DefaultUpgradeTime, + ApricotPhasePre6Time: DefaultUpgradeTime, + ApricotPhase6Time: DefaultUpgradeTime, + ApricotPhasePost6Time: DefaultUpgradeTime, + BanffTime: DefaultUpgradeTime, + CortinaTime: DefaultUpgradeTime, + CortinaXChainStopVertexID: ids.Empty, + DurangoTime: DefaultUpgradeTime, + EtnaUpgradeTime: DefaultUpgradeTime, + } +) + +type Config struct { + ApricotPhase1Time time.Time + ApricotPhase2Time time.Time + ApricotPhase3Time time.Time + ApricotPhase4Time time.Time + ApricotPhase4MinPChainHeight uint64 + ApricotPhase5Time time.Time + ApricotPhasePre6Time time.Time + ApricotPhase6Time time.Time + ApricotPhasePost6Time time.Time + BanffTime time.Time + CortinaTime time.Time + CortinaXChainStopVertexID ids.ID + DurangoTime time.Time + EtnaUpgradeTime time.Time +} + +func GetConfig(networkID uint32) Config { + switch networkID { + case constants.MainnetID: + return Mainnet + case constants.FujiID: + return Fuji + default: + return Default + } +} diff --git a/version/constants.go b/version/constants.go index 9e294b98169..fa322c6d720 100644 --- a/version/constants.go +++ b/version/constants.go @@ -8,9 +8,6 @@ import ( "time" _ "embed" - - "github.com/ava-labs/avalanchego/ids" - "github.com/ava-labs/avalanchego/utils/constants" ) const ( @@ -67,84 +64,6 @@ var ( // set of avalanchego versions that supported that version. This is not used // by avalanchego, but is useful for downstream libraries. RPCChainVMProtocolCompatibility map[uint][]*Semantic - - DefaultUpgradeTime = time.Date(2020, time.December, 5, 5, 0, 0, 0, time.UTC) - - ApricotPhase1Times = map[uint32]time.Time{ - constants.MainnetID: time.Date(2021, time.March, 31, 14, 0, 0, 0, time.UTC), - constants.FujiID: time.Date(2021, time.March, 26, 14, 0, 0, 0, time.UTC), - } - - ApricotPhase2Times = map[uint32]time.Time{ - constants.MainnetID: time.Date(2021, time.May, 10, 11, 0, 0, 0, time.UTC), - constants.FujiID: time.Date(2021, time.May, 5, 14, 0, 0, 0, time.UTC), - } - - ApricotPhase3Times = map[uint32]time.Time{ - constants.MainnetID: time.Date(2021, time.August, 24, 14, 0, 0, 0, time.UTC), - constants.FujiID: time.Date(2021, time.August, 16, 19, 0, 0, 0, time.UTC), - } - - ApricotPhase4Times = map[uint32]time.Time{ - constants.MainnetID: time.Date(2021, time.September, 22, 21, 0, 0, 0, time.UTC), - constants.FujiID: time.Date(2021, time.September, 16, 21, 0, 0, 0, time.UTC), - } - ApricotPhase4MinPChainHeight = map[uint32]uint64{ - constants.MainnetID: 793005, - constants.FujiID: 47437, - } - - ApricotPhase5Times = map[uint32]time.Time{ - constants.MainnetID: time.Date(2021, time.December, 2, 18, 0, 0, 0, time.UTC), - constants.FujiID: time.Date(2021, time.November, 24, 15, 0, 0, 0, time.UTC), - } - - ApricotPhasePre6Times = map[uint32]time.Time{ - constants.MainnetID: time.Date(2022, time.September, 5, 1, 30, 0, 0, time.UTC), - constants.FujiID: time.Date(2022, time.September, 6, 20, 0, 0, 0, time.UTC), - } - - ApricotPhase6Times = map[uint32]time.Time{ - constants.MainnetID: time.Date(2022, time.September, 6, 20, 0, 0, 0, time.UTC), - constants.FujiID: time.Date(2022, time.September, 6, 20, 0, 0, 0, time.UTC), - } - - ApricotPhasePost6Times = map[uint32]time.Time{ - constants.MainnetID: time.Date(2022, time.September, 7, 3, 0, 0, 0, time.UTC), - constants.FujiID: time.Date(2022, time.September, 7, 6, 0, 0, 0, time.UTC), - } - - BanffTimes = map[uint32]time.Time{ - constants.MainnetID: time.Date(2022, time.October, 18, 16, 0, 0, 0, time.UTC), - constants.FujiID: time.Date(2022, time.October, 3, 14, 0, 0, 0, time.UTC), - } - - CortinaTimes = map[uint32]time.Time{ - constants.MainnetID: time.Date(2023, time.April, 25, 15, 0, 0, 0, time.UTC), - constants.FujiID: time.Date(2023, time.April, 6, 15, 0, 0, 0, time.UTC), - } - CortinaXChainStopVertexID = map[uint32]ids.ID{ - // The mainnet stop vertex is well known. It can be verified on any - // fully synced node by looking at the parentID of the genesis block. - // - // Ref: https://subnets.avax.network/x-chain/block/0 - constants.MainnetID: ids.FromStringOrPanic("jrGWDh5Po9FMj54depyunNixpia5PN4aAYxfmNzU8n752Rjga"), - // The fuji stop vertex is well known. It can be verified on any fully - // synced node by looking at the parentID of the genesis block. - // - // Ref: https://subnets-test.avax.network/x-chain/block/0 - constants.FujiID: ids.FromStringOrPanic("2D1cmbiG36BqQMRyHt4kFhWarmatA1ighSpND3FeFgz3vFVtCZ"), - } - - DurangoTimes = map[uint32]time.Time{ - constants.MainnetID: time.Date(2024, time.March, 6, 16, 0, 0, 0, time.UTC), - constants.FujiID: time.Date(2024, time.February, 13, 16, 0, 0, 0, time.UTC), - } - - EUpgradeTimes = map[uint32]time.Time{ - constants.MainnetID: time.Date(10000, time.December, 1, 0, 0, 0, 0, time.UTC), - constants.FujiID: time.Date(10000, time.December, 1, 0, 0, 0, 0, time.UTC), - } ) func init() { @@ -168,95 +87,11 @@ func init() { } } -func GetApricotPhase1Time(networkID uint32) time.Time { - if upgradeTime, exists := ApricotPhase1Times[networkID]; exists { - return upgradeTime - } - return DefaultUpgradeTime -} - -func GetApricotPhase2Time(networkID uint32) time.Time { - if upgradeTime, exists := ApricotPhase2Times[networkID]; exists { - return upgradeTime - } - return DefaultUpgradeTime -} - -func GetApricotPhase3Time(networkID uint32) time.Time { - if upgradeTime, exists := ApricotPhase3Times[networkID]; exists { - return upgradeTime - } - return DefaultUpgradeTime -} - -func GetApricotPhase4Time(networkID uint32) time.Time { - if upgradeTime, exists := ApricotPhase4Times[networkID]; exists { - return upgradeTime - } - return DefaultUpgradeTime -} - -func GetApricotPhase5Time(networkID uint32) time.Time { - if upgradeTime, exists := ApricotPhase5Times[networkID]; exists { - return upgradeTime - } - return DefaultUpgradeTime -} - -func GetApricotPhasePre6Time(networkID uint32) time.Time { - if upgradeTime, exists := ApricotPhasePre6Times[networkID]; exists { - return upgradeTime - } - return DefaultUpgradeTime -} - -func GetApricotPhase6Time(networkID uint32) time.Time { - if upgradeTime, exists := ApricotPhase6Times[networkID]; exists { - return upgradeTime - } - return DefaultUpgradeTime -} - -func GetApricotPhasePost6Time(networkID uint32) time.Time { - if upgradeTime, exists := ApricotPhasePost6Times[networkID]; exists { - return upgradeTime - } - return DefaultUpgradeTime -} - -func GetBanffTime(networkID uint32) time.Time { - if upgradeTime, exists := BanffTimes[networkID]; exists { - return upgradeTime - } - return DefaultUpgradeTime -} - -func GetCortinaTime(networkID uint32) time.Time { - if upgradeTime, exists := CortinaTimes[networkID]; exists { - return upgradeTime - } - return DefaultUpgradeTime -} - -func GetDurangoTime(networkID uint32) time.Time { - if upgradeTime, exists := DurangoTimes[networkID]; exists { - return upgradeTime - } - return DefaultUpgradeTime -} - -func GetEUpgradeTime(networkID uint32) time.Time { - if upgradeTime, exists := EUpgradeTimes[networkID]; exists { - return upgradeTime - } - return DefaultUpgradeTime -} - -func GetCompatibility(networkID uint32) Compatibility { +func GetCompatibility(networkID uint32, minCompatibleTime time.Time) Compatibility { return NewCompatibility( CurrentApp, MinimumCompatibleVersion, - GetDurangoTime(networkID), + minCompatibleTime, PrevMinimumCompatibleVersion, ) } diff --git a/vms/avm/config/config.go b/vms/avm/config/config.go index 0d026eb05db..b7fe3cecf14 100644 --- a/vms/avm/config/config.go +++ b/vms/avm/config/config.go @@ -13,6 +13,9 @@ type Config struct { // Fee that must be burned by every asset creating transaction CreateAssetTxFee uint64 + // Time of the Cortina network upgrade + CortinaUpgradeTime time.Time + // Time of the E network upgrade EUpgradeTime time.Time } diff --git a/vms/avm/state/state_test.go b/vms/avm/state/state_test.go index a6170c62c40..e1743b03794 100644 --- a/vms/avm/state/state_test.go +++ b/vms/avm/state/state_test.go @@ -14,7 +14,7 @@ import ( "github.com/ava-labs/avalanchego/database/memdb" "github.com/ava-labs/avalanchego/database/versiondb" "github.com/ava-labs/avalanchego/ids" - "github.com/ava-labs/avalanchego/version" + "github.com/ava-labs/avalanchego/upgrade" "github.com/ava-labs/avalanchego/vms/avm/block" "github.com/ava-labs/avalanchego/vms/avm/fxs" "github.com/ava-labs/avalanchego/vms/avm/txs" @@ -287,7 +287,7 @@ func TestInitializeChainState(t *testing.T) { require.NoError(err) stopVertexID := ids.GenerateTestID() - genesisTimestamp := version.DefaultUpgradeTime + genesisTimestamp := upgrade.DefaultUpgradeTime require.NoError(s.InitializeChainState(stopVertexID, genesisTimestamp)) lastAcceptedID := s.GetLastAccepted() diff --git a/vms/avm/vm.go b/vms/avm/vm.go index e83e7cd9ea7..49ee0cd09a8 100644 --- a/vms/avm/vm.go +++ b/vms/avm/vm.go @@ -395,7 +395,7 @@ func (vm *VM) GetBlockIDAtHeight(_ context.Context, height uint64) (ids.ID, erro */ func (vm *VM) Linearize(ctx context.Context, stopVertexID ids.ID, toEngine chan<- common.Message) error { - time := version.GetCortinaTime(vm.ctx.NetworkID) + time := vm.Config.CortinaUpgradeTime err := vm.state.InitializeChainState(stopVertexID, time) if err != nil { return err From a2ffd04bf581f493473cfebc169e5934b1bdff13 Mon Sep 17 00:00:00 2001 From: Aaron Buchwald Date: Thu, 25 Jul 2024 20:25:36 -0400 Subject: [PATCH 02/12] Update coreth dep and fix lint --- config/config.go | 2 +- go.mod | 2 +- go.sum | 4 ++-- network/network.go | 2 +- network/peer/peer_test.go | 30 +++++++++++++++--------------- network/peer/test_peer.go | 2 +- node/node.go | 2 +- version/constants.go | 2 +- 8 files changed, 23 insertions(+), 23 deletions(-) diff --git a/config/config.go b/config/config.go index 2710b23bc05..95a8923e5b9 100644 --- a/config/config.go +++ b/config/config.go @@ -780,7 +780,7 @@ func getTxFeeConfig(v *viper.Viper, networkID uint32) fee.StaticConfig { return genesis.GetTxFeeConfig(networkID) } -func getUpgradeConfig(v *viper.Viper, networkID uint32) upgrade.Config { +func getUpgradeConfig(_ *viper.Viper, networkID uint32) upgrade.Config { return upgrade.GetConfig(networkID) } diff --git a/go.mod b/go.mod index 00458471b34..8e9846a68e7 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/DataDog/zstd v1.5.2 github.com/NYTimes/gziphandler v1.1.1 github.com/antithesishq/antithesis-sdk-go v0.3.8 - github.com/ava-labs/coreth v0.13.7 + github.com/ava-labs/coreth v0.13.8-0.20240726001013-e5d123e010da github.com/ava-labs/ledger-avalanche/go v0.0.0-20240610153809-9c955cc90a95 github.com/btcsuite/btcd/btcutil v1.1.3 github.com/cockroachdb/pebble v0.0.0-20230928194634-aa077af62593 diff --git a/go.sum b/go.sum index 1887349b142..030c890fddc 100644 --- a/go.sum +++ b/go.sum @@ -62,8 +62,8 @@ github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax github.com/antithesishq/antithesis-sdk-go v0.3.8 h1:OvGoHxIcOXFJLyn9IJQ5DzByZ3YVAWNBc394ObzDRb8= github.com/antithesishq/antithesis-sdk-go v0.3.8/go.mod h1:IUpT2DPAKh6i/YhSbt6Gl3v2yvUZjmKncl7U91fup7E= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= -github.com/ava-labs/coreth v0.13.7 h1:k8T9u/ROifl8f7oXjHRc1KvSISRl9txvy7gGVmHEz6g= -github.com/ava-labs/coreth v0.13.7/go.mod h1:tXDujonxXFOF6oK5HS2EmgtSXJK3Gy6RpZxb5WzR9rM= +github.com/ava-labs/coreth v0.13.8-0.20240726001013-e5d123e010da h1:QUR0bREz315+j8kI89o+XQOoDSj21Mn2z4ayVspNRZg= +github.com/ava-labs/coreth v0.13.8-0.20240726001013-e5d123e010da/go.mod h1:apBYWuSBsADVDzpajW/JJDRlom1/co7zT8PU+6CUECw= github.com/ava-labs/ledger-avalanche/go v0.0.0-20240610153809-9c955cc90a95 h1:dOVbtdnZL++pENdTCNZ1nu41eYDQkTML4sWebDnnq8c= github.com/ava-labs/ledger-avalanche/go v0.0.0-20240610153809-9c955cc90a95/go.mod h1:pJxaT9bUgeRNVmNRgtCHb7sFDIRKy7CzTQVi8gGNT6g= github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g= diff --git a/network/network.go b/network/network.go index 76cf2a9ed51..5d2fa1ec344 100644 --- a/network/network.go +++ b/network/network.go @@ -262,7 +262,7 @@ func NewNetwork( InboundMsgThrottler: inboundMsgThrottler, Network: nil, // This is set below. Router: router, - VersionCompatibility: version.GetCompatibility(config.NetworkID, minCompatibleTime), + VersionCompatibility: version.GetCompatibility(minCompatibleTime), MySubnets: config.TrackedSubnets, Beacons: config.Beacons, Validators: config.Validators, diff --git a/network/peer/peer_test.go b/network/peer/peer_test.go index b9aa939cafb..57d03c51e5f 100644 --- a/network/peer/peer_test.go +++ b/network/peer/peer_test.go @@ -84,7 +84,7 @@ func newConfig(t *testing.T) Config { InboundMsgThrottler: throttling.NewNoInboundThrottler(), Network: TestNetwork, Router: nil, - VersionCompatibility: version.GetCompatibility(constants.LocalID, upgrade.DefaultUpgradeTime), + VersionCompatibility: version.GetCompatibility(upgrade.DefaultUpgradeTime), MySubnets: nil, Beacons: validators.NewManager(), Validators: validators.NewManager(), @@ -452,7 +452,7 @@ func TestShouldDisconnect(t *testing.T) { initialPeer: &peer{ Config: &Config{ Log: logging.NoLog{}, - VersionCompatibility: version.GetCompatibility(constants.UnitTestID, upgrade.DefaultUpgradeTime), + VersionCompatibility: version.GetCompatibility(upgrade.DefaultUpgradeTime), }, version: &version.Application{ Name: version.Client, @@ -464,7 +464,7 @@ func TestShouldDisconnect(t *testing.T) { expectedPeer: &peer{ Config: &Config{ Log: logging.NoLog{}, - VersionCompatibility: version.GetCompatibility(constants.UnitTestID, upgrade.DefaultUpgradeTime), + VersionCompatibility: version.GetCompatibility(upgrade.DefaultUpgradeTime), }, version: &version.Application{ Name: version.Client, @@ -480,7 +480,7 @@ func TestShouldDisconnect(t *testing.T) { initialPeer: &peer{ Config: &Config{ Log: logging.NoLog{}, - VersionCompatibility: version.GetCompatibility(constants.UnitTestID, upgrade.DefaultUpgradeTime), + VersionCompatibility: version.GetCompatibility(upgrade.DefaultUpgradeTime), Validators: validators.NewManager(), }, version: version.CurrentApp, @@ -488,7 +488,7 @@ func TestShouldDisconnect(t *testing.T) { expectedPeer: &peer{ Config: &Config{ Log: logging.NoLog{}, - VersionCompatibility: version.GetCompatibility(constants.UnitTestID, upgrade.DefaultUpgradeTime), + VersionCompatibility: version.GetCompatibility(upgrade.DefaultUpgradeTime), Validators: validators.NewManager(), }, version: version.CurrentApp, @@ -500,7 +500,7 @@ func TestShouldDisconnect(t *testing.T) { initialPeer: &peer{ Config: &Config{ Log: logging.NoLog{}, - VersionCompatibility: version.GetCompatibility(constants.UnitTestID, upgrade.DefaultUpgradeTime), + VersionCompatibility: version.GetCompatibility(upgrade.DefaultUpgradeTime), Validators: func() validators.Manager { vdrs := validators.NewManager() require.NoError(t, vdrs.AddStaker( @@ -519,7 +519,7 @@ func TestShouldDisconnect(t *testing.T) { expectedPeer: &peer{ Config: &Config{ Log: logging.NoLog{}, - VersionCompatibility: version.GetCompatibility(constants.UnitTestID, upgrade.DefaultUpgradeTime), + VersionCompatibility: version.GetCompatibility(upgrade.DefaultUpgradeTime), Validators: func() validators.Manager { vdrs := validators.NewManager() require.NoError(t, vdrs.AddStaker( @@ -542,7 +542,7 @@ func TestShouldDisconnect(t *testing.T) { initialPeer: &peer{ Config: &Config{ Log: logging.NoLog{}, - VersionCompatibility: version.GetCompatibility(constants.UnitTestID, upgrade.DefaultUpgradeTime), + VersionCompatibility: version.GetCompatibility(upgrade.DefaultUpgradeTime), Validators: func() validators.Manager { vdrs := validators.NewManager() require.NoError(t, vdrs.AddStaker( @@ -562,7 +562,7 @@ func TestShouldDisconnect(t *testing.T) { expectedPeer: &peer{ Config: &Config{ Log: logging.NoLog{}, - VersionCompatibility: version.GetCompatibility(constants.UnitTestID, upgrade.DefaultUpgradeTime), + VersionCompatibility: version.GetCompatibility(upgrade.DefaultUpgradeTime), Validators: func() validators.Manager { vdrs := validators.NewManager() require.NoError(t, vdrs.AddStaker( @@ -586,7 +586,7 @@ func TestShouldDisconnect(t *testing.T) { initialPeer: &peer{ Config: &Config{ Log: logging.NoLog{}, - VersionCompatibility: version.GetCompatibility(constants.UnitTestID, upgrade.DefaultUpgradeTime), + VersionCompatibility: version.GetCompatibility(upgrade.DefaultUpgradeTime), Validators: func() validators.Manager { vdrs := validators.NewManager() require.NoError(t, vdrs.AddStaker( @@ -606,7 +606,7 @@ func TestShouldDisconnect(t *testing.T) { expectedPeer: &peer{ Config: &Config{ Log: logging.NoLog{}, - VersionCompatibility: version.GetCompatibility(constants.UnitTestID, upgrade.DefaultUpgradeTime), + VersionCompatibility: version.GetCompatibility(upgrade.DefaultUpgradeTime), Validators: func() validators.Manager { vdrs := validators.NewManager() require.NoError(t, vdrs.AddStaker( @@ -630,7 +630,7 @@ func TestShouldDisconnect(t *testing.T) { initialPeer: &peer{ Config: &Config{ Log: logging.NoLog{}, - VersionCompatibility: version.GetCompatibility(constants.UnitTestID, upgrade.DefaultUpgradeTime), + VersionCompatibility: version.GetCompatibility(upgrade.DefaultUpgradeTime), Validators: func() validators.Manager { vdrs := validators.NewManager() require.NoError(t, vdrs.AddStaker( @@ -652,7 +652,7 @@ func TestShouldDisconnect(t *testing.T) { expectedPeer: &peer{ Config: &Config{ Log: logging.NoLog{}, - VersionCompatibility: version.GetCompatibility(constants.UnitTestID, upgrade.DefaultUpgradeTime), + VersionCompatibility: version.GetCompatibility(upgrade.DefaultUpgradeTime), Validators: func() validators.Manager { vdrs := validators.NewManager() require.NoError(t, vdrs.AddStaker( @@ -678,7 +678,7 @@ func TestShouldDisconnect(t *testing.T) { initialPeer: &peer{ Config: &Config{ Log: logging.NoLog{}, - VersionCompatibility: version.GetCompatibility(constants.UnitTestID, upgrade.DefaultUpgradeTime), + VersionCompatibility: version.GetCompatibility(upgrade.DefaultUpgradeTime), Validators: func() validators.Manager { vdrs := validators.NewManager() require.NoError(t, vdrs.AddStaker( @@ -700,7 +700,7 @@ func TestShouldDisconnect(t *testing.T) { expectedPeer: &peer{ Config: &Config{ Log: logging.NoLog{}, - VersionCompatibility: version.GetCompatibility(constants.UnitTestID, upgrade.DefaultUpgradeTime), + VersionCompatibility: version.GetCompatibility(upgrade.DefaultUpgradeTime), Validators: func() validators.Manager { vdrs := validators.NewManager() require.NoError(t, vdrs.AddStaker( diff --git a/network/peer/test_peer.go b/network/peer/test_peer.go index 0961d6759ec..592e53d9b0c 100644 --- a/network/peer/test_peer.go +++ b/network/peer/test_peer.go @@ -114,7 +114,7 @@ func StartTestPeer( InboundMsgThrottler: throttling.NewNoInboundThrottler(), Network: TestNetwork, Router: router, - VersionCompatibility: version.GetCompatibility(networkID, upgrade.DefaultUpgradeTime), + VersionCompatibility: version.GetCompatibility(upgrade.DefaultUpgradeTime), MySubnets: set.Set[ids.ID]{}, Beacons: validators.NewManager(), Validators: validators.NewManager(), diff --git a/node/node.go b/node/node.go index cf005ecdee1..a1d0367d955 100644 --- a/node/node.go +++ b/node/node.go @@ -77,12 +77,12 @@ import ( "github.com/ava-labs/avalanchego/vms/avm" "github.com/ava-labs/avalanchego/vms/platformvm" "github.com/ava-labs/avalanchego/vms/platformvm/signer" - pupgrade "github.com/ava-labs/avalanchego/vms/platformvm/upgrade" "github.com/ava-labs/avalanchego/vms/registry" "github.com/ava-labs/avalanchego/vms/rpcchainvm/runtime" avmconfig "github.com/ava-labs/avalanchego/vms/avm/config" platformconfig "github.com/ava-labs/avalanchego/vms/platformvm/config" + pupgrade "github.com/ava-labs/avalanchego/vms/platformvm/upgrade" coreth "github.com/ava-labs/coreth/plugin/evm" ) diff --git a/version/constants.go b/version/constants.go index fa322c6d720..a2ef3ced40c 100644 --- a/version/constants.go +++ b/version/constants.go @@ -87,7 +87,7 @@ func init() { } } -func GetCompatibility(networkID uint32, minCompatibleTime time.Time) Compatibility { +func GetCompatibility(minCompatibleTime time.Time) Compatibility { return NewCompatibility( CurrentApp, MinimumCompatibleVersion, From 2bc0a81923ed5670c26cb068fbd28914145765d2 Mon Sep 17 00:00:00 2001 From: Aaron Buchwald Date: Fri, 26 Jul 2024 13:37:54 -0400 Subject: [PATCH 03/12] Add upgrade CLI flag --- config/config.go | 42 ++++++++++++++++++++++-- config/flags.go | 5 +++ config/keys.go | 2 ++ node/node.go | 2 +- upgrade/upgrade.go | 72 +++++++++++++++++++++++++++++++---------- upgrade/upgrade_test.go | 35 ++++++++++++++++++++ 6 files changed, 137 insertions(+), 21 deletions(-) create mode 100644 upgrade/upgrade_test.go diff --git a/config/config.go b/config/config.go index 95a8923e5b9..b3048e39600 100644 --- a/config/config.go +++ b/config/config.go @@ -780,8 +780,41 @@ func getTxFeeConfig(v *viper.Viper, networkID uint32) fee.StaticConfig { return genesis.GetTxFeeConfig(networkID) } -func getUpgradeConfig(_ *viper.Viper, networkID uint32) upgrade.Config { - return upgrade.GetConfig(networkID) +func getUpgradeConfig(v *viper.Viper, networkID uint32) (upgrade.Config, error) { + configured := v.IsSet(UpgradeFileContentKey) || v.IsSet(UpgradeFileKey) + if !configured { + return upgrade.GetConfig(networkID), nil + } + + switch networkID { + case constants.MainnetID, constants.FujiID, constants.LocalID: + return upgrade.Config{}, fmt.Errorf("cannot configure upgrades on mainnet, fuji, or default local networkID") + } + + var ( + upgradeBytes []byte + err error + ) + switch { + case v.IsSet(UpgradeFileContentKey): + upgradeContent := v.GetString(UpgradeFileContentKey) + upgradeBytes, err = base64.StdEncoding.DecodeString(upgradeContent) + if err != nil { + return upgrade.Config{}, fmt.Errorf("unable to decode upgrade base64 content: %w", err) + } + case v.IsSet(UpgradeFileKey): + upgradeFileName := GetExpandedArg(v, UpgradeFileKey) + upgradeBytes, err = os.ReadFile(upgradeFileName) + if err != nil { + return upgrade.Config{}, fmt.Errorf("unable to read upgrade file: %w", err) + } + } + + var upgradeConfig upgrade.Config + if err := json.Unmarshal(upgradeBytes, &upgradeConfig); err != nil { + return upgrade.Config{}, fmt.Errorf("unable to unmarshal upgrade bytes: %w", err) + } + return upgradeConfig, nil } func getGenesisData(v *viper.Viper, networkID uint32, stakingCfg *genesis.StakingConfig) ([]byte, ids.ID, error) { @@ -1300,7 +1333,10 @@ func GetNodeConfig(v *viper.Viper) (node.Config, error) { } // Upgrade config - nodeConfig.UpgradeConfig = getUpgradeConfig(v, nodeConfig.NetworkID) + nodeConfig.UpgradeConfig, err = getUpgradeConfig(v, nodeConfig.NetworkID) + if err != nil { + return node.Config{}, err + } // Network Config nodeConfig.NetworkConfig, err = getNetworkConfig( diff --git a/config/flags.go b/config/flags.go index 3fb99e5f03e..3ee44009107 100644 --- a/config/flags.go +++ b/config/flags.go @@ -91,6 +91,11 @@ func addNodeFlags(fs *pflag.FlagSet) { GenesisFileContentKey)) fs.String(GenesisFileContentKey, "", "Specifies base64 encoded genesis content") + // Upgrade + fs.String(UpgradeFileKey, "", fmt.Sprintf("Specifies an upgrade config file path. Ignored when running standard networks or if %s is specified", + UpgradeFileContentKey)) + fs.String(UpgradeFileContentKey, "", "Specifies base64 encoded upgrade content") + // Network ID fs.String(NetworkNameKey, constants.MainnetName, "Network ID this node will connect to") diff --git a/config/keys.go b/config/keys.go index 289c8317061..35e4df181e8 100644 --- a/config/keys.go +++ b/config/keys.go @@ -16,6 +16,8 @@ const ( VersionJSONKey = "version-json" GenesisFileKey = "genesis-file" GenesisFileContentKey = "genesis-file-content" + UpgradeFileKey = "upgrade-file" + UpgradeFileContentKey = "upgrade-file-content" NetworkNameKey = "network-id" ACPSupportKey = "acp-support" ACPObjectKey = "acp-object" diff --git a/node/node.go b/node/node.go index a1d0367d955..2e413bfe9c5 100644 --- a/node/node.go +++ b/node/node.go @@ -1221,7 +1221,7 @@ func (n *Node) initVMs() error { } // Register the VMs that Avalanche supports - eUpgradeTime := n.Config.UpgradeConfig.EtnaUpgradeTime + eUpgradeTime := n.Config.UpgradeConfig.EtnaTime err := errors.Join( n.VMManager.RegisterFactory(context.TODO(), constants.PlatformVMID, &platformvm.Factory{ Config: platformconfig.Config{ diff --git a/upgrade/upgrade.go b/upgrade/upgrade.go index bf1ee6334b5..fe4d8cead13 100644 --- a/upgrade/upgrade.go +++ b/upgrade/upgrade.go @@ -4,6 +4,7 @@ package upgrade import ( + "fmt" "time" "github.com/ava-labs/avalanchego/ids" @@ -105,7 +106,7 @@ var ( CortinaTime: CortinaTimes[constants.MainnetID], CortinaXChainStopVertexID: CortinaXChainStopVertexID[constants.MainnetID], DurangoTime: DurangoTimes[constants.MainnetID], - EtnaUpgradeTime: EUpgradeTimes[constants.MainnetID], + EtnaTime: EUpgradeTimes[constants.MainnetID], } Fuji = Config{ ApricotPhase1Time: ApricotPhase1Times[constants.FujiID], @@ -121,7 +122,7 @@ var ( CortinaTime: CortinaTimes[constants.FujiID], CortinaXChainStopVertexID: CortinaXChainStopVertexID[constants.FujiID], DurangoTime: DurangoTimes[constants.FujiID], - EtnaUpgradeTime: EUpgradeTimes[constants.FujiID], + EtnaTime: EUpgradeTimes[constants.FujiID], } Default = Config{ ApricotPhase1Time: DefaultUpgradeTime, @@ -137,25 +138,62 @@ var ( CortinaTime: DefaultUpgradeTime, CortinaXChainStopVertexID: ids.Empty, DurangoTime: DefaultUpgradeTime, - EtnaUpgradeTime: DefaultUpgradeTime, + EtnaTime: DefaultUpgradeTime, } ) type Config struct { - ApricotPhase1Time time.Time - ApricotPhase2Time time.Time - ApricotPhase3Time time.Time - ApricotPhase4Time time.Time - ApricotPhase4MinPChainHeight uint64 - ApricotPhase5Time time.Time - ApricotPhasePre6Time time.Time - ApricotPhase6Time time.Time - ApricotPhasePost6Time time.Time - BanffTime time.Time - CortinaTime time.Time - CortinaXChainStopVertexID ids.ID - DurangoTime time.Time - EtnaUpgradeTime time.Time + ApricotPhase1Time time.Time `json:"apricotPhase1Time"` + ApricotPhase2Time time.Time `json:"apricotPhase2Time"` + ApricotPhase3Time time.Time `json:"apricotPhase3Time"` + ApricotPhase4Time time.Time `json:"apricotPhase4Time"` + ApricotPhase4MinPChainHeight uint64 `json:"apricotPhase4MinPChainHeight"` + ApricotPhase5Time time.Time `json:"apricotPhase5Time"` + ApricotPhasePre6Time time.Time `json:"apricotPhasePre6Time"` + ApricotPhase6Time time.Time `json:"apricotPhase6Time"` + ApricotPhasePost6Time time.Time `json:"apricotPhasePost6Time"` + BanffTime time.Time `json:"banffTime"` + CortinaTime time.Time `json:"cortinaTime"` + CortinaXChainStopVertexID ids.ID `json:"cortinaXChainStopVertexID"` + DurangoTime time.Time `json:"durangoTime"` + EtnaTime time.Time `json:"etnaTime"` +} + +func (c Config) Validate() error { + if c.ApricotPhase1Time.After(c.ApricotPhase2Time) { + return fmt.Errorf("apricot phase 1 time (%s) is after apricot phase 2 time (%s)", c.ApricotPhase1Time, c.ApricotPhase2Time) + } + if c.ApricotPhase2Time.After(c.ApricotPhase3Time) { + return fmt.Errorf("apricot phase 2 time (%s) is after apricot phase 3 time (%s)", c.ApricotPhase2Time, c.ApricotPhase3Time) + } + if c.ApricotPhase3Time.After(c.ApricotPhase4Time) { + return fmt.Errorf("apricot phase 3 time (%s) is after apricot phase 4 time (%s)", c.ApricotPhase3Time, c.ApricotPhase4Time) + } + if c.ApricotPhase4Time.After(c.ApricotPhase5Time) { + return fmt.Errorf("apricot phase 4 time (%s) is after apricot phase 5 time (%s)", c.ApricotPhase4Time, c.ApricotPhase5Time) + } + if c.ApricotPhase5Time.After(c.ApricotPhasePre6Time) { + return fmt.Errorf("apricot phase 5 time (%s) is after apricot phase pre-6 time (%s)", c.ApricotPhase5Time, c.ApricotPhasePre6Time) + } + if c.ApricotPhasePre6Time.After(c.ApricotPhase6Time) { + return fmt.Errorf("apricot phase pre-6 time (%s) is after apricot phase 6 time (%s)", c.ApricotPhasePre6Time, c.ApricotPhase6Time) + } + if c.ApricotPhase6Time.After(c.ApricotPhasePost6Time) { + return fmt.Errorf("apricot phase 6 time (%s) is after apricot phase post-6 time (%s)", c.ApricotPhase6Time, c.ApricotPhasePost6Time) + } + if c.ApricotPhasePost6Time.After(c.BanffTime) { + return fmt.Errorf("apricot phase post-6 time (%s) is after banff time (%s)", c.ApricotPhasePost6Time, c.BanffTime) + } + if c.BanffTime.After(c.CortinaTime) { + return fmt.Errorf("banff time (%s) is after cortina time (%s)", c.BanffTime, c.CortinaTime) + } + if c.CortinaTime.After(c.DurangoTime) { + return fmt.Errorf("cortina time (%s) is after durango time (%s)", c.CortinaTime, c.DurangoTime) + } + if c.DurangoTime.After(c.EtnaTime) { + return fmt.Errorf("durango time (%s) is after etna time (%s)", c.DurangoTime, c.EtnaTime) + } + return nil } func GetConfig(networkID uint32) Config { diff --git a/upgrade/upgrade_test.go b/upgrade/upgrade_test.go new file mode 100644 index 00000000000..4ade68da6d0 --- /dev/null +++ b/upgrade/upgrade_test.go @@ -0,0 +1,35 @@ +// Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. +// See the file LICENSE for licensing terms. + +package upgrade + +import ( + "testing" + + "github.com/stretchr/testify/require" +) + +func TestValidDefaultUpgrades(t *testing.T) { + for _, upgradeTest := range []struct { + name string + upgrade Config + }{ + { + name: "Default", + upgrade: Default, + }, + { + name: "Fuji", + upgrade: Fuji, + }, + { + name: "Mainnet", + upgrade: Mainnet, + }, + } { + t.Run(upgradeTest.name, func(t *testing.T) { + require := require.New(t) + require.NoError(upgradeTest.upgrade.Validate()) + }) + } +} From 71f92d8b6a37a1dea8b011d0c0e24dc0f5ffc1cd Mon Sep 17 00:00:00 2001 From: Aaron Buchwald Date: Fri, 26 Jul 2024 13:44:31 -0400 Subject: [PATCH 04/12] change order of content/file flag handling --- config/config.go | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/config/config.go b/config/config.go index b3048e39600..59f5e3f9773 100644 --- a/config/config.go +++ b/config/config.go @@ -787,8 +787,12 @@ func getUpgradeConfig(v *viper.Viper, networkID uint32) (upgrade.Config, error) } switch networkID { - case constants.MainnetID, constants.FujiID, constants.LocalID: - return upgrade.Config{}, fmt.Errorf("cannot configure upgrades on mainnet, fuji, or default local networkID") + case constants.MainnetID: + return upgrade.Config{}, fmt.Errorf("cannot configure upgrades for mainnet networkID: %d", networkID) + case constants.FujiID: + return upgrade.Config{}, fmt.Errorf("cannot configure upgrades for fuji networkID: %d", networkID) + case constants.LocalID: + return upgrade.Config{}, fmt.Errorf("cannot configure upgrades for local networkID: %d", networkID) } var ( @@ -796,18 +800,18 @@ func getUpgradeConfig(v *viper.Viper, networkID uint32) (upgrade.Config, error) err error ) switch { - case v.IsSet(UpgradeFileContentKey): - upgradeContent := v.GetString(UpgradeFileContentKey) - upgradeBytes, err = base64.StdEncoding.DecodeString(upgradeContent) - if err != nil { - return upgrade.Config{}, fmt.Errorf("unable to decode upgrade base64 content: %w", err) - } case v.IsSet(UpgradeFileKey): upgradeFileName := GetExpandedArg(v, UpgradeFileKey) upgradeBytes, err = os.ReadFile(upgradeFileName) if err != nil { return upgrade.Config{}, fmt.Errorf("unable to read upgrade file: %w", err) } + case v.IsSet(UpgradeFileContentKey): + upgradeContent := v.GetString(UpgradeFileContentKey) + upgradeBytes, err = base64.StdEncoding.DecodeString(upgradeContent) + if err != nil { + return upgrade.Config{}, fmt.Errorf("unable to decode upgrade base64 content: %w", err) + } } var upgradeConfig upgrade.Config From 7c45bedc87910d47fd22197d3780097a22ad1639 Mon Sep 17 00:00:00 2001 From: Aaron Buchwald Date: Fri, 26 Jul 2024 14:05:09 -0400 Subject: [PATCH 05/12] Add invalid upgrade test --- upgrade/upgrade.go | 25 ++++++++++++++----------- upgrade/upgrade_test.go | 13 +++++++++++++ 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/upgrade/upgrade.go b/upgrade/upgrade.go index fe4d8cead13..c42e04532f9 100644 --- a/upgrade/upgrade.go +++ b/upgrade/upgrade.go @@ -4,6 +4,7 @@ package upgrade import ( + "errors" "fmt" "time" @@ -12,6 +13,8 @@ import ( ) var ( + ErrInvalidUpgradeTimes = errors.New("invalid upgrade configuration") + DefaultUpgradeTime = time.Date(2020, time.December, 5, 5, 0, 0, 0, time.UTC) ApricotPhase1Times = map[uint32]time.Time{ @@ -161,37 +164,37 @@ type Config struct { func (c Config) Validate() error { if c.ApricotPhase1Time.After(c.ApricotPhase2Time) { - return fmt.Errorf("apricot phase 1 time (%s) is after apricot phase 2 time (%s)", c.ApricotPhase1Time, c.ApricotPhase2Time) + return fmt.Errorf("%w: apricot phase 1 time (%s) is after apricot phase 2 time (%s)", ErrInvalidUpgradeTimes, c.ApricotPhase1Time, c.ApricotPhase2Time) } if c.ApricotPhase2Time.After(c.ApricotPhase3Time) { - return fmt.Errorf("apricot phase 2 time (%s) is after apricot phase 3 time (%s)", c.ApricotPhase2Time, c.ApricotPhase3Time) + return fmt.Errorf("%w: apricot phase 2 time (%s) is after apricot phase 3 time (%s)", ErrInvalidUpgradeTimes, c.ApricotPhase2Time, c.ApricotPhase3Time) } if c.ApricotPhase3Time.After(c.ApricotPhase4Time) { - return fmt.Errorf("apricot phase 3 time (%s) is after apricot phase 4 time (%s)", c.ApricotPhase3Time, c.ApricotPhase4Time) + return fmt.Errorf("%w: apricot phase 3 time (%s) is after apricot phase 4 time (%s)", ErrInvalidUpgradeTimes, c.ApricotPhase3Time, c.ApricotPhase4Time) } if c.ApricotPhase4Time.After(c.ApricotPhase5Time) { - return fmt.Errorf("apricot phase 4 time (%s) is after apricot phase 5 time (%s)", c.ApricotPhase4Time, c.ApricotPhase5Time) + return fmt.Errorf("%w: apricot phase 4 time (%s) is after apricot phase 5 time (%s)", ErrInvalidUpgradeTimes, c.ApricotPhase4Time, c.ApricotPhase5Time) } if c.ApricotPhase5Time.After(c.ApricotPhasePre6Time) { - return fmt.Errorf("apricot phase 5 time (%s) is after apricot phase pre-6 time (%s)", c.ApricotPhase5Time, c.ApricotPhasePre6Time) + return fmt.Errorf("%w: apricot phase 5 time (%s) is after apricot phase pre-6 time (%s)", ErrInvalidUpgradeTimes, c.ApricotPhase5Time, c.ApricotPhasePre6Time) } if c.ApricotPhasePre6Time.After(c.ApricotPhase6Time) { - return fmt.Errorf("apricot phase pre-6 time (%s) is after apricot phase 6 time (%s)", c.ApricotPhasePre6Time, c.ApricotPhase6Time) + return fmt.Errorf("%w: apricot phase pre-6 time (%s) is after apricot phase 6 time (%s)", ErrInvalidUpgradeTimes, c.ApricotPhasePre6Time, c.ApricotPhase6Time) } if c.ApricotPhase6Time.After(c.ApricotPhasePost6Time) { - return fmt.Errorf("apricot phase 6 time (%s) is after apricot phase post-6 time (%s)", c.ApricotPhase6Time, c.ApricotPhasePost6Time) + return fmt.Errorf("%w: apricot phase 6 time (%s) is after apricot phase post-6 time (%s)", ErrInvalidUpgradeTimes, c.ApricotPhase6Time, c.ApricotPhasePost6Time) } if c.ApricotPhasePost6Time.After(c.BanffTime) { - return fmt.Errorf("apricot phase post-6 time (%s) is after banff time (%s)", c.ApricotPhasePost6Time, c.BanffTime) + return fmt.Errorf("%w: apricot phase post-6 time (%s) is after banff time (%s)", ErrInvalidUpgradeTimes, c.ApricotPhasePost6Time, c.BanffTime) } if c.BanffTime.After(c.CortinaTime) { - return fmt.Errorf("banff time (%s) is after cortina time (%s)", c.BanffTime, c.CortinaTime) + return fmt.Errorf("%w: banff time (%s) is after cortina time (%s)", ErrInvalidUpgradeTimes, c.BanffTime, c.CortinaTime) } if c.CortinaTime.After(c.DurangoTime) { - return fmt.Errorf("cortina time (%s) is after durango time (%s)", c.CortinaTime, c.DurangoTime) + return fmt.Errorf("%w: cortina time (%s) is after durango time (%s)", ErrInvalidUpgradeTimes, c.CortinaTime, c.DurangoTime) } if c.DurangoTime.After(c.EtnaTime) { - return fmt.Errorf("durango time (%s) is after etna time (%s)", c.DurangoTime, c.EtnaTime) + return fmt.Errorf("%w: durango time (%s) is after etna time (%s)", ErrInvalidUpgradeTimes, c.DurangoTime, c.EtnaTime) } return nil } diff --git a/upgrade/upgrade_test.go b/upgrade/upgrade_test.go index 4ade68da6d0..eb9cdb38bd3 100644 --- a/upgrade/upgrade_test.go +++ b/upgrade/upgrade_test.go @@ -5,6 +5,7 @@ package upgrade import ( "testing" + "time" "github.com/stretchr/testify/require" ) @@ -33,3 +34,15 @@ func TestValidDefaultUpgrades(t *testing.T) { }) } } + +func TestInvalidUpgrade(t *testing.T) { + require := require.New(t) + firstUpgradeTime := time.Now() + invalidSecondUpgradeTime := firstUpgradeTime.Add(-1 * time.Second) + upgrade := Config{ + ApricotPhase1Time: firstUpgradeTime, + ApricotPhase2Time: invalidSecondUpgradeTime, + } + err := upgrade.Validate() + require.ErrorIs(err, ErrInvalidUpgradeTimes) +} From b6fb8fa44c318d541c908272ec1ce847eb69fdec Mon Sep 17 00:00:00 2001 From: Aaron Buchwald Date: Fri, 26 Jul 2024 14:16:35 -0400 Subject: [PATCH 06/12] bump coreth --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 8e9846a68e7..37eb809e355 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/DataDog/zstd v1.5.2 github.com/NYTimes/gziphandler v1.1.1 github.com/antithesishq/antithesis-sdk-go v0.3.8 - github.com/ava-labs/coreth v0.13.8-0.20240726001013-e5d123e010da + github.com/ava-labs/coreth v0.13.8-0.20240726181218-5de5e26d2d06 github.com/ava-labs/ledger-avalanche/go v0.0.0-20240610153809-9c955cc90a95 github.com/btcsuite/btcd/btcutil v1.1.3 github.com/cockroachdb/pebble v0.0.0-20230928194634-aa077af62593 diff --git a/go.sum b/go.sum index 030c890fddc..467cd16481e 100644 --- a/go.sum +++ b/go.sum @@ -62,8 +62,8 @@ github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax github.com/antithesishq/antithesis-sdk-go v0.3.8 h1:OvGoHxIcOXFJLyn9IJQ5DzByZ3YVAWNBc394ObzDRb8= github.com/antithesishq/antithesis-sdk-go v0.3.8/go.mod h1:IUpT2DPAKh6i/YhSbt6Gl3v2yvUZjmKncl7U91fup7E= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= -github.com/ava-labs/coreth v0.13.8-0.20240726001013-e5d123e010da h1:QUR0bREz315+j8kI89o+XQOoDSj21Mn2z4ayVspNRZg= -github.com/ava-labs/coreth v0.13.8-0.20240726001013-e5d123e010da/go.mod h1:apBYWuSBsADVDzpajW/JJDRlom1/co7zT8PU+6CUECw= +github.com/ava-labs/coreth v0.13.8-0.20240726181218-5de5e26d2d06 h1:avudVHFinDUhAr5i6kx2OCG6Fcid0Q7tF+UlI5yufR0= +github.com/ava-labs/coreth v0.13.8-0.20240726181218-5de5e26d2d06/go.mod h1:iFNJdWrpPe+ifGQknsg5obEHdihW4mjMJC6QFT4UnaI= github.com/ava-labs/ledger-avalanche/go v0.0.0-20240610153809-9c955cc90a95 h1:dOVbtdnZL++pENdTCNZ1nu41eYDQkTML4sWebDnnq8c= github.com/ava-labs/ledger-avalanche/go v0.0.0-20240610153809-9c955cc90a95/go.mod h1:pJxaT9bUgeRNVmNRgtCHb7sFDIRKy7CzTQVi8gGNT6g= github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g= From 298961383d0bf311de877e13098408c8036b5f14 Mon Sep 17 00:00:00 2001 From: Aaron Buchwald Date: Sun, 28 Jul 2024 11:38:59 -0400 Subject: [PATCH 07/12] Update coreth dep --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 37eb809e355..d9892a314d5 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/DataDog/zstd v1.5.2 github.com/NYTimes/gziphandler v1.1.1 github.com/antithesishq/antithesis-sdk-go v0.3.8 - github.com/ava-labs/coreth v0.13.8-0.20240726181218-5de5e26d2d06 + github.com/ava-labs/coreth v0.13.8-0.20240728153455-82b5d021f081 github.com/ava-labs/ledger-avalanche/go v0.0.0-20240610153809-9c955cc90a95 github.com/btcsuite/btcd/btcutil v1.1.3 github.com/cockroachdb/pebble v0.0.0-20230928194634-aa077af62593 diff --git a/go.sum b/go.sum index 467cd16481e..fc31ea2ab99 100644 --- a/go.sum +++ b/go.sum @@ -62,8 +62,8 @@ github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax github.com/antithesishq/antithesis-sdk-go v0.3.8 h1:OvGoHxIcOXFJLyn9IJQ5DzByZ3YVAWNBc394ObzDRb8= github.com/antithesishq/antithesis-sdk-go v0.3.8/go.mod h1:IUpT2DPAKh6i/YhSbt6Gl3v2yvUZjmKncl7U91fup7E= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= -github.com/ava-labs/coreth v0.13.8-0.20240726181218-5de5e26d2d06 h1:avudVHFinDUhAr5i6kx2OCG6Fcid0Q7tF+UlI5yufR0= -github.com/ava-labs/coreth v0.13.8-0.20240726181218-5de5e26d2d06/go.mod h1:iFNJdWrpPe+ifGQknsg5obEHdihW4mjMJC6QFT4UnaI= +github.com/ava-labs/coreth v0.13.8-0.20240728153455-82b5d021f081 h1:xgl4bbOf7+s7p6y+khveDY2BcxDlY+XdaTMlc6m/41o= +github.com/ava-labs/coreth v0.13.8-0.20240728153455-82b5d021f081/go.mod h1:YBkvMDJxoYOsKJUOUvZEhJx06xPuWrqNfG7X8tlUNec= github.com/ava-labs/ledger-avalanche/go v0.0.0-20240610153809-9c955cc90a95 h1:dOVbtdnZL++pENdTCNZ1nu41eYDQkTML4sWebDnnq8c= github.com/ava-labs/ledger-avalanche/go v0.0.0-20240610153809-9c955cc90a95/go.mod h1:pJxaT9bUgeRNVmNRgtCHb7sFDIRKy7CzTQVi8gGNT6g= github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g= From bbe6de53f10478e777986302b0e9e6796d0ce2fe Mon Sep 17 00:00:00 2001 From: Stephen Buttolph Date: Thu, 1 Aug 2024 15:42:51 -0400 Subject: [PATCH 08/12] Cleanup upgrade config (#3257) --- chains/manager.go | 34 +- config/config.go | 10 +- network/network_test.go | 8 +- network/peer/peer_test.go | 30 +- network/peer/test_peer.go | 2 +- network/test_network.go | 2 +- node/node.go | 26 +- snow/engine/avalanche/state/serializer.go | 10 +- upgrade/upgrade.go | 293 ++++++++++-------- vms/avm/block/executor/block_test.go | 5 +- vms/avm/config/config.go | 14 +- vms/avm/environment_test.go | 11 +- vms/avm/service_test.go | 5 +- vms/avm/state/state_test.go | 2 +- .../txs/executor/syntactic_verifier_test.go | 5 +- vms/avm/vm.go | 2 +- vms/platformvm/block/builder/helpers_test.go | 6 +- vms/platformvm/block/executor/helpers_test.go | 6 +- .../block/executor/verifier_test.go | 2 +- vms/platformvm/config/config.go | 2 +- vms/platformvm/txs/executor/helpers_test.go | 6 +- .../txs/executor/standard_tx_executor_test.go | 6 +- vms/platformvm/upgrade/config.go | 50 --- vms/platformvm/validator_set_property_test.go | 4 +- vms/platformvm/vm_regression_test.go | 10 +- vms/platformvm/vm_test.go | 64 ++-- vms/proposervm/batched_vm_test.go | 9 +- vms/proposervm/block.go | 4 +- vms/proposervm/block_test.go | 15 +- vms/proposervm/config.go | 14 +- vms/proposervm/post_fork_option_test.go | 9 +- vms/proposervm/pre_fork_block.go | 10 +- vms/proposervm/pre_fork_block_test.go | 2 +- vms/proposervm/state_syncable_vm_test.go | 9 +- vms/proposervm/vm.go | 2 +- vms/proposervm/vm_test.go | 89 ++++-- 36 files changed, 389 insertions(+), 389 deletions(-) delete mode 100644 vms/platformvm/upgrade/config.go diff --git a/chains/manager.go b/chains/manager.go index a89834b93fb..1980b999a01 100644 --- a/chains/manager.go +++ b/chains/manager.go @@ -43,6 +43,7 @@ import ( "github.com/ava-labs/avalanchego/staking" "github.com/ava-labs/avalanchego/subnets" "github.com/ava-labs/avalanchego/trace" + "github.com/ava-labs/avalanchego/upgrade" "github.com/ava-labs/avalanchego/utils/buffer" "github.com/ava-labs/avalanchego/utils/constants" "github.com/ava-labs/avalanchego/utils/crypto/bls" @@ -232,11 +233,7 @@ type ManagerConfig struct { // containers in an ancestors message it receives. BootstrapAncestorsMaxContainersReceived int - ApricotPhase4Time time.Time - ApricotPhase4MinPChainHeight uint64 - CortinaTime time.Time - CortinaXChainStopVertexID ids.ID - DurangoTime time.Time + Upgrades upgrade.Config // Tracks CPU/disk usage caused by each peer. ResourceTracker timetracker.ResourceTracker @@ -728,11 +725,10 @@ func (m *manager) createAvalancheChain( // persistence of vertices vtxManager := state.NewSerializer( state.SerializerConfig{ - ChainID: ctx.ChainID, - VM: dagVM, - DB: vertexDB, - Log: ctx.Log, - CortinaTime: m.CortinaTime, + ChainID: ctx.ChainID, + VM: dagVM, + DB: vertexDB, + Log: ctx.Log, }, ) @@ -769,8 +765,8 @@ func (m *manager) createAvalancheChain( numHistoricalBlocks = subnetCfg.ProposerNumHistoricalBlocks } m.Log.Info("creating proposervm wrapper", - zap.Time("activationTime", m.ApricotPhase4Time), - zap.Uint64("minPChainHeight", m.ApricotPhase4MinPChainHeight), + zap.Time("activationTime", m.Upgrades.ApricotPhase4Time), + zap.Uint64("minPChainHeight", m.Upgrades.ApricotPhase4MinPChainHeight), zap.Duration("minBlockDelay", minBlockDelay), zap.Uint64("numHistoricalBlocks", numHistoricalBlocks), ) @@ -796,9 +792,7 @@ func (m *manager) createAvalancheChain( var vmWrappingProposerVM block.ChainVM = proposervm.New( vmWrappedInsideProposerVM, proposervm.Config{ - ActivationTime: m.ApricotPhase4Time, - DurangoTime: m.DurangoTime, - MinimumPChainHeight: m.ApricotPhase4MinPChainHeight, + Upgrades: m.Upgrades, MinBlkDelay: minBlockDelay, NumHistoricalBlocks: numHistoricalBlocks, StakingLeafSigner: m.StakingTLSSigner, @@ -1012,7 +1006,7 @@ func (m *manager) createAvalancheChain( VM: linearizableVM, } if ctx.ChainID == m.XChainID { - avalancheBootstrapperConfig.StopVertexID = m.CortinaXChainStopVertexID + avalancheBootstrapperConfig.StopVertexID = m.Upgrades.CortinaXChainStopVertexID } avalancheBootstrapper, err := avbootstrap.New( @@ -1172,8 +1166,8 @@ func (m *manager) createSnowmanChain( numHistoricalBlocks = subnetCfg.ProposerNumHistoricalBlocks } m.Log.Info("creating proposervm wrapper", - zap.Time("activationTime", m.ApricotPhase4Time), - zap.Uint64("minPChainHeight", m.ApricotPhase4MinPChainHeight), + zap.Time("activationTime", m.Upgrades.ApricotPhase4Time), + zap.Uint64("minPChainHeight", m.Upgrades.ApricotPhase4MinPChainHeight), zap.Duration("minBlockDelay", minBlockDelay), zap.Uint64("numHistoricalBlocks", numHistoricalBlocks), ) @@ -1193,9 +1187,7 @@ func (m *manager) createSnowmanChain( vm = proposervm.New( vm, proposervm.Config{ - ActivationTime: m.ApricotPhase4Time, - DurangoTime: m.DurangoTime, - MinimumPChainHeight: m.ApricotPhase4MinPChainHeight, + Upgrades: m.Upgrades, MinBlkDelay: minBlockDelay, NumHistoricalBlocks: numHistoricalBlocks, StakingLeafSigner: m.StakingTLSSigner, diff --git a/config/config.go b/config/config.go index 925318383ce..e0176464b90 100644 --- a/config/config.go +++ b/config/config.go @@ -804,12 +804,10 @@ func getUpgradeConfig(v *viper.Viper, networkID uint32) (upgrade.Config, error) } switch networkID { - case constants.MainnetID: - return upgrade.Config{}, fmt.Errorf("cannot configure upgrades for mainnet networkID: %d", networkID) - case constants.FujiID: - return upgrade.Config{}, fmt.Errorf("cannot configure upgrades for fuji networkID: %d", networkID) - case constants.LocalID: - return upgrade.Config{}, fmt.Errorf("cannot configure upgrades for local networkID: %d", networkID) + case constants.MainnetID, constants.TestnetID, constants.LocalID: + return upgrade.Config{}, fmt.Errorf("cannot configure upgrades for networkID: %s", + constants.NetworkName(networkID), + ) } var ( diff --git a/network/network_test.go b/network/network_test.go index 7cfdf6bf7c2..a79d5d0cf71 100644 --- a/network/network_test.go +++ b/network/network_test.go @@ -238,7 +238,7 @@ func newFullyConnectedTestNetwork(t *testing.T, handlers []router.InboundHandler var connected set.Set[ids.NodeID] net, err := NewNetwork( config, - upgrade.DefaultUpgradeTime, + upgrade.InitiallyActiveTime, msgCreator, registry, logging.NoLog{}, @@ -468,7 +468,7 @@ func TestTrackDoesNotDialPrivateIPs(t *testing.T) { net, err := NewNetwork( config, - upgrade.DefaultUpgradeTime, + upgrade.InitiallyActiveTime, msgCreator, registry, logging.NoLog{}, @@ -548,7 +548,7 @@ func TestDialDeletesNonValidators(t *testing.T) { net, err := NewNetwork( config, - upgrade.DefaultUpgradeTime, + upgrade.InitiallyActiveTime, msgCreator, registry, logging.NoLog{}, @@ -703,7 +703,7 @@ func TestAllowConnectionAsAValidator(t *testing.T) { net, err := NewNetwork( config, - upgrade.DefaultUpgradeTime, + upgrade.InitiallyActiveTime, msgCreator, registry, logging.NoLog{}, diff --git a/network/peer/peer_test.go b/network/peer/peer_test.go index 57d03c51e5f..316b491180a 100644 --- a/network/peer/peer_test.go +++ b/network/peer/peer_test.go @@ -84,7 +84,7 @@ func newConfig(t *testing.T) Config { InboundMsgThrottler: throttling.NewNoInboundThrottler(), Network: TestNetwork, Router: nil, - VersionCompatibility: version.GetCompatibility(upgrade.DefaultUpgradeTime), + VersionCompatibility: version.GetCompatibility(upgrade.InitiallyActiveTime), MySubnets: nil, Beacons: validators.NewManager(), Validators: validators.NewManager(), @@ -452,7 +452,7 @@ func TestShouldDisconnect(t *testing.T) { initialPeer: &peer{ Config: &Config{ Log: logging.NoLog{}, - VersionCompatibility: version.GetCompatibility(upgrade.DefaultUpgradeTime), + VersionCompatibility: version.GetCompatibility(upgrade.InitiallyActiveTime), }, version: &version.Application{ Name: version.Client, @@ -464,7 +464,7 @@ func TestShouldDisconnect(t *testing.T) { expectedPeer: &peer{ Config: &Config{ Log: logging.NoLog{}, - VersionCompatibility: version.GetCompatibility(upgrade.DefaultUpgradeTime), + VersionCompatibility: version.GetCompatibility(upgrade.InitiallyActiveTime), }, version: &version.Application{ Name: version.Client, @@ -480,7 +480,7 @@ func TestShouldDisconnect(t *testing.T) { initialPeer: &peer{ Config: &Config{ Log: logging.NoLog{}, - VersionCompatibility: version.GetCompatibility(upgrade.DefaultUpgradeTime), + VersionCompatibility: version.GetCompatibility(upgrade.InitiallyActiveTime), Validators: validators.NewManager(), }, version: version.CurrentApp, @@ -488,7 +488,7 @@ func TestShouldDisconnect(t *testing.T) { expectedPeer: &peer{ Config: &Config{ Log: logging.NoLog{}, - VersionCompatibility: version.GetCompatibility(upgrade.DefaultUpgradeTime), + VersionCompatibility: version.GetCompatibility(upgrade.InitiallyActiveTime), Validators: validators.NewManager(), }, version: version.CurrentApp, @@ -500,7 +500,7 @@ func TestShouldDisconnect(t *testing.T) { initialPeer: &peer{ Config: &Config{ Log: logging.NoLog{}, - VersionCompatibility: version.GetCompatibility(upgrade.DefaultUpgradeTime), + VersionCompatibility: version.GetCompatibility(upgrade.InitiallyActiveTime), Validators: func() validators.Manager { vdrs := validators.NewManager() require.NoError(t, vdrs.AddStaker( @@ -519,7 +519,7 @@ func TestShouldDisconnect(t *testing.T) { expectedPeer: &peer{ Config: &Config{ Log: logging.NoLog{}, - VersionCompatibility: version.GetCompatibility(upgrade.DefaultUpgradeTime), + VersionCompatibility: version.GetCompatibility(upgrade.InitiallyActiveTime), Validators: func() validators.Manager { vdrs := validators.NewManager() require.NoError(t, vdrs.AddStaker( @@ -542,7 +542,7 @@ func TestShouldDisconnect(t *testing.T) { initialPeer: &peer{ Config: &Config{ Log: logging.NoLog{}, - VersionCompatibility: version.GetCompatibility(upgrade.DefaultUpgradeTime), + VersionCompatibility: version.GetCompatibility(upgrade.InitiallyActiveTime), Validators: func() validators.Manager { vdrs := validators.NewManager() require.NoError(t, vdrs.AddStaker( @@ -562,7 +562,7 @@ func TestShouldDisconnect(t *testing.T) { expectedPeer: &peer{ Config: &Config{ Log: logging.NoLog{}, - VersionCompatibility: version.GetCompatibility(upgrade.DefaultUpgradeTime), + VersionCompatibility: version.GetCompatibility(upgrade.InitiallyActiveTime), Validators: func() validators.Manager { vdrs := validators.NewManager() require.NoError(t, vdrs.AddStaker( @@ -586,7 +586,7 @@ func TestShouldDisconnect(t *testing.T) { initialPeer: &peer{ Config: &Config{ Log: logging.NoLog{}, - VersionCompatibility: version.GetCompatibility(upgrade.DefaultUpgradeTime), + VersionCompatibility: version.GetCompatibility(upgrade.InitiallyActiveTime), Validators: func() validators.Manager { vdrs := validators.NewManager() require.NoError(t, vdrs.AddStaker( @@ -606,7 +606,7 @@ func TestShouldDisconnect(t *testing.T) { expectedPeer: &peer{ Config: &Config{ Log: logging.NoLog{}, - VersionCompatibility: version.GetCompatibility(upgrade.DefaultUpgradeTime), + VersionCompatibility: version.GetCompatibility(upgrade.InitiallyActiveTime), Validators: func() validators.Manager { vdrs := validators.NewManager() require.NoError(t, vdrs.AddStaker( @@ -630,7 +630,7 @@ func TestShouldDisconnect(t *testing.T) { initialPeer: &peer{ Config: &Config{ Log: logging.NoLog{}, - VersionCompatibility: version.GetCompatibility(upgrade.DefaultUpgradeTime), + VersionCompatibility: version.GetCompatibility(upgrade.InitiallyActiveTime), Validators: func() validators.Manager { vdrs := validators.NewManager() require.NoError(t, vdrs.AddStaker( @@ -652,7 +652,7 @@ func TestShouldDisconnect(t *testing.T) { expectedPeer: &peer{ Config: &Config{ Log: logging.NoLog{}, - VersionCompatibility: version.GetCompatibility(upgrade.DefaultUpgradeTime), + VersionCompatibility: version.GetCompatibility(upgrade.InitiallyActiveTime), Validators: func() validators.Manager { vdrs := validators.NewManager() require.NoError(t, vdrs.AddStaker( @@ -678,7 +678,7 @@ func TestShouldDisconnect(t *testing.T) { initialPeer: &peer{ Config: &Config{ Log: logging.NoLog{}, - VersionCompatibility: version.GetCompatibility(upgrade.DefaultUpgradeTime), + VersionCompatibility: version.GetCompatibility(upgrade.InitiallyActiveTime), Validators: func() validators.Manager { vdrs := validators.NewManager() require.NoError(t, vdrs.AddStaker( @@ -700,7 +700,7 @@ func TestShouldDisconnect(t *testing.T) { expectedPeer: &peer{ Config: &Config{ Log: logging.NoLog{}, - VersionCompatibility: version.GetCompatibility(upgrade.DefaultUpgradeTime), + VersionCompatibility: version.GetCompatibility(upgrade.InitiallyActiveTime), Validators: func() validators.Manager { vdrs := validators.NewManager() require.NoError(t, vdrs.AddStaker( diff --git a/network/peer/test_peer.go b/network/peer/test_peer.go index 592e53d9b0c..bb102298263 100644 --- a/network/peer/test_peer.go +++ b/network/peer/test_peer.go @@ -114,7 +114,7 @@ func StartTestPeer( InboundMsgThrottler: throttling.NewNoInboundThrottler(), Network: TestNetwork, Router: router, - VersionCompatibility: version.GetCompatibility(upgrade.DefaultUpgradeTime), + VersionCompatibility: version.GetCompatibility(upgrade.InitiallyActiveTime), MySubnets: set.Set[ids.ID]{}, Beacons: validators.NewManager(), Validators: validators.NewManager(), diff --git a/network/test_network.go b/network/test_network.go index 4b8aba89a79..e0647210ee5 100644 --- a/network/test_network.go +++ b/network/test_network.go @@ -217,7 +217,7 @@ func NewTestNetwork( resourceTracker.DiskTracker(), ), }, - upgrade.DefaultUpgradeTime, + upgrade.InitiallyActiveTime, msgCreator, metrics, log, diff --git a/node/node.go b/node/node.go index fd76136dc6f..ca804b815cd 100644 --- a/node/node.go +++ b/node/node.go @@ -82,7 +82,6 @@ import ( avmconfig "github.com/ava-labs/avalanchego/vms/avm/config" platformconfig "github.com/ava-labs/avalanchego/vms/platformvm/config" - pupgrade "github.com/ava-labs/avalanchego/vms/platformvm/upgrade" coreth "github.com/ava-labs/coreth/plugin/evm" ) @@ -1185,11 +1184,7 @@ func (n *Node) initChainManager(avaxAssetID ids.ID) error { BootstrapMaxTimeGetAncestors: n.Config.BootstrapMaxTimeGetAncestors, BootstrapAncestorsMaxContainersSent: n.Config.BootstrapAncestorsMaxContainersSent, BootstrapAncestorsMaxContainersReceived: n.Config.BootstrapAncestorsMaxContainersReceived, - ApricotPhase4Time: n.Config.UpgradeConfig.ApricotPhase4Time, - ApricotPhase4MinPChainHeight: n.Config.UpgradeConfig.ApricotPhase4MinPChainHeight, - CortinaTime: n.Config.UpgradeConfig.CortinaTime, - CortinaXChainStopVertexID: n.Config.UpgradeConfig.CortinaXChainStopVertexID, - DurangoTime: n.Config.UpgradeConfig.DurangoTime, + Upgrades: n.Config.UpgradeConfig, ResourceTracker: n.resourceTracker, StateSyncBeacons: n.Config.StateSyncIDs, TracingEnabled: n.Config.TraceConfig.Enabled, @@ -1221,7 +1216,6 @@ func (n *Node) initVMs() error { } // Register the VMs that Avalanche supports - eUpgradeTime := n.Config.UpgradeConfig.EtnaTime err := errors.Join( n.VMManager.RegisterFactory(context.TODO(), constants.PlatformVMID, &platformvm.Factory{ Config: platformconfig.Config{ @@ -1242,23 +1236,15 @@ func (n *Node) initVMs() error { MinStakeDuration: n.Config.MinStakeDuration, MaxStakeDuration: n.Config.MaxStakeDuration, RewardConfig: n.Config.RewardConfig, - UpgradeConfig: pupgrade.Config{ - ApricotPhase3Time: n.Config.UpgradeConfig.ApricotPhase3Time, - ApricotPhase5Time: n.Config.UpgradeConfig.ApricotPhase5Time, - BanffTime: n.Config.UpgradeConfig.BanffTime, - CortinaTime: n.Config.UpgradeConfig.CortinaTime, - DurangoTime: n.Config.UpgradeConfig.DurangoTime, - EUpgradeTime: eUpgradeTime, - }, - UseCurrentHeight: n.Config.UseCurrentHeight, + UpgradeConfig: n.Config.UpgradeConfig, + UseCurrentHeight: n.Config.UseCurrentHeight, }, }), n.VMManager.RegisterFactory(context.TODO(), constants.AVMID, &avm.Factory{ Config: avmconfig.Config{ - TxFee: n.Config.StaticFeeConfig.TxFee, - CreateAssetTxFee: n.Config.CreateAssetTxFee, - CortinaUpgradeTime: n.Config.UpgradeConfig.CortinaTime, - EUpgradeTime: eUpgradeTime, + Upgrades: n.Config.UpgradeConfig, + TxFee: n.Config.StaticFeeConfig.TxFee, + CreateAssetTxFee: n.Config.CreateAssetTxFee, }, }), n.VMManager.RegisterFactory(context.TODO(), constants.EVMID, &coreth.Factory{}), diff --git a/snow/engine/avalanche/state/serializer.go b/snow/engine/avalanche/state/serializer.go index d88fa79ae24..1b0051bb666 100644 --- a/snow/engine/avalanche/state/serializer.go +++ b/snow/engine/avalanche/state/serializer.go @@ -8,7 +8,6 @@ package state import ( "context" "errors" - "time" "github.com/ava-labs/avalanchego/cache" "github.com/ava-labs/avalanchego/database" @@ -43,11 +42,10 @@ type Serializer struct { } type SerializerConfig struct { - ChainID ids.ID - VM vertex.DAGVM - DB database.Database - Log logging.Logger - CortinaTime time.Time + ChainID ids.ID + VM vertex.DAGVM + DB database.Database + Log logging.Logger } func NewSerializer(config SerializerConfig) vertex.Manager { diff --git a/upgrade/upgrade.go b/upgrade/upgrade.go index c42e04532f9..d2b1fd912c6 100644 --- a/upgrade/upgrade.go +++ b/upgrade/upgrade.go @@ -13,136 +13,139 @@ import ( ) var ( - ErrInvalidUpgradeTimes = errors.New("invalid upgrade configuration") + InitiallyActiveTime = time.Date(2020, time.December, 5, 5, 0, 0, 0, time.UTC) + UnscheduledActivationTime = time.Date(10000, time.December, 1, 0, 0, 0, 0, time.UTC) - DefaultUpgradeTime = time.Date(2020, time.December, 5, 5, 0, 0, 0, time.UTC) + Mainnet = Config{ + ApricotPhase1Time: time.Date(2021, time.March, 31, 14, 0, 0, 0, time.UTC), + ApricotPhase2Time: time.Date(2021, time.May, 10, 11, 0, 0, 0, time.UTC), + ApricotPhase3Time: time.Date(2021, time.August, 24, 14, 0, 0, 0, time.UTC), + ApricotPhase4Time: time.Date(2021, time.September, 22, 21, 0, 0, 0, time.UTC), + ApricotPhase4MinPChainHeight: 793005, + ApricotPhase5Time: time.Date(2021, time.December, 2, 18, 0, 0, 0, time.UTC), + ApricotPhasePre6Time: time.Date(2022, time.September, 5, 1, 30, 0, 0, time.UTC), + ApricotPhase6Time: time.Date(2022, time.September, 6, 20, 0, 0, 0, time.UTC), + ApricotPhasePost6Time: time.Date(2022, time.September, 7, 3, 0, 0, 0, time.UTC), + BanffTime: time.Date(2022, time.October, 18, 16, 0, 0, 0, time.UTC), + CortinaTime: time.Date(2023, time.April, 25, 15, 0, 0, 0, time.UTC), + // The mainnet stop vertex is well known. It can be verified on any + // fully synced node by looking at the parentID of the genesis block. + // + // Ref: https://subnets.avax.network/x-chain/block/0 + CortinaXChainStopVertexID: ids.FromStringOrPanic("jrGWDh5Po9FMj54depyunNixpia5PN4aAYxfmNzU8n752Rjga"), + DurangoTime: time.Date(2024, time.March, 6, 16, 0, 0, 0, time.UTC), + EtnaTime: UnscheduledActivationTime, + } + Fuji = Config{ + ApricotPhase1Time: time.Date(2021, time.March, 26, 14, 0, 0, 0, time.UTC), + ApricotPhase2Time: time.Date(2021, time.May, 5, 14, 0, 0, 0, time.UTC), + ApricotPhase3Time: time.Date(2021, time.August, 16, 19, 0, 0, 0, time.UTC), + ApricotPhase4Time: time.Date(2021, time.September, 16, 21, 0, 0, 0, time.UTC), + ApricotPhase4MinPChainHeight: 47437, + ApricotPhase5Time: time.Date(2021, time.November, 24, 15, 0, 0, 0, time.UTC), + ApricotPhasePre6Time: time.Date(2022, time.September, 6, 20, 0, 0, 0, time.UTC), + ApricotPhase6Time: time.Date(2022, time.September, 6, 20, 0, 0, 0, time.UTC), + ApricotPhasePost6Time: time.Date(2022, time.September, 7, 6, 0, 0, 0, time.UTC), + BanffTime: time.Date(2022, time.October, 3, 14, 0, 0, 0, time.UTC), + CortinaTime: time.Date(2023, time.April, 6, 15, 0, 0, 0, time.UTC), + // The fuji stop vertex is well known. It can be verified on any fully + // synced node by looking at the parentID of the genesis block. + // + // Ref: https://subnets-test.avax.network/x-chain/block/0 + CortinaXChainStopVertexID: ids.FromStringOrPanic("2D1cmbiG36BqQMRyHt4kFhWarmatA1ighSpND3FeFgz3vFVtCZ"), + DurangoTime: time.Date(2024, time.February, 13, 16, 0, 0, 0, time.UTC), + EtnaTime: UnscheduledActivationTime, + } + Default = Config{ + ApricotPhase1Time: InitiallyActiveTime, + ApricotPhase2Time: InitiallyActiveTime, + ApricotPhase3Time: InitiallyActiveTime, + ApricotPhase4Time: InitiallyActiveTime, + ApricotPhase4MinPChainHeight: 0, + ApricotPhase5Time: InitiallyActiveTime, + ApricotPhasePre6Time: InitiallyActiveTime, + ApricotPhase6Time: InitiallyActiveTime, + ApricotPhasePost6Time: InitiallyActiveTime, + BanffTime: InitiallyActiveTime, + CortinaTime: InitiallyActiveTime, + CortinaXChainStopVertexID: ids.Empty, + DurangoTime: InitiallyActiveTime, + EtnaTime: InitiallyActiveTime, + } + // Deprecated: This will be removed once coreth no longer uses it. ApricotPhase1Times = map[uint32]time.Time{ - constants.MainnetID: time.Date(2021, time.March, 31, 14, 0, 0, 0, time.UTC), - constants.FujiID: time.Date(2021, time.March, 26, 14, 0, 0, 0, time.UTC), + constants.MainnetID: Mainnet.ApricotPhase1Time, + constants.FujiID: Fuji.ApricotPhase1Time, } + // Deprecated: This will be removed once coreth no longer uses it. ApricotPhase2Times = map[uint32]time.Time{ - constants.MainnetID: time.Date(2021, time.May, 10, 11, 0, 0, 0, time.UTC), - constants.FujiID: time.Date(2021, time.May, 5, 14, 0, 0, 0, time.UTC), + constants.MainnetID: Mainnet.ApricotPhase2Time, + constants.FujiID: Fuji.ApricotPhase2Time, } + // Deprecated: This will be removed once coreth no longer uses it. ApricotPhase3Times = map[uint32]time.Time{ - constants.MainnetID: time.Date(2021, time.August, 24, 14, 0, 0, 0, time.UTC), - constants.FujiID: time.Date(2021, time.August, 16, 19, 0, 0, 0, time.UTC), + constants.MainnetID: Mainnet.ApricotPhase3Time, + constants.FujiID: Fuji.ApricotPhase3Time, } + // Deprecated: This will be removed once coreth no longer uses it. ApricotPhase4Times = map[uint32]time.Time{ - constants.MainnetID: time.Date(2021, time.September, 22, 21, 0, 0, 0, time.UTC), - constants.FujiID: time.Date(2021, time.September, 16, 21, 0, 0, 0, time.UTC), - } - ApricotPhase4MinPChainHeight = map[uint32]uint64{ - constants.MainnetID: 793005, - constants.FujiID: 47437, + constants.MainnetID: Mainnet.ApricotPhase4Time, + constants.FujiID: Fuji.ApricotPhase4Time, } + // Deprecated: This will be removed once coreth no longer uses it. ApricotPhase5Times = map[uint32]time.Time{ - constants.MainnetID: time.Date(2021, time.December, 2, 18, 0, 0, 0, time.UTC), - constants.FujiID: time.Date(2021, time.November, 24, 15, 0, 0, 0, time.UTC), + constants.MainnetID: Mainnet.ApricotPhase5Time, + constants.FujiID: Fuji.ApricotPhase5Time, } + // Deprecated: This will be removed once coreth no longer uses it. ApricotPhasePre6Times = map[uint32]time.Time{ - constants.MainnetID: time.Date(2022, time.September, 5, 1, 30, 0, 0, time.UTC), - constants.FujiID: time.Date(2022, time.September, 6, 20, 0, 0, 0, time.UTC), + constants.MainnetID: Mainnet.ApricotPhasePre6Time, + constants.FujiID: Fuji.ApricotPhasePre6Time, } + // Deprecated: This will be removed once coreth no longer uses it. ApricotPhase6Times = map[uint32]time.Time{ - constants.MainnetID: time.Date(2022, time.September, 6, 20, 0, 0, 0, time.UTC), - constants.FujiID: time.Date(2022, time.September, 6, 20, 0, 0, 0, time.UTC), + constants.MainnetID: Mainnet.ApricotPhase6Time, + constants.FujiID: Fuji.ApricotPhase6Time, } + // Deprecated: This will be removed once coreth no longer uses it. ApricotPhasePost6Times = map[uint32]time.Time{ - constants.MainnetID: time.Date(2022, time.September, 7, 3, 0, 0, 0, time.UTC), - constants.FujiID: time.Date(2022, time.September, 7, 6, 0, 0, 0, time.UTC), + constants.MainnetID: Mainnet.ApricotPhasePost6Time, + constants.FujiID: Fuji.ApricotPhasePost6Time, } + // Deprecated: This will be removed once coreth no longer uses it. BanffTimes = map[uint32]time.Time{ - constants.MainnetID: time.Date(2022, time.October, 18, 16, 0, 0, 0, time.UTC), - constants.FujiID: time.Date(2022, time.October, 3, 14, 0, 0, 0, time.UTC), + constants.MainnetID: Mainnet.BanffTime, + constants.FujiID: Fuji.BanffTime, } + // Deprecated: This will be removed once coreth no longer uses it. CortinaTimes = map[uint32]time.Time{ - constants.MainnetID: time.Date(2023, time.April, 25, 15, 0, 0, 0, time.UTC), - constants.FujiID: time.Date(2023, time.April, 6, 15, 0, 0, 0, time.UTC), - } - CortinaXChainStopVertexID = map[uint32]ids.ID{ - // The mainnet stop vertex is well known. It can be verified on any - // fully synced node by looking at the parentID of the genesis block. - // - // Ref: https://subnets.avax.network/x-chain/block/0 - constants.MainnetID: ids.FromStringOrPanic("jrGWDh5Po9FMj54depyunNixpia5PN4aAYxfmNzU8n752Rjga"), - // The fuji stop vertex is well known. It can be verified on any fully - // synced node by looking at the parentID of the genesis block. - // - // Ref: https://subnets-test.avax.network/x-chain/block/0 - constants.FujiID: ids.FromStringOrPanic("2D1cmbiG36BqQMRyHt4kFhWarmatA1ighSpND3FeFgz3vFVtCZ"), + constants.MainnetID: Mainnet.CortinaTime, + constants.FujiID: Fuji.CortinaTime, } + // Deprecated: This will be removed once coreth no longer uses it. DurangoTimes = map[uint32]time.Time{ - constants.MainnetID: time.Date(2024, time.March, 6, 16, 0, 0, 0, time.UTC), - constants.FujiID: time.Date(2024, time.February, 13, 16, 0, 0, 0, time.UTC), + constants.MainnetID: Mainnet.DurangoTime, + constants.FujiID: Fuji.DurangoTime, } + // Deprecated: This will be removed once coreth no longer uses it. EUpgradeTimes = map[uint32]time.Time{ - constants.MainnetID: time.Date(10000, time.December, 1, 0, 0, 0, 0, time.UTC), - constants.FujiID: time.Date(10000, time.December, 1, 0, 0, 0, 0, time.UTC), + constants.MainnetID: Mainnet.EtnaTime, + constants.FujiID: Fuji.EtnaTime, } -) -var ( - Mainnet = Config{ - ApricotPhase1Time: ApricotPhase1Times[constants.MainnetID], - ApricotPhase2Time: ApricotPhase2Times[constants.MainnetID], - ApricotPhase3Time: ApricotPhase3Times[constants.MainnetID], - ApricotPhase4Time: ApricotPhase4Times[constants.MainnetID], - ApricotPhase4MinPChainHeight: ApricotPhase4MinPChainHeight[constants.MainnetID], - ApricotPhase5Time: ApricotPhase5Times[constants.MainnetID], - ApricotPhasePre6Time: ApricotPhasePre6Times[constants.MainnetID], - ApricotPhase6Time: ApricotPhase6Times[constants.MainnetID], - ApricotPhasePost6Time: ApricotPhasePost6Times[constants.MainnetID], - BanffTime: BanffTimes[constants.MainnetID], - CortinaTime: CortinaTimes[constants.MainnetID], - CortinaXChainStopVertexID: CortinaXChainStopVertexID[constants.MainnetID], - DurangoTime: DurangoTimes[constants.MainnetID], - EtnaTime: EUpgradeTimes[constants.MainnetID], - } - Fuji = Config{ - ApricotPhase1Time: ApricotPhase1Times[constants.FujiID], - ApricotPhase2Time: ApricotPhase2Times[constants.FujiID], - ApricotPhase3Time: ApricotPhase3Times[constants.FujiID], - ApricotPhase4Time: ApricotPhase4Times[constants.FujiID], - ApricotPhase4MinPChainHeight: ApricotPhase4MinPChainHeight[constants.FujiID], - ApricotPhase5Time: ApricotPhase5Times[constants.FujiID], - ApricotPhasePre6Time: ApricotPhasePre6Times[constants.FujiID], - ApricotPhase6Time: ApricotPhase6Times[constants.FujiID], - ApricotPhasePost6Time: ApricotPhasePost6Times[constants.FujiID], - BanffTime: BanffTimes[constants.FujiID], - CortinaTime: CortinaTimes[constants.FujiID], - CortinaXChainStopVertexID: CortinaXChainStopVertexID[constants.FujiID], - DurangoTime: DurangoTimes[constants.FujiID], - EtnaTime: EUpgradeTimes[constants.FujiID], - } - Default = Config{ - ApricotPhase1Time: DefaultUpgradeTime, - ApricotPhase2Time: DefaultUpgradeTime, - ApricotPhase3Time: DefaultUpgradeTime, - ApricotPhase4Time: DefaultUpgradeTime, - ApricotPhase4MinPChainHeight: 0, - ApricotPhase5Time: DefaultUpgradeTime, - ApricotPhasePre6Time: DefaultUpgradeTime, - ApricotPhase6Time: DefaultUpgradeTime, - ApricotPhasePost6Time: DefaultUpgradeTime, - BanffTime: DefaultUpgradeTime, - CortinaTime: DefaultUpgradeTime, - CortinaXChainStopVertexID: ids.Empty, - DurangoTime: DefaultUpgradeTime, - EtnaTime: DefaultUpgradeTime, - } + ErrInvalidUpgradeTimes = errors.New("invalid upgrade configuration") ) type Config struct { @@ -162,43 +165,83 @@ type Config struct { EtnaTime time.Time `json:"etnaTime"` } -func (c Config) Validate() error { - if c.ApricotPhase1Time.After(c.ApricotPhase2Time) { - return fmt.Errorf("%w: apricot phase 1 time (%s) is after apricot phase 2 time (%s)", ErrInvalidUpgradeTimes, c.ApricotPhase1Time, c.ApricotPhase2Time) - } - if c.ApricotPhase2Time.After(c.ApricotPhase3Time) { - return fmt.Errorf("%w: apricot phase 2 time (%s) is after apricot phase 3 time (%s)", ErrInvalidUpgradeTimes, c.ApricotPhase2Time, c.ApricotPhase3Time) - } - if c.ApricotPhase3Time.After(c.ApricotPhase4Time) { - return fmt.Errorf("%w: apricot phase 3 time (%s) is after apricot phase 4 time (%s)", ErrInvalidUpgradeTimes, c.ApricotPhase3Time, c.ApricotPhase4Time) - } - if c.ApricotPhase4Time.After(c.ApricotPhase5Time) { - return fmt.Errorf("%w: apricot phase 4 time (%s) is after apricot phase 5 time (%s)", ErrInvalidUpgradeTimes, c.ApricotPhase4Time, c.ApricotPhase5Time) - } - if c.ApricotPhase5Time.After(c.ApricotPhasePre6Time) { - return fmt.Errorf("%w: apricot phase 5 time (%s) is after apricot phase pre-6 time (%s)", ErrInvalidUpgradeTimes, c.ApricotPhase5Time, c.ApricotPhasePre6Time) - } - if c.ApricotPhasePre6Time.After(c.ApricotPhase6Time) { - return fmt.Errorf("%w: apricot phase pre-6 time (%s) is after apricot phase 6 time (%s)", ErrInvalidUpgradeTimes, c.ApricotPhasePre6Time, c.ApricotPhase6Time) - } - if c.ApricotPhase6Time.After(c.ApricotPhasePost6Time) { - return fmt.Errorf("%w: apricot phase 6 time (%s) is after apricot phase post-6 time (%s)", ErrInvalidUpgradeTimes, c.ApricotPhase6Time, c.ApricotPhasePost6Time) - } - if c.ApricotPhasePost6Time.After(c.BanffTime) { - return fmt.Errorf("%w: apricot phase post-6 time (%s) is after banff time (%s)", ErrInvalidUpgradeTimes, c.ApricotPhasePost6Time, c.BanffTime) - } - if c.BanffTime.After(c.CortinaTime) { - return fmt.Errorf("%w: banff time (%s) is after cortina time (%s)", ErrInvalidUpgradeTimes, c.BanffTime, c.CortinaTime) - } - if c.CortinaTime.After(c.DurangoTime) { - return fmt.Errorf("%w: cortina time (%s) is after durango time (%s)", ErrInvalidUpgradeTimes, c.CortinaTime, c.DurangoTime) - } - if c.DurangoTime.After(c.EtnaTime) { - return fmt.Errorf("%w: durango time (%s) is after etna time (%s)", ErrInvalidUpgradeTimes, c.DurangoTime, c.EtnaTime) +func (c *Config) Validate() error { + upgrades := []time.Time{ + c.ApricotPhase1Time, + c.ApricotPhase2Time, + c.ApricotPhase3Time, + c.ApricotPhase4Time, + c.ApricotPhase5Time, + c.ApricotPhasePre6Time, + c.ApricotPhase6Time, + c.ApricotPhasePost6Time, + c.BanffTime, + c.CortinaTime, + c.DurangoTime, + c.EtnaTime, + } + for i := 0; i < len(upgrades)-1; i++ { + if upgrades[i].After(upgrades[i+1]) { + return fmt.Errorf("%w: upgrade %d (%s) is after upgrade %d (%s)", + ErrInvalidUpgradeTimes, + i, + upgrades[i], + i+1, + upgrades[i+1], + ) + } } return nil } +func (c *Config) IsApricotPhase1Activated(t time.Time) bool { + return !t.Before(c.ApricotPhase1Time) +} + +func (c *Config) IsApricotPhase2Activated(t time.Time) bool { + return !t.Before(c.ApricotPhase2Time) +} + +func (c *Config) IsApricotPhase3Activated(t time.Time) bool { + return !t.Before(c.ApricotPhase3Time) +} + +func (c *Config) IsApricotPhase4Activated(t time.Time) bool { + return !t.Before(c.ApricotPhase4Time) +} + +func (c *Config) IsApricotPhase5Activated(t time.Time) bool { + return !t.Before(c.ApricotPhase5Time) +} + +func (c *Config) IsApricotPhasePre6Activated(t time.Time) bool { + return !t.Before(c.ApricotPhasePre6Time) +} + +func (c *Config) IsApricotPhase6Activated(t time.Time) bool { + return !t.Before(c.ApricotPhase6Time) +} + +func (c *Config) IsApricotPhasePost6Activated(t time.Time) bool { + return !t.Before(c.ApricotPhasePost6Time) +} + +func (c *Config) IsBanffActivated(t time.Time) bool { + return !t.Before(c.BanffTime) +} + +func (c *Config) IsCortinaActivated(t time.Time) bool { + return !t.Before(c.CortinaTime) +} + +func (c *Config) IsDurangoActivated(t time.Time) bool { + return !t.Before(c.DurangoTime) +} + +func (c *Config) IsEtnaActivated(t time.Time) bool { + return !t.Before(c.EtnaTime) +} + func GetConfig(networkID uint32) Config { switch networkID { case constants.MainnetID: diff --git a/vms/avm/block/executor/block_test.go b/vms/avm/block/executor/block_test.go index 3f6c0a81b97..c95796da638 100644 --- a/vms/avm/block/executor/block_test.go +++ b/vms/avm/block/executor/block_test.go @@ -15,6 +15,7 @@ import ( "github.com/ava-labs/avalanchego/chains/atomic" "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/snow" + "github.com/ava-labs/avalanchego/upgrade" "github.com/ava-labs/avalanchego/utils" "github.com/ava-labs/avalanchego/utils/logging" "github.com/ava-labs/avalanchego/utils/set" @@ -939,7 +940,9 @@ func defaultTestBackend(bootstrapped bool, sharedMemory atomic.SharedMemory) *ex Log: logging.NoLog{}, }, Config: &config.Config{ - EUpgradeTime: mockable.MaxTime, + Upgrades: upgrade.Config{ + EtnaTime: mockable.MaxTime, + }, TxFee: 0, CreateAssetTxFee: 0, }, diff --git a/vms/avm/config/config.go b/vms/avm/config/config.go index b7fe3cecf14..9fddc7427c6 100644 --- a/vms/avm/config/config.go +++ b/vms/avm/config/config.go @@ -3,23 +3,15 @@ package config -import "time" +import "github.com/ava-labs/avalanchego/upgrade" // Struct collecting all the foundational parameters of the AVM type Config struct { + Upgrades upgrade.Config + // Fee that is burned by every non-asset creating transaction TxFee uint64 // Fee that must be burned by every asset creating transaction CreateAssetTxFee uint64 - - // Time of the Cortina network upgrade - CortinaUpgradeTime time.Time - - // Time of the E network upgrade - EUpgradeTime time.Time -} - -func (c *Config) IsEActivated(timestamp time.Time) bool { - return !timestamp.Before(c.EUpgradeTime) } diff --git a/vms/avm/environment_test.go b/vms/avm/environment_test.go index d4375aa092d..ad4eff1aa1b 100644 --- a/vms/avm/environment_test.go +++ b/vms/avm/environment_test.go @@ -20,6 +20,7 @@ import ( "github.com/ava-labs/avalanchego/snow" "github.com/ava-labs/avalanchego/snow/engine/common" "github.com/ava-labs/avalanchego/snow/snowtest" + "github.com/ava-labs/avalanchego/upgrade" "github.com/ava-labs/avalanchego/utils/constants" "github.com/ava-labs/avalanchego/utils/crypto/secp256k1" "github.com/ava-labs/avalanchego/utils/formatting" @@ -44,7 +45,7 @@ type fork uint8 const ( durango fork = iota - eUpgrade + etna latest = durango @@ -230,14 +231,16 @@ func setup(tb testing.TB, c *envConfig) *environment { func staticConfig(tb testing.TB, f fork) config.Config { c := config.Config{ + Upgrades: upgrade.Config{ + EtnaTime: mockable.MaxTime, + }, TxFee: testTxFee, CreateAssetTxFee: testTxFee, - EUpgradeTime: mockable.MaxTime, } switch f { - case eUpgrade: - c.EUpgradeTime = time.Time{} + case etna: + c.Upgrades.EtnaTime = time.Time{} case durango: default: require.FailNow(tb, "unhandled fork", f) diff --git a/vms/avm/service_test.go b/vms/avm/service_test.go index 4648506b2a5..534424c63b0 100644 --- a/vms/avm/service_test.go +++ b/vms/avm/service_test.go @@ -22,6 +22,7 @@ import ( "github.com/ava-labs/avalanchego/snow" "github.com/ava-labs/avalanchego/snow/choices" "github.com/ava-labs/avalanchego/snow/engine/common" + "github.com/ava-labs/avalanchego/upgrade" "github.com/ava-labs/avalanchego/utils/constants" "github.com/ava-labs/avalanchego/utils/crypto/secp256k1" "github.com/ava-labs/avalanchego/utils/formatting" @@ -2720,7 +2721,9 @@ func TestSendMultiple(t *testing.T) { initialKeys: keys, }}, vmStaticConfig: &config.Config{ - EUpgradeTime: mockable.MaxTime, + Upgrades: upgrade.Config{ + EtnaTime: mockable.MaxTime, + }, }, }) service := &Service{vm: env.vm} diff --git a/vms/avm/state/state_test.go b/vms/avm/state/state_test.go index e1743b03794..b2d8f4f4084 100644 --- a/vms/avm/state/state_test.go +++ b/vms/avm/state/state_test.go @@ -287,7 +287,7 @@ func TestInitializeChainState(t *testing.T) { require.NoError(err) stopVertexID := ids.GenerateTestID() - genesisTimestamp := upgrade.DefaultUpgradeTime + genesisTimestamp := upgrade.InitiallyActiveTime require.NoError(s.InitializeChainState(stopVertexID, genesisTimestamp)) lastAcceptedID := s.GetLastAccepted() diff --git a/vms/avm/txs/executor/syntactic_verifier_test.go b/vms/avm/txs/executor/syntactic_verifier_test.go index c5762a81c74..a5811163bad 100644 --- a/vms/avm/txs/executor/syntactic_verifier_test.go +++ b/vms/avm/txs/executor/syntactic_verifier_test.go @@ -12,6 +12,7 @@ import ( "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/snow/snowtest" + "github.com/ava-labs/avalanchego/upgrade" "github.com/ava-labs/avalanchego/utils/constants" "github.com/ava-labs/avalanchego/utils/crypto/secp256k1" "github.com/ava-labs/avalanchego/utils/timer/mockable" @@ -28,9 +29,11 @@ import ( var ( keys = secp256k1.TestKeys() feeConfig = config.Config{ + Upgrades: upgrade.Config{ + EtnaTime: mockable.MaxTime, + }, TxFee: 2, CreateAssetTxFee: 3, - EUpgradeTime: mockable.MaxTime, } ) diff --git a/vms/avm/vm.go b/vms/avm/vm.go index 49ee0cd09a8..c9170ba882f 100644 --- a/vms/avm/vm.go +++ b/vms/avm/vm.go @@ -395,7 +395,7 @@ func (vm *VM) GetBlockIDAtHeight(_ context.Context, height uint64) (ids.ID, erro */ func (vm *VM) Linearize(ctx context.Context, stopVertexID ids.ID, toEngine chan<- common.Message) error { - time := vm.Config.CortinaUpgradeTime + time := vm.Config.Upgrades.CortinaTime err := vm.state.InitializeChainState(stopVertexID, time) if err != nil { return err diff --git a/vms/platformvm/block/builder/helpers_test.go b/vms/platformvm/block/builder/helpers_test.go index d197cf9a183..0c9ff263753 100644 --- a/vms/platformvm/block/builder/helpers_test.go +++ b/vms/platformvm/block/builder/helpers_test.go @@ -25,6 +25,7 @@ import ( "github.com/ava-labs/avalanchego/snow/snowtest" "github.com/ava-labs/avalanchego/snow/uptime" "github.com/ava-labs/avalanchego/snow/validators" + "github.com/ava-labs/avalanchego/upgrade" "github.com/ava-labs/avalanchego/utils" "github.com/ava-labs/avalanchego/utils/constants" "github.com/ava-labs/avalanchego/utils/crypto/secp256k1" @@ -46,7 +47,6 @@ import ( "github.com/ava-labs/avalanchego/vms/platformvm/txs/fee" "github.com/ava-labs/avalanchego/vms/platformvm/txs/mempool" "github.com/ava-labs/avalanchego/vms/platformvm/txs/txstest" - "github.com/ava-labs/avalanchego/vms/platformvm/upgrade" "github.com/ava-labs/avalanchego/vms/platformvm/utxo" "github.com/ava-labs/avalanchego/vms/secp256k1fx" @@ -329,13 +329,13 @@ func defaultConfig(t *testing.T, f fork) *config.Config { BanffTime: mockable.MaxTime, CortinaTime: mockable.MaxTime, DurangoTime: mockable.MaxTime, - EUpgradeTime: mockable.MaxTime, + EtnaTime: mockable.MaxTime, }, } switch f { case eUpgrade: - c.UpgradeConfig.EUpgradeTime = time.Time{} // neglecting fork ordering this for package tests + c.UpgradeConfig.EtnaTime = time.Time{} // neglecting fork ordering this for package tests fallthrough case durango: c.UpgradeConfig.DurangoTime = time.Time{} // neglecting fork ordering for this package's tests diff --git a/vms/platformvm/block/executor/helpers_test.go b/vms/platformvm/block/executor/helpers_test.go index e06031eb2bc..9bd02b8dce5 100644 --- a/vms/platformvm/block/executor/helpers_test.go +++ b/vms/platformvm/block/executor/helpers_test.go @@ -27,6 +27,7 @@ import ( "github.com/ava-labs/avalanchego/snow/snowtest" "github.com/ava-labs/avalanchego/snow/uptime" "github.com/ava-labs/avalanchego/snow/validators" + "github.com/ava-labs/avalanchego/upgrade" "github.com/ava-labs/avalanchego/utils" "github.com/ava-labs/avalanchego/utils/constants" "github.com/ava-labs/avalanchego/utils/crypto/secp256k1" @@ -48,7 +49,6 @@ import ( "github.com/ava-labs/avalanchego/vms/platformvm/txs/fee" "github.com/ava-labs/avalanchego/vms/platformvm/txs/mempool" "github.com/ava-labs/avalanchego/vms/platformvm/txs/txstest" - "github.com/ava-labs/avalanchego/vms/platformvm/upgrade" "github.com/ava-labs/avalanchego/vms/platformvm/utxo" "github.com/ava-labs/avalanchego/vms/secp256k1fx" @@ -359,13 +359,13 @@ func defaultConfig(t *testing.T, f fork) *config.Config { BanffTime: mockable.MaxTime, CortinaTime: mockable.MaxTime, DurangoTime: mockable.MaxTime, - EUpgradeTime: mockable.MaxTime, + EtnaTime: mockable.MaxTime, }, } switch f { case eUpgrade: - c.UpgradeConfig.EUpgradeTime = time.Time{} // neglecting fork ordering this for package tests + c.UpgradeConfig.EtnaTime = time.Time{} // neglecting fork ordering this for package tests fallthrough case durango: c.UpgradeConfig.DurangoTime = time.Time{} // neglecting fork ordering for this package's tests diff --git a/vms/platformvm/block/executor/verifier_test.go b/vms/platformvm/block/executor/verifier_test.go index bbb6dd36e33..5c058e7c69e 100644 --- a/vms/platformvm/block/executor/verifier_test.go +++ b/vms/platformvm/block/executor/verifier_test.go @@ -15,6 +15,7 @@ import ( "github.com/ava-labs/avalanchego/database" "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/snow" + "github.com/ava-labs/avalanchego/upgrade" "github.com/ava-labs/avalanchego/utils/logging" "github.com/ava-labs/avalanchego/utils/set" "github.com/ava-labs/avalanchego/utils/timer/mockable" @@ -27,7 +28,6 @@ import ( "github.com/ava-labs/avalanchego/vms/platformvm/txs" "github.com/ava-labs/avalanchego/vms/platformvm/txs/executor" "github.com/ava-labs/avalanchego/vms/platformvm/txs/mempool" - "github.com/ava-labs/avalanchego/vms/platformvm/upgrade" ) func TestVerifierVisitProposalBlock(t *testing.T) { diff --git a/vms/platformvm/config/config.go b/vms/platformvm/config/config.go index 61dedea3ff2..4cb6c981fea 100644 --- a/vms/platformvm/config/config.go +++ b/vms/platformvm/config/config.go @@ -10,11 +10,11 @@ import ( "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/snow/uptime" "github.com/ava-labs/avalanchego/snow/validators" + "github.com/ava-labs/avalanchego/upgrade" "github.com/ava-labs/avalanchego/utils/constants" "github.com/ava-labs/avalanchego/utils/set" "github.com/ava-labs/avalanchego/vms/platformvm/reward" "github.com/ava-labs/avalanchego/vms/platformvm/txs" - "github.com/ava-labs/avalanchego/vms/platformvm/upgrade" feecomponent "github.com/ava-labs/avalanchego/vms/components/fee" txfee "github.com/ava-labs/avalanchego/vms/platformvm/txs/fee" diff --git a/vms/platformvm/txs/executor/helpers_test.go b/vms/platformvm/txs/executor/helpers_test.go index 1485f180255..5e4584f2b12 100644 --- a/vms/platformvm/txs/executor/helpers_test.go +++ b/vms/platformvm/txs/executor/helpers_test.go @@ -25,6 +25,7 @@ import ( "github.com/ava-labs/avalanchego/snow/snowtest" "github.com/ava-labs/avalanchego/snow/uptime" "github.com/ava-labs/avalanchego/snow/validators" + "github.com/ava-labs/avalanchego/upgrade" "github.com/ava-labs/avalanchego/utils" "github.com/ava-labs/avalanchego/utils/constants" "github.com/ava-labs/avalanchego/utils/crypto/secp256k1" @@ -44,7 +45,6 @@ import ( "github.com/ava-labs/avalanchego/vms/platformvm/txs" "github.com/ava-labs/avalanchego/vms/platformvm/txs/fee" "github.com/ava-labs/avalanchego/vms/platformvm/txs/txstest" - "github.com/ava-labs/avalanchego/vms/platformvm/upgrade" "github.com/ava-labs/avalanchego/vms/platformvm/utxo" "github.com/ava-labs/avalanchego/vms/secp256k1fx" "github.com/ava-labs/avalanchego/wallet/subnet/primary/common" @@ -302,13 +302,13 @@ func defaultConfig(t *testing.T, f fork) *config.Config { BanffTime: mockable.MaxTime, CortinaTime: mockable.MaxTime, DurangoTime: mockable.MaxTime, - EUpgradeTime: mockable.MaxTime, + EtnaTime: mockable.MaxTime, }, } switch f { case eUpgrade: - c.UpgradeConfig.EUpgradeTime = defaultValidateStartTime.Add(-2 * time.Second) + c.UpgradeConfig.EtnaTime = defaultValidateStartTime.Add(-2 * time.Second) fallthrough case durango: c.UpgradeConfig.DurangoTime = defaultValidateStartTime.Add(-2 * time.Second) diff --git a/vms/platformvm/txs/executor/standard_tx_executor_test.go b/vms/platformvm/txs/executor/standard_tx_executor_test.go index 9e610bb71dc..3a0333aa250 100644 --- a/vms/platformvm/txs/executor/standard_tx_executor_test.go +++ b/vms/platformvm/txs/executor/standard_tx_executor_test.go @@ -17,6 +17,7 @@ import ( "github.com/ava-labs/avalanchego/database" "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/snow" + "github.com/ava-labs/avalanchego/upgrade" "github.com/ava-labs/avalanchego/utils" "github.com/ava-labs/avalanchego/utils/constants" "github.com/ava-labs/avalanchego/utils/crypto/bls" @@ -33,7 +34,6 @@ import ( "github.com/ava-labs/avalanchego/vms/platformvm/state" "github.com/ava-labs/avalanchego/vms/platformvm/status" "github.com/ava-labs/avalanchego/vms/platformvm/txs" - "github.com/ava-labs/avalanchego/vms/platformvm/upgrade" "github.com/ava-labs/avalanchego/vms/platformvm/utxo" "github.com/ava-labs/avalanchego/vms/secp256k1fx" "github.com/ava-labs/avalanchego/wallet/subnet/primary/common" @@ -2257,13 +2257,13 @@ func defaultTestConfig(t *testing.T, f fork, tm time.Time) *config.Config { BanffTime: mockable.MaxTime, CortinaTime: mockable.MaxTime, DurangoTime: mockable.MaxTime, - EUpgradeTime: mockable.MaxTime, + EtnaTime: mockable.MaxTime, }, } switch f { case eUpgrade: - c.UpgradeConfig.EUpgradeTime = tm + c.UpgradeConfig.EtnaTime = tm fallthrough case durango: c.UpgradeConfig.DurangoTime = tm diff --git a/vms/platformvm/upgrade/config.go b/vms/platformvm/upgrade/config.go deleted file mode 100644 index 1d92736a2ee..00000000000 --- a/vms/platformvm/upgrade/config.go +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. -// See the file LICENSE for licensing terms. - -package upgrade - -import "time" - -type Config struct { - // Time of the AP3 network upgrade - ApricotPhase3Time time.Time - - // Time of the AP5 network upgrade - ApricotPhase5Time time.Time - - // Time of the Banff network upgrade - BanffTime time.Time - - // Time of the Cortina network upgrade - CortinaTime time.Time - - // Time of the Durango network upgrade - DurangoTime time.Time - - // Time of the E network upgrade - EUpgradeTime time.Time -} - -func (c *Config) IsApricotPhase3Activated(timestamp time.Time) bool { - return !timestamp.Before(c.ApricotPhase3Time) -} - -func (c *Config) IsApricotPhase5Activated(timestamp time.Time) bool { - return !timestamp.Before(c.ApricotPhase5Time) -} - -func (c *Config) IsBanffActivated(timestamp time.Time) bool { - return !timestamp.Before(c.BanffTime) -} - -func (c *Config) IsCortinaActivated(timestamp time.Time) bool { - return !timestamp.Before(c.CortinaTime) -} - -func (c *Config) IsDurangoActivated(timestamp time.Time) bool { - return !timestamp.Before(c.DurangoTime) -} - -func (c *Config) IsEActivated(timestamp time.Time) bool { - return !timestamp.Before(c.EUpgradeTime) -} diff --git a/vms/platformvm/validator_set_property_test.go b/vms/platformvm/validator_set_property_test.go index 9ed3dc7cbd4..e55bca43418 100644 --- a/vms/platformvm/validator_set_property_test.go +++ b/vms/platformvm/validator_set_property_test.go @@ -28,6 +28,7 @@ import ( "github.com/ava-labs/avalanchego/snow/snowtest" "github.com/ava-labs/avalanchego/snow/uptime" "github.com/ava-labs/avalanchego/snow/validators" + "github.com/ava-labs/avalanchego/upgrade" "github.com/ava-labs/avalanchego/utils/constants" "github.com/ava-labs/avalanchego/utils/crypto/bls" "github.com/ava-labs/avalanchego/utils/formatting" @@ -44,7 +45,6 @@ import ( "github.com/ava-labs/avalanchego/vms/platformvm/txs" "github.com/ava-labs/avalanchego/vms/platformvm/txs/fee" "github.com/ava-labs/avalanchego/vms/platformvm/txs/txstest" - "github.com/ava-labs/avalanchego/vms/platformvm/upgrade" "github.com/ava-labs/avalanchego/vms/secp256k1fx" blockexecutor "github.com/ava-labs/avalanchego/vms/platformvm/block/executor" @@ -667,7 +667,7 @@ func buildVM(t *testing.T) (*VM, ids.ID, error) { ApricotPhase5Time: forkTime, BanffTime: forkTime, CortinaTime: forkTime, - EUpgradeTime: mockable.MaxTime, + EtnaTime: mockable.MaxTime, }, }} vm.clock.Set(forkTime.Add(time.Second)) diff --git a/vms/platformvm/vm_regression_test.go b/vms/platformvm/vm_regression_test.go index 035573fd8ae..b967dfd6632 100644 --- a/vms/platformvm/vm_regression_test.go +++ b/vms/platformvm/vm_regression_test.go @@ -27,6 +27,7 @@ import ( "github.com/ava-labs/avalanchego/snow/snowtest" "github.com/ava-labs/avalanchego/snow/uptime" "github.com/ava-labs/avalanchego/snow/validators" + "github.com/ava-labs/avalanchego/upgrade" "github.com/ava-labs/avalanchego/utils/bloom" "github.com/ava-labs/avalanchego/utils/constants" "github.com/ava-labs/avalanchego/utils/crypto/bls" @@ -43,7 +44,6 @@ import ( "github.com/ava-labs/avalanchego/vms/platformvm/txs" "github.com/ava-labs/avalanchego/vms/platformvm/txs/executor" "github.com/ava-labs/avalanchego/vms/platformvm/txs/txstest" - "github.com/ava-labs/avalanchego/vms/platformvm/upgrade" "github.com/ava-labs/avalanchego/vms/secp256k1fx" blockexecutor "github.com/ava-labs/avalanchego/vms/platformvm/block/executor" @@ -457,10 +457,10 @@ func TestUnverifiedParentPanicRegression(t *testing.T) { MaxStakeDuration: defaultMaxStakingDuration, RewardConfig: defaultRewardConfig, UpgradeConfig: upgrade.Config{ - BanffTime: latestForkTime, - CortinaTime: mockable.MaxTime, - DurangoTime: mockable.MaxTime, - EUpgradeTime: mockable.MaxTime, + BanffTime: latestForkTime, + CortinaTime: mockable.MaxTime, + DurangoTime: mockable.MaxTime, + EtnaTime: mockable.MaxTime, }, }} diff --git a/vms/platformvm/vm_test.go b/vms/platformvm/vm_test.go index 277eed26801..de4f14112f5 100644 --- a/vms/platformvm/vm_test.go +++ b/vms/platformvm/vm_test.go @@ -34,6 +34,7 @@ import ( "github.com/ava-labs/avalanchego/snow/uptime" "github.com/ava-labs/avalanchego/snow/validators" "github.com/ava-labs/avalanchego/subnets" + "github.com/ava-labs/avalanchego/upgrade" "github.com/ava-labs/avalanchego/utils/constants" "github.com/ava-labs/avalanchego/utils/crypto/bls" "github.com/ava-labs/avalanchego/utils/crypto/secp256k1" @@ -58,7 +59,6 @@ import ( "github.com/ava-labs/avalanchego/vms/platformvm/txs" "github.com/ava-labs/avalanchego/vms/platformvm/txs/fee" "github.com/ava-labs/avalanchego/vms/platformvm/txs/txstest" - "github.com/ava-labs/avalanchego/vms/platformvm/upgrade" "github.com/ava-labs/avalanchego/vms/secp256k1fx" p2ppb "github.com/ava-labs/avalanchego/proto/pb/p2p" @@ -213,7 +213,7 @@ func defaultVM(t *testing.T, f fork) (*VM, *txstest.WalletFactory, database.Data banffTime = mockable.MaxTime cortinaTime = mockable.MaxTime durangoTime = mockable.MaxTime - eUpgradeTime = mockable.MaxTime + etnaTime = mockable.MaxTime ) // always reset latestForkTime (a package level variable) @@ -221,7 +221,7 @@ func defaultVM(t *testing.T, f fork) (*VM, *txstest.WalletFactory, database.Data latestForkTime = defaultGenesisTime.Add(time.Second) switch f { case eUpgrade: - eUpgradeTime = latestForkTime + etnaTime = latestForkTime fallthrough case durango: durangoTime = latestForkTime @@ -264,7 +264,7 @@ func defaultVM(t *testing.T, f fork) (*VM, *txstest.WalletFactory, database.Data BanffTime: banffTime, CortinaTime: cortinaTime, DurangoTime: durangoTime, - EUpgradeTime: eUpgradeTime, + EtnaTime: etnaTime, }, }} @@ -1203,10 +1203,10 @@ func TestRestartFullyAccepted(t *testing.T) { MaxStakeDuration: defaultMaxStakingDuration, RewardConfig: defaultRewardConfig, UpgradeConfig: upgrade.Config{ - BanffTime: latestForkTime, - CortinaTime: latestForkTime, - DurangoTime: latestForkTime, - EUpgradeTime: mockable.MaxTime, + BanffTime: latestForkTime, + CortinaTime: latestForkTime, + DurangoTime: latestForkTime, + EtnaTime: mockable.MaxTime, }, }} @@ -1293,10 +1293,10 @@ func TestRestartFullyAccepted(t *testing.T) { MaxStakeDuration: defaultMaxStakingDuration, RewardConfig: defaultRewardConfig, UpgradeConfig: upgrade.Config{ - BanffTime: latestForkTime, - CortinaTime: latestForkTime, - DurangoTime: latestForkTime, - EUpgradeTime: mockable.MaxTime, + BanffTime: latestForkTime, + CortinaTime: latestForkTime, + DurangoTime: latestForkTime, + EtnaTime: mockable.MaxTime, }, }} @@ -1344,10 +1344,10 @@ func TestBootstrapPartiallyAccepted(t *testing.T) { MaxStakeDuration: defaultMaxStakingDuration, RewardConfig: defaultRewardConfig, UpgradeConfig: upgrade.Config{ - BanffTime: latestForkTime, - CortinaTime: latestForkTime, - DurangoTime: latestForkTime, - EUpgradeTime: mockable.MaxTime, + BanffTime: latestForkTime, + CortinaTime: latestForkTime, + DurangoTime: latestForkTime, + EtnaTime: mockable.MaxTime, }, }} @@ -1694,10 +1694,10 @@ func TestUnverifiedParent(t *testing.T) { MaxStakeDuration: defaultMaxStakingDuration, RewardConfig: defaultRewardConfig, UpgradeConfig: upgrade.Config{ - BanffTime: latestForkTime, - CortinaTime: latestForkTime, - DurangoTime: latestForkTime, - EUpgradeTime: mockable.MaxTime, + BanffTime: latestForkTime, + CortinaTime: latestForkTime, + DurangoTime: latestForkTime, + EtnaTime: mockable.MaxTime, }, }} @@ -1857,10 +1857,10 @@ func TestUptimeDisallowedWithRestart(t *testing.T) { Validators: validators.NewManager(), UptimeLockedCalculator: uptime.NewLockedCalculator(), UpgradeConfig: upgrade.Config{ - BanffTime: latestForkTime, - CortinaTime: latestForkTime, - DurangoTime: latestForkTime, - EUpgradeTime: mockable.MaxTime, + BanffTime: latestForkTime, + CortinaTime: latestForkTime, + DurangoTime: latestForkTime, + EtnaTime: mockable.MaxTime, }, }} @@ -1908,10 +1908,10 @@ func TestUptimeDisallowedWithRestart(t *testing.T) { Validators: validators.NewManager(), UptimeLockedCalculator: uptime.NewLockedCalculator(), UpgradeConfig: upgrade.Config{ - BanffTime: latestForkTime, - CortinaTime: latestForkTime, - DurangoTime: latestForkTime, - EUpgradeTime: mockable.MaxTime, + BanffTime: latestForkTime, + CortinaTime: latestForkTime, + DurangoTime: latestForkTime, + EtnaTime: mockable.MaxTime, }, }} @@ -2010,10 +2010,10 @@ func TestUptimeDisallowedAfterNeverConnecting(t *testing.T) { Validators: validators.NewManager(), UptimeLockedCalculator: uptime.NewLockedCalculator(), UpgradeConfig: upgrade.Config{ - BanffTime: latestForkTime, - CortinaTime: latestForkTime, - DurangoTime: latestForkTime, - EUpgradeTime: mockable.MaxTime, + BanffTime: latestForkTime, + CortinaTime: latestForkTime, + DurangoTime: latestForkTime, + EtnaTime: mockable.MaxTime, }, }} diff --git a/vms/proposervm/batched_vm_test.go b/vms/proposervm/batched_vm_test.go index d3588cb7334..dc4d8d3ac61 100644 --- a/vms/proposervm/batched_vm_test.go +++ b/vms/proposervm/batched_vm_test.go @@ -26,6 +26,7 @@ import ( "github.com/ava-labs/avalanchego/snow/snowtest" "github.com/ava-labs/avalanchego/snow/validators" "github.com/ava-labs/avalanchego/staking" + "github.com/ava-labs/avalanchego/upgrade" "github.com/ava-labs/avalanchego/utils/timer/mockable" blockbuilder "github.com/ava-labs/avalanchego/vms/proposervm/block" @@ -964,9 +965,11 @@ func initTestRemoteProposerVM( proVM := New( coreVM, Config{ - ActivationTime: activationTime, - DurangoTime: durangoTime, - MinimumPChainHeight: 0, + Upgrades: upgrade.Config{ + ApricotPhase4Time: activationTime, + ApricotPhase4MinPChainHeight: 0, + DurangoTime: durangoTime, + }, MinBlkDelay: DefaultMinBlockDelay, NumHistoricalBlocks: DefaultNumHistoricalBlocks, StakingLeafSigner: pTestSigner, diff --git a/vms/proposervm/block.go b/vms/proposervm/block.go index 6c0c2c7e14e..8136e428e11 100644 --- a/vms/proposervm/block.go +++ b/vms/proposervm/block.go @@ -141,7 +141,7 @@ func (p *postForkCommonComponents) Verify( } var shouldHaveProposer bool - if p.vm.IsDurangoActivated(parentTimestamp) { + if p.vm.Upgrades.IsDurangoActivated(parentTimestamp) { shouldHaveProposer, err = p.verifyPostDurangoBlockDelay(ctx, parentTimestamp, parentPChainHeight, child) } else { shouldHaveProposer, err = p.verifyPreDurangoBlockDelay(ctx, parentTimestamp, parentPChainHeight, child) @@ -197,7 +197,7 @@ func (p *postForkCommonComponents) buildChild( } var shouldBuildSignedBlock bool - if p.vm.IsDurangoActivated(parentTimestamp) { + if p.vm.Upgrades.IsDurangoActivated(parentTimestamp) { shouldBuildSignedBlock, err = p.shouldBuildSignedBlockPostDurango( ctx, parentID, diff --git a/vms/proposervm/block_test.go b/vms/proposervm/block_test.go index d55a615537d..6c04c5d1394 100644 --- a/vms/proposervm/block_test.go +++ b/vms/proposervm/block_test.go @@ -23,6 +23,7 @@ import ( "github.com/ava-labs/avalanchego/snow/engine/snowman/block" "github.com/ava-labs/avalanchego/snow/validators" "github.com/ava-labs/avalanchego/staking" + "github.com/ava-labs/avalanchego/upgrade" "github.com/ava-labs/avalanchego/utils/logging" "github.com/ava-labs/avalanchego/utils/timer/mockable" "github.com/ava-labs/avalanchego/vms/proposervm/proposer" @@ -71,8 +72,11 @@ func TestPostForkCommonComponents_buildChild(t *testing.T) { require.NoError(err) vm := &VM{ Config: Config{ - ActivationTime: time.Unix(0, 0), - DurangoTime: time.Unix(0, 0), + Upgrades: upgrade.Config{ + ApricotPhase4Time: time.Unix(0, 0), + ApricotPhase4MinPChainHeight: 0, + DurangoTime: time.Unix(0, 0), + }, StakingCertLeaf: &staking.Certificate{}, StakingLeafSigner: pk, Registerer: prometheus.NewRegistry(), @@ -384,8 +388,11 @@ func TestPostDurangoBuildChildResetScheduler(t *testing.T) { require.NoError(err) vm := &VM{ Config: Config{ - ActivationTime: time.Unix(0, 0), - DurangoTime: time.Unix(0, 0), + Upgrades: upgrade.Config{ + ApricotPhase4Time: time.Unix(0, 0), + ApricotPhase4MinPChainHeight: 0, + DurangoTime: time.Unix(0, 0), + }, StakingCertLeaf: &staking.Certificate{}, StakingLeafSigner: pk, Registerer: prometheus.NewRegistry(), diff --git a/vms/proposervm/config.go b/vms/proposervm/config.go index 296f6a60520..ac357d56823 100644 --- a/vms/proposervm/config.go +++ b/vms/proposervm/config.go @@ -10,17 +10,11 @@ import ( "github.com/prometheus/client_golang/prometheus" "github.com/ava-labs/avalanchego/staking" + "github.com/ava-labs/avalanchego/upgrade" ) type Config struct { - // Time at which proposerVM activates its congestion control mechanism - ActivationTime time.Time - - // Durango fork activation time - DurangoTime time.Time - - // Minimal P-chain height referenced upon block building - MinimumPChainHeight uint64 + Upgrades upgrade.Config // Configurable minimal delay among blocks issued consecutively MinBlkDelay time.Duration @@ -38,7 +32,3 @@ type Config struct { // Registerer for prometheus metrics Registerer prometheus.Registerer } - -func (c *Config) IsDurangoActivated(timestamp time.Time) bool { - return !timestamp.Before(c.DurangoTime) -} diff --git a/vms/proposervm/post_fork_option_test.go b/vms/proposervm/post_fork_option_test.go index 0055fa3f50e..3a76bc9faa0 100644 --- a/vms/proposervm/post_fork_option_test.go +++ b/vms/proposervm/post_fork_option_test.go @@ -19,6 +19,7 @@ import ( "github.com/ava-labs/avalanchego/snow/consensus/snowman/snowmantest" "github.com/ava-labs/avalanchego/snow/engine/common" "github.com/ava-labs/avalanchego/snow/snowtest" + "github.com/ava-labs/avalanchego/upgrade" "github.com/ava-labs/avalanchego/vms/proposervm/block" ) @@ -527,9 +528,11 @@ func TestOptionTimestampValidity(t *testing.T) { proVM = New( coreVM, Config{ - ActivationTime: time.Unix(0, 0), - DurangoTime: time.Unix(0, 0), - MinimumPChainHeight: 0, + Upgrades: upgrade.Config{ + ApricotPhase4Time: time.Unix(0, 0), + ApricotPhase4MinPChainHeight: 0, + DurangoTime: time.Unix(0, 0), + }, MinBlkDelay: DefaultMinBlockDelay, NumHistoricalBlocks: DefaultNumHistoricalBlocks, StakingLeafSigner: pTestSigner, diff --git a/vms/proposervm/pre_fork_block.go b/vms/proposervm/pre_fork_block.go index 6610a9f4d82..72f2a5a46a2 100644 --- a/vms/proposervm/pre_fork_block.go +++ b/vms/proposervm/pre_fork_block.go @@ -79,7 +79,7 @@ func (b *preForkBlock) getInnerBlk() snowman.Block { func (b *preForkBlock) verifyPreForkChild(ctx context.Context, child *preForkBlock) error { parentTimestamp := b.Timestamp() - if !parentTimestamp.Before(b.vm.ActivationTime) { + if b.vm.Upgrades.IsApricotPhase4Activated(parentTimestamp) { if err := verifyIsOracleBlock(ctx, b.Block); err != nil { return err } @@ -117,7 +117,7 @@ func (b *preForkBlock) verifyPostForkChild(ctx context.Context, child *postForkB currentPChainHeight, ) } - if childPChainHeight < b.vm.MinimumPChainHeight { + if childPChainHeight < b.vm.Upgrades.ApricotPhase4MinPChainHeight { return errPChainHeightTooLow } @@ -132,7 +132,7 @@ func (b *preForkBlock) verifyPostForkChild(ctx context.Context, child *postForkB // if the *preForkBlock is the last *preForkBlock before activation takes effect // (its timestamp is at or after the activation time) parentTimestamp := b.Timestamp() - if parentTimestamp.Before(b.vm.ActivationTime) { + if !b.vm.Upgrades.IsApricotPhase4Activated(parentTimestamp) { return errProposersNotActivated } @@ -163,7 +163,7 @@ func (*preForkBlock) verifyPostForkOption(context.Context, *postForkOption) erro func (b *preForkBlock) buildChild(ctx context.Context) (Block, error) { parentTimestamp := b.Timestamp() - if parentTimestamp.Before(b.vm.ActivationTime) { + if !b.vm.Upgrades.IsApricotPhase4Activated(parentTimestamp) { // The chain hasn't forked yet innerBlock, err := b.vm.ChainVM.BuildBlock(ctx) if err != nil { @@ -192,7 +192,7 @@ func (b *preForkBlock) buildChild(ctx context.Context) (Block, error) { // The child's P-Chain height is proposed as the optimal P-Chain height that // is at least the minimum height - pChainHeight, err := b.vm.optimalPChainHeight(ctx, b.vm.MinimumPChainHeight) + pChainHeight, err := b.vm.optimalPChainHeight(ctx, b.vm.Upgrades.ApricotPhase4MinPChainHeight) if err != nil { b.vm.ctx.Log.Error("unexpected build block failure", zap.String("reason", "failed to calculate optimal P-chain height"), diff --git a/vms/proposervm/pre_fork_block_test.go b/vms/proposervm/pre_fork_block_test.go index 2153a62f9e3..b69ddd5a0d3 100644 --- a/vms/proposervm/pre_fork_block_test.go +++ b/vms/proposervm/pre_fork_block_test.go @@ -667,7 +667,7 @@ func TestPreForkBlock_BuildBlockWithContext(t *testing.T) { // Should call BuildBlock since proposervm is not activated innerBlk.EXPECT().Timestamp().Return(time.Time{}) - vm.ActivationTime = mockable.MaxTime + vm.Upgrades.ApricotPhase4Time = mockable.MaxTime gotChild, err = blk.buildChild(context.Background()) require.NoError(err) diff --git a/vms/proposervm/state_syncable_vm_test.go b/vms/proposervm/state_syncable_vm_test.go index 2327384fc04..5c4810f9d14 100644 --- a/vms/proposervm/state_syncable_vm_test.go +++ b/vms/proposervm/state_syncable_vm_test.go @@ -21,6 +21,7 @@ import ( "github.com/ava-labs/avalanchego/snow/engine/common" "github.com/ava-labs/avalanchego/snow/engine/snowman/block" "github.com/ava-labs/avalanchego/snow/snowtest" + "github.com/ava-labs/avalanchego/upgrade" "github.com/ava-labs/avalanchego/vms/proposervm/summary" statelessblock "github.com/ava-labs/avalanchego/vms/proposervm/block" @@ -58,9 +59,11 @@ func helperBuildStateSyncTestObjects(t *testing.T) (*fullVM, *VM) { vm := New( innerVM, Config{ - ActivationTime: time.Unix(0, 0), - DurangoTime: time.Unix(0, 0), - MinimumPChainHeight: 0, + Upgrades: upgrade.Config{ + ApricotPhase4Time: time.Unix(0, 0), + ApricotPhase4MinPChainHeight: 0, + DurangoTime: time.Unix(0, 0), + }, MinBlkDelay: DefaultMinBlockDelay, NumHistoricalBlocks: DefaultNumHistoricalBlocks, StakingLeafSigner: pTestSigner, diff --git a/vms/proposervm/vm.go b/vms/proposervm/vm.go index 6622e37e024..6853507b1a9 100644 --- a/vms/proposervm/vm.go +++ b/vms/proposervm/vm.go @@ -321,7 +321,7 @@ func (vm *VM) SetPreference(ctx context.Context, preferred ids.ID) error { parentTimestamp = blk.Timestamp() nextStartTime time.Time ) - if vm.IsDurangoActivated(parentTimestamp) { + if vm.Upgrades.IsDurangoActivated(parentTimestamp) { currentTime := vm.Clock.Time().Truncate(time.Second) if nextStartTime, err = vm.getPostDurangoSlotTime( ctx, diff --git a/vms/proposervm/vm_test.go b/vms/proposervm/vm_test.go index f92d5973157..98375932891 100644 --- a/vms/proposervm/vm_test.go +++ b/vms/proposervm/vm_test.go @@ -28,6 +28,7 @@ import ( "github.com/ava-labs/avalanchego/snow/snowtest" "github.com/ava-labs/avalanchego/snow/validators" "github.com/ava-labs/avalanchego/staking" + "github.com/ava-labs/avalanchego/upgrade" "github.com/ava-labs/avalanchego/utils" "github.com/ava-labs/avalanchego/utils/timer/mockable" "github.com/ava-labs/avalanchego/vms/proposervm/proposer" @@ -124,9 +125,11 @@ func initTestProposerVM( proVM := New( coreVM, Config{ - ActivationTime: proBlkStartTime, - DurangoTime: durangoTime, - MinimumPChainHeight: minPChainHeight, + Upgrades: upgrade.Config{ + ApricotPhase4Time: proBlkStartTime, + ApricotPhase4MinPChainHeight: minPChainHeight, + DurangoTime: durangoTime, + }, MinBlkDelay: DefaultMinBlockDelay, NumHistoricalBlocks: DefaultNumHistoricalBlocks, StakingLeafSigner: pTestSigner, @@ -801,9 +804,11 @@ func TestExpiredBuildBlock(t *testing.T) { proVM := New( coreVM, Config{ - ActivationTime: time.Time{}, - DurangoTime: mockable.MaxTime, - MinimumPChainHeight: 0, + Upgrades: upgrade.Config{ + ApricotPhase4Time: time.Time{}, + ApricotPhase4MinPChainHeight: 0, + DurangoTime: mockable.MaxTime, + }, MinBlkDelay: DefaultMinBlockDelay, NumHistoricalBlocks: DefaultNumHistoricalBlocks, StakingLeafSigner: pTestSigner, @@ -1119,9 +1124,11 @@ func TestInnerVMRollback(t *testing.T) { proVM := New( coreVM, Config{ - ActivationTime: time.Time{}, - DurangoTime: mockable.MaxTime, - MinimumPChainHeight: 0, + Upgrades: upgrade.Config{ + ApricotPhase4Time: time.Time{}, + ApricotPhase4MinPChainHeight: 0, + DurangoTime: mockable.MaxTime, + }, MinBlkDelay: DefaultMinBlockDelay, NumHistoricalBlocks: DefaultNumHistoricalBlocks, StakingLeafSigner: pTestSigner, @@ -1199,9 +1206,11 @@ func TestInnerVMRollback(t *testing.T) { proVM = New( coreVM, Config{ - ActivationTime: time.Time{}, - DurangoTime: mockable.MaxTime, - MinimumPChainHeight: 0, + Upgrades: upgrade.Config{ + ApricotPhase4Time: time.Time{}, + ApricotPhase4MinPChainHeight: 0, + DurangoTime: mockable.MaxTime, + }, MinBlkDelay: DefaultMinBlockDelay, NumHistoricalBlocks: DefaultNumHistoricalBlocks, StakingLeafSigner: pTestSigner, @@ -1587,9 +1596,11 @@ func TestRejectedHeightNotIndexed(t *testing.T) { proVM := New( coreVM, Config{ - ActivationTime: time.Unix(0, 0), - DurangoTime: time.Unix(0, 0), - MinimumPChainHeight: 0, + Upgrades: upgrade.Config{ + ApricotPhase4Time: time.Unix(0, 0), + ApricotPhase4MinPChainHeight: 0, + DurangoTime: time.Unix(0, 0), + }, MinBlkDelay: DefaultMinBlockDelay, NumHistoricalBlocks: DefaultNumHistoricalBlocks, StakingLeafSigner: pTestSigner, @@ -1758,9 +1769,11 @@ func TestRejectedOptionHeightNotIndexed(t *testing.T) { proVM := New( coreVM, Config{ - ActivationTime: time.Unix(0, 0), - DurangoTime: time.Unix(0, 0), - MinimumPChainHeight: 0, + Upgrades: upgrade.Config{ + ApricotPhase4Time: time.Unix(0, 0), + ApricotPhase4MinPChainHeight: 0, + DurangoTime: time.Unix(0, 0), + }, MinBlkDelay: DefaultMinBlockDelay, NumHistoricalBlocks: DefaultNumHistoricalBlocks, StakingLeafSigner: pTestSigner, @@ -1893,9 +1906,11 @@ func TestVMInnerBlkCache(t *testing.T) { vm := New( innerVM, Config{ - ActivationTime: time.Unix(0, 0), - DurangoTime: time.Unix(0, 0), - MinimumPChainHeight: 0, + Upgrades: upgrade.Config{ + ApricotPhase4Time: time.Unix(0, 0), + ApricotPhase4MinPChainHeight: 0, + DurangoTime: time.Unix(0, 0), + }, MinBlkDelay: DefaultMinBlockDelay, NumHistoricalBlocks: DefaultNumHistoricalBlocks, StakingLeafSigner: pTestSigner, @@ -2003,9 +2018,11 @@ func TestVM_VerifyBlockWithContext(t *testing.T) { vm := New( innerVM, Config{ - ActivationTime: time.Unix(0, 0), - DurangoTime: time.Unix(0, 0), - MinimumPChainHeight: 0, + Upgrades: upgrade.Config{ + ApricotPhase4Time: time.Unix(0, 0), + ApricotPhase4MinPChainHeight: 0, + DurangoTime: time.Unix(0, 0), + }, MinBlkDelay: DefaultMinBlockDelay, NumHistoricalBlocks: DefaultNumHistoricalBlocks, StakingLeafSigner: pTestSigner, @@ -2205,9 +2222,11 @@ func TestHistoricalBlockDeletion(t *testing.T) { proVM := New( coreVM, Config{ - ActivationTime: time.Unix(0, 0), - DurangoTime: mockable.MaxTime, - MinimumPChainHeight: 0, + Upgrades: upgrade.Config{ + ApricotPhase4Time: time.Unix(0, 0), + ApricotPhase4MinPChainHeight: 0, + DurangoTime: mockable.MaxTime, + }, MinBlkDelay: DefaultMinBlockDelay, NumHistoricalBlocks: DefaultNumHistoricalBlocks, StakingLeafSigner: pTestSigner, @@ -2297,9 +2316,11 @@ func TestHistoricalBlockDeletion(t *testing.T) { proVM = New( coreVM, Config{ - ActivationTime: time.Time{}, - DurangoTime: mockable.MaxTime, - MinimumPChainHeight: 0, + Upgrades: upgrade.Config{ + ApricotPhase4Time: time.Time{}, + ApricotPhase4MinPChainHeight: 0, + DurangoTime: mockable.MaxTime, + }, MinBlkDelay: DefaultMinBlockDelay, NumHistoricalBlocks: numHistoricalBlocks, StakingLeafSigner: pTestSigner, @@ -2342,9 +2363,11 @@ func TestHistoricalBlockDeletion(t *testing.T) { proVM = New( coreVM, Config{ - ActivationTime: time.Time{}, - DurangoTime: mockable.MaxTime, - MinimumPChainHeight: 0, + Upgrades: upgrade.Config{ + ApricotPhase4Time: time.Time{}, + ApricotPhase4MinPChainHeight: 0, + DurangoTime: mockable.MaxTime, + }, MinBlkDelay: DefaultMinBlockDelay, NumHistoricalBlocks: newNumHistoricalBlocks, StakingLeafSigner: pTestSigner, From c2907b4bb5ab79c06c0359f172e6817d082d4769 Mon Sep 17 00:00:00 2001 From: Stephen Buttolph Date: Thu, 1 Aug 2024 15:51:53 -0400 Subject: [PATCH 09/12] long live etna --- vms/platformvm/block/executor/helpers_test.go | 4 ++-- vms/platformvm/txs/executor/helpers_test.go | 4 ++-- vms/platformvm/txs/executor/standard_tx_executor_test.go | 2 +- vms/platformvm/vm_test.go | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/vms/platformvm/block/executor/helpers_test.go b/vms/platformvm/block/executor/helpers_test.go index 9bd02b8dce5..33470fecf9f 100644 --- a/vms/platformvm/block/executor/helpers_test.go +++ b/vms/platformvm/block/executor/helpers_test.go @@ -69,7 +69,7 @@ const ( banff cortina durango - eUpgrade + etna ) var ( @@ -364,7 +364,7 @@ func defaultConfig(t *testing.T, f fork) *config.Config { } switch f { - case eUpgrade: + case etna: c.UpgradeConfig.EtnaTime = time.Time{} // neglecting fork ordering this for package tests fallthrough case durango: diff --git a/vms/platformvm/txs/executor/helpers_test.go b/vms/platformvm/txs/executor/helpers_test.go index 5e4584f2b12..8aea45ee331 100644 --- a/vms/platformvm/txs/executor/helpers_test.go +++ b/vms/platformvm/txs/executor/helpers_test.go @@ -61,7 +61,7 @@ const ( banff cortina durango - eUpgrade + etna ) var ( @@ -307,7 +307,7 @@ func defaultConfig(t *testing.T, f fork) *config.Config { } switch f { - case eUpgrade: + case etna: c.UpgradeConfig.EtnaTime = defaultValidateStartTime.Add(-2 * time.Second) fallthrough case durango: diff --git a/vms/platformvm/txs/executor/standard_tx_executor_test.go b/vms/platformvm/txs/executor/standard_tx_executor_test.go index 3a0333aa250..f6bd40f7aae 100644 --- a/vms/platformvm/txs/executor/standard_tx_executor_test.go +++ b/vms/platformvm/txs/executor/standard_tx_executor_test.go @@ -2262,7 +2262,7 @@ func defaultTestConfig(t *testing.T, f fork, tm time.Time) *config.Config { } switch f { - case eUpgrade: + case etna: c.UpgradeConfig.EtnaTime = tm fallthrough case durango: diff --git a/vms/platformvm/vm_test.go b/vms/platformvm/vm_test.go index de4f14112f5..726c4a8b039 100644 --- a/vms/platformvm/vm_test.go +++ b/vms/platformvm/vm_test.go @@ -80,7 +80,7 @@ const ( banff cortina durango - eUpgrade + etna latestFork = durango @@ -220,7 +220,7 @@ func defaultVM(t *testing.T, f fork) (*VM, *txstest.WalletFactory, database.Data // to ensure test independence latestForkTime = defaultGenesisTime.Add(time.Second) switch f { - case eUpgrade: + case etna: etnaTime = latestForkTime fallthrough case durango: From cfb4234007b0b2f7f6c956f8acf5ced06c3de5cc Mon Sep 17 00:00:00 2001 From: Stephen Buttolph Date: Thu, 1 Aug 2024 15:59:51 -0400 Subject: [PATCH 10/12] nit --- config/config.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/config/config.go b/config/config.go index e0176464b90..4c98b6a47fd 100644 --- a/config/config.go +++ b/config/config.go @@ -798,8 +798,7 @@ func getTxFeeConfig(v *viper.Viper, networkID uint32) genesis.TxFeeConfig { } func getUpgradeConfig(v *viper.Viper, networkID uint32) (upgrade.Config, error) { - configured := v.IsSet(UpgradeFileContentKey) || v.IsSet(UpgradeFileKey) - if !configured { + if !v.IsSet(UpgradeFileKey) && !v.IsSet(UpgradeFileContentKey) { return upgrade.GetConfig(networkID), nil } From 0906151260cfa4a90e3548469dadcbe60fe4b1ba Mon Sep 17 00:00:00 2001 From: Stephen Buttolph Date: Thu, 1 Aug 2024 16:30:36 -0400 Subject: [PATCH 11/12] reduce diff --- go.mod | 2 +- go.sum | 4 +-- upgrade/upgrade.go | 72 ------------------------------------------ version/constants.go | 75 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 78 insertions(+), 75 deletions(-) diff --git a/go.mod b/go.mod index d9892a314d5..00458471b34 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/DataDog/zstd v1.5.2 github.com/NYTimes/gziphandler v1.1.1 github.com/antithesishq/antithesis-sdk-go v0.3.8 - github.com/ava-labs/coreth v0.13.8-0.20240728153455-82b5d021f081 + github.com/ava-labs/coreth v0.13.7 github.com/ava-labs/ledger-avalanche/go v0.0.0-20240610153809-9c955cc90a95 github.com/btcsuite/btcd/btcutil v1.1.3 github.com/cockroachdb/pebble v0.0.0-20230928194634-aa077af62593 diff --git a/go.sum b/go.sum index fc31ea2ab99..1887349b142 100644 --- a/go.sum +++ b/go.sum @@ -62,8 +62,8 @@ github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax github.com/antithesishq/antithesis-sdk-go v0.3.8 h1:OvGoHxIcOXFJLyn9IJQ5DzByZ3YVAWNBc394ObzDRb8= github.com/antithesishq/antithesis-sdk-go v0.3.8/go.mod h1:IUpT2DPAKh6i/YhSbt6Gl3v2yvUZjmKncl7U91fup7E= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= -github.com/ava-labs/coreth v0.13.8-0.20240728153455-82b5d021f081 h1:xgl4bbOf7+s7p6y+khveDY2BcxDlY+XdaTMlc6m/41o= -github.com/ava-labs/coreth v0.13.8-0.20240728153455-82b5d021f081/go.mod h1:YBkvMDJxoYOsKJUOUvZEhJx06xPuWrqNfG7X8tlUNec= +github.com/ava-labs/coreth v0.13.7 h1:k8T9u/ROifl8f7oXjHRc1KvSISRl9txvy7gGVmHEz6g= +github.com/ava-labs/coreth v0.13.7/go.mod h1:tXDujonxXFOF6oK5HS2EmgtSXJK3Gy6RpZxb5WzR9rM= github.com/ava-labs/ledger-avalanche/go v0.0.0-20240610153809-9c955cc90a95 h1:dOVbtdnZL++pENdTCNZ1nu41eYDQkTML4sWebDnnq8c= github.com/ava-labs/ledger-avalanche/go v0.0.0-20240610153809-9c955cc90a95/go.mod h1:pJxaT9bUgeRNVmNRgtCHb7sFDIRKy7CzTQVi8gGNT6g= github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g= diff --git a/upgrade/upgrade.go b/upgrade/upgrade.go index d2b1fd912c6..f17ecfede88 100644 --- a/upgrade/upgrade.go +++ b/upgrade/upgrade.go @@ -73,78 +73,6 @@ var ( EtnaTime: InitiallyActiveTime, } - // Deprecated: This will be removed once coreth no longer uses it. - ApricotPhase1Times = map[uint32]time.Time{ - constants.MainnetID: Mainnet.ApricotPhase1Time, - constants.FujiID: Fuji.ApricotPhase1Time, - } - - // Deprecated: This will be removed once coreth no longer uses it. - ApricotPhase2Times = map[uint32]time.Time{ - constants.MainnetID: Mainnet.ApricotPhase2Time, - constants.FujiID: Fuji.ApricotPhase2Time, - } - - // Deprecated: This will be removed once coreth no longer uses it. - ApricotPhase3Times = map[uint32]time.Time{ - constants.MainnetID: Mainnet.ApricotPhase3Time, - constants.FujiID: Fuji.ApricotPhase3Time, - } - - // Deprecated: This will be removed once coreth no longer uses it. - ApricotPhase4Times = map[uint32]time.Time{ - constants.MainnetID: Mainnet.ApricotPhase4Time, - constants.FujiID: Fuji.ApricotPhase4Time, - } - - // Deprecated: This will be removed once coreth no longer uses it. - ApricotPhase5Times = map[uint32]time.Time{ - constants.MainnetID: Mainnet.ApricotPhase5Time, - constants.FujiID: Fuji.ApricotPhase5Time, - } - - // Deprecated: This will be removed once coreth no longer uses it. - ApricotPhasePre6Times = map[uint32]time.Time{ - constants.MainnetID: Mainnet.ApricotPhasePre6Time, - constants.FujiID: Fuji.ApricotPhasePre6Time, - } - - // Deprecated: This will be removed once coreth no longer uses it. - ApricotPhase6Times = map[uint32]time.Time{ - constants.MainnetID: Mainnet.ApricotPhase6Time, - constants.FujiID: Fuji.ApricotPhase6Time, - } - - // Deprecated: This will be removed once coreth no longer uses it. - ApricotPhasePost6Times = map[uint32]time.Time{ - constants.MainnetID: Mainnet.ApricotPhasePost6Time, - constants.FujiID: Fuji.ApricotPhasePost6Time, - } - - // Deprecated: This will be removed once coreth no longer uses it. - BanffTimes = map[uint32]time.Time{ - constants.MainnetID: Mainnet.BanffTime, - constants.FujiID: Fuji.BanffTime, - } - - // Deprecated: This will be removed once coreth no longer uses it. - CortinaTimes = map[uint32]time.Time{ - constants.MainnetID: Mainnet.CortinaTime, - constants.FujiID: Fuji.CortinaTime, - } - - // Deprecated: This will be removed once coreth no longer uses it. - DurangoTimes = map[uint32]time.Time{ - constants.MainnetID: Mainnet.DurangoTime, - constants.FujiID: Fuji.DurangoTime, - } - - // Deprecated: This will be removed once coreth no longer uses it. - EUpgradeTimes = map[uint32]time.Time{ - constants.MainnetID: Mainnet.EtnaTime, - constants.FujiID: Fuji.EtnaTime, - } - ErrInvalidUpgradeTimes = errors.New("invalid upgrade configuration") ) diff --git a/version/constants.go b/version/constants.go index a2ef3ced40c..3742f7ffe61 100644 --- a/version/constants.go +++ b/version/constants.go @@ -8,6 +8,9 @@ import ( "time" _ "embed" + + "github.com/ava-labs/avalanchego/upgrade" + "github.com/ava-labs/avalanchego/utils/constants" ) const ( @@ -64,6 +67,78 @@ var ( // set of avalanchego versions that supported that version. This is not used // by avalanchego, but is useful for downstream libraries. RPCChainVMProtocolCompatibility map[uint][]*Semantic + + // Deprecated: This will be removed once coreth no longer uses it. + ApricotPhase1Times = map[uint32]time.Time{ + constants.MainnetID: upgrade.Mainnet.ApricotPhase1Time, + constants.FujiID: upgrade.Fuji.ApricotPhase1Time, + } + + // Deprecated: This will be removed once coreth no longer uses it. + ApricotPhase2Times = map[uint32]time.Time{ + constants.MainnetID: upgrade.Mainnet.ApricotPhase2Time, + constants.FujiID: upgrade.Fuji.ApricotPhase2Time, + } + + // Deprecated: This will be removed once coreth no longer uses it. + ApricotPhase3Times = map[uint32]time.Time{ + constants.MainnetID: upgrade.Mainnet.ApricotPhase3Time, + constants.FujiID: upgrade.Fuji.ApricotPhase3Time, + } + + // Deprecated: This will be removed once coreth no longer uses it. + ApricotPhase4Times = map[uint32]time.Time{ + constants.MainnetID: upgrade.Mainnet.ApricotPhase4Time, + constants.FujiID: upgrade.Fuji.ApricotPhase4Time, + } + + // Deprecated: This will be removed once coreth no longer uses it. + ApricotPhase5Times = map[uint32]time.Time{ + constants.MainnetID: upgrade.Mainnet.ApricotPhase5Time, + constants.FujiID: upgrade.Fuji.ApricotPhase5Time, + } + + // Deprecated: This will be removed once coreth no longer uses it. + ApricotPhasePre6Times = map[uint32]time.Time{ + constants.MainnetID: upgrade.Mainnet.ApricotPhasePre6Time, + constants.FujiID: upgrade.Fuji.ApricotPhasePre6Time, + } + + // Deprecated: This will be removed once coreth no longer uses it. + ApricotPhase6Times = map[uint32]time.Time{ + constants.MainnetID: upgrade.Mainnet.ApricotPhase6Time, + constants.FujiID: upgrade.Fuji.ApricotPhase6Time, + } + + // Deprecated: This will be removed once coreth no longer uses it. + ApricotPhasePost6Times = map[uint32]time.Time{ + constants.MainnetID: upgrade.Mainnet.ApricotPhasePost6Time, + constants.FujiID: upgrade.Fuji.ApricotPhasePost6Time, + } + + // Deprecated: This will be removed once coreth no longer uses it. + BanffTimes = map[uint32]time.Time{ + constants.MainnetID: upgrade.Mainnet.BanffTime, + constants.FujiID: upgrade.Fuji.BanffTime, + } + + // Deprecated: This will be removed once coreth no longer uses it. + CortinaTimes = map[uint32]time.Time{ + constants.MainnetID: upgrade.Mainnet.CortinaTime, + constants.FujiID: upgrade.Fuji.CortinaTime, + } + + // Deprecated: This will be removed once coreth no longer uses it. + DurangoTimes = map[uint32]time.Time{ + constants.MainnetID: upgrade.Mainnet.DurangoTime, + constants.FujiID: upgrade.Fuji.DurangoTime, + } + + // Deprecated: This will be removed once coreth no longer uses it. + EUpgradeTimes = map[uint32]time.Time{ + constants.MainnetID: upgrade.Mainnet.EtnaTime, + constants.FujiID: upgrade.Fuji.EtnaTime, + } ) func init() { From 8eaa376a9226d6e89f98dc1bf4c48762d29a196d Mon Sep 17 00:00:00 2001 From: Stephen Buttolph Date: Thu, 1 Aug 2024 17:18:05 -0400 Subject: [PATCH 12/12] missed one - forgot to save --- vms/platformvm/block/builder/helpers_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vms/platformvm/block/builder/helpers_test.go b/vms/platformvm/block/builder/helpers_test.go index 0c9ff263753..9b1954ebefe 100644 --- a/vms/platformvm/block/builder/helpers_test.go +++ b/vms/platformvm/block/builder/helpers_test.go @@ -66,7 +66,7 @@ const ( banff cortina durango - eUpgrade + etna latestFork = durango ) @@ -334,7 +334,7 @@ func defaultConfig(t *testing.T, f fork) *config.Config { } switch f { - case eUpgrade: + case etna: c.UpgradeConfig.EtnaTime = time.Time{} // neglecting fork ordering this for package tests fallthrough case durango: