@agoric/cosmos 0.33.0 → 0.33.1-dev-800c2bb.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/Makefile +1 -1
- package/app/app.go +109 -16
- package/app/const.go +2 -2
- package/daemon/cmd/root.go +8 -13
- package/package.json +2 -2
- package/proto/agoric/swingset/msgs.proto +10 -0
- package/proto/agoric/swingset/swingset.proto +14 -0
- package/x/swingset/abci.go +24 -17
- package/x/swingset/alias.go +1 -0
- package/x/swingset/client/cli/tx.go +18 -0
- package/x/swingset/genesis.go +11 -6
- package/x/swingset/keeper/keeper.go +131 -56
- package/x/swingset/keeper/migrations.go +27 -0
- package/x/swingset/keeper/msg_server.go +23 -6
- package/x/swingset/keeper/proposal.go +1 -1
- package/x/swingset/keeper/querier.go +3 -3
- package/x/swingset/keeper/snapshotter.go +491 -0
- package/x/swingset/keeper/snapshotter_test.go +185 -0
- package/x/swingset/legacy/v32/params.go +37 -0
- package/x/swingset/legacy/v32/params_test.go +133 -0
- package/x/swingset/module.go +6 -1
- package/x/swingset/types/default-params.go +5 -2
- package/x/swingset/types/expected_keepers.go +1 -0
- package/x/swingset/types/msgs.go +156 -10
- package/x/swingset/types/msgs.pb.go +142 -47
- package/x/swingset/types/msgs_test.go +174 -0
- package/x/swingset/types/swingset.pb.go +280 -51
- package/x/swingset/types/types.go +1 -1
- package/x/vbank/README.md +1 -1
- package/x/vbank/keeper/keeper.go +15 -1
- package/x/vbank/module.go +13 -1
- package/x/vbank/types/expected_keepers.go +3 -1
- package/x/vbank/vbank.go +8 -0
- package/x/vbank/vbank_test.go +70 -9
- package/x/vstorage/keeper/grpc_query.go +2 -2
- package/x/vstorage/keeper/keeper.go +269 -38
- package/x/vstorage/keeper/keeper_test.go +162 -17
- package/x/vstorage/keeper/querier.go +4 -4
- package/x/vstorage/module.go +2 -0
- package/x/vstorage/types/path_keys.go +10 -3
- package/x/vstorage/types/types.go +66 -0
- package/x/vstorage/vstorage.go +118 -25
- package/x/vstorage/vstorage_test.go +297 -0
|
@@ -4,37 +4,59 @@ import (
|
|
|
4
4
|
"encoding/json"
|
|
5
5
|
"errors"
|
|
6
6
|
"fmt"
|
|
7
|
-
"
|
|
7
|
+
stdlog "log"
|
|
8
8
|
"math"
|
|
9
9
|
|
|
10
10
|
"github.com/tendermint/tendermint/libs/log"
|
|
11
11
|
|
|
12
|
+
"github.com/cosmos/cosmos-sdk/baseapp"
|
|
12
13
|
"github.com/cosmos/cosmos-sdk/codec"
|
|
13
14
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
14
15
|
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
|
|
15
16
|
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
|
|
16
17
|
|
|
18
|
+
"github.com/Agoric/agoric-sdk/golang/cosmos/ante"
|
|
17
19
|
"github.com/Agoric/agoric-sdk/golang/cosmos/vm"
|
|
18
20
|
"github.com/Agoric/agoric-sdk/golang/cosmos/x/swingset/types"
|
|
19
21
|
vstoragekeeper "github.com/Agoric/agoric-sdk/golang/cosmos/x/vstorage/keeper"
|
|
22
|
+
vstoragetypes "github.com/Agoric/agoric-sdk/golang/cosmos/x/vstorage/types"
|
|
20
23
|
)
|
|
21
24
|
|
|
22
25
|
// Top-level paths for chain storage should remain synchronized with
|
|
23
|
-
// packages/
|
|
26
|
+
// packages/internal/src/chain-storage-paths.js
|
|
24
27
|
const (
|
|
25
|
-
StoragePathActionQueue
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
StoragePathActionQueue = "actionQueue"
|
|
29
|
+
StoragePathHighPriorityQueue = "highPriorityQueue"
|
|
30
|
+
StoragePathHighPrioritySenders = "highPrioritySenders"
|
|
31
|
+
StoragePathBeansOwing = "beansOwing"
|
|
32
|
+
StoragePathEgress = "egress"
|
|
33
|
+
StoragePathMailbox = "mailbox"
|
|
34
|
+
StoragePathCustom = "published"
|
|
35
|
+
StoragePathBundles = "bundles"
|
|
36
|
+
StoragePathSwingStore = "swingStore"
|
|
32
37
|
)
|
|
33
38
|
|
|
34
|
-
const MaxUint53 = 9007199254740991 // Number.MAX_SAFE_INTEGER = 2**53 - 1
|
|
35
|
-
|
|
36
39
|
const stateKey string = "state"
|
|
37
40
|
|
|
41
|
+
// Contextual information about the message source of an action on an inbound queue.
|
|
42
|
+
// This context should be unique per inboundQueueRecord.
|
|
43
|
+
type actionContext struct {
|
|
44
|
+
// The block height in which the corresponding action was enqueued
|
|
45
|
+
BlockHeight int64 `json:"blockHeight"`
|
|
46
|
+
// The hash of the cosmos transaction that included the message
|
|
47
|
+
// If the action didn't result from a transaction message, a substitute value
|
|
48
|
+
// may be used. For example the VBANK_BALANCE_UPDATE actions use `x/vbank`.
|
|
49
|
+
TxHash string `json:"txHash"`
|
|
50
|
+
// The index of the message within the transaction. If the action didn't
|
|
51
|
+
// result from a cosmos transaction, a number should be chosen to make the
|
|
52
|
+
// actionContext unique. (for example a counter per block and source module).
|
|
53
|
+
MsgIdx int `json:"msgIdx"`
|
|
54
|
+
}
|
|
55
|
+
type inboundQueueRecord struct {
|
|
56
|
+
Action vm.Jsonable `json:"action"`
|
|
57
|
+
Context actionContext `json:"context"`
|
|
58
|
+
}
|
|
59
|
+
|
|
38
60
|
// Keeper maintains the link to data vstorage and exposes getter/setter methods for the various parts of the state machine
|
|
39
61
|
type Keeper struct {
|
|
40
62
|
storeKey sdk.StoreKey
|
|
@@ -51,6 +73,7 @@ type Keeper struct {
|
|
|
51
73
|
}
|
|
52
74
|
|
|
53
75
|
var _ types.SwingSetKeeper = &Keeper{}
|
|
76
|
+
var _ ante.SwingsetKeeper = &Keeper{}
|
|
54
77
|
|
|
55
78
|
// NewKeeper creates a new IBC transfer Keeper instance
|
|
56
79
|
func NewKeeper(
|
|
@@ -77,63 +100,110 @@ func NewKeeper(
|
|
|
77
100
|
}
|
|
78
101
|
}
|
|
79
102
|
|
|
80
|
-
//
|
|
81
|
-
// kept in the kvstore so that changes
|
|
103
|
+
// pushAction appends an action to the controller's specified inbound queue.
|
|
104
|
+
// The queue is kept in the kvstore so that changes are properly reverted if the
|
|
82
105
|
// kvstore is rolled back. By the time the block manager runs, it can commit
|
|
83
106
|
// its SwingSet transactions without fear of side-effecting the world with
|
|
84
107
|
// intermediate transaction state.
|
|
85
108
|
//
|
|
86
|
-
// The
|
|
87
|
-
// `packages/cosmic-swingset/src/make-queue.js`.
|
|
88
|
-
func (k Keeper)
|
|
89
|
-
|
|
90
|
-
if
|
|
91
|
-
|
|
109
|
+
// The inbound queue's format is documented by `makeChainQueue` in
|
|
110
|
+
// `packages/cosmic-swingset/src/helpers/make-queue.js`.
|
|
111
|
+
func (k Keeper) pushAction(ctx sdk.Context, inboundQueuePath string, action vm.Jsonable) error {
|
|
112
|
+
txHash, txHashOk := ctx.Context().Value(baseapp.TxHashContextKey).(string)
|
|
113
|
+
if !txHashOk {
|
|
114
|
+
txHash = "unknown"
|
|
92
115
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
116
|
+
msgIdx, msgIdxOk := ctx.Context().Value(baseapp.TxMsgIdxContextKey).(int)
|
|
117
|
+
if !txHashOk || !msgIdxOk {
|
|
118
|
+
switch action.(type) {
|
|
119
|
+
case *coreEvalAction:
|
|
120
|
+
// This is expected for CORE_EVAL since it's not in a transaction
|
|
121
|
+
// (deferred by governance to a BeginBlocker).
|
|
122
|
+
default:
|
|
123
|
+
stdlog.Printf("error while extracting context for action %q\n", action)
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
record := inboundQueueRecord{Action: action, Context: actionContext{BlockHeight: ctx.BlockHeight(), TxHash: txHash, MsgIdx: msgIdx}}
|
|
127
|
+
bz, err := json.Marshal(record)
|
|
96
128
|
if err != nil {
|
|
97
129
|
return err
|
|
98
130
|
}
|
|
99
131
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
return errors.New("actionQueue overflow")
|
|
103
|
-
}
|
|
132
|
+
return k.vstorageKeeper.PushQueueItem(ctx, inboundQueuePath, string(bz))
|
|
133
|
+
}
|
|
104
134
|
|
|
105
|
-
|
|
106
|
-
|
|
135
|
+
// PushAction appends an action to the controller's actionQueue.
|
|
136
|
+
func (k Keeper) PushAction(ctx sdk.Context, action vm.Jsonable) error {
|
|
137
|
+
return k.pushAction(ctx, StoragePathActionQueue, action)
|
|
138
|
+
}
|
|
107
139
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
return
|
|
140
|
+
// PushAction appends an action to the controller's highPriorityQueue.
|
|
141
|
+
func (k Keeper) PushHighPriorityAction(ctx sdk.Context, action vm.Jsonable) error {
|
|
142
|
+
return k.pushAction(ctx, StoragePathHighPriorityQueue, action)
|
|
111
143
|
}
|
|
112
144
|
|
|
113
|
-
func (k Keeper)
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
indexStr := k.vstorageKeeper.GetData(ctx, "actionQueue."+name)
|
|
117
|
-
if indexStr != "" {
|
|
118
|
-
index, err = strconv.ParseUint(indexStr, 10, 64)
|
|
119
|
-
}
|
|
120
|
-
return index, err
|
|
145
|
+
func (k Keeper) IsHighPriorityAddress(ctx sdk.Context, addr sdk.AccAddress) (bool, error) {
|
|
146
|
+
path := StoragePathHighPrioritySenders + "." + addr.String()
|
|
147
|
+
return k.vstorageKeeper.HasEntry(ctx, path), nil
|
|
121
148
|
}
|
|
122
149
|
|
|
123
|
-
func (k Keeper)
|
|
124
|
-
|
|
150
|
+
func (k Keeper) InboundQueueLength(ctx sdk.Context) (int32, error) {
|
|
151
|
+
size := sdk.NewInt(0)
|
|
152
|
+
|
|
153
|
+
highPriorityQueueLength, err := k.vstorageKeeper.GetQueueLength(ctx, StoragePathHighPriorityQueue)
|
|
125
154
|
if err != nil {
|
|
126
155
|
return 0, err
|
|
127
156
|
}
|
|
128
|
-
|
|
157
|
+
size = size.Add(highPriorityQueueLength)
|
|
158
|
+
|
|
159
|
+
actionQueueLength, err := k.vstorageKeeper.GetQueueLength(ctx, StoragePathActionQueue)
|
|
129
160
|
if err != nil {
|
|
130
161
|
return 0, err
|
|
131
162
|
}
|
|
132
|
-
size
|
|
133
|
-
|
|
163
|
+
size = size.Add(actionQueueLength)
|
|
164
|
+
|
|
165
|
+
if !size.IsInt64() {
|
|
166
|
+
return 0, fmt.Errorf("inbound queue size too big: %s", size)
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
int64Size := size.Int64()
|
|
170
|
+
if int64Size > math.MaxInt32 {
|
|
134
171
|
return math.MaxInt32, nil
|
|
135
172
|
}
|
|
136
|
-
return int32(
|
|
173
|
+
return int32(int64Size), nil
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
func (k Keeper) UpdateQueueAllowed(ctx sdk.Context) error {
|
|
177
|
+
params := k.GetParams(ctx)
|
|
178
|
+
inboundQueueMax, found := types.QueueSizeEntry(params.QueueMax, types.QueueInbound)
|
|
179
|
+
if !found {
|
|
180
|
+
return errors.New("could not find max inboundQueue size in params")
|
|
181
|
+
}
|
|
182
|
+
inboundMempoolQueueMax := inboundQueueMax / 2
|
|
183
|
+
|
|
184
|
+
inboundQueueSize, err := k.InboundQueueLength(ctx)
|
|
185
|
+
if err != nil {
|
|
186
|
+
return err
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
var inboundQueueAllowed int32
|
|
190
|
+
if inboundQueueMax > inboundQueueSize {
|
|
191
|
+
inboundQueueAllowed = inboundQueueMax - inboundQueueSize
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
var inboundMempoolQueueAllowed int32
|
|
195
|
+
if inboundMempoolQueueMax > inboundQueueSize {
|
|
196
|
+
inboundMempoolQueueAllowed = inboundMempoolQueueMax - inboundQueueSize
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
state := k.GetState(ctx)
|
|
200
|
+
state.QueueAllowed = []types.QueueSize{
|
|
201
|
+
{Key: types.QueueInbound, Size_: inboundQueueAllowed},
|
|
202
|
+
{Key: types.QueueInboundMempool, Size_: inboundMempoolQueueAllowed},
|
|
203
|
+
}
|
|
204
|
+
k.SetState(ctx, state)
|
|
205
|
+
|
|
206
|
+
return nil
|
|
137
207
|
}
|
|
138
208
|
|
|
139
209
|
// BlockingSend sends a message to the controller and blocks the Golang process
|
|
@@ -190,18 +260,18 @@ func getBeansOwingPathForAddress(addr sdk.AccAddress) string {
|
|
|
190
260
|
// the FeeAccount but has not yet paid.
|
|
191
261
|
func (k Keeper) GetBeansOwing(ctx sdk.Context, addr sdk.AccAddress) sdk.Uint {
|
|
192
262
|
path := getBeansOwingPathForAddress(addr)
|
|
193
|
-
|
|
194
|
-
if
|
|
263
|
+
entry := k.vstorageKeeper.GetEntry(ctx, path)
|
|
264
|
+
if !entry.HasData() {
|
|
195
265
|
return sdk.ZeroUint()
|
|
196
266
|
}
|
|
197
|
-
return sdk.NewUintFromString(
|
|
267
|
+
return sdk.NewUintFromString(entry.StringValue())
|
|
198
268
|
}
|
|
199
269
|
|
|
200
270
|
// SetBeansOwing sets the number of beans that the given address owes to the
|
|
201
271
|
// feeCollector but has not yet paid.
|
|
202
272
|
func (k Keeper) SetBeansOwing(ctx sdk.Context, addr sdk.AccAddress, beans sdk.Uint) {
|
|
203
273
|
path := getBeansOwingPathForAddress(addr)
|
|
204
|
-
k.vstorageKeeper.SetStorage(ctx, path, beans.String())
|
|
274
|
+
k.vstorageKeeper.SetStorage(ctx, vstoragetypes.NewStorageEntry(path, beans.String()))
|
|
205
275
|
}
|
|
206
276
|
|
|
207
277
|
// ChargeBeans charges the given address the given number of beans. It divides
|
|
@@ -304,13 +374,13 @@ func (k Keeper) ChargeForProvisioning(ctx sdk.Context, submitter, addr sdk.AccAd
|
|
|
304
374
|
// GetEgress gets the entire egress struct for a peer
|
|
305
375
|
func (k Keeper) GetEgress(ctx sdk.Context, addr sdk.AccAddress) types.Egress {
|
|
306
376
|
path := StoragePathEgress + "." + addr.String()
|
|
307
|
-
|
|
308
|
-
if
|
|
377
|
+
entry := k.vstorageKeeper.GetEntry(ctx, path)
|
|
378
|
+
if !entry.HasData() {
|
|
309
379
|
return types.Egress{}
|
|
310
380
|
}
|
|
311
381
|
|
|
312
382
|
var egress types.Egress
|
|
313
|
-
err := json.Unmarshal([]byte(
|
|
383
|
+
err := json.Unmarshal([]byte(entry.StringValue()), &egress)
|
|
314
384
|
if err != nil {
|
|
315
385
|
panic(err)
|
|
316
386
|
}
|
|
@@ -327,8 +397,8 @@ func (k Keeper) SetEgress(ctx sdk.Context, egress *types.Egress) error {
|
|
|
327
397
|
return err
|
|
328
398
|
}
|
|
329
399
|
|
|
330
|
-
// FIXME: We
|
|
331
|
-
k.vstorageKeeper.LegacySetStorageAndNotify(ctx, path, string(bz))
|
|
400
|
+
// FIXME: We should use just SetStorageAndNotify here, but solo needs legacy for now.
|
|
401
|
+
k.vstorageKeeper.LegacySetStorageAndNotify(ctx, vstoragetypes.NewStorageEntry(path, string(bz)))
|
|
332
402
|
|
|
333
403
|
// Now make sure the corresponding account has been initialised.
|
|
334
404
|
if acc := k.accountKeeper.GetAccount(ctx, egress.Peer); acc != nil {
|
|
@@ -354,13 +424,18 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger {
|
|
|
354
424
|
// GetMailbox gets the entire mailbox struct for a peer
|
|
355
425
|
func (k Keeper) GetMailbox(ctx sdk.Context, peer string) string {
|
|
356
426
|
path := StoragePathMailbox + "." + peer
|
|
357
|
-
return k.vstorageKeeper.
|
|
427
|
+
return k.vstorageKeeper.GetEntry(ctx, path).StringValue()
|
|
358
428
|
}
|
|
359
429
|
|
|
360
430
|
// SetMailbox sets the entire mailbox struct for a peer
|
|
361
431
|
func (k Keeper) SetMailbox(ctx sdk.Context, peer string, mailbox string) {
|
|
362
432
|
path := StoragePathMailbox + "." + peer
|
|
363
|
-
|
|
433
|
+
// FIXME: We should use just SetStorageAndNotify here, but solo needs legacy for now.
|
|
434
|
+
k.vstorageKeeper.LegacySetStorageAndNotify(ctx, vstoragetypes.NewStorageEntry(path, mailbox))
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
func (k Keeper) ExportSwingStore(ctx sdk.Context) []*vstoragetypes.DataEntry {
|
|
438
|
+
return k.vstorageKeeper.ExportStorageFromPrefix(ctx, StoragePathSwingStore)
|
|
364
439
|
}
|
|
365
440
|
|
|
366
441
|
func (k Keeper) PathToEncodedKey(path string) []byte {
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
package keeper
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
v32 "github.com/Agoric/agoric-sdk/golang/cosmos/x/swingset/legacy/v32"
|
|
5
|
+
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
6
|
+
)
|
|
7
|
+
|
|
8
|
+
// Migrator handles in-place store migrations.
|
|
9
|
+
type Migrator struct {
|
|
10
|
+
keeper Keeper
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// NewMigrator returns a new migrator based on the keeper.
|
|
14
|
+
func NewMigrator(keeper Keeper) Migrator {
|
|
15
|
+
return Migrator{keeper: keeper}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Migrate1to2 migrates from version 1 to 2.
|
|
19
|
+
func (m Migrator) Migrate1to2(ctx sdk.Context) error {
|
|
20
|
+
params := m.keeper.GetParams(ctx)
|
|
21
|
+
newParams, err := v32.UpdateParams(params)
|
|
22
|
+
if err != nil {
|
|
23
|
+
return err
|
|
24
|
+
}
|
|
25
|
+
m.keeper.SetParams(ctx, newParams)
|
|
26
|
+
return nil
|
|
27
|
+
}
|
|
@@ -30,6 +30,19 @@ type deliverInboundAction struct {
|
|
|
30
30
|
BlockTime int64 `json:"blockTime"`
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
func (keeper msgServer) routeAction(ctx sdk.Context, msg vm.ControllerAdmissionMsg, action vm.Jsonable) error {
|
|
34
|
+
isHighPriority, err := msg.IsHighPriority(ctx, keeper)
|
|
35
|
+
if err != nil {
|
|
36
|
+
return err
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if isHighPriority {
|
|
40
|
+
return keeper.PushHighPriorityAction(ctx, action)
|
|
41
|
+
} else {
|
|
42
|
+
return keeper.PushAction(ctx, action)
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
33
46
|
func (keeper msgServer) DeliverInbound(goCtx context.Context, msg *types.MsgDeliverInbound) (*types.MsgDeliverInboundResponse, error) {
|
|
34
47
|
ctx := sdk.UnwrapSDKContext(goCtx)
|
|
35
48
|
|
|
@@ -50,7 +63,7 @@ func (keeper msgServer) DeliverInbound(goCtx context.Context, msg *types.MsgDeli
|
|
|
50
63
|
BlockTime: ctx.BlockTime().Unix(),
|
|
51
64
|
}
|
|
52
65
|
|
|
53
|
-
err := keeper.
|
|
66
|
+
err := keeper.routeAction(ctx, msg, action)
|
|
54
67
|
// fmt.Fprintln(os.Stderr, "Returned from SwingSet", out, err)
|
|
55
68
|
if err != nil {
|
|
56
69
|
return nil, err
|
|
@@ -78,7 +91,7 @@ func (keeper msgServer) WalletAction(goCtx context.Context, msg *types.MsgWallet
|
|
|
78
91
|
}
|
|
79
92
|
// fmt.Fprintf(os.Stderr, "Context is %+v\n", ctx)
|
|
80
93
|
|
|
81
|
-
err := keeper.
|
|
94
|
+
err := keeper.routeAction(ctx, msg, action)
|
|
82
95
|
// fmt.Fprintln(os.Stderr, "Returned from SwingSet", out, err)
|
|
83
96
|
if err != nil {
|
|
84
97
|
return nil, err
|
|
@@ -87,7 +100,7 @@ func (keeper msgServer) WalletAction(goCtx context.Context, msg *types.MsgWallet
|
|
|
87
100
|
}
|
|
88
101
|
|
|
89
102
|
type walletSpendAction struct {
|
|
90
|
-
Type string `json:"type"` //
|
|
103
|
+
Type string `json:"type"` // WALLET_SPEND_ACTION
|
|
91
104
|
Owner string `json:"owner"`
|
|
92
105
|
SpendAction string `json:"spendAction"`
|
|
93
106
|
BlockHeight int64 `json:"blockHeight"`
|
|
@@ -105,7 +118,7 @@ func (keeper msgServer) WalletSpendAction(goCtx context.Context, msg *types.MsgW
|
|
|
105
118
|
BlockTime: ctx.BlockTime().Unix(),
|
|
106
119
|
}
|
|
107
120
|
// fmt.Fprintf(os.Stderr, "Context is %+v\n", ctx)
|
|
108
|
-
err := keeper.
|
|
121
|
+
err := keeper.routeAction(ctx, msg, action)
|
|
109
122
|
if err != nil {
|
|
110
123
|
return nil, err
|
|
111
124
|
}
|
|
@@ -141,7 +154,7 @@ func (keeper msgServer) Provision(goCtx context.Context, msg *types.MsgProvision
|
|
|
141
154
|
return nil, err
|
|
142
155
|
}
|
|
143
156
|
|
|
144
|
-
err = keeper.
|
|
157
|
+
err = keeper.routeAction(ctx, msg, action)
|
|
145
158
|
// fmt.Fprintln(os.Stderr, "Returned from SwingSet", out, err)
|
|
146
159
|
if err != nil {
|
|
147
160
|
return nil, err
|
|
@@ -160,6 +173,10 @@ type installBundleAction struct {
|
|
|
160
173
|
func (keeper msgServer) InstallBundle(goCtx context.Context, msg *types.MsgInstallBundle) (*types.MsgInstallBundleResponse, error) {
|
|
161
174
|
ctx := sdk.UnwrapSDKContext(goCtx)
|
|
162
175
|
|
|
176
|
+
err := msg.Uncompress()
|
|
177
|
+
if err != nil {
|
|
178
|
+
return nil, err
|
|
179
|
+
}
|
|
163
180
|
action := &installBundleAction{
|
|
164
181
|
MsgInstallBundle: msg,
|
|
165
182
|
Type: "INSTALL_BUNDLE",
|
|
@@ -167,7 +184,7 @@ func (keeper msgServer) InstallBundle(goCtx context.Context, msg *types.MsgInsta
|
|
|
167
184
|
BlockTime: ctx.BlockTime().Unix(),
|
|
168
185
|
}
|
|
169
186
|
|
|
170
|
-
err
|
|
187
|
+
err = keeper.routeAction(ctx, msg, action)
|
|
171
188
|
// fmt.Fprintln(os.Stderr, "Returned from SwingSet", out, err)
|
|
172
189
|
if err != nil {
|
|
173
190
|
return nil, err
|
|
@@ -79,12 +79,12 @@ func queryMailbox(ctx sdk.Context, path []string, req abci.RequestQuery, keeper
|
|
|
79
79
|
|
|
80
80
|
// nolint: unparam
|
|
81
81
|
func legacyQueryStorage(ctx sdk.Context, path string, req abci.RequestQuery, keeper Keeper, legacyQuerierCdc *codec.LegacyAmino) (res []byte, err error) {
|
|
82
|
-
|
|
83
|
-
if
|
|
82
|
+
entry := keeper.vstorageKeeper.GetEntry(ctx, path)
|
|
83
|
+
if !entry.HasData() {
|
|
84
84
|
return []byte{}, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "could not get swingset %+v", path)
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
bz, err2 := codec.MarshalJSONIndent(legacyQuerierCdc, vstoragetypes.Data{Value:
|
|
87
|
+
bz, err2 := codec.MarshalJSONIndent(legacyQuerierCdc, vstoragetypes.Data{Value: entry.StringValue()})
|
|
88
88
|
if err2 != nil {
|
|
89
89
|
return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err2.Error())
|
|
90
90
|
}
|