Skip to content

Commit

Permalink
minor adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
iurii-ssv committed Oct 26, 2024
1 parent e6043e3 commit 1f220c0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 33 deletions.
25 changes: 0 additions & 25 deletions protocol/v2/qbft/instance/proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,30 +138,6 @@ func isValidProposal(
return errors.New("proposal is not valid with current state")
}

func IsProposalJustification(
config qbft.IConfig,
committeeMember *spectypes.CommitteeMember,
roundChangeMsgs []*specqbft.ProcessingMessage,
prepareMsgs []*specqbft.ProcessingMessage,
height specqbft.Height,
round specqbft.Round,
fullData []byte,
) error {
return isProposalJustification(
&specqbft.State{
CommitteeMember: committeeMember,
Height: height,
},
config,
roundChangeMsgs,
prepareMsgs,
height,
round,
fullData,
func(data []byte) error { return nil },
)
}

// isProposalJustification returns nil if the proposal and round change messages are valid and justify a proposal message for the provided round, value and leader
func isProposalJustification(
state *specqbft.State,
Expand Down Expand Up @@ -210,7 +186,6 @@ func isProposalJustification(
if !previouslyPrepared {
return nil
} else {

// check prepare quorum
if !specqbft.HasQuorum(state.CommitteeMember, prepareMsgs) {
return errors.New("prepares has no quorum")
Expand Down
21 changes: 13 additions & 8 deletions protocol/v2/qbft/instance/round_change.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ func (i *Instance) uponRoundChange(
instanceStartValue,
msg,
roundChangeMsgContainer,
valCheck)
valCheck,
)
if err != nil {
return errors.Wrap(err, "could not get proposal justification for leading round")
}
Expand Down Expand Up @@ -144,10 +145,13 @@ func hasReceivedPartialQuorum(state *specqbft.State, roundChangeMsgContainer *sp
return specqbft.HasPartialQuorum(state.CommitteeMember, rc), rc
}

// 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
// (all the above considering the operator is a leader for the round
// hasReceivedProposalJustificationForLeadingRound (if operator is a leader for the round):
// - if first round or not received round change msgs with prepare justification
// returns first round change 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 operator is not a leader for the round - return nil, nil, nil.
func hasReceivedProposalJustificationForLeadingRound(
state *specqbft.State,
config qbft.IConfig,
Expand All @@ -163,7 +167,7 @@ func hasReceivedProposalJustificationForLeadingRound(
}

// Important!
// We iterate on all round chance msgs for liveliness in case the last round change msg is malicious.
// We iterate on all round change msgs for liveliness in case the last round change msg is malicious.
for _, containerRoundChangeMessage := range roundChanges {
// Chose proposal value.
// If justifiedRoundChangeMsg has no prepare justification chose state value
Expand Down Expand Up @@ -219,7 +223,8 @@ func isProposalJustificationForLeadingRound(
roundChangeJustifications,
roundChangeMsg.QBFTMessage.Round,
value,
valCheck); err != nil {
valCheck,
); err != nil {
return err
}

Expand Down Expand Up @@ -382,7 +387,7 @@ func highestPrepared(roundChanges []*specqbft.ProcessingMessage) (*specqbft.Proc
return ret, nil
}

// returns the min round number out of the signed round change messages and the current round
// returns the min round number out of the signed round change messages
func minRound(roundChangeMsgs []*specqbft.ProcessingMessage) specqbft.Round {
ret := specqbft.NoRound
for _, msg := range roundChangeMsgs {
Expand Down

0 comments on commit 1f220c0

Please sign in to comment.