@agoric/cosmos 0.35.0-u20.0 → 0.35.0-u21.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.
Files changed (113) hide show
  1. package/.clang-format +116 -0
  2. package/CHANGELOG.md +14 -2
  3. package/Makefile +38 -67
  4. package/ante/ante.go +2 -2
  5. package/ante/inbound_test.go +1 -1
  6. package/app/app.go +173 -142
  7. package/app/export.go +6 -6
  8. package/app/genesis.go +4 -0
  9. package/app/sim_test.go +299 -50
  10. package/app/upgrade.go +125 -24
  11. package/app/upgrade_test.go +1 -1
  12. package/cmd/agd/agvm.go +1 -1
  13. package/cmd/agd/main.go +1 -1
  14. package/cmd/libdaemon/main.go +34 -1
  15. package/daemon/cmd/root.go +26 -35
  16. package/daemon/cmd/root_test.go +5 -4
  17. package/daemon/cmd/testnet.go +221 -95
  18. package/daemon/main.go +1 -0
  19. package/git-revision.txt +1 -1
  20. package/go.mod +93 -58
  21. package/go.sum +148 -95
  22. package/package.json +6 -3
  23. package/proto/agoric/swingset/genesis.proto +7 -11
  24. package/proto/agoric/swingset/msgs.proto +56 -75
  25. package/proto/agoric/swingset/query.proto +7 -10
  26. package/proto/agoric/swingset/swingset.proto +79 -108
  27. package/proto/agoric/vbank/genesis.proto +5 -5
  28. package/proto/agoric/vbank/msgs.proto +1 -2
  29. package/proto/agoric/vbank/vbank.proto +42 -52
  30. package/proto/agoric/vibc/msgs.proto +8 -11
  31. package/proto/agoric/vstorage/genesis.proto +6 -9
  32. package/proto/agoric/vstorage/query.proto +19 -48
  33. package/proto/agoric/vstorage/vstorage.proto +4 -10
  34. package/proto/agoric/vtransfer/genesis.proto +7 -7
  35. package/proto/buf.gen.gogo.yaml +8 -0
  36. package/proto/buf.gen.pulsar.yaml +17 -0
  37. package/proto/buf.gen.swagger.yaml +5 -0
  38. package/proto/buf.yaml +10 -0
  39. package/scripts/protocgen.sh +14 -21
  40. package/third_party/proto/amino/amino.proto +79 -0
  41. package/third_party/proto/cosmos/base/v1beta1/coin.proto +7 -2
  42. package/third_party/proto/cosmos/ics23/v1/proofs.proto +243 -0
  43. package/third_party/proto/cosmos/msg/v1/msg.proto +30 -0
  44. package/third_party/proto/cosmos/upgrade/v1beta1/upgrade.proto +17 -5
  45. package/third_party/proto/cosmos_proto/cosmos.proto +16 -1
  46. package/third_party/proto/gogoproto/gogo.proto +2 -2
  47. package/third_party/proto/google/protobuf/any.proto +6 -3
  48. package/third_party/proto/ibc/core/channel/v1/channel.proto +1 -1
  49. package/third_party/proto/ibc/core/client/v1/client.proto +4 -2
  50. package/types/address_hooks.go +2 -2
  51. package/types/address_hooks_test.go +3 -3
  52. package/types/ibc_packet.go +3 -3
  53. package/types/ibc_packet_test.go +3 -3
  54. package/vm/client.go +32 -7
  55. package/vm/proto_json.go +2 -2
  56. package/x/swingset/abci.go +1 -1
  57. package/x/swingset/alias.go +0 -1
  58. package/x/swingset/config.go +1 -1
  59. package/x/swingset/keeper/extension_snapshotter.go +1 -1
  60. package/x/swingset/keeper/extension_snapshotter_test.go +1 -1
  61. package/x/swingset/keeper/keeper.go +1 -1
  62. package/x/swingset/keeper/keeper_test.go +1 -1
  63. package/x/swingset/keeper/querier.go +1 -30
  64. package/x/swingset/keeper/swing_store_exports_handler.go +1 -1
  65. package/x/swingset/keeper/swing_store_exports_handler_test.go +1 -1
  66. package/x/swingset/module.go +1 -14
  67. package/x/swingset/types/default-params.go +24 -16
  68. package/x/swingset/types/genesis.pb.go +2 -2
  69. package/x/swingset/types/msgs.pb.go +4 -3
  70. package/x/swingset/types/msgs_test.go +1 -1
  71. package/x/swingset/types/query.pb.go +4 -3
  72. package/x/swingset/types/swingset.pb.go +2 -2
  73. package/x/vbank/genesis.go +1 -1
  74. package/x/vbank/keeper/querier.go +1 -21
  75. package/x/vbank/module.go +1 -16
  76. package/x/vbank/types/genesis.pb.go +2 -2
  77. package/x/vbank/types/msgs.pb.go +3 -2
  78. package/x/vbank/types/query.pb.go +4 -3
  79. package/x/vbank/types/vbank.pb.go +2 -2
  80. package/x/vbank/vbank_test.go +95 -16
  81. package/x/vibc/keeper/keeper.go +8 -5
  82. package/x/vibc/keeper/migrations.go +36 -0
  83. package/x/vibc/keeper/triggers.go +1 -1
  84. package/x/vibc/module.go +9 -17
  85. package/x/vibc/types/expected_keepers.go +5 -10
  86. package/x/vibc/types/ibc_module.go +4 -4
  87. package/x/vibc/types/msgs.go +1 -1
  88. package/x/vibc/types/msgs.pb.go +5 -4
  89. package/x/vibc/types/receiver.go +2 -2
  90. package/x/vlocalchain/keeper/keeper.go +3 -3
  91. package/x/vlocalchain/types/vlocalchain.pb.go +1 -1
  92. package/x/vlocalchain/vlocalchain_test.go +6 -6
  93. package/x/vstorage/alias.go +0 -1
  94. package/x/vstorage/client/cli/query.go +1 -1
  95. package/x/vstorage/genesis.go +1 -1
  96. package/x/vstorage/keeper/keeper.go +6 -5
  97. package/x/vstorage/keeper/keeper_test.go +24 -24
  98. package/x/vstorage/keeper/querier.go +1 -32
  99. package/x/vstorage/keeper/querier_test.go +41 -6
  100. package/x/vstorage/module.go +1 -14
  101. package/x/vstorage/types/genesis.pb.go +2 -2
  102. package/x/vstorage/types/query.pb.go +8 -5
  103. package/x/vstorage/types/vstorage.pb.go +2 -2
  104. package/x/vstorage/vstorage_test.go +3 -3
  105. package/x/vtransfer/genesis.go +1 -1
  106. package/x/vtransfer/ibc_middleware.go +4 -4
  107. package/x/vtransfer/ibc_middleware_test.go +10 -11
  108. package/x/vtransfer/keeper/keeper.go +5 -5
  109. package/x/vtransfer/module.go +1 -14
  110. package/x/vtransfer/types/expected_keepers.go +2 -18
  111. package/x/vtransfer/types/genesis.pb.go +2 -2
  112. package/x/vtransfer/utils_test.go +15 -15
  113. package/daemon/cmd/genaccounts.go +0 -195
@@ -10,13 +10,16 @@ import (
10
10
  "os"
11
11
  "path/filepath"
12
12
 
13
+ tmconfig "github.com/cometbft/cometbft/config"
14
+ tmrand "github.com/cometbft/cometbft/libs/rand"
15
+ "github.com/cometbft/cometbft/types"
16
+ tmtime "github.com/cometbft/cometbft/types/time"
13
17
  "github.com/spf13/cobra"
14
- tmconfig "github.com/tendermint/tendermint/config"
15
- tmos "github.com/tendermint/tendermint/libs/os"
16
- tmrand "github.com/tendermint/tendermint/libs/rand"
17
- "github.com/tendermint/tendermint/types"
18
- tmtime "github.com/tendermint/tendermint/types/time"
18
+ "github.com/spf13/pflag"
19
19
 
20
+ "cosmossdk.io/math"
21
+
22
+ "cosmossdk.io/simapp"
20
23
  "github.com/cosmos/cosmos-sdk/client"
21
24
  "github.com/cosmos/cosmos-sdk/client/flags"
22
25
  "github.com/cosmos/cosmos-sdk/client/tx"
@@ -26,6 +29,7 @@ import (
26
29
  "github.com/cosmos/cosmos-sdk/server"
27
30
  srvconfig "github.com/cosmos/cosmos-sdk/server/config"
28
31
  "github.com/cosmos/cosmos-sdk/testutil"
32
+ "github.com/cosmos/cosmos-sdk/testutil/network"
29
33
  sdk "github.com/cosmos/cosmos-sdk/types"
30
34
  "github.com/cosmos/cosmos-sdk/types/module"
31
35
  authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
@@ -41,104 +45,188 @@ var (
41
45
  flagOutputDir = "output-dir"
42
46
  flagNodeDaemonHome = "node-daemon-home"
43
47
  flagStartingIPAddress = "starting-ip-address"
48
+ flagEnableLogging = "enable-logging"
49
+ flagGRPCAddress = "grpc.address"
50
+ flagRPCAddress = "rpc.address"
51
+ flagAPIAddress = "api.address"
52
+ flagPrintMnemonic = "print-mnemonic"
53
+
54
+ shortFlagNumValidators = "c"
55
+ flagDeprecatedNumValidators = "v"
44
56
  )
45
57
 
46
- // get cmd to initialize all files for tendermint testnet and application
47
- func testnetCmd(mbm module.BasicManager, genBalIterator banktypes.GenesisBalancesIterator) *cobra.Command {
58
+ type initArgs struct {
59
+ algo string
60
+ chainID string
61
+ keyringBackend string
62
+ minGasPrices string
63
+ nodeDaemonHome string
64
+ nodeDirPrefix string
65
+ numValidators int
66
+ outputDir string
67
+ startingIPAddress string
68
+ }
69
+
70
+ type startArgs struct {
71
+ algo string
72
+ apiAddress string
73
+ chainID string
74
+ enableLogging bool
75
+ grpcAddress string
76
+ minGasPrices string
77
+ numValidators int
78
+ outputDir string
79
+ printMnemonic bool
80
+ rpcAddress string
81
+ }
82
+
83
+ func addTestnetFlagsToCmd(cmd *cobra.Command) {
84
+ cmd.Flags().IntP(flagNumValidators, shortFlagNumValidators, 4, "Number of validators to initialize the testnet with")
85
+ cmd.Flags().Int(flagDeprecatedNumValidators, 4, "Number of validators to initialize the testnet with")
86
+ cmd.Flags().MarkDeprecated(flagDeprecatedNumValidators, fmt.Sprintf("use -%s or --%s", shortFlagNumValidators, flagNumValidators))
87
+ cmd.Flags().StringP(flagOutputDir, "o", "./.testnets", "Directory to store initialization data for the testnet")
88
+ cmd.Flags().String(flags.FlagChainID, "", "genesis file chain-id, if left blank will be randomly created")
89
+ cmd.Flags().String(server.FlagMinGasPrices, fmt.Sprintf("0.000006%s", sdk.DefaultBondDenom), "Minimum gas prices to accept for transactions; All fees in a tx must meet this minimum (e.g. 0.01photino,0.001stake)")
90
+ cmd.Flags().String(flags.FlagKeyType, string(hd.Secp256k1Type), "Key signing algorithm to generate keys for")
91
+
92
+ // support old flags name for backwards compatibility
93
+ cmd.Flags().SetNormalizeFunc(func(f *pflag.FlagSet, name string) pflag.NormalizedName {
94
+ if name == "algo" {
95
+ name = flags.FlagKeyType
96
+ }
97
+
98
+ return pflag.NormalizedName(name)
99
+ })
100
+ }
101
+
102
+ // NewTestnetCmd creates a root testnet command with subcommands to run an in-process testnet or initialize
103
+ // validator configuration files for running a multi-validator testnet in a separate process
104
+ func NewTestnetCmd(mbm module.BasicManager, genBalIterator banktypes.GenesisBalancesIterator, appName string) *cobra.Command {
105
+ testnetCmd := &cobra.Command{
106
+ Use: "testnet",
107
+ Short: "subcommands for starting or configuring local testnets",
108
+ DisableFlagParsing: true,
109
+ SuggestionsMinimumDistance: 2,
110
+ RunE: client.ValidateCmd,
111
+ }
112
+
113
+ testnetCmd.AddCommand(testnetStartCmd(appName))
114
+ testnetCmd.AddCommand(testnetInitFilesCmd(mbm, genBalIterator, appName))
115
+
116
+ return testnetCmd
117
+ }
118
+
119
+ // testnetInitFilesCmd returns a cmd to initialize all files for tendermint testnet and application
120
+ func testnetInitFilesCmd(mbm module.BasicManager, genBalIterator banktypes.GenesisBalancesIterator, appName string) *cobra.Command {
48
121
  cmd := &cobra.Command{
49
- Use: "testnet",
50
- Short: fmt.Sprintf("Initialize files for a %s testnet", AppName),
51
- Long: `testnet will create one directory per validator and populate each with
52
- necessary files (private validator, genesis, config, etc.).
122
+ Use: "init-files",
123
+ Short: "Initialize config directories & files for a multi-validator testnet running locally via separate processes (e.g. Docker Compose or similar)",
124
+ Long: fmt.Sprintf(`init-files will setup a number of directories (specified by "-%[2]s") and populate each with
125
+ necessary files (private validator, genesis, config, etc.) for running validator nodes.
126
+
127
+ Booting up a network with these validator folders is intended to be used with Docker Compose,
128
+ or a similar setup where each node has a manually configurable IP address.
53
129
 
54
130
  Note, strict routability for addresses is turned off in the config file.
55
131
 
56
132
  Example:
57
- agd testnet -n 4 --output-dir ./output --starting-ip-address 192.168.10.2
58
- `,
133
+ %[1]s testnet init-files -%[2]s 4 --output-dir ./.testnets --starting-ip-address 192.168.10.2
134
+ `, appName, shortFlagNumValidators),
59
135
  RunE: func(cmd *cobra.Command, _ []string) error {
60
136
  clientCtx, err := client.GetClientQueryContext(cmd)
61
137
  if err != nil {
62
138
  return err
63
139
  }
140
+
64
141
  serverCtx := server.GetServerContextFromCmd(cmd)
65
142
  config := serverCtx.Config
66
143
 
67
- outputDir, _ := cmd.Flags().GetString(flagOutputDir)
68
- keyringBackend, _ := cmd.Flags().GetString(flags.FlagKeyringBackend)
69
- chainID, _ := cmd.Flags().GetString(flags.FlagChainID)
70
- minGasPrices, _ := cmd.Flags().GetString(server.FlagMinGasPrices)
71
- nodeDirPrefix, _ := cmd.Flags().GetString(flagNodeDirPrefix)
72
- nodeDaemonHome, _ := cmd.Flags().GetString(flagNodeDaemonHome)
73
- startingIPAddress, _ := cmd.Flags().GetString(flagStartingIPAddress)
74
- numValidators, _ := cmd.Flags().GetInt(flagNumValidators)
75
- algo, _ := cmd.Flags().GetString(flags.FlagKeyAlgorithm)
76
-
77
- if cmd.Flags().Changed("v") {
78
- if cmd.Flags().Changed(flagNumValidators) {
79
- return fmt.Errorf("--%s and --v are mutually exclusive", flagNumValidators)
80
- }
81
- numValidators, _ = cmd.Flags().GetInt("v")
82
- }
83
-
84
- return InitTestnet(
85
- clientCtx, cmd, config, mbm, genBalIterator, outputDir, chainID, minGasPrices,
86
- nodeDirPrefix, nodeDaemonHome, startingIPAddress, keyringBackend, algo, numValidators,
87
- )
144
+ args := initArgs{}
145
+ args.outputDir, _ = cmd.Flags().GetString(flagOutputDir)
146
+ args.keyringBackend, _ = cmd.Flags().GetString(flags.FlagKeyringBackend)
147
+ args.chainID, _ = cmd.Flags().GetString(flags.FlagChainID)
148
+ args.minGasPrices, _ = cmd.Flags().GetString(server.FlagMinGasPrices)
149
+ args.nodeDirPrefix, _ = cmd.Flags().GetString(flagNodeDirPrefix)
150
+ args.nodeDaemonHome, _ = cmd.Flags().GetString(flagNodeDaemonHome)
151
+ args.startingIPAddress, _ = cmd.Flags().GetString(flagStartingIPAddress)
152
+ args.numValidators, _ = cmd.Flags().GetInt(flagNumValidators)
153
+ args.algo, _ = cmd.Flags().GetString(flags.FlagKeyType)
154
+
155
+ return initTestnetFiles(clientCtx, cmd, config, mbm, genBalIterator, args)
88
156
  },
89
157
  }
90
158
 
91
- cmd.Flags().IntP(flagNumValidators, "n", 4, "Number of validators to initialize the testnet with")
92
- cmd.Flags().Int("v", 4, fmt.Sprintf("Alias for --%s", flagNumValidators))
93
- if vFlag := cmd.Flags().Lookup("v"); vFlag != nil {
94
- vFlag.Deprecated = fmt.Sprintf("use --%s", flagNumValidators)
95
- }
96
- cmd.Flags().StringP(flagOutputDir, "o", "./mytestnet", "Directory to store initialization data for the testnet")
97
- cmd.Flags().String(flagNodeDirPrefix, "node", "Prefix for the name of per-validator subdirectories (to be number-suffixed like node0, node1, ...)")
98
- cmd.Flags().String(flagNodeDaemonHome, AppName, "Home directory of the node's daemon configuration")
159
+ addTestnetFlagsToCmd(cmd)
160
+ cmd.Flags().String(flagNodeDirPrefix, "node", "Prefix the directory name for each node with (node results in node0, node1, ...)")
161
+ cmd.Flags().String(flagNodeDaemonHome, appName, "Home directory of the node's daemon configuration")
99
162
  cmd.Flags().String(flagStartingIPAddress, "192.168.0.1", "Starting IP address (192.168.0.1 results in persistent peers list ID0@192.168.0.1:46656, ID1@192.168.0.2:46656, ...)")
100
- cmd.Flags().String(flags.FlagChainID, "", "genesis file chain-id, if left blank will be randomly created")
101
- cmd.Flags().String(server.FlagMinGasPrices, fmt.Sprintf("0.000006%s", sdk.DefaultBondDenom), "Minimum gas prices to accept for transactions; All fees in a tx must meet this minimum (e.g. 0.01photino,0.001stake)")
102
163
  cmd.Flags().String(flags.FlagKeyringBackend, flags.DefaultKeyringBackend, "Select keyring's backend (os|file|test)")
103
- cmd.Flags().String(flags.FlagKeyAlgorithm, string(hd.Secp256k1Type), "Key signing algorithm to generate keys for")
104
164
 
105
165
  return cmd
106
166
  }
107
167
 
108
- const nodeDirPerm = 0755
168
+ // testnetStartCmd returns a cmd to start multi validator in-process testnet
169
+ func testnetStartCmd(appName string) *cobra.Command {
170
+ cmd := &cobra.Command{
171
+ Use: "start",
172
+ Short: "Launch an in-process multi-validator testnet",
173
+ Long: fmt.Sprintf(`testnet will launch an in-process multi-validator testnet,
174
+ and generate a number of directories (specified by "-%[2]s"), populated with necessary validator configuration files
175
+ (private validator, genesis, config, etc.).
109
176
 
110
- // Initialize the testnet
111
- func InitTestnet(
177
+ Example:
178
+ %[1]s testnet start -%[2]s 4 --output-dir ./.testnets
179
+ `, appName, shortFlagNumValidators),
180
+ RunE: func(cmd *cobra.Command, _ []string) error {
181
+ args := startArgs{}
182
+ args.outputDir, _ = cmd.Flags().GetString(flagOutputDir)
183
+ args.chainID, _ = cmd.Flags().GetString(flags.FlagChainID)
184
+ args.minGasPrices, _ = cmd.Flags().GetString(server.FlagMinGasPrices)
185
+ args.numValidators, _ = cmd.Flags().GetInt(flagNumValidators)
186
+ args.algo, _ = cmd.Flags().GetString(flags.FlagKeyType)
187
+ args.enableLogging, _ = cmd.Flags().GetBool(flagEnableLogging)
188
+ args.rpcAddress, _ = cmd.Flags().GetString(flagRPCAddress)
189
+ args.apiAddress, _ = cmd.Flags().GetString(flagAPIAddress)
190
+ args.grpcAddress, _ = cmd.Flags().GetString(flagGRPCAddress)
191
+ args.printMnemonic, _ = cmd.Flags().GetBool(flagPrintMnemonic)
192
+
193
+ return startTestnet(cmd, args)
194
+ },
195
+ }
196
+
197
+ addTestnetFlagsToCmd(cmd)
198
+ cmd.Flags().Bool(flagEnableLogging, false, "Enable INFO logging of tendermint validator nodes")
199
+ cmd.Flags().String(flagRPCAddress, "tcp://0.0.0.0:26657", "the RPC address to listen on")
200
+ cmd.Flags().String(flagAPIAddress, "tcp://0.0.0.0:1317", "the address to listen on for REST API")
201
+ cmd.Flags().String(flagGRPCAddress, "0.0.0.0:9090", "the gRPC server address to listen on")
202
+ cmd.Flags().Bool(flagPrintMnemonic, true, "print mnemonic of first validator to stdout for manual testing")
203
+ return cmd
204
+ }
205
+
206
+ const nodeDirPerm = 0o755
207
+
208
+ // initTestnetFiles initializes testnet files for a testnet to be run in a separate process
209
+ func initTestnetFiles(
112
210
  clientCtx client.Context,
113
211
  cmd *cobra.Command,
114
212
  nodeConfig *tmconfig.Config,
115
213
  mbm module.BasicManager,
116
214
  genBalIterator banktypes.GenesisBalancesIterator,
117
- outputDir,
118
- chainID,
119
- minGasPrices,
120
- nodeDirPrefix,
121
- nodeDaemonHome,
122
- startingIPAddress,
123
- keyringBackend,
124
- algoStr string,
125
- numValidators int,
215
+ args initArgs,
126
216
  ) error {
127
-
128
- if chainID == "" {
129
- chainID = "chain-" + tmrand.NewRand().Str(6)
217
+ if args.chainID == "" {
218
+ args.chainID = "chain-" + tmrand.Str(6)
130
219
  }
131
-
132
- nodeIDs := make([]string, numValidators)
133
- valPubKeys := make([]cryptotypes.PubKey, numValidators)
220
+ nodeIDs := make([]string, args.numValidators)
221
+ valPubKeys := make([]cryptotypes.PubKey, args.numValidators)
134
222
 
135
223
  simappConfig := srvconfig.DefaultConfig()
136
- simappConfig.MinGasPrices = minGasPrices
224
+ simappConfig.MinGasPrices = args.minGasPrices
137
225
  simappConfig.API.Enable = true
138
226
  simappConfig.Telemetry.Enabled = true
139
227
  simappConfig.Telemetry.PrometheusRetentionTime = 60
140
228
  simappConfig.Telemetry.EnableHostnameLabel = false
141
- simappConfig.Telemetry.GlobalLabels = [][]string{{"chain_id", chainID}}
229
+ simappConfig.Telemetry.GlobalLabels = [][]string{{"chain_id", args.chainID}}
142
230
 
143
231
  var (
144
232
  genAccounts []authtypes.GenesisAccount
@@ -148,50 +236,49 @@ func InitTestnet(
148
236
 
149
237
  inBuf := bufio.NewReader(cmd.InOrStdin())
150
238
  // generate private keys, node IDs, and initial transactions
151
- for i := 0; i < numValidators; i++ {
152
- nodeDirName := fmt.Sprintf("%s%d", nodeDirPrefix, i)
153
- nodeDir := filepath.Join(outputDir, nodeDirName, nodeDaemonHome)
154
- gentxsDir := filepath.Join(outputDir, "gentxs")
239
+ for i := 0; i < args.numValidators; i++ {
240
+ nodeDirName := fmt.Sprintf("%s%d", args.nodeDirPrefix, i)
241
+ nodeDir := filepath.Join(args.outputDir, nodeDirName, args.nodeDaemonHome)
242
+ gentxsDir := filepath.Join(args.outputDir, "gentxs")
155
243
 
156
244
  nodeConfig.SetRoot(nodeDir)
245
+ nodeConfig.Moniker = nodeDirName
157
246
  nodeConfig.RPC.ListenAddress = "tcp://0.0.0.0:26657"
158
247
 
159
248
  if err := os.MkdirAll(filepath.Join(nodeDir, "config"), nodeDirPerm); err != nil {
160
- _ = os.RemoveAll(outputDir)
249
+ _ = os.RemoveAll(args.outputDir)
161
250
  return err
162
251
  }
163
252
 
164
- nodeConfig.Moniker = nodeDirName
165
-
166
- ip, err := getIP(i, startingIPAddress)
253
+ ip, err := getIP(i, args.startingIPAddress)
167
254
  if err != nil {
168
- _ = os.RemoveAll(outputDir)
255
+ _ = os.RemoveAll(args.outputDir)
169
256
  return err
170
257
  }
171
258
 
172
259
  nodeIDs[i], valPubKeys[i], err = genutil.InitializeNodeValidatorFiles(nodeConfig)
173
260
  if err != nil {
174
- _ = os.RemoveAll(outputDir)
261
+ _ = os.RemoveAll(args.outputDir)
175
262
  return err
176
263
  }
177
264
 
178
265
  memo := fmt.Sprintf("%s@%s:26656", nodeIDs[i], ip)
179
266
  genFiles = append(genFiles, nodeConfig.GenesisFile())
180
267
 
181
- kb, err := keyring.New(sdk.KeyringServiceName(), keyringBackend, nodeDir, inBuf, clientCtx.Codec)
268
+ kb, err := keyring.New(sdk.KeyringServiceName(), args.keyringBackend, nodeDir, inBuf, clientCtx.Codec)
182
269
  if err != nil {
183
270
  return err
184
271
  }
185
272
 
186
273
  keyringAlgos, _ := kb.SupportedAlgorithms()
187
- algo, err := keyring.NewSigningAlgoFromString(algoStr, keyringAlgos)
274
+ algo, err := keyring.NewSigningAlgoFromString(args.algo, keyringAlgos)
188
275
  if err != nil {
189
276
  return err
190
277
  }
191
278
 
192
279
  addr, secret, err := testutil.GenerateSaveCoinKey(kb, nodeDirName, "", true, algo)
193
280
  if err != nil {
194
- _ = os.RemoveAll(outputDir)
281
+ _ = os.RemoveAll(args.outputDir)
195
282
  return err
196
283
  }
197
284
 
@@ -210,7 +297,7 @@ func InitTestnet(
210
297
  accTokens := sdk.TokensFromConsensusPower(1000, sdk.DefaultPowerReduction)
211
298
  accStakingTokens := sdk.TokensFromConsensusPower(500, sdk.DefaultPowerReduction)
212
299
  coins := sdk.Coins{
213
- sdk.NewCoin(fmt.Sprintf("%stoken", nodeDirName), accTokens),
300
+ sdk.NewCoin("testtoken", accTokens),
214
301
  sdk.NewCoin(sdk.DefaultBondDenom, accStakingTokens),
215
302
  }
216
303
 
@@ -223,8 +310,8 @@ func InitTestnet(
223
310
  valPubKeys[i],
224
311
  sdk.NewCoin(sdk.DefaultBondDenom, valTokens),
225
312
  stakingtypes.NewDescription(nodeDirName, "", "", "", ""),
226
- stakingtypes.NewCommissionRates(sdk.OneDec(), sdk.OneDec(), sdk.OneDec()),
227
- sdk.OneInt(),
313
+ stakingtypes.NewCommissionRates(math.LegacyOneDec(), math.LegacyOneDec(), math.LegacyOneDec()),
314
+ math.OneInt(),
228
315
  )
229
316
  if err != nil {
230
317
  return err
@@ -239,7 +326,7 @@ func InitTestnet(
239
326
 
240
327
  txFactory := tx.Factory{}
241
328
  txFactory = txFactory.
242
- WithChainID(chainID).
329
+ WithChainID(args.chainID).
243
330
  WithMemo(memo).
244
331
  WithKeybase(kb).
245
332
  WithTxConfig(clientCtx.TxConfig)
@@ -257,22 +344,22 @@ func InitTestnet(
257
344
  return err
258
345
  }
259
346
 
260
- srvconfig.WriteConfigFile(filepath.Join(nodeDir, "config/app.toml"), simappConfig)
347
+ srvconfig.WriteConfigFile(filepath.Join(nodeDir, "config", "app.toml"), simappConfig)
261
348
  }
262
349
 
263
- if err := initGenFiles(clientCtx, mbm, chainID, genAccounts, genBalances, genFiles, numValidators); err != nil {
350
+ if err := initGenFiles(clientCtx, mbm, args.chainID, genAccounts, genBalances, genFiles, args.numValidators); err != nil {
264
351
  return err
265
352
  }
266
353
 
267
354
  err := collectGenFiles(
268
- clientCtx, nodeConfig, chainID, nodeIDs, valPubKeys, numValidators,
269
- outputDir, nodeDirPrefix, nodeDaemonHome, genBalIterator,
355
+ clientCtx, nodeConfig, args.chainID, nodeIDs, valPubKeys, args.numValidators,
356
+ args.outputDir, args.nodeDirPrefix, args.nodeDaemonHome, genBalIterator,
270
357
  )
271
358
  if err != nil {
272
359
  return err
273
360
  }
274
361
 
275
- cmd.PrintErrf("Successfully initialized %d node directories\n", numValidators)
362
+ cmd.PrintErrf("Successfully initialized %d node directories\n", args.numValidators)
276
363
  return nil
277
364
  }
278
365
 
@@ -281,7 +368,6 @@ func initGenFiles(
281
368
  genAccounts []authtypes.GenesisAccount, genBalances []banktypes.Balance,
282
369
  genFiles []string, numValidators int,
283
370
  ) error {
284
-
285
371
  appGenState := mbm.DefaultGenesis(clientCtx.Codec)
286
372
 
287
373
  // set the accounts in the genesis state
@@ -299,6 +385,7 @@ func initGenFiles(
299
385
  // set the balances in the genesis state
300
386
  var bankGenState banktypes.GenesisState
301
387
  clientCtx.Codec.MustUnmarshalJSON(appGenState[banktypes.ModuleName], &bankGenState)
388
+
302
389
  bankGenState.Balances = banktypes.SanitizeGenesisBalances(genBalances)
303
390
  for _, bal := range bankGenState.Balances {
304
391
  bankGenState.Supply = bankGenState.Supply.Add(bal.Coins...)
@@ -330,7 +417,6 @@ func collectGenFiles(
330
417
  nodeIDs []string, valPubKeys []cryptotypes.PubKey, numValidators int,
331
418
  outputDir, nodeDirPrefix, nodeDaemonHome string, genBalIterator banktypes.GenesisBalancesIterator,
332
419
  ) error {
333
-
334
420
  var appState json.RawMessage
335
421
  genTime := tmtime.Now()
336
422
 
@@ -350,7 +436,7 @@ func collectGenFiles(
350
436
  return err
351
437
  }
352
438
 
353
- nodeAppState, err := genutil.GenAppStateFromConfig(clientCtx.Codec, clientCtx.TxConfig, nodeConfig, initCfg, *genDoc, genBalIterator)
439
+ nodeAppState, err := genutil.GenAppStateFromConfig(clientCtx.Codec, clientCtx.TxConfig, nodeConfig, initCfg, *genDoc, genBalIterator, genutiltypes.DefaultMessageValidator)
354
440
  if err != nil {
355
441
  return err
356
442
  }
@@ -396,18 +482,58 @@ func calculateIP(ip string, i int) (string, error) {
396
482
  }
397
483
 
398
484
  func writeFile(name string, dir string, contents []byte) error {
399
- writePath := filepath.Join(dir)
400
- file := filepath.Join(writePath, name)
485
+ file := filepath.Join(dir, name)
401
486
 
402
- err := tmos.EnsureDir(writePath, 0755)
403
- if err != nil {
487
+ if err := os.MkdirAll(dir, 0o755); err != nil {
488
+ return fmt.Errorf("could not create directory %q: %s", dir, err)
489
+ }
490
+
491
+ if err := os.WriteFile(file, contents, 0o644); err != nil { //nolint: gosec
404
492
  return err
405
493
  }
406
494
 
407
- err = tmos.WriteFile(file, contents, 0644)
495
+ return nil
496
+ }
497
+
498
+ // startTestnet starts an in-process testnet
499
+ func startTestnet(cmd *cobra.Command, args startArgs) error {
500
+ networkConfig := network.DefaultConfig(simapp.NewTestNetworkFixture)
501
+
502
+ // Default networkConfig.ChainID is random, and we should only override it if chainID provided
503
+ // is non-empty
504
+ if args.chainID != "" {
505
+ networkConfig.ChainID = args.chainID
506
+ }
507
+ networkConfig.SigningAlgo = args.algo
508
+ networkConfig.MinGasPrices = args.minGasPrices
509
+ networkConfig.NumValidators = args.numValidators
510
+ networkConfig.EnableTMLogging = args.enableLogging
511
+ networkConfig.RPCAddress = args.rpcAddress
512
+ networkConfig.APIAddress = args.apiAddress
513
+ networkConfig.GRPCAddress = args.grpcAddress
514
+ networkConfig.PrintMnemonic = args.printMnemonic
515
+ networkLogger := network.NewCLILogger(cmd)
516
+
517
+ baseDir := fmt.Sprintf("%s/%s", args.outputDir, networkConfig.ChainID)
518
+ if _, err := os.Stat(baseDir); !os.IsNotExist(err) {
519
+ return fmt.Errorf(
520
+ "testnests directory already exists for chain-id '%s': %s, please remove or select a new --chain-id",
521
+ networkConfig.ChainID, baseDir)
522
+ }
523
+
524
+ testnet, err := network.New(networkLogger, baseDir, networkConfig)
408
525
  if err != nil {
409
526
  return err
410
527
  }
411
528
 
529
+ if _, err := testnet.WaitForHeight(1); err != nil {
530
+ return err
531
+ }
532
+ cmd.Println("press the Enter Key to terminate")
533
+ if _, err := fmt.Scanln(); err != nil { // wait for Enter Key
534
+ return err
535
+ }
536
+ testnet.Cleanup()
537
+
412
538
  return nil
413
539
  }
package/daemon/main.go CHANGED
@@ -51,6 +51,7 @@ func RunWithController(sendToController vm.Sender) {
51
51
  os.Exit(e.Code)
52
52
 
53
53
  default:
54
+ fmt.Fprintf(os.Stderr, "Error: %v\n", e)
54
55
  os.Exit(1)
55
56
  }
56
57
  }
package/git-revision.txt CHANGED
@@ -1 +1 @@
1
- 8e4207fa19
1
+ e4dd468571