From 7bc73f0043ca8eccfe2570c93410697fa4c0e8cc Mon Sep 17 00:00:00 2001 From: Randy Grok Date: Wed, 7 Aug 2024 14:37:01 +0200 Subject: [PATCH] remove commented code --- simapp/v2/app_test.go | 2 +- simapp/v2/export.go | 206 ------------------------------------------ 2 files changed, 1 insertion(+), 207 deletions(-) diff --git a/simapp/v2/app_test.go b/simapp/v2/app_test.go index 457b35c55a6b..0498c513a7e6 100644 --- a/simapp/v2/app_test.go +++ b/simapp/v2/app_test.go @@ -98,7 +98,7 @@ func MoveNextBlock(t *testing.T, app *SimApp[transaction.Tx], ctx context.Contex changes, err := newState.GetStateChanges() require.NoError(t, err) - _, err = st.Commit(&store.Changeset{changes}) + _, err = st.Commit(&store.Changeset{Changes: changes}) require.NoError(t, err) } diff --git a/simapp/v2/export.go b/simapp/v2/export.go index 3eca0dfe2c3f..a2b02ed1b82f 100644 --- a/simapp/v2/export.go +++ b/simapp/v2/export.go @@ -38,209 +38,3 @@ func (app *SimApp[T]) ExportAppStateAndValidators(forZeroHeight bool, jailAllowe ConsensusParams: cmtproto.ConsensusParams{}, // TODO: CometBFT consensus params }, err } - -// prepare for fresh start at zero height -// NOTE zero height genesis is a temporary feature which will be deprecated -// -// in favor of export at a block height -// func (app *SimApp[T]) prepForZeroHeightGenesis(ctx context.Context, jailAllowedAddrs []string) { -// applyAllowedAddrs := false - -// // check if there is a allowed address list -// if len(jailAllowedAddrs) > 0 { -// applyAllowedAddrs = true -// } - -// allowedAddrsMap := make(map[string]bool) - -// for _, addr := range jailAllowedAddrs { -// _, err := sdk.ValAddressFromBech32(addr) -// if err != nil { -// log.Fatal(err) -// } -// allowedAddrsMap[addr] = true -// } - -// /* Handle fee distribution state. */ - -// // withdraw all validator commission -// err := app.StakingKeeper.IterateValidators(ctx, func(_ int64, val sdk.ValidatorI) (stop bool) { -// valBz, err := app.StakingKeeper.ValidatorAddressCodec().StringToBytes(val.GetOperator()) -// if err != nil { -// panic(err) -// } -// _, _ = app.DistrKeeper.WithdrawValidatorCommission(ctx, valBz) -// return false -// }) -// if err != nil { -// panic(err) -// } - -// // withdraw all delegator rewards -// dels, err := app.StakingKeeper.GetAllDelegations(ctx) -// if err != nil { -// panic(err) -// } - -// for _, delegation := range dels { -// valAddr, err := sdk.ValAddressFromBech32(delegation.ValidatorAddress) -// if err != nil { -// panic(err) -// } - -// delAddr := sdk.MustAccAddressFromBech32(delegation.DelegatorAddress) - -// _, _ = app.DistrKeeper.WithdrawDelegationRewards(ctx, delAddr, valAddr) -// } - -// // clear validator slash events -// err = app.DistrKeeper.ValidatorSlashEvents.Clear(ctx, nil) -// if err != nil { -// panic(err) -// } - -// // clear validator historical rewards -// err = app.DistrKeeper.ValidatorHistoricalRewards.Clear(ctx, nil) -// if err != nil { -// panic(err) -// } - -// //TODO: set height to 0 - -// // reinitialize all validators -// err = app.StakingKeeper.IterateValidators(ctx, func(_ int64, val sdk.ValidatorI) (stop bool) { -// valBz, err := app.StakingKeeper.ValidatorAddressCodec().StringToBytes(val.GetOperator()) -// if err != nil { -// panic(err) -// } -// // donate any unwithdrawn outstanding reward tokens to the community pool -// rewards, err := app.DistrKeeper.GetValidatorOutstandingRewardsCoins(ctx, valBz) -// if err != nil { -// panic(err) -// } -// feePool, err := app.DistrKeeper.FeePool.Get(ctx) -// if err != nil { -// panic(err) -// } -// feePool.DecimalPool = feePool.DecimalPool.Add(rewards...) // distribution will allocate this to the protocolpool eventually -// if err := app.DistrKeeper.FeePool.Set(ctx, feePool); err != nil { -// panic(err) -// } - -// if err := app.DistrKeeper.Hooks().AfterValidatorCreated(ctx, valBz); err != nil { -// panic(err) -// } -// return false -// }) -// if err != nil { -// panic(err) -// } - -// // reinitialize all delegations -// for _, del := range dels { -// valAddr, err := sdk.ValAddressFromBech32(del.ValidatorAddress) -// if err != nil { -// panic(err) -// } -// delAddr := sdk.MustAccAddressFromBech32(del.DelegatorAddress) - -// if err := app.DistrKeeper.Hooks().BeforeDelegationCreated(ctx, delAddr, valAddr); err != nil { -// // never called as BeforeDelegationCreated always returns nil -// panic(fmt.Errorf("error while incrementing period: %w", err)) -// } - -// if err := app.DistrKeeper.Hooks().AfterDelegationModified(ctx, delAddr, valAddr); err != nil { -// // never called as AfterDelegationModified always returns nil -// panic(fmt.Errorf("error while creating a new delegation period record: %w", err)) -// } -// } - -// /* Handle staking state. */ - -// // iterate through redelegations, reset creation height -// err = app.StakingKeeper.IterateRedelegations(ctx, func(_ int64, red stakingtypes.Redelegation) (stop bool) { -// for i := range red.Entries { -// red.Entries[i].CreationHeight = 0 -// } -// err = app.StakingKeeper.SetRedelegation(ctx, red) -// if err != nil { -// panic(err) -// } -// return false -// }) -// if err != nil { -// panic(err) -// } - -// // iterate through unbonding delegations, reset creation height -// err = app.StakingKeeper.UnbondingDelegations.Walk( -// ctx, -// nil, -// func(key collections.Pair[[]byte, []byte], ubd stakingtypes.UnbondingDelegation) (stop bool, err error) { -// for i := range ubd.Entries { -// ubd.Entries[i].CreationHeight = 0 -// } -// err = app.StakingKeeper.SetUnbondingDelegation(ctx, ubd) -// if err != nil { -// return true, err -// } -// return false, err -// }, -// ) -// if err != nil { -// panic(err) -// } - -// counter := 0 -// iter, err := app.StakingKeeper.Validators.IterateRaw(ctx, []byte{}, []byte{}, collections.OrderDescending) -// if err != nil { -// log.Fatal(err) -// } - -// for ; iter.Valid(); iter.Next() { -// key, err := iter.KeyValue() -// if err != nil { -// log.Fatal(err) -// } -// addr := sdk.ValAddress(stakingtypes.AddressFromValidatorsKey(key.Key)) -// validator, err := app.StakingKeeper.GetValidator(ctx, addr) -// if err != nil { -// panic("expected validator, not found") -// } - -// validator.UnbondingHeight = 0 -// if applyAllowedAddrs && !allowedAddrsMap[addr.String()] { -// validator.Jailed = true -// } - -// if err = app.StakingKeeper.SetValidator(ctx, validator); err != nil { -// panic(err) -// } -// counter++ -// } - -// if err := iter.Close(); err != nil { -// app.Logger().Error("error while closing the key-value store reverse prefix iterator: ", err) -// return -// } - -// _, err = app.StakingKeeper.ApplyAndReturnValidatorSetUpdates(ctx) -// if err != nil { -// log.Fatal(err) -// } - -// /* Handle slashing state. */ - -// // reset start height on signing infos -// err = app.SlashingKeeper.ValidatorSigningInfo.Walk(ctx, nil, func(addr sdk.ConsAddress, info slashingtypes.ValidatorSigningInfo) (stop bool, err error) { -// info.StartHeight = 0 -// err = app.SlashingKeeper.ValidatorSigningInfo.Set(ctx, addr, info) -// if err != nil { -// return true, err -// } -// return false, nil -// }) -// if err != nil { -// panic(err) -// } -// }