Skip to content
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
2 changes: 1 addition & 1 deletion api/info/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func (i *Info) GetNodeVersion(_ *http.Request, _ *struct{}, reply *GetNodeVersio
}

reply.Version = i.Version.String()
reply.DatabaseVersion = version.CurrentDatabase.String()
reply.DatabaseVersion = version.CurrentDatabase
reply.RPCProtocolVersion = json.Uint32(version.RPCChainVMProtocol)
reply.GitCommit = version.GitCommit
reply.VMVersions = vmVersions
Expand Down
2 changes: 1 addition & 1 deletion network/peer/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type Config struct {
InboundMsgThrottler throttling.InboundMsgThrottler
Network Network
Router router.InboundHandler
VersionCompatibility version.Compatibility
VersionCompatibility *version.Compatibility
MyNodeID ids.NodeID
// MySubnets does not include the primary network ID
MySubnets set.Set[ids.ID]
Expand Down
9 changes: 5 additions & 4 deletions network/peer/peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ func (p *peer) writeMessages() {
return
}

myVersion := p.VersionCompatibility.Version()
myVersion := p.VersionCompatibility.Current
knownPeersFilter, knownPeersSalt := p.Network.KnownPeers()

_, areWeAPrimaryNetworkValidator := p.Validators.GetValidator(constants.PrimaryNetworkID, p.MyNodeID)
Expand Down Expand Up @@ -709,12 +709,12 @@ func (p *peer) sendNetworkMessages() {
// changes. It's called when sending a Ping rather than in a validator set
// callback to avoid signature verification on the P-chain accept path.
func (p *peer) shouldDisconnect() bool {
if err := p.VersionCompatibility.Compatible(p.version); err != nil {
if !p.VersionCompatibility.Compatible(p.version) {
p.Log.Debug(disconnectingLog,
zap.String("reason", "version not compatible"),
zap.Stringer("nodeID", p.id),
zap.Stringer("myVersion", p.VersionCompatibility.Current),
zap.Stringer("peerVersion", p.version),
zap.Error(err),
)
return true
}
Expand Down Expand Up @@ -897,13 +897,14 @@ func (p *peer) handleHandshake(msg *p2p.Handshake) {
Patch: int(msg.Client.GetPatch()),
}

if p.VersionCompatibility.Version().Before(p.version) {
if myVersion := p.VersionCompatibility.Current; myVersion.Compare(p.version) < 0 {
log := p.Log.Debug
if _, ok := p.Beacons.GetValidator(constants.PrimaryNetworkID, p.id); ok {
log = p.Log.Info
}
log("peer attempting to connect with newer version. You may want to update your client",
zap.Stringer("nodeID", p.id),
zap.Stringer("myVersion", myVersion),
zap.Stringer("peerVersion", p.version),
)
}
Expand Down
24 changes: 12 additions & 12 deletions network/peer/peer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -405,15 +405,15 @@ func TestShouldDisconnect(t *testing.T) {
VersionCompatibility: version.GetCompatibility(upgrade.InitiallyActiveTime),
Validators: validators.NewManager(),
},
version: version.CurrentApp,
version: version.Current,
},
expectedPeer: &peer{
Config: &Config{
Log: logging.NoLog{},
VersionCompatibility: version.GetCompatibility(upgrade.InitiallyActiveTime),
Validators: validators.NewManager(),
},
version: version.CurrentApp,
version: version.Current,
},
expectedShouldDisconnect: false,
},
Expand All @@ -436,7 +436,7 @@ func TestShouldDisconnect(t *testing.T) {
}(),
},
id: peerID,
version: version.CurrentApp,
version: version.Current,
},
expectedPeer: &peer{
Config: &Config{
Expand All @@ -455,7 +455,7 @@ func TestShouldDisconnect(t *testing.T) {
}(),
},
id: peerID,
version: version.CurrentApp,
version: version.Current,
},
expectedShouldDisconnect: false,
},
Expand All @@ -478,7 +478,7 @@ func TestShouldDisconnect(t *testing.T) {
}(),
},
id: peerID,
version: version.CurrentApp,
version: version.Current,
txIDOfVerifiedBLSKey: txID,
},
expectedPeer: &peer{
Expand All @@ -498,7 +498,7 @@ func TestShouldDisconnect(t *testing.T) {
}(),
},
id: peerID,
version: version.CurrentApp,
version: version.Current,
txIDOfVerifiedBLSKey: txID,
},
expectedShouldDisconnect: false,
Expand All @@ -522,7 +522,7 @@ func TestShouldDisconnect(t *testing.T) {
}(),
},
id: peerID,
version: version.CurrentApp,
version: version.Current,
ip: &SignedIP{},
},
expectedPeer: &peer{
Expand All @@ -542,7 +542,7 @@ func TestShouldDisconnect(t *testing.T) {
}(),
},
id: peerID,
version: version.CurrentApp,
version: version.Current,
ip: &SignedIP{},
},
expectedShouldDisconnect: true,
Expand All @@ -566,7 +566,7 @@ func TestShouldDisconnect(t *testing.T) {
}(),
},
id: peerID,
version: version.CurrentApp,
version: version.Current,
ip: &SignedIP{
BLSSignature: must(blsKey.SignProofOfPossession([]byte("wrong message"))),
},
Expand All @@ -588,7 +588,7 @@ func TestShouldDisconnect(t *testing.T) {
}(),
},
id: peerID,
version: version.CurrentApp,
version: version.Current,
ip: &SignedIP{
BLSSignature: must(blsKey.SignProofOfPossession([]byte("wrong message"))),
},
Expand All @@ -614,7 +614,7 @@ func TestShouldDisconnect(t *testing.T) {
}(),
},
id: peerID,
version: version.CurrentApp,
version: version.Current,
ip: &SignedIP{
BLSSignature: must(blsKey.SignProofOfPossession((&UnsignedIP{}).bytes())),
},
Expand All @@ -636,7 +636,7 @@ func TestShouldDisconnect(t *testing.T) {
}(),
},
id: peerID,
version: version.CurrentApp,
version: version.Current,
ip: &SignedIP{
BLSSignature: must(blsKey.SignProofOfPossession((&UnsignedIP{}).bytes())),
},
Expand Down
4 changes: 2 additions & 2 deletions node/beacon_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ func TestBeaconManager_DataRace(t *testing.T) {

for _, nodeID := range validatorIDs {
go func() {
b.Connected(nodeID, version.CurrentApp, constants.PrimaryNetworkID)
b.Connected(nodeID, version.CurrentApp, ids.GenerateTestID())
b.Connected(nodeID, version.Current, constants.PrimaryNetworkID)
b.Connected(nodeID, version.Current, ids.GenerateTestID())
}()
}
wg.Wait()
Expand Down
6 changes: 3 additions & 3 deletions node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ func New(
}

logger.Info("initializing node",
zap.Stringer("version", version.CurrentApp),
zap.Stringer("version", version.Current),
zap.String("commit", version.GitCommit),
zap.Stringer("nodeID", n.ID),
zap.Stringer("stakingKeyType", tlsCert.PublicKeyAlgorithm),
Expand Down Expand Up @@ -760,7 +760,7 @@ func (n *Node) initDatabase() error {
case leveldb.Name:
// Prior to v1.10.15, the only on-disk database was leveldb, and its
// files went to [dbPath]/[networkID]/v1.4.5.
dbFolderName = version.CurrentDatabase.String()
dbFolderName = version.CurrentDatabase
case pebbledb.Name:
dbFolderName = "pebble"
default:
Expand Down Expand Up @@ -1360,7 +1360,7 @@ func (n *Node) initInfoAPI() error {

service, err := info.NewService(
info.Parameters{
Version: version.CurrentApp,
Version: version.Current,
NodeID: n.ID,
NodePOP: pop,
NetworkID: n.Config.NetworkID,
Expand Down
4 changes: 2 additions & 2 deletions snow/engine/avalanche/bootstrap/bootstrapper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@ func newConfig(t *testing.T) (Config, ids.NodeID, *enginetest.Sender, *vertextes
"",
prometheus.NewRegistry(),
nil,
version.CurrentApp,
version.Current,
)
require.NoError(err)

p2pTracker.Connected(peer, version.CurrentApp)
p2pTracker.Connected(peer, version.Current)

return Config{
AllGetsServer: avaGetHandler,
Expand Down
2 changes: 1 addition & 1 deletion snow/engine/common/tracker/peers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func TestPeers(t *testing.T) {
p.OnValidatorAdded(nodeID, nil, ids.Empty, 5)
require.Zero(p.ConnectedWeight())

require.NoError(p.Connected(t.Context(), nodeID, version.CurrentApp))
require.NoError(p.Connected(t.Context(), nodeID, version.Current))
require.Equal(uint64(5), p.ConnectedWeight())

p.OnValidatorWeightChanged(nodeID, 5, 10)
Expand Down
18 changes: 9 additions & 9 deletions snow/engine/snowman/bootstrap/bootstrapper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func newConfig(t *testing.T) (Config, ids.NodeID, *enginetest.Sender, *blocktest
startupTracker := tracker.NewStartup(tracker.NewPeers(), totalWeight/2+1)
vdrs.RegisterSetCallbackListener(ctx.SubnetID, startupTracker)

require.NoError(startupTracker.Connected(t.Context(), peer, version.CurrentApp))
require.NoError(startupTracker.Connected(t.Context(), peer, version.Current))

snowGetHandler, err := getter.New(vm, sender, ctx.Log, time.Second, 2000, ctx.Registerer)
require.NoError(err)
Expand All @@ -88,7 +88,7 @@ func newConfig(t *testing.T) (Config, ids.NodeID, *enginetest.Sender, *blocktest
)
require.NoError(err)

peerTracker.Connected(peer, version.CurrentApp)
peerTracker.Connected(peer, version.Current)

var halter common.Halter

Expand Down Expand Up @@ -198,8 +198,8 @@ func TestBootstrapperStartsOnlyIfEnoughStakeIsConnected(t *testing.T) {
vdr0 := ids.GenerateTestNodeID()
require.NoError(peers.AddStaker(ctx.SubnetID, vdr0, nil, ids.Empty, startupAlpha/2))

peerTracker.Connected(vdr0, version.CurrentApp)
require.NoError(bs.Connected(t.Context(), vdr0, version.CurrentApp))
peerTracker.Connected(vdr0, version.Current)
require.NoError(bs.Connected(t.Context(), vdr0, version.Current))

require.NoError(bs.Start(t.Context(), 0))
require.False(frontierRequested)
Expand All @@ -208,8 +208,8 @@ func TestBootstrapperStartsOnlyIfEnoughStakeIsConnected(t *testing.T) {
vdr := ids.GenerateTestNodeID()
require.NoError(peers.AddStaker(ctx.SubnetID, vdr, nil, ids.Empty, startupAlpha))

peerTracker.Connected(vdr, version.CurrentApp)
require.NoError(bs.Connected(t.Context(), vdr, version.CurrentApp))
peerTracker.Connected(vdr, version.Current)
require.NoError(bs.Connected(t.Context(), vdr, version.Current))
require.True(frontierRequested)
}

Expand Down Expand Up @@ -378,7 +378,7 @@ func TestBootstrapperEmptyResponse(t *testing.T) {

// Add another peer to allow a new node to be selected. A new node should be
// sampled if the prior response was empty.
bs.PeerTracker.Connected(ids.GenerateTestNodeID(), version.CurrentApp)
bs.PeerTracker.Connected(ids.GenerateTestNodeID(), version.Current)

require.NoError(bs.Ancestors(t.Context(), requestedNodeID, requestID, nil)) // respond with empty
require.NotEqual(requestedNodeID, peerID)
Expand Down Expand Up @@ -653,7 +653,7 @@ func TestBootstrapNoParseOnNew(t *testing.T) {
require.NoError(err)
startupTracker := tracker.NewStartup(tracker.NewPeers(), totalWeight/2+1)
peers.RegisterSetCallbackListener(ctx.SubnetID, startupTracker)
require.NoError(startupTracker.Connected(t.Context(), peer, version.CurrentApp))
require.NoError(startupTracker.Connected(t.Context(), peer, version.Current))

snowGetHandler, err := getter.New(vm, sender, ctx.Log, time.Second, 2000, ctx.Registerer)
require.NoError(err)
Expand Down Expand Up @@ -682,7 +682,7 @@ func TestBootstrapNoParseOnNew(t *testing.T) {
)
require.NoError(err)

peerTracker.Connected(peer, version.CurrentApp)
peerTracker.Connected(peer, version.Current)

config := Config{
Haltable: &common.Halter{},
Expand Down
2 changes: 1 addition & 1 deletion snow/engine/snowman/engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func setup(t *testing.T, config Config) (ids.NodeID, validators.Manager, *engine

vdr := ids.GenerateTestNodeID()
require.NoError(config.Validators.AddStaker(config.Ctx.SubnetID, vdr, nil, ids.Empty, 1))
require.NoError(config.ConnectedValidators.Connected(t.Context(), vdr, version.CurrentApp))
require.NoError(config.ConnectedValidators.Connected(t.Context(), vdr, version.Current))
config.Validators.RegisterSetCallbackListener(config.Ctx.SubnetID, config.ConnectedValidators)

sender := &enginetest.Sender{T: t}
Expand Down
Loading