Export for zero height fixes (#3183)
This commit is contained in:
parent
131ad378e0
commit
feff014df1
|
@ -74,6 +74,7 @@ BUG FIXES
|
|||
|
||||
* Gaia
|
||||
* \#3148 Fix `gaiad export` by adding a boolean to `NewGaiaApp` determining whether or not to load the latest version
|
||||
* \#3181 Correctly reset total accum update height and jailed-validator bond height / unbonding height on export-for-zero-height
|
||||
* [\#3172](https://github.com/cosmos/cosmos-sdk/pull/3172) Fix parsing `gaiad.toml`
|
||||
when it already exists.
|
||||
|
||||
|
|
|
@ -92,6 +92,7 @@ func (app *GaiaApp) prepForZeroHeightGenesis(ctx sdk.Context) {
|
|||
})
|
||||
app.distrKeeper.IterateValidatorDistInfos(ctx, func(_ int64, valInfo distr.ValidatorDistInfo) (stop bool) {
|
||||
valInfo.FeePoolWithdrawalHeight = 0
|
||||
valInfo.DelAccum.UpdateHeight = 0
|
||||
app.distrKeeper.SetValidatorDistInfo(ctx, valInfo)
|
||||
return false
|
||||
})
|
||||
|
@ -113,12 +114,26 @@ func (app *GaiaApp) prepForZeroHeightGenesis(ctx sdk.Context) {
|
|||
|
||||
/* Handle stake state. */
|
||||
|
||||
// iterate through redelegations, reset creation height
|
||||
app.stakeKeeper.IterateRedelegations(ctx, func(_ int64, red stake.Redelegation) (stop bool) {
|
||||
red.CreationHeight = 0
|
||||
app.stakeKeeper.SetRedelegation(ctx, red)
|
||||
return false
|
||||
})
|
||||
|
||||
// iterate through unbonding delegations, reset creation height
|
||||
app.stakeKeeper.IterateUnbondingDelegations(ctx, func(_ int64, ubd stake.UnbondingDelegation) (stop bool) {
|
||||
ubd.CreationHeight = 0
|
||||
app.stakeKeeper.SetUnbondingDelegation(ctx, ubd)
|
||||
return false
|
||||
})
|
||||
|
||||
// iterate through validators by power descending, reset bond height, update bond intra-tx counter
|
||||
store := ctx.KVStore(app.keyStake)
|
||||
iter := sdk.KVStoreReversePrefixIterator(store, stake.ValidatorsByPowerIndexKey)
|
||||
iter := sdk.KVStoreReversePrefixIterator(store, stake.ValidatorsKey)
|
||||
counter := int16(0)
|
||||
for ; iter.Valid(); iter.Next() {
|
||||
addr := sdk.ValAddress(iter.Value())
|
||||
addr := sdk.ValAddress(iter.Key()[1:])
|
||||
validator, found := app.stakeKeeper.GetValidator(ctx, addr)
|
||||
if !found {
|
||||
panic("expected validator, not found")
|
||||
|
|
Loading…
Reference in New Issue