Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Cleanup upgrade config #3257

Merged
merged 4 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 13 additions & 21 deletions chains/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
},
)

Expand Down Expand Up @@ -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),
)
Expand All @@ -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,
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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),
)
Expand All @@ -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,
Expand Down
10 changes: 4 additions & 6 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
8 changes: 4 additions & 4 deletions network/network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{},
Expand Down Expand Up @@ -468,7 +468,7 @@ func TestTrackDoesNotDialPrivateIPs(t *testing.T) {

net, err := NewNetwork(
config,
upgrade.DefaultUpgradeTime,
upgrade.InitiallyActiveTime,
msgCreator,
registry,
logging.NoLog{},
Expand Down Expand Up @@ -548,7 +548,7 @@ func TestDialDeletesNonValidators(t *testing.T) {

net, err := NewNetwork(
config,
upgrade.DefaultUpgradeTime,
upgrade.InitiallyActiveTime,
msgCreator,
registry,
logging.NoLog{},
Expand Down Expand Up @@ -703,7 +703,7 @@ func TestAllowConnectionAsAValidator(t *testing.T) {

net, err := NewNetwork(
config,
upgrade.DefaultUpgradeTime,
upgrade.InitiallyActiveTime,
msgCreator,
registry,
logging.NoLog{},
Expand Down
30 changes: 15 additions & 15 deletions network/peer/peer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -480,15 +480,15 @@ 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,
},
expectedPeer: &peer{
Config: &Config{
Log: logging.NoLog{},
VersionCompatibility: version.GetCompatibility(upgrade.DefaultUpgradeTime),
VersionCompatibility: version.GetCompatibility(upgrade.InitiallyActiveTime),
Validators: validators.NewManager(),
},
version: version.CurrentApp,
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion network/peer/test_peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
2 changes: 1 addition & 1 deletion network/test_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ func NewTestNetwork(
resourceTracker.DiskTracker(),
),
},
upgrade.DefaultUpgradeTime,
upgrade.InitiallyActiveTime,
msgCreator,
metrics,
log,
Expand Down
26 changes: 6 additions & 20 deletions node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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{
Expand All @@ -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{}),
Expand Down
10 changes: 4 additions & 6 deletions snow/engine/avalanche/state/serializer.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ package state
import (
"context"
"errors"
"time"

"github.com/ava-labs/avalanchego/cache"
"github.com/ava-labs/avalanchego/database"
Expand Down Expand Up @@ -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 {
Expand Down
Loading
Loading