From 01410990332df638db248a37db786f5017d0fbdf Mon Sep 17 00:00:00 2001 From: Julian Toledano Date: Tue, 16 Apr 2024 10:10:44 +0200 Subject: [PATCH 1/2] update: remove accAddress --- simapp/app_di.go | 2 +- simapp/sim_bench_test.go | 2 ++ simapp/sim_test.go | 6 ++++++ simapp/upgrades.go | 1 + x/simulation/simulate.go | 8 +++++++- 5 files changed, 17 insertions(+), 2 deletions(-) diff --git a/simapp/app_di.go b/simapp/app_di.go index 2630778ebbc2..997565a4b1dc 100644 --- a/simapp/app_di.go +++ b/simapp/app_di.go @@ -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( diff --git a/simapp/sim_bench_test.go b/simapp/sim_bench_test.go index ab3538c7af07..e4d01fcd44f4 100644 --- a/simapp/sim_bench_test.go +++ b/simapp/sim_bench_test.go @@ -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" @@ -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 diff --git a/simapp/sim_test.go b/simapp/sim_test.go index b4f9802830e9..ef43684e1571 100644 --- a/simapp/sim_test.go +++ b/simapp/sim_test.go @@ -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" @@ -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 @@ -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 @@ -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 @@ -313,6 +317,7 @@ func TestAppSimulationAfterImport(t *testing.T) { BlockedAddresses(), config, app.AppCodec(), + codectestutil.CodecOptions{}.GetAddressCodec(), ) require.NoError(t, err) } @@ -392,6 +397,7 @@ func TestAppStateDeterminism(t *testing.T) { BlockedAddresses(), config, app.AppCodec(), + codectestutil.CodecOptions{}.GetAddressCodec(), ) require.NoError(t, err) diff --git a/simapp/upgrades.go b/simapp/upgrades.go index 4351e99f1063..ed6d35c0b490 100644 --- a/simapp/upgrades.go +++ b/simapp/upgrades.go @@ -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" ) diff --git a/x/simulation/simulate.go b/x/simulation/simulate.go index 1da741088559..bdc52a366b64 100644 --- a/x/simulation/simulate.go +++ b/x/simulation/simulate.go @@ -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" @@ -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. @@ -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) } } From 42867e5fe183213fd3b9e72bf8fe48f1c8fb57ec Mon Sep 17 00:00:00 2001 From: Julian Toledano Date: Tue, 16 Apr 2024 10:13:48 +0200 Subject: [PATCH 2/2] CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 22670a522326..766fac648838 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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`.