Skip to content

Commit

Permalink
fix: stale operator ID in p2pNetwork (#1229) (#1230)
Browse files Browse the repository at this point in the history
* fix: stale operator ID in `p2pNetwork`

---------

Co-authored-by: Lior Rutenberg <[email protected]>
  • Loading branch information
moshe-blox and Lior Rutenberg authored Dec 6, 2023
1 parent 2731ff3 commit 5e7e0d7
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
7 changes: 5 additions & 2 deletions cli/operator/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,13 @@ var StartNodeCmd = &cobra.Command{
logger.Fatal("could not connect to execution client", zap.Error(err))
}

var validatorCtrl validator.Controller
cfg.P2pNetworkConfig.Permissioned = permissioned
cfg.P2pNetworkConfig.NodeStorage = nodeStorage
cfg.P2pNetworkConfig.OperatorPubKeyHash = format.OperatorID(operatorData.PublicKey)
cfg.P2pNetworkConfig.OperatorID = operatorData.ID
cfg.P2pNetworkConfig.OperatorID = func() spectypes.OperatorID {
return validatorCtrl.GetOperatorData().ID
}
cfg.P2pNetworkConfig.FullNode = cfg.SSVOptions.ValidatorOptions.FullNode
cfg.P2pNetworkConfig.Network = networkConfig

Expand Down Expand Up @@ -238,7 +241,7 @@ var StartNodeCmd = &cobra.Command{
cfg.SSVOptions.ValidatorOptions.Metrics = metricsReporter
cfg.SSVOptions.Metrics = metricsReporter

validatorCtrl := validator.NewController(logger, cfg.SSVOptions.ValidatorOptions)
validatorCtrl = validator.NewController(logger, cfg.SSVOptions.ValidatorOptions)
cfg.SSVOptions.ValidatorController = validatorCtrl

operatorNode = operator.New(logger, cfg.SSVOptions, slotTickerProvider)
Expand Down
2 changes: 1 addition & 1 deletion network/p2p/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ type Config struct {
// OperatorPubKeyHash is hash of operator public key, used for identity, optional
OperatorPubKeyHash string
// OperatorID contains numeric operator ID
OperatorID spectypes.OperatorID
OperatorID func() spectypes.OperatorID
// Router propagate incoming network messages to the responsive components
Router network.MessageRouter
// UserAgent to use by libp2p identify protocol
Expand Down
2 changes: 1 addition & 1 deletion network/p2p/p2p.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ type p2pNetwork struct {
nodeStorage operatorstorage.Storage
operatorPKHashToPKCache *hashmap.Map[string, []byte] // used for metrics
operatorPrivateKey *rsa.PrivateKey
operatorID spectypes.OperatorID
operatorID func() spectypes.OperatorID
}

// New creates a new p2p network
Expand Down
2 changes: 1 addition & 1 deletion network/p2p/p2p_pubsub.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (n *p2pNetwork) Broadcast(msg *spectypes.SSVMessage) error {
return err
}

encodedMsg = commons.EncodeSignedSSVMessage(encodedMsg, n.operatorID, signature)
encodedMsg = commons.EncodeSignedSSVMessage(encodedMsg, n.operatorID(), signature)
}

vpk := msg.GetID().GetPubKey()
Expand Down

0 comments on commit 5e7e0d7

Please sign in to comment.