@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.
- package/MAINTAINERS.md +3 -0
- package/Makefile +67 -41
- package/agoric/config.go +35 -0
- package/ante/ante.go +65 -0
- package/ante/expected_keepers.go +26 -0
- package/ante/inbound.go +137 -0
- package/ante/inbound_test.go +228 -0
- package/ante/vm_admission.go +65 -0
- package/app/app.go +396 -211
- package/app/export.go +13 -9
- package/app/sim_test.go +4 -4
- package/app/upgrade.go +215 -0
- package/binding.gyp.in +29 -4
- package/buf.work.yaml +4 -0
- package/cmd/agd/agvm.go +42 -0
- package/cmd/agd/find_binary.go +22 -7
- package/cmd/agd/main.go +133 -10
- package/cmd/libdaemon/main.go +67 -53
- package/cmd/libdaemon/main_test.go +37 -0
- package/daemon/cmd/genaccounts.go +22 -18
- package/daemon/cmd/root.go +253 -52
- package/daemon/cmd/root_test.go +190 -2
- package/daemon/cmd/testnet.go +17 -6
- package/daemon/main.go +6 -3
- package/e2e_test/Makefile +29 -0
- package/e2e_test/README.md +100 -0
- package/e2e_test/go.mod +217 -0
- package/e2e_test/go.sum +1323 -0
- package/e2e_test/ibc_conformance_test.go +56 -0
- package/e2e_test/pfm_test.go +613 -0
- package/e2e_test/util.go +271 -0
- package/git-revision.txt +1 -0
- package/go.mod +207 -0
- package/go.sum +1877 -0
- package/package.json +13 -21
- package/proto/agoric/swingset/genesis.proto +14 -0
- package/proto/agoric/swingset/swingset.proto +6 -3
- package/proto/agoric/vlocalchain/.clang-format +7 -0
- package/proto/agoric/vlocalchain/vlocalchain.proto +31 -0
- package/proto/agoric/vstorage/query.proto +53 -1
- package/proto/agoric/vtransfer/genesis.proto +18 -0
- package/scripts/protocgen.sh +16 -6
- package/third_party/proto/buf.yaml +1 -0
- package/third_party/proto/cosmos/base/query/v1beta1/pagination.proto +4 -1
- package/third_party/proto/cosmos/base/v1beta1/coin.proto +7 -4
- package/third_party/proto/cosmos/upgrade/v1beta1/upgrade.proto +16 -6
- package/third_party/proto/cosmos_proto/cosmos.proto +97 -0
- package/third_party/proto/google/api/annotations.proto +1 -1
- package/third_party/proto/google/api/http.proto +181 -120
- package/third_party/proto/google/api/httpbody.proto +9 -6
- package/third_party/proto/google/protobuf/any.proto +1 -7
- package/third_party/proto/ibc/core/channel/v1/channel.proto +15 -1
- package/third_party/proto/ibc/core/client/v1/client.proto +9 -6
- package/tools/tools.go +11 -0
- package/types/events.go +41 -0
- package/types/kv_entry.go +114 -0
- package/types/kv_entry_helpers.go +276 -0
- package/types/kv_entry_helpers_test.go +237 -0
- package/types/kv_entry_test.go +143 -0
- package/upgradegaia.sh +75 -0
- package/vm/action.go +134 -0
- package/vm/action_test.go +149 -0
- package/vm/client.go +113 -0
- package/vm/client_test.go +182 -0
- package/vm/controller.go +49 -0
- package/vm/core_proposals.go +51 -0
- package/vm/jsonrpcconn/jsonrpcconn.go +160 -0
- package/vm/jsonrpcconn/jsonrpcconn_test.go +126 -0
- package/vm/proto_json.go +38 -0
- package/vm/proto_json_test.go +103 -0
- package/vm/server.go +124 -0
- package/x/swingset/abci.go +26 -37
- package/x/swingset/alias.go +9 -6
- package/x/swingset/client/cli/query.go +2 -2
- package/x/swingset/client/cli/tx.go +52 -33
- package/x/swingset/client/proposal_handler.go +2 -17
- package/x/swingset/genesis.go +163 -37
- package/x/swingset/handler.go +2 -1
- package/x/swingset/keeper/extension_snapshotter.go +309 -0
- package/x/swingset/keeper/extension_snapshotter_test.go +104 -0
- package/x/swingset/keeper/keeper.go +95 -48
- package/x/swingset/keeper/keeper_test.go +77 -0
- package/x/swingset/keeper/migrations.go +7 -2
- package/x/swingset/keeper/msg_server.go +71 -56
- package/x/swingset/keeper/proposal.go +15 -9
- package/x/swingset/keeper/querier.go +24 -15
- package/x/swingset/keeper/swing_store_exports_handler.go +872 -0
- package/x/swingset/keeper/swing_store_exports_handler_test.go +247 -0
- package/x/swingset/keeper/test_utils.go +16 -0
- package/x/swingset/module.go +33 -11
- package/x/swingset/proposal_handler.go +5 -4
- package/x/swingset/swingset.go +73 -0
- package/x/swingset/testing/queue.go +17 -0
- package/x/swingset/types/codec.go +2 -2
- package/x/swingset/types/default-params.go +23 -17
- package/x/swingset/types/expected_keepers.go +14 -2
- package/x/swingset/types/genesis.pb.go +361 -18
- package/x/swingset/types/msgs.go +87 -26
- package/x/swingset/types/msgs.pb.go +16 -16
- package/x/swingset/types/params.go +76 -1
- package/x/swingset/types/params_test.go +116 -0
- package/x/swingset/types/proposal.go +10 -9
- package/x/swingset/types/swingset.pb.go +83 -81
- package/x/swingset/types/types.go +30 -28
- package/x/vbank/genesis.go +0 -2
- package/x/vbank/handler.go +2 -1
- package/x/vbank/keeper/keeper.go +3 -2
- package/x/vbank/keeper/querier.go +9 -4
- package/x/vbank/keeper/rewards.go +1 -1
- package/x/vbank/module.go +0 -5
- package/x/vbank/types/msgs.go +0 -12
- package/x/vbank/vbank.go +34 -32
- package/x/vbank/vbank_test.go +20 -20
- package/x/vibc/alias.go +3 -0
- package/x/vibc/handler.go +17 -15
- package/x/vibc/keeper/keeper.go +113 -89
- package/x/vibc/keeper/triggers.go +101 -0
- package/x/vibc/module.go +5 -8
- package/x/vibc/types/expected_keepers.go +28 -6
- package/x/vibc/types/ibc_module.go +336 -0
- package/x/vibc/types/msgs.go +1 -1
- package/x/vibc/types/msgs.pb.go +1 -1
- package/x/vibc/types/receiver.go +170 -0
- package/x/vlocalchain/alias.go +19 -0
- package/x/vlocalchain/handler.go +21 -0
- package/x/vlocalchain/keeper/keeper.go +279 -0
- package/x/vlocalchain/keeper/keeper_test.go +97 -0
- package/x/vlocalchain/types/codec.go +34 -0
- package/x/vlocalchain/types/key.go +27 -0
- package/x/vlocalchain/types/msgs.go +16 -0
- package/x/vlocalchain/types/vlocalchain.pb.go +1072 -0
- package/x/vlocalchain/vlocalchain.go +114 -0
- package/x/vlocalchain/vlocalchain_test.go +434 -0
- package/x/vstorage/README.md +138 -0
- package/x/vstorage/capdata/capdata.go +298 -0
- package/x/vstorage/capdata/capdata_test.go +352 -0
- package/x/vstorage/client/cli/query.go +51 -4
- package/x/vstorage/genesis.go +0 -3
- package/x/vstorage/handler.go +2 -1
- package/x/vstorage/keeper/grpc_query.go +220 -0
- package/x/vstorage/keeper/keeper.go +75 -57
- package/x/vstorage/keeper/keeper_grpc_test.go +300 -0
- package/x/vstorage/keeper/keeper_test.go +40 -62
- package/x/vstorage/keeper/querier.go +39 -14
- package/x/vstorage/keeper/querier_test.go +113 -0
- package/x/vstorage/module.go +0 -5
- package/x/vstorage/testing/queue.go +27 -0
- package/x/vstorage/types/path_keys.go +22 -10
- package/x/vstorage/types/path_keys_test.go +84 -18
- package/x/vstorage/types/query.pb.go +646 -36
- package/x/vstorage/types/query.pb.gw.go +119 -0
- package/x/vstorage/types/types.go +0 -66
- package/x/vstorage/vstorage.go +33 -35
- package/x/vstorage/vstorage_test.go +19 -19
- 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 +448 -0
- package/x/vtransfer/keeper/keeper.go +281 -0
- package/x/vtransfer/module.go +124 -0
- package/x/vtransfer/types/expected_keepers.go +38 -0
- package/x/vtransfer/types/genesis.pb.go +327 -0
- package/x/vtransfer/types/key.go +9 -0
- package/x/vtransfer/types/msgs.go +9 -0
- package/app/const.go +0 -6
- package/cmd/helper/main.go +0 -21
- package/proto/agoric/lien/genesis.proto +0 -25
- package/proto/agoric/lien/lien.proto +0 -25
- package/x/lien/alias.go +0 -17
- package/x/lien/genesis.go +0 -58
- package/x/lien/genesis_test.go +0 -101
- package/x/lien/keeper/account.go +0 -285
- package/x/lien/keeper/keeper.go +0 -254
- package/x/lien/keeper/keeper_test.go +0 -623
- package/x/lien/lien.go +0 -203
- package/x/lien/lien_test.go +0 -529
- package/x/lien/module.go +0 -115
- package/x/lien/spec/01_concepts.md +0 -146
- package/x/lien/spec/02_messages.md +0 -96
- package/x/lien/types/accountkeeper.go +0 -81
- package/x/lien/types/accountstate.go +0 -27
- package/x/lien/types/expected_keepers.go +0 -18
- package/x/lien/types/genesis.pb.go +0 -567
- package/x/lien/types/key.go +0 -25
- package/x/lien/types/lien.pb.go +0 -403
- package/x/swingset/keeper/snapshotter.go +0 -491
- package/x/swingset/keeper/snapshotter_test.go +0 -185
- package/x/swingset/legacy/v32/params.go +0 -37
- package/x/swingset/legacy/v32/params_test.go +0 -133
- package/x/vibc/ibc.go +0 -442
- /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
|
+
}
|
package/x/swingset/abci.go
CHANGED
|
@@ -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
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
|
|
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
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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 :=
|
|
41
|
-
|
|
42
|
-
|
|
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 :=
|
|
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 :=
|
|
90
|
-
|
|
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 :=
|
|
109
|
-
|
|
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: %
|
|
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
|
}
|
package/x/swingset/alias.go
CHANGED
|
@@ -21,10 +21,13 @@ var (
|
|
|
21
21
|
)
|
|
22
22
|
|
|
23
23
|
type (
|
|
24
|
-
Keeper
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
|
49
|
-
Short: "
|
|
50
|
-
|
|
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
|
|
60
|
-
|
|
67
|
+
if strings.HasPrefix(jsonIn, "@") {
|
|
68
|
+
var jsonBytes []byte
|
|
69
|
+
fname := jsonIn[1:]
|
|
61
70
|
if fname == "-" {
|
|
62
|
-
|
|
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
|
|
68
|
-
|
|
69
|
-
|
|
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:
|
|
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
|
|
106
|
-
|
|
118
|
+
if strings.HasPrefix(jsonIn, "@") {
|
|
119
|
+
var jsonBytes []byte
|
|
120
|
+
fname := jsonIn[1:]
|
|
107
121
|
if fname == "-" {
|
|
108
|
-
|
|
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
|
|
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
|
|
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(
|
|
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
|
|
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
|
|
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
|
|
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 :=
|
|
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
|
|
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
|
-
}
|