@agoric/cosmos 0.34.2-dev-9f6644d.0 → 0.34.2-dev-0467291.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.clang-format +116 -0
- package/Makefile +38 -67
- package/ante/ante.go +2 -2
- package/ante/inbound_test.go +1 -1
- package/app/app.go +173 -142
- package/app/export.go +6 -6
- package/app/genesis.go +4 -0
- package/app/sim_test.go +299 -50
- package/app/upgrade.go +70 -3
- package/cmd/agd/agvm.go +1 -1
- package/cmd/agd/main.go +1 -1
- package/cmd/libdaemon/main.go +1 -1
- package/daemon/cmd/root.go +25 -34
- package/daemon/cmd/root_test.go +5 -4
- package/daemon/cmd/testnet.go +221 -95
- package/daemon/main.go +1 -0
- package/git-revision.txt +1 -1
- package/go.mod +93 -58
- package/go.sum +148 -95
- package/package.json +2 -2
- package/proto/agoric/swingset/genesis.proto +7 -11
- package/proto/agoric/swingset/msgs.proto +56 -75
- package/proto/agoric/swingset/query.proto +7 -10
- package/proto/agoric/swingset/swingset.proto +79 -108
- package/proto/agoric/vbank/genesis.proto +5 -5
- package/proto/agoric/vbank/msgs.proto +1 -2
- package/proto/agoric/vbank/vbank.proto +42 -52
- package/proto/agoric/vibc/msgs.proto +8 -11
- package/proto/agoric/vstorage/genesis.proto +6 -9
- package/proto/agoric/vstorage/query.proto +19 -48
- package/proto/agoric/vstorage/vstorage.proto +4 -10
- package/proto/agoric/vtransfer/genesis.proto +7 -7
- package/proto/buf.gen.gogo.yaml +8 -0
- package/proto/buf.gen.pulsar.yaml +17 -0
- package/proto/buf.gen.swagger.yaml +5 -0
- package/proto/buf.yaml +10 -0
- package/scripts/protocgen.sh +14 -21
- package/third_party/proto/amino/amino.proto +79 -0
- package/third_party/proto/cosmos/base/v1beta1/coin.proto +7 -2
- package/third_party/proto/cosmos/ics23/v1/proofs.proto +243 -0
- package/third_party/proto/cosmos/msg/v1/msg.proto +30 -0
- package/third_party/proto/cosmos/upgrade/v1beta1/upgrade.proto +17 -5
- package/third_party/proto/cosmos_proto/cosmos.proto +16 -1
- package/third_party/proto/gogoproto/gogo.proto +2 -2
- package/third_party/proto/google/protobuf/any.proto +6 -3
- package/third_party/proto/ibc/core/channel/v1/channel.proto +1 -1
- package/third_party/proto/ibc/core/client/v1/client.proto +4 -2
- package/types/address_hooks.go +2 -2
- package/types/address_hooks_test.go +3 -3
- package/types/ibc_packet.go +3 -3
- package/types/ibc_packet_test.go +3 -3
- package/vm/proto_json.go +2 -2
- package/x/swingset/abci.go +1 -1
- package/x/swingset/alias.go +0 -1
- package/x/swingset/config.go +1 -1
- package/x/swingset/keeper/extension_snapshotter.go +1 -1
- package/x/swingset/keeper/extension_snapshotter_test.go +1 -1
- package/x/swingset/keeper/keeper.go +1 -1
- package/x/swingset/keeper/keeper_test.go +1 -1
- package/x/swingset/keeper/querier.go +1 -30
- package/x/swingset/keeper/swing_store_exports_handler.go +1 -1
- package/x/swingset/keeper/swing_store_exports_handler_test.go +1 -1
- package/x/swingset/module.go +1 -14
- package/x/swingset/types/genesis.pb.go +2 -2
- package/x/swingset/types/msgs.pb.go +4 -3
- package/x/swingset/types/msgs_test.go +1 -1
- package/x/swingset/types/query.pb.go +4 -3
- package/x/swingset/types/swingset.pb.go +2 -2
- package/x/vbank/genesis.go +1 -1
- package/x/vbank/keeper/querier.go +1 -21
- package/x/vbank/module.go +1 -16
- package/x/vbank/types/genesis.pb.go +2 -2
- package/x/vbank/types/msgs.pb.go +3 -2
- package/x/vbank/types/query.pb.go +4 -3
- package/x/vbank/types/vbank.pb.go +2 -2
- package/x/vbank/vbank_test.go +16 -16
- package/x/vibc/keeper/keeper.go +8 -5
- package/x/vibc/keeper/migrations.go +36 -0
- package/x/vibc/keeper/triggers.go +1 -1
- package/x/vibc/module.go +9 -17
- package/x/vibc/types/expected_keepers.go +5 -10
- package/x/vibc/types/ibc_module.go +4 -4
- package/x/vibc/types/msgs.go +1 -1
- package/x/vibc/types/msgs.pb.go +5 -4
- package/x/vibc/types/receiver.go +2 -2
- package/x/vlocalchain/keeper/keeper.go +3 -3
- package/x/vlocalchain/types/vlocalchain.pb.go +1 -1
- package/x/vlocalchain/vlocalchain_test.go +6 -6
- package/x/vstorage/alias.go +0 -1
- package/x/vstorage/client/cli/query.go +1 -1
- package/x/vstorage/genesis.go +1 -1
- package/x/vstorage/keeper/keeper.go +6 -5
- package/x/vstorage/keeper/keeper_test.go +24 -24
- package/x/vstorage/keeper/querier.go +1 -32
- package/x/vstorage/keeper/querier_test.go +41 -6
- package/x/vstorage/module.go +1 -14
- package/x/vstorage/types/genesis.pb.go +2 -2
- package/x/vstorage/types/query.pb.go +8 -5
- package/x/vstorage/types/vstorage.pb.go +2 -2
- package/x/vstorage/vstorage_test.go +3 -3
- package/x/vtransfer/genesis.go +1 -1
- package/x/vtransfer/ibc_middleware.go +4 -4
- package/x/vtransfer/ibc_middleware_test.go +10 -11
- package/x/vtransfer/keeper/keeper.go +5 -5
- package/x/vtransfer/module.go +1 -14
- package/x/vtransfer/types/expected_keepers.go +2 -18
- package/x/vtransfer/types/genesis.pb.go +2 -2
- package/x/vtransfer/utils_test.go +15 -15
- package/daemon/cmd/genaccounts.go +0 -195
package/app/export.go
CHANGED
|
@@ -2,9 +2,10 @@ package gaia
|
|
|
2
2
|
|
|
3
3
|
import (
|
|
4
4
|
"encoding/json"
|
|
5
|
+
"fmt"
|
|
5
6
|
"log"
|
|
6
7
|
|
|
7
|
-
tmproto "github.com/
|
|
8
|
+
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
|
|
8
9
|
|
|
9
10
|
servertypes "github.com/cosmos/cosmos-sdk/server/types"
|
|
10
11
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
@@ -16,7 +17,7 @@ import (
|
|
|
16
17
|
// ExportAppStateAndValidators exports the state of the application for a genesis
|
|
17
18
|
// file.
|
|
18
19
|
func (app *GaiaApp) ExportAppStateAndValidators(
|
|
19
|
-
forZeroHeight bool, jailAllowedAddrs []string,
|
|
20
|
+
forZeroHeight bool, jailAllowedAddrs []string, modulesToExport []string,
|
|
20
21
|
) (servertypes.ExportedApp, error) {
|
|
21
22
|
// as if they could withdraw from the start of the next block
|
|
22
23
|
ctx := app.NewContext(true, tmproto.Header{Height: app.LastBlockHeight()})
|
|
@@ -25,17 +26,16 @@ func (app *GaiaApp) ExportAppStateAndValidators(
|
|
|
25
26
|
// Tendermint will start InitChain.
|
|
26
27
|
height := app.LastBlockHeight() + 1
|
|
27
28
|
if forZeroHeight {
|
|
28
|
-
|
|
29
|
-
app.prepForZeroHeightGenesis(ctx, jailAllowedAddrs)
|
|
29
|
+
return servertypes.ExportedApp{}, fmt.Errorf("forZeroHeight not supported")
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
genState := app.
|
|
32
|
+
genState := app.ModuleManager.ExportGenesisForModules(ctx, app.appCodec, modulesToExport)
|
|
33
33
|
appState, err := json.MarshalIndent(genState, "", " ")
|
|
34
34
|
if err != nil {
|
|
35
35
|
return servertypes.ExportedApp{}, err
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
validators, err := staking.WriteValidators(ctx, app.StakingKeeper)
|
|
38
|
+
validators, err := staking.WriteValidators(ctx, &app.StakingKeeper)
|
|
39
39
|
return servertypes.ExportedApp{
|
|
40
40
|
AppState: appState,
|
|
41
41
|
Validators: validators,
|
package/app/genesis.go
CHANGED
package/app/sim_test.go
CHANGED
|
@@ -1,112 +1,361 @@
|
|
|
1
|
-
package
|
|
1
|
+
package gaia
|
|
2
2
|
|
|
3
3
|
import (
|
|
4
4
|
"encoding/json"
|
|
5
5
|
"fmt"
|
|
6
|
+
"math/rand"
|
|
6
7
|
"os"
|
|
8
|
+
"runtime/debug"
|
|
9
|
+
"strings"
|
|
7
10
|
"testing"
|
|
8
11
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
"github.com/
|
|
12
|
+
dbm "github.com/cometbft/cometbft-db"
|
|
13
|
+
abci "github.com/cometbft/cometbft/abci/types"
|
|
14
|
+
"github.com/cometbft/cometbft/libs/log"
|
|
15
|
+
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
|
|
12
16
|
"github.com/stretchr/testify/require"
|
|
13
|
-
|
|
14
|
-
"github.com/
|
|
15
|
-
|
|
17
|
+
|
|
18
|
+
"github.com/cosmos/cosmos-sdk/client/flags"
|
|
19
|
+
"github.com/cosmos/cosmos-sdk/server"
|
|
20
|
+
storetypes "github.com/cosmos/cosmos-sdk/store/types"
|
|
16
21
|
|
|
17
22
|
"github.com/cosmos/cosmos-sdk/baseapp"
|
|
18
|
-
"github.com/cosmos/cosmos-sdk/simapp"
|
|
19
23
|
"github.com/cosmos/cosmos-sdk/store"
|
|
20
|
-
|
|
24
|
+
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
|
|
25
|
+
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
26
|
+
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
|
|
27
|
+
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
|
28
|
+
authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper"
|
|
29
|
+
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
|
30
|
+
capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types"
|
|
31
|
+
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
|
|
32
|
+
evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types"
|
|
33
|
+
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
|
|
34
|
+
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
|
|
35
|
+
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
|
|
21
36
|
"github.com/cosmos/cosmos-sdk/x/simulation"
|
|
37
|
+
simcli "github.com/cosmos/cosmos-sdk/x/simulation/client/cli"
|
|
38
|
+
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
|
|
39
|
+
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
|
|
22
40
|
)
|
|
23
41
|
|
|
42
|
+
// SimAppChainID hardcoded chainID for simulation
|
|
43
|
+
const SimAppChainID = "simulation-app"
|
|
44
|
+
|
|
45
|
+
// Get flags every time the simulator is run
|
|
24
46
|
func init() {
|
|
25
|
-
|
|
47
|
+
simcli.GetSimulatorFlags()
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
type StoreKeysPrefixes struct {
|
|
51
|
+
A storetypes.StoreKey
|
|
52
|
+
B storetypes.StoreKey
|
|
53
|
+
Prefixes [][]byte
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// fauxMerkleModeOpt returns a BaseApp option to use a dbStoreAdapter instead of
|
|
57
|
+
// an IAVLStore for faster simulation speed.
|
|
58
|
+
func fauxMerkleModeOpt(bapp *baseapp.BaseApp) {
|
|
59
|
+
bapp.SetFauxMerkleMode()
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// interBlockCacheOpt returns a BaseApp option function that sets the persistent
|
|
63
|
+
// inter-block write-through cache.
|
|
64
|
+
func interBlockCacheOpt() func(*baseapp.BaseApp) {
|
|
65
|
+
return baseapp.SetInterBlockCache(store.NewCommitKVStoreCacheManager())
|
|
26
66
|
}
|
|
27
67
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
68
|
+
func TestFullAppSimulation(t *testing.T) {
|
|
69
|
+
config := simcli.NewConfigFromFlags()
|
|
70
|
+
config.ChainID = SimAppChainID
|
|
71
|
+
|
|
72
|
+
db, dir, logger, skip, err := simtestutil.SetupSimulation(config, "leveldb-app-sim", "Simulation", simcli.FlagVerboseValue, simcli.FlagEnabledValue)
|
|
73
|
+
if skip {
|
|
74
|
+
t.Skip("skipping application simulation")
|
|
34
75
|
}
|
|
76
|
+
require.NoError(t, err, "simulation setup failed")
|
|
35
77
|
|
|
36
78
|
defer func() {
|
|
37
|
-
db.Close()
|
|
38
|
-
|
|
39
|
-
if err != nil {
|
|
40
|
-
b.Fatal(err)
|
|
41
|
-
}
|
|
79
|
+
require.NoError(t, db.Close())
|
|
80
|
+
require.NoError(t, os.RemoveAll(dir))
|
|
42
81
|
}()
|
|
43
82
|
|
|
44
|
-
|
|
83
|
+
appOptions := make(simtestutil.AppOptionsMap, 0)
|
|
84
|
+
appOptions[flags.FlagHome] = DefaultNodeHome
|
|
85
|
+
appOptions[server.FlagInvCheckPeriod] = simcli.FlagPeriodValue
|
|
45
86
|
|
|
46
|
-
|
|
87
|
+
app := NewSimApp(logger, db, nil, true, appOptions, fauxMerkleModeOpt, baseapp.SetChainID(SimAppChainID))
|
|
88
|
+
require.Equal(t, "SimApp", app.Name())
|
|
89
|
+
|
|
90
|
+
// run randomized simulation
|
|
47
91
|
_, simParams, simErr := simulation.SimulateFromSeed(
|
|
48
|
-
|
|
92
|
+
t,
|
|
49
93
|
os.Stdout,
|
|
50
94
|
app.BaseApp,
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
95
|
+
simtestutil.AppStateFn(app.AppCodec(), app.SimulationManager(), app.DefaultGenesis()),
|
|
96
|
+
simtypes.RandomAccounts, // Replace with own random account function if using keys other than secp256k1
|
|
97
|
+
simtestutil.SimulationOperations(app, app.AppCodec(), config),
|
|
98
|
+
BlockedAddresses(),
|
|
55
99
|
config,
|
|
56
100
|
app.AppCodec(),
|
|
57
101
|
)
|
|
58
102
|
|
|
59
103
|
// export state and simParams before the simulation error is checked
|
|
60
|
-
|
|
61
|
-
|
|
104
|
+
err = simtestutil.CheckExportSimulation(app, config, simParams)
|
|
105
|
+
require.NoError(t, err)
|
|
106
|
+
require.NoError(t, simErr)
|
|
107
|
+
|
|
108
|
+
if config.Commit {
|
|
109
|
+
simtestutil.PrintStats(db)
|
|
62
110
|
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
func TestAppImportExport(t *testing.T) {
|
|
114
|
+
config := simcli.NewConfigFromFlags()
|
|
115
|
+
config.ChainID = SimAppChainID
|
|
63
116
|
|
|
64
|
-
|
|
65
|
-
|
|
117
|
+
db, dir, logger, skip, err := simtestutil.SetupSimulation(config, "leveldb-app-sim", "Simulation", simcli.FlagVerboseValue, simcli.FlagEnabledValue)
|
|
118
|
+
if skip {
|
|
119
|
+
t.Skip("skipping application import/export simulation")
|
|
66
120
|
}
|
|
121
|
+
require.NoError(t, err, "simulation setup failed")
|
|
122
|
+
|
|
123
|
+
defer func() {
|
|
124
|
+
require.NoError(t, db.Close())
|
|
125
|
+
require.NoError(t, os.RemoveAll(dir))
|
|
126
|
+
}()
|
|
127
|
+
|
|
128
|
+
appOptions := make(simtestutil.AppOptionsMap, 0)
|
|
129
|
+
appOptions[flags.FlagHome] = DefaultNodeHome
|
|
130
|
+
appOptions[server.FlagInvCheckPeriod] = simcli.FlagPeriodValue
|
|
131
|
+
|
|
132
|
+
app := NewSimApp(logger, db, nil, true, appOptions, fauxMerkleModeOpt, baseapp.SetChainID(SimAppChainID))
|
|
133
|
+
require.Equal(t, "SimApp", app.Name())
|
|
134
|
+
|
|
135
|
+
// Run randomized simulation
|
|
136
|
+
_, simParams, simErr := simulation.SimulateFromSeed(
|
|
137
|
+
t,
|
|
138
|
+
os.Stdout,
|
|
139
|
+
app.BaseApp,
|
|
140
|
+
simtestutil.AppStateFn(app.AppCodec(), app.SimulationManager(), app.DefaultGenesis()),
|
|
141
|
+
simtypes.RandomAccounts, // Replace with own random account function if using keys other than secp256k1
|
|
142
|
+
simtestutil.SimulationOperations(app, app.AppCodec(), config),
|
|
143
|
+
BlockedAddresses(),
|
|
144
|
+
config,
|
|
145
|
+
app.AppCodec(),
|
|
146
|
+
)
|
|
147
|
+
|
|
148
|
+
// export state and simParams before the simulation error is checked
|
|
149
|
+
err = simtestutil.CheckExportSimulation(app, config, simParams)
|
|
150
|
+
require.NoError(t, err)
|
|
151
|
+
require.NoError(t, simErr)
|
|
67
152
|
|
|
68
153
|
if config.Commit {
|
|
69
|
-
|
|
154
|
+
simtestutil.PrintStats(db)
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
fmt.Printf("exporting genesis...\n")
|
|
158
|
+
|
|
159
|
+
exported, err := app.ExportAppStateAndValidators(false, []string{}, []string{})
|
|
160
|
+
require.NoError(t, err)
|
|
161
|
+
|
|
162
|
+
fmt.Printf("importing genesis...\n")
|
|
163
|
+
|
|
164
|
+
newDB, newDir, _, _, err := simtestutil.SetupSimulation(config, "leveldb-app-sim-2", "Simulation-2", simcli.FlagVerboseValue, simcli.FlagEnabledValue)
|
|
165
|
+
require.NoError(t, err, "simulation setup failed")
|
|
166
|
+
|
|
167
|
+
defer func() {
|
|
168
|
+
require.NoError(t, newDB.Close())
|
|
169
|
+
require.NoError(t, os.RemoveAll(newDir))
|
|
170
|
+
}()
|
|
171
|
+
|
|
172
|
+
newApp := NewSimApp(log.NewNopLogger(), newDB, nil, true, appOptions, fauxMerkleModeOpt, baseapp.SetChainID(SimAppChainID))
|
|
173
|
+
require.Equal(t, "SimApp", newApp.Name())
|
|
174
|
+
|
|
175
|
+
var genesisState GenesisState
|
|
176
|
+
err = json.Unmarshal(exported.AppState, &genesisState)
|
|
177
|
+
require.NoError(t, err)
|
|
178
|
+
|
|
179
|
+
defer func() {
|
|
180
|
+
if r := recover(); r != nil {
|
|
181
|
+
err := fmt.Sprintf("%v", r)
|
|
182
|
+
if !strings.Contains(err, "validator set is empty after InitGenesis") {
|
|
183
|
+
panic(r)
|
|
184
|
+
}
|
|
185
|
+
logger.Info("Skipping simulation as all validators have been unbonded")
|
|
186
|
+
logger.Info("err", err, "stacktrace", string(debug.Stack()))
|
|
187
|
+
}
|
|
188
|
+
}()
|
|
189
|
+
|
|
190
|
+
ctxA := app.NewContext(true, tmproto.Header{Height: app.LastBlockHeight()})
|
|
191
|
+
ctxB := newApp.NewContext(true, tmproto.Header{Height: app.LastBlockHeight()})
|
|
192
|
+
newApp.ModuleManager.InitGenesis(ctxB, app.AppCodec(), genesisState)
|
|
193
|
+
newApp.StoreConsensusParams(ctxB, exported.ConsensusParams)
|
|
194
|
+
|
|
195
|
+
fmt.Printf("comparing stores...\n")
|
|
196
|
+
|
|
197
|
+
storeKeysPrefixes := []StoreKeysPrefixes{
|
|
198
|
+
{app.GetKey(authtypes.StoreKey), newApp.GetKey(authtypes.StoreKey), [][]byte{}},
|
|
199
|
+
{
|
|
200
|
+
app.GetKey(stakingtypes.StoreKey), newApp.GetKey(stakingtypes.StoreKey),
|
|
201
|
+
[][]byte{
|
|
202
|
+
stakingtypes.UnbondingQueueKey, stakingtypes.RedelegationQueueKey, stakingtypes.ValidatorQueueKey,
|
|
203
|
+
stakingtypes.HistoricalInfoKey, stakingtypes.UnbondingIDKey, stakingtypes.UnbondingIndexKey, stakingtypes.UnbondingTypeKey, stakingtypes.ValidatorUpdatesKey,
|
|
204
|
+
},
|
|
205
|
+
}, // ordering may change but it doesn't matter
|
|
206
|
+
{app.GetKey(slashingtypes.StoreKey), newApp.GetKey(slashingtypes.StoreKey), [][]byte{}},
|
|
207
|
+
{app.GetKey(minttypes.StoreKey), newApp.GetKey(minttypes.StoreKey), [][]byte{}},
|
|
208
|
+
{app.GetKey(distrtypes.StoreKey), newApp.GetKey(distrtypes.StoreKey), [][]byte{}},
|
|
209
|
+
{app.GetKey(banktypes.StoreKey), newApp.GetKey(banktypes.StoreKey), [][]byte{banktypes.BalancesPrefix}},
|
|
210
|
+
{app.GetKey(paramtypes.StoreKey), newApp.GetKey(paramtypes.StoreKey), [][]byte{}},
|
|
211
|
+
{app.GetKey(govtypes.StoreKey), newApp.GetKey(govtypes.StoreKey), [][]byte{}},
|
|
212
|
+
{app.GetKey(evidencetypes.StoreKey), newApp.GetKey(evidencetypes.StoreKey), [][]byte{}},
|
|
213
|
+
{app.GetKey(capabilitytypes.StoreKey), newApp.GetKey(capabilitytypes.StoreKey), [][]byte{}},
|
|
214
|
+
{app.GetKey(authzkeeper.StoreKey), newApp.GetKey(authzkeeper.StoreKey), [][]byte{authzkeeper.GrantKey, authzkeeper.GrantQueuePrefix}},
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
for _, skp := range storeKeysPrefixes {
|
|
218
|
+
storeA := ctxA.KVStore(skp.A)
|
|
219
|
+
storeB := ctxB.KVStore(skp.B)
|
|
220
|
+
|
|
221
|
+
failedKVAs, failedKVBs := sdk.DiffKVStores(storeA, storeB, skp.Prefixes)
|
|
222
|
+
require.Equal(t, len(failedKVAs), len(failedKVBs), "unequal sets of key-values to compare")
|
|
223
|
+
|
|
224
|
+
fmt.Printf("compared %d different key/value pairs between %s and %s\n", len(failedKVAs), skp.A, skp.B)
|
|
225
|
+
require.Equal(t, 0, len(failedKVAs), simtestutil.GetSimulationLog(skp.A.Name(), app.SimulationManager().StoreDecoders, failedKVAs, failedKVBs))
|
|
70
226
|
}
|
|
71
227
|
}
|
|
72
228
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
229
|
+
func TestAppSimulationAfterImport(t *testing.T) {
|
|
230
|
+
config := simcli.NewConfigFromFlags()
|
|
231
|
+
config.ChainID = SimAppChainID
|
|
232
|
+
|
|
233
|
+
db, dir, logger, skip, err := simtestutil.SetupSimulation(config, "leveldb-app-sim", "Simulation", simcli.FlagVerboseValue, simcli.FlagEnabledValue)
|
|
234
|
+
if skip {
|
|
235
|
+
t.Skip("skipping application simulation after import")
|
|
236
|
+
}
|
|
237
|
+
require.NoError(t, err, "simulation setup failed")
|
|
238
|
+
|
|
239
|
+
defer func() {
|
|
240
|
+
require.NoError(t, db.Close())
|
|
241
|
+
require.NoError(t, os.RemoveAll(dir))
|
|
242
|
+
}()
|
|
243
|
+
|
|
244
|
+
appOptions := make(simtestutil.AppOptionsMap, 0)
|
|
245
|
+
appOptions[flags.FlagHome] = DefaultNodeHome
|
|
246
|
+
appOptions[server.FlagInvCheckPeriod] = simcli.FlagPeriodValue
|
|
247
|
+
|
|
248
|
+
app := NewSimApp(logger, db, nil, true, appOptions, fauxMerkleModeOpt, baseapp.SetChainID(SimAppChainID))
|
|
249
|
+
require.Equal(t, "SimApp", app.Name())
|
|
250
|
+
|
|
251
|
+
// Run randomized simulation
|
|
252
|
+
stopEarly, simParams, simErr := simulation.SimulateFromSeed(
|
|
253
|
+
t,
|
|
254
|
+
os.Stdout,
|
|
255
|
+
app.BaseApp,
|
|
256
|
+
simtestutil.AppStateFn(app.AppCodec(), app.SimulationManager(), app.DefaultGenesis()),
|
|
257
|
+
simtypes.RandomAccounts, // Replace with own random account function if using keys other than secp256k1
|
|
258
|
+
simtestutil.SimulationOperations(app, app.AppCodec(), config),
|
|
259
|
+
BlockedAddresses(),
|
|
260
|
+
config,
|
|
261
|
+
app.AppCodec(),
|
|
262
|
+
)
|
|
263
|
+
|
|
264
|
+
// export state and simParams before the simulation error is checked
|
|
265
|
+
err = simtestutil.CheckExportSimulation(app, config, simParams)
|
|
266
|
+
require.NoError(t, err)
|
|
267
|
+
require.NoError(t, simErr)
|
|
268
|
+
|
|
269
|
+
if config.Commit {
|
|
270
|
+
simtestutil.PrintStats(db)
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
if stopEarly {
|
|
274
|
+
fmt.Println("can't export or import a zero-validator genesis, exiting test...")
|
|
275
|
+
return
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
fmt.Printf("exporting genesis...\n")
|
|
279
|
+
|
|
280
|
+
exported, err := app.ExportAppStateAndValidators(true, []string{}, []string{})
|
|
281
|
+
require.NoError(t, err)
|
|
282
|
+
|
|
283
|
+
fmt.Printf("importing genesis...\n")
|
|
284
|
+
|
|
285
|
+
newDB, newDir, _, _, err := simtestutil.SetupSimulation(config, "leveldb-app-sim-2", "Simulation-2", simcli.FlagVerboseValue, simcli.FlagEnabledValue)
|
|
286
|
+
require.NoError(t, err, "simulation setup failed")
|
|
287
|
+
|
|
288
|
+
defer func() {
|
|
289
|
+
require.NoError(t, newDB.Close())
|
|
290
|
+
require.NoError(t, os.RemoveAll(newDir))
|
|
291
|
+
}()
|
|
292
|
+
|
|
293
|
+
newApp := NewSimApp(log.NewNopLogger(), newDB, nil, true, appOptions, fauxMerkleModeOpt, baseapp.SetChainID(SimAppChainID))
|
|
294
|
+
require.Equal(t, "SimApp", newApp.Name())
|
|
295
|
+
|
|
296
|
+
newApp.InitChain(abci.RequestInitChain{
|
|
297
|
+
ChainId: SimAppChainID,
|
|
298
|
+
AppStateBytes: exported.AppState,
|
|
299
|
+
})
|
|
300
|
+
|
|
301
|
+
_, _, err = simulation.SimulateFromSeed(
|
|
302
|
+
t,
|
|
303
|
+
os.Stdout,
|
|
304
|
+
newApp.BaseApp,
|
|
305
|
+
simtestutil.AppStateFn(app.AppCodec(), app.SimulationManager(), app.DefaultGenesis()),
|
|
306
|
+
simtypes.RandomAccounts, // Replace with own random account function if using keys other than secp256k1
|
|
307
|
+
simtestutil.SimulationOperations(newApp, newApp.AppCodec(), config),
|
|
308
|
+
BlockedAddresses(),
|
|
309
|
+
config,
|
|
310
|
+
app.AppCodec(),
|
|
311
|
+
)
|
|
312
|
+
require.NoError(t, err)
|
|
77
313
|
}
|
|
78
314
|
|
|
79
|
-
//
|
|
80
|
-
//
|
|
315
|
+
// TODO: Make another test for the fuzzer itself, which just has noOp txs
|
|
316
|
+
// and doesn't depend on the application.
|
|
81
317
|
func TestAppStateDeterminism(t *testing.T) {
|
|
82
|
-
if !
|
|
318
|
+
if !simcli.FlagEnabledValue {
|
|
83
319
|
t.Skip("skipping application simulation")
|
|
84
320
|
}
|
|
85
321
|
|
|
86
|
-
config :=
|
|
322
|
+
config := simcli.NewConfigFromFlags()
|
|
87
323
|
config.InitialBlockHeight = 1
|
|
88
324
|
config.ExportParamsPath = ""
|
|
89
325
|
config.OnOperation = false
|
|
90
326
|
config.AllInvariants = false
|
|
91
|
-
config.ChainID =
|
|
327
|
+
config.ChainID = SimAppChainID
|
|
92
328
|
|
|
93
329
|
numSeeds := 3
|
|
94
330
|
numTimesToRunPerSeed := 5
|
|
331
|
+
|
|
332
|
+
// We will be overriding the random seed and just run a single simulation on the provided seed value
|
|
333
|
+
if config.Seed != simcli.DefaultSeedValue {
|
|
334
|
+
numSeeds = 1
|
|
335
|
+
}
|
|
336
|
+
|
|
95
337
|
appHashList := make([]json.RawMessage, numTimesToRunPerSeed)
|
|
338
|
+
appOptions := make(simtestutil.AppOptionsMap, 0)
|
|
339
|
+
appOptions[flags.FlagHome] = DefaultNodeHome
|
|
340
|
+
appOptions[server.FlagInvCheckPeriod] = simcli.FlagPeriodValue
|
|
96
341
|
|
|
97
342
|
for i := 0; i < numSeeds; i++ {
|
|
98
|
-
config.Seed
|
|
343
|
+
if config.Seed == simcli.DefaultSeedValue {
|
|
344
|
+
config.Seed = rand.Int63()
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
fmt.Println("config.Seed: ", config.Seed)
|
|
99
348
|
|
|
100
349
|
for j := 0; j < numTimesToRunPerSeed; j++ {
|
|
101
350
|
var logger log.Logger
|
|
102
|
-
if
|
|
351
|
+
if simcli.FlagVerboseValue {
|
|
103
352
|
logger = log.TestingLogger()
|
|
104
353
|
} else {
|
|
105
354
|
logger = log.NewNopLogger()
|
|
106
355
|
}
|
|
107
356
|
|
|
108
357
|
db := dbm.NewMemDB()
|
|
109
|
-
app :=
|
|
358
|
+
app := NewSimApp(logger, db, nil, true, appOptions, interBlockCacheOpt(), baseapp.SetChainID(SimAppChainID))
|
|
110
359
|
|
|
111
360
|
fmt.Printf(
|
|
112
361
|
"running non-determinism simulation; seed %d: %d/%d, attempt: %d/%d\n",
|
|
@@ -117,17 +366,17 @@ func TestAppStateDeterminism(t *testing.T) {
|
|
|
117
366
|
t,
|
|
118
367
|
os.Stdout,
|
|
119
368
|
app.BaseApp,
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
369
|
+
simtestutil.AppStateFn(app.AppCodec(), app.SimulationManager(), app.DefaultGenesis()),
|
|
370
|
+
simtypes.RandomAccounts, // Replace with own random account function if using keys other than secp256k1
|
|
371
|
+
simtestutil.SimulationOperations(app, app.AppCodec(), config),
|
|
372
|
+
BlockedAddresses(),
|
|
124
373
|
config,
|
|
125
374
|
app.AppCodec(),
|
|
126
375
|
)
|
|
127
376
|
require.NoError(t, err)
|
|
128
377
|
|
|
129
378
|
if config.Commit {
|
|
130
|
-
|
|
379
|
+
simtestutil.PrintStats(db)
|
|
131
380
|
}
|
|
132
381
|
|
|
133
382
|
appHash := app.LastCommitID().Hash
|
package/app/upgrade.go
CHANGED
|
@@ -6,9 +6,23 @@ import (
|
|
|
6
6
|
|
|
7
7
|
"github.com/Agoric/agoric-sdk/golang/cosmos/vm"
|
|
8
8
|
swingsetkeeper "github.com/Agoric/agoric-sdk/golang/cosmos/x/swingset/keeper"
|
|
9
|
+
"github.com/cosmos/cosmos-sdk/baseapp"
|
|
9
10
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
10
11
|
"github.com/cosmos/cosmos-sdk/types/module"
|
|
12
|
+
|
|
13
|
+
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
|
14
|
+
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
|
15
|
+
crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types"
|
|
16
|
+
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
|
|
17
|
+
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
|
|
18
|
+
govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
|
|
19
|
+
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
|
|
20
|
+
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
|
|
21
|
+
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
|
|
22
|
+
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
|
|
11
23
|
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
|
|
24
|
+
|
|
25
|
+
ibctmmigrations "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint/migrations"
|
|
12
26
|
)
|
|
13
27
|
|
|
14
28
|
var upgradeNamesOfThisVersion = []string{
|
|
@@ -140,11 +154,64 @@ func buildProposalStepFromScript(targetUpgrade string, builderScript string) (vm
|
|
|
140
154
|
)
|
|
141
155
|
}
|
|
142
156
|
|
|
143
|
-
//
|
|
144
|
-
func
|
|
157
|
+
// RegisterUpgradeHandlers registers the upgrade handlers for all upgradeNames.
|
|
158
|
+
func (app *GaiaApp) RegisterUpgradeHandlers() {
|
|
159
|
+
// Set param key table for params module migration
|
|
160
|
+
for _, subspace := range app.ParamsKeeper.GetSubspaces() {
|
|
161
|
+
subspace := subspace
|
|
162
|
+
|
|
163
|
+
var keyTable paramstypes.KeyTable
|
|
164
|
+
switch subspace.Name() {
|
|
165
|
+
case authtypes.ModuleName:
|
|
166
|
+
keyTable = authtypes.ParamKeyTable() //nolint:staticcheck
|
|
167
|
+
case banktypes.ModuleName:
|
|
168
|
+
keyTable = banktypes.ParamKeyTable() //nolint:staticcheck
|
|
169
|
+
case stakingtypes.ModuleName:
|
|
170
|
+
keyTable = stakingtypes.ParamKeyTable() //nolint:staticcheck
|
|
171
|
+
case minttypes.ModuleName:
|
|
172
|
+
keyTable = minttypes.ParamKeyTable() //nolint:staticcheck
|
|
173
|
+
case distrtypes.ModuleName:
|
|
174
|
+
keyTable = distrtypes.ParamKeyTable() //nolint:staticcheck
|
|
175
|
+
case slashingtypes.ModuleName:
|
|
176
|
+
keyTable = slashingtypes.ParamKeyTable() //nolint:staticcheck
|
|
177
|
+
case govtypes.ModuleName:
|
|
178
|
+
keyTable = govv1.ParamKeyTable() //nolint:staticcheck
|
|
179
|
+
case crisistypes.ModuleName:
|
|
180
|
+
keyTable = crisistypes.ParamKeyTable() //nolint:staticcheck
|
|
181
|
+
default:
|
|
182
|
+
continue
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
if !subspace.HasKeyTable() {
|
|
186
|
+
subspace.WithKeyTable(keyTable)
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
baseAppLegacySS := app.ParamsKeeper.Subspace(baseapp.Paramspace).WithKeyTable(paramstypes.ConsensusParamsKeyTable())
|
|
191
|
+
|
|
192
|
+
for _, name := range upgradeNamesOfThisVersion {
|
|
193
|
+
app.UpgradeKeeper.SetUpgradeHandler(
|
|
194
|
+
name,
|
|
195
|
+
makeUnreleasedUpgradeHandler(app, name, baseAppLegacySS),
|
|
196
|
+
)
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// makeUnreleasedUpgradeHandler performs standard upgrade actions plus custom actions for the unreleased upgrade.
|
|
201
|
+
func makeUnreleasedUpgradeHandler(app *GaiaApp, targetUpgrade string, baseAppLegacySS paramstypes.Subspace) func(sdk.Context, upgradetypes.Plan, module.VersionMap) (module.VersionMap, error) {
|
|
202
|
+
_ = targetUpgrade
|
|
145
203
|
return func(ctx sdk.Context, plan upgradetypes.Plan, fromVm module.VersionMap) (module.VersionMap, error) {
|
|
146
204
|
app.CheckControllerInited(false)
|
|
147
205
|
|
|
206
|
+
// prune expired tendermint consensus states to save storage space
|
|
207
|
+
_, err := ibctmmigrations.PruneExpiredConsensusStates(ctx, app.AppCodec(), app.IBCKeeper.ClientKeeper)
|
|
208
|
+
if err != nil {
|
|
209
|
+
return nil, err
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// Migrate Tendermint consensus parameters from x/params module to a dedicated x/consensus module.
|
|
213
|
+
baseapp.MigrateParams(ctx, baseAppLegacySS, &app.ConsensusParamsKeeper)
|
|
214
|
+
|
|
148
215
|
CoreProposalSteps := []vm.CoreProposalStep{}
|
|
149
216
|
|
|
150
217
|
// These CoreProposalSteps are not idempotent and should only be executed
|
|
@@ -215,7 +282,7 @@ func unreleasedUpgradeHandler(app *GaiaApp, targetUpgrade string) func(sdk.Conte
|
|
|
215
282
|
}
|
|
216
283
|
|
|
217
284
|
// Always run module migrations
|
|
218
|
-
mvm, err := app.
|
|
285
|
+
mvm, err := app.ModuleManager.RunMigrations(ctx, app.configurator, fromVm)
|
|
219
286
|
if err != nil {
|
|
220
287
|
return mvm, err
|
|
221
288
|
}
|
package/cmd/agd/agvm.go
CHANGED
package/cmd/agd/main.go
CHANGED
|
@@ -10,8 +10,8 @@ import (
|
|
|
10
10
|
"syscall"
|
|
11
11
|
"time"
|
|
12
12
|
|
|
13
|
+
"github.com/cometbft/cometbft/libs/log"
|
|
13
14
|
"github.com/spf13/cast"
|
|
14
|
-
"github.com/tendermint/tendermint/libs/log"
|
|
15
15
|
|
|
16
16
|
gaia "github.com/Agoric/agoric-sdk/golang/cosmos/app"
|
|
17
17
|
"github.com/Agoric/agoric-sdk/golang/cosmos/daemon"
|
package/cmd/libdaemon/main.go
CHANGED