@agoric/cosmos 0.35.0-upgrade-14-dev-c8f9e7b.0 → 0.35.0-upgrade-16a-dev-fb592e4.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/CHANGELOG.md +121 -77
- package/MAINTAINERS.md +3 -0
- package/Makefile +36 -26
- package/ante/ante.go +7 -9
- package/ante/inbound_test.go +3 -2
- package/ante/vm_admission.go +2 -1
- package/app/app.go +212 -140
- package/app/upgrade.go +76 -0
- package/cmd/agd/agvm.go +42 -0
- package/cmd/agd/main.go +130 -11
- package/cmd/libdaemon/main.go +64 -53
- package/cmd/libdaemon/main_test.go +2 -1
- package/daemon/cmd/root.go +171 -74
- package/daemon/cmd/root_test.go +189 -1
- package/daemon/main.go +4 -2
- package/e2e_test/Makefile +29 -0
- package/e2e_test/README.md +100 -0
- package/e2e_test/go.mod +217 -0
- package/e2e_test/go.sum +1323 -0
- package/e2e_test/ibc_conformance_test.go +56 -0
- package/e2e_test/pfm_test.go +613 -0
- package/e2e_test/util.go +271 -0
- package/git-revision.txt +1 -1
- package/go.mod +22 -11
- package/go.sum +17 -13
- package/package.json +9 -5
- package/proto/agoric/swingset/genesis.proto +4 -0
- package/proto/agoric/swingset/swingset.proto +1 -1
- package/proto/agoric/vlocalchain/.clang-format +7 -0
- package/proto/agoric/vlocalchain/vlocalchain.proto +31 -0
- package/proto/agoric/vtransfer/genesis.proto +18 -0
- package/scripts/protocgen.sh +7 -8
- package/types/kv_entry_helpers.go +42 -0
- package/upgradegaia.sh +8 -8
- package/vm/action.go +5 -4
- package/vm/action_test.go +31 -11
- package/vm/client.go +113 -0
- package/vm/client_test.go +182 -0
- package/vm/controller.go +17 -40
- package/vm/core_proposals.go +22 -2
- package/vm/jsonrpcconn/jsonrpcconn.go +160 -0
- package/vm/jsonrpcconn/jsonrpcconn_test.go +126 -0
- package/vm/proto_json.go +38 -0
- package/vm/proto_json_test.go +103 -0
- package/vm/server.go +124 -0
- package/x/swingset/abci.go +10 -10
- package/x/swingset/alias.go +2 -0
- package/x/swingset/client/cli/tx.go +4 -0
- package/x/swingset/genesis.go +84 -24
- package/x/swingset/handler.go +2 -1
- package/x/swingset/keeper/extension_snapshotter.go +2 -2
- package/x/swingset/keeper/keeper.go +13 -25
- package/x/swingset/keeper/msg_server.go +18 -18
- package/x/swingset/keeper/proposal.go +3 -3
- package/x/swingset/keeper/querier.go +12 -11
- package/x/swingset/keeper/swing_store_exports_handler.go +21 -6
- package/x/swingset/keeper/test_utils.go +16 -0
- package/x/swingset/module.go +7 -7
- package/x/swingset/proposal_handler.go +2 -1
- package/x/swingset/testing/queue.go +17 -0
- package/x/swingset/types/default-params.go +1 -1
- package/x/swingset/types/expected_keepers.go +3 -2
- package/x/swingset/types/genesis.pb.go +78 -25
- package/x/swingset/types/msgs.go +44 -24
- package/x/swingset/types/params.go +2 -1
- package/x/swingset/types/proposal.go +5 -4
- package/x/swingset/types/swingset.pb.go +1 -1
- package/x/vbank/genesis.go +0 -2
- package/x/vbank/handler.go +2 -1
- package/x/vbank/keeper/querier.go +4 -3
- package/x/vbank/module.go +0 -5
- package/x/vbank/types/msgs.go +0 -12
- package/x/vbank/vbank.go +9 -9
- package/x/vbank/vbank_test.go +2 -2
- package/x/vibc/alias.go +3 -0
- package/x/vibc/handler.go +16 -9
- package/x/vibc/keeper/keeper.go +102 -65
- package/x/vibc/keeper/triggers.go +101 -0
- package/x/vibc/module.go +5 -8
- package/x/vibc/types/expected_keepers.go +13 -0
- package/x/vibc/types/ibc_module.go +336 -0
- package/x/vibc/types/receiver.go +170 -0
- package/x/vlocalchain/alias.go +19 -0
- package/x/vlocalchain/handler.go +21 -0
- package/x/vlocalchain/keeper/keeper.go +279 -0
- package/x/vlocalchain/keeper/keeper_test.go +97 -0
- package/x/vlocalchain/types/codec.go +34 -0
- package/x/vlocalchain/types/key.go +27 -0
- package/x/vlocalchain/types/msgs.go +16 -0
- package/x/vlocalchain/types/vlocalchain.pb.go +1072 -0
- package/x/vlocalchain/vlocalchain.go +114 -0
- package/x/vlocalchain/vlocalchain_test.go +434 -0
- package/x/vstorage/handler.go +2 -1
- package/x/vstorage/keeper/grpc_query.go +0 -1
- package/x/vstorage/keeper/keeper.go +13 -20
- package/x/vstorage/keeper/querier.go +6 -5
- package/x/vstorage/keeper/querier_test.go +4 -3
- package/x/vstorage/module.go +0 -5
- package/x/vstorage/testing/queue.go +27 -0
- package/x/vtransfer/alias.go +13 -0
- package/x/vtransfer/genesis.go +39 -0
- package/x/vtransfer/genesis_test.go +12 -0
- package/x/vtransfer/handler.go +20 -0
- package/x/vtransfer/ibc_middleware.go +186 -0
- package/x/vtransfer/ibc_middleware_test.go +448 -0
- package/x/vtransfer/keeper/keeper.go +281 -0
- package/x/vtransfer/module.go +124 -0
- package/x/vtransfer/types/expected_keepers.go +38 -0
- package/x/vtransfer/types/genesis.pb.go +327 -0
- package/x/vtransfer/types/key.go +9 -0
- package/x/vtransfer/types/msgs.go +9 -0
- package/ante/fee.go +0 -96
- package/proto/agoric/lien/genesis.proto +0 -25
- package/proto/agoric/lien/lien.proto +0 -25
- package/x/lien/alias.go +0 -17
- package/x/lien/genesis.go +0 -58
- package/x/lien/genesis_test.go +0 -101
- package/x/lien/keeper/account.go +0 -290
- package/x/lien/keeper/keeper.go +0 -255
- package/x/lien/keeper/keeper_test.go +0 -623
- package/x/lien/lien.go +0 -205
- package/x/lien/lien_test.go +0 -533
- package/x/lien/module.go +0 -115
- package/x/lien/spec/01_concepts.md +0 -146
- package/x/lien/spec/02_messages.md +0 -96
- package/x/lien/types/accountkeeper.go +0 -81
- package/x/lien/types/accountstate.go +0 -27
- package/x/lien/types/expected_keepers.go +0 -18
- package/x/lien/types/genesis.pb.go +0 -567
- package/x/lien/types/key.go +0 -25
- package/x/lien/types/lien.pb.go +0 -403
- package/x/vibc/ibc.go +0 -394
- /package/{src/index.cjs → index.cjs} +0 -0
package/daemon/cmd/root.go
CHANGED
|
@@ -1,26 +1,24 @@
|
|
|
1
1
|
package cmd
|
|
2
2
|
|
|
3
3
|
import (
|
|
4
|
-
"context"
|
|
5
4
|
"errors"
|
|
5
|
+
"fmt"
|
|
6
6
|
"io"
|
|
7
7
|
"os"
|
|
8
8
|
"path/filepath"
|
|
9
9
|
|
|
10
10
|
serverconfig "github.com/cosmos/cosmos-sdk/server/config"
|
|
11
11
|
|
|
12
|
-
"github.com/cosmos/cosmos-sdk/baseapp"
|
|
13
12
|
"github.com/cosmos/cosmos-sdk/client"
|
|
14
13
|
"github.com/cosmos/cosmos-sdk/client/config"
|
|
15
14
|
"github.com/cosmos/cosmos-sdk/client/debug"
|
|
16
15
|
"github.com/cosmos/cosmos-sdk/client/flags"
|
|
17
16
|
"github.com/cosmos/cosmos-sdk/client/keys"
|
|
17
|
+
"github.com/cosmos/cosmos-sdk/client/pruning"
|
|
18
18
|
"github.com/cosmos/cosmos-sdk/client/rpc"
|
|
19
|
+
"github.com/cosmos/cosmos-sdk/client/snapshot"
|
|
19
20
|
"github.com/cosmos/cosmos-sdk/server"
|
|
20
21
|
servertypes "github.com/cosmos/cosmos-sdk/server/types"
|
|
21
|
-
"github.com/cosmos/cosmos-sdk/snapshots"
|
|
22
|
-
snapshottypes "github.com/cosmos/cosmos-sdk/snapshots/types"
|
|
23
|
-
"github.com/cosmos/cosmos-sdk/store"
|
|
24
22
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
25
23
|
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
|
|
26
24
|
"github.com/cosmos/cosmos-sdk/x/auth/types"
|
|
@@ -37,18 +35,17 @@ import (
|
|
|
37
35
|
|
|
38
36
|
gaia "github.com/Agoric/agoric-sdk/golang/cosmos/app"
|
|
39
37
|
"github.com/Agoric/agoric-sdk/golang/cosmos/app/params"
|
|
38
|
+
"github.com/Agoric/agoric-sdk/golang/cosmos/vm"
|
|
39
|
+
swingsetkeeper "github.com/Agoric/agoric-sdk/golang/cosmos/x/swingset/keeper"
|
|
40
40
|
)
|
|
41
41
|
|
|
42
|
-
// Sender is a function that sends a request to the controller.
|
|
43
|
-
type Sender func(ctx context.Context, needReply bool, str string) (string, error)
|
|
44
|
-
|
|
45
42
|
var AppName = "agd"
|
|
46
|
-
var OnStartHook func(log.Logger, servertypes.AppOptions) error
|
|
47
|
-
var OnExportHook func(log.Logger, servertypes.AppOptions) error
|
|
43
|
+
var OnStartHook func(*vm.AgdServer, log.Logger, servertypes.AppOptions) error
|
|
44
|
+
var OnExportHook func(*vm.AgdServer, log.Logger, servertypes.AppOptions) error
|
|
48
45
|
|
|
49
46
|
// NewRootCmd creates a new root command for simd. It is called once in the
|
|
50
47
|
// main function.
|
|
51
|
-
func NewRootCmd(sender Sender) (*cobra.Command, params.EncodingConfig) {
|
|
48
|
+
func NewRootCmd(sender vm.Sender) (*cobra.Command, params.EncodingConfig) {
|
|
52
49
|
encodingConfig := gaia.MakeEncodingConfig()
|
|
53
50
|
initClientCtx := client.Context{}.
|
|
54
51
|
WithCodec(encodingConfig.Marshaler).
|
|
@@ -122,13 +119,20 @@ func initAppConfig() (string, interface{}) {
|
|
|
122
119
|
return serverconfig.DefaultConfigTemplate, *srvCfg
|
|
123
120
|
}
|
|
124
121
|
|
|
125
|
-
func initRootCmd(sender Sender, rootCmd *cobra.Command, encodingConfig params.EncodingConfig) {
|
|
122
|
+
func initRootCmd(sender vm.Sender, rootCmd *cobra.Command, encodingConfig params.EncodingConfig) {
|
|
126
123
|
cfg := sdk.GetConfig()
|
|
127
124
|
cfg.Seal()
|
|
128
125
|
|
|
126
|
+
ac := appCreator{
|
|
127
|
+
encCfg: encodingConfig,
|
|
128
|
+
sender: sender,
|
|
129
|
+
agdServer: vm.NewAgdServer(),
|
|
130
|
+
}
|
|
131
|
+
|
|
129
132
|
rootCmd.AddCommand(
|
|
130
133
|
genutilcli.InitCmd(gaia.ModuleBasics, gaia.DefaultNodeHome),
|
|
131
134
|
genutilcli.CollectGenTxsCmd(banktypes.GenesisBalancesIterator{}, gaia.DefaultNodeHome),
|
|
135
|
+
genutilcli.MigrateGenesisCmd(),
|
|
132
136
|
genutilcli.GenTxCmd(gaia.ModuleBasics, encodingConfig.TxConfig, banktypes.GenesisBalancesIterator{}, gaia.DefaultNodeHome),
|
|
133
137
|
genutilcli.ValidateGenesisCmd(gaia.ModuleBasics),
|
|
134
138
|
AddGenesisAccountCmd(encodingConfig.Marshaler, gaia.DefaultNodeHome),
|
|
@@ -136,19 +140,27 @@ func initRootCmd(sender Sender, rootCmd *cobra.Command, encodingConfig params.En
|
|
|
136
140
|
testnetCmd(gaia.ModuleBasics, banktypes.GenesisBalancesIterator{}),
|
|
137
141
|
debug.Cmd(),
|
|
138
142
|
config.Cmd(),
|
|
143
|
+
pruning.Cmd(ac.newSnapshotsApp, gaia.DefaultNodeHome),
|
|
144
|
+
snapshot.Cmd(ac.newSnapshotsApp),
|
|
139
145
|
)
|
|
140
146
|
|
|
141
|
-
ac := appCreator{
|
|
142
|
-
encCfg: encodingConfig,
|
|
143
|
-
sender: sender,
|
|
144
|
-
}
|
|
145
147
|
server.AddCommands(rootCmd, gaia.DefaultNodeHome, ac.newApp, ac.appExport, addModuleInitFlags)
|
|
146
148
|
|
|
147
|
-
hasVMController := sender != nil
|
|
148
149
|
for _, command := range rootCmd.Commands() {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
150
|
+
switch command.Name() {
|
|
151
|
+
case "export":
|
|
152
|
+
addAgoricVMFlags(command)
|
|
153
|
+
extendCosmosExportCommand(command)
|
|
154
|
+
case "snapshots":
|
|
155
|
+
for _, subCommand := range command.Commands() {
|
|
156
|
+
switch subCommand.Name() {
|
|
157
|
+
case "restore":
|
|
158
|
+
addAgoricVMFlags(subCommand)
|
|
159
|
+
case "export":
|
|
160
|
+
addAgoricVMFlags(subCommand)
|
|
161
|
+
replaceCosmosSnapshotExportCommand(subCommand, ac)
|
|
162
|
+
}
|
|
163
|
+
}
|
|
152
164
|
}
|
|
153
165
|
}
|
|
154
166
|
|
|
@@ -163,7 +175,30 @@ func initRootCmd(sender Sender, rootCmd *cobra.Command, encodingConfig params.En
|
|
|
163
175
|
rootCmd.AddCommand(server.RosettaCommand(encodingConfig.InterfaceRegistry, encodingConfig.Marshaler))
|
|
164
176
|
}
|
|
165
177
|
|
|
178
|
+
const (
|
|
179
|
+
// FlagSplitVm is the command-line flag for subcommands that can use a
|
|
180
|
+
// split-process Agoric VM. The default is to use an embedded VM.
|
|
181
|
+
FlagSplitVm = "split-vm"
|
|
182
|
+
EmbeddedVmEnvVar = "AGD_EMBEDDED_VM"
|
|
183
|
+
)
|
|
184
|
+
|
|
185
|
+
// hasVMController returns true if we have a VM (are running in split-vm mode,
|
|
186
|
+
// or with an embedded VM).
|
|
187
|
+
func hasVMController(serverCtx *server.Context) bool {
|
|
188
|
+
return serverCtx.Viper.GetString(FlagSplitVm) != "" ||
|
|
189
|
+
os.Getenv(EmbeddedVmEnvVar) != ""
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
func addAgoricVMFlags(cmd *cobra.Command) {
|
|
193
|
+
cmd.PersistentFlags().String(
|
|
194
|
+
FlagSplitVm,
|
|
195
|
+
"",
|
|
196
|
+
"Specify the external Agoric VM program",
|
|
197
|
+
)
|
|
198
|
+
}
|
|
199
|
+
|
|
166
200
|
func addModuleInitFlags(startCmd *cobra.Command) {
|
|
201
|
+
addAgoricVMFlags(startCmd)
|
|
167
202
|
}
|
|
168
203
|
|
|
169
204
|
func queryCommand() *cobra.Command {
|
|
@@ -209,6 +244,7 @@ func txCommand() *cobra.Command {
|
|
|
209
244
|
authcmd.GetBroadcastCommand(),
|
|
210
245
|
authcmd.GetEncodeCommand(),
|
|
211
246
|
authcmd.GetDecodeCommand(),
|
|
247
|
+
authcmd.GetAuxToFeeCommand(),
|
|
212
248
|
flags.LineBreak,
|
|
213
249
|
vestingcli.GetTxCmd(),
|
|
214
250
|
)
|
|
@@ -220,8 +256,9 @@ func txCommand() *cobra.Command {
|
|
|
220
256
|
}
|
|
221
257
|
|
|
222
258
|
type appCreator struct {
|
|
223
|
-
encCfg
|
|
224
|
-
sender
|
|
259
|
+
encCfg params.EncodingConfig
|
|
260
|
+
sender vm.Sender
|
|
261
|
+
agdServer *vm.AgdServer
|
|
225
262
|
}
|
|
226
263
|
|
|
227
264
|
func (ac appCreator) newApp(
|
|
@@ -231,27 +268,18 @@ func (ac appCreator) newApp(
|
|
|
231
268
|
appOpts servertypes.AppOptions,
|
|
232
269
|
) servertypes.Application {
|
|
233
270
|
if OnStartHook != nil {
|
|
234
|
-
if err := OnStartHook(logger, appOpts); err != nil {
|
|
271
|
+
if err := OnStartHook(ac.agdServer, logger, appOpts); err != nil {
|
|
235
272
|
panic(err)
|
|
236
273
|
}
|
|
237
274
|
}
|
|
238
275
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
if cast.ToBool(appOpts.Get(server.FlagInterBlockCache)) {
|
|
242
|
-
cache = store.NewCommitKVStoreCacheManager()
|
|
243
|
-
}
|
|
276
|
+
baseappOptions := server.DefaultBaseappOptions(appOpts)
|
|
244
277
|
|
|
245
278
|
skipUpgradeHeights := make(map[int64]bool)
|
|
246
279
|
for _, h := range cast.ToIntSlice(appOpts.Get(server.FlagUnsafeSkipUpgrades)) {
|
|
247
280
|
skipUpgradeHeights[int64(h)] = true
|
|
248
281
|
}
|
|
249
282
|
|
|
250
|
-
pruningOpts, err := server.GetPruningOptionsFromFlags(appOpts)
|
|
251
|
-
if err != nil {
|
|
252
|
-
panic(err)
|
|
253
|
-
}
|
|
254
|
-
|
|
255
283
|
homePath := cast.ToString(appOpts.Get(flags.FlagHome))
|
|
256
284
|
|
|
257
285
|
// Set a default value for FlagSwingStoreExportDir based on the homePath
|
|
@@ -261,36 +289,41 @@ func (ac appCreator) newApp(
|
|
|
261
289
|
viper.Set(gaia.FlagSwingStoreExportDir, filepath.Join(homePath, "config", ExportedSwingStoreDirectoryName))
|
|
262
290
|
}
|
|
263
291
|
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
}
|
|
273
|
-
snapshotOptions := snapshottypes.NewSnapshotOptions(
|
|
274
|
-
cast.ToUint64(appOpts.Get(server.FlagStateSyncSnapshotInterval)),
|
|
275
|
-
cast.ToUint32(appOpts.Get(server.FlagStateSyncSnapshotKeepRecent)),
|
|
292
|
+
return gaia.NewAgoricApp(
|
|
293
|
+
ac.sender, ac.agdServer,
|
|
294
|
+
logger, db, traceStore, true, skipUpgradeHeights,
|
|
295
|
+
homePath,
|
|
296
|
+
cast.ToUint(appOpts.Get(server.FlagInvCheckPeriod)),
|
|
297
|
+
ac.encCfg,
|
|
298
|
+
appOpts,
|
|
299
|
+
baseappOptions...,
|
|
276
300
|
)
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
func (ac appCreator) newSnapshotsApp(
|
|
304
|
+
logger log.Logger,
|
|
305
|
+
db dbm.DB,
|
|
306
|
+
traceStore io.Writer,
|
|
307
|
+
appOpts servertypes.AppOptions,
|
|
308
|
+
) servertypes.Application {
|
|
309
|
+
if OnExportHook != nil {
|
|
310
|
+
if err := OnExportHook(ac.agdServer, logger, appOpts); err != nil {
|
|
311
|
+
panic(err)
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
baseappOptions := server.DefaultBaseappOptions(appOpts)
|
|
316
|
+
|
|
317
|
+
homePath := cast.ToString(appOpts.Get(flags.FlagHome))
|
|
277
318
|
|
|
278
319
|
return gaia.NewAgoricApp(
|
|
279
|
-
ac.sender,
|
|
280
|
-
logger, db, traceStore, true,
|
|
320
|
+
ac.sender, ac.agdServer,
|
|
321
|
+
logger, db, traceStore, true, map[int64]bool{},
|
|
281
322
|
homePath,
|
|
282
323
|
cast.ToUint(appOpts.Get(server.FlagInvCheckPeriod)),
|
|
283
324
|
ac.encCfg,
|
|
284
325
|
appOpts,
|
|
285
|
-
|
|
286
|
-
baseapp.SetMinGasPrices(cast.ToString(appOpts.Get(server.FlagMinGasPrices))),
|
|
287
|
-
baseapp.SetHaltHeight(cast.ToUint64(appOpts.Get(server.FlagHaltHeight))),
|
|
288
|
-
baseapp.SetHaltTime(cast.ToUint64(appOpts.Get(server.FlagHaltTime))),
|
|
289
|
-
baseapp.SetMinRetainBlocks(cast.ToUint64(appOpts.Get(server.FlagMinRetainBlocks))),
|
|
290
|
-
baseapp.SetInterBlockCache(cache),
|
|
291
|
-
baseapp.SetTrace(cast.ToBool(appOpts.Get(server.FlagTrace))),
|
|
292
|
-
baseapp.SetIndexEvents(cast.ToStringSlice(appOpts.Get(server.FlagIndexEvents))),
|
|
293
|
-
baseapp.SetSnapshot(snapshotStore, snapshotOptions),
|
|
326
|
+
baseappOptions...,
|
|
294
327
|
)
|
|
295
328
|
}
|
|
296
329
|
|
|
@@ -309,8 +342,8 @@ const (
|
|
|
309
342
|
|
|
310
343
|
// extendCosmosExportCommand monkey-patches the "export" command added by
|
|
311
344
|
// cosmos-sdk to add a required "export-dir" command-line flag, and create the
|
|
312
|
-
// genesis export in the specified directory.
|
|
313
|
-
func extendCosmosExportCommand(cmd *cobra.Command
|
|
345
|
+
// genesis export in the specified directory if the VM is running.
|
|
346
|
+
func extendCosmosExportCommand(cmd *cobra.Command) {
|
|
314
347
|
cmd.Flags().String(FlagExportDir, "", "The directory where to create the genesis export")
|
|
315
348
|
err := cmd.MarkFlagRequired(FlagExportDir)
|
|
316
349
|
if err != nil {
|
|
@@ -341,25 +374,28 @@ func extendCosmosExportCommand(cmd *cobra.Command, hasVMController bool) {
|
|
|
341
374
|
// current genesis.
|
|
342
375
|
serverCtx.Viper.Set(gaia.FlagSwingStoreExportDir, swingStoreExportPath)
|
|
343
376
|
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
377
|
+
if hasVMController(serverCtx) {
|
|
378
|
+
// Capture the export in the genesisPath.
|
|
379
|
+
// This will fail if a genesis.json already exists in the export-dir
|
|
380
|
+
genesisFile, err := os.OpenFile(
|
|
381
|
+
genesisPath,
|
|
382
|
+
os.O_CREATE|os.O_EXCL|os.O_WRONLY,
|
|
383
|
+
os.ModePerm,
|
|
384
|
+
)
|
|
385
|
+
if err != nil {
|
|
386
|
+
return err
|
|
387
|
+
}
|
|
388
|
+
defer genesisFile.Close()
|
|
389
|
+
cmd.SetOut(genesisFile)
|
|
348
390
|
}
|
|
349
|
-
defer genesisFile.Close()
|
|
350
|
-
|
|
351
|
-
cmd.SetOut(genesisFile)
|
|
352
391
|
|
|
392
|
+
// If we don't have a VM, appExport will just use the OnExportHook to exec
|
|
393
|
+
// the VM program, which will result in reentering this function with the VM
|
|
394
|
+
// controller set, and activate the above condition.
|
|
353
395
|
return originalRunE(cmd, args)
|
|
354
396
|
}
|
|
355
397
|
|
|
356
|
-
|
|
357
|
-
// the full export logic. Otherwise, appExport will just exec the VM program
|
|
358
|
-
// (OnExportHook), which will result in re-entering this flow with the VM
|
|
359
|
-
// controller set.
|
|
360
|
-
if hasVMController {
|
|
361
|
-
cmd.RunE = extendedRunE
|
|
362
|
-
}
|
|
398
|
+
cmd.RunE = extendedRunE
|
|
363
399
|
}
|
|
364
400
|
|
|
365
401
|
func (ac appCreator) appExport(
|
|
@@ -372,7 +408,7 @@ func (ac appCreator) appExport(
|
|
|
372
408
|
appOpts servertypes.AppOptions,
|
|
373
409
|
) (servertypes.ExportedApp, error) {
|
|
374
410
|
if OnExportHook != nil {
|
|
375
|
-
if err := OnExportHook(logger, appOpts); err != nil {
|
|
411
|
+
if err := OnExportHook(ac.agdServer, logger, appOpts); err != nil {
|
|
376
412
|
return servertypes.ExportedApp{}, err
|
|
377
413
|
}
|
|
378
414
|
}
|
|
@@ -388,7 +424,7 @@ func (ac appCreator) appExport(
|
|
|
388
424
|
}
|
|
389
425
|
|
|
390
426
|
gaiaApp := gaia.NewAgoricApp(
|
|
391
|
-
ac.sender,
|
|
427
|
+
ac.sender, ac.agdServer,
|
|
392
428
|
logger,
|
|
393
429
|
db,
|
|
394
430
|
traceStore,
|
|
@@ -408,3 +444,64 @@ func (ac appCreator) appExport(
|
|
|
408
444
|
|
|
409
445
|
return gaiaApp.ExportAppStateAndValidators(forZeroHeight, jailAllowedAddrs)
|
|
410
446
|
}
|
|
447
|
+
|
|
448
|
+
// replaceCosmosSnapshotExportCommand monkey-patches the "snapshots export" command
|
|
449
|
+
// added by cosmos-sdk and replaces its implementation with one suitable for
|
|
450
|
+
// our modifications to the cosmos snapshots process
|
|
451
|
+
func replaceCosmosSnapshotExportCommand(cmd *cobra.Command, ac appCreator) {
|
|
452
|
+
// Copy of RunE is cosmos-sdk/client/snapshot/export.go
|
|
453
|
+
replacedRunE := func(cmd *cobra.Command, args []string) error {
|
|
454
|
+
ctx := server.GetServerContextFromCmd(cmd)
|
|
455
|
+
|
|
456
|
+
heightFlag, err := cmd.Flags().GetInt64("height")
|
|
457
|
+
if err != nil {
|
|
458
|
+
return err
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
home := ctx.Config.RootDir
|
|
462
|
+
dataDir := filepath.Join(home, "data")
|
|
463
|
+
db, err := dbm.NewDB("application", server.GetAppDBBackend(ctx.Viper), dataDir)
|
|
464
|
+
if err != nil {
|
|
465
|
+
return err
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
app := ac.newSnapshotsApp(ctx.Logger, db, nil, ctx.Viper)
|
|
469
|
+
gaiaApp := app.(*gaia.GaiaApp)
|
|
470
|
+
|
|
471
|
+
latestHeight := app.CommitMultiStore().LastCommitID().Version
|
|
472
|
+
|
|
473
|
+
if heightFlag != 0 && latestHeight != heightFlag {
|
|
474
|
+
return fmt.Errorf("cannot export at height %d, only latest height %d is supported", heightFlag, latestHeight)
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
cmd.Printf("Exporting snapshot for height %d\n", latestHeight)
|
|
478
|
+
|
|
479
|
+
err = gaiaApp.SwingSetSnapshotter.InitiateSnapshot(latestHeight)
|
|
480
|
+
if err != nil {
|
|
481
|
+
return err
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
err = swingsetkeeper.WaitUntilSwingStoreExportDone()
|
|
485
|
+
if err != nil {
|
|
486
|
+
return err
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
snapshotList, err := app.SnapshotManager().List()
|
|
490
|
+
if err != nil {
|
|
491
|
+
return err
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
snapshotHeight := uint64(latestHeight)
|
|
495
|
+
|
|
496
|
+
for _, snapshot := range snapshotList {
|
|
497
|
+
if snapshot.Height == snapshotHeight {
|
|
498
|
+
cmd.Printf("Snapshot created at height %d, format %d, chunks %d\n", snapshot.Height, snapshot.Format, snapshot.Chunks)
|
|
499
|
+
break
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
return nil
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
cmd.RunE = replacedRunE
|
|
507
|
+
}
|
package/daemon/cmd/root_test.go
CHANGED
|
@@ -1,13 +1,24 @@
|
|
|
1
1
|
package cmd_test
|
|
2
2
|
|
|
3
3
|
import (
|
|
4
|
+
"bytes"
|
|
5
|
+
"io"
|
|
6
|
+
"os"
|
|
4
7
|
"testing"
|
|
8
|
+
"text/template"
|
|
5
9
|
|
|
10
|
+
"github.com/spf13/pflag"
|
|
11
|
+
"github.com/stretchr/testify/require"
|
|
12
|
+
|
|
13
|
+
"github.com/cosmos/cosmos-sdk/server"
|
|
6
14
|
svrcmd "github.com/cosmos/cosmos-sdk/server/cmd"
|
|
15
|
+
serverconfig "github.com/cosmos/cosmos-sdk/server/config"
|
|
16
|
+
servertypes "github.com/cosmos/cosmos-sdk/server/types"
|
|
17
|
+
"github.com/tendermint/tendermint/libs/log"
|
|
18
|
+
dbm "github.com/tendermint/tm-db"
|
|
7
19
|
|
|
8
20
|
app "github.com/Agoric/agoric-sdk/golang/cosmos/app"
|
|
9
21
|
"github.com/Agoric/agoric-sdk/golang/cosmos/daemon/cmd"
|
|
10
|
-
"github.com/stretchr/testify/require"
|
|
11
22
|
)
|
|
12
23
|
|
|
13
24
|
func TestRootCmdConfig(t *testing.T) {
|
|
@@ -21,3 +32,180 @@ func TestRootCmdConfig(t *testing.T) {
|
|
|
21
32
|
|
|
22
33
|
require.NoError(t, svrcmd.Execute(rootCmd, "", app.DefaultNodeHome))
|
|
23
34
|
}
|
|
35
|
+
|
|
36
|
+
func TestCLIFlags(t *testing.T) {
|
|
37
|
+
// List of flags we have so far observed as used by the base cosmos sdk
|
|
38
|
+
// Before adding any flag to this list, the author should audit if explicit
|
|
39
|
+
// handling should not be added in the Agoric app (most likely in root.go)
|
|
40
|
+
expectedFlagNames := map[string]interface{}{
|
|
41
|
+
"abci": "",
|
|
42
|
+
"abci-client-type": "",
|
|
43
|
+
"address": "",
|
|
44
|
+
"app-db-backend": "",
|
|
45
|
+
"cpu-profile": "",
|
|
46
|
+
"db_backend": "",
|
|
47
|
+
"db_dir": "",
|
|
48
|
+
"fast_sync": "",
|
|
49
|
+
"genesis_hash": "",
|
|
50
|
+
"grpc-only": "",
|
|
51
|
+
"halt-height": "",
|
|
52
|
+
"halt-time": "",
|
|
53
|
+
"home": "",
|
|
54
|
+
"iavl-cache-size": "",
|
|
55
|
+
"iavl-disable-fastnode": "",
|
|
56
|
+
"iavl-lazy-loading": "",
|
|
57
|
+
"index-events": "",
|
|
58
|
+
"inter-block-cache": "",
|
|
59
|
+
"inv-check-period": "",
|
|
60
|
+
"min-retain-blocks": "",
|
|
61
|
+
"minimum-gas-prices": "",
|
|
62
|
+
"moniker": "",
|
|
63
|
+
"priv_validator_laddr": "",
|
|
64
|
+
"proxy_app": "",
|
|
65
|
+
"pruning": "default",
|
|
66
|
+
"pruning-interval": "",
|
|
67
|
+
"pruning-keep-recent": "",
|
|
68
|
+
"trace": "",
|
|
69
|
+
"trace-store": "",
|
|
70
|
+
"transport": "",
|
|
71
|
+
"unsafe-skip-upgrades": "",
|
|
72
|
+
"with-tendermint": "",
|
|
73
|
+
|
|
74
|
+
"api.address": "",
|
|
75
|
+
"api.enable": "",
|
|
76
|
+
"api.enabled-unsafe-cors": "",
|
|
77
|
+
"api.max-open-connections": "",
|
|
78
|
+
"api.rpc-max-body-bytes": "",
|
|
79
|
+
"api.rpc-read-timeout": "",
|
|
80
|
+
"api.rpc-write-timeout": "",
|
|
81
|
+
"api.swagger": "",
|
|
82
|
+
|
|
83
|
+
"consensus.create_empty_blocks": "",
|
|
84
|
+
"consensus.create_empty_blocks_interval": "",
|
|
85
|
+
"consensus.double_sign_check_height": "",
|
|
86
|
+
|
|
87
|
+
"grpc-web.address": "",
|
|
88
|
+
"grpc-web.enable": "",
|
|
89
|
+
"grpc-web.enable-unsafe-cors": "",
|
|
90
|
+
|
|
91
|
+
"grpc.address": "",
|
|
92
|
+
"grpc.enable": "",
|
|
93
|
+
"grpc.max-recv-msg-size": "",
|
|
94
|
+
"grpc.max-send-msg-size": "",
|
|
95
|
+
|
|
96
|
+
"p2p.external-address": "",
|
|
97
|
+
"p2p.laddr": "",
|
|
98
|
+
"p2p.persistent_peers": "",
|
|
99
|
+
"p2p.pex": "",
|
|
100
|
+
"p2p.private_peer_ids": "",
|
|
101
|
+
"p2p.seed_mode": "",
|
|
102
|
+
"p2p.seeds": "",
|
|
103
|
+
"p2p.unconditional_peer_ids": "",
|
|
104
|
+
"p2p.upnp": "",
|
|
105
|
+
|
|
106
|
+
"rpc.grpc_laddr": "",
|
|
107
|
+
"rpc.laddr": "",
|
|
108
|
+
"rpc.pprof_laddr": "",
|
|
109
|
+
"rpc.unsafe": "",
|
|
110
|
+
|
|
111
|
+
"rosetta.address": "",
|
|
112
|
+
"rosetta.blockchain": "",
|
|
113
|
+
"rosetta.denom-to-suggest": "",
|
|
114
|
+
"rosetta.enable-fee-suggestion": "",
|
|
115
|
+
"rosetta.enable": "",
|
|
116
|
+
"rosetta.gas-to-suggest": "",
|
|
117
|
+
"rosetta.network": "",
|
|
118
|
+
"rosetta.offline": "",
|
|
119
|
+
"rosetta.retries": "",
|
|
120
|
+
|
|
121
|
+
"state-sync.snapshot-interval": "",
|
|
122
|
+
"state-sync.snapshot-keep-recent": "",
|
|
123
|
+
|
|
124
|
+
"store.streamers": "",
|
|
125
|
+
|
|
126
|
+
"streamers.file.fsync": "",
|
|
127
|
+
"streamers.file.keys": "",
|
|
128
|
+
"streamers.file.output-metadata": "",
|
|
129
|
+
"streamers.file.prefix": "",
|
|
130
|
+
"streamers.file.stop-node-on-error": "",
|
|
131
|
+
"streamers.file.write_dir": "",
|
|
132
|
+
|
|
133
|
+
"telemetry.enable-hostname-label": "",
|
|
134
|
+
"telemetry.enable-hostname": "",
|
|
135
|
+
"telemetry.enable-service-label": "",
|
|
136
|
+
"telemetry.enabled": "",
|
|
137
|
+
"telemetry.global-labels": "",
|
|
138
|
+
"telemetry.prometheus-retention-time": "",
|
|
139
|
+
"telemetry.service-name": "",
|
|
140
|
+
}
|
|
141
|
+
unknownFlagNames := []string{}
|
|
142
|
+
missingFlagNames := map[string]bool{}
|
|
143
|
+
for name := range expectedFlagNames {
|
|
144
|
+
missingFlagNames[name] = true
|
|
145
|
+
}
|
|
146
|
+
readFlag := func(name string) interface{} {
|
|
147
|
+
if defaultValue, found := expectedFlagNames[name]; found {
|
|
148
|
+
delete(missingFlagNames, name)
|
|
149
|
+
return defaultValue
|
|
150
|
+
}
|
|
151
|
+
unknownFlagNames = append(unknownFlagNames, name)
|
|
152
|
+
return nil
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
homeDir, err := os.MkdirTemp("", "cosmos-sdk-home")
|
|
156
|
+
if err != nil {
|
|
157
|
+
panic(err)
|
|
158
|
+
}
|
|
159
|
+
defer os.RemoveAll(homeDir)
|
|
160
|
+
|
|
161
|
+
// First get the command line flags that the base cosmos-sdk defines
|
|
162
|
+
dummyAppCreator := func(
|
|
163
|
+
logger log.Logger,
|
|
164
|
+
db dbm.DB,
|
|
165
|
+
traceStore io.Writer,
|
|
166
|
+
appOpts servertypes.AppOptions,
|
|
167
|
+
) servertypes.Application {
|
|
168
|
+
return new(app.GaiaApp)
|
|
169
|
+
}
|
|
170
|
+
cmd := server.StartCmd(dummyAppCreator, homeDir)
|
|
171
|
+
flags := cmd.Flags()
|
|
172
|
+
flags.SortFlags = true
|
|
173
|
+
flags.VisitAll(func(flag *pflag.Flag) {
|
|
174
|
+
readFlag(flag.Name)
|
|
175
|
+
})
|
|
176
|
+
|
|
177
|
+
// Then get the options parsing the default config file.
|
|
178
|
+
serverCtx := server.NewDefaultContext()
|
|
179
|
+
// appTemplate, appConfig := initAppConfig()
|
|
180
|
+
appTemplate := serverconfig.DefaultConfigTemplate
|
|
181
|
+
appConfig := serverconfig.DefaultConfig()
|
|
182
|
+
configTemplate := template.Must(template.New("").Parse(appTemplate))
|
|
183
|
+
var buffer bytes.Buffer
|
|
184
|
+
if err := configTemplate.Execute(&buffer, appConfig); err != nil {
|
|
185
|
+
panic(err)
|
|
186
|
+
}
|
|
187
|
+
serverCtx.Viper.SetConfigType("toml")
|
|
188
|
+
if err := serverCtx.Viper.MergeConfig(&buffer); err != nil {
|
|
189
|
+
panic(err)
|
|
190
|
+
}
|
|
191
|
+
for _, configKey := range serverCtx.Viper.AllKeys() {
|
|
192
|
+
readFlag(configKey)
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
if len(unknownFlagNames) != 0 {
|
|
196
|
+
t.Error(
|
|
197
|
+
"unknown CLI flags in cosmos-sdk; incorporate as needed and update this test",
|
|
198
|
+
unknownFlagNames,
|
|
199
|
+
)
|
|
200
|
+
}
|
|
201
|
+
if len(missingFlagNames) != 0 {
|
|
202
|
+
missing := []string{}
|
|
203
|
+
for name := range missingFlagNames {
|
|
204
|
+
missing = append(missing, name)
|
|
205
|
+
}
|
|
206
|
+
t.Error(
|
|
207
|
+
"expected CLI flags missing from cosmos-sdk; remove from this test",
|
|
208
|
+
missing,
|
|
209
|
+
)
|
|
210
|
+
}
|
|
211
|
+
}
|
package/daemon/main.go
CHANGED
|
@@ -13,12 +13,13 @@ import (
|
|
|
13
13
|
"github.com/Agoric/agoric-sdk/golang/cosmos/agoric"
|
|
14
14
|
app "github.com/Agoric/agoric-sdk/golang/cosmos/app"
|
|
15
15
|
"github.com/Agoric/agoric-sdk/golang/cosmos/daemon/cmd"
|
|
16
|
+
"github.com/Agoric/agoric-sdk/golang/cosmos/vm"
|
|
16
17
|
|
|
17
18
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
18
19
|
)
|
|
19
20
|
|
|
20
21
|
// DefaultController is a stub controller.
|
|
21
|
-
var DefaultController = func(ctx context.Context, needReply bool,
|
|
22
|
+
var DefaultController vm.Sender = func(ctx context.Context, needReply bool, jsonRequest string) (jsonReply string, err error) {
|
|
22
23
|
return "", fmt.Errorf("Controller not configured; did you mean to use `ag-chain-cosmos` instead?")
|
|
23
24
|
}
|
|
24
25
|
|
|
@@ -28,13 +29,14 @@ func Run() {
|
|
|
28
29
|
}
|
|
29
30
|
|
|
30
31
|
// RunWithController starts the app with a custom upcall handler.
|
|
31
|
-
func RunWithController(sendToController
|
|
32
|
+
func RunWithController(sendToController vm.Sender) {
|
|
32
33
|
// Exit on Control-C and kill.
|
|
33
34
|
// Without this explicitly, ag-chain-cosmos ignores them.
|
|
34
35
|
sigs := make(chan os.Signal, 1)
|
|
35
36
|
signal.Notify(sigs, os.Interrupt, syscall.SIGINT, syscall.SIGTERM)
|
|
36
37
|
go func() {
|
|
37
38
|
<-sigs
|
|
39
|
+
_, _ = sendToController(context.Background(), false, "shutdown")
|
|
38
40
|
os.Exit(98)
|
|
39
41
|
}()
|
|
40
42
|
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# It is possible to use environment variables to change how the tests run
|
|
2
|
+
# - `E2ETEST_CHAINNAME0` - set to `"agoric"`, `"gaia"`, or another chain known by interchaintest to choose which chain runs as the first chain
|
|
3
|
+
# - `E2ETEST_CHAINNAME1` - set to `"agoric"`, `"gaia"`, or another chain known by interchaintest to choose which chain runs as the second chain
|
|
4
|
+
# - `E2ETEST_CHAINNAME2` - set to `"agoric"`, `"gaia"`, or another chain known by interchaintest to choose which chain runs as the third chain
|
|
5
|
+
# - `E2ETEST_CHAINNAME3` - set to `"agoric"`, `"gaia"`, or another chain known by interchaintest to choose which chain runs as the fourth chain
|
|
6
|
+
# - `E2ETEST_CHAINIMAGE_AGORIC` - the value of this will be used specific the repository & version of docker image to use for the agoric chain. a valid value must have a semicolon and be formatted as `repository:tag`. ex: `E2ETEST_CHAINIMAGE_AGORIC="ghcr.io/agoric/agoricinterchain:latest"`
|
|
7
|
+
# - `E2ETEST_RELAYERNAME` - set to `"cosmos"` or `"hermes"` to choose the relayer type
|
|
8
|
+
# - `E2ETEST_BLOCKS_TO_WAIT` - set to a number to control how many blocks to wait for an ACK from an IBC transfer and how many blocks to wait for TX settlement.
|
|
9
|
+
all: TestConformance TestPFM
|
|
10
|
+
|
|
11
|
+
# build - Sanity compile the tests
|
|
12
|
+
build:
|
|
13
|
+
go test -c -o ./bin/agoricinterchaintest
|
|
14
|
+
|
|
15
|
+
# TestPFM - use 4 chains to test PFM
|
|
16
|
+
TestPFM:
|
|
17
|
+
# Add a 20min timeout since tests are slow
|
|
18
|
+
# Add failfast since each test depends on the next
|
|
19
|
+
go test -failfast -timeout 20m -v -run ^TestPFM
|
|
20
|
+
|
|
21
|
+
# TestConformance - use 2 chains to test basic IBC conformance
|
|
22
|
+
TestConformance:
|
|
23
|
+
# Add a 20min timeout since tests are slow
|
|
24
|
+
go test -timeout 20m -v -run ^TestConformance
|
|
25
|
+
|
|
26
|
+
# TestChainPair - Minimal version of TestConformance does less permutations
|
|
27
|
+
TestChainPair:
|
|
28
|
+
# Add a 20min timeout since tests are slow
|
|
29
|
+
go test -timeout 20m -v -run ^TestChainPair
|