-
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.
* drop blinded block rejection * generate JSONs * Added test for Runner receiving different type of block (normal/blinded) * Merge with branch 'main' * Separate blinded test from full happy flow test * Move tests; Add tests to all_tests file * Revert to previous types/tests.json --------- Co-authored-by: Matheus Franco <[email protected]>
- Loading branch information
1 parent
384b025
commit 8fd4372
Showing
14 changed files
with
5,237 additions
and
25 deletions.
There are no files selected for viewing
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
1,249 changes: 1,249 additions & 0 deletions
1,249
...pts_normal_block_proposal/blinded proposer accepts normal block proposal (bellatrix).json
Large diffs are not rendered by default.
Oops, something went wrong.
1,249 changes: 1,249 additions & 0 deletions
1,249
...cepts_normal_block_proposal/blinded proposer accepts normal block proposal (capella).json
Large diffs are not rendered by default.
Oops, something went wrong.
1,249 changes: 1,249 additions & 0 deletions
1,249
...ts_blinded_block_proposal/normal proposer accepts blinded block proposal (bellatrix).json
Large diffs are not rendered by default.
Oops, something went wrong.
1,249 changes: 1,249 additions & 0 deletions
1,249
...epts_blinded_block_proposal/normal proposer accepts blinded block proposal (capella).json
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
52 changes: 52 additions & 0 deletions
52
ssv/spectest/tests/runner/duties/proposer/blinded_accepts_normal_block.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,52 @@ | ||
package proposer | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/attestantio/go-eth2-client/spec" | ||
|
||
"github.com/bloxapp/ssv-spec/ssv/spectest/tests" | ||
"github.com/bloxapp/ssv-spec/types" | ||
"github.com/bloxapp/ssv-spec/types/testingutils" | ||
) | ||
|
||
// BlindedRunnerAcceptsNormalBlock tests a full happy flow for a proposer runner that produces blinded blocks but receives as proposal a normal block | ||
func BlindedRunnerAcceptsNormalBlock() tests.SpecTest { | ||
ks := testingutils.Testing4SharesSet() | ||
|
||
multiSpecTest := &tests.MultiMsgProcessingSpecTest{ | ||
Name: "blinded proposer accepts normal block proposal", | ||
Tests: []*tests.MsgProcessingSpecTest{}, | ||
} | ||
|
||
// proposerBlindedReceivingNormalBlockV creates a test specification for versioned blinded proposer receiving a normal block. | ||
proposerBlindedReceivingNormalBlockV := func(version spec.DataVersion) *tests.MsgProcessingSpecTest { | ||
return &tests.MsgProcessingSpecTest{ | ||
Name: fmt.Sprintf("blinded proposer accepts normal block proposal (%s)", version.String()), | ||
Runner: testingutils.ProposerBlindedBlockRunner(ks), | ||
Duty: testingutils.TestingProposerDutyV(version), | ||
Messages: append( | ||
testingutils.SSVDecidingMsgsV(testingutils.TestProposerConsensusDataV(version), ks, types.BNRoleProposer), // consensus | ||
[]*types.SSVMessage{ // post consensus | ||
testingutils.SSVMsgProposer(nil, testingutils.PostConsensusProposerMsgV(ks.Shares[1], 1, version)), | ||
testingutils.SSVMsgProposer(nil, testingutils.PostConsensusProposerMsgV(ks.Shares[2], 2, version)), | ||
testingutils.SSVMsgProposer(nil, testingutils.PostConsensusProposerMsgV(ks.Shares[3], 3, version)), | ||
}..., | ||
), | ||
PostDutyRunnerStateRoot: fullHappyFlowBlindedProposerReceivingNormalBlockSC(version).Root(), | ||
PostDutyRunnerState: fullHappyFlowBlindedProposerReceivingNormalBlockSC(version).ExpectedState, | ||
OutputMessages: []*types.SignedPartialSignatureMessage{ | ||
testingutils.PreConsensusRandaoMsgV(ks.Shares[1], 1, version), | ||
testingutils.PostConsensusProposerMsgV(ks.Shares[1], 1, version), | ||
}, | ||
BeaconBroadcastedRoots: []string{ | ||
testingutils.GetSSZRootNoError(testingutils.TestingSignedBeaconBlockV(ks, version)), | ||
}, | ||
} | ||
} | ||
|
||
for _, v := range testingutils.SupportedBlockVersions { | ||
multiSpecTest.Tests = append(multiSpecTest.Tests, []*tests.MsgProcessingSpecTest{proposerBlindedReceivingNormalBlockV(v)}...) | ||
} | ||
return multiSpecTest | ||
} |
124 changes: 124 additions & 0 deletions
124
ssv/spectest/tests/runner/duties/proposer/blinded_sc.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,124 @@ | ||
package proposer | ||
|
||
import ( | ||
"github.com/attestantio/go-eth2-client/spec" | ||
|
||
"github.com/bloxapp/ssv-spec/qbft" | ||
"github.com/bloxapp/ssv-spec/ssv" | ||
ssvcomparable "github.com/bloxapp/ssv-spec/ssv/spectest/comparable" | ||
"github.com/bloxapp/ssv-spec/types" | ||
"github.com/bloxapp/ssv-spec/types/testingutils" | ||
"github.com/bloxapp/ssv-spec/types/testingutils/comparable" | ||
) | ||
|
||
// fullHappyFlowProposerReceivingBlindedBlockSC returns state comparison object for the FullHappyFlow for a normal Proposer receiving a Blinded Block versioned spec test | ||
func fullHappyFlowProposerReceivingBlindedBlockSC(version spec.DataVersion) *comparable.StateComparison { | ||
ks := testingutils.Testing4SharesSet() | ||
// consensus data used for message creation | ||
cd := testingutils.TestProposerBlindedBlockConsensusDataV(version) | ||
// encoded consensus data relative to messages | ||
cdBytes := testingutils.TestProposerBlindedBlockConsensusDataBytsV(version) | ||
// encoded consensus data that the runner set as StartValue | ||
startedCdBytes := testingutils.TestProposerConsensusDataBytsV(version) | ||
|
||
return &comparable.StateComparison{ | ||
ExpectedState: func() ssv.Runner { | ||
ret := testingutils.ProposerRunner(ks) | ||
ret.GetBaseRunner().State = &ssv.State{ | ||
PreConsensusContainer: ssvcomparable.SetMessagesInContainer( | ||
ssv.NewPartialSigContainer(3), | ||
testingutils.ExpectedSSVDecidingMsgsV(cd, ks, types.BNRoleProposer)[:3], | ||
), | ||
PostConsensusContainer: ssvcomparable.SetMessagesInContainer( | ||
ssv.NewPartialSigContainer(3), | ||
[]*types.SSVMessage{ | ||
testingutils.SSVMsgProposer(nil, testingutils.PostConsensusProposerMsgV(ks.Shares[1], 1, version)), | ||
testingutils.SSVMsgProposer(nil, testingutils.PostConsensusProposerMsgV(ks.Shares[2], 2, version)), | ||
testingutils.SSVMsgProposer(nil, testingutils.PostConsensusProposerMsgV(ks.Shares[3], 3, version)), | ||
}, | ||
), | ||
DecidedValue: comparable.FixIssue178(cd, version), | ||
StartingDuty: &testingutils.TestProposerConsensusDataV(version).Duty, | ||
Finished: true, | ||
} | ||
ret.GetBaseRunner().State.RunningInstance = &qbft.Instance{ | ||
State: &qbft.State{ | ||
Share: testingutils.TestingShare(ks), | ||
ID: ret.GetBaseRunner().QBFTController.Identifier, | ||
Round: qbft.FirstRound, | ||
Height: qbft.Height(testingutils.TestingDutySlotV(version)), | ||
LastPreparedRound: qbft.FirstRound, | ||
LastPreparedValue: cdBytes, | ||
ProposalAcceptedForCurrentRound: testingutils.TestingProposalMessageWithIdentifierAndFullData( | ||
ks.Shares[1], types.OperatorID(1), ret.GetBaseRunner().QBFTController.Identifier, cdBytes, qbft.Height(testingutils.TestingDutySlotV(version))), | ||
Decided: true, | ||
DecidedValue: cdBytes, | ||
}, | ||
StartValue: startedCdBytes, | ||
} | ||
ret.GetBaseRunner().QBFTController.Height = qbft.Height(testingutils.TestingDutySlotV(version)) | ||
comparable.SetMessages( | ||
ret.GetBaseRunner().State.RunningInstance, | ||
testingutils.ExpectedSSVDecidingMsgsV(cd, ks, types.BNRoleProposer)[3:10], | ||
) | ||
ret.GetBaseRunner().QBFTController.StoredInstances = append(ret.GetBaseRunner().QBFTController.StoredInstances, ret.GetBaseRunner().State.RunningInstance) | ||
return ret | ||
}(), | ||
} | ||
} | ||
|
||
// fullHappyFlowBlindedProposerReceivingNormalBlockSC returns state comparison object for the FullHappyFlow for a Blinded Proposer receiving a Normal Block versioned spec test | ||
func fullHappyFlowBlindedProposerReceivingNormalBlockSC(version spec.DataVersion) *comparable.StateComparison { | ||
ks := testingutils.Testing4SharesSet() | ||
// consensus data used for message creation | ||
cd := testingutils.TestProposerConsensusDataV(version) | ||
// encoded consensus data relative to messages | ||
cdBytes := testingutils.TestProposerConsensusDataBytsV(version) | ||
// encoded consensus data that the runner set as StartValue | ||
startedCdBytes := testingutils.TestProposerBlindedBlockConsensusDataBytsV(version) | ||
|
||
return &comparable.StateComparison{ | ||
ExpectedState: func() ssv.Runner { | ||
ret := testingutils.ProposerBlindedBlockRunner(ks) | ||
ret.GetBaseRunner().State = &ssv.State{ | ||
PreConsensusContainer: ssvcomparable.SetMessagesInContainer( | ||
ssv.NewPartialSigContainer(3), | ||
testingutils.ExpectedSSVDecidingMsgsV(cd, ks, types.BNRoleProposer)[:3], | ||
), | ||
PostConsensusContainer: ssvcomparable.SetMessagesInContainer( | ||
ssv.NewPartialSigContainer(3), | ||
[]*types.SSVMessage{ | ||
testingutils.SSVMsgProposer(nil, testingutils.PostConsensusProposerMsgV(ks.Shares[1], 1, version)), | ||
testingutils.SSVMsgProposer(nil, testingutils.PostConsensusProposerMsgV(ks.Shares[2], 2, version)), | ||
testingutils.SSVMsgProposer(nil, testingutils.PostConsensusProposerMsgV(ks.Shares[3], 3, version)), | ||
}, | ||
), | ||
DecidedValue: comparable.FixIssue178(cd, version), | ||
StartingDuty: &testingutils.TestProposerConsensusDataV(version).Duty, | ||
Finished: true, | ||
} | ||
ret.GetBaseRunner().State.RunningInstance = &qbft.Instance{ | ||
State: &qbft.State{ | ||
Share: testingutils.TestingShare(ks), | ||
ID: ret.GetBaseRunner().QBFTController.Identifier, | ||
Round: qbft.FirstRound, | ||
Height: qbft.Height(testingutils.TestingDutySlotV(version)), | ||
LastPreparedRound: qbft.FirstRound, | ||
LastPreparedValue: cdBytes, | ||
ProposalAcceptedForCurrentRound: testingutils.TestingProposalMessageWithIdentifierAndFullData( | ||
ks.Shares[1], types.OperatorID(1), ret.GetBaseRunner().QBFTController.Identifier, cdBytes, qbft.Height(testingutils.TestingDutySlotV(version))), | ||
Decided: true, | ||
DecidedValue: cdBytes, | ||
}, | ||
StartValue: startedCdBytes, | ||
} | ||
ret.GetBaseRunner().QBFTController.Height = qbft.Height(testingutils.TestingDutySlotV(version)) | ||
comparable.SetMessages( | ||
ret.GetBaseRunner().State.RunningInstance, | ||
testingutils.ExpectedSSVDecidingMsgsV(cd, ks, types.BNRoleProposer)[3:10], | ||
) | ||
ret.GetBaseRunner().QBFTController.StoredInstances = append(ret.GetBaseRunner().QBFTController.StoredInstances, ret.GetBaseRunner().State.RunningInstance) | ||
return ret | ||
}(), | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
ssv/spectest/tests/runner/duties/proposer/normal_accepts_blinded_block.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,53 @@ | ||
package proposer | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/attestantio/go-eth2-client/spec" | ||
|
||
"github.com/bloxapp/ssv-spec/ssv/spectest/tests" | ||
"github.com/bloxapp/ssv-spec/types" | ||
"github.com/bloxapp/ssv-spec/types/testingutils" | ||
) | ||
|
||
// NormalProposerAcceptsBlindedBlock tests a full happy flow for a proposer runner that produces normal blocks but receives as proposal a blinded block | ||
func NormalProposerAcceptsBlindedBlock() tests.SpecTest { | ||
ks := testingutils.Testing4SharesSet() | ||
|
||
multiSpecTest := &tests.MultiMsgProcessingSpecTest{ | ||
Name: "normal proposer accepts blinded block proposal", | ||
Tests: []*tests.MsgProcessingSpecTest{}, | ||
} | ||
|
||
// proposerReceivingBlindedBlockV creates a test specification for versioned normal proposer receiving blinded block as proposal. | ||
proposerReceivingBlindedBlockV := func(version spec.DataVersion) *tests.MsgProcessingSpecTest { | ||
return &tests.MsgProcessingSpecTest{ | ||
Name: fmt.Sprintf("normal proposer accepts blinded block proposal (%s)", version.String()), | ||
Runner: testingutils.ProposerRunner(ks), | ||
Duty: testingutils.TestingProposerDutyV(version), | ||
Messages: append( | ||
testingutils.SSVDecidingMsgsV(testingutils.TestProposerBlindedBlockConsensusDataV(version), ks, types.BNRoleProposer), // consensus | ||
[]*types.SSVMessage{ // post consensus | ||
testingutils.SSVMsgProposer(nil, testingutils.PostConsensusProposerMsgV(ks.Shares[1], 1, version)), | ||
testingutils.SSVMsgProposer(nil, testingutils.PostConsensusProposerMsgV(ks.Shares[2], 2, version)), | ||
testingutils.SSVMsgProposer(nil, testingutils.PostConsensusProposerMsgV(ks.Shares[3], 3, version)), | ||
}..., | ||
), | ||
PostDutyRunnerStateRoot: fullHappyFlowProposerReceivingBlindedBlockSC(version).Root(), | ||
PostDutyRunnerState: fullHappyFlowProposerReceivingBlindedBlockSC(version).ExpectedState, | ||
OutputMessages: []*types.SignedPartialSignatureMessage{ | ||
testingutils.PreConsensusRandaoMsgV(ks.Shares[1], 1, version), | ||
testingutils.PostConsensusProposerMsgV(ks.Shares[1], 1, version), | ||
}, | ||
BeaconBroadcastedRoots: []string{ | ||
testingutils.GetSSZRootNoError(testingutils.TestingSignedBeaconBlockV(ks, version)), | ||
}, | ||
} | ||
} | ||
|
||
for _, v := range testingutils.SupportedBlockVersions { | ||
multiSpecTest.Tests = append(multiSpecTest.Tests, []*tests.MsgProcessingSpecTest{proposerReceivingBlindedBlockV(v)}...) | ||
} | ||
|
||
return multiSpecTest | ||
} |
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
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