Skip to content

Commit 50ca08e

Browse files
Remove pre-Durango checks in BLS key verification (#2824)
1 parent 1340cce commit 50ca08e

File tree

2 files changed

+4
-97
lines changed

2 files changed

+4
-97
lines changed

network/peer/peer.go

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -716,22 +716,14 @@ func (p *peer) shouldDisconnect() bool {
716716
return false
717717
}
718718

719-
postDurango := p.Clock.Time().After(version.GetDurangoTime(constants.MainnetID))
720-
if postDurango && p.ip.BLSSignature == nil {
719+
if p.ip.BLSSignature == nil {
721720
p.Log.Debug("disconnecting from peer",
722721
zap.String("reason", "missing BLS signature"),
723722
zap.Stringer("nodeID", p.id),
724723
)
725724
return true
726725
}
727726

728-
// If Durango hasn't activated on mainnet yet, we don't require BLS
729-
// signatures to be provided. However, if they are provided, verify that
730-
// they are correct.
731-
if p.ip.BLSSignature == nil {
732-
return false
733-
}
734-
735727
validSignature := bls.VerifyProofOfPossession(
736728
vdr.PublicKey,
737729
p.ip.BLSSignature,

network/peer/peer_test.go

Lines changed: 3 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import (
2929
"github.com/ava-labs/avalanchego/utils/math/meter"
3030
"github.com/ava-labs/avalanchego/utils/resource"
3131
"github.com/ava-labs/avalanchego/utils/set"
32-
"github.com/ava-labs/avalanchego/utils/timer/mockable"
3332
"github.com/ava-labs/avalanchego/version"
3433
)
3534

@@ -591,14 +590,9 @@ func TestShouldDisconnect(t *testing.T) {
591590
expectedShouldDisconnect: false,
592591
},
593592
{
594-
name: "past durango without a signature",
593+
name: "peer without signature",
595594
initialPeer: &peer{
596595
Config: &Config{
597-
Clock: func() mockable.Clock {
598-
clk := mockable.Clock{}
599-
clk.Set(mockable.MaxTime)
600-
return clk
601-
}(),
602596
Log: logging.NoLog{},
603597
VersionCompatibility: version.GetCompatibility(constants.UnitTestID),
604598
Validators: func() validators.Manager {
@@ -619,11 +613,6 @@ func TestShouldDisconnect(t *testing.T) {
619613
},
620614
expectedPeer: &peer{
621615
Config: &Config{
622-
Clock: func() mockable.Clock {
623-
clk := mockable.Clock{}
624-
clk.Set(mockable.MaxTime)
625-
return clk
626-
}(),
627616
Log: logging.NoLog{},
628617
VersionCompatibility: version.GetCompatibility(constants.UnitTestID),
629618
Validators: func() validators.Manager {
@@ -645,68 +634,9 @@ func TestShouldDisconnect(t *testing.T) {
645634
expectedShouldDisconnect: true,
646635
},
647636
{
648-
name: "pre durango without a signature",
637+
name: "peer with invalid signature",
649638
initialPeer: &peer{
650639
Config: &Config{
651-
Clock: func() mockable.Clock {
652-
clk := mockable.Clock{}
653-
clk.Set(time.Time{})
654-
return clk
655-
}(),
656-
Log: logging.NoLog{},
657-
VersionCompatibility: version.GetCompatibility(constants.UnitTestID),
658-
Validators: func() validators.Manager {
659-
vdrs := validators.NewManager()
660-
require.NoError(t, vdrs.AddStaker(
661-
constants.PrimaryNetworkID,
662-
peerID,
663-
bls.PublicFromSecretKey(blsKey),
664-
txID,
665-
1,
666-
))
667-
return vdrs
668-
}(),
669-
},
670-
id: peerID,
671-
version: version.CurrentApp,
672-
ip: &SignedIP{},
673-
},
674-
expectedPeer: &peer{
675-
Config: &Config{
676-
Clock: func() mockable.Clock {
677-
clk := mockable.Clock{}
678-
clk.Set(time.Time{})
679-
return clk
680-
}(),
681-
Log: logging.NoLog{},
682-
VersionCompatibility: version.GetCompatibility(constants.UnitTestID),
683-
Validators: func() validators.Manager {
684-
vdrs := validators.NewManager()
685-
require.NoError(t, vdrs.AddStaker(
686-
constants.PrimaryNetworkID,
687-
peerID,
688-
bls.PublicFromSecretKey(blsKey),
689-
txID,
690-
1,
691-
))
692-
return vdrs
693-
}(),
694-
},
695-
id: peerID,
696-
version: version.CurrentApp,
697-
ip: &SignedIP{},
698-
},
699-
expectedShouldDisconnect: false,
700-
},
701-
{
702-
name: "pre durango with an invalid signature",
703-
initialPeer: &peer{
704-
Config: &Config{
705-
Clock: func() mockable.Clock {
706-
clk := mockable.Clock{}
707-
clk.Set(time.Time{})
708-
return clk
709-
}(),
710640
Log: logging.NoLog{},
711641
VersionCompatibility: version.GetCompatibility(constants.UnitTestID),
712642
Validators: func() validators.Manager {
@@ -729,11 +659,6 @@ func TestShouldDisconnect(t *testing.T) {
729659
},
730660
expectedPeer: &peer{
731661
Config: &Config{
732-
Clock: func() mockable.Clock {
733-
clk := mockable.Clock{}
734-
clk.Set(time.Time{})
735-
return clk
736-
}(),
737662
Log: logging.NoLog{},
738663
VersionCompatibility: version.GetCompatibility(constants.UnitTestID),
739664
Validators: func() validators.Manager {
@@ -757,14 +682,9 @@ func TestShouldDisconnect(t *testing.T) {
757682
expectedShouldDisconnect: true,
758683
},
759684
{
760-
name: "pre durango with a valid signature",
685+
name: "peer with valid signature",
761686
initialPeer: &peer{
762687
Config: &Config{
763-
Clock: func() mockable.Clock {
764-
clk := mockable.Clock{}
765-
clk.Set(time.Time{})
766-
return clk
767-
}(),
768688
Log: logging.NoLog{},
769689
VersionCompatibility: version.GetCompatibility(constants.UnitTestID),
770690
Validators: func() validators.Manager {
@@ -787,11 +707,6 @@ func TestShouldDisconnect(t *testing.T) {
787707
},
788708
expectedPeer: &peer{
789709
Config: &Config{
790-
Clock: func() mockable.Clock {
791-
clk := mockable.Clock{}
792-
clk.Set(time.Time{})
793-
return clk
794-
}(),
795710
Log: logging.NoLog{},
796711
VersionCompatibility: version.GetCompatibility(constants.UnitTestID),
797712
Validators: func() validators.Manager {

0 commit comments

Comments
 (0)