Skip to content

Commit

Permalink
Revert "feat: add extend cb to avoid unmarshal state twice for sim te…
Browse files Browse the repository at this point in the history
…st (backport: cosmos#15305) (cosmos#15321)"

This reverts commit 570392a.
  • Loading branch information
GAtom22 committed Mar 23, 2023
1 parent 571eedc commit efc6c9a
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 25 deletions.
20 changes: 0 additions & 20 deletions simapp/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,6 @@ import (
// It panics if the user provides files for both of them.
// If a file is not given for the genesis or the sim params, it creates a randomized one.
func AppStateFn(cdc codec.JSONCodec, simManager *module.SimulationManager) simtypes.AppStateFn {
genesisState := NewDefaultGenesisState(cdc)
return AppStateFnWithExtendedCb(cdc, simManager, genesisState, nil)
}

// AppStateFnWithExtendedCb returns the initial application state using a genesis or the simulation parameters.
// It panics if the user provides files for both of them.
// If a file is not given for the genesis or the sim params, it creates a randomized one.
// genesisState is the genesis state of the app.
// cb is the callback function to extend rawState.
func AppStateFnWithExtendedCb(
cdc codec.JSONCodec,
simManager *module.SimulationManager,
genesisState map[string]json.RawMessage,
cb func(rawState map[string]json.RawMessage),
) simtypes.AppStateFn {
return func(r *rand.Rand, accs []simtypes.Account, config simtypes.Config,
) (appState json.RawMessage, simAccs []simtypes.Account, chainID string, genesisTimestamp time.Time) {
if FlagGenesisTimeValue == 0 {
Expand Down Expand Up @@ -142,11 +127,6 @@ func AppStateFnWithExtendedCb(
rawState[stakingtypes.ModuleName] = cdc.MustMarshalJSON(stakingState)
rawState[banktypes.ModuleName] = cdc.MustMarshalJSON(bankState)

// extend state from callback function
if cb != nil {
cb(rawState)
}

// replace appstate
appState, err = json.Marshal(rawState)
if err != nil {
Expand Down
5 changes: 0 additions & 5 deletions types/simulation/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,6 @@ type AppStateFn func(r *rand.Rand, accs []Account, config Config) (
appState json.RawMessage, accounts []Account, chainId string, genesisTimestamp time.Time,
)

// AppStateFnWithExtendedCb returns the app state json bytes and the genesis accounts
type AppStateFnWithExtendedCb func(r *rand.Rand, accs []Account, config Config) (
appState json.RawMessage, accounts []Account, chainId string, genesisTimestamp time.Time,
)

// RandomAccountFn returns a slice of n random simulation accounts
type RandomAccountFn func(r *rand.Rand, n int) []Account

Expand Down

0 comments on commit efc6c9a

Please sign in to comment.