@agoric/cosmos 0.34.2-dev-8d05faf.0 → 0.34.2-dev-d941b39.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/daemon/cmd/root.go +103 -44
- package/git-revision.txt +1 -1
- package/package.json +2 -2
package/daemon/cmd/root.go
CHANGED
|
@@ -8,7 +8,6 @@ import (
|
|
|
8
8
|
|
|
9
9
|
serverconfig "github.com/cosmos/cosmos-sdk/server/config"
|
|
10
10
|
|
|
11
|
-
"github.com/cosmos/cosmos-sdk/baseapp"
|
|
12
11
|
"github.com/cosmos/cosmos-sdk/client"
|
|
13
12
|
"github.com/cosmos/cosmos-sdk/client/config"
|
|
14
13
|
"github.com/cosmos/cosmos-sdk/client/debug"
|
|
@@ -19,9 +18,6 @@ import (
|
|
|
19
18
|
"github.com/cosmos/cosmos-sdk/client/snapshot"
|
|
20
19
|
"github.com/cosmos/cosmos-sdk/server"
|
|
21
20
|
servertypes "github.com/cosmos/cosmos-sdk/server/types"
|
|
22
|
-
"github.com/cosmos/cosmos-sdk/snapshots"
|
|
23
|
-
snapshottypes "github.com/cosmos/cosmos-sdk/snapshots/types"
|
|
24
|
-
"github.com/cosmos/cosmos-sdk/store"
|
|
25
21
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
26
22
|
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
|
|
27
23
|
"github.com/cosmos/cosmos-sdk/x/auth/types"
|
|
@@ -39,6 +35,7 @@ import (
|
|
|
39
35
|
gaia "github.com/Agoric/agoric-sdk/golang/cosmos/app"
|
|
40
36
|
"github.com/Agoric/agoric-sdk/golang/cosmos/app/params"
|
|
41
37
|
"github.com/Agoric/agoric-sdk/golang/cosmos/vm"
|
|
38
|
+
swingsetkeeper "github.com/Agoric/agoric-sdk/golang/cosmos/x/swingset/keeper"
|
|
42
39
|
)
|
|
43
40
|
|
|
44
41
|
var AppName = "agd"
|
|
@@ -142,16 +139,27 @@ func initRootCmd(sender vm.Sender, rootCmd *cobra.Command, encodingConfig params
|
|
|
142
139
|
testnetCmd(gaia.ModuleBasics, banktypes.GenesisBalancesIterator{}),
|
|
143
140
|
debug.Cmd(),
|
|
144
141
|
config.Cmd(),
|
|
145
|
-
pruning.Cmd(ac.
|
|
146
|
-
snapshot.Cmd(ac.
|
|
142
|
+
pruning.Cmd(ac.newSnapshotsApp, gaia.DefaultNodeHome),
|
|
143
|
+
snapshot.Cmd(ac.newSnapshotsApp),
|
|
147
144
|
)
|
|
148
145
|
|
|
149
146
|
server.AddCommands(rootCmd, gaia.DefaultNodeHome, ac.newApp, ac.appExport, addModuleInitFlags)
|
|
150
147
|
|
|
151
148
|
for _, command := range rootCmd.Commands() {
|
|
152
|
-
|
|
149
|
+
switch command.Name() {
|
|
150
|
+
case "export":
|
|
151
|
+
addAgoricVMFlags(command)
|
|
153
152
|
extendCosmosExportCommand(command)
|
|
154
|
-
|
|
153
|
+
case "snapshots":
|
|
154
|
+
for _, subCommand := range command.Commands() {
|
|
155
|
+
switch subCommand.Name() {
|
|
156
|
+
case "restore":
|
|
157
|
+
addAgoricVMFlags(subCommand)
|
|
158
|
+
case "export":
|
|
159
|
+
addAgoricVMFlags(subCommand)
|
|
160
|
+
replaceCosmosSnapshotExportCommand(subCommand, ac)
|
|
161
|
+
}
|
|
162
|
+
}
|
|
155
163
|
}
|
|
156
164
|
}
|
|
157
165
|
|
|
@@ -264,22 +272,13 @@ func (ac appCreator) newApp(
|
|
|
264
272
|
}
|
|
265
273
|
}
|
|
266
274
|
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
if cast.ToBool(appOpts.Get(server.FlagInterBlockCache)) {
|
|
270
|
-
cache = store.NewCommitKVStoreCacheManager()
|
|
271
|
-
}
|
|
275
|
+
baseappOptions := server.DefaultBaseappOptions(appOpts)
|
|
272
276
|
|
|
273
277
|
skipUpgradeHeights := make(map[int64]bool)
|
|
274
278
|
for _, h := range cast.ToIntSlice(appOpts.Get(server.FlagUnsafeSkipUpgrades)) {
|
|
275
279
|
skipUpgradeHeights[int64(h)] = true
|
|
276
280
|
}
|
|
277
281
|
|
|
278
|
-
pruningOpts, err := server.GetPruningOptionsFromFlags(appOpts)
|
|
279
|
-
if err != nil {
|
|
280
|
-
panic(err)
|
|
281
|
-
}
|
|
282
|
-
|
|
283
282
|
homePath := cast.ToString(appOpts.Get(flags.FlagHome))
|
|
284
283
|
|
|
285
284
|
// Set a default value for FlagSwingStoreExportDir based on the homePath
|
|
@@ -289,39 +288,41 @@ func (ac appCreator) newApp(
|
|
|
289
288
|
viper.Set(gaia.FlagSwingStoreExportDir, filepath.Join(homePath, "config", ExportedSwingStoreDirectoryName))
|
|
290
289
|
}
|
|
291
290
|
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
}
|
|
301
|
-
snapshotOptions := snapshottypes.NewSnapshotOptions(
|
|
302
|
-
cast.ToUint64(appOpts.Get(server.FlagStateSyncSnapshotInterval)),
|
|
303
|
-
cast.ToUint32(appOpts.Get(server.FlagStateSyncSnapshotKeepRecent)),
|
|
291
|
+
return gaia.NewAgoricApp(
|
|
292
|
+
ac.sender, ac.agdServer,
|
|
293
|
+
logger, db, traceStore, true, skipUpgradeHeights,
|
|
294
|
+
homePath,
|
|
295
|
+
cast.ToUint(appOpts.Get(server.FlagInvCheckPeriod)),
|
|
296
|
+
ac.encCfg,
|
|
297
|
+
appOpts,
|
|
298
|
+
baseappOptions...,
|
|
304
299
|
)
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
func (ac appCreator) newSnapshotsApp(
|
|
303
|
+
logger log.Logger,
|
|
304
|
+
db dbm.DB,
|
|
305
|
+
traceStore io.Writer,
|
|
306
|
+
appOpts servertypes.AppOptions,
|
|
307
|
+
) servertypes.Application {
|
|
308
|
+
if OnExportHook != nil {
|
|
309
|
+
if err := OnExportHook(ac.agdServer, logger, appOpts); err != nil {
|
|
310
|
+
panic(err)
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
baseappOptions := server.DefaultBaseappOptions(appOpts)
|
|
315
|
+
|
|
316
|
+
homePath := cast.ToString(appOpts.Get(flags.FlagHome))
|
|
305
317
|
|
|
306
318
|
return gaia.NewAgoricApp(
|
|
307
319
|
ac.sender, ac.agdServer,
|
|
308
|
-
logger, db, traceStore, true,
|
|
320
|
+
logger, db, traceStore, true, map[int64]bool{},
|
|
309
321
|
homePath,
|
|
310
322
|
cast.ToUint(appOpts.Get(server.FlagInvCheckPeriod)),
|
|
311
323
|
ac.encCfg,
|
|
312
324
|
appOpts,
|
|
313
|
-
|
|
314
|
-
baseapp.SetMinGasPrices(cast.ToString(appOpts.Get(server.FlagMinGasPrices))),
|
|
315
|
-
baseapp.SetHaltHeight(cast.ToUint64(appOpts.Get(server.FlagHaltHeight))),
|
|
316
|
-
baseapp.SetHaltTime(cast.ToUint64(appOpts.Get(server.FlagHaltTime))),
|
|
317
|
-
baseapp.SetMinRetainBlocks(cast.ToUint64(appOpts.Get(server.FlagMinRetainBlocks))),
|
|
318
|
-
baseapp.SetInterBlockCache(cache),
|
|
319
|
-
baseapp.SetTrace(cast.ToBool(appOpts.Get(server.FlagTrace))),
|
|
320
|
-
baseapp.SetIndexEvents(cast.ToStringSlice(appOpts.Get(server.FlagIndexEvents))),
|
|
321
|
-
baseapp.SetSnapshot(snapshotStore, snapshotOptions),
|
|
322
|
-
baseapp.SetIAVLCacheSize(cast.ToInt(appOpts.Get(server.FlagIAVLCacheSize))),
|
|
323
|
-
baseapp.SetIAVLDisableFastNode(cast.ToBool(appOpts.Get(server.FlagDisableIAVLFastNode))),
|
|
324
|
-
baseapp.SetIAVLLazyLoading(cast.ToBool(appOpts.Get(server.FlagIAVLLazyLoading))),
|
|
325
|
+
baseappOptions...,
|
|
325
326
|
)
|
|
326
327
|
}
|
|
327
328
|
|
|
@@ -342,7 +343,6 @@ const (
|
|
|
342
343
|
// cosmos-sdk to add a required "export-dir" command-line flag, and create the
|
|
343
344
|
// genesis export in the specified directory if the VM is running.
|
|
344
345
|
func extendCosmosExportCommand(cmd *cobra.Command) {
|
|
345
|
-
addAgoricVMFlags(cmd)
|
|
346
346
|
cmd.Flags().String(FlagExportDir, "", "The directory where to create the genesis export")
|
|
347
347
|
err := cmd.MarkFlagRequired(FlagExportDir)
|
|
348
348
|
if err != nil {
|
|
@@ -443,3 +443,62 @@ func (ac appCreator) appExport(
|
|
|
443
443
|
|
|
444
444
|
return gaiaApp.ExportAppStateAndValidators(forZeroHeight, jailAllowedAddrs)
|
|
445
445
|
}
|
|
446
|
+
|
|
447
|
+
// replaceCosmosSnapshotExportCommand monkey-patches the "snapshots export" command
|
|
448
|
+
// added by cosmos-sdk and replaces its implementation with one suitable for
|
|
449
|
+
// our modifications to the cosmos snapshots process
|
|
450
|
+
func replaceCosmosSnapshotExportCommand(cmd *cobra.Command, ac appCreator) {
|
|
451
|
+
// Copy of RunE is cosmos-sdk/client/snapshot/export.go
|
|
452
|
+
replacedRunE := func(cmd *cobra.Command, args []string) error {
|
|
453
|
+
ctx := server.GetServerContextFromCmd(cmd)
|
|
454
|
+
|
|
455
|
+
height, err := cmd.Flags().GetInt64("height")
|
|
456
|
+
if err != nil {
|
|
457
|
+
return err
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
home := ctx.Config.RootDir
|
|
461
|
+
dataDir := filepath.Join(home, "data")
|
|
462
|
+
db, err := dbm.NewDB("application", server.GetAppDBBackend(ctx.Viper), dataDir)
|
|
463
|
+
if err != nil {
|
|
464
|
+
return err
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
app := ac.newSnapshotsApp(ctx.Logger, db, nil, ctx.Viper)
|
|
468
|
+
gaiaApp := app.(*gaia.GaiaApp)
|
|
469
|
+
|
|
470
|
+
if height == 0 {
|
|
471
|
+
height = app.CommitMultiStore().LastCommitID().Version
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
cmd.Printf("Exporting snapshot for height %d\n", height)
|
|
475
|
+
|
|
476
|
+
err = gaiaApp.SwingSetSnapshotter.InitiateSnapshot(height)
|
|
477
|
+
if err != nil {
|
|
478
|
+
return err
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
err = swingsetkeeper.WaitUntilSwingStoreExportDone()
|
|
482
|
+
if err != nil {
|
|
483
|
+
return err
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
snapshotList, err := app.SnapshotManager().List()
|
|
487
|
+
if err != nil {
|
|
488
|
+
return err
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
snapshotHeight := uint64(height)
|
|
492
|
+
|
|
493
|
+
for _, snapshot := range snapshotList {
|
|
494
|
+
if snapshot.Height == snapshotHeight {
|
|
495
|
+
cmd.Printf("Snapshot created at height %d, format %d, chunks %d\n", snapshot.Height, snapshot.Format, snapshot.Chunks)
|
|
496
|
+
break
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
return nil
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
cmd.RunE = replacedRunE
|
|
504
|
+
}
|
package/git-revision.txt
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
d941b39
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/cosmos",
|
|
3
|
-
"version": "0.34.2-dev-
|
|
3
|
+
"version": "0.34.2-dev-d941b39.0+d941b39",
|
|
4
4
|
"description": "Connect JS to the Cosmos blockchain SDK",
|
|
5
5
|
"parsers": {
|
|
6
6
|
"js": "mjs"
|
|
@@ -39,5 +39,5 @@
|
|
|
39
39
|
"typeCoverage": {
|
|
40
40
|
"atLeast": 0
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "d941b39f33c41c1e0f9350f95533fcdc15edc404"
|
|
43
43
|
}
|