@agoric/cosmos 0.35.0-u15.0 → 0.35.0-u16.1

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.
Files changed (131) hide show
  1. package/CHANGELOG.md +123 -143
  2. package/MAINTAINERS.md +3 -0
  3. package/Makefile +36 -26
  4. package/ante/ante.go +6 -5
  5. package/ante/inbound_test.go +3 -2
  6. package/ante/vm_admission.go +2 -1
  7. package/app/app.go +206 -147
  8. package/app/upgrade.go +77 -0
  9. package/cmd/agd/agvm.go +42 -0
  10. package/cmd/agd/main.go +130 -11
  11. package/cmd/libdaemon/main.go +64 -53
  12. package/cmd/libdaemon/main_test.go +2 -1
  13. package/daemon/cmd/root.go +164 -74
  14. package/daemon/cmd/root_test.go +189 -1
  15. package/daemon/main.go +4 -2
  16. package/e2e_test/Makefile +29 -0
  17. package/e2e_test/README.md +100 -0
  18. package/e2e_test/go.mod +217 -0
  19. package/e2e_test/go.sum +1323 -0
  20. package/e2e_test/ibc_conformance_test.go +56 -0
  21. package/e2e_test/pfm_test.go +613 -0
  22. package/e2e_test/util.go +271 -0
  23. package/git-revision.txt +1 -1
  24. package/go.mod +12 -7
  25. package/go.sum +13 -9
  26. package/package.json +8 -4
  27. package/proto/agoric/swingset/genesis.proto +4 -0
  28. package/proto/agoric/swingset/swingset.proto +1 -1
  29. package/proto/agoric/vlocalchain/.clang-format +7 -0
  30. package/proto/agoric/vlocalchain/vlocalchain.proto +31 -0
  31. package/proto/agoric/vtransfer/genesis.proto +18 -0
  32. package/scripts/protocgen.sh +7 -8
  33. package/types/kv_entry_helpers.go +42 -0
  34. package/upgradegaia.sh +8 -8
  35. package/vm/action.go +5 -4
  36. package/vm/action_test.go +31 -11
  37. package/vm/client.go +113 -0
  38. package/vm/client_test.go +182 -0
  39. package/vm/controller.go +17 -40
  40. package/vm/core_proposals.go +22 -2
  41. package/vm/jsonrpcconn/jsonrpcconn.go +160 -0
  42. package/vm/jsonrpcconn/jsonrpcconn_test.go +126 -0
  43. package/vm/proto_json.go +38 -0
  44. package/vm/proto_json_test.go +103 -0
  45. package/vm/server.go +124 -0
  46. package/x/swingset/abci.go +10 -10
  47. package/x/swingset/alias.go +2 -0
  48. package/x/swingset/client/cli/tx.go +4 -0
  49. package/x/swingset/genesis.go +84 -24
  50. package/x/swingset/handler.go +2 -1
  51. package/x/swingset/keeper/extension_snapshotter.go +2 -2
  52. package/x/swingset/keeper/keeper.go +13 -25
  53. package/x/swingset/keeper/msg_server.go +18 -18
  54. package/x/swingset/keeper/proposal.go +3 -3
  55. package/x/swingset/keeper/querier.go +12 -11
  56. package/x/swingset/keeper/swing_store_exports_handler.go +16 -5
  57. package/x/swingset/keeper/test_utils.go +16 -0
  58. package/x/swingset/module.go +7 -7
  59. package/x/swingset/proposal_handler.go +2 -1
  60. package/x/swingset/testing/queue.go +17 -0
  61. package/x/swingset/types/default-params.go +1 -1
  62. package/x/swingset/types/expected_keepers.go +3 -2
  63. package/x/swingset/types/genesis.pb.go +78 -25
  64. package/x/swingset/types/msgs.go +44 -24
  65. package/x/swingset/types/params.go +2 -1
  66. package/x/swingset/types/proposal.go +5 -4
  67. package/x/swingset/types/swingset.pb.go +1 -1
  68. package/x/vbank/genesis.go +0 -2
  69. package/x/vbank/handler.go +2 -1
  70. package/x/vbank/keeper/querier.go +4 -3
  71. package/x/vbank/module.go +0 -5
  72. package/x/vbank/types/msgs.go +0 -12
  73. package/x/vbank/vbank.go +9 -9
  74. package/x/vbank/vbank_test.go +2 -2
  75. package/x/vibc/alias.go +3 -0
  76. package/x/vibc/handler.go +16 -9
  77. package/x/vibc/keeper/keeper.go +102 -65
  78. package/x/vibc/keeper/triggers.go +101 -0
  79. package/x/vibc/module.go +5 -8
  80. package/x/vibc/types/expected_keepers.go +13 -0
  81. package/x/vibc/types/ibc_module.go +336 -0
  82. package/x/vibc/types/receiver.go +170 -0
  83. package/x/vlocalchain/alias.go +19 -0
  84. package/x/vlocalchain/handler.go +21 -0
  85. package/x/vlocalchain/keeper/keeper.go +279 -0
  86. package/x/vlocalchain/keeper/keeper_test.go +97 -0
  87. package/x/vlocalchain/types/codec.go +34 -0
  88. package/x/vlocalchain/types/key.go +27 -0
  89. package/x/vlocalchain/types/msgs.go +16 -0
  90. package/x/vlocalchain/types/vlocalchain.pb.go +1072 -0
  91. package/x/vlocalchain/vlocalchain.go +114 -0
  92. package/x/vlocalchain/vlocalchain_test.go +434 -0
  93. package/x/vstorage/handler.go +2 -1
  94. package/x/vstorage/keeper/grpc_query.go +0 -1
  95. package/x/vstorage/keeper/keeper.go +13 -20
  96. package/x/vstorage/keeper/querier.go +6 -5
  97. package/x/vstorage/keeper/querier_test.go +4 -3
  98. package/x/vstorage/module.go +0 -5
  99. package/x/vstorage/testing/queue.go +27 -0
  100. package/x/vtransfer/alias.go +13 -0
  101. package/x/vtransfer/genesis.go +39 -0
  102. package/x/vtransfer/genesis_test.go +12 -0
  103. package/x/vtransfer/handler.go +20 -0
  104. package/x/vtransfer/ibc_middleware.go +186 -0
  105. package/x/vtransfer/ibc_middleware_test.go +448 -0
  106. package/x/vtransfer/keeper/keeper.go +281 -0
  107. package/x/vtransfer/module.go +124 -0
  108. package/x/vtransfer/types/expected_keepers.go +38 -0
  109. package/x/vtransfer/types/genesis.pb.go +327 -0
  110. package/x/vtransfer/types/key.go +9 -0
  111. package/x/vtransfer/types/msgs.go +9 -0
  112. package/proto/agoric/lien/genesis.proto +0 -25
  113. package/proto/agoric/lien/lien.proto +0 -25
  114. package/x/lien/alias.go +0 -17
  115. package/x/lien/genesis.go +0 -58
  116. package/x/lien/genesis_test.go +0 -101
  117. package/x/lien/keeper/account.go +0 -290
  118. package/x/lien/keeper/keeper.go +0 -255
  119. package/x/lien/keeper/keeper_test.go +0 -623
  120. package/x/lien/lien.go +0 -205
  121. package/x/lien/lien_test.go +0 -533
  122. package/x/lien/module.go +0 -115
  123. package/x/lien/spec/01_concepts.md +0 -146
  124. package/x/lien/spec/02_messages.md +0 -96
  125. package/x/lien/types/accountkeeper.go +0 -81
  126. package/x/lien/types/accountstate.go +0 -27
  127. package/x/lien/types/expected_keepers.go +0 -18
  128. package/x/lien/types/genesis.pb.go +0 -567
  129. package/x/lien/types/key.go +0 -25
  130. package/x/lien/types/lien.pb.go +0 -403
  131. package/x/vibc/ibc.go +0 -394
@@ -1,15 +1,14 @@
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"
@@ -20,9 +19,6 @@ import (
20
19
  "github.com/cosmos/cosmos-sdk/client/snapshot"
21
20
  "github.com/cosmos/cosmos-sdk/server"
22
21
  servertypes "github.com/cosmos/cosmos-sdk/server/types"
23
- "github.com/cosmos/cosmos-sdk/snapshots"
24
- snapshottypes "github.com/cosmos/cosmos-sdk/snapshots/types"
25
- "github.com/cosmos/cosmos-sdk/store"
26
22
  sdk "github.com/cosmos/cosmos-sdk/types"
27
23
  authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
28
24
  "github.com/cosmos/cosmos-sdk/x/auth/types"
@@ -39,18 +35,17 @@ import (
39
35
 
40
36
  gaia "github.com/Agoric/agoric-sdk/golang/cosmos/app"
41
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"
42
40
  )
43
41
 
44
- // Sender is a function that sends a request to the controller.
45
- type Sender func(ctx context.Context, needReply bool, str string) (string, error)
46
-
47
42
  var AppName = "agd"
48
- var OnStartHook func(log.Logger, servertypes.AppOptions) error
49
- 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
50
45
 
51
46
  // NewRootCmd creates a new root command for simd. It is called once in the
52
47
  // main function.
53
- func NewRootCmd(sender Sender) (*cobra.Command, params.EncodingConfig) {
48
+ func NewRootCmd(sender vm.Sender) (*cobra.Command, params.EncodingConfig) {
54
49
  encodingConfig := gaia.MakeEncodingConfig()
55
50
  initClientCtx := client.Context{}.
56
51
  WithCodec(encodingConfig.Marshaler).
@@ -124,13 +119,14 @@ func initAppConfig() (string, interface{}) {
124
119
  return serverconfig.DefaultConfigTemplate, *srvCfg
125
120
  }
126
121
 
127
- func initRootCmd(sender Sender, rootCmd *cobra.Command, encodingConfig params.EncodingConfig) {
122
+ func initRootCmd(sender vm.Sender, rootCmd *cobra.Command, encodingConfig params.EncodingConfig) {
128
123
  cfg := sdk.GetConfig()
129
124
  cfg.Seal()
130
125
 
131
126
  ac := appCreator{
132
- encCfg: encodingConfig,
133
- sender: sender,
127
+ encCfg: encodingConfig,
128
+ sender: sender,
129
+ agdServer: vm.NewAgdServer(),
134
130
  }
135
131
 
136
132
  rootCmd.AddCommand(
@@ -144,17 +140,27 @@ func initRootCmd(sender Sender, rootCmd *cobra.Command, encodingConfig params.En
144
140
  testnetCmd(gaia.ModuleBasics, banktypes.GenesisBalancesIterator{}),
145
141
  debug.Cmd(),
146
142
  config.Cmd(),
147
- pruning.Cmd(ac.newApp, gaia.DefaultNodeHome),
148
- snapshot.Cmd(ac.newApp),
143
+ pruning.Cmd(ac.newSnapshotsApp, gaia.DefaultNodeHome),
144
+ snapshot.Cmd(ac.newSnapshotsApp),
149
145
  )
150
146
 
151
147
  server.AddCommands(rootCmd, gaia.DefaultNodeHome, ac.newApp, ac.appExport, addModuleInitFlags)
152
148
 
153
- hasVMController := sender != nil
154
149
  for _, command := range rootCmd.Commands() {
155
- if command.Name() == "export" {
156
- extendCosmosExportCommand(command, hasVMController)
157
- break
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
+ }
158
164
  }
159
165
  }
160
166
 
@@ -169,7 +175,30 @@ func initRootCmd(sender Sender, rootCmd *cobra.Command, encodingConfig params.En
169
175
  rootCmd.AddCommand(server.RosettaCommand(encodingConfig.InterfaceRegistry, encodingConfig.Marshaler))
170
176
  }
171
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
+
172
200
  func addModuleInitFlags(startCmd *cobra.Command) {
201
+ addAgoricVMFlags(startCmd)
173
202
  }
174
203
 
175
204
  func queryCommand() *cobra.Command {
@@ -227,8 +256,9 @@ func txCommand() *cobra.Command {
227
256
  }
228
257
 
229
258
  type appCreator struct {
230
- encCfg params.EncodingConfig
231
- sender Sender
259
+ encCfg params.EncodingConfig
260
+ sender vm.Sender
261
+ agdServer *vm.AgdServer
232
262
  }
233
263
 
234
264
  func (ac appCreator) newApp(
@@ -238,27 +268,18 @@ func (ac appCreator) newApp(
238
268
  appOpts servertypes.AppOptions,
239
269
  ) servertypes.Application {
240
270
  if OnStartHook != nil {
241
- if err := OnStartHook(logger, appOpts); err != nil {
271
+ if err := OnStartHook(ac.agdServer, logger, appOpts); err != nil {
242
272
  panic(err)
243
273
  }
244
274
  }
245
275
 
246
- var cache sdk.MultiStorePersistentCache
247
-
248
- if cast.ToBool(appOpts.Get(server.FlagInterBlockCache)) {
249
- cache = store.NewCommitKVStoreCacheManager()
250
- }
276
+ baseappOptions := server.DefaultBaseappOptions(appOpts)
251
277
 
252
278
  skipUpgradeHeights := make(map[int64]bool)
253
279
  for _, h := range cast.ToIntSlice(appOpts.Get(server.FlagUnsafeSkipUpgrades)) {
254
280
  skipUpgradeHeights[int64(h)] = true
255
281
  }
256
282
 
257
- pruningOpts, err := server.GetPruningOptionsFromFlags(appOpts)
258
- if err != nil {
259
- panic(err)
260
- }
261
-
262
283
  homePath := cast.ToString(appOpts.Get(flags.FlagHome))
263
284
 
264
285
  // Set a default value for FlagSwingStoreExportDir based on the homePath
@@ -268,36 +289,41 @@ func (ac appCreator) newApp(
268
289
  viper.Set(gaia.FlagSwingStoreExportDir, filepath.Join(homePath, "config", ExportedSwingStoreDirectoryName))
269
290
  }
270
291
 
271
- snapshotDir := filepath.Join(homePath, "data", "snapshots")
272
- snapshotDB, err := sdk.NewLevelDB("metadata", snapshotDir)
273
- if err != nil {
274
- panic(err)
275
- }
276
- snapshotStore, err := snapshots.NewStore(snapshotDB, snapshotDir)
277
- if err != nil {
278
- panic(err)
279
- }
280
- snapshotOptions := snapshottypes.NewSnapshotOptions(
281
- cast.ToUint64(appOpts.Get(server.FlagStateSyncSnapshotInterval)),
282
- 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...,
283
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))
284
318
 
285
319
  return gaia.NewAgoricApp(
286
- ac.sender,
287
- logger, db, traceStore, true, skipUpgradeHeights,
320
+ ac.sender, ac.agdServer,
321
+ logger, db, traceStore, true, map[int64]bool{},
288
322
  homePath,
289
323
  cast.ToUint(appOpts.Get(server.FlagInvCheckPeriod)),
290
324
  ac.encCfg,
291
325
  appOpts,
292
- baseapp.SetPruning(pruningOpts),
293
- baseapp.SetMinGasPrices(cast.ToString(appOpts.Get(server.FlagMinGasPrices))),
294
- baseapp.SetHaltHeight(cast.ToUint64(appOpts.Get(server.FlagHaltHeight))),
295
- baseapp.SetHaltTime(cast.ToUint64(appOpts.Get(server.FlagHaltTime))),
296
- baseapp.SetMinRetainBlocks(cast.ToUint64(appOpts.Get(server.FlagMinRetainBlocks))),
297
- baseapp.SetInterBlockCache(cache),
298
- baseapp.SetTrace(cast.ToBool(appOpts.Get(server.FlagTrace))),
299
- baseapp.SetIndexEvents(cast.ToStringSlice(appOpts.Get(server.FlagIndexEvents))),
300
- baseapp.SetSnapshot(snapshotStore, snapshotOptions),
326
+ baseappOptions...,
301
327
  )
302
328
  }
303
329
 
@@ -316,8 +342,8 @@ const (
316
342
 
317
343
  // extendCosmosExportCommand monkey-patches the "export" command added by
318
344
  // cosmos-sdk to add a required "export-dir" command-line flag, and create the
319
- // genesis export in the specified directory.
320
- func extendCosmosExportCommand(cmd *cobra.Command, hasVMController bool) {
345
+ // genesis export in the specified directory if the VM is running.
346
+ func extendCosmosExportCommand(cmd *cobra.Command) {
321
347
  cmd.Flags().String(FlagExportDir, "", "The directory where to create the genesis export")
322
348
  err := cmd.MarkFlagRequired(FlagExportDir)
323
349
  if err != nil {
@@ -348,25 +374,28 @@ func extendCosmosExportCommand(cmd *cobra.Command, hasVMController bool) {
348
374
  // current genesis.
349
375
  serverCtx.Viper.Set(gaia.FlagSwingStoreExportDir, swingStoreExportPath)
350
376
 
351
- // This will fail is a genesis.json already exists in the export-dir
352
- genesisFile, err := os.OpenFile(genesisPath, os.O_CREATE|os.O_EXCL|os.O_WRONLY, os.ModePerm)
353
- if err != nil {
354
- return err
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)
355
390
  }
356
- defer genesisFile.Close()
357
-
358
- cmd.SetOut(genesisFile)
359
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.
360
395
  return originalRunE(cmd, args)
361
396
  }
362
397
 
363
- // Only modify the command handler when we have a VM controller to handle
364
- // the full export logic. Otherwise, appExport will just exec the VM program
365
- // (OnExportHook), which will result in re-entering this flow with the VM
366
- // controller set.
367
- if hasVMController {
368
- cmd.RunE = extendedRunE
369
- }
398
+ cmd.RunE = extendedRunE
370
399
  }
371
400
 
372
401
  func (ac appCreator) appExport(
@@ -379,7 +408,7 @@ func (ac appCreator) appExport(
379
408
  appOpts servertypes.AppOptions,
380
409
  ) (servertypes.ExportedApp, error) {
381
410
  if OnExportHook != nil {
382
- if err := OnExportHook(logger, appOpts); err != nil {
411
+ if err := OnExportHook(ac.agdServer, logger, appOpts); err != nil {
383
412
  return servertypes.ExportedApp{}, err
384
413
  }
385
414
  }
@@ -395,7 +424,7 @@ func (ac appCreator) appExport(
395
424
  }
396
425
 
397
426
  gaiaApp := gaia.NewAgoricApp(
398
- ac.sender,
427
+ ac.sender, ac.agdServer,
399
428
  logger,
400
429
  db,
401
430
  traceStore,
@@ -415,3 +444,64 @@ func (ac appCreator) appExport(
415
444
 
416
445
  return gaiaApp.ExportAppStateAndValidators(forZeroHeight, jailAllowedAddrs)
417
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
+ }
@@ -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, str string) (string, error) {
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 cmd.Sender) {
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