Skip to content

Commit

Permalink
Pass MessageID To Broadcast (#381)
Browse files Browse the repository at this point in the history
* implementation

* reorg params

* use GetID for message id
  • Loading branch information
olegshmuelov authored Apr 16, 2024
1 parent 331f2f0 commit 5ad0f14
Show file tree
Hide file tree
Showing 12 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion p2p/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import "github.com/bloxapp/ssv-spec/types"

// Broadcaster is the interface used to abstract message broadcasting
type Broadcaster interface {
Broadcast(message *types.SignedSSVMessage) error
Broadcast(msgID types.MessageID, message *types.SignedSSVMessage) error
}

// Subscriber is used to abstract topic management
Expand Down
2 changes: 1 addition & 1 deletion qbft/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ func (c *Controller) broadcastDecided(aggregatedCommit *SignedMessage) error {
return errors.Wrap(err, "could not create SignedSSVMessage from SSVMessage")
}

if err := c.GetConfig().GetNetwork().Broadcast(msgToBroadcast); err != nil {
if err := c.GetConfig().GetNetwork().Broadcast(ssvMsg.GetID(), msgToBroadcast); err != nil {
// We do not return error here, just Log broadcasting error.
return errors.Wrap(err, "could not broadcast decided")
}
Expand Down
2 changes: 1 addition & 1 deletion qbft/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func (i *Instance) Broadcast(msg *SignedMessage) error {
return errors.Wrap(err, "could not create SignedSSVMessage from SSVMessage")
}

return i.GetConfig().GetNetwork().Broadcast(msgToBroadcast)
return i.GetConfig().GetNetwork().Broadcast(ssvMsg.GetID(), msgToBroadcast)
}

// ProcessMsg processes a new QBFT msg, returns non nil error on msg processing error
Expand Down
4 changes: 2 additions & 2 deletions ssv/aggregator.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ func (r *AggregatorRunner) ProcessConsensus(signedMsg *qbft.SignedMessage) error
return errors.Wrap(err, "could not create SignedSSVMessage from SSVMessage")
}

if err := r.GetNetwork().Broadcast(msgToBroadcast); err != nil {
if err := r.GetNetwork().Broadcast(ssvMsg.GetID(), msgToBroadcast); err != nil {
return errors.Wrap(err, "can't broadcast partial post consensus sig")
}
return nil
Expand Down Expand Up @@ -260,7 +260,7 @@ func (r *AggregatorRunner) executeDuty(duty *types.Duty) error {
return errors.Wrap(err, "could not create SignedSSVMessage from SSVMessage")
}

if err := r.GetNetwork().Broadcast(msgToBroadcast); err != nil {
if err := r.GetNetwork().Broadcast(ssvMsg.GetID(), msgToBroadcast); err != nil {
return errors.Wrap(err, "can't broadcast partial selection proof sig")
}
return nil
Expand Down
2 changes: 1 addition & 1 deletion ssv/attester.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func (r *AttesterRunner) ProcessConsensus(signedMsg *qbft.SignedMessage) error {
return errors.Wrap(err, "could not create SignedSSVMessage from SSVMessage")
}

if err := r.GetNetwork().Broadcast(msgToBroadcast); err != nil {
if err := r.GetNetwork().Broadcast(ssvMsg.GetID(), msgToBroadcast); err != nil {
return errors.Wrap(err, "can't broadcast partial post consensus sig")
}
return nil
Expand Down
4 changes: 2 additions & 2 deletions ssv/proposer.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ func (r *ProposerRunner) ProcessConsensus(signedMsg *qbft.SignedMessage) error {
return errors.Wrap(err, "could not create SignedSSVMessage from SSVMessage")
}

if err := r.GetNetwork().Broadcast(msgToBroadcast); err != nil {
if err := r.GetNetwork().Broadcast(ssvMsg.GetID(), msgToBroadcast); err != nil {
return errors.Wrap(err, "can't broadcast partial post consensus sig")
}
return nil
Expand Down Expand Up @@ -308,7 +308,7 @@ func (r *ProposerRunner) executeDuty(duty *types.Duty) error {
return errors.Wrap(err, "could not create SignedSSVMessage from SSVMessage")
}

if err := r.GetNetwork().Broadcast(msgToBroadcast); err != nil {
if err := r.GetNetwork().Broadcast(ssvMsg.GetID(), msgToBroadcast); err != nil {
return errors.Wrap(err, "can't broadcast partial randao sig")
}
return nil
Expand Down
2 changes: 1 addition & 1 deletion ssv/sync_committee.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func (r *SyncCommitteeRunner) ProcessConsensus(signedMsg *qbft.SignedMessage) er
return errors.Wrap(err, "could not create SignedSSVMessage from SSVMessage")
}

if err := r.GetNetwork().Broadcast(msgToBroadcast); err != nil {
if err := r.GetNetwork().Broadcast(ssvMsg.GetID(), msgToBroadcast); err != nil {
return errors.Wrap(err, "can't broadcast partial post consensus sig")
}
return nil
Expand Down
4 changes: 2 additions & 2 deletions ssv/sync_committee_aggregator.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ func (r *SyncCommitteeAggregatorRunner) ProcessConsensus(signedMsg *qbft.SignedM
return errors.Wrap(err, "could not create SignedSSVMessage from SSVMessage")
}

if err := r.GetNetwork().Broadcast(msgToBroadcast); err != nil {
if err := r.GetNetwork().Broadcast(ssvMsg.GetID(), msgToBroadcast); err != nil {
return errors.Wrap(err, "can't broadcast partial post consensus sig")
}
return nil
Expand Down Expand Up @@ -372,7 +372,7 @@ func (r *SyncCommitteeAggregatorRunner) executeDuty(duty *types.Duty) error {
return errors.Wrap(err, "could not create SignedSSVMessage from SSVMessage")
}

if err := r.GetNetwork().Broadcast(msgToBroadcast); err != nil {
if err := r.GetNetwork().Broadcast(ssvMsg.GetID(), msgToBroadcast); err != nil {
return errors.Wrap(err, "can't broadcast partial contribution proof sig")
}
return nil
Expand Down
2 changes: 1 addition & 1 deletion ssv/validator_registration.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ func (r *ValidatorRegistrationRunner) executeDuty(duty *types.Duty) error {
return errors.Wrap(err, "could not create SignedSSVMessage from SSVMessage")
}

if err := r.GetNetwork().Broadcast(msgToBroadcast); err != nil {
if err := r.GetNetwork().Broadcast(ssvMsg.GetID(), msgToBroadcast); err != nil {
return errors.Wrap(err, "can't broadcast partial randao sig")
}
return nil
Expand Down
2 changes: 1 addition & 1 deletion ssv/voluntary_exit.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ func (r *VoluntaryExitRunner) executeDuty(duty *types.Duty) error {
return errors.Wrap(err, "could not create SignedSSVMessage from SSVMessage")
}

if err := r.GetNetwork().Broadcast(msgToBroadcast); err != nil {
if err := r.GetNetwork().Broadcast(ssvMsg.GetID(), msgToBroadcast); err != nil {
return errors.Wrap(err, "can't broadcast signedPartialMsg with VoluntaryExit")
}

Expand Down
2 changes: 1 addition & 1 deletion types/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func (msg *SSVMessage) Decode(data []byte) error {
return msg.UnmarshalSSZ(data)
}

// SSVMessage is the main message passed within the SSV network. It encapsulates the SSVMessage structure and a signature
// SignedSSVMessage is the main message passed within the SSV network. It encapsulates the SSVMessage structure and a signature
type SignedSSVMessage struct {
Signature [256]byte // Created by the operator's network key
OperatorID OperatorID
Expand Down
2 changes: 1 addition & 1 deletion types/testingutils/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func NewTestingNetwork(operatorID types.OperatorID, sk *rsa.PrivateKey) *Testing
}
}

func (net *TestingNetwork) Broadcast(message *types.SignedSSVMessage) error {
func (net *TestingNetwork) Broadcast(msgID types.MessageID, message *types.SignedSSVMessage) error {
net.BroadcastedMsgs = append(net.BroadcastedMsgs, message)
return nil
}
Expand Down

0 comments on commit 5ad0f14

Please sign in to comment.