-
Notifications
You must be signed in to change notification settings - Fork 21
/
no_running_duty.go
114 lines (105 loc) · 5.5 KB
/
no_running_duty.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
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"
)
// NoRunningDuty tests a valid partial pre consensus msg before duty starts
func NoRunningDuty() tests.SpecTest {
ks := testingutils.Testing4SharesSet()
multiSpecTest := &tests.MultiMsgProcessingSpecTest{
Name: "pre consensus no running duty",
Tests: []*tests.MsgProcessingSpecTest{
{
Name: "sync committee contribution",
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))),
},
PostDutyRunnerStateRoot: noRunningDutySyncCommitteeContributionSC().Root(),
PostDutyRunnerState: noRunningDutySyncCommitteeContributionSC().ExpectedState,
OutputMessages: []*types.SignedPartialSignatureMessage{},
DontStartDuty: true,
ExpectedError: "failed processing sync committee selection proof message: invalid pre-consensus message: no running duty",
},
{
Name: "aggregator",
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))),
},
PostDutyRunnerStateRoot: noRunningDutyAggregatorSC().Root(),
PostDutyRunnerState: noRunningDutyAggregatorSC().ExpectedState,
OutputMessages: []*types.SignedPartialSignatureMessage{},
DontStartDuty: true,
ExpectedError: "failed processing selection proof message: invalid pre-consensus message: no running 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))),
},
PostDutyRunnerStateRoot: noRunningDutyValidatorRegistrationSC().Root(),
PostDutyRunnerState: noRunningDutyValidatorRegistrationSC().ExpectedState,
OutputMessages: []*types.SignedPartialSignatureMessage{},
DontStartDuty: true,
ExpectedError: "failed processing validator registration message: invalid pre-consensus message: no running duty",
},
{
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))),
},
PostDutyRunnerStateRoot: noRunningDutyVoluntaryExitSC().Root(),
PostDutyRunnerState: noRunningDutyVoluntaryExitSC().ExpectedState,
OutputMessages: []*types.SignedPartialSignatureMessage{},
DontStartDuty: true,
ExpectedError: "failed processing voluntary exit message: invalid pre-consensus message: no running duty",
},
},
}
// proposerV creates a test specification for versioned proposer.
proposerV := func(version spec.DataVersion) *tests.MsgProcessingSpecTest {
return &tests.MsgProcessingSpecTest{
Name: fmt.Sprintf("proposer (%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))),
},
PostDutyRunnerStateRoot: noRunningDutyProposerSC(version).Root(),
PostDutyRunnerState: noRunningDutyProposerSC(version).ExpectedState,
OutputMessages: []*types.SignedPartialSignatureMessage{},
DontStartDuty: true,
ExpectedError: "failed processing randao message: invalid pre-consensus message: no running 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("proposer 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))),
},
PostDutyRunnerStateRoot: noRunningDutyBlindedProposerSC(version).Root(),
PostDutyRunnerState: noRunningDutyBlindedProposerSC(version).ExpectedState,
OutputMessages: []*types.SignedPartialSignatureMessage{},
DontStartDuty: true,
ExpectedError: "failed processing randao message: invalid pre-consensus message: no running duty",
}
}
for _, v := range testingutils.SupportedBlockVersions {
multiSpecTest.Tests = append(multiSpecTest.Tests, []*tests.MsgProcessingSpecTest{proposerV(v), proposerBlindedV(v)}...)
}
return multiSpecTest
}