@@ -51,7 +51,7 @@ func (app *TutorialApp) ExportAppStateAndValidators(
51
51
}
52
52
53
53
// prepare for fresh start at zero height
54
- // NOTE zero height genesis is a temporary feature, which will be deprecated in favour of export at a block height
54
+ // NOTE zero height genesis is a temporary feature, which will be deprecated in favor of export at a block height
55
55
func (app * TutorialApp ) prepForZeroHeightGenesis (ctx sdk.Context , jailAllowedAddrs []string ) {
56
56
applyAllowedAddrs := false
57
57
@@ -73,15 +73,17 @@ func (app *TutorialApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAdd
73
73
/* Handle fee distribution state. */
74
74
75
75
// withdraw all validator commission
76
- app .StakingKeeper .IterateValidators (ctx , func (_ int64 , val stakingtypes.ValidatorI ) (stop bool ) {
76
+ if err := app .StakingKeeper .IterateValidators (ctx , func (_ int64 , val stakingtypes.ValidatorI ) (stop bool ) {
77
77
valBz , err := app .StakingKeeper .ValidatorAddressCodec ().StringToBytes (val .GetOperator ())
78
78
if err != nil {
79
79
panic (err )
80
80
}
81
81
82
82
_ , _ = app .DistrKeeper .WithdrawValidatorCommission (ctx , valBz )
83
83
return false
84
- })
84
+ }); err != nil {
85
+ panic (err )
86
+ }
85
87
86
88
// withdraw all delegator rewards
87
89
dels , err := app .StakingKeeper .GetAllDelegations (ctx )
@@ -114,7 +116,7 @@ func (app *TutorialApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAdd
114
116
ctx = ctx .WithBlockHeight (0 )
115
117
116
118
// reinitialize all validators
117
- app .StakingKeeper .IterateValidators (ctx , func (_ int64 , val stakingtypes.ValidatorI ) (stop bool ) {
119
+ if err := app .StakingKeeper .IterateValidators (ctx , func (_ int64 , val stakingtypes.ValidatorI ) (stop bool ) {
118
120
valBz , err := app .StakingKeeper .ValidatorAddressCodec ().StringToBytes (val .GetOperator ())
119
121
if err != nil {
120
122
panic (err )
@@ -140,7 +142,9 @@ func (app *TutorialApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAdd
140
142
panic (err )
141
143
}
142
144
return false
143
- })
145
+ }); err != nil {
146
+ panic (err )
147
+ }
144
148
145
149
// reinitialize all delegations
146
150
for _ , del := range dels {
@@ -171,22 +175,30 @@ func (app *TutorialApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAdd
171
175
/* Handle staking state. */
172
176
173
177
// iterate through redelegations, reset creation height
174
- app .StakingKeeper .IterateRedelegations (ctx , func (_ int64 , red stakingtypes.Redelegation ) (stop bool ) {
178
+ if err := app .StakingKeeper .IterateRedelegations (ctx , func (_ int64 , red stakingtypes.Redelegation ) (stop bool ) {
175
179
for i := range red .Entries {
176
180
red .Entries [i ].CreationHeight = 0
177
181
}
178
- app .StakingKeeper .SetRedelegation (ctx , red )
182
+ if err := app .StakingKeeper .SetRedelegation (ctx , red ); err != nil {
183
+ panic (err )
184
+ }
179
185
return false
180
- })
186
+ }); err != nil {
187
+ panic (err )
188
+ }
181
189
182
190
// iterate through unbonding delegations, reset creation height
183
- app .StakingKeeper .IterateUnbondingDelegations (ctx , func (_ int64 , ubd stakingtypes.UnbondingDelegation ) (stop bool ) {
191
+ if err := app .StakingKeeper .IterateUnbondingDelegations (ctx , func (_ int64 , ubd stakingtypes.UnbondingDelegation ) (stop bool ) {
184
192
for i := range ubd .Entries {
185
193
ubd .Entries [i ].CreationHeight = 0
186
194
}
187
- app .StakingKeeper .SetUnbondingDelegation (ctx , ubd )
195
+ if err := app .StakingKeeper .SetUnbondingDelegation (ctx , ubd ); err != nil {
196
+ panic (err )
197
+ }
188
198
return false
189
- })
199
+ }); err != nil {
200
+ panic (err )
201
+ }
190
202
191
203
// Iterate through validators by power descending, reset bond heights, and
192
204
// update bond intra-tx counters.
@@ -208,7 +220,9 @@ func (app *TutorialApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAdd
208
220
validator .Jailed = true
209
221
}
210
222
211
- app .StakingKeeper .SetValidator (ctx , validator )
223
+ if err := app .StakingKeeper .SetValidator (ctx , validator ); err != nil {
224
+ panic (err )
225
+ }
212
226
counter ++
213
227
}
214
228
0 commit comments