-
Notifications
You must be signed in to change notification settings - Fork 110
/
steps_submit_equivocation_proposal.go
149 lines (145 loc) · 4.01 KB
/
steps_submit_equivocation_proposal.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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
package main
import "time"
// submits an invalid equivocation proposal which should be rejected
func stepsRejectEquivocationProposal(consumerName string, propNumber uint) []Step {
return []Step{
{
// bob submits a proposal to slash himself
action: submitEquivocationProposalAction{
chain: chainID("consu"),
from: validatorID("bob"),
deposit: 10000001,
height: 10,
time: time.Now(),
power: 500,
validator: validatorID("bob"),
},
state: State{
chainID("provi"): ChainState{
ValPowers: &map[validatorID]uint{
validatorID("alice"): 509,
validatorID("bob"): 500,
validatorID("carol"): 495,
},
ValBalances: &map[validatorID]uint{
validatorID("bob"): 9500000000,
},
Proposals: &map[uint]Proposal{
// proposal does not exist
propNumber: TextProposal{},
},
},
chainID(consumerName): ChainState{
ValPowers: &map[validatorID]uint{
validatorID("alice"): 509,
validatorID("bob"): 500,
validatorID("carol"): 495,
},
},
},
},
}
}
// submits an equivocation proposal, votes on it, and tomstones the equivocating validator
func stepsSubmitEquivocationProposal(consumerName string, propNumber uint) []Step {
s := []Step{
{
// bob submits a proposal to slash himself
action: submitEquivocationProposalAction{
chain: chainID("consu"),
from: validatorID("bob"),
deposit: 10000001,
height: 10,
time: time.Now(), // not sure what time in equivocations means
power: 500,
validator: validatorID("bob"),
},
state: State{
chainID("provi"): ChainState{
ValPowers: &map[validatorID]uint{
validatorID("alice"): 509,
validatorID("bob"): 500,
validatorID("carol"): 0,
},
ValBalances: &map[validatorID]uint{
validatorID("bob"): 9489999999,
},
Proposals: &map[uint]Proposal{
propNumber: EquivocationProposal{
Deposit: 10000001,
Status: "PROPOSAL_STATUS_VOTING_PERIOD",
ConsensusAddress: "cosmosvalcons1nx7n5uh0ztxsynn4sje6eyq2ud6rc6klc96w39",
Power: 500,
Height: 10,
},
},
},
chainID(consumerName): ChainState{
ValPowers: &map[validatorID]uint{
validatorID("alice"): 509,
validatorID("bob"): 500,
validatorID("carol"): 0,
},
},
},
},
{
action: voteGovProposalAction{
chain: chainID("provi"),
from: []validatorID{validatorID("alice"), validatorID("bob"), validatorID("carol")},
vote: []string{"yes", "yes", "yes"},
propNumber: propNumber,
},
state: State{
chainID("provi"): ChainState{
ValPowers: &map[validatorID]uint{
validatorID("alice"): 509,
validatorID("bob"): 0, // bob is tombstoned after proposal passes
validatorID("carol"): 0,
},
Proposals: &map[uint]Proposal{
propNumber: EquivocationProposal{
Deposit: 10000001,
Status: "PROPOSAL_STATUS_PASSED",
ConsensusAddress: "cosmosvalcons1nx7n5uh0ztxsynn4sje6eyq2ud6rc6klc96w39",
Power: 500,
Height: 10,
},
},
},
chainID(consumerName): ChainState{
ValPowers: &map[validatorID]uint{
validatorID("alice"): 509,
validatorID("bob"): 500, // slash not reflected in consumer chain
validatorID("carol"): 0,
},
},
},
},
{
// relay power change to consumer1
action: relayPacketsAction{
chain: chainID("provi"),
port: "provider",
channel: 0,
},
state: State{
chainID("provi"): ChainState{
ValPowers: &map[validatorID]uint{
validatorID("alice"): 509,
validatorID("bob"): 0,
validatorID("carol"): 0,
},
},
chainID(consumerName): ChainState{
ValPowers: &map[validatorID]uint{
validatorID("alice"): 509,
validatorID("bob"): 0, // slash relayed to consumer chain
validatorID("carol"): 0,
},
},
},
},
}
return s
}