Skip to content

Commit 73058d5

Browse files
committed
Merge branch 'release/v0.2.x' of https://github.com/terra-money/alliance into fix/delete-validator-0.2.x
2 parents 1cdf4e3 + 1d34f63 commit 73058d5

41 files changed

Lines changed: 5502 additions & 1757 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/lint.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ jobs:
1818
- uses: actions/setup-go@v4
1919
with:
2020
go-version: 1.20.0
21-
- uses: actions/checkout@v3
21+
- uses: actions/checkout@v3
2222
- name: golangci-lint
2323
uses: golangci/golangci-lint-action@v3
2424
with:
2525
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
26-
version: latest
26+
version: v1.52.2

Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,10 @@ test-e2e:
9999
test-benchmark:
100100
@VERSION=$(VERSION) go test -v -mod=readonly -tags='ledger test_ledger_mock' github.com/terra-money/alliance/x/alliance/tests/benchmark
101101

102-
.PHONY: test test-unit test-e2e test-benchmark
102+
test-simulate:
103+
@VERSION=$(VERSION) go test -v -run=TestFullAppSimulation ./app -NumBlocks 200 -BlockSize 10 -Commit -Enabled -Period 1
104+
105+
.PHONY: test test-unit test-e2e test-benchmark test-simulate
103106
###############################################################################
104107
### Linting ###
105108
###############################################################################
@@ -115,7 +118,7 @@ lint: format-tools
115118
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "*.pb.go" -not -path "*pb.gw.go" | xargs gofumpt -d
116119

117120
lint-docker:
118-
docker run --rm -v $(PWD):/app -w /app golangci/golangci-lint:v1.52.2-alpine golangci-lint run
121+
docker run --rm -v $(PWD):/app -w /app golangci/golangci-lint:v1.52.2-alpine golangci-lint run --timeout 10m
119122

120123
format: format-tools
121124
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "*.pb.go" -not -path "*pb.gw.go" | xargs gofumpt -w

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,13 @@ Chains that want to add `x/alliance` must enable the following modules:
5959
- [x/distribution](https://github.com/cosmos/cosmos-sdk/blob/main/x/distribution/README.md)
6060
- [x/gov](https://github.com/cosmos/cosmos-sdk/blob/main/x/gov/README.md)
6161

62+
Compatibility matrix:
63+
64+
| Release | Branch | CosmosSDK |
65+
|---------|----------------|-----------|
66+
| v0.2.0 | release/v0.2.x | 0.47 |
67+
| v0.1.0 | release/v0.1.x | 0.46 |
68+
6269
For an in-depth guide on integrating `x/alliance`, visit the [Alliance Module Integration Guide](https://alliance.terra.money/guides/get-started).
6370

6471
## Development environment

app/app.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,7 @@ func New(
441441
app.BankKeeper,
442442
app.StakingKeeper,
443443
app.DistrKeeper,
444+
authtypes.FeeCollectorName,
444445
)
445446

446447
app.BankKeeper.RegisterKeepers(app.AllianceKeeper, app.StakingKeeper)

app/simulation_test.go

Lines changed: 74 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,38 +4,86 @@ import (
44
"os"
55
"testing"
66

7-
abci "github.com/cometbft/cometbft/abci/types"
87
"github.com/cosmos/cosmos-sdk/baseapp"
9-
"github.com/cosmos/cosmos-sdk/codec"
108
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
11-
sdk "github.com/cosmos/cosmos-sdk/types"
12-
"github.com/cosmos/cosmos-sdk/types/module"
13-
simulationtypes "github.com/cosmos/cosmos-sdk/types/simulation"
9+
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
1410
"github.com/cosmos/cosmos-sdk/x/simulation"
1511
simcli "github.com/cosmos/cosmos-sdk/x/simulation/client/cli"
12+
1613
"github.com/stretchr/testify/require"
1714

1815
"github.com/terra-money/alliance/app"
1916
)
2017

21-
// SimAppChainID hardcoded chainID for simulation
22-
const SimAppChainID = "simulation-app"
18+
// Hardcoded chainID for simulation.
19+
const (
20+
simulationAppChainID = "simulation-app"
21+
simulationDirPrefix = "leveldb-app-sim"
22+
simulationDBName = "Simulation"
23+
)
2324

2425
func init() {
2526
simcli.GetSimulatorFlags()
2627
}
2728

28-
type SimApp interface {
29-
app.App
30-
GetBaseApp() *baseapp.BaseApp
31-
AppCodec() codec.Codec
32-
SimulationManager() *module.SimulationManager
33-
ModuleAccountAddrs() map[string]bool
34-
Name() string
35-
LegacyAmino() *codec.LegacyAmino
36-
BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) abci.ResponseBeginBlock
37-
EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock
38-
InitChainer(ctx sdk.Context, req abci.RequestInitChain) abci.ResponseInitChain
29+
// Running as a go test:
30+
//
31+
// go test -v -run=TestFullAppSimulation ./app -NumBlocks 200 -BlockSize 10 -Commit -Enabled -Period 1
32+
func TestFullAppSimulation(t *testing.T) {
33+
config := simcli.NewConfigFromFlags()
34+
config.ChainID = simulationAppChainID
35+
36+
if !simcli.FlagEnabledValue {
37+
t.Skip("skipping application simulation")
38+
}
39+
40+
db, dir, logger, _, err := simtestutil.SetupSimulation(
41+
config,
42+
simulationDirPrefix,
43+
simulationDBName,
44+
simcli.FlagVerboseValue,
45+
true, // Don't use this as it is confusing
46+
)
47+
require.NoError(t, err, "simulation setup failed")
48+
49+
defer func() {
50+
require.NoError(t, db.Close())
51+
require.NoError(t, os.RemoveAll(dir))
52+
}()
53+
54+
app := app.New(logger,
55+
db,
56+
nil,
57+
true,
58+
map[int64]bool{},
59+
app.DefaultNodeHome,
60+
simcli.FlagPeriodValue,
61+
app.MakeTestEncodingConfig(),
62+
simtestutil.EmptyAppOptions{},
63+
baseapp.SetChainID(simulationAppChainID),
64+
)
65+
66+
// run randomized simulation
67+
_, simParams, simErr := simulation.SimulateFromSeed(
68+
t,
69+
os.Stdout,
70+
app.BaseApp,
71+
simtestutil.AppStateFn(app.AppCodec(), app.SimulationManager(), app.DefaultGenesis()),
72+
simtypes.RandomAccounts,
73+
simtestutil.SimulationOperations(app, app.AppCodec(), config),
74+
app.BankKeeper.GetBlockedAddresses(),
75+
config,
76+
app.AppCodec(),
77+
)
78+
79+
// export state and simParams before the simulatino error is checked
80+
err = simtestutil.CheckExportSimulation(app, config, simParams)
81+
require.NoError(t, err)
82+
require.NoError(t, simErr)
83+
84+
if config.Commit {
85+
simtestutil.PrintStats(db)
86+
}
3987
}
4088

4189
// BenchmarkSimulation run the chain simulation
@@ -61,8 +109,7 @@ func BenchmarkSimulation(b *testing.B) {
61109

62110
encoding := app.MakeTestEncodingConfig()
63111

64-
simApp := app.New(
65-
logger,
112+
app := app.New(logger,
66113
db,
67114
nil,
68115
true,
@@ -77,17 +124,17 @@ func BenchmarkSimulation(b *testing.B) {
77124
_, simParams, simErr := simulation.SimulateFromSeed(
78125
b,
79126
os.Stdout,
80-
simApp.GetBaseApp(),
81-
simtestutil.AppStateFn(simApp.AppCodec(), simApp.SimulationManager(), simApp.DefaultGenesis()),
82-
simulationtypes.RandomAccounts,
83-
simtestutil.SimulationOperations(simApp, simApp.AppCodec(), config),
84-
simApp.ModuleAccountAddrs(),
127+
app.GetBaseApp(),
128+
simtestutil.AppStateFn(app.AppCodec(), app.SimulationManager(), app.DefaultGenesis()),
129+
simtypes.RandomAccounts,
130+
simtestutil.SimulationOperations(app, app.AppCodec(), config),
131+
app.ModuleAccountAddrs(),
85132
config,
86-
simApp.AppCodec(),
133+
app.AppCodec(),
87134
)
88135

89136
// export state and simParams before the simulation error is checked
90-
err = simtestutil.CheckExportSimulation(simApp, config, simParams)
137+
err = simtestutil.CheckExportSimulation(app, config, simParams)
91138
require.NoError(b, err)
92139
require.NoError(b, simErr)
93140

config.yml

Lines changed: 0 additions & 21 deletions
This file was deleted.

custom/bank/module.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ func NewAppModule(cdc codec.Codec, keeper custombankkeeper.Keeper, accountKeeper
2828
return AppModule{
2929
AppModule: bankModule,
3030
keeper: keeper,
31+
subspace: ss,
3132
}
3233
}
3334

@@ -46,4 +47,8 @@ func (am AppModule) RegisterServices(cfg module.Configurator) {
4647
if err := cfg.RegisterMigration(types.ModuleName, 2, m.Migrate2to3); err != nil {
4748
panic(fmt.Sprintf("failed to migrate x/bank from version 2 to 3: %v", err))
4849
}
50+
51+
if err := cfg.RegisterMigration(types.ModuleName, 3, m.Migrate3to4); err != nil {
52+
panic(fmt.Sprintf("failed to migrate x/bank from version 3 to 4: %v", err))
53+
}
4954
}

0 commit comments

Comments
 (0)