@agoric/cosmos 0.34.2-orchestration-dev-096c4e8.0 → 0.34.2-other-dev-3eb1a1d.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/MAINTAINERS.md +3 -0
- package/Makefile +38 -34
- package/ante/ante.go +1 -4
- package/ante/inbound_test.go +2 -2
- package/app/app.go +198 -137
- package/app/upgrade.go +248 -0
- package/cmd/agd/agvm.go +3 -3
- package/cmd/agd/find_binary.go +2 -2
- package/cmd/agd/main.go +9 -10
- package/cmd/libdaemon/main.go +13 -13
- package/daemon/cmd/root.go +235 -92
- package/daemon/cmd/root_test.go +189 -1
- package/daemon/main.go +3 -2
- package/git-revision.txt +1 -1
- package/go.mod +14 -11
- package/go.sum +20 -19
- package/index.cjs +1 -1
- package/package.json +4 -3
- package/proto/agoric/swingset/genesis.proto +4 -0
- package/proto/agoric/swingset/swingset.proto +26 -1
- package/proto/agoric/vbank/vbank.proto +7 -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/util/util.go +21 -0
- package/vm/action.go +1 -1
- package/vm/client.go +15 -13
- package/vm/client_test.go +34 -36
- package/vm/controller.go +3 -38
- package/vm/core_proposals.go +22 -2
- package/vm/proto_json.go +38 -0
- package/vm/proto_json_test.go +103 -0
- package/vm/server.go +106 -5
- package/x/swingset/alias.go +2 -0
- package/x/swingset/config.go +234 -0
- package/x/swingset/genesis.go +178 -40
- package/x/swingset/keeper/extension_snapshotter.go +2 -2
- package/x/swingset/keeper/keeper.go +24 -27
- package/x/swingset/keeper/swing_store_exports_handler.go +14 -3
- package/x/swingset/keeper/test_utils.go +16 -0
- package/x/swingset/module.go +24 -9
- package/x/swingset/testing/queue.go +17 -0
- package/x/swingset/types/default-params.go +31 -5
- package/x/swingset/types/expected_keepers.go +2 -2
- package/x/swingset/types/genesis.pb.go +78 -25
- package/x/swingset/types/msgs.go +53 -12
- package/x/swingset/types/params.go +53 -43
- package/x/swingset/types/params_test.go +75 -9
- package/x/swingset/types/swingset.pb.go +387 -57
- package/x/vbank/README.md +6 -1
- package/x/vbank/genesis.go +0 -2
- package/x/vbank/keeper/keeper.go +4 -9
- package/x/vbank/keeper/migrations.go +30 -0
- package/x/vbank/module.go +8 -7
- package/x/vbank/types/key.go +3 -3
- package/x/vbank/types/msgs.go +0 -12
- package/x/vbank/types/params.go +43 -2
- package/x/vbank/types/vbank.pb.go +105 -36
- package/x/vbank/vbank.go +8 -13
- package/x/vbank/vbank_test.go +14 -9
- package/x/vibc/alias.go +1 -1
- package/x/vibc/module.go +2 -7
- package/x/vibc/types/ibc_module.go +9 -3
- package/x/vibc/types/receiver.go +17 -7
- package/x/vlocalchain/handler.go +2 -1
- package/x/vlocalchain/keeper/keeper.go +24 -8
- package/x/vlocalchain/keeper/keeper_test.go +65 -1
- package/x/vlocalchain/types/expected_keepers.go +12 -0
- package/x/vlocalchain/vlocalchain.go +27 -22
- package/x/vlocalchain/vlocalchain_test.go +163 -8
- package/x/vstorage/keeper/grpc_query.go +0 -1
- package/x/vstorage/keeper/keeper.go +9 -17
- package/x/vstorage/module.go +0 -5
- package/x/vstorage/testing/queue.go +28 -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 +449 -0
- package/x/vtransfer/keeper/keeper.go +282 -0
- package/x/vtransfer/module.go +124 -0
- package/x/vtransfer/types/baseaddr.go +156 -0
- package/x/vtransfer/types/baseaddr_test.go +167 -0
- package/x/vtransfer/types/expected_keepers.go +38 -0
- package/x/vtransfer/types/genesis.pb.go +328 -0
- package/x/vtransfer/types/key.go +9 -0
- package/x/vtransfer/types/msgs.go +9 -0
- package/ante/fee.go +0 -97
package/daemon/cmd/root.go
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
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
|
+
"strings"
|
|
9
10
|
|
|
10
11
|
serverconfig "github.com/cosmos/cosmos-sdk/server/config"
|
|
11
12
|
|
|
12
|
-
"github.com/cosmos/cosmos-sdk/baseapp"
|
|
13
13
|
"github.com/cosmos/cosmos-sdk/client"
|
|
14
14
|
"github.com/cosmos/cosmos-sdk/client/config"
|
|
15
15
|
"github.com/cosmos/cosmos-sdk/client/debug"
|
|
@@ -20,9 +20,6 @@ import (
|
|
|
20
20
|
"github.com/cosmos/cosmos-sdk/client/snapshot"
|
|
21
21
|
"github.com/cosmos/cosmos-sdk/server"
|
|
22
22
|
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
23
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
27
24
|
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
|
|
28
25
|
"github.com/cosmos/cosmos-sdk/x/auth/types"
|
|
@@ -39,18 +36,43 @@ import (
|
|
|
39
36
|
|
|
40
37
|
gaia "github.com/Agoric/agoric-sdk/golang/cosmos/app"
|
|
41
38
|
"github.com/Agoric/agoric-sdk/golang/cosmos/app/params"
|
|
39
|
+
"github.com/Agoric/agoric-sdk/golang/cosmos/vm"
|
|
40
|
+
swingset "github.com/Agoric/agoric-sdk/golang/cosmos/x/swingset"
|
|
41
|
+
swingsetkeeper "github.com/Agoric/agoric-sdk/golang/cosmos/x/swingset/keeper"
|
|
42
42
|
)
|
|
43
43
|
|
|
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
44
|
var AppName = "agd"
|
|
48
|
-
var OnStartHook func(log.Logger, servertypes.AppOptions) error
|
|
49
|
-
var OnExportHook func(log.Logger, servertypes.AppOptions) error
|
|
45
|
+
var OnStartHook func(*vm.AgdServer, log.Logger, servertypes.AppOptions) error
|
|
46
|
+
var OnExportHook func(*vm.AgdServer, log.Logger, servertypes.AppOptions) error
|
|
47
|
+
|
|
48
|
+
// CustomAppConfig extends the base config struct.
|
|
49
|
+
type CustomAppConfig struct {
|
|
50
|
+
serverconfig.Config `mapstructure:",squash"`
|
|
51
|
+
// Swingset must be named as expected by swingset.DefaultConfigTemplate
|
|
52
|
+
// and must use a mapstructure key matching swingset.ConfigPrefix.
|
|
53
|
+
Swingset swingset.SwingsetConfig `mapstructure:"swingset"`
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
type cobraRunE func(cmd *cobra.Command, args []string) error
|
|
57
|
+
|
|
58
|
+
func appendToPreRunE(cmd *cobra.Command, fn cobraRunE) {
|
|
59
|
+
preRunE := cmd.PreRunE
|
|
60
|
+
if preRunE == nil {
|
|
61
|
+
cmd.PreRunE = fn
|
|
62
|
+
return
|
|
63
|
+
}
|
|
64
|
+
composite := func(cmd *cobra.Command, args []string) error {
|
|
65
|
+
if err := preRunE(cmd, args); err != nil {
|
|
66
|
+
return err
|
|
67
|
+
}
|
|
68
|
+
return fn(cmd, args)
|
|
69
|
+
}
|
|
70
|
+
cmd.PreRunE = composite
|
|
71
|
+
}
|
|
50
72
|
|
|
51
73
|
// NewRootCmd creates a new root command for simd. It is called once in the
|
|
52
74
|
// main function.
|
|
53
|
-
func NewRootCmd(sender Sender) (*cobra.Command, params.EncodingConfig) {
|
|
75
|
+
func NewRootCmd(sender vm.Sender) (*cobra.Command, params.EncodingConfig) {
|
|
54
76
|
encodingConfig := gaia.MakeEncodingConfig()
|
|
55
77
|
initClientCtx := client.Context{}.
|
|
56
78
|
WithCodec(encodingConfig.Marshaler).
|
|
@@ -104,33 +126,35 @@ func initTendermintConfig() *tmcfg.Config {
|
|
|
104
126
|
// initAppConfig helps to override default appConfig template and configs.
|
|
105
127
|
// return "", nil if no custom configuration is required for the application.
|
|
106
128
|
func initAppConfig() (string, interface{}) {
|
|
107
|
-
// Allow us to overwrite the SDK's default server config.
|
|
108
129
|
srvCfg := serverconfig.DefaultConfig()
|
|
109
|
-
|
|
110
|
-
//
|
|
111
|
-
//
|
|
112
|
-
//
|
|
113
|
-
//
|
|
114
|
-
// In summary:
|
|
115
|
-
// - if you leave srvCfg.MinGasPrices = "", all validators MUST tweak their
|
|
116
|
-
// own app.toml config,
|
|
117
|
-
// - if you set srvCfg.MinGasPrices non-empty, validators CAN tweak their
|
|
118
|
-
// own app.toml to override, or use this default value.
|
|
119
|
-
//
|
|
120
|
-
// FIXME: We may want to have Agoric set a min gas price in uist.
|
|
121
|
-
// For now, we set it to zero so that validators don't have to worry about it.
|
|
130
|
+
|
|
131
|
+
// FIXME: We may want a non-zero min gas price.
|
|
132
|
+
// For now, we set it to zero to reduce friction (the default "" fails
|
|
133
|
+
// startup, forcing each validator to set their own value).
|
|
122
134
|
srvCfg.MinGasPrices = "0uist"
|
|
123
135
|
|
|
124
|
-
|
|
136
|
+
customAppConfig := CustomAppConfig{
|
|
137
|
+
Config: *srvCfg,
|
|
138
|
+
Swingset: swingset.DefaultSwingsetConfig,
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// Config TOML.
|
|
142
|
+
customAppTemplate := strings.Join([]string{
|
|
143
|
+
serverconfig.DefaultConfigTemplate,
|
|
144
|
+
swingset.DefaultConfigTemplate,
|
|
145
|
+
}, "")
|
|
146
|
+
|
|
147
|
+
return customAppTemplate, customAppConfig
|
|
125
148
|
}
|
|
126
149
|
|
|
127
|
-
func initRootCmd(sender Sender, rootCmd *cobra.Command, encodingConfig params.EncodingConfig) {
|
|
150
|
+
func initRootCmd(sender vm.Sender, rootCmd *cobra.Command, encodingConfig params.EncodingConfig) {
|
|
128
151
|
cfg := sdk.GetConfig()
|
|
129
152
|
cfg.Seal()
|
|
130
153
|
|
|
131
154
|
ac := appCreator{
|
|
132
|
-
encCfg:
|
|
133
|
-
sender:
|
|
155
|
+
encCfg: encodingConfig,
|
|
156
|
+
sender: sender,
|
|
157
|
+
agdServer: vm.NewAgdServer(),
|
|
134
158
|
}
|
|
135
159
|
|
|
136
160
|
rootCmd.AddCommand(
|
|
@@ -144,16 +168,44 @@ func initRootCmd(sender Sender, rootCmd *cobra.Command, encodingConfig params.En
|
|
|
144
168
|
testnetCmd(gaia.ModuleBasics, banktypes.GenesisBalancesIterator{}),
|
|
145
169
|
debug.Cmd(),
|
|
146
170
|
config.Cmd(),
|
|
147
|
-
pruning.Cmd(ac.
|
|
148
|
-
snapshot.Cmd(ac.
|
|
171
|
+
pruning.Cmd(ac.newSnapshotsApp, gaia.DefaultNodeHome),
|
|
172
|
+
snapshot.Cmd(ac.newSnapshotsApp),
|
|
149
173
|
)
|
|
150
174
|
|
|
151
|
-
server.AddCommands(rootCmd, gaia.DefaultNodeHome, ac.newApp, ac.appExport,
|
|
175
|
+
server.AddCommands(rootCmd, gaia.DefaultNodeHome, ac.newApp, ac.appExport, addStartFlags)
|
|
152
176
|
|
|
153
177
|
for _, command := range rootCmd.Commands() {
|
|
154
|
-
|
|
178
|
+
switch command.Name() {
|
|
179
|
+
case "start":
|
|
180
|
+
var preRunE cobraRunE = func(cmd *cobra.Command, _ []string) error {
|
|
181
|
+
// Consume and validate config.
|
|
182
|
+
viper := server.GetServerContextFromCmd(cmd).Viper
|
|
183
|
+
baseConfig, err := serverconfig.GetConfig(viper)
|
|
184
|
+
if err != nil {
|
|
185
|
+
return err
|
|
186
|
+
}
|
|
187
|
+
if err = baseConfig.ValidateBasic(); err != nil {
|
|
188
|
+
return err
|
|
189
|
+
}
|
|
190
|
+
if _, err = swingset.SwingsetConfigFromViper(viper); err != nil {
|
|
191
|
+
return err
|
|
192
|
+
}
|
|
193
|
+
return nil
|
|
194
|
+
}
|
|
195
|
+
appendToPreRunE(command, preRunE)
|
|
196
|
+
case "export":
|
|
197
|
+
addAgoricVMFlags(command)
|
|
155
198
|
extendCosmosExportCommand(command)
|
|
156
|
-
|
|
199
|
+
case "snapshots":
|
|
200
|
+
for _, subCommand := range command.Commands() {
|
|
201
|
+
switch subCommand.Name() {
|
|
202
|
+
case "restore":
|
|
203
|
+
addAgoricVMFlags(subCommand)
|
|
204
|
+
case "export":
|
|
205
|
+
addAgoricVMFlags(subCommand)
|
|
206
|
+
replaceCosmosSnapshotExportCommand(subCommand, ac)
|
|
207
|
+
}
|
|
208
|
+
}
|
|
157
209
|
}
|
|
158
210
|
}
|
|
159
211
|
|
|
@@ -190,7 +242,7 @@ func addAgoricVMFlags(cmd *cobra.Command) {
|
|
|
190
242
|
)
|
|
191
243
|
}
|
|
192
244
|
|
|
193
|
-
func
|
|
245
|
+
func addStartFlags(startCmd *cobra.Command) {
|
|
194
246
|
addAgoricVMFlags(startCmd)
|
|
195
247
|
}
|
|
196
248
|
|
|
@@ -249,8 +301,9 @@ func txCommand() *cobra.Command {
|
|
|
249
301
|
}
|
|
250
302
|
|
|
251
303
|
type appCreator struct {
|
|
252
|
-
encCfg
|
|
253
|
-
sender
|
|
304
|
+
encCfg params.EncodingConfig
|
|
305
|
+
sender vm.Sender
|
|
306
|
+
agdServer *vm.AgdServer
|
|
254
307
|
}
|
|
255
308
|
|
|
256
309
|
func (ac appCreator) newApp(
|
|
@@ -260,66 +313,63 @@ func (ac appCreator) newApp(
|
|
|
260
313
|
appOpts servertypes.AppOptions,
|
|
261
314
|
) servertypes.Application {
|
|
262
315
|
if OnStartHook != nil {
|
|
263
|
-
if err := OnStartHook(logger, appOpts); err != nil {
|
|
316
|
+
if err := OnStartHook(ac.agdServer, logger, appOpts); err != nil {
|
|
264
317
|
panic(err)
|
|
265
318
|
}
|
|
266
319
|
}
|
|
267
320
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
if cast.ToBool(appOpts.Get(server.FlagInterBlockCache)) {
|
|
271
|
-
cache = store.NewCommitKVStoreCacheManager()
|
|
272
|
-
}
|
|
321
|
+
baseappOptions := server.DefaultBaseappOptions(appOpts)
|
|
273
322
|
|
|
274
323
|
skipUpgradeHeights := make(map[int64]bool)
|
|
275
324
|
for _, h := range cast.ToIntSlice(appOpts.Get(server.FlagUnsafeSkipUpgrades)) {
|
|
276
325
|
skipUpgradeHeights[int64(h)] = true
|
|
277
326
|
}
|
|
278
327
|
|
|
279
|
-
pruningOpts, err := server.GetPruningOptionsFromFlags(appOpts)
|
|
280
|
-
if err != nil {
|
|
281
|
-
panic(err)
|
|
282
|
-
}
|
|
283
|
-
|
|
284
328
|
homePath := cast.ToString(appOpts.Get(flags.FlagHome))
|
|
285
329
|
|
|
286
|
-
// Set a default value for FlagSwingStoreExportDir based on
|
|
330
|
+
// Set a default value for FlagSwingStoreExportDir based on homePath
|
|
287
331
|
// in case we need to InitGenesis with swing-store data
|
|
288
332
|
viper, ok := appOpts.(*viper.Viper)
|
|
289
|
-
if ok &&
|
|
290
|
-
|
|
333
|
+
if ok && viper.GetString(gaia.FlagSwingStoreExportDir) == "" {
|
|
334
|
+
exportDir := filepath.Join(homePath, "config", ExportedSwingStoreDirectoryName)
|
|
335
|
+
viper.Set(gaia.FlagSwingStoreExportDir, exportDir)
|
|
291
336
|
}
|
|
292
337
|
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
}
|
|
302
|
-
snapshotOptions := snapshottypes.NewSnapshotOptions(
|
|
303
|
-
cast.ToUint64(appOpts.Get(server.FlagStateSyncSnapshotInterval)),
|
|
304
|
-
cast.ToUint32(appOpts.Get(server.FlagStateSyncSnapshotKeepRecent)),
|
|
338
|
+
return gaia.NewAgoricApp(
|
|
339
|
+
ac.sender, ac.agdServer,
|
|
340
|
+
logger, db, traceStore, true, skipUpgradeHeights,
|
|
341
|
+
homePath,
|
|
342
|
+
cast.ToUint(appOpts.Get(server.FlagInvCheckPeriod)),
|
|
343
|
+
ac.encCfg,
|
|
344
|
+
appOpts,
|
|
345
|
+
baseappOptions...,
|
|
305
346
|
)
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
func (ac appCreator) newSnapshotsApp(
|
|
350
|
+
logger log.Logger,
|
|
351
|
+
db dbm.DB,
|
|
352
|
+
traceStore io.Writer,
|
|
353
|
+
appOpts servertypes.AppOptions,
|
|
354
|
+
) servertypes.Application {
|
|
355
|
+
if OnExportHook != nil {
|
|
356
|
+
if err := OnExportHook(ac.agdServer, logger, appOpts); err != nil {
|
|
357
|
+
panic(err)
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
baseappOptions := server.DefaultBaseappOptions(appOpts)
|
|
362
|
+
|
|
363
|
+
homePath := cast.ToString(appOpts.Get(flags.FlagHome))
|
|
306
364
|
|
|
307
365
|
return gaia.NewAgoricApp(
|
|
308
|
-
ac.sender,
|
|
309
|
-
logger, db, traceStore, true,
|
|
366
|
+
ac.sender, ac.agdServer,
|
|
367
|
+
logger, db, traceStore, true, map[int64]bool{},
|
|
310
368
|
homePath,
|
|
311
369
|
cast.ToUint(appOpts.Get(server.FlagInvCheckPeriod)),
|
|
312
370
|
ac.encCfg,
|
|
313
371
|
appOpts,
|
|
314
|
-
|
|
315
|
-
baseapp.SetMinGasPrices(cast.ToString(appOpts.Get(server.FlagMinGasPrices))),
|
|
316
|
-
baseapp.SetHaltHeight(cast.ToUint64(appOpts.Get(server.FlagHaltHeight))),
|
|
317
|
-
baseapp.SetHaltTime(cast.ToUint64(appOpts.Get(server.FlagHaltTime))),
|
|
318
|
-
baseapp.SetMinRetainBlocks(cast.ToUint64(appOpts.Get(server.FlagMinRetainBlocks))),
|
|
319
|
-
baseapp.SetInterBlockCache(cache),
|
|
320
|
-
baseapp.SetTrace(cast.ToBool(appOpts.Get(server.FlagTrace))),
|
|
321
|
-
baseapp.SetIndexEvents(cast.ToStringSlice(appOpts.Get(server.FlagIndexEvents))),
|
|
322
|
-
baseapp.SetSnapshot(snapshotStore, snapshotOptions),
|
|
372
|
+
baseappOptions...,
|
|
323
373
|
)
|
|
324
374
|
}
|
|
325
375
|
|
|
@@ -336,42 +386,68 @@ const (
|
|
|
336
386
|
ExportedSwingStoreDirectoryName = "swing-store"
|
|
337
387
|
)
|
|
338
388
|
|
|
389
|
+
var allowedSwingSetExportModes = map[string]bool{
|
|
390
|
+
swingset.SwingStoreExportModeDebug: true,
|
|
391
|
+
swingset.SwingStoreExportModeOperational: true,
|
|
392
|
+
swingset.SwingStoreExportModeSkip: true,
|
|
393
|
+
}
|
|
394
|
+
|
|
339
395
|
// extendCosmosExportCommand monkey-patches the "export" command added by
|
|
340
396
|
// cosmos-sdk to add a required "export-dir" command-line flag, and create the
|
|
341
397
|
// genesis export in the specified directory if the VM is running.
|
|
342
398
|
func extendCosmosExportCommand(cmd *cobra.Command) {
|
|
343
|
-
addAgoricVMFlags(cmd)
|
|
344
399
|
cmd.Flags().String(FlagExportDir, "", "The directory where to create the genesis export")
|
|
345
400
|
err := cmd.MarkFlagRequired(FlagExportDir)
|
|
346
401
|
if err != nil {
|
|
347
402
|
panic(err)
|
|
348
403
|
}
|
|
349
404
|
|
|
405
|
+
var keys []string
|
|
406
|
+
for key := range allowedSwingSetExportModes {
|
|
407
|
+
keys = append(keys, key)
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
cmd.Flags().String(
|
|
411
|
+
gaia.FlagSwingStoreExportMode,
|
|
412
|
+
swingset.SwingStoreExportModeOperational,
|
|
413
|
+
fmt.Sprintf(
|
|
414
|
+
"The mode for swingstore export (%s)",
|
|
415
|
+
strings.Join(keys, " | "),
|
|
416
|
+
),
|
|
417
|
+
)
|
|
418
|
+
|
|
350
419
|
originalRunE := cmd.RunE
|
|
351
420
|
|
|
352
421
|
extendedRunE := func(cmd *cobra.Command, args []string) error {
|
|
353
422
|
serverCtx := server.GetServerContextFromCmd(cmd)
|
|
354
423
|
|
|
355
424
|
exportDir, _ := cmd.Flags().GetString(FlagExportDir)
|
|
425
|
+
swingStoreExportMode, _ := cmd.Flags().GetString(gaia.FlagSwingStoreExportMode)
|
|
426
|
+
|
|
356
427
|
err := os.MkdirAll(exportDir, os.ModePerm)
|
|
357
428
|
if err != nil {
|
|
358
429
|
return err
|
|
359
430
|
}
|
|
360
431
|
|
|
361
432
|
genesisPath := filepath.Join(exportDir, ExportedGenesisFileName)
|
|
362
|
-
swingStoreExportPath := filepath.Join(exportDir, ExportedSwingStoreDirectoryName)
|
|
363
433
|
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
434
|
+
// Since none mode doesn't perform any swing store export
|
|
435
|
+
// There is no point in creating the export directory
|
|
436
|
+
if swingStoreExportMode != swingset.SwingStoreExportModeSkip {
|
|
437
|
+
swingStoreExportPath := filepath.Join(exportDir, ExportedSwingStoreDirectoryName)
|
|
438
|
+
|
|
439
|
+
err = os.MkdirAll(swingStoreExportPath, os.ModePerm)
|
|
440
|
+
if err != nil {
|
|
441
|
+
return err
|
|
442
|
+
}
|
|
443
|
+
// We unconditionally set FlagSwingStoreExportDir as for export, it makes
|
|
444
|
+
// little sense for users to control this location separately, and we don't
|
|
445
|
+
// want to override any swing-store artifacts that may be associated to the
|
|
446
|
+
// current genesis.
|
|
447
|
+
serverCtx.Viper.Set(gaia.FlagSwingStoreExportDir, swingStoreExportPath)
|
|
367
448
|
}
|
|
368
|
-
// We unconditionally set FlagSwingStoreExportDir as for export, it makes
|
|
369
|
-
// little sense for users to control this location separately, and we don't
|
|
370
|
-
// want to override any swing-store artifacts that may be associated to the
|
|
371
|
-
// current genesis.
|
|
372
|
-
serverCtx.Viper.Set(gaia.FlagSwingStoreExportDir, swingStoreExportPath)
|
|
373
449
|
|
|
374
|
-
if hasVMController(serverCtx) {
|
|
450
|
+
if hasVMController(serverCtx) || swingStoreExportMode == swingset.SwingStoreExportModeSkip {
|
|
375
451
|
// Capture the export in the genesisPath.
|
|
376
452
|
// This will fail if a genesis.json already exists in the export-dir
|
|
377
453
|
genesisFile, err := os.OpenFile(
|
|
@@ -404,8 +480,17 @@ func (ac appCreator) appExport(
|
|
|
404
480
|
jailAllowedAddrs []string,
|
|
405
481
|
appOpts servertypes.AppOptions,
|
|
406
482
|
) (servertypes.ExportedApp, error) {
|
|
407
|
-
|
|
408
|
-
|
|
483
|
+
swingStoreExportMode, ok := appOpts.Get(gaia.FlagSwingStoreExportMode).(string)
|
|
484
|
+
if !(ok && allowedSwingSetExportModes[swingStoreExportMode]) {
|
|
485
|
+
return servertypes.ExportedApp{}, fmt.Errorf(
|
|
486
|
+
"export mode '%s' is not supported",
|
|
487
|
+
swingStoreExportMode,
|
|
488
|
+
)
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
// We don't have to launch VM in case the swing store export is not required
|
|
492
|
+
if swingStoreExportMode != swingset.SwingStoreExportModeSkip && OnExportHook != nil {
|
|
493
|
+
if err := OnExportHook(ac.agdServer, logger, appOpts); err != nil {
|
|
409
494
|
return servertypes.ExportedApp{}, err
|
|
410
495
|
}
|
|
411
496
|
}
|
|
@@ -415,13 +500,10 @@ func (ac appCreator) appExport(
|
|
|
415
500
|
return servertypes.ExportedApp{}, errors.New("application home is not set")
|
|
416
501
|
}
|
|
417
502
|
|
|
418
|
-
|
|
419
|
-
if height == -1 {
|
|
420
|
-
loadLatest = true
|
|
421
|
-
}
|
|
503
|
+
loadLatest := height == -1
|
|
422
504
|
|
|
423
505
|
gaiaApp := gaia.NewAgoricApp(
|
|
424
|
-
ac.sender,
|
|
506
|
+
ac.sender, ac.agdServer,
|
|
425
507
|
logger,
|
|
426
508
|
db,
|
|
427
509
|
traceStore,
|
|
@@ -441,3 +523,64 @@ func (ac appCreator) appExport(
|
|
|
441
523
|
|
|
442
524
|
return gaiaApp.ExportAppStateAndValidators(forZeroHeight, jailAllowedAddrs)
|
|
443
525
|
}
|
|
526
|
+
|
|
527
|
+
// replaceCosmosSnapshotExportCommand monkey-patches the "snapshots export" command
|
|
528
|
+
// added by cosmos-sdk and replaces its implementation with one suitable for
|
|
529
|
+
// our modifications to the cosmos snapshots process
|
|
530
|
+
func replaceCosmosSnapshotExportCommand(cmd *cobra.Command, ac appCreator) {
|
|
531
|
+
// Copy of RunE is cosmos-sdk/client/snapshot/export.go
|
|
532
|
+
replacedRunE := func(cmd *cobra.Command, args []string) error {
|
|
533
|
+
ctx := server.GetServerContextFromCmd(cmd)
|
|
534
|
+
|
|
535
|
+
heightFlag, err := cmd.Flags().GetInt64("height")
|
|
536
|
+
if err != nil {
|
|
537
|
+
return err
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
home := ctx.Config.RootDir
|
|
541
|
+
dataDir := filepath.Join(home, "data")
|
|
542
|
+
db, err := dbm.NewDB("application", server.GetAppDBBackend(ctx.Viper), dataDir)
|
|
543
|
+
if err != nil {
|
|
544
|
+
return err
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
app := ac.newSnapshotsApp(ctx.Logger, db, nil, ctx.Viper)
|
|
548
|
+
gaiaApp := app.(*gaia.GaiaApp)
|
|
549
|
+
|
|
550
|
+
latestHeight := app.CommitMultiStore().LastCommitID().Version
|
|
551
|
+
|
|
552
|
+
if heightFlag != 0 && latestHeight != heightFlag {
|
|
553
|
+
return fmt.Errorf("cannot export at height %d, only latest height %d is supported", heightFlag, latestHeight)
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
cmd.Printf("Exporting snapshot for height %d\n", latestHeight)
|
|
557
|
+
|
|
558
|
+
err = gaiaApp.SwingSetSnapshotter.InitiateSnapshot(latestHeight)
|
|
559
|
+
if err != nil {
|
|
560
|
+
return err
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
err = swingsetkeeper.WaitUntilSwingStoreExportDone()
|
|
564
|
+
if err != nil {
|
|
565
|
+
return err
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
snapshotList, err := app.SnapshotManager().List()
|
|
569
|
+
if err != nil {
|
|
570
|
+
return err
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
snapshotHeight := uint64(latestHeight)
|
|
574
|
+
|
|
575
|
+
for _, snapshot := range snapshotList {
|
|
576
|
+
if snapshot.Height == snapshotHeight {
|
|
577
|
+
cmd.Printf("Snapshot created at height %d, format %d, chunks %d\n", snapshot.Height, snapshot.Format, snapshot.Chunks)
|
|
578
|
+
break
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
return nil
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
cmd.RunE = replacedRunE
|
|
586
|
+
}
|
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
|
+
}
|