@@ -2,6 +2,7 @@ package app
2
2
3
3
import (
4
4
"encoding/json"
5
+ "log"
5
6
6
7
abci "github.com/tendermint/tendermint/abci/types"
7
8
tmtypes "github.com/tendermint/tendermint/types"
@@ -18,14 +19,14 @@ import (
18
19
)
19
20
20
21
// export the state of gaia for a genesis file
21
- func (app * GaiaApp ) ExportAppStateAndValidators (forZeroHeight bool ) (
22
+ func (app * GaiaApp ) ExportAppStateAndValidators (forZeroHeight bool , jailWhiteList [] string ) (
22
23
appState json.RawMessage , validators []tmtypes.GenesisValidator , err error ) {
23
24
24
25
// as if they could withdraw from the start of the next block
25
26
ctx := app .NewContext (true , abci.Header {Height : app .LastBlockHeight ()})
26
27
27
28
if forZeroHeight {
28
- app .prepForZeroHeightGenesis (ctx )
29
+ app .prepForZeroHeightGenesis (ctx , jailWhiteList )
29
30
}
30
31
31
32
// iterate to get the accounts
@@ -56,7 +57,23 @@ func (app *GaiaApp) ExportAppStateAndValidators(forZeroHeight bool) (
56
57
}
57
58
58
59
// prepare for fresh start at zero height
59
- func (app * GaiaApp ) prepForZeroHeightGenesis (ctx sdk.Context ) {
60
+ func (app * GaiaApp ) prepForZeroHeightGenesis (ctx sdk.Context , jailWhiteList []string ) {
61
+ applyWhiteList := false
62
+
63
+ //Check if there is a whitelist
64
+ if len (jailWhiteList ) > 0 {
65
+ applyWhiteList = true
66
+ }
67
+
68
+ whiteListMap := make (map [string ]bool )
69
+
70
+ for _ , addr := range jailWhiteList {
71
+ _ , err := sdk .ValAddressFromBech32 (addr )
72
+ if err != nil {
73
+ log .Fatal (err )
74
+ }
75
+ whiteListMap [addr ] = true
76
+ }
60
77
61
78
/* Just to be safe, assert the invariants on current state. */
62
79
app .assertRuntimeInvariantsOnContext (ctx )
@@ -136,13 +153,18 @@ func (app *GaiaApp) prepForZeroHeightGenesis(ctx sdk.Context) {
136
153
validator .BondHeight = 0
137
154
validator .UnbondingHeight = 0
138
155
valConsAddrs = append (valConsAddrs , validator .ConsAddress ())
156
+ if applyWhiteList && ! whiteListMap [addr .String ()] {
157
+ validator .Jailed = true
158
+ }
139
159
140
160
app .stakingKeeper .SetValidator (ctx , validator )
141
161
counter ++
142
162
}
143
163
144
164
iter .Close ()
145
165
166
+ _ = app .stakingKeeper .ApplyAndReturnValidatorSetUpdates (ctx )
167
+
146
168
/* Handle slashing state. */
147
169
148
170
// reset start height on signing infos
0 commit comments