-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into sc-ssv-runner-consensus-sanity-tests
- Loading branch information
Showing
53 changed files
with
532 additions
and
166 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package commit | ||
|
||
import ( | ||
"github.com/bloxapp/ssv-spec/qbft" | ||
"github.com/bloxapp/ssv-spec/qbft/spectest/tests" | ||
"github.com/bloxapp/ssv-spec/types" | ||
"github.com/bloxapp/ssv-spec/types/testingutils" | ||
"github.com/bloxapp/ssv-spec/types/testingutils/comparable" | ||
) | ||
|
||
// NoCommitQuorum tests the state of the QBFT instance when received commit messages don't create a quorum | ||
func NoCommitQuorum() tests.SpecTest { | ||
pre := testingutils.BaseInstance() | ||
ks := testingutils.Testing4SharesSet() | ||
sc := NoCommitQuorumStateComparison() | ||
|
||
msgs := []*qbft.SignedMessage{ | ||
testingutils.TestingProposalMessage(ks.Shares[1], 1), | ||
|
||
testingutils.TestingPrepareMessage(ks.Shares[1], 1), | ||
testingutils.TestingPrepareMessage(ks.Shares[2], 2), | ||
testingutils.TestingPrepareMessage(ks.Shares[3], 3), | ||
|
||
testingutils.TestingCommitMessage(ks.Shares[1], 1), | ||
testingutils.TestingCommitMessage(ks.Shares[2], 2), | ||
} | ||
return &tests.MsgProcessingSpecTest{ | ||
Name: "no commit quorum", | ||
Pre: pre, | ||
PostRoot: sc.Root(), | ||
PostState: sc.ExpectedState, | ||
InputMessages: msgs, | ||
OutputMessages: []*qbft.SignedMessage{ | ||
testingutils.TestingPrepareMessage(ks.Shares[1], 1), | ||
testingutils.TestingCommitMessage(ks.Shares[1], 1), | ||
}, | ||
} | ||
} | ||
|
||
func NoCommitQuorumStateComparison() *comparable.StateComparison { | ||
ks := testingutils.Testing4SharesSet() | ||
|
||
state := testingutils.BaseInstance().State | ||
state.ProposalAcceptedForCurrentRound = testingutils.TestingProposalMessage(ks.Shares[1], types.OperatorID(1)) | ||
|
||
state.LastPreparedRound = 1 | ||
state.LastPreparedValue = testingutils.TestingQBFTFullData | ||
state.Decided = false | ||
|
||
state.ProposeContainer = &qbft.MsgContainer{Msgs: map[qbft.Round][]*qbft.SignedMessage{ | ||
qbft.FirstRound: { | ||
testingutils.TestingProposalMessage(ks.Shares[1], types.OperatorID(1)), | ||
}, | ||
}} | ||
|
||
state.PrepareContainer = &qbft.MsgContainer{Msgs: map[qbft.Round][]*qbft.SignedMessage{ | ||
qbft.FirstRound: { | ||
testingutils.TestingPrepareMessage(ks.Shares[1], types.OperatorID(1)), | ||
testingutils.TestingPrepareMessage(ks.Shares[2], types.OperatorID(2)), | ||
testingutils.TestingPrepareMessage(ks.Shares[3], types.OperatorID(3)), | ||
}, | ||
}} | ||
|
||
state.CommitContainer = &qbft.MsgContainer{Msgs: map[qbft.Round][]*qbft.SignedMessage{ | ||
qbft.FirstRound: { | ||
testingutils.TestingCommitMessage(ks.Shares[1], types.OperatorID(1)), | ||
testingutils.TestingCommitMessage(ks.Shares[2], types.OperatorID(2)), | ||
}, | ||
}} | ||
|
||
return &comparable.StateComparison{ExpectedState: state} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
qbft/spectest/tests/messages/create_round_change_no_justification_quorum.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package messages | ||
|
||
import ( | ||
"github.com/bloxapp/ssv-spec/qbft" | ||
"github.com/bloxapp/ssv-spec/qbft/spectest/tests" | ||
"github.com/bloxapp/ssv-spec/types" | ||
"github.com/bloxapp/ssv-spec/types/testingutils" | ||
"github.com/bloxapp/ssv-spec/types/testingutils/comparable" | ||
"github.com/pkg/errors" | ||
) | ||
|
||
// CreateRoundChangeNoJustificationQuorum tests creating a round change msg that was previouly prepared | ||
// but failed to extract a justification quorum (shouldn't happen). | ||
// The result should be an unjustified round change. | ||
func CreateRoundChangeNoJustificationQuorum() tests.SpecTest { | ||
ks := testingutils.Testing4SharesSet() | ||
sc := CreateRoundChangeNoJustificationQuorumSC() | ||
return &tests.CreateMsgSpecTest{ | ||
CreateType: tests.CreateRoundChange, | ||
Name: "create round change no justification quorum", | ||
StateValue: testingutils.TestingQBFTFullData, | ||
ExpectedState: sc.ExpectedState, | ||
PrepareJustifications: []*qbft.SignedMessage{ | ||
testingutils.TestingPrepareMessage(ks.Shares[1], types.OperatorID(1)), | ||
testingutils.TestingPrepareMessage(ks.Shares[2], types.OperatorID(2)), | ||
}, | ||
ExpectedRoot: sc.Root(), | ||
} | ||
} | ||
|
||
func CreateRoundChangeNoJustificationQuorumSC() *comparable.StateComparison { | ||
expectedMsg := qbft.Message{ | ||
MsgType: qbft.RoundChangeMsgType, | ||
Height: 0, | ||
Round: 1, | ||
Identifier: []byte{1, 2, 3, 4}, | ||
Root: testingutils.TestingQBFTRootData, | ||
DataRound: 1, | ||
RoundChangeJustification: [][]byte{}, | ||
PrepareJustification: nil, | ||
} | ||
|
||
ks := testingutils.Testing4SharesSet() | ||
config := testingutils.TestingConfig(ks) | ||
sig, err := config.GetSigner().SignRoot(&expectedMsg, types.QBFTSignatureType, config.GetSigningPubKey()) | ||
if err != nil { | ||
panic(errors.Wrap(err, "unable to sign root for create_round_change_no_justification_quorum")) | ||
} | ||
signedMsg := &qbft.SignedMessage{ | ||
Signature: sig, | ||
Signers: []types.OperatorID{1}, | ||
Message: expectedMsg, | ||
|
||
FullData: testingutils.TestingQBFTFullData, | ||
} | ||
return &comparable.StateComparison{ExpectedState: signedMsg} | ||
} |
71 changes: 71 additions & 0 deletions
71
qbft/spectest/tests/prepare/prepare_quorum_triggered_twice.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package prepare | ||
|
||
import ( | ||
"github.com/bloxapp/ssv-spec/qbft" | ||
"github.com/bloxapp/ssv-spec/qbft/spectest/tests" | ||
"github.com/bloxapp/ssv-spec/types" | ||
"github.com/bloxapp/ssv-spec/types/testingutils" | ||
"github.com/bloxapp/ssv-spec/types/testingutils/comparable" | ||
) | ||
|
||
// PrepareQuorumTriggeredTwice tests triggering prepare quorum twice by sending > 2f+1 prepare messages | ||
func PrepareQuorumTriggeredTwice() tests.SpecTest { | ||
ks := testingutils.Testing4SharesSet() | ||
pre := testingutils.BaseInstance() | ||
sc := prepareQuorumTriggeredTwiceStateComparison() | ||
msgs := []*qbft.SignedMessage{ | ||
testingutils.TestingProposalMessage(ks.Shares[1], 1), | ||
|
||
testingutils.TestingPrepareMessage(ks.Shares[1], 1), | ||
testingutils.TestingPrepareMessage(ks.Shares[2], 2), | ||
testingutils.TestingPrepareMessage(ks.Shares[3], 3), | ||
|
||
testingutils.TestingCommitMessage(ks.Shares[1], 1), | ||
|
||
testingutils.TestingPrepareMessage(ks.Shares[4], 4), | ||
} | ||
return &tests.MsgProcessingSpecTest{ | ||
Name: "prepared quorum committed twice", | ||
Pre: pre, | ||
PostRoot: sc.Root(), | ||
PostState: sc.ExpectedState, | ||
InputMessages: msgs, | ||
OutputMessages: []*qbft.SignedMessage{ | ||
testingutils.TestingPrepareMessage(ks.Shares[1], 1), | ||
testingutils.TestingCommitMessage(ks.Shares[1], 1), | ||
}, | ||
} | ||
} | ||
|
||
func prepareQuorumTriggeredTwiceStateComparison() *comparable.StateComparison { | ||
ks := testingutils.Testing4SharesSet() | ||
|
||
state := testingutils.BaseInstance().State | ||
state.ProposalAcceptedForCurrentRound = testingutils.TestingProposalMessage(ks.Shares[1], types.OperatorID(1)) | ||
|
||
state.LastPreparedRound = 1 | ||
state.LastPreparedValue = testingutils.TestingQBFTFullData | ||
|
||
state.ProposeContainer = &qbft.MsgContainer{Msgs: map[qbft.Round][]*qbft.SignedMessage{ | ||
qbft.FirstRound: { | ||
testingutils.TestingProposalMessage(ks.Shares[1], types.OperatorID(1)), | ||
}, | ||
}} | ||
|
||
state.PrepareContainer = &qbft.MsgContainer{Msgs: map[qbft.Round][]*qbft.SignedMessage{ | ||
qbft.FirstRound: { | ||
testingutils.TestingPrepareMessage(ks.Shares[1], types.OperatorID(1)), | ||
testingutils.TestingPrepareMessage(ks.Shares[2], types.OperatorID(2)), | ||
testingutils.TestingPrepareMessage(ks.Shares[3], types.OperatorID(3)), | ||
testingutils.TestingPrepareMessage(ks.Shares[4], types.OperatorID(4)), | ||
}, | ||
}} | ||
|
||
state.CommitContainer = &qbft.MsgContainer{Msgs: map[qbft.Round][]*qbft.SignedMessage{ | ||
qbft.FirstRound: { | ||
testingutils.TestingCommitMessage(ks.Shares[1], types.OperatorID(1)), | ||
}, | ||
}} | ||
|
||
return &comparable.StateComparison{ExpectedState: state} | ||
} |
39 changes: 39 additions & 0 deletions
39
qbft/spectest/tests/prepare/prepare_quorum_triggered_twice_late_commit.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package prepare | ||
|
||
import ( | ||
"github.com/bloxapp/ssv-spec/qbft" | ||
"github.com/bloxapp/ssv-spec/qbft/spectest/tests" | ||
"github.com/bloxapp/ssv-spec/types/testingutils" | ||
) | ||
|
||
// PrepareQuorumTriggeredTwiceLateCommit tests triggering prepare quorum twice by sending > 2f+1 prepare messages. | ||
// The commit message is processed after the second prepare quorum is triggered. | ||
func PrepareQuorumTriggeredTwiceLateCommit() tests.SpecTest { | ||
ks := testingutils.Testing4SharesSet() | ||
pre := testingutils.BaseInstance() | ||
sc := prepareQuorumTriggeredTwiceStateComparison() | ||
|
||
msgs := []*qbft.SignedMessage{ | ||
testingutils.TestingProposalMessage(ks.Shares[1], 1), | ||
|
||
testingutils.TestingPrepareMessage(ks.Shares[1], 1), | ||
testingutils.TestingPrepareMessage(ks.Shares[2], 2), | ||
testingutils.TestingPrepareMessage(ks.Shares[3], 3), | ||
|
||
testingutils.TestingPrepareMessage(ks.Shares[4], 4), | ||
testingutils.TestingCommitMessage(ks.Shares[1], 1), | ||
} | ||
return &tests.MsgProcessingSpecTest{ | ||
Name: "prepared quorum committed twice late commit", | ||
Pre: pre, | ||
PostRoot: sc.Root(), | ||
PostState: sc.ExpectedState, | ||
InputMessages: msgs, | ||
OutputMessages: []*qbft.SignedMessage{ | ||
testingutils.TestingPrepareMessage(ks.Shares[1], 1), | ||
testingutils.TestingCommitMessage(ks.Shares[1], 1), | ||
// ISSUE 214: we should have only commit broadcasted | ||
testingutils.TestingCommitMessage(ks.Shares[1], 1), | ||
}, | ||
} | ||
} |
Oops, something went wrong.