Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix - Misaligned terms #349

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions qbft/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package qbft
import (
"bytes"
"crypto/sha256"

"github.com/bloxapp/ssv-spec/types"
"github.com/pkg/errors"
)
Expand Down Expand Up @@ -53,15 +54,15 @@ type Message struct {
Root [32]byte `ssz-size:"32"`
DataRound Round
RoundChangeJustification [][]byte `ssz-max:"13,65536"` // 2^16
PrepareJustification [][]byte `ssz-max:"13,65536"` // 2^16
ProposalJustification [][]byte `ssz-max:"13,65536"` // 2^16
}

func (msg *Message) GetRoundChangeJustifications() ([]*SignedMessage, error) {
return unmarshalJustifications(msg.RoundChangeJustification)
}

func (msg *Message) GetPrepareJustifications() ([]*SignedMessage, error) {
return unmarshalJustifications(msg.PrepareJustification)
func (msg *Message) GetProposalJustifications() ([]*SignedMessage, error) {
return unmarshalJustifications(msg.ProposalJustification)
}

func unmarshalJustifications(data [][]byte) ([]*SignedMessage, error) {
Expand Down Expand Up @@ -121,7 +122,7 @@ func (msg *Message) Validate() error {
if _, err := msg.GetRoundChangeJustifications(); err != nil {
return err
}
if _, err := msg.GetPrepareJustifications(); err != nil {
if _, err := msg.GetProposalJustifications(); err != nil {
return err
}
if msg.MsgType > RoundChangeMsgType {
Expand Down Expand Up @@ -245,7 +246,7 @@ func (signedMsg *SignedMessage) DeepCopy() *SignedMessage {

Root: signedMsg.Message.Root,
DataRound: signedMsg.Message.DataRound,
PrepareJustification: signedMsg.Message.PrepareJustification,
ProposalJustification: signedMsg.Message.ProposalJustification,
RoundChangeJustification: signedMsg.Message.RoundChangeJustification,
}
copy(ret.Message.Identifier, signedMsg.Message.Identifier)
Expand Down
52 changes: 26 additions & 26 deletions qbft/messages_encoding.go

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

9 changes: 5 additions & 4 deletions qbft/proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package qbft

import (
"bytes"

"github.com/bloxapp/ssv-spec/types"
"github.com/pkg/errors"
)
Expand Down Expand Up @@ -82,13 +83,13 @@ func isValidProposal(

// get justifications
roundChangeJustification, _ := signedProposal.Message.GetRoundChangeJustifications() // no need to check error, checked on signedProposal.Validate()
prepareJustification, _ := signedProposal.Message.GetPrepareJustifications() // no need to check error, checked on signedProposal.Validate()
proposalJustification, _ := signedProposal.Message.GetProposalJustifications() // no need to check error, checked on signedProposal.Validate()

if err := isProposalJustification(
state,
config,
proposalJustification,
roundChangeJustification,
prepareJustification,
state.Height,
signedProposal.Message.Round,
signedProposal.FullData,
Expand Down Expand Up @@ -234,8 +235,8 @@ func CreateProposal(state *State, config IConfig, fullData []byte, roundChanges,
Identifier: state.ID,

Root: r,
RoundChangeJustification: roundChangesData,
PrepareJustification: preparesData,
RoundChangeJustification: preparesData,
ProposalJustification: roundChangesData,
}
sig, err := config.GetSigner().SignRoot(msg, types.QBFTSignatureType, state.Share.SharePubKey)
if err != nil {
Expand Down
5 changes: 3 additions & 2 deletions qbft/round_change.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package qbft

import (
"bytes"

"github.com/bloxapp/ssv-spec/types"
"github.com/pkg/errors"
)
Expand Down Expand Up @@ -98,8 +99,8 @@ func hasReceivedPartialQuorum(state *State, roundChangeMsgContainer *MsgContaine
}

// hasReceivedProposalJustificationForLeadingRound returns
// if first round or not received round change msgs with prepare justification - returns first rc msg in container and value to propose
// if received round change msgs with prepare justification - returns the highest prepare justification round change msg and value to propose
// if first round or not received round change msgs with prepare msgs justification - returns first rc msg in container and value to propose
// if received round change msgs with prepare msgs justification - returns the highest prepared round change msg and value to propose
// (all the above considering the operator is a leader for the round
func hasReceivedProposalJustificationForLeadingRound(
state *State,
Expand Down
14 changes: 7 additions & 7 deletions qbft/spectest/all_tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,18 +126,18 @@ var AllTests = []tests.TestF{
proposal.FirstRoundJustification,
proposal.FutureRoundPrevNotPrepared,
proposal.FutureRound,
proposal.InvalidRoundChangeJustificationPrepared,
proposal.InvalidRoundChangeJustification,
proposal.PreparedPreviouslyNoRCJustificationQuorum,
proposal.NoRCJustification,
proposal.PreparedPreviouslyNoPrepareJustificationQuorum,
proposal.InvalidProposalJustificationPrepared,
proposal.InvalidProposalJustification,
proposal.PreparedPreviouslyNoProposalJustificationQuorum,
proposal.NoProposalJustification,
proposal.PreparedPreviouslyNoRoundChangeJustificationQuorum,
proposal.PreparedPreviouslyDuplicatePrepareMsg,
proposal.PreparedPreviouslyDuplicatePrepareQuorum,
proposal.PreparedPreviouslyDuplicateRCMsg,
proposal.PreparedPreviouslyDuplicateRCQuorum,
proposal.DuplicateRCMsg,
proposal.InvalidPrepareJustificationValue,
proposal.InvalidPrepareJustificationRound,
proposal.InvalidProposalJustificationValue,
proposal.InvalidProposalJustificationRound,
proposal.InvalidValueCheck,
proposal.MultiSigner,
proposal.PostDecided,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
],
"DataRound": 0,
"RoundChangeJustification": null,
"PrepareJustification": null
"ProposalJustification": null
},
"FullData": "AQIDBAUGBwgJAQIDBAUGBwgJAQIDBAUGBwgJ"
},
Expand Down Expand Up @@ -165,7 +165,7 @@
],
"DataRound": 0,
"RoundChangeJustification": null,
"PrepareJustification": null
"ProposalJustification": null
},
"FullData": "AQIDBAUGBwgJAQIDBAUGBwgJAQIDBAUGBwgJ"
}
Expand Down Expand Up @@ -221,7 +221,7 @@
],
"DataRound": 0,
"RoundChangeJustification": null,
"PrepareJustification": null
"ProposalJustification": null
},
"FullData": null
},
Expand Down Expand Up @@ -271,7 +271,7 @@
],
"DataRound": 0,
"RoundChangeJustification": null,
"PrepareJustification": null
"ProposalJustification": null
},
"FullData": null
},
Expand Down Expand Up @@ -321,7 +321,7 @@
],
"DataRound": 0,
"RoundChangeJustification": null,
"PrepareJustification": null
"ProposalJustification": null
},
"FullData": null
}
Expand Down Expand Up @@ -377,7 +377,7 @@
],
"DataRound": 0,
"RoundChangeJustification": null,
"PrepareJustification": null
"ProposalJustification": null
},
"FullData": null
},
Expand Down Expand Up @@ -427,7 +427,7 @@
],
"DataRound": 0,
"RoundChangeJustification": null,
"PrepareJustification": null
"ProposalJustification": null
},
"FullData": null
},
Expand Down Expand Up @@ -477,7 +477,7 @@
],
"DataRound": 0,
"RoundChangeJustification": null,
"PrepareJustification": null
"ProposalJustification": null
},
"FullData": null
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
],
"DataRound": 0,
"RoundChangeJustification": null,
"PrepareJustification": null
"ProposalJustification": null
},
"FullData": "AQIDBAUGBwgJAQIDBAUGBwgJAQIDBAUGBwgJ"
},
Expand Down Expand Up @@ -165,7 +165,7 @@
],
"DataRound": 0,
"RoundChangeJustification": null,
"PrepareJustification": null
"ProposalJustification": null
},
"FullData": "AQIDBAUGBwgJAQIDBAUGBwgJAQIDBAUGBwgJ"
}
Expand Down Expand Up @@ -221,7 +221,7 @@
],
"DataRound": 0,
"RoundChangeJustification": null,
"PrepareJustification": null
"ProposalJustification": null
},
"FullData": "AQIDBAUGBwgJAQIDBAUGBwgJAQIDBAUGBwgJ"
},
Expand Down Expand Up @@ -271,7 +271,7 @@
],
"DataRound": 0,
"RoundChangeJustification": null,
"PrepareJustification": null
"ProposalJustification": null
},
"FullData": "AQIDBAUGBwgJAQIDBAUGBwgJAQIDBAUGBwgJ"
},
Expand Down Expand Up @@ -321,7 +321,7 @@
],
"DataRound": 0,
"RoundChangeJustification": null,
"PrepareJustification": null
"ProposalJustification": null
},
"FullData": "AQIDBAUGBwgJAQIDBAUGBwgJAQIDBAUGBwgJ"
}
Expand Down Expand Up @@ -377,7 +377,7 @@
],
"DataRound": 0,
"RoundChangeJustification": null,
"PrepareJustification": null
"ProposalJustification": null
},
"FullData": null
},
Expand Down Expand Up @@ -427,7 +427,7 @@
],
"DataRound": 0,
"RoundChangeJustification": null,
"PrepareJustification": null
"ProposalJustification": null
},
"FullData": null
}
Expand Down Expand Up @@ -481,7 +481,7 @@
],
"DataRound": 0,
"RoundChangeJustification": null,
"PrepareJustification": null
"ProposalJustification": null
},
"FullData": "AQIDBAUGBwgJAQIDBAUGBwgJAQIDBAUGBwgJ"
}
Expand Down
Loading