Skip to content

Commit 9d6c6ef

Browse files
refactor(x/simulation)!: remove accounts string (#20056)
1 parent 4ed8c84 commit 9d6c6ef

6 files changed

Lines changed: 18 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ Every module contains its own CHANGELOG.md. Please refer to the module you are i
120120

121121
### API Breaking Changes
122122

123+
* (x/simulation)[#20056](https://github.com/cosmos/cosmos-sdk/pull/20056) `SimulateFromSeed` now takes an address codec as argument.
123124
* (x/crisis) [#20043](https://github.com/cosmos/cosmos-sdk/pull/20043) Changed `NewMsgVerifyInvariant` to accept a string as argument instead of an `AccAddress`.
124125
* (x/genutil) [#19926](https://github.com/cosmos/cosmos-sdk/pull/19926) Removal of the Address.String() method and related changes:
125126
* Added an address codec as an argument to `CollectTxs`, `GenAppStateFromConfig`, and `AddGenesisAccount`.

simapp/app_di.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ func NewSimApp(
306306
return app
307307
}
308308

309-
// overwritte default ante handlers with custom ante handlers
309+
// overwrite default ante handlers with custom ante handlers
310310
// set SkipAnteHandler to true in app config and set custom ante handler on baseapp
311311
func (app *SimApp) setCustomAnteHandler() {
312312
anteHandler, err := NewAnteHandler(

simapp/sim_bench_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010

1111
"github.com/cosmos/cosmos-sdk/baseapp"
1212
"github.com/cosmos/cosmos-sdk/client/flags"
13+
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
1314
"github.com/cosmos/cosmos-sdk/server"
1415
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
1516
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
@@ -72,6 +73,7 @@ func BenchmarkFullAppSimulation(b *testing.B) {
7273
BlockedAddresses(),
7374
config,
7475
app.AppCodec(),
76+
codectestutil.CodecOptions{}.GetAddressCodec(),
7577
)
7678

7779
// export state and simParams before the simulation error is checked

simapp/sim_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626

2727
"github.com/cosmos/cosmos-sdk/baseapp"
2828
"github.com/cosmos/cosmos-sdk/client/flags"
29+
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
2930
"github.com/cosmos/cosmos-sdk/server"
3031
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
3132
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
@@ -92,6 +93,7 @@ func TestFullAppSimulation(t *testing.T) {
9293
BlockedAddresses(),
9394
config,
9495
app.AppCodec(),
96+
codectestutil.CodecOptions{}.GetAddressCodec(),
9597
)
9698

9799
// export state and simParams before the simulation error is checked
@@ -140,6 +142,7 @@ func TestAppImportExport(t *testing.T) {
140142
BlockedAddresses(),
141143
config,
142144
app.AppCodec(),
145+
codectestutil.CodecOptions{}.GetAddressCodec(),
143146
)
144147

145148
// export state and simParams before the simulation error is checked
@@ -261,6 +264,7 @@ func TestAppSimulationAfterImport(t *testing.T) {
261264
BlockedAddresses(),
262265
config,
263266
app.AppCodec(),
267+
codectestutil.CodecOptions{}.GetAddressCodec(),
264268
)
265269

266270
// export state and simParams before the simulation error is checked
@@ -313,6 +317,7 @@ func TestAppSimulationAfterImport(t *testing.T) {
313317
BlockedAddresses(),
314318
config,
315319
app.AppCodec(),
320+
codectestutil.CodecOptions{}.GetAddressCodec(),
316321
)
317322
require.NoError(t, err)
318323
}
@@ -392,6 +397,7 @@ func TestAppStateDeterminism(t *testing.T) {
392397
BlockedAddresses(),
393398
config,
394399
app.AppCodec(),
400+
codectestutil.CodecOptions{}.GetAddressCodec(),
395401
)
396402
require.NoError(t, err)
397403

simapp/upgrades.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
epochstypes "cosmossdk.io/x/epochs/types"
99
protocolpooltypes "cosmossdk.io/x/protocolpool/types"
1010
upgradetypes "cosmossdk.io/x/upgrade/types"
11+
1112
"github.com/cosmos/cosmos-sdk/types/module"
1213
crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types"
1314
)

x/simulation/simulate.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
abci "github.com/cometbft/cometbft/abci/types"
1414
cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
1515

16+
"cosmossdk.io/core/address"
1617
"cosmossdk.io/core/header"
1718

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

103105
for _, acc := range accs {
104-
if !blockedAddrs[acc.Address.String()] {
106+
accAddr, err := addresscodec.BytesToString(acc.Address)
107+
if err != nil {
108+
return true, params, err
109+
}
110+
if !blockedAddrs[accAddr] {
105111
tmpAccs = append(tmpAccs, acc)
106112
}
107113
}

0 commit comments

Comments
 (0)