Skip to content

Commit

Permalink
fixed qbft/instance/instance.go (#1403)
Browse files Browse the repository at this point in the history
  • Loading branch information
AKorpusenko committed May 24, 2024
1 parent a926ea0 commit 472f800
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
16 changes: 13 additions & 3 deletions protocol/v2/qbft/instance/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,10 @@ func (i *Instance) BaseMsgValidation(signedMsg *spectypes.SignedSSVMessage) erro
return err
}

if err := msg.Validate(); err != nil {
return errors.Wrap(err, "invalid Message")
}

if msg.Round < i.State.Round {
return errors.New("past round")
}
Expand All @@ -181,15 +185,21 @@ func (i *Instance) BaseMsgValidation(signedMsg *spectypes.SignedSSVMessage) erro
i.config.GetValueCheckF(),
)
case specqbft.PrepareMsgType:
proposedMsg := i.State.ProposalAcceptedForCurrentRound
if proposedMsg == nil {
proposedSignedMsg := i.State.ProposalAcceptedForCurrentRound
if proposedSignedMsg == nil {
return errors.New("did not receive proposal for this round")
}

proposedMsg, err := specqbft.DecodeMessage(proposedSignedMsg.SSVMessage.Data)
if err != nil {
return errors.Wrap(err, "proposal saved for this round is invalid")
}

return validSignedPrepareForHeightRoundAndRootIgnoreSignature(
signedMsg,
i.State.Height,
i.State.Round,
msg.Root,
proposedMsg.Root,
i.State.Share.Committee,
)
case specqbft.CommitMsgType:
Expand Down
9 changes: 0 additions & 9 deletions protocol/v2/qbft/spectest/qbft_mapping_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,6 @@ func TestQBFTMapping(t *testing.T) {
testName := strings.Split(name, "_")[1]
testType := strings.Split(name, "_")[0]

//
//if testName != "qbft message processing prepare wrong data" {
// continue
//}
//
//if testName != "qbft create message create round change no justification quorum" {
// continue
//}

switch testType {
case reflect.TypeOf(&spectests.MsgProcessingSpecTest{}).String():
byts, err := json.Marshal(test)
Expand Down

0 comments on commit 472f800

Please sign in to comment.