-
Notifications
You must be signed in to change notification settings - Fork 20
/
inconsisten_roots.go
117 lines (108 loc) · 5.45 KB
/
inconsisten_roots.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
package pre_consensus_justifications
import (
"github.com/attestantio/go-eth2-client/spec"
"github.com/bloxapp/ssv-spec/qbft"
"github.com/bloxapp/ssv-spec/ssv/spectest/tests"
"github.com/bloxapp/ssv-spec/types"
"github.com/bloxapp/ssv-spec/types/testingutils"
)
// InconsistentRoots tests an invalid pre-consensus justification due to inconsistent roots
func InconsistentRoots() tests.SpecTest {
ks := testingutils.Testing4SharesSet()
// changeRootsAndPrepareMsg will change signing roots
changeRootsAndPrepareMsg := func(obj *types.ConsensusData, id []byte) *qbft.SignedMessage {
if len(obj.PreConsensusJustifications) > 0 {
obj.PreConsensusJustifications[1].Message.Messages[0].SigningRoot = [32]byte{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
}
fullData, _ := obj.Encode()
root, _ := qbft.HashDataRoot(fullData)
msg := &qbft.Message{
MsgType: qbft.ProposalMsgType,
Height: 1,
Round: qbft.FirstRound,
Identifier: id,
Root: root,
}
signed := testingutils.SignQBFTMsg(ks.Shares[1], 1, msg)
signed.FullData = fullData
return signed
}
expectedErr := "failed processing consensus message: invalid pre-consensus justification: inconsistent roots"
return &tests.MultiMsgProcessingSpecTest{
Name: "pre consensus inconsistent roots",
Tests: []*tests.MsgProcessingSpecTest{
{
Name: "sync committee aggregator selection proof",
Runner: decideFirstHeight(testingutils.SyncCommitteeContributionRunner(ks)),
Duty: &testingutils.TestingSyncCommitteeContributionDuty,
Messages: []*types.SignedSSVMessage{
testingutils.SignedSSVMessageF(ks, testingutils.SSVMsgSyncCommitteeContribution(changeRootsAndPrepareMsg(testingutils.TestContributionProofWithJustificationsConsensusData(ks), testingutils.SyncCommitteeContributionMsgID), nil)),
},
PostDutyRunnerStateRoot: "2619aeecde47fe0efc36aa98fbb2df9834d9eee77f62abe0d10532dbd5215790",
OutputMessages: []*types.SignedPartialSignatureMessage{
testingutils.PreConsensusContributionProofMsg(ks.Shares[1], ks.Shares[1], 1, 1), // broadcasts when starting a new duty
},
ExpectedError: expectedErr,
},
{
Name: "aggregator selection proof",
Runner: decideFirstHeight(testingutils.AggregatorRunner(ks)),
Duty: &testingutils.TestingAggregatorDuty,
Messages: []*types.SignedSSVMessage{
testingutils.SignedSSVMessageF(ks, testingutils.SSVMsgAggregator(changeRootsAndPrepareMsg(testingutils.TestSelectionProofWithJustificationsConsensusData(ks), testingutils.AggregatorMsgID), nil)),
},
PostDutyRunnerStateRoot: "db1b416873d19be76cddc92ded0d442ba0e642514973b5dfec45f587c6ffde15",
OutputMessages: []*types.SignedPartialSignatureMessage{
testingutils.PreConsensusSelectionProofMsg(ks.Shares[1], ks.Shares[1], 1, 1), // broadcasts when starting a new duty
},
ExpectedError: expectedErr,
},
{
Name: "randao",
Runner: decideFirstHeight(testingutils.ProposerRunner(ks)),
Duty: testingutils.TestingProposerDutyV(spec.DataVersionDeneb),
Messages: []*types.SignedSSVMessage{
testingutils.SignedSSVMessageF(ks, testingutils.SSVMsgProposer(changeRootsAndPrepareMsg(testingutils.TestProposerWithJustificationsConsensusDataV(ks, spec.DataVersionDeneb), testingutils.ProposerMsgID), nil)),
},
PostDutyRunnerStateRoot: "2754fc7ced14fb15f3f18556bb6b837620287cbbfbf908abafa5a0533fc4bc5f",
OutputMessages: []*types.SignedPartialSignatureMessage{
testingutils.PreConsensusRandaoMsgV(ks.Shares[1], 1, spec.DataVersionDeneb), // broadcasts when starting a new duty
},
ExpectedError: expectedErr,
},
{
Name: "randao (blinded block)",
Runner: decideFirstHeight(testingutils.ProposerBlindedBlockRunner(ks)),
Duty: testingutils.TestingProposerDutyV(spec.DataVersionDeneb),
Messages: []*types.SignedSSVMessage{
testingutils.SignedSSVMessageF(ks, testingutils.SSVMsgProposer(changeRootsAndPrepareMsg(testingutils.TestProposerBlindedWithJustificationsConsensusDataV(ks, spec.DataVersionDeneb), testingutils.ProposerMsgID), nil)),
},
PostDutyRunnerStateRoot: "6bd59da9f817b8e40112e58231e36738b9d021db4416c9eeec1dd0236a5362e2",
OutputMessages: []*types.SignedPartialSignatureMessage{
testingutils.PreConsensusRandaoMsgV(ks.Shares[1], 1, spec.DataVersionDeneb), // broadcasts when starting a new duty
},
ExpectedError: expectedErr,
},
{
Name: "attester",
Runner: decideFirstHeight(testingutils.AttesterRunner(ks)),
Duty: &testingutils.TestingAttesterDuty,
Messages: []*types.SignedSSVMessage{
testingutils.SignedSSVMessageF(ks, testingutils.SSVMsgAttester(changeRootsAndPrepareMsg(testingutils.TestAttesterConsensusData, testingutils.AttesterMsgID), nil)),
},
PostDutyRunnerStateRoot: "c913d1b6e4150231615ad2475a26b03403cc40fc7dd90c011c1c24a7bb39ae1a",
OutputMessages: []*types.SignedPartialSignatureMessage{},
},
{
Name: "sync committee",
Runner: decideFirstHeight(testingutils.SyncCommitteeRunner(ks)),
Duty: &testingutils.TestingSyncCommitteeDuty,
Messages: []*types.SignedSSVMessage{
testingutils.SignedSSVMessageF(ks, testingutils.SSVMsgSyncCommittee(changeRootsAndPrepareMsg(testingutils.TestSyncCommitteeConsensusData, testingutils.SyncCommitteeMsgID), nil)),
},
PostDutyRunnerStateRoot: "4dbe7550c9fe66953ae2f5066463e8d1288fc37a4cc031b58d4b3e1a87220dc0",
OutputMessages: []*types.SignedPartialSignatureMessage{},
},
},
}
}