@agoric/cosmos 0.34.1 → 0.34.2-calypso-dev-dabccdc.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 (193) hide show
  1. package/MAINTAINERS.md +3 -0
  2. package/Makefile +67 -41
  3. package/agoric/config.go +35 -0
  4. package/ante/ante.go +65 -0
  5. package/ante/expected_keepers.go +26 -0
  6. package/ante/inbound.go +137 -0
  7. package/ante/inbound_test.go +228 -0
  8. package/ante/vm_admission.go +65 -0
  9. package/app/app.go +396 -211
  10. package/app/export.go +13 -9
  11. package/app/sim_test.go +4 -4
  12. package/app/upgrade.go +215 -0
  13. package/binding.gyp.in +29 -4
  14. package/buf.work.yaml +4 -0
  15. package/cmd/agd/agvm.go +42 -0
  16. package/cmd/agd/find_binary.go +22 -7
  17. package/cmd/agd/main.go +133 -10
  18. package/cmd/libdaemon/main.go +67 -53
  19. package/cmd/libdaemon/main_test.go +37 -0
  20. package/daemon/cmd/genaccounts.go +22 -18
  21. package/daemon/cmd/root.go +253 -52
  22. package/daemon/cmd/root_test.go +190 -2
  23. package/daemon/cmd/testnet.go +17 -6
  24. package/daemon/main.go +6 -3
  25. package/e2e_test/Makefile +29 -0
  26. package/e2e_test/README.md +100 -0
  27. package/e2e_test/go.mod +217 -0
  28. package/e2e_test/go.sum +1323 -0
  29. package/e2e_test/ibc_conformance_test.go +56 -0
  30. package/e2e_test/pfm_test.go +613 -0
  31. package/e2e_test/util.go +271 -0
  32. package/git-revision.txt +1 -0
  33. package/go.mod +207 -0
  34. package/go.sum +1877 -0
  35. package/package.json +13 -21
  36. package/proto/agoric/swingset/genesis.proto +14 -0
  37. package/proto/agoric/swingset/swingset.proto +6 -3
  38. package/proto/agoric/vlocalchain/.clang-format +7 -0
  39. package/proto/agoric/vlocalchain/vlocalchain.proto +31 -0
  40. package/proto/agoric/vstorage/query.proto +53 -1
  41. package/proto/agoric/vtransfer/genesis.proto +18 -0
  42. package/scripts/protocgen.sh +16 -6
  43. package/third_party/proto/buf.yaml +1 -0
  44. package/third_party/proto/cosmos/base/query/v1beta1/pagination.proto +4 -1
  45. package/third_party/proto/cosmos/base/v1beta1/coin.proto +7 -4
  46. package/third_party/proto/cosmos/upgrade/v1beta1/upgrade.proto +16 -6
  47. package/third_party/proto/cosmos_proto/cosmos.proto +97 -0
  48. package/third_party/proto/google/api/annotations.proto +1 -1
  49. package/third_party/proto/google/api/http.proto +181 -120
  50. package/third_party/proto/google/api/httpbody.proto +9 -6
  51. package/third_party/proto/google/protobuf/any.proto +1 -7
  52. package/third_party/proto/ibc/core/channel/v1/channel.proto +15 -1
  53. package/third_party/proto/ibc/core/client/v1/client.proto +9 -6
  54. package/tools/tools.go +11 -0
  55. package/types/events.go +41 -0
  56. package/types/kv_entry.go +114 -0
  57. package/types/kv_entry_helpers.go +276 -0
  58. package/types/kv_entry_helpers_test.go +237 -0
  59. package/types/kv_entry_test.go +143 -0
  60. package/upgradegaia.sh +75 -0
  61. package/vm/action.go +134 -0
  62. package/vm/action_test.go +149 -0
  63. package/vm/client.go +113 -0
  64. package/vm/client_test.go +182 -0
  65. package/vm/controller.go +49 -0
  66. package/vm/core_proposals.go +51 -0
  67. package/vm/jsonrpcconn/jsonrpcconn.go +160 -0
  68. package/vm/jsonrpcconn/jsonrpcconn_test.go +126 -0
  69. package/vm/proto_json.go +38 -0
  70. package/vm/proto_json_test.go +103 -0
  71. package/vm/server.go +124 -0
  72. package/x/swingset/abci.go +26 -37
  73. package/x/swingset/alias.go +9 -6
  74. package/x/swingset/client/cli/query.go +2 -2
  75. package/x/swingset/client/cli/tx.go +52 -33
  76. package/x/swingset/client/proposal_handler.go +2 -17
  77. package/x/swingset/genesis.go +163 -37
  78. package/x/swingset/handler.go +2 -1
  79. package/x/swingset/keeper/extension_snapshotter.go +309 -0
  80. package/x/swingset/keeper/extension_snapshotter_test.go +104 -0
  81. package/x/swingset/keeper/keeper.go +95 -48
  82. package/x/swingset/keeper/keeper_test.go +77 -0
  83. package/x/swingset/keeper/migrations.go +7 -2
  84. package/x/swingset/keeper/msg_server.go +71 -56
  85. package/x/swingset/keeper/proposal.go +15 -9
  86. package/x/swingset/keeper/querier.go +24 -15
  87. package/x/swingset/keeper/swing_store_exports_handler.go +872 -0
  88. package/x/swingset/keeper/swing_store_exports_handler_test.go +247 -0
  89. package/x/swingset/keeper/test_utils.go +16 -0
  90. package/x/swingset/module.go +33 -11
  91. package/x/swingset/proposal_handler.go +5 -4
  92. package/x/swingset/swingset.go +73 -0
  93. package/x/swingset/testing/queue.go +17 -0
  94. package/x/swingset/types/codec.go +2 -2
  95. package/x/swingset/types/default-params.go +23 -17
  96. package/x/swingset/types/expected_keepers.go +14 -2
  97. package/x/swingset/types/genesis.pb.go +361 -18
  98. package/x/swingset/types/msgs.go +87 -26
  99. package/x/swingset/types/msgs.pb.go +16 -16
  100. package/x/swingset/types/params.go +76 -1
  101. package/x/swingset/types/params_test.go +116 -0
  102. package/x/swingset/types/proposal.go +10 -9
  103. package/x/swingset/types/swingset.pb.go +83 -81
  104. package/x/swingset/types/types.go +30 -28
  105. package/x/vbank/genesis.go +0 -2
  106. package/x/vbank/handler.go +2 -1
  107. package/x/vbank/keeper/keeper.go +3 -2
  108. package/x/vbank/keeper/querier.go +9 -4
  109. package/x/vbank/keeper/rewards.go +1 -1
  110. package/x/vbank/module.go +0 -5
  111. package/x/vbank/types/msgs.go +0 -12
  112. package/x/vbank/vbank.go +34 -32
  113. package/x/vbank/vbank_test.go +20 -20
  114. package/x/vibc/alias.go +3 -0
  115. package/x/vibc/handler.go +17 -15
  116. package/x/vibc/keeper/keeper.go +113 -89
  117. package/x/vibc/keeper/triggers.go +101 -0
  118. package/x/vibc/module.go +5 -8
  119. package/x/vibc/types/expected_keepers.go +28 -6
  120. package/x/vibc/types/ibc_module.go +336 -0
  121. package/x/vibc/types/msgs.go +1 -1
  122. package/x/vibc/types/msgs.pb.go +1 -1
  123. package/x/vibc/types/receiver.go +170 -0
  124. package/x/vlocalchain/alias.go +19 -0
  125. package/x/vlocalchain/handler.go +21 -0
  126. package/x/vlocalchain/keeper/keeper.go +279 -0
  127. package/x/vlocalchain/keeper/keeper_test.go +97 -0
  128. package/x/vlocalchain/types/codec.go +34 -0
  129. package/x/vlocalchain/types/key.go +27 -0
  130. package/x/vlocalchain/types/msgs.go +16 -0
  131. package/x/vlocalchain/types/vlocalchain.pb.go +1072 -0
  132. package/x/vlocalchain/vlocalchain.go +114 -0
  133. package/x/vlocalchain/vlocalchain_test.go +434 -0
  134. package/x/vstorage/README.md +138 -0
  135. package/x/vstorage/capdata/capdata.go +298 -0
  136. package/x/vstorage/capdata/capdata_test.go +352 -0
  137. package/x/vstorage/client/cli/query.go +51 -4
  138. package/x/vstorage/genesis.go +0 -3
  139. package/x/vstorage/handler.go +2 -1
  140. package/x/vstorage/keeper/grpc_query.go +220 -0
  141. package/x/vstorage/keeper/keeper.go +75 -57
  142. package/x/vstorage/keeper/keeper_grpc_test.go +300 -0
  143. package/x/vstorage/keeper/keeper_test.go +40 -62
  144. package/x/vstorage/keeper/querier.go +39 -14
  145. package/x/vstorage/keeper/querier_test.go +113 -0
  146. package/x/vstorage/module.go +0 -5
  147. package/x/vstorage/testing/queue.go +27 -0
  148. package/x/vstorage/types/path_keys.go +22 -10
  149. package/x/vstorage/types/path_keys_test.go +84 -18
  150. package/x/vstorage/types/query.pb.go +646 -36
  151. package/x/vstorage/types/query.pb.gw.go +119 -0
  152. package/x/vstorage/types/types.go +0 -66
  153. package/x/vstorage/vstorage.go +33 -35
  154. package/x/vstorage/vstorage_test.go +19 -19
  155. package/x/vtransfer/alias.go +13 -0
  156. package/x/vtransfer/genesis.go +39 -0
  157. package/x/vtransfer/genesis_test.go +12 -0
  158. package/x/vtransfer/handler.go +20 -0
  159. package/x/vtransfer/ibc_middleware.go +186 -0
  160. package/x/vtransfer/ibc_middleware_test.go +448 -0
  161. package/x/vtransfer/keeper/keeper.go +281 -0
  162. package/x/vtransfer/module.go +124 -0
  163. package/x/vtransfer/types/expected_keepers.go +38 -0
  164. package/x/vtransfer/types/genesis.pb.go +327 -0
  165. package/x/vtransfer/types/key.go +9 -0
  166. package/x/vtransfer/types/msgs.go +9 -0
  167. package/app/const.go +0 -6
  168. package/cmd/helper/main.go +0 -21
  169. package/proto/agoric/lien/genesis.proto +0 -25
  170. package/proto/agoric/lien/lien.proto +0 -25
  171. package/x/lien/alias.go +0 -17
  172. package/x/lien/genesis.go +0 -58
  173. package/x/lien/genesis_test.go +0 -101
  174. package/x/lien/keeper/account.go +0 -285
  175. package/x/lien/keeper/keeper.go +0 -254
  176. package/x/lien/keeper/keeper_test.go +0 -623
  177. package/x/lien/lien.go +0 -203
  178. package/x/lien/lien_test.go +0 -529
  179. package/x/lien/module.go +0 -115
  180. package/x/lien/spec/01_concepts.md +0 -146
  181. package/x/lien/spec/02_messages.md +0 -96
  182. package/x/lien/types/accountkeeper.go +0 -81
  183. package/x/lien/types/accountstate.go +0 -27
  184. package/x/lien/types/expected_keepers.go +0 -18
  185. package/x/lien/types/genesis.pb.go +0 -567
  186. package/x/lien/types/key.go +0 -25
  187. package/x/lien/types/lien.pb.go +0 -403
  188. package/x/swingset/keeper/snapshotter.go +0 -491
  189. package/x/swingset/keeper/snapshotter_test.go +0 -185
  190. package/x/swingset/legacy/v32/params.go +0 -37
  191. package/x/swingset/legacy/v32/params_test.go +0 -133
  192. package/x/vibc/ibc.go +0 -442
  193. /package/{src/index.cjs → index.cjs} +0 -0
package/vm/server.go ADDED
@@ -0,0 +1,124 @@
1
+ package vm
2
+
3
+ import (
4
+ "context"
5
+ "fmt"
6
+ "sync"
7
+
8
+ sdk "github.com/cosmos/cosmos-sdk/types"
9
+ )
10
+
11
+ // AgdServer manages communication from the VM to the ABCI app. The structure
12
+ // is mutable and the mutex must be held to read or write any field.
13
+ type AgdServer struct {
14
+ currentCtx context.Context
15
+ mtx sync.Mutex
16
+ // zero is an out-of-bounds port number
17
+ lastPort int
18
+ // portToHandler[i] is nonzero iff portToName[i] is nonempty
19
+ portToHandler map[int]PortHandler
20
+ // portToName[nameToPort[s]] == s && nameToPort[portToName[i]] == i for all i, s
21
+ portToName map[int]string
22
+ nameToPort map[string]int
23
+ }
24
+
25
+ var wrappedEmptySDKContext = sdk.WrapSDKContext(
26
+ sdk.Context{}.WithContext(context.Background()),
27
+ )
28
+
29
+ // NewAgdServer returns a pointer to a new AgdServer with empty context and port
30
+ // mappings.
31
+ func NewAgdServer() *AgdServer {
32
+ return &AgdServer{
33
+ currentCtx: wrappedEmptySDKContext,
34
+ mtx: sync.Mutex{},
35
+ portToHandler: make(map[int]PortHandler),
36
+ portToName: make(map[int]string),
37
+ nameToPort: make(map[string]int),
38
+ }
39
+ }
40
+
41
+ // SetControllerContext sets the context to the given argument and returns a function
42
+ // which will reset the context to an empty context (not the old context).
43
+ func (s *AgdServer) SetControllerContext(ctx sdk.Context) func() {
44
+ // We are only called by the controller, so we assume that it is billing its
45
+ // own meter usage.
46
+ s.mtx.Lock()
47
+ defer s.mtx.Unlock()
48
+ s.currentCtx = sdk.WrapSDKContext(ctx.WithGasMeter(sdk.NewInfiniteGasMeter()))
49
+ return func() {
50
+ s.mtx.Lock()
51
+ defer s.mtx.Unlock()
52
+ s.currentCtx = wrappedEmptySDKContext
53
+ }
54
+ }
55
+
56
+ // getContextAndHandler returns the current context and the handler for the
57
+ // given port number.
58
+ func (s *AgdServer) getContextAndHandler(port int) (context.Context, PortHandler) {
59
+ s.mtx.Lock()
60
+ defer s.mtx.Unlock()
61
+ ctx := s.currentCtx
62
+ handler := s.portToHandler[port]
63
+ return ctx, handler
64
+ }
65
+
66
+ // ReceiveMessage is the method the VM calls in order to have agd receive a
67
+ // Message.
68
+ func (s *AgdServer) ReceiveMessage(msg *Message, reply *string) error {
69
+ ctx, handler := s.getContextAndHandler(msg.Port)
70
+ if handler == nil {
71
+ return fmt.Errorf("unregistered port %d", msg.Port)
72
+ }
73
+ resp, err := handler.Receive(ctx, msg.Data)
74
+ *reply = resp
75
+ return err
76
+ }
77
+
78
+ // GetPort returns the port number for the given port name, or 0 if the name is
79
+ // not registered.
80
+ func (s *AgdServer) GetPort(name string) int {
81
+ s.mtx.Lock()
82
+ defer s.mtx.Unlock()
83
+ return s.nameToPort[name]
84
+ }
85
+
86
+ // MustRegisterPortHandler attempts to RegisterPortHandler, panicing on error.
87
+ func (s *AgdServer) MustRegisterPortHandler(name string, portHandler PortHandler) int {
88
+ port, err := s.RegisterPortHandler(name, portHandler)
89
+ if err != nil {
90
+ panic(err)
91
+ }
92
+ return port
93
+ }
94
+
95
+ // RegisterPortHandler registers the handler to a new port number, then maps the name to it,
96
+ // returning the port number. If the name was previously in use, an error is returned.
97
+ func (s *AgdServer) RegisterPortHandler(name string, portHandler PortHandler) (int, error) {
98
+ s.mtx.Lock()
99
+ defer s.mtx.Unlock()
100
+ if _, ok := s.nameToPort[name]; ok {
101
+ return 0, fmt.Errorf("name %s already in use", name)
102
+ }
103
+ s.lastPort++
104
+ s.portToHandler[s.lastPort] = NewProtectedPortHandler(portHandler)
105
+ s.portToName[s.lastPort] = name
106
+ s.nameToPort[name] = s.lastPort
107
+ return s.lastPort, nil
108
+ }
109
+
110
+ // UnregisterPortHandler unregisters the handler and name mappings for this port
111
+ // number, and the reverse mapping for its name, if any of these exist. If
112
+ // portNum is not registered, return an error.
113
+ func (s *AgdServer) UnregisterPortHandler(portNum int) error {
114
+ s.mtx.Lock()
115
+ defer s.mtx.Unlock()
116
+ if s.portToHandler[portNum] == nil {
117
+ return fmt.Errorf("port %d not registered", portNum)
118
+ }
119
+ delete(s.portToHandler, portNum)
120
+ name := s.portToName[portNum]
121
+ delete(s.portToName, portNum)
122
+ delete(s.nameToPort, name)
123
+ return nil
124
+ }
@@ -2,6 +2,7 @@ package swingset
2
2
 
3
3
  import (
4
4
  // "os"
5
+ "context"
5
6
  "fmt"
6
7
  "time"
7
8
 
@@ -14,36 +15,29 @@ import (
14
15
  )
15
16
 
16
17
  type beginBlockAction struct {
17
- Type string `json:"type"`
18
- StoragePort int `json:"storagePort"`
19
- BlockHeight int64 `json:"blockHeight"`
20
- BlockTime int64 `json:"blockTime"`
21
- ChainID string `json:"chainID"`
22
- Params types.Params `json:"params"`
18
+ *vm.ActionHeader `actionType:"BEGIN_BLOCK"`
19
+ ChainID string `json:"chainID"`
20
+ Params types.Params `json:"params"`
23
21
  }
24
22
 
25
23
  type endBlockAction struct {
26
- Type string `json:"type"`
27
- BlockHeight int64 `json:"blockHeight"`
28
- BlockTime int64 `json:"blockTime"`
24
+ *vm.ActionHeader `actionType:"END_BLOCK"`
29
25
  }
30
26
 
31
27
  type commitBlockAction struct {
32
- Type string `json:"type"`
33
- BlockHeight int64 `json:"blockHeight"`
34
- BlockTime int64 `json:"blockTime"`
28
+ *vm.ActionHeader `actionType:"COMMIT_BLOCK"`
29
+ }
30
+
31
+ type afterCommitBlockAction struct {
32
+ *vm.ActionHeader `actionType:"AFTER_COMMIT_BLOCK"`
35
33
  }
36
34
 
37
35
  func BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock, keeper Keeper) error {
38
36
  defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyBeginBlocker)
39
37
 
40
- action := &beginBlockAction{
41
- Type: "BEGIN_BLOCK",
42
- StoragePort: vm.GetPort("vstorage"),
43
- BlockHeight: ctx.BlockHeight(),
44
- BlockTime: ctx.BlockTime().Unix(),
45
- ChainID: ctx.ChainID(),
46
- Params: keeper.GetParams(ctx),
38
+ action := beginBlockAction{
39
+ ChainID: ctx.ChainID(),
40
+ Params: keeper.GetParams(ctx),
47
41
  }
48
42
  _, err := keeper.BlockingSend(ctx, action)
49
43
  // fmt.Fprintf(os.Stderr, "BEGIN_BLOCK Returned from SwingSet: %s, %v\n", out, err)
@@ -62,11 +56,7 @@ var endBlockTime int64
62
56
  func EndBlock(ctx sdk.Context, req abci.RequestEndBlock, keeper Keeper) ([]abci.ValidatorUpdate, error) {
63
57
  defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyEndBlocker)
64
58
 
65
- action := &endBlockAction{
66
- Type: "END_BLOCK",
67
- BlockHeight: ctx.BlockHeight(),
68
- BlockTime: ctx.BlockTime().Unix(),
69
- }
59
+ action := endBlockAction{}
70
60
  _, err := keeper.BlockingSend(ctx, action)
71
61
 
72
62
  // fmt.Fprintf(os.Stderr, "END_BLOCK Returned from SwingSet: %s, %v\n", out, err)
@@ -83,15 +73,18 @@ func EndBlock(ctx sdk.Context, req abci.RequestEndBlock, keeper Keeper) ([]abci.
83
73
  return []abci.ValidatorUpdate{}, nil
84
74
  }
85
75
 
76
+ func getEndBlockContext() sdk.Context {
77
+ return sdk.Context{}.
78
+ WithContext(context.Background()).
79
+ WithBlockHeight(endBlockHeight).
80
+ WithBlockTime(time.Unix(endBlockTime, 0))
81
+ }
82
+
86
83
  func CommitBlock(keeper Keeper) error {
87
84
  defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), "commit_blocker")
88
85
 
89
- action := &commitBlockAction{
90
- Type: "COMMIT_BLOCK",
91
- BlockHeight: endBlockHeight,
92
- BlockTime: endBlockTime,
93
- }
94
- _, err := keeper.BlockingSend(sdk.Context{}, action)
86
+ action := commitBlockAction{}
87
+ _, err := keeper.BlockingSend(getEndBlockContext(), action)
95
88
 
96
89
  // fmt.Fprintf(os.Stderr, "COMMIT_BLOCK Returned from SwingSet: %s, %v\n", out, err)
97
90
  if err != nil {
@@ -105,17 +98,13 @@ func CommitBlock(keeper Keeper) error {
105
98
  func AfterCommitBlock(keeper Keeper) error {
106
99
  // defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), "commit_blocker")
107
100
 
108
- action := &commitBlockAction{
109
- Type: "AFTER_COMMIT_BLOCK",
110
- BlockHeight: endBlockHeight,
111
- BlockTime: endBlockTime,
112
- }
113
- _, err := keeper.BlockingSend(sdk.Context{}, action)
101
+ action := afterCommitBlockAction{}
102
+ _, err := keeper.BlockingSend(getEndBlockContext(), action)
114
103
 
115
104
  // fmt.Fprintf(os.Stderr, "AFTER_COMMIT_BLOCK Returned from SwingSet: %s, %v\n", out, err)
116
105
  if err != nil {
117
106
  // Panic here, in the hopes that a replay from scratch will fix the problem.
118
- panic(fmt.Errorf("AFTER_COMMIT_BLOCK failed: %w. Swingset is in an irrecoverable inconsistent state", err))
107
+ panic(fmt.Errorf("AFTER_COMMIT_BLOCK failed: %s. Swingset is in an irrecoverable inconsistent state", err))
119
108
  }
120
109
  return err
121
110
  }
@@ -21,10 +21,13 @@ var (
21
21
  )
22
22
 
23
23
  type (
24
- Keeper = keeper.Keeper
25
- Snapshotter = keeper.SwingsetSnapshotter
26
- Egress = types.Egress
27
- MsgDeliverInbound = types.MsgDeliverInbound
28
- MsgProvision = types.MsgProvision
29
- Params = types.Params
24
+ Keeper = keeper.Keeper
25
+ SwingStoreExportsHandler = keeper.SwingStoreExportsHandler
26
+ ExtensionSnapshotter = keeper.ExtensionSnapshotter
27
+ ActionContext = types.ActionContext
28
+ InboundQueueRecord = types.InboundQueueRecord
29
+ Egress = types.Egress
30
+ MsgDeliverInbound = types.MsgDeliverInbound
31
+ MsgProvision = types.MsgProvision
32
+ Params = types.Params
30
33
  )
@@ -53,7 +53,7 @@ func GetCmdQueryParams(queryRoute string) *cobra.Command {
53
53
 
54
54
  func GetCmdGetEgress(queryRoute string) *cobra.Command {
55
55
  cmd := &cobra.Command{
56
- Use: "egress [account]",
56
+ Use: "egress <account>",
57
57
  Short: "get egress info for account",
58
58
  Args: cobra.ExactArgs(1),
59
59
  RunE: func(cmd *cobra.Command, args []string) error {
@@ -86,7 +86,7 @@ func GetCmdGetEgress(queryRoute string) *cobra.Command {
86
86
  // GetCmdMailbox queries information about a mailbox
87
87
  func GetCmdMailbox(queryRoute string) *cobra.Command {
88
88
  cmd := &cobra.Command{
89
- Use: "mailbox [peer]",
89
+ Use: "mailbox <peer>",
90
90
  Short: "get mailbox for peer",
91
91
  Args: cobra.ExactArgs(1),
92
92
  RunE: func(cmd *cobra.Command, args []string) error {
@@ -2,6 +2,7 @@ package cli
2
2
 
3
3
  import (
4
4
  "fmt"
5
+ "io"
5
6
  "os"
6
7
  "strings"
7
8
 
@@ -12,7 +13,7 @@ import (
12
13
  "github.com/cosmos/cosmos-sdk/client/flags"
13
14
  "github.com/cosmos/cosmos-sdk/client/tx"
14
15
  govcli "github.com/cosmos/cosmos-sdk/x/gov/client/cli"
15
- govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
16
+ govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
16
17
 
17
18
  "github.com/Agoric/agoric-sdk/golang/cosmos/x/swingset/types"
18
19
  sdk "github.com/cosmos/cosmos-sdk/types"
@@ -43,11 +44,18 @@ func GetTxCmd(storeKey string) *cobra.Command {
43
44
  }
44
45
 
45
46
  // GetCmdDeliver is the CLI command for sending a DeliverInbound transaction
47
+ // containing mailbox messages.
46
48
  func GetCmdDeliver() *cobra.Command {
47
49
  cmd := &cobra.Command{
48
- Use: "deliver [json string]",
49
- Short: "deliver inbound messages",
50
- Args: cobra.ExactArgs(1),
50
+ Use: "deliver {<messages JSON> | @- | @<file>}",
51
+ Short: "send mailbox messages",
52
+ Long: `send mailbox messages.
53
+ The argument indicates how to read input JSON ("@-" for standard input,
54
+ "@..." for a file path, and otherwise directly as in "deliver '[...]'").
55
+ Input must represent an array in which the first element is an array of
56
+ [messageNum: integer, messageBody: string] pairs and the second element
57
+ is an "Ack" integer.`,
58
+ Args: cobra.ExactArgs(1),
51
59
 
52
60
  RunE: func(cmd *cobra.Command, args []string) error {
53
61
  cctx, err := client.GetClientTxContext(cmd)
@@ -56,20 +64,18 @@ func GetCmdDeliver() *cobra.Command {
56
64
  }
57
65
 
58
66
  jsonIn := args[0]
59
- if jsonIn[0] == '@' {
60
- fname := args[0][1:]
67
+ if strings.HasPrefix(jsonIn, "@") {
68
+ var jsonBytes []byte
69
+ fname := jsonIn[1:]
61
70
  if fname == "-" {
62
- // Reading from stdin.
63
- if _, err := fmt.Scanln(&jsonIn); err != nil {
64
- return err
65
- }
71
+ jsonBytes, err = io.ReadAll(os.Stdin)
66
72
  } else {
67
- jsonBytes, err := os.ReadFile(fname)
68
- if err != nil {
69
- return err
70
- }
71
- jsonIn = string(jsonBytes)
73
+ jsonBytes, err = os.ReadFile(fname)
74
+ }
75
+ if err != nil {
76
+ return err
72
77
  }
78
+ jsonIn = string(jsonBytes)
73
79
  }
74
80
  msgs, err := types.UnmarshalMessagesJSON(jsonIn)
75
81
  if err != nil {
@@ -92,7 +98,14 @@ func GetCmdDeliver() *cobra.Command {
92
98
  // InstallBundle message in a transaction.
93
99
  func GetCmdInstallBundle() *cobra.Command {
94
100
  cmd := &cobra.Command{
95
- Use: "install-bundle <JSON>/@<FILE>/-",
101
+ Use: "install-bundle {<bundle JSON> | @- | @<file>}",
102
+ Short: "install a bundle",
103
+ Long: `install a bundle.
104
+ The argument indicates how to read input JSON ("@-" for standard input,
105
+ "@..." for a file path, and otherwise directly as in
106
+ "install-bundle '{...}'").
107
+ Input should be endoZipBase64 JSON, but this is not verified.
108
+ https://github.com/endojs/endo/tree/master/packages/bundle-source`,
96
109
  Args: cobra.ExactArgs(1),
97
110
 
98
111
  RunE: func(cmd *cobra.Command, args []string) error {
@@ -102,20 +115,18 @@ func GetCmdInstallBundle() *cobra.Command {
102
115
  }
103
116
 
104
117
  jsonIn := args[0]
105
- if jsonIn[0] == '@' {
106
- fname := args[0][1:]
118
+ if strings.HasPrefix(jsonIn, "@") {
119
+ var jsonBytes []byte
120
+ fname := jsonIn[1:]
107
121
  if fname == "-" {
108
- // Reading from stdin.
109
- if _, err := fmt.Scanln(&jsonIn); err != nil {
110
- return err
111
- }
122
+ jsonBytes, err = io.ReadAll(os.Stdin)
112
123
  } else {
113
- jsonBytes, err := os.ReadFile(fname)
114
- if err != nil {
115
- return err
116
- }
117
- jsonIn = string(jsonBytes)
124
+ jsonBytes, err = os.ReadFile(fname)
118
125
  }
126
+ if err != nil {
127
+ return err
128
+ }
129
+ jsonIn = string(jsonBytes)
119
130
  }
120
131
 
121
132
  msg := types.NewMsgInstallBundle(jsonIn, cctx.GetFromAddress())
@@ -150,7 +161,7 @@ func GetCmdInstallBundle() *cobra.Command {
150
161
  // GetCmdProvision is the CLI command for sending a Provision transaction
151
162
  func GetCmdProvisionOne() *cobra.Command {
152
163
  cmd := &cobra.Command{
153
- Use: "provision-one [nickname] [address] [power-flags]",
164
+ Use: "provision-one <nickname> <address> [<power-flag>[,...]]",
154
165
  Short: "provision a single address",
155
166
  Args: cobra.RangeArgs(2, 3),
156
167
 
@@ -160,6 +171,8 @@ func GetCmdProvisionOne() *cobra.Command {
160
171
  return err
161
172
  }
162
173
 
174
+ nickname := args[0]
175
+
163
176
  addr, err := sdk.AccAddressFromBech32(args[1])
164
177
  if err != nil {
165
178
  return err
@@ -170,7 +183,7 @@ func GetCmdProvisionOne() *cobra.Command {
170
183
  powerFlags = strings.Split(args[2], ",")
171
184
  }
172
185
 
173
- msg := types.NewMsgProvision(args[0], addr, powerFlags, cctx.GetFromAddress())
186
+ msg := types.NewMsgProvision(nickname, addr, powerFlags, cctx.GetFromAddress())
174
187
  if err := msg.ValidateBasic(); err != nil {
175
188
  return err
176
189
  }
@@ -186,7 +199,7 @@ func GetCmdProvisionOne() *cobra.Command {
186
199
  // GetCmdWalletAction is the CLI command for sending a WalletAction or WalletSpendAction transaction
187
200
  func GetCmdWalletAction() *cobra.Command {
188
201
  cmd := &cobra.Command{
189
- Use: "wallet-action [json string]",
202
+ Use: "wallet-action <action JSON>",
190
203
  Short: "perform a wallet action",
191
204
  Args: cobra.ExactArgs(1),
192
205
  RunE: func(cmd *cobra.Command, args []string) error {
@@ -221,16 +234,18 @@ func GetCmdWalletAction() *cobra.Command {
221
234
  return cmd
222
235
  }
223
236
 
237
+ // NewCmdSubmitCoreEvalProposal is the CLI command for submitting a "CoreEval"
238
+ // governance proposal via `agd tx gov submit-proposal swingset-core-eval ...`.
224
239
  func NewCmdSubmitCoreEvalProposal() *cobra.Command {
225
240
  cmd := &cobra.Command{
226
- Use: "swingset-core-eval [[permit.json] [code.js]]...",
241
+ Use: "swingset-core-eval <permit.json code.js>...",
227
242
  Args: cobra.MinimumNArgs(2),
228
243
  Short: "Submit a proposal to evaluate code in the SwingSet core",
229
244
  Long: `Submit a SwingSet evaluate core Compartment code proposal along with an initial deposit.
230
245
  Specify at least one pair of permit.json and code.js files`,
231
246
  RunE: func(cmd *cobra.Command, args []string) error {
232
247
  if len(args)%2 != 0 {
233
- return fmt.Errorf("must specify an even number of permit.json and code.js files")
248
+ return fmt.Errorf("must specify paired permit.json and code.js files")
234
249
  }
235
250
 
236
251
  clientCtx, err := client.GetClientTxContext(cmd)
@@ -238,11 +253,13 @@ Specify at least one pair of permit.json and code.js files`,
238
253
  return err
239
254
  }
240
255
 
256
+ //nolint:staticcheck // Agoric is still using the legacy proposal shape
241
257
  title, err := cmd.Flags().GetString(govcli.FlagTitle)
242
258
  if err != nil {
243
259
  return err
244
260
  }
245
261
 
262
+ //nolint:staticcheck // Agoric is still using the legacy proposal shape
246
263
  description, err := cmd.Flags().GetString(govcli.FlagDescription)
247
264
  if err != nil {
248
265
  return err
@@ -287,7 +304,7 @@ Specify at least one pair of permit.json and code.js files`,
287
304
  return err
288
305
  }
289
306
 
290
- msg, err := govtypes.NewMsgSubmitProposal(content, deposit, from)
307
+ msg, err := govv1beta1.NewMsgSubmitProposal(content, deposit, from)
291
308
  if err != nil {
292
309
  return err
293
310
  }
@@ -300,7 +317,9 @@ Specify at least one pair of permit.json and code.js files`,
300
317
  },
301
318
  }
302
319
 
320
+ //nolint:staticcheck // Agoric is still using the legacy proposal shape
303
321
  cmd.Flags().String(govcli.FlagTitle, "", "title of proposal")
322
+ //nolint:staticcheck // Agoric is still using the legacy proposal shape
304
323
  cmd.Flags().String(govcli.FlagDescription, "", "description of proposal")
305
324
  cmd.Flags().String(govcli.FlagDeposit, "", "deposit for proposal")
306
325
 
@@ -1,25 +1,10 @@
1
1
  package client
2
2
 
3
3
  import (
4
- "net/http"
5
-
6
- "github.com/cosmos/cosmos-sdk/client"
7
- "github.com/cosmos/cosmos-sdk/types/rest"
8
- govclient "github.com/cosmos/cosmos-sdk/x/gov/client"
9
- govrest "github.com/cosmos/cosmos-sdk/x/gov/client/rest"
10
-
11
4
  "github.com/Agoric/agoric-sdk/golang/cosmos/x/swingset/client/cli"
5
+ govclient "github.com/cosmos/cosmos-sdk/x/gov/client"
12
6
  )
13
7
 
14
8
  var (
15
- CoreEvalProposalHandler = govclient.NewProposalHandler(cli.NewCmdSubmitCoreEvalProposal, emptyRestHandler)
9
+ CoreEvalProposalHandler = govclient.NewProposalHandler(cli.NewCmdSubmitCoreEvalProposal)
16
10
  )
17
-
18
- func emptyRestHandler(client.Context) govrest.ProposalRESTHandler {
19
- return govrest.ProposalRESTHandler{
20
- SubRoute: "unsupported-swingset",
21
- Handler: func(w http.ResponseWriter, r *http.Request) {
22
- rest.WriteErrorResponse(w, http.StatusBadRequest, "Legacy REST Routes are not supported for SwingSet proposals")
23
- },
24
- }
25
- }