-
Notifications
You must be signed in to change notification settings - Fork 138
/
Copy pathsteps_democracy.go
297 lines (295 loc) · 8.16 KB
/
steps_democracy.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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
package main
const consumerRewardDenom = "ibc/3C3D7B3BE4ECC85A0E5B52A3AEC3B7DFC2AA9CA47C37821E57020D6807043BE9"
func stepsDemocracy(consumerName string) []Step {
return []Step{
{
Action: registerRepresentativeAction{
Chain: ChainID(consumerName),
Representatives: []ValidatorID{ValidatorID("alice"), ValidatorID("bob")},
Stakes: []uint{100000000, 40000000},
},
State: State{
ChainID(consumerName): ChainState{
RepresentativePowers: &map[ValidatorID]uint{
ValidatorID("alice"): 100000000,
ValidatorID("bob"): 40000000,
},
Rewards: &Rewards{
IsRewarded: map[ValidatorID]bool{
ValidatorID("alice"): true,
ValidatorID("bob"): true,
ValidatorID("carol"): false,
},
IsIncrementalReward: true,
IsNativeDenom: true,
},
},
},
},
{
Action: delegateTokensAction{
Chain: ChainID(consumerName),
From: ValidatorID("carol"),
To: ValidatorID("alice"),
Amount: 500000,
},
State: State{
ChainID(consumerName): ChainState{
// Check that delegators on gov-consumer chain can change representative powers
RepresentativePowers: &map[ValidatorID]uint{
ValidatorID("alice"): 100500000,
ValidatorID("bob"): 40000000,
},
// Check that delegating on gov-consumer does not change validator powers
ValPowers: &map[ValidatorID]uint{
ValidatorID("alice"): 511,
ValidatorID("bob"): 500,
ValidatorID("carol"): 500,
},
// Check that tokens are minted and distributed to representatives and their delegators
Rewards: &Rewards{
IsRewarded: map[ValidatorID]bool{
ValidatorID("alice"): true,
ValidatorID("bob"): true,
ValidatorID("carol"): true,
},
IsIncrementalReward: true,
IsNativeDenom: true,
},
},
},
},
{
// whitelisted legacy proposal can only handle ibctransfer.SendEnabled/ReceiveEnabled
Action: submitParamChangeLegacyProposalAction{
Chain: ChainID(consumerName),
From: ValidatorID("alice"),
Deposit: 10000001,
Subspace: "transfer",
Key: "SendEnabled",
Value: true,
},
State: State{
ChainID(consumerName): ChainState{
ValBalances: &map[ValidatorID]uint{
ValidatorID("alice"): 9889999998,
ValidatorID("bob"): 9960000001,
},
Proposals: &map[uint]Proposal{
1: ParamsProposal{
Deposit: 10000001,
Status: "PROPOSAL_STATUS_VOTING_PERIOD",
Subspace: "transfer",
Key: "SendEnabled",
Value: "true",
},
},
},
},
},
{
// Have accounts vote on something on the gov-consumer chain
Action: voteGovProposalAction{
Chain: ChainID(consumerName),
From: []ValidatorID{ValidatorID("alice"), ValidatorID("bob")},
Vote: []string{"yes", "no"},
PropNumber: 1,
},
State: State{
ChainID(consumerName): ChainState{
ValBalances: &map[ValidatorID]uint{
ValidatorID("alice"): 9889999998,
ValidatorID("bob"): 9960000001,
},
// Check that the parameter is changed on gov-consumer chain
Params: &([]Param{{Subspace: "transfer", Key: "SendEnabled", Value: "true"}}),
},
},
},
{
Action: relayRewardPacketsToProviderAction{
ConsumerChain: ChainID(consumerName),
ProviderChain: ChainID("provi"),
Port: "transfer",
Channel: 1,
},
State: State{
ChainID("provi"): ChainState{
// Check that tokens are not distributed before the denom has been registered
Rewards: &Rewards{
IsRewarded: map[ValidatorID]bool{
ValidatorID("alice"): false,
ValidatorID("bob"): false,
ValidatorID("carol"): false,
},
IsIncrementalReward: false,
IsNativeDenom: false,
},
// Check that the denom is not registered on provider chain
RegisteredConsumerRewardDenoms: &[]string{},
},
},
},
{
Action: submitChangeRewardDenomsProposalAction{
Denom: consumerRewardDenom,
Deposit: 10000001,
From: ValidatorID("bob"),
},
State: State{
ChainID("provi"): ChainState{
// Denom not yet registered, gov prop needs to pass first
RegisteredConsumerRewardDenoms: &[]string{},
},
},
},
{
Action: voteGovProposalAction{
Chain: ChainID("provi"),
From: []ValidatorID{ValidatorID("alice"), ValidatorID("bob"), ValidatorID("carol")},
Vote: []string{"yes", "yes", "yes"},
PropNumber: 2,
},
State: State{
ChainID("provi"): ChainState{
// Check that the denom is registered on provider chain
RegisteredConsumerRewardDenoms: &[]string{consumerRewardDenom},
},
},
},
{
Action: relayRewardPacketsToProviderAction{
ConsumerChain: ChainID(consumerName),
ProviderChain: ChainID("provi"),
Port: "transfer",
Channel: 1,
},
State: State{
ChainID("provi"): ChainState{
// Check that tokens are minted and sent to provider chain and distributed to validators and their delegators on provider chain
Rewards: &Rewards{
IsRewarded: map[ValidatorID]bool{
ValidatorID("alice"): true,
ValidatorID("bob"): true,
ValidatorID("carol"): true,
},
IsIncrementalReward: false,
IsNativeDenom: false,
},
},
},
},
{
Action: downtimeSlashAction{
Chain: ChainID(consumerName),
Validator: ValidatorID("bob"),
},
State: State{
// validator should be slashed on consumer, powers not affected on either chain yet
ChainID("provi"): ChainState{
ValPowers: &map[ValidatorID]uint{
ValidatorID("alice"): 511,
ValidatorID("bob"): 500,
ValidatorID("carol"): 500,
},
},
ChainID(consumerName): ChainState{
ValPowers: &map[ValidatorID]uint{
ValidatorID("alice"): 511,
ValidatorID("bob"): 500,
ValidatorID("carol"): 500,
},
},
},
},
{
Action: relayPacketsAction{
ChainA: ChainID("provi"),
ChainB: ChainID(consumerName),
Port: "provider",
Channel: 0,
},
State: State{
ChainID("provi"): ChainState{
ValPowers: &map[ValidatorID]uint{
ValidatorID("alice"): 511,
// Downtime jailing and corresponding voting power change are processed by provider
ValidatorID("bob"): 0,
ValidatorID("carol"): 500,
},
},
ChainID(consumerName): ChainState{
ValPowers: &map[ValidatorID]uint{
ValidatorID("alice"): 511,
ValidatorID("bob"): 500,
ValidatorID("carol"): 500,
},
},
},
},
// A block is incremented each action, hence why VSC is committed on provider,
// and can now be relayed as packet to consumer
{
Action: relayPacketsAction{
ChainA: ChainID("provi"),
ChainB: ChainID(consumerName),
Port: "provider",
Channel: 0,
},
State: State{
ChainID(consumerName): ChainState{
ValPowers: &map[ValidatorID]uint{
ValidatorID("alice"): 511,
// VSC now seen on consumer
ValidatorID("bob"): 0,
ValidatorID("carol"): 500,
},
},
},
},
{
Action: unjailValidatorAction{
Provider: ChainID("provi"),
Validator: ValidatorID("bob"),
},
State: State{
ChainID("provi"): ChainState{
ValPowers: &map[ValidatorID]uint{
ValidatorID("alice"): 511,
ValidatorID("bob"): 500,
ValidatorID("carol"): 500,
},
},
ChainID(consumerName): ChainState{
ValPowers: &map[ValidatorID]uint{
ValidatorID("alice"): 511,
ValidatorID("bob"): 0,
ValidatorID("carol"): 500,
},
},
},
},
{
Action: relayPacketsAction{
ChainA: ChainID("provi"),
ChainB: ChainID(consumerName),
Port: "provider",
Channel: 0,
},
State: State{
ChainID(consumerName): ChainState{
ValPowers: &map[ValidatorID]uint{
ValidatorID("alice"): 511,
ValidatorID("bob"): 500,
ValidatorID("carol"): 500,
},
// Check that slashing on the gov-consumer chain does not result in slashing for the representatives or their delegators
RepresentativePowers: &map[ValidatorID]uint{
ValidatorID("alice"): 100500000,
ValidatorID("bob"): 40000000,
},
},
},
},
}
}