From 5ad0f14f2709e05724b1269b98d70bf65fa74fe1 Mon Sep 17 00:00:00 2001 From: olegshmuelov <45327364+olegshmuelov@users.noreply.github.com> Date: Tue, 16 Apr 2024 15:24:51 +0300 Subject: [PATCH] Pass MessageID To Broadcast (#381) * implementation * reorg params * use GetID for message id --- p2p/interface.go | 2 +- qbft/controller.go | 2 +- qbft/instance.go | 2 +- ssv/aggregator.go | 4 ++-- ssv/attester.go | 2 +- ssv/proposer.go | 4 ++-- ssv/sync_committee.go | 2 +- ssv/sync_committee_aggregator.go | 4 ++-- ssv/validator_registration.go | 2 +- ssv/voluntary_exit.go | 2 +- types/messages.go | 2 +- types/testingutils/network.go | 2 +- 12 files changed, 15 insertions(+), 15 deletions(-) diff --git a/p2p/interface.go b/p2p/interface.go index e61a7bd61..0cc2ce2ba 100644 --- a/p2p/interface.go +++ b/p2p/interface.go @@ -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 diff --git a/qbft/controller.go b/qbft/controller.go index 90f0163a8..1411b039f 100644 --- a/qbft/controller.go +++ b/qbft/controller.go @@ -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") } diff --git a/qbft/instance.go b/qbft/instance.go index c724ec256..91cd814f4 100644 --- a/qbft/instance.go +++ b/qbft/instance.go @@ -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 diff --git a/ssv/aggregator.go b/ssv/aggregator.go index 145204d05..759f3860b 100644 --- a/ssv/aggregator.go +++ b/ssv/aggregator.go @@ -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 @@ -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 diff --git a/ssv/attester.go b/ssv/attester.go index 55ed2841e..627f0c27d 100644 --- a/ssv/attester.go +++ b/ssv/attester.go @@ -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 diff --git a/ssv/proposer.go b/ssv/proposer.go index fe0ed6213..5ed84c76f 100644 --- a/ssv/proposer.go +++ b/ssv/proposer.go @@ -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 @@ -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 diff --git a/ssv/sync_committee.go b/ssv/sync_committee.go index 5556cc56c..d9455fbf8 100644 --- a/ssv/sync_committee.go +++ b/ssv/sync_committee.go @@ -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 diff --git a/ssv/sync_committee_aggregator.go b/ssv/sync_committee_aggregator.go index d2fffa2d7..7e5db0e46 100644 --- a/ssv/sync_committee_aggregator.go +++ b/ssv/sync_committee_aggregator.go @@ -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 @@ -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 diff --git a/ssv/validator_registration.go b/ssv/validator_registration.go index d8e650a13..dbf4ada4d 100644 --- a/ssv/validator_registration.go +++ b/ssv/validator_registration.go @@ -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 diff --git a/ssv/voluntary_exit.go b/ssv/voluntary_exit.go index 95854de12..173b06f02 100644 --- a/ssv/voluntary_exit.go +++ b/ssv/voluntary_exit.go @@ -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") } diff --git a/types/messages.go b/types/messages.go index 4c887eba9..285076d42 100644 --- a/types/messages.go +++ b/types/messages.go @@ -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 diff --git a/types/testingutils/network.go b/types/testingutils/network.go index ef21d7fc0..1399afaeb 100644 --- a/types/testingutils/network.go +++ b/types/testingutils/network.go @@ -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 }