refactor(x/staking)!: removes the use of Accounts String() method (#19742)
This commit is contained in:
@@ -54,10 +54,12 @@ func SetupSimulation(config simtypes.Config, dirPrefix, dbName string, verbose,
|
||||
func SimulationOperations(app runtime.AppSimI, cdc codec.Codec, config simtypes.Config) []simtypes.WeightedOperation {
|
||||
signingCtx := cdc.InterfaceRegistry().SigningContext()
|
||||
simState := module.SimulationState{
|
||||
AppParams: make(simtypes.AppParams),
|
||||
Cdc: cdc,
|
||||
TxConfig: authtx.NewTxConfig(cdc, signingCtx.AddressCodec(), signingCtx.ValidatorAddressCodec(), authtx.DefaultSignModes), // TODO(tip): we should extract this from app
|
||||
BondDenom: sdk.DefaultBondDenom,
|
||||
AppParams: make(simtypes.AppParams),
|
||||
Cdc: cdc,
|
||||
AddressCodec: signingCtx.AddressCodec(),
|
||||
ValidatorCodec: signingCtx.ValidatorAddressCodec(),
|
||||
TxConfig: authtx.NewTxConfig(cdc, signingCtx.AddressCodec(), signingCtx.ValidatorAddressCodec(), authtx.DefaultSignModes), // TODO(tip): we should extract this from app
|
||||
BondDenom: sdk.DefaultBondDenom,
|
||||
}
|
||||
|
||||
if config.ParamsFile != "" {
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
|
||||
"github.com/cosmos/gogoproto/proto"
|
||||
|
||||
"cosmossdk.io/core/address"
|
||||
"cosmossdk.io/math"
|
||||
authtypes "cosmossdk.io/x/auth/types"
|
||||
banktypes "cosmossdk.io/x/bank/types"
|
||||
@@ -36,19 +37,20 @@ const (
|
||||
|
||||
// AppStateFn returns the initial application state using a genesis or the simulation parameters.
|
||||
// It calls AppStateFnWithExtendedCb with nil rawStateCb.
|
||||
func AppStateFn(cdc codec.JSONCodec, simManager *module.SimulationManager, genesisState map[string]json.RawMessage) simtypes.AppStateFn {
|
||||
return AppStateFnWithExtendedCb(cdc, simManager, genesisState, nil)
|
||||
func AppStateFn(cdc codec.JSONCodec, addresCodec, validatorCodec address.Codec, simManager *module.SimulationManager, genesisState map[string]json.RawMessage) simtypes.AppStateFn {
|
||||
return AppStateFnWithExtendedCb(cdc, addresCodec, validatorCodec, simManager, genesisState, nil)
|
||||
}
|
||||
|
||||
// AppStateFnWithExtendedCb returns the initial application state using a genesis or the simulation parameters.
|
||||
// It calls AppStateFnWithExtendedCbs with nil moduleStateCb.
|
||||
func AppStateFnWithExtendedCb(
|
||||
cdc codec.JSONCodec,
|
||||
addresCodec, validatorCodec address.Codec,
|
||||
simManager *module.SimulationManager,
|
||||
genesisState map[string]json.RawMessage,
|
||||
rawStateCb func(rawState map[string]json.RawMessage),
|
||||
) simtypes.AppStateFn {
|
||||
return AppStateFnWithExtendedCbs(cdc, simManager, genesisState, nil, rawStateCb)
|
||||
return AppStateFnWithExtendedCbs(cdc, addresCodec, validatorCodec, simManager, genesisState, nil, rawStateCb)
|
||||
}
|
||||
|
||||
// AppStateFnWithExtendedCbs returns the initial application state using a genesis or the simulation parameters.
|
||||
@@ -59,6 +61,7 @@ func AppStateFnWithExtendedCb(
|
||||
// rawStateCb is the callback function to extend rawState.
|
||||
func AppStateFnWithExtendedCbs(
|
||||
cdc codec.JSONCodec,
|
||||
addressCodec, validatorCodec address.Codec,
|
||||
simManager *module.SimulationManager,
|
||||
genesisState map[string]json.RawMessage,
|
||||
moduleStateCb func(moduleName string, genesisState interface{}),
|
||||
@@ -103,11 +106,11 @@ func AppStateFnWithExtendedCbs(
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
appState, simAccs = AppStateRandomizedFn(simManager, r, cdc, accs, genesisTimestamp, appParams, genesisState)
|
||||
appState, simAccs = AppStateRandomizedFn(simManager, r, cdc, accs, genesisTimestamp, appParams, genesisState, addressCodec, validatorCodec)
|
||||
|
||||
default:
|
||||
appParams := make(simtypes.AppParams)
|
||||
appState, simAccs = AppStateRandomizedFn(simManager, r, cdc, accs, genesisTimestamp, appParams, genesisState)
|
||||
appState, simAccs = AppStateRandomizedFn(simManager, r, cdc, accs, genesisTimestamp, appParams, genesisState, addressCodec, validatorCodec)
|
||||
}
|
||||
|
||||
rawState := make(map[string]json.RawMessage)
|
||||
@@ -195,6 +198,7 @@ func AppStateRandomizedFn(
|
||||
genesisTimestamp time.Time,
|
||||
appParams simtypes.AppParams,
|
||||
genesisState map[string]json.RawMessage,
|
||||
addressCodec, validatorCodec address.Codec,
|
||||
) (json.RawMessage, []simtypes.Account) {
|
||||
numAccs := int64(len(accs))
|
||||
// generate a random amount of initial stake coins and a random initial
|
||||
@@ -226,15 +230,17 @@ func AppStateRandomizedFn(
|
||||
)
|
||||
|
||||
simState := &module.SimulationState{
|
||||
AppParams: appParams,
|
||||
Cdc: cdc,
|
||||
Rand: r,
|
||||
GenState: genesisState,
|
||||
Accounts: accs,
|
||||
InitialStake: initialStake,
|
||||
NumBonded: numInitiallyBonded,
|
||||
BondDenom: sdk.DefaultBondDenom,
|
||||
GenTimestamp: genesisTimestamp,
|
||||
AppParams: appParams,
|
||||
Cdc: cdc,
|
||||
AddressCodec: addressCodec,
|
||||
ValidatorCodec: validatorCodec,
|
||||
Rand: r,
|
||||
GenState: genesisState,
|
||||
Accounts: accs,
|
||||
InitialStake: initialStake,
|
||||
NumBonded: numInitiallyBonded,
|
||||
BondDenom: sdk.DefaultBondDenom,
|
||||
GenTimestamp: genesisTimestamp,
|
||||
}
|
||||
|
||||
simManager.GenerateGenesisStates(simState)
|
||||
|
||||
Reference in New Issue
Block a user