Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
8 changes: 4 additions & 4 deletions qbft/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

// Controller is a QBFT coordinator responsible for starting and following the entire life cycle of multiple QBFT InstanceContainer
type Controller struct {
Identifier []byte
Identifier Identifier
Height Height // incremental Height for InstanceContainer
// StoredInstances stores the last HistoricalInstanceCapacity in an array for message processing purposes.
StoredInstances InstanceContainer
Expand All @@ -20,7 +20,7 @@ type Controller struct {
config IConfig
}

func NewController(identifier []byte, committeeMember *types.CommitteeMember, config IConfig,
func NewController(identifier Identifier, committeeMember *types.CommitteeMember, config IConfig,
signer *types.OperatorSigner) *Controller {
return &Controller{
Identifier: identifier,
Expand Down Expand Up @@ -130,7 +130,7 @@ func (c *Controller) UponExistingInstanceMsg(msg *ProcessingMessage) (*types.Sig
// BaseMsgValidation returns error if msg is invalid (base validation)
func (c *Controller) BaseMsgValidation(msg *ProcessingMessage) error {
// verify msg belongs to controller
if !bytes.Equal(c.Identifier, msg.QBFTMessage.Identifier) {
if !bytes.Equal(c.Identifier[:], msg.QBFTMessage.Identifier[:]) {
return errors.New("message doesn't belong to Identifier")
}
return nil
Expand All @@ -141,7 +141,7 @@ func (c *Controller) InstanceForHeight(height Height) *Instance {
}

// GetIdentifier returns QBFT Identifier, used to identify messages
func (c *Controller) GetIdentifier() []byte {
func (c *Controller) GetIdentifier() Identifier {
return c.Identifier
}

Expand Down
2 changes: 1 addition & 1 deletion qbft/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type Instance struct {
func NewInstance(
config IConfig,
committeeMember *types.CommitteeMember,
identifier []byte,
identifier Identifier,
height Height,
signer *types.OperatorSigner,
) *Instance {
Expand Down
4 changes: 2 additions & 2 deletions qbft/instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func TestInstance_Marshaling(t *testing.T) {
MsgType: qbft.ProposalMsgType,
Height: qbft.FirstHeight,
Round: qbft.FirstRound,
Identifier: []byte{1, 2, 3, 4},
Identifier: testingutils.TestingIdentifier,
Root: testingutils.TestingQBFTRootData,
}
keySet := testingutils.Testing4SharesSet()
Expand All @@ -27,7 +27,7 @@ func TestInstance_Marshaling(t *testing.T) {
i := &qbft.Instance{
State: &qbft.State{
CommitteeMember: testingCommitteeMember,
ID: []byte{1, 2, 3, 4},
ID: testingutils.TestingIdentifier,
Round: 1,
Height: 1,
LastPreparedRound: 1,
Expand Down
5 changes: 1 addition & 4 deletions qbft/message_container_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,14 @@ func TestMsgContainer_Marshaling(t *testing.T) {

func MessageWithSigners(signers []types.OperatorID, msg *qbft.Message) *qbft.ProcessingMessage {

msgID := [56]byte{}
copy(msgID[:], msg.Identifier)

encodedMsg, err := msg.Encode()
if err != nil {
panic(err)
}

ssvMsg := &types.SSVMessage{
MsgType: types.SSVConsensusMsgType,
MsgID: msgID,
MsgID: types.MessageID(msg.Identifier),
Data: encodedMsg,
}
return testingutils.ToProcessingMessage(&types.SignedSSVMessage{
Expand Down
16 changes: 6 additions & 10 deletions qbft/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ const (

type Message struct {
MsgType MessageType
Height Height // QBFT instance Height
Round Round // QBFT round for which the msg is for
Identifier []byte `ssz-max:"56"` // instance Identifier this msg belongs to
Height Height // QBFT instance Height
Round Round // QBFT round for which the msg is for
Identifier Identifier `ssz-size:"56"` // instance Identifier this msg belongs to

Root [32]byte `ssz-size:"32"`
DataRound Round // The last round that obtained a Prepare quorum
RoundChangeJustification [][]byte `ssz-max:"13,51852"`
PrepareJustification [][]byte `ssz-max:"13,3700"`
RoundChangeJustification [][]byte `ssz-max:"13,51796"`
PrepareJustification [][]byte `ssz-max:"13,3696"`
}

// Creates a Message object from bytes
Expand Down Expand Up @@ -90,9 +90,6 @@ func (msg *Message) GetRoot() ([32]byte, error) {
// Validate returns error if msg validation doesn't pass.
// Msg validation checks the msg, it's variables for validity.
func (msg *Message) Validate() error {
if len(msg.Identifier) == 0 {
return errors.New("message identifier is invalid")
}
if _, err := msg.GetRoundChangeJustifications(); err != nil {
return err
}
Expand Down Expand Up @@ -144,8 +141,7 @@ func Sign(msg *Message, operatorID types.OperatorID, operatorSigner *types.Opera
return nil, errors.Wrap(err, "could not encode message")
}

msgID := types.MessageID{}
copy(msgID[:], msg.Identifier)
msgID := types.MessageID(msg.Identifier)

ssvMsg := &types.SSVMessage{
MsgType: types.SSVConsensusMsgType,
Expand Down
90 changes: 28 additions & 62 deletions qbft/messages_encoding.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions qbft/spectest/all_tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,6 @@ var AllTests = []tests.TestF{
messages.RoundChangePrePreparedJustifications,
messages.RoundChangeNotPreparedJustifications,
messages.CommitDataEncoding,
messages.MsgNilIdentifier,
messages.MsgNonZeroIdentifier,
messages.MsgTypeUnknown,
messages.PrepareDataEncoding,
messages.PrepareJustificationsUnmarshalling,
Expand Down
Loading