-
Notifications
You must be signed in to change notification settings - Fork 22
/
quorum.go
131 lines (123 loc) · 7.25 KB
/
quorum.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
package preconsensus
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"
)
// Quorum tests a quorum of valid SignedPartialSignatureMessage
func Quorum() tests.SpecTest {
ks := testingutils.Testing4SharesSet()
multiSpecTest := &tests.MultiMsgProcessingSpecTest{
Name: "pre consensus quorum",
Tests: []*tests.MsgProcessingSpecTest{
{
Name: "sync committee aggregator selection proof",
Runner: testingutils.SyncCommitteeContributionRunner(ks),
Duty: &testingutils.TestingSyncCommitteeContributionDuty,
Messages: []*types.SignedSSVMessage{
testingutils.SignedSSVMessageF(ks, testingutils.SSVMsgSyncCommitteeContribution(nil, testingutils.PreConsensusContributionProofMsg(ks.Shares[1], ks.Shares[1], 1, 1))),
testingutils.SignedSSVMessageF(ks, testingutils.SSVMsgSyncCommitteeContribution(nil, testingutils.PreConsensusContributionProofMsg(ks.Shares[2], ks.Shares[2], 2, 2))),
testingutils.SignedSSVMessageF(ks, testingutils.SSVMsgSyncCommitteeContribution(nil, testingutils.PreConsensusContributionProofMsg(ks.Shares[3], ks.Shares[3], 3, 3))),
},
PostDutyRunnerStateRoot: quorumSyncCommitteeContributionSC().Root(),
PostDutyRunnerState: quorumSyncCommitteeContributionSC().ExpectedState,
OutputMessages: []*types.SignedPartialSignatureMessage{
testingutils.PreConsensusContributionProofMsg(ks.Shares[1], ks.Shares[1], 1, 1), // broadcasts when starting a new duty
},
},
{
Name: "aggregator selection proof",
Runner: testingutils.AggregatorRunner(ks),
Duty: &testingutils.TestingAggregatorDuty,
Messages: []*types.SignedSSVMessage{
testingutils.SignedSSVMessageF(ks, testingutils.SSVMsgAggregator(nil, testingutils.PreConsensusSelectionProofMsg(ks.Shares[1], ks.Shares[1], 1, 1))),
testingutils.SignedSSVMessageF(ks, testingutils.SSVMsgAggregator(nil, testingutils.PreConsensusSelectionProofMsg(ks.Shares[2], ks.Shares[2], 2, 2))),
testingutils.SignedSSVMessageF(ks, testingutils.SSVMsgAggregator(nil, testingutils.PreConsensusSelectionProofMsg(ks.Shares[3], ks.Shares[3], 3, 3))),
},
PostDutyRunnerStateRoot: quorumAggregatorSC().Root(),
PostDutyRunnerState: quorumAggregatorSC().ExpectedState,
OutputMessages: []*types.SignedPartialSignatureMessage{
testingutils.PreConsensusSelectionProofMsg(ks.Shares[1], ks.Shares[1], 1, 1), // broadcasts when starting a new duty
},
},
{
Name: "validator registration",
Runner: testingutils.ValidatorRegistrationRunner(ks),
Duty: &testingutils.TestingValidatorRegistrationDuty,
Messages: []*types.SignedSSVMessage{
testingutils.SignedSSVMessageF(ks, testingutils.SSVMsgValidatorRegistration(nil, testingutils.PreConsensusValidatorRegistrationMsg(ks.Shares[1], 1))),
testingutils.SignedSSVMessageF(ks, testingutils.SSVMsgValidatorRegistration(nil, testingutils.PreConsensusValidatorRegistrationMsg(ks.Shares[2], 2))),
testingutils.SignedSSVMessageF(ks, testingutils.SSVMsgValidatorRegistration(nil, testingutils.PreConsensusValidatorRegistrationMsg(ks.Shares[3], 3))),
},
PostDutyRunnerStateRoot: quorumValidatorRegistrationSC().Root(),
PostDutyRunnerState: quorumValidatorRegistrationSC().ExpectedState,
OutputMessages: []*types.SignedPartialSignatureMessage{
testingutils.PreConsensusValidatorRegistrationMsg(ks.Shares[1], 1), // broadcasts when starting a new duty
},
BeaconBroadcastedRoots: []string{
testingutils.GetSSZRootNoError(testingutils.TestingValidatorRegistration),
},
},
{
Name: "voluntary exit",
Runner: testingutils.VoluntaryExitRunner(ks),
Duty: &testingutils.TestingVoluntaryExitDuty,
Messages: []*types.SignedSSVMessage{
testingutils.SignedSSVMessageF(ks, testingutils.SSVMsgVoluntaryExit(nil, testingutils.PreConsensusVoluntaryExitMsg(ks.Shares[1], 1))),
testingutils.SignedSSVMessageF(ks, testingutils.SSVMsgVoluntaryExit(nil, testingutils.PreConsensusVoluntaryExitMsg(ks.Shares[2], 2))),
testingutils.SignedSSVMessageF(ks, testingutils.SSVMsgVoluntaryExit(nil, testingutils.PreConsensusVoluntaryExitMsg(ks.Shares[3], 3))),
},
PostDutyRunnerStateRoot: quorumVoluntaryExitSC().Root(),
PostDutyRunnerState: quorumVoluntaryExitSC().ExpectedState,
OutputMessages: []*types.SignedPartialSignatureMessage{
testingutils.PreConsensusVoluntaryExitMsg(ks.Shares[1], 1), // broadcasts when starting a new duty
},
BeaconBroadcastedRoots: []string{
testingutils.GetSSZRootNoError(testingutils.TestingSignedVoluntaryExit(ks)),
},
},
},
}
// proposerV creates a test specification for versioned proposer.
proposerV := func(version spec.DataVersion) *tests.MsgProcessingSpecTest {
return &tests.MsgProcessingSpecTest{
Name: fmt.Sprintf("randao (%s)", version.String()),
Runner: testingutils.ProposerRunner(ks),
Duty: testingutils.TestingProposerDutyV(version),
Messages: []*types.SignedSSVMessage{
testingutils.SignedSSVMessageF(ks, testingutils.SSVMsgProposer(nil, testingutils.PreConsensusRandaoDifferentSignerMsgV(ks.Shares[1], ks.Shares[1], 1, 1, version))),
testingutils.SignedSSVMessageF(ks, testingutils.SSVMsgProposer(nil, testingutils.PreConsensusRandaoDifferentSignerMsgV(ks.Shares[2], ks.Shares[2], 2, 2, version))),
testingutils.SignedSSVMessageF(ks, testingutils.SSVMsgProposer(nil, testingutils.PreConsensusRandaoDifferentSignerMsgV(ks.Shares[3], ks.Shares[3], 3, 3, version))),
},
PostDutyRunnerStateRoot: quorumProposerSC(version).Root(),
PostDutyRunnerState: quorumProposerSC(version).ExpectedState,
OutputMessages: []*types.SignedPartialSignatureMessage{
testingutils.PreConsensusRandaoMsgV(ks.Shares[1], 1, version), // broadcasts when starting a new duty
},
}
}
// proposerBlindedV creates a test specification for versioned proposer with blinded block.
proposerBlindedV := func(version spec.DataVersion) *tests.MsgProcessingSpecTest {
return &tests.MsgProcessingSpecTest{
Name: fmt.Sprintf("randao blinded block (%s)", version.String()),
Runner: testingutils.ProposerBlindedBlockRunner(ks),
Duty: testingutils.TestingProposerDutyV(version),
Messages: []*types.SignedSSVMessage{
testingutils.SignedSSVMessageF(ks, testingutils.SSVMsgProposer(nil, testingutils.PreConsensusRandaoDifferentSignerMsgV(ks.Shares[1], ks.Shares[1], 1, 1, version))),
testingutils.SignedSSVMessageF(ks, testingutils.SSVMsgProposer(nil, testingutils.PreConsensusRandaoDifferentSignerMsgV(ks.Shares[2], ks.Shares[2], 2, 2, version))),
testingutils.SignedSSVMessageF(ks, testingutils.SSVMsgProposer(nil, testingutils.PreConsensusRandaoDifferentSignerMsgV(ks.Shares[3], ks.Shares[3], 3, 3, version))),
},
PostDutyRunnerStateRoot: quorumBlindedProposerSC(version).Root(),
PostDutyRunnerState: quorumBlindedProposerSC(version).ExpectedState,
OutputMessages: []*types.SignedPartialSignatureMessage{
testingutils.PreConsensusRandaoMsgV(ks.Shares[1], 1, version), // broadcasts when starting a new duty
},
}
}
for _, v := range testingutils.SupportedBlockVersions {
multiSpecTest.Tests = append(multiSpecTest.Tests, []*tests.MsgProcessingSpecTest{proposerV(v), proposerBlindedV(v)}...)
}
return multiSpecTest
}