@agoric/cosmos 0.34.2-dev-ecf2d8e.0 → 0.35.0-other-dev-70beeb7.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/CHANGELOG.md +45 -0
- package/app/app.go +103 -14
- package/app/const.go +6 -0
- package/cmd/agd/main.go +11 -133
- package/cmd/libdaemon/main.go +53 -67
- package/daemon/cmd/root.go +24 -55
- package/daemon/main.go +1 -3
- package/git-revision.txt +1 -1
- package/package.json +3 -3
- package/proto/agoric/vstorage/query.proto +1 -53
- package/vm/controller.go +18 -8
- package/x/lien/lien.go +4 -6
- package/x/lien/lien_test.go +15 -19
- package/x/swingset/abci.go +2 -3
- package/x/swingset/swingset.go +2 -4
- package/x/swingset/types/default-params.go +1 -1
- package/x/swingset/types/msgs.pb.go +16 -16
- package/x/vbank/vbank.go +10 -11
- package/x/vbank/vbank_test.go +5 -5
- package/x/vibc/ibc.go +11 -12
- package/x/vibc/keeper/keeper.go +15 -1
- package/x/vibc/types/expected_keepers.go +1 -2
- package/x/vstorage/keeper/grpc_query.go +0 -221
- package/x/vstorage/keeper/querier.go +11 -31
- package/x/vstorage/types/path_keys.go +10 -22
- package/x/vstorage/types/path_keys_test.go +18 -84
- package/x/vstorage/types/query.pb.go +36 -646
- package/x/vstorage/types/query.pb.gw.go +0 -119
- package/x/vstorage/vstorage.go +15 -16
- package/x/vstorage/vstorage_test.go +4 -4
- package/cmd/agd/agvm.go +0 -42
- package/vm/client.go +0 -113
- package/vm/client_test.go +0 -184
- package/vm/jsonrpcconn/jsonrpcconn.go +0 -160
- package/vm/jsonrpcconn/jsonrpcconn_test.go +0 -126
- package/vm/server.go +0 -23
- package/x/vstorage/README.md +0 -95
- package/x/vstorage/capdata/capdata.go +0 -298
- package/x/vstorage/capdata/capdata_test.go +0 -352
- package/x/vstorage/keeper/keeper_grpc_test.go +0 -300
package/daemon/cmd/root.go
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
package cmd
|
|
2
2
|
|
|
3
3
|
import (
|
|
4
|
-
"context"
|
|
5
4
|
"errors"
|
|
6
5
|
"io"
|
|
7
6
|
"os"
|
|
@@ -39,11 +38,11 @@ import (
|
|
|
39
38
|
)
|
|
40
39
|
|
|
41
40
|
// Sender is a function that sends a request to the controller.
|
|
42
|
-
type Sender func(
|
|
41
|
+
type Sender func(needReply bool, str string) (string, error)
|
|
43
42
|
|
|
44
43
|
var AppName = "agd"
|
|
45
|
-
var OnStartHook func(log.Logger
|
|
46
|
-
var OnExportHook func(log.Logger
|
|
44
|
+
var OnStartHook func(logger log.Logger)
|
|
45
|
+
var OnExportHook func(logger log.Logger)
|
|
47
46
|
|
|
48
47
|
// NewRootCmd creates a new root command for simd. It is called once in the
|
|
49
48
|
// main function.
|
|
@@ -61,7 +60,7 @@ func NewRootCmd(sender Sender) (*cobra.Command, params.EncodingConfig) {
|
|
|
61
60
|
|
|
62
61
|
rootCmd := &cobra.Command{
|
|
63
62
|
Use: AppName,
|
|
64
|
-
Short: "Agoric
|
|
63
|
+
Short: "Stargate Agoric App",
|
|
65
64
|
PersistentPreRunE: func(cmd *cobra.Command, _ []string) error {
|
|
66
65
|
// set the default command outputs
|
|
67
66
|
cmd.SetOut(cmd.OutOrStdout())
|
|
@@ -136,9 +135,10 @@ func initRootCmd(sender Sender, rootCmd *cobra.Command, encodingConfig params.En
|
|
|
136
135
|
}
|
|
137
136
|
server.AddCommands(rootCmd, gaia.DefaultNodeHome, ac.newApp, ac.appExport, addModuleInitFlags)
|
|
138
137
|
|
|
138
|
+
hasVMController := sender != nil
|
|
139
139
|
for _, command := range rootCmd.Commands() {
|
|
140
140
|
if command.Name() == "export" {
|
|
141
|
-
extendCosmosExportCommand(command)
|
|
141
|
+
extendCosmosExportCommand(command, hasVMController)
|
|
142
142
|
break
|
|
143
143
|
}
|
|
144
144
|
}
|
|
@@ -154,31 +154,8 @@ func initRootCmd(sender Sender, rootCmd *cobra.Command, encodingConfig params.En
|
|
|
154
154
|
rootCmd.AddCommand(server.RosettaCommand(encodingConfig.InterfaceRegistry, encodingConfig.Marshaler))
|
|
155
155
|
}
|
|
156
156
|
|
|
157
|
-
const (
|
|
158
|
-
// FlagSplitVm is the command-line flag for subcommands that can use a
|
|
159
|
-
// split-process Agoric VM. The default is to use an embedded VM.
|
|
160
|
-
FlagSplitVm = "split-vm"
|
|
161
|
-
EmbeddedVmEnvVar = "AGD_EMBEDDED_VM"
|
|
162
|
-
)
|
|
163
|
-
|
|
164
|
-
// hasVMController returns true if we have a VM (are running in split-vm mode,
|
|
165
|
-
// or with an embedded VM).
|
|
166
|
-
func hasVMController(serverCtx *server.Context) bool {
|
|
167
|
-
return serverCtx.Viper.GetString(FlagSplitVm) != "" ||
|
|
168
|
-
os.Getenv(EmbeddedVmEnvVar) != ""
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
func addAgoricVMFlags(cmd *cobra.Command) {
|
|
172
|
-
cmd.PersistentFlags().String(
|
|
173
|
-
FlagSplitVm,
|
|
174
|
-
"",
|
|
175
|
-
"Specify the external Agoric VM program",
|
|
176
|
-
)
|
|
177
|
-
}
|
|
178
|
-
|
|
179
157
|
func addModuleInitFlags(startCmd *cobra.Command) {
|
|
180
158
|
crisis.AddModuleInitFlags(startCmd)
|
|
181
|
-
addAgoricVMFlags(startCmd)
|
|
182
159
|
}
|
|
183
160
|
|
|
184
161
|
func queryCommand() *cobra.Command {
|
|
@@ -246,9 +223,7 @@ func (ac appCreator) newApp(
|
|
|
246
223
|
appOpts servertypes.AppOptions,
|
|
247
224
|
) servertypes.Application {
|
|
248
225
|
if OnStartHook != nil {
|
|
249
|
-
|
|
250
|
-
panic(err)
|
|
251
|
-
}
|
|
226
|
+
OnStartHook(logger)
|
|
252
227
|
}
|
|
253
228
|
|
|
254
229
|
var cache sdk.MultiStorePersistentCache
|
|
@@ -322,9 +297,8 @@ const (
|
|
|
322
297
|
|
|
323
298
|
// extendCosmosExportCommand monkey-patches the "export" command added by
|
|
324
299
|
// cosmos-sdk to add a required "export-dir" command-line flag, and create the
|
|
325
|
-
// genesis export in the specified directory
|
|
326
|
-
func extendCosmosExportCommand(cmd *cobra.Command) {
|
|
327
|
-
addAgoricVMFlags(cmd)
|
|
300
|
+
// genesis export in the specified directory.
|
|
301
|
+
func extendCosmosExportCommand(cmd *cobra.Command, hasVMController bool) {
|
|
328
302
|
cmd.Flags().String(FlagExportDir, "", "The directory where to create the genesis export")
|
|
329
303
|
err := cmd.MarkFlagRequired(FlagExportDir)
|
|
330
304
|
if err != nil {
|
|
@@ -355,28 +329,25 @@ func extendCosmosExportCommand(cmd *cobra.Command) {
|
|
|
355
329
|
// current genesis.
|
|
356
330
|
serverCtx.Viper.Set(gaia.FlagSwingStoreExportDir, swingStoreExportPath)
|
|
357
331
|
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
genesisPath,
|
|
363
|
-
os.O_CREATE|os.O_EXCL|os.O_WRONLY,
|
|
364
|
-
os.ModePerm,
|
|
365
|
-
)
|
|
366
|
-
if err != nil {
|
|
367
|
-
return err
|
|
368
|
-
}
|
|
369
|
-
defer genesisFile.Close()
|
|
370
|
-
cmd.SetOut(genesisFile)
|
|
332
|
+
// This will fail is a genesis.json already exists in the export-dir
|
|
333
|
+
genesisFile, err := os.OpenFile(genesisPath, os.O_CREATE|os.O_EXCL|os.O_WRONLY, os.ModePerm)
|
|
334
|
+
if err != nil {
|
|
335
|
+
return err
|
|
371
336
|
}
|
|
337
|
+
defer genesisFile.Close()
|
|
338
|
+
|
|
339
|
+
cmd.SetOut(genesisFile)
|
|
372
340
|
|
|
373
|
-
// If we don't have a VM, appExport will just use the OnExportHook to exec
|
|
374
|
-
// the VM program, which will result in reentering this function with the VM
|
|
375
|
-
// controller set, and activate the above condition.
|
|
376
341
|
return originalRunE(cmd, args)
|
|
377
342
|
}
|
|
378
343
|
|
|
379
|
-
|
|
344
|
+
// Only modify the command handler when we have a VM controller to handle
|
|
345
|
+
// the full export logic. Otherwise, appExport will just exec the VM program
|
|
346
|
+
// (OnExportHook), which will result in re-entering this flow with the VM
|
|
347
|
+
// controller set.
|
|
348
|
+
if hasVMController {
|
|
349
|
+
cmd.RunE = extendedRunE
|
|
350
|
+
}
|
|
380
351
|
}
|
|
381
352
|
|
|
382
353
|
func (ac appCreator) appExport(
|
|
@@ -389,9 +360,7 @@ func (ac appCreator) appExport(
|
|
|
389
360
|
appOpts servertypes.AppOptions,
|
|
390
361
|
) (servertypes.ExportedApp, error) {
|
|
391
362
|
if OnExportHook != nil {
|
|
392
|
-
|
|
393
|
-
return servertypes.ExportedApp{}, err
|
|
394
|
-
}
|
|
363
|
+
OnExportHook(logger)
|
|
395
364
|
}
|
|
396
365
|
|
|
397
366
|
homePath, ok := appOpts.Get(flags.FlagHome).(string)
|
package/daemon/main.go
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
package daemon
|
|
2
2
|
|
|
3
3
|
import (
|
|
4
|
-
"context"
|
|
5
4
|
"fmt"
|
|
6
5
|
"os"
|
|
7
6
|
"os/signal"
|
|
@@ -18,7 +17,7 @@ import (
|
|
|
18
17
|
)
|
|
19
18
|
|
|
20
19
|
// DefaultController is a stub controller.
|
|
21
|
-
var DefaultController = func(
|
|
20
|
+
var DefaultController = func(needReply bool, str string) (string, error) {
|
|
22
21
|
return "", fmt.Errorf("Controller not configured; did you mean to use `ag-chain-cosmos` instead?")
|
|
23
22
|
}
|
|
24
23
|
|
|
@@ -35,7 +34,6 @@ func RunWithController(sendToController cmd.Sender) {
|
|
|
35
34
|
signal.Notify(sigs, os.Interrupt, syscall.SIGINT, syscall.SIGTERM)
|
|
36
35
|
go func() {
|
|
37
36
|
<-sigs
|
|
38
|
-
_, _ = sendToController(context.Background(), false, "shutdown")
|
|
39
37
|
os.Exit(98)
|
|
40
38
|
}()
|
|
41
39
|
|
package/git-revision.txt
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
70beeb7
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/cosmos",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.35.0-other-dev-70beeb7.0+70beeb7",
|
|
4
4
|
"description": "Connect JS to the Cosmos blockchain SDK",
|
|
5
5
|
"parsers": {
|
|
6
6
|
"js": "mjs"
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"postpack": "git clean -f git-revision.txt",
|
|
20
20
|
"build": "exit 0",
|
|
21
21
|
"lint-fix": "yarn lint:eslint --fix",
|
|
22
|
-
"lint": "
|
|
22
|
+
"lint": "eslint '**/*.{cjs,js}'"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"bindings": "^1.2.1",
|
|
@@ -35,5 +35,5 @@
|
|
|
35
35
|
"publishConfig": {
|
|
36
36
|
"access": "public"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "70beeb7e476f24cfad30fa8cd5918f04746e8839"
|
|
39
39
|
}
|
|
@@ -9,18 +9,11 @@ option go_package = "github.com/Agoric/agoric-sdk/golang/cosmos/x/vstorage/types
|
|
|
9
9
|
|
|
10
10
|
// Query defines the gRPC querier service
|
|
11
11
|
service Query {
|
|
12
|
-
// Return
|
|
12
|
+
// Return an arbitrary vstorage datum.
|
|
13
13
|
rpc Data(QueryDataRequest) returns (QueryDataResponse) {
|
|
14
14
|
option (google.api.http).get = "/agoric/vstorage/data/{path}";
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
// Return a formatted representation of a vstorage datum that must be
|
|
18
|
-
// a valid StreamCell with CapData values, or standalone CapData.
|
|
19
|
-
rpc CapData(QueryCapDataRequest)
|
|
20
|
-
returns (QueryCapDataResponse) {
|
|
21
|
-
option (google.api.http).get = "/agoric/vstorage/capdata/{path}";
|
|
22
|
-
}
|
|
23
|
-
|
|
24
17
|
// Return the children of a given vstorage path.
|
|
25
18
|
rpc Children(QueryChildrenRequest)
|
|
26
19
|
returns (QueryChildrenResponse) {
|
|
@@ -44,51 +37,6 @@ message QueryDataResponse {
|
|
|
44
37
|
];
|
|
45
38
|
}
|
|
46
39
|
|
|
47
|
-
// QueryCapDataRequest contains a path and formatting configuration.
|
|
48
|
-
message QueryCapDataRequest {
|
|
49
|
-
string path = 1 [
|
|
50
|
-
(gogoproto.jsontag) = "path",
|
|
51
|
-
(gogoproto.moretags) = "yaml:\"path\""
|
|
52
|
-
];
|
|
53
|
-
// mediaType must be an actual media type in the registry at
|
|
54
|
-
// https://www.iana.org/assignments/media-types/media-types.xhtml
|
|
55
|
-
// or a special value that does not conflict with the media type syntax.
|
|
56
|
-
// The only valid value is "JSON Lines", which is also the default.
|
|
57
|
-
string media_type = 2 [
|
|
58
|
-
(gogoproto.jsontag) = "mediaType",
|
|
59
|
-
(gogoproto.moretags) = "yaml:\"mediaType\""
|
|
60
|
-
];
|
|
61
|
-
// itemFormat, if present, must be the special value "flat" to indicate that
|
|
62
|
-
// the deep structure of each item should be flattened into a single level
|
|
63
|
-
// with kebab-case keys (e.g., `{ "metrics": { "min": 0, "max": 88 } }` as
|
|
64
|
-
// `{ "metrics-min": 0, "metrics-max": 88 }`).
|
|
65
|
-
string item_format = 3 [
|
|
66
|
-
(gogoproto.jsontag) = "itemFormat",
|
|
67
|
-
(gogoproto.moretags) = "yaml:\"itemFormat\""
|
|
68
|
-
];
|
|
69
|
-
// remotableValueFormat indicates how to transform references to opaque but
|
|
70
|
-
// distinguishable Remotables into readable embedded representations.
|
|
71
|
-
// * "object" represents each Remotable as an `{ id, allegedName }` object, e.g. `{ "id": "board007", "allegedName": "IST brand" }`.
|
|
72
|
-
// * "string" represents each Remotable as a string with bracket-wrapped contents including its alleged name and id, e.g. "[Alleged: IST brand <board007>]".
|
|
73
|
-
string remotable_value_format = 10 [
|
|
74
|
-
(gogoproto.jsontag) = "remotableValueFormat",
|
|
75
|
-
(gogoproto.moretags) = "yaml:\"remotableValueFormat\""
|
|
76
|
-
];
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// QueryCapDataResponse represents the result with the requested formatting,
|
|
80
|
-
// reserving space for future metadata such as media type.
|
|
81
|
-
message QueryCapDataResponse {
|
|
82
|
-
string block_height = 1 [
|
|
83
|
-
(gogoproto.jsontag) = "blockHeight",
|
|
84
|
-
(gogoproto.moretags) = "yaml:\"blockHeight\""
|
|
85
|
-
];
|
|
86
|
-
string value = 10 [
|
|
87
|
-
(gogoproto.jsontag) = "value",
|
|
88
|
-
(gogoproto.moretags) = "yaml:\"value\""
|
|
89
|
-
];
|
|
90
|
-
}
|
|
91
|
-
|
|
92
40
|
// QueryChildrenRequest is the vstorage path children query.
|
|
93
41
|
message QueryChildrenRequest {
|
|
94
42
|
string path = 1 [
|
package/vm/controller.go
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
package vm
|
|
2
2
|
|
|
3
3
|
import (
|
|
4
|
-
"
|
|
4
|
+
"fmt"
|
|
5
5
|
|
|
6
6
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
7
7
|
)
|
|
8
8
|
|
|
9
|
+
type ControllerContext struct {
|
|
10
|
+
Context sdk.Context
|
|
11
|
+
IBCChannelHandlerPort int
|
|
12
|
+
}
|
|
13
|
+
|
|
9
14
|
type ControllerAdmissionMsg interface {
|
|
10
15
|
sdk.Msg
|
|
11
16
|
CheckAdmissibility(sdk.Context, interface{}) error
|
|
@@ -26,13 +31,10 @@ type Jsonable interface{}
|
|
|
26
31
|
// ActionPusher enqueues data for later consumption by the controller.
|
|
27
32
|
type ActionPusher func(ctx sdk.Context, action Jsonable) error
|
|
28
33
|
|
|
29
|
-
var
|
|
30
|
-
sdk.Context{}.WithContext(context.Background()),
|
|
31
|
-
)
|
|
32
|
-
var controllerContext context.Context = wrappedEmptySDKContext
|
|
34
|
+
var controllerContext ControllerContext
|
|
33
35
|
|
|
34
36
|
type PortHandler interface {
|
|
35
|
-
Receive(
|
|
37
|
+
Receive(*ControllerContext, string) (string, error)
|
|
36
38
|
}
|
|
37
39
|
|
|
38
40
|
var portToHandler = make(map[int]PortHandler)
|
|
@@ -43,9 +45,9 @@ var lastPort = 0
|
|
|
43
45
|
func SetControllerContext(ctx sdk.Context) func() {
|
|
44
46
|
// We are only called by the controller, so we assume that it is billing its
|
|
45
47
|
// own meter usage.
|
|
46
|
-
controllerContext =
|
|
48
|
+
controllerContext.Context = ctx.WithGasMeter(sdk.NewInfiniteGasMeter())
|
|
47
49
|
return func() {
|
|
48
|
-
controllerContext =
|
|
50
|
+
controllerContext.Context = sdk.Context{}
|
|
49
51
|
}
|
|
50
52
|
}
|
|
51
53
|
|
|
@@ -67,3 +69,11 @@ func UnregisterPortHandler(portNum int) error {
|
|
|
67
69
|
delete(nameToPort, name)
|
|
68
70
|
return nil
|
|
69
71
|
}
|
|
72
|
+
|
|
73
|
+
func ReceiveFromController(portNum int, msg string) (string, error) {
|
|
74
|
+
handler := portToHandler[portNum]
|
|
75
|
+
if handler == nil {
|
|
76
|
+
return "", fmt.Errorf("unregistered port %d", portNum)
|
|
77
|
+
}
|
|
78
|
+
return handler.Receive(&controllerContext, msg)
|
|
79
|
+
}
|
package/x/lien/lien.go
CHANGED
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
package lien
|
|
6
6
|
|
|
7
7
|
import (
|
|
8
|
-
"context"
|
|
9
8
|
"encoding/json"
|
|
10
9
|
"fmt"
|
|
11
10
|
"math"
|
|
@@ -71,8 +70,7 @@ const (
|
|
|
71
70
|
// Receives and processes a bridge message, returning the
|
|
72
71
|
// JSON-encoded response or error.
|
|
73
72
|
// See spec/02_messages.md for the messages and responses.
|
|
74
|
-
func (ch portHandler) Receive(
|
|
75
|
-
ctx := sdk.UnwrapSDKContext(cctx)
|
|
73
|
+
func (ch portHandler) Receive(ctx *vm.ControllerContext, str string) (string, error) {
|
|
76
74
|
var msg portMessage
|
|
77
75
|
err := json.Unmarshal([]byte(str), &msg)
|
|
78
76
|
if err != nil {
|
|
@@ -80,13 +78,13 @@ func (ch portHandler) Receive(cctx context.Context, str string) (string, error)
|
|
|
80
78
|
}
|
|
81
79
|
switch msg.Type {
|
|
82
80
|
case LIEN_GET_ACCOUNT_STATE:
|
|
83
|
-
return ch.handleGetAccountState(ctx, msg)
|
|
81
|
+
return ch.handleGetAccountState(ctx.Context, msg)
|
|
84
82
|
|
|
85
83
|
case LIEN_GET_STAKING:
|
|
86
|
-
return ch.handleGetStaking(ctx, msg)
|
|
84
|
+
return ch.handleGetStaking(ctx.Context, msg)
|
|
87
85
|
|
|
88
86
|
case LIEN_CHANGE_LIENED:
|
|
89
|
-
return ch.handleChangeLiened(ctx, msg)
|
|
87
|
+
return ch.handleChangeLiened(ctx.Context, msg)
|
|
90
88
|
}
|
|
91
89
|
return "", fmt.Errorf("unrecognized type %s", msg.Type)
|
|
92
90
|
}
|
package/x/lien/lien_test.go
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
package lien
|
|
2
2
|
|
|
3
3
|
import (
|
|
4
|
-
"context"
|
|
5
4
|
"encoding/json"
|
|
6
5
|
"reflect"
|
|
7
6
|
"testing"
|
|
8
7
|
|
|
8
|
+
"github.com/Agoric/agoric-sdk/golang/cosmos/vm"
|
|
9
9
|
"github.com/Agoric/agoric-sdk/golang/cosmos/x/lien/types"
|
|
10
10
|
|
|
11
11
|
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
|
|
@@ -114,8 +114,8 @@ func (m *mockLienKeeper) GetDelegatorDelegations(ctx sdk.Context, delegator sdk.
|
|
|
114
114
|
}
|
|
115
115
|
|
|
116
116
|
func TestBadType(t *testing.T) {
|
|
117
|
-
ctx := sdk.Context{}
|
|
118
|
-
ctlCtx :=
|
|
117
|
+
ctx := sdk.Context{}
|
|
118
|
+
ctlCtx := &vm.ControllerContext{Context: ctx}
|
|
119
119
|
keeper := mockLienKeeper{
|
|
120
120
|
states: map[string]types.AccountState{},
|
|
121
121
|
}
|
|
@@ -135,8 +135,8 @@ func TestBadType(t *testing.T) {
|
|
|
135
135
|
}
|
|
136
136
|
|
|
137
137
|
func TestGetAccountState(t *testing.T) {
|
|
138
|
-
ctx := sdk.Context{}
|
|
139
|
-
ctlCtx :=
|
|
138
|
+
ctx := sdk.Context{}
|
|
139
|
+
ctlCtx := &vm.ControllerContext{Context: ctx}
|
|
140
140
|
|
|
141
141
|
keeper := mockLienKeeper{
|
|
142
142
|
states: map[string]types.AccountState{
|
|
@@ -177,9 +177,8 @@ func TestGetAccountState(t *testing.T) {
|
|
|
177
177
|
}
|
|
178
178
|
|
|
179
179
|
func TestGetAccountState_badRequest(t *testing.T) {
|
|
180
|
-
ctx := sdk.Context{}
|
|
181
|
-
ctlCtx :=
|
|
182
|
-
|
|
180
|
+
ctx := sdk.Context{}
|
|
181
|
+
ctlCtx := &vm.ControllerContext{Context: ctx}
|
|
183
182
|
keeper := mockLienKeeper{
|
|
184
183
|
states: map[string]types.AccountState{},
|
|
185
184
|
}
|
|
@@ -215,9 +214,8 @@ func TestGetAccountState_badRequest(t *testing.T) {
|
|
|
215
214
|
}
|
|
216
215
|
|
|
217
216
|
func TestSetLiened_badAddr(t *testing.T) {
|
|
218
|
-
ctx := sdk.Context{}
|
|
219
|
-
ctlCtx :=
|
|
220
|
-
|
|
217
|
+
ctx := sdk.Context{}
|
|
218
|
+
ctlCtx := &vm.ControllerContext{Context: ctx}
|
|
221
219
|
keeper := mockLienKeeper{}
|
|
222
220
|
ph := NewPortHandler(&keeper)
|
|
223
221
|
msg := portMessage{
|
|
@@ -237,9 +235,8 @@ func TestSetLiened_badAddr(t *testing.T) {
|
|
|
237
235
|
}
|
|
238
236
|
|
|
239
237
|
func TestSetLiened_badDenom(t *testing.T) {
|
|
240
|
-
ctx := sdk.Context{}
|
|
241
|
-
ctlCtx :=
|
|
242
|
-
|
|
238
|
+
ctx := sdk.Context{}
|
|
239
|
+
ctlCtx := &vm.ControllerContext{Context: ctx}
|
|
243
240
|
keeper := mockLienKeeper{}
|
|
244
241
|
ph := NewPortHandler(&keeper)
|
|
245
242
|
msg := portMessage{
|
|
@@ -259,9 +256,8 @@ func TestSetLiened_badDenom(t *testing.T) {
|
|
|
259
256
|
}
|
|
260
257
|
|
|
261
258
|
func TestSetLiened(t *testing.T) {
|
|
262
|
-
ctx := sdk.Context{}
|
|
263
|
-
ctlCtx :=
|
|
264
|
-
|
|
259
|
+
ctx := sdk.Context{}
|
|
260
|
+
ctlCtx := &vm.ControllerContext{Context: ctx}
|
|
265
261
|
keeper := mockLienKeeper{}
|
|
266
262
|
ph := NewPortHandler(&keeper)
|
|
267
263
|
msg := portMessage{
|
|
@@ -340,8 +336,8 @@ func TestGetStaking(t *testing.T) {
|
|
|
340
336
|
keeper.delegations[addr4.String()] = []stakingTypes.Delegation{}
|
|
341
337
|
|
|
342
338
|
ph := NewPortHandler(&keeper)
|
|
343
|
-
ctx := sdk.Context{}
|
|
344
|
-
ctlCtx :=
|
|
339
|
+
ctx := sdk.Context{}
|
|
340
|
+
ctlCtx := &vm.ControllerContext{Context: ctx}
|
|
345
341
|
|
|
346
342
|
pi := func(x int64) *sdk.Int {
|
|
347
343
|
n := i(x)
|
package/x/swingset/abci.go
CHANGED
|
@@ -2,7 +2,6 @@ package swingset
|
|
|
2
2
|
|
|
3
3
|
import (
|
|
4
4
|
// "os"
|
|
5
|
-
"context"
|
|
6
5
|
"fmt"
|
|
7
6
|
"time"
|
|
8
7
|
|
|
@@ -89,7 +88,7 @@ func CommitBlock(keeper Keeper) error {
|
|
|
89
88
|
BlockHeight: endBlockHeight,
|
|
90
89
|
BlockTime: endBlockTime,
|
|
91
90
|
}
|
|
92
|
-
_, err := keeper.BlockingSend(sdk.Context{}
|
|
91
|
+
_, err := keeper.BlockingSend(sdk.Context{}, action)
|
|
93
92
|
|
|
94
93
|
// fmt.Fprintf(os.Stderr, "COMMIT_BLOCK Returned from SwingSet: %s, %v\n", out, err)
|
|
95
94
|
if err != nil {
|
|
@@ -108,7 +107,7 @@ func AfterCommitBlock(keeper Keeper) error {
|
|
|
108
107
|
BlockHeight: endBlockHeight,
|
|
109
108
|
BlockTime: endBlockTime,
|
|
110
109
|
}
|
|
111
|
-
_, err := keeper.BlockingSend(sdk.Context{}
|
|
110
|
+
_, err := keeper.BlockingSend(sdk.Context{}, action)
|
|
112
111
|
|
|
113
112
|
// fmt.Fprintf(os.Stderr, "AFTER_COMMIT_BLOCK Returned from SwingSet: %s, %v\n", out, err)
|
|
114
113
|
if err != nil {
|
package/x/swingset/swingset.go
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
package swingset
|
|
2
2
|
|
|
3
3
|
import (
|
|
4
|
-
"context"
|
|
5
4
|
"encoding/json"
|
|
6
5
|
"fmt"
|
|
7
6
|
"io"
|
|
@@ -34,8 +33,7 @@ func NewPortHandler(k Keeper) vm.PortHandler {
|
|
|
34
33
|
// Receive implements the vm.PortHandler method.
|
|
35
34
|
// It receives and processes an inbound message, returning the
|
|
36
35
|
// JSON-serialized response or an error.
|
|
37
|
-
func (ph portHandler) Receive(
|
|
38
|
-
ctx := sdk.UnwrapSDKContext(cctx)
|
|
36
|
+
func (ph portHandler) Receive(ctx *vm.ControllerContext, str string) (string, error) {
|
|
39
37
|
var msg swingsetMessage
|
|
40
38
|
err := json.Unmarshal([]byte(str), &msg)
|
|
41
39
|
if err != nil {
|
|
@@ -44,7 +42,7 @@ func (ph portHandler) Receive(cctx context.Context, str string) (string, error)
|
|
|
44
42
|
|
|
45
43
|
switch msg.Method {
|
|
46
44
|
case SwingStoreUpdateExportData:
|
|
47
|
-
return ph.handleSwingStoreUpdateExportData(ctx, msg.Args)
|
|
45
|
+
return ph.handleSwingStoreUpdateExportData(ctx.Context, msg.Args)
|
|
48
46
|
|
|
49
47
|
default:
|
|
50
48
|
return "", fmt.Errorf("unrecognized swingset method %s", msg.Method)
|
|
@@ -50,7 +50,7 @@ var (
|
|
|
50
50
|
DefaultBeansPerMinFeeDebit = DefaultBeansPerFeeUnit.Quo(sdk.NewUint(5)) // $0.2
|
|
51
51
|
DefaultBeansPerStorageByte = DefaultBeansPerFeeUnit.Quo(sdk.NewUint(500)) // $0.002
|
|
52
52
|
|
|
53
|
-
DefaultBootstrapVatConfig = "@agoric/
|
|
53
|
+
DefaultBootstrapVatConfig = "@agoric/vats/decentral-core-config.json"
|
|
54
54
|
|
|
55
55
|
DefaultPowerFlagFees = []PowerFlagFee{
|
|
56
56
|
NewPowerFlagFee("SMART_WALLET", sdk.NewCoins(sdk.NewInt64Coin("ubld", 10_000_000))),
|
|
@@ -433,7 +433,7 @@ type MsgInstallBundle struct {
|
|
|
433
433
|
Submitter github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,2,opt,name=submitter,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"submitter" yaml:"submitter"`
|
|
434
434
|
// Either bundle or compressed_bundle will be set.
|
|
435
435
|
// Default compression algorithm is gzip.
|
|
436
|
-
CompressedBundle []byte `protobuf:"bytes,3,opt,name=compressed_bundle,json=compressedBundle,proto3" json:"compressedBundle" yaml:"
|
|
436
|
+
CompressedBundle []byte `protobuf:"bytes,3,opt,name=compressed_bundle,json=compressedBundle,proto3" json:"compressedBundle" yaml:"bcompressedBndle"`
|
|
437
437
|
// Size in bytes of uncompression of compressed_bundle.
|
|
438
438
|
UncompressedSize int64 `protobuf:"varint,4,opt,name=uncompressed_size,json=uncompressedSize,proto3" json:"uncompressedSize"`
|
|
439
439
|
}
|
|
@@ -553,7 +553,7 @@ func init() {
|
|
|
553
553
|
func init() { proto.RegisterFile("agoric/swingset/msgs.proto", fileDescriptor_788baa062b181a57) }
|
|
554
554
|
|
|
555
555
|
var fileDescriptor_788baa062b181a57 = []byte{
|
|
556
|
-
//
|
|
556
|
+
// 789 bytes of a gzipped FileDescriptorProto
|
|
557
557
|
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x56, 0xcf, 0x6f, 0xe3, 0x44,
|
|
558
558
|
0x14, 0x8e, 0xe3, 0x50, 0x36, 0xaf, 0xd9, 0x6d, 0x63, 0x95, 0xad, 0xd7, 0x0b, 0x99, 0xac, 0xa5,
|
|
559
559
|
0x15, 0x01, 0xd4, 0x44, 0xb0, 0xb7, 0xed, 0x29, 0x16, 0x42, 0x5a, 0xa4, 0xa0, 0xc5, 0x2b, 0x84,
|
|
@@ -590,20 +590,20 @@ var fileDescriptor_788baa062b181a57 = []byte{
|
|
|
590
590
|
0x01, 0x8d, 0x2d, 0xcf, 0x33, 0x66, 0xc1, 0xc4, 0xc3, 0xca, 0x0b, 0xd8, 0x1a, 0xf3, 0x7f, 0xf9,
|
|
591
591
|
0xe9, 0x3c, 0x4d, 0x18, 0xca, 0x91, 0x94, 0xa1, 0x87, 0xc2, 0x9e, 0x88, 0x75, 0x33, 0x27, 0x96,
|
|
592
592
|
0x57, 0x56, 0xbf, 0x87, 0x95, 0x29, 0xdf, 0x40, 0xdb, 0x26, 0x7e, 0x98, 0xc1, 0x78, 0x72, 0x9c,
|
|
593
|
-
0x3b, 0x96, 0x79, 0xe7, 0x41, 0xc2, 0xd0, 0x6e, 0x45, 0x1a, 0x85, 0xf7,
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
0x4b, 0x08, 0x00, 0x00,
|
|
593
|
+
0x3b, 0x96, 0x79, 0xe7, 0x41, 0xc2, 0xd0, 0x6e, 0x45, 0x1a, 0x85, 0xf7, 0xfd, 0xdc, 0xfb, 0x02,
|
|
594
|
+
0x25, 0x56, 0xb1, 0x26, 0x56, 0x86, 0xd0, 0x9e, 0x05, 0x0b, 0xf5, 0xa9, 0x7b, 0x89, 0xf9, 0x89,
|
|
595
|
+
0xc9, 0xc6, 0x5e, 0x56, 0x7d, 0x91, 0x7c, 0xe3, 0x5e, 0x62, 0x73, 0x0d, 0xd1, 0x35, 0x50, 0x57,
|
|
596
|
+
0xf7, 0xb6, 0xd8, 0xf8, 0x4f, 0xae, 0x65, 0x90, 0x47, 0xd4, 0x51, 0xbe, 0x85, 0x87, 0xcb, 0x9b,
|
|
597
|
+
0xff, 0xac, 0xbf, 0xf2, 0x1a, 0xe8, 0xaf, 0xd6, 0xd0, 0x3e, 0xb8, 0x55, 0x52, 0xb4, 0x51, 0x4e,
|
|
598
|
+
0xe0, 0xd1, 0xca, 0x8b, 0x42, 0xdf, 0x94, 0xbc, 0xac, 0xd1, 0x3e, 0xbc, 0x5d, 0x53, 0x76, 0x38,
|
|
599
|
+
0x82, 0xd6, 0xd2, 0xc3, 0xb4, 0xbb, 0x29, 0x77, 0x51, 0xa1, 0xf5, 0x6e, 0x53, 0x94, 0xb5, 0x5d,
|
|
600
|
+
0x68, 0xaf, 0x3f, 0xf9, 0x9e, 0xff, 0x73, 0xfa, 0x82, 0x4c, 0x3b, 0xf8, 0x4f, 0xb2, 0xb2, 0xd5,
|
|
601
|
+
0x97, 0xd0, 0xac, 0x1e, 0x50, 0xef, 0x6d, 0xca, 0x2d, 0x69, 0xed, 0xf9, 0xbf, 0xd2, 0x45, 0x49,
|
|
602
|
+
0xe3, 0xab, 0xdf, 0xe6, 0x1d, 0xe9, 0x6a, 0xde, 0x91, 0xae, 0xe7, 0x1d, 0xe9, 0xc7, 0x9b, 0x4e,
|
|
603
|
+
0xed, 0xea, 0xa6, 0x53, 0xfb, 0xfd, 0xa6, 0x53, 0x3b, 0x3a, 0x5c, 0x98, 0xf9, 0xa1, 0xf8, 0x20,
|
|
604
|
+
0x10, 0x15, 0xf9, 0xcc, 0x3b, 0xc4, 0xb3, 0x02, 0xa7, 0xb8, 0x0c, 0xdf, 0x57, 0xdf, 0x0a, 0xfc,
|
|
605
|
+
0x32, 0x8c, 0xb7, 0xf8, 0x67, 0xc0, 0x8b, 0xbf, 0x03, 0x00, 0x00, 0xff, 0xff, 0x99, 0x11, 0x18,
|
|
606
|
+
0xbe, 0x4b, 0x08, 0x00, 0x00,
|
|
607
607
|
}
|
|
608
608
|
|
|
609
609
|
// Reference imports to suppress errors if they are not otherwise used.
|
package/x/vbank/vbank.go
CHANGED
|
@@ -121,9 +121,8 @@ func marshal(event vm.Jsonable) ([]byte, error) {
|
|
|
121
121
|
return json.Marshal(event)
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
-
func (ch portHandler) Receive(
|
|
124
|
+
func (ch portHandler) Receive(ctx *vm.ControllerContext, str string) (ret string, err error) {
|
|
125
125
|
// fmt.Println("vbank.go downcall", str)
|
|
126
|
-
ctx := sdk.UnwrapSDKContext(cctx)
|
|
127
126
|
keeper := ch.keeper
|
|
128
127
|
|
|
129
128
|
var msg portMessage
|
|
@@ -141,7 +140,7 @@ func (ch portHandler) Receive(cctx context.Context, str string) (ret string, err
|
|
|
141
140
|
if err = sdk.ValidateDenom(msg.Denom); err != nil {
|
|
142
141
|
return "", fmt.Errorf("invalid denom %s: %s", msg.Denom, err)
|
|
143
142
|
}
|
|
144
|
-
coin := keeper.GetBalance(ctx, addr, msg.Denom)
|
|
143
|
+
coin := keeper.GetBalance(ctx.Context, addr, msg.Denom)
|
|
145
144
|
packet := coin.Amount.String()
|
|
146
145
|
if err == nil {
|
|
147
146
|
bytes, err := json.Marshal(&packet)
|
|
@@ -163,12 +162,12 @@ func (ch portHandler) Receive(cctx context.Context, str string) (ret string, err
|
|
|
163
162
|
return "", fmt.Errorf("cannot convert %s to int", msg.Amount)
|
|
164
163
|
}
|
|
165
164
|
coins := sdk.NewCoins(sdk.NewCoin(msg.Denom, value))
|
|
166
|
-
if err := keeper.GrabCoins(ctx, addr, coins); err != nil {
|
|
165
|
+
if err := keeper.GrabCoins(ctx.Context, addr, coins); err != nil {
|
|
167
166
|
return "", fmt.Errorf("cannot grab %s coins: %s", coins.Sort().String(), err)
|
|
168
167
|
}
|
|
169
168
|
addressToBalances := make(map[string]sdk.Coins, 1)
|
|
170
169
|
addressToBalances[msg.Sender] = sdk.NewCoins(sdk.NewInt64Coin(msg.Denom, 1))
|
|
171
|
-
bz, err := marshal(getBalanceUpdate(ctx, keeper, addressToBalances))
|
|
170
|
+
bz, err := marshal(getBalanceUpdate(ctx.Context, keeper, addressToBalances))
|
|
172
171
|
if err != nil {
|
|
173
172
|
return "", err
|
|
174
173
|
}
|
|
@@ -191,12 +190,12 @@ func (ch portHandler) Receive(cctx context.Context, str string) (ret string, err
|
|
|
191
190
|
return "", fmt.Errorf("cannot convert %s to int", msg.Amount)
|
|
192
191
|
}
|
|
193
192
|
coins := sdk.NewCoins(sdk.NewCoin(msg.Denom, value))
|
|
194
|
-
if err := keeper.SendCoins(ctx, addr, coins); err != nil {
|
|
193
|
+
if err := keeper.SendCoins(ctx.Context, addr, coins); err != nil {
|
|
195
194
|
return "", fmt.Errorf("cannot give %s coins: %s", coins.Sort().String(), err)
|
|
196
195
|
}
|
|
197
196
|
addressToBalances := make(map[string]sdk.Coins, 1)
|
|
198
197
|
addressToBalances[msg.Recipient] = sdk.NewCoins(sdk.NewInt64Coin(msg.Denom, 1))
|
|
199
|
-
bz, err := marshal(getBalanceUpdate(ctx, keeper, addressToBalances))
|
|
198
|
+
bz, err := marshal(getBalanceUpdate(ctx.Context, keeper, addressToBalances))
|
|
200
199
|
if err != nil {
|
|
201
200
|
return "", err
|
|
202
201
|
}
|
|
@@ -212,20 +211,20 @@ func (ch portHandler) Receive(cctx context.Context, str string) (ret string, err
|
|
|
212
211
|
return "", fmt.Errorf("cannot convert %s to int", msg.Amount)
|
|
213
212
|
}
|
|
214
213
|
coins := sdk.NewCoins(sdk.NewCoin(msg.Denom, value))
|
|
215
|
-
if err := keeper.StoreRewardCoins(ctx, coins); err != nil {
|
|
214
|
+
if err := keeper.StoreRewardCoins(ctx.Context, coins); err != nil {
|
|
216
215
|
return "", fmt.Errorf("cannot store reward %s coins: %s", coins.Sort().String(), err)
|
|
217
216
|
}
|
|
218
217
|
if err != nil {
|
|
219
218
|
return "", err
|
|
220
219
|
}
|
|
221
|
-
state := keeper.GetState(ctx)
|
|
220
|
+
state := keeper.GetState(ctx.Context)
|
|
222
221
|
state.RewardPool = state.RewardPool.Add(coins...)
|
|
223
|
-
keeper.SetState(ctx, state)
|
|
222
|
+
keeper.SetState(ctx.Context, state)
|
|
224
223
|
// We don't supply the module balance, since the controller shouldn't know.
|
|
225
224
|
ret = "true"
|
|
226
225
|
|
|
227
226
|
case "VBANK_GET_MODULE_ACCOUNT_ADDRESS":
|
|
228
|
-
addr := keeper.GetModuleAccountAddress(ctx, msg.ModuleName).String()
|
|
227
|
+
addr := keeper.GetModuleAccountAddress(ctx.Context, msg.ModuleName).String()
|
|
229
228
|
if len(addr) == 0 {
|
|
230
229
|
return "", fmt.Errorf("module account %s not found", msg.ModuleName)
|
|
231
230
|
}
|