Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(x/simulation)!: remove accounts string #20056

Merged
merged 2 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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`.
JulianToledano marked this conversation as resolved.
Show resolved Hide resolved
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
Loading