Skip to content

Commit

Permalink
migrate what is possible to collections
Browse files Browse the repository at this point in the history
  • Loading branch information
tac0turtle committed Feb 26, 2024
1 parent 8d2a749 commit fcbbf76
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions docs/build/building-apps/05-app-testnet.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,15 @@ When creating a testnet the important part is migrate the validator set from man
// Remove all valdiators from last validators store
iterator = app.StakingKeeper.LastValidatorsIterator(ctx)
for ; iterator.Valid(); iterator.Next() {
stakingStore.Delete(iterator.Key())
app.StakingKeeper.LastValidatorPower.Delete(iterator.Key())
}
iterator.Close()

// Add our validator to power and last validators store
app.StakingKeeper.SetValidator(ctx, newVal)
err = app.StakingKeeper.SetValidatorByConsAddr(ctx, newVal)
if err != nil {
tmos.Exit(err.Error())
panic(err)
}
app.StakingKeeper.SetValidatorByPowerIndex(ctx, newVal)
app.StakingKeeper.SetLastValidatorPower(ctx, newVal.GetOperator(), 0)
Expand All @@ -103,10 +103,10 @@ Since the validator set has changed, we need to update the distribution records

```go
// Initialize records for this validator across all distribution stores
app.DistrKeeper.SetValidatorHistoricalRewards(ctx, newVal.GetOperator(), 0, distrtypes.NewValidatorHistoricalRewards(sdk.DecCoins{}, 1))
app.DistrKeeper.SetValidatorCurrentRewards(ctx, newVal.GetOperator(), distrtypes.NewValidatorCurrentRewards(sdk.DecCoins{}, 1))
app.DistrKeeper.SetValidatorAccumulatedCommission(ctx, newVal.GetOperator(), distrtypes.InitialValidatorAccumulatedCommission())
app.DistrKeeper.SetValidatorOutstandingRewards(ctx, newVal.GetOperator(), distrtypes.ValidatorOutstandingRewards{Rewards: sdk.DecCoins{}})
app.DistrKeeper.ValidatorHistoricalRewards.Set(ctx, newVal.GetOperator(), 0, distrtypes.NewValidatorHistoricalRewards(sdk.DecCoins{}, 1))
app.DistrKeeper.ValidatorCurrentRewards.Set(ctx, newVal.GetOperator(), distrtypes.NewValidatorCurrentRewards(sdk.DecCoins{}, 1))
app.DistrKeeper.ValidatorAccumulatedCommission.Set(ctx, newVal.GetOperator(), distrtypes.InitialValidatorAccumulatedCommission())
app.DistrKeeper.ValidatorOutstandingRewards.Set(ctx, newVal.GetOperator(), distrtypes.ValidatorOutstandingRewards{Rewards: sdk.DecCoins{}})
```

#### Slashing
Expand All @@ -124,7 +124,7 @@ We also need to set the validator signing info for the new validator.
StartHeight: app.LastBlockHeight() - 1,
Tombstoned: false,
}
app.SlashingKeeper.SetValidatorSigningInfo(ctx, newConsAddr, newValidatorSigningInfo)
app.SlashingKeeper.ValidatorSigningInfo.Set(ctx, newConsAddr, newValidatorSigningInfo)
```

#### Bank
Expand Down

0 comments on commit fcbbf76

Please sign in to comment.