@@ -61,6 +61,7 @@ import (
6161 "github.com/ava-labs/avalanchego/trace"
6262 "github.com/ava-labs/avalanchego/utils"
6363 "github.com/ava-labs/avalanchego/utils/constants"
64+ "github.com/ava-labs/avalanchego/utils/crypto/bls"
6465 "github.com/ava-labs/avalanchego/utils/dynamicip"
6566 "github.com/ava-labs/avalanchego/utils/filesystem"
6667 "github.com/ava-labs/avalanchego/utils/hashing"
@@ -1495,6 +1496,32 @@ func (n *Node) initHealthAPI() error {
14951496 return fmt .Errorf ("couldn't register resource health check: %w" , err )
14961497 }
14971498
1499+ wrongBLSKeyCheck := health .CheckerFunc (func (context.Context ) (interface {}, error ) {
1500+ vdr , ok := n .vdrs .GetValidator (constants .PrimaryNetworkID , n .ID )
1501+ if ! ok {
1502+ return "node is not a validator" , nil
1503+ }
1504+
1505+ vdrPK := vdr .PublicKey
1506+ if vdrPK == nil {
1507+ return "validator doesn't have a BLS key" , nil
1508+ }
1509+
1510+ nodePK := n .Config .StakingSigningKey .PublicKey ()
1511+ if nodePK .Equals (vdrPK ) {
1512+ return "node has the correct BLS key" , nil
1513+ }
1514+ return nil , fmt .Errorf ("node has BLS key 0x%x, but is registered to the validator set with 0x%x" ,
1515+ bls .PublicKeyToCompressedBytes (nodePK ),
1516+ bls .PublicKeyToCompressedBytes (vdrPK ),
1517+ )
1518+ })
1519+
1520+ err = n .health .RegisterHealthCheck ("bls" , wrongBLSKeyCheck , health .ApplicationTag )
1521+ if err != nil {
1522+ return fmt .Errorf ("couldn't register bls health check: %w" , err )
1523+ }
1524+
14981525 handler , err := health .NewGetAndPostHandler (n .Log , n .health )
14991526 if err != nil {
15001527 return err
0 commit comments