Skip to content

Commit

Permalink
refactor(x/simulation)!: remove accounts string (cosmos#20056)
Browse files Browse the repository at this point in the history
  • Loading branch information
JulianToledano authored Apr 16, 2024
1 parent 4ed8c84 commit 9d6c6ef
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ Every module contains its own CHANGELOG.md. Please refer to the module you are i

### API Breaking Changes

* (x/simulation)[#20056](https://github.com/cosmos/cosmos-sdk/pull/20056) `SimulateFromSeed` now takes an address codec as argument.
* (x/crisis) [#20043](https://github.com/cosmos/cosmos-sdk/pull/20043) Changed `NewMsgVerifyInvariant` to accept a string as argument instead of an `AccAddress`.
* (x/genutil) [#19926](https://github.com/cosmos/cosmos-sdk/pull/19926) Removal of the Address.String() method and related changes:
* Added an address codec as an argument to `CollectTxs`, `GenAppStateFromConfig`, and `AddGenesisAccount`.
Expand Down
2 changes: 1 addition & 1 deletion simapp/app_di.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ func NewSimApp(
return app
}

// overwritte default ante handlers with custom ante handlers
// overwrite default ante handlers with custom ante handlers
// set SkipAnteHandler to true in app config and set custom ante handler on baseapp
func (app *SimApp) setCustomAnteHandler() {
anteHandler, err := NewAnteHandler(
Expand Down
2 changes: 2 additions & 0 deletions simapp/sim_bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/client/flags"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
"github.com/cosmos/cosmos-sdk/server"
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
Expand Down Expand Up @@ -72,6 +73,7 @@ func BenchmarkFullAppSimulation(b *testing.B) {
BlockedAddresses(),
config,
app.AppCodec(),
codectestutil.CodecOptions{}.GetAddressCodec(),
)

// export state and simParams before the simulation error is checked
Expand Down
6 changes: 6 additions & 0 deletions simapp/sim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (

"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/client/flags"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
"github.com/cosmos/cosmos-sdk/server"
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
Expand Down Expand Up @@ -92,6 +93,7 @@ func TestFullAppSimulation(t *testing.T) {
BlockedAddresses(),
config,
app.AppCodec(),
codectestutil.CodecOptions{}.GetAddressCodec(),
)

// export state and simParams before the simulation error is checked
Expand Down Expand Up @@ -140,6 +142,7 @@ func TestAppImportExport(t *testing.T) {
BlockedAddresses(),
config,
app.AppCodec(),
codectestutil.CodecOptions{}.GetAddressCodec(),
)

// export state and simParams before the simulation error is checked
Expand Down Expand Up @@ -261,6 +264,7 @@ func TestAppSimulationAfterImport(t *testing.T) {
BlockedAddresses(),
config,
app.AppCodec(),
codectestutil.CodecOptions{}.GetAddressCodec(),
)

// export state and simParams before the simulation error is checked
Expand Down Expand Up @@ -313,6 +317,7 @@ func TestAppSimulationAfterImport(t *testing.T) {
BlockedAddresses(),
config,
app.AppCodec(),
codectestutil.CodecOptions{}.GetAddressCodec(),
)
require.NoError(t, err)
}
Expand Down Expand Up @@ -392,6 +397,7 @@ func TestAppStateDeterminism(t *testing.T) {
BlockedAddresses(),
config,
app.AppCodec(),
codectestutil.CodecOptions{}.GetAddressCodec(),
)
require.NoError(t, err)

Expand Down
1 change: 1 addition & 0 deletions simapp/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
epochstypes "cosmossdk.io/x/epochs/types"
protocolpooltypes "cosmossdk.io/x/protocolpool/types"
upgradetypes "cosmossdk.io/x/upgrade/types"

"github.com/cosmos/cosmos-sdk/types/module"
crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types"
)
Expand Down
8 changes: 7 additions & 1 deletion x/simulation/simulate.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
abci "github.com/cometbft/cometbft/abci/types"
cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"

"cosmossdk.io/core/address"
"cosmossdk.io/core/header"

"github.com/cosmos/cosmos-sdk/baseapp"
Expand Down Expand Up @@ -66,6 +67,7 @@ func SimulateFromSeed(
blockedAddrs map[string]bool,
config simulation.Config,
cdc codec.JSONCodec,
addresscodec address.Codec,
) (stopEarly bool, exportedParams Params, err error) {
tb.Helper()
// in case we have to end early, don't os.Exit so that we can run cleanup code.
Expand Down Expand Up @@ -101,7 +103,11 @@ func SimulateFromSeed(
var tmpAccs []simulation.Account

for _, acc := range accs {
if !blockedAddrs[acc.Address.String()] {
accAddr, err := addresscodec.BytesToString(acc.Address)
if err != nil {
return true, params, err
}
if !blockedAddrs[accAddr] {
tmpAccs = append(tmpAccs, acc)
}
}
Expand Down

0 comments on commit 9d6c6ef

Please sign in to comment.