@agoric/cosmos 0.34.2-dev-7ffae88.0 → 0.34.2-dev-c5284e4.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 (85) hide show
  1. package/Makefile +7 -0
  2. package/ante/ante.go +6 -5
  3. package/ante/fee.go +8 -7
  4. package/ante/inbound_test.go +3 -2
  5. package/ante/vm_admission.go +2 -1
  6. package/app/app.go +107 -59
  7. package/app/export.go +13 -6
  8. package/cmd/libdaemon/main_test.go +2 -1
  9. package/daemon/cmd/root.go +12 -5
  10. package/e2e_test/Makefile +29 -0
  11. package/e2e_test/README.md +100 -0
  12. package/e2e_test/go.mod +217 -0
  13. package/e2e_test/go.sum +1323 -0
  14. package/e2e_test/ibc_conformance_test.go +56 -0
  15. package/e2e_test/pfm_test.go +613 -0
  16. package/e2e_test/util.go +271 -0
  17. package/git-revision.txt +1 -1
  18. package/go.mod +15 -7
  19. package/go.sum +8 -5
  20. package/package.json +3 -3
  21. package/proto/agoric/vlocalchain/.clang-format +7 -0
  22. package/proto/agoric/vlocalchain/vlocalchain.proto +31 -0
  23. package/vm/action.go +5 -4
  24. package/vm/action_test.go +31 -11
  25. package/vm/controller.go +22 -1
  26. package/vm/server.go +1 -1
  27. package/x/swingset/abci.go +10 -10
  28. package/x/swingset/client/cli/tx.go +4 -0
  29. package/x/swingset/handler.go +2 -1
  30. package/x/swingset/keeper/keeper.go +6 -12
  31. package/x/swingset/keeper/msg_server.go +18 -18
  32. package/x/swingset/keeper/proposal.go +13 -3
  33. package/x/swingset/keeper/querier.go +12 -11
  34. package/x/swingset/keeper/swing_store_exports_handler.go +7 -3
  35. package/x/swingset/proposal_handler.go +2 -1
  36. package/x/swingset/types/expected_keepers.go +3 -2
  37. package/x/swingset/types/msgs.go +25 -24
  38. package/x/swingset/types/params.go +2 -1
  39. package/x/swingset/types/proposal.go +5 -4
  40. package/x/vbank/handler.go +2 -1
  41. package/x/vbank/keeper/querier.go +4 -3
  42. package/x/vbank/vbank.go +3 -3
  43. package/x/vibc/alias.go +3 -0
  44. package/x/vibc/handler.go +16 -9
  45. package/x/vibc/keeper/keeper.go +102 -65
  46. package/x/vibc/keeper/triggers.go +101 -0
  47. package/x/vibc/module.go +4 -2
  48. package/x/vibc/types/expected_keepers.go +13 -0
  49. package/x/vibc/types/ibc_module.go +335 -0
  50. package/x/vibc/types/receiver.go +160 -0
  51. package/x/vlocalchain/alias.go +19 -0
  52. package/x/vlocalchain/handler.go +20 -0
  53. package/x/vlocalchain/keeper/keeper.go +279 -0
  54. package/x/vlocalchain/keeper/keeper_test.go +32 -0
  55. package/x/vlocalchain/types/codec.go +34 -0
  56. package/x/vlocalchain/types/key.go +27 -0
  57. package/x/vlocalchain/types/msgs.go +16 -0
  58. package/x/vlocalchain/types/vlocalchain.pb.go +1072 -0
  59. package/x/vlocalchain/vlocalchain.go +109 -0
  60. package/x/vlocalchain/vlocalchain_test.go +305 -0
  61. package/x/vstorage/handler.go +2 -1
  62. package/x/vstorage/keeper/keeper.go +5 -4
  63. package/x/vstorage/keeper/querier.go +6 -5
  64. package/x/vstorage/keeper/querier_test.go +4 -3
  65. package/proto/agoric/lien/genesis.proto +0 -25
  66. package/proto/agoric/lien/lien.proto +0 -25
  67. package/x/lien/alias.go +0 -17
  68. package/x/lien/genesis.go +0 -58
  69. package/x/lien/genesis_test.go +0 -101
  70. package/x/lien/keeper/account.go +0 -290
  71. package/x/lien/keeper/keeper.go +0 -255
  72. package/x/lien/keeper/keeper_test.go +0 -623
  73. package/x/lien/lien.go +0 -205
  74. package/x/lien/lien_test.go +0 -533
  75. package/x/lien/module.go +0 -115
  76. package/x/lien/spec/01_concepts.md +0 -146
  77. package/x/lien/spec/02_messages.md +0 -96
  78. package/x/lien/types/accountkeeper.go +0 -81
  79. package/x/lien/types/accountstate.go +0 -27
  80. package/x/lien/types/expected_keepers.go +0 -18
  81. package/x/lien/types/genesis.pb.go +0 -567
  82. package/x/lien/types/key.go +0 -25
  83. package/x/lien/types/lien.pb.go +0 -403
  84. package/x/vibc/ibc.go +0 -394
  85. /package/{src/index.cjs → index.cjs} +0 -0
@@ -15,27 +15,27 @@ import (
15
15
  )
16
16
 
17
17
  type beginBlockAction struct {
18
- vm.ActionHeader `actionType:"BEGIN_BLOCK"`
19
- ChainID string `json:"chainID"`
20
- Params types.Params `json:"params"`
18
+ *vm.ActionHeader `actionType:"BEGIN_BLOCK"`
19
+ ChainID string `json:"chainID"`
20
+ Params types.Params `json:"params"`
21
21
  }
22
22
 
23
23
  type endBlockAction struct {
24
- vm.ActionHeader `actionType:"END_BLOCK"`
24
+ *vm.ActionHeader `actionType:"END_BLOCK"`
25
25
  }
26
26
 
27
27
  type commitBlockAction struct {
28
- vm.ActionHeader `actionType:"COMMIT_BLOCK"`
28
+ *vm.ActionHeader `actionType:"COMMIT_BLOCK"`
29
29
  }
30
30
 
31
31
  type afterCommitBlockAction struct {
32
- vm.ActionHeader `actionType:"AFTER_COMMIT_BLOCK"`
32
+ *vm.ActionHeader `actionType:"AFTER_COMMIT_BLOCK"`
33
33
  }
34
34
 
35
35
  func BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock, keeper Keeper) error {
36
36
  defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyBeginBlocker)
37
37
 
38
- action := &beginBlockAction{
38
+ action := beginBlockAction{
39
39
  ChainID: ctx.ChainID(),
40
40
  Params: keeper.GetParams(ctx),
41
41
  }
@@ -56,7 +56,7 @@ var endBlockTime int64
56
56
  func EndBlock(ctx sdk.Context, req abci.RequestEndBlock, keeper Keeper) ([]abci.ValidatorUpdate, error) {
57
57
  defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyEndBlocker)
58
58
 
59
- action := &endBlockAction{}
59
+ action := endBlockAction{}
60
60
  _, err := keeper.BlockingSend(ctx, action)
61
61
 
62
62
  // fmt.Fprintf(os.Stderr, "END_BLOCK Returned from SwingSet: %s, %v\n", out, err)
@@ -83,7 +83,7 @@ func getEndBlockContext() sdk.Context {
83
83
  func CommitBlock(keeper Keeper) error {
84
84
  defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), "commit_blocker")
85
85
 
86
- action := &commitBlockAction{}
86
+ action := commitBlockAction{}
87
87
  _, err := keeper.BlockingSend(getEndBlockContext(), action)
88
88
 
89
89
  // fmt.Fprintf(os.Stderr, "COMMIT_BLOCK Returned from SwingSet: %s, %v\n", out, err)
@@ -98,7 +98,7 @@ func CommitBlock(keeper Keeper) error {
98
98
  func AfterCommitBlock(keeper Keeper) error {
99
99
  // defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), "commit_blocker")
100
100
 
101
- action := &afterCommitBlockAction{}
101
+ action := afterCommitBlockAction{}
102
102
  _, err := keeper.BlockingSend(getEndBlockContext(), action)
103
103
 
104
104
  // fmt.Fprintf(os.Stderr, "AFTER_COMMIT_BLOCK Returned from SwingSet: %s, %v\n", out, err)
@@ -253,11 +253,13 @@ Specify at least one pair of permit.json and code.js files`,
253
253
  return err
254
254
  }
255
255
 
256
+ //nolint:staticcheck // Agoric is still using the legacy proposal shape
256
257
  title, err := cmd.Flags().GetString(govcli.FlagTitle)
257
258
  if err != nil {
258
259
  return err
259
260
  }
260
261
 
262
+ //nolint:staticcheck // Agoric is still using the legacy proposal shape
261
263
  description, err := cmd.Flags().GetString(govcli.FlagDescription)
262
264
  if err != nil {
263
265
  return err
@@ -315,7 +317,9 @@ Specify at least one pair of permit.json and code.js files`,
315
317
  },
316
318
  }
317
319
 
320
+ //nolint:staticcheck // Agoric is still using the legacy proposal shape
318
321
  cmd.Flags().String(govcli.FlagTitle, "", "title of proposal")
322
+ //nolint:staticcheck // Agoric is still using the legacy proposal shape
319
323
  cmd.Flags().String(govcli.FlagDescription, "", "description of proposal")
320
324
  cmd.Flags().String(govcli.FlagDeposit, "", "deposit for proposal")
321
325
 
@@ -5,6 +5,7 @@ import (
5
5
 
6
6
  "github.com/Agoric/agoric-sdk/golang/cosmos/x/swingset/keeper"
7
7
 
8
+ sdkioerrors "cosmossdk.io/errors"
8
9
  sdk "github.com/cosmos/cosmos-sdk/types"
9
10
  sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
10
11
  )
@@ -29,7 +30,7 @@ func NewHandler(k Keeper) sdk.Handler {
29
30
 
30
31
  default:
31
32
  errMsg := fmt.Sprintf("Unrecognized swingset Msg type: %T", msg)
32
- return nil, sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, errMsg)
33
+ return nil, sdkioerrors.Wrap(sdkerrors.ErrUnknownRequest, errMsg)
33
34
  }
34
35
  }
35
36
  }
@@ -142,13 +142,7 @@ func (k Keeper) pushAction(ctx sdk.Context, inboundQueuePath string, action vm.A
142
142
  }
143
143
  msgIdx, msgIdxOk := ctx.Context().Value(baseapp.TxMsgIdxContextKey).(int)
144
144
  if !txHashOk || !msgIdxOk {
145
- switch action.(type) {
146
- case *coreEvalAction:
147
- // This is expected for CORE_EVAL since it's not in a transaction
148
- // (deferred by governance to a BeginBlocker).
149
- default:
150
- stdlog.Printf("error while extracting context for action %q\n", action)
151
- }
145
+ stdlog.Printf("error while extracting context for action %q\n", action)
152
146
  }
153
147
  record := inboundQueueRecord{Action: action, Context: actionContext{BlockHeight: ctx.BlockHeight(), TxHash: txHash, MsgIdx: msgIdx}}
154
148
  bz, err := json.Marshal(record)
@@ -288,9 +282,9 @@ func (k Keeper) SetState(ctx sdk.Context, state types.State) {
288
282
 
289
283
  // GetBeansPerUnit returns a map taken from the current SwingSet parameters from
290
284
  // a unit (key) string to an unsigned integer amount of beans.
291
- func (k Keeper) GetBeansPerUnit(ctx sdk.Context) map[string]sdk.Uint {
285
+ func (k Keeper) GetBeansPerUnit(ctx sdk.Context) map[string]sdkmath.Uint {
292
286
  params := k.GetParams(ctx)
293
- beansPerUnit := make(map[string]sdk.Uint, len(params.BeansPerUnit))
287
+ beansPerUnit := make(map[string]sdkmath.Uint, len(params.BeansPerUnit))
294
288
  for _, bpu := range params.BeansPerUnit {
295
289
  beansPerUnit[bpu.Key] = bpu.Beans
296
290
  }
@@ -303,7 +297,7 @@ func getBeansOwingPathForAddress(addr sdk.AccAddress) string {
303
297
 
304
298
  // GetBeansOwing returns the number of beans that the given address owes to
305
299
  // the FeeAccount but has not yet paid.
306
- func (k Keeper) GetBeansOwing(ctx sdk.Context, addr sdk.AccAddress) sdk.Uint {
300
+ func (k Keeper) GetBeansOwing(ctx sdk.Context, addr sdk.AccAddress) sdkmath.Uint {
307
301
  path := getBeansOwingPathForAddress(addr)
308
302
  entry := k.vstorageKeeper.GetEntry(ctx, path)
309
303
  if !entry.HasValue() {
@@ -314,7 +308,7 @@ func (k Keeper) GetBeansOwing(ctx sdk.Context, addr sdk.AccAddress) sdk.Uint {
314
308
 
315
309
  // SetBeansOwing sets the number of beans that the given address owes to the
316
310
  // feeCollector but has not yet paid.
317
- func (k Keeper) SetBeansOwing(ctx sdk.Context, addr sdk.AccAddress, beans sdk.Uint) {
311
+ func (k Keeper) SetBeansOwing(ctx sdk.Context, addr sdk.AccAddress, beans sdkmath.Uint) {
318
312
  path := getBeansOwingPathForAddress(addr)
319
313
  k.vstorageKeeper.SetStorage(ctx, agoric.NewKVEntry(path, beans.String()))
320
314
  }
@@ -322,7 +316,7 @@ func (k Keeper) SetBeansOwing(ctx sdk.Context, addr sdk.AccAddress, beans sdk.Ui
322
316
  // ChargeBeans charges the given address the given number of beans. It divides
323
317
  // the beans into the number to debit immediately vs. the number to store in the
324
318
  // beansOwing.
325
- func (k Keeper) ChargeBeans(ctx sdk.Context, addr sdk.AccAddress, beans sdk.Uint) error {
319
+ func (k Keeper) ChargeBeans(ctx sdk.Context, addr sdk.AccAddress, beans sdkmath.Uint) error {
326
320
  beansPerUnit := k.GetBeansPerUnit(ctx)
327
321
 
328
322
  wasOwing := k.GetBeansOwing(ctx, addr)
@@ -21,10 +21,10 @@ func NewMsgServerImpl(keeper Keeper) types.MsgServer {
21
21
  var _ types.MsgServer = msgServer{}
22
22
 
23
23
  type deliverInboundAction struct {
24
- vm.ActionHeader `actionType:"DELIVER_INBOUND"`
25
- Peer string `json:"peer"`
26
- Messages [][]interface{} `json:"messages"`
27
- Ack uint64 `json:"ack"`
24
+ *vm.ActionHeader `actionType:"DELIVER_INBOUND"`
25
+ Peer string `json:"peer"`
26
+ Messages [][]interface{} `json:"messages"`
27
+ Ack uint64 `json:"ack"`
28
28
  }
29
29
 
30
30
  func (keeper msgServer) routeAction(ctx sdk.Context, msg vm.ControllerAdmissionMsg, action vm.Action) error {
@@ -48,7 +48,7 @@ func (keeper msgServer) DeliverInbound(goCtx context.Context, msg *types.MsgDeli
48
48
  for i, message := range msg.Messages {
49
49
  messages[i] = []interface{}{msg.Nums[i], message}
50
50
  }
51
- action := &deliverInboundAction{
51
+ action := deliverInboundAction{
52
52
  Peer: msg.Submitter.String(),
53
53
  Messages: messages,
54
54
  Ack: msg.Ack,
@@ -63,9 +63,9 @@ func (keeper msgServer) DeliverInbound(goCtx context.Context, msg *types.MsgDeli
63
63
  }
64
64
 
65
65
  type walletAction struct {
66
- vm.ActionHeader `actionType:"WALLET_ACTION"`
67
- Owner string `json:"owner"`
68
- Action string `json:"action"`
66
+ *vm.ActionHeader `actionType:"WALLET_ACTION"`
67
+ Owner string `json:"owner"`
68
+ Action string `json:"action"`
69
69
  }
70
70
 
71
71
  func (keeper msgServer) WalletAction(goCtx context.Context, msg *types.MsgWalletAction) (*types.MsgWalletActionResponse, error) {
@@ -76,7 +76,7 @@ func (keeper msgServer) WalletAction(goCtx context.Context, msg *types.MsgWallet
76
76
  return nil, err
77
77
  }
78
78
 
79
- action := &walletAction{
79
+ action := walletAction{
80
80
  Owner: msg.Owner.String(),
81
81
  Action: msg.Action,
82
82
  }
@@ -91,9 +91,9 @@ func (keeper msgServer) WalletAction(goCtx context.Context, msg *types.MsgWallet
91
91
  }
92
92
 
93
93
  type walletSpendAction struct {
94
- vm.ActionHeader `actionType:"WALLET_SPEND_ACTION"`
95
- Owner string `json:"owner"`
96
- SpendAction string `json:"spendAction"`
94
+ *vm.ActionHeader `actionType:"WALLET_SPEND_ACTION"`
95
+ Owner string `json:"owner"`
96
+ SpendAction string `json:"spendAction"`
97
97
  }
98
98
 
99
99
  func (keeper msgServer) WalletSpendAction(goCtx context.Context, msg *types.MsgWalletSpendAction) (*types.MsgWalletSpendActionResponse, error) {
@@ -104,7 +104,7 @@ func (keeper msgServer) WalletSpendAction(goCtx context.Context, msg *types.MsgW
104
104
  return nil, err
105
105
  }
106
106
 
107
- action := &walletSpendAction{
107
+ action := walletSpendAction{
108
108
  Owner: msg.Owner.String(),
109
109
  SpendAction: msg.SpendAction,
110
110
  }
@@ -117,7 +117,7 @@ func (keeper msgServer) WalletSpendAction(goCtx context.Context, msg *types.MsgW
117
117
  }
118
118
 
119
119
  type provisionAction struct {
120
- vm.ActionHeader `actionType:"PLEASE_PROVISION"`
120
+ *vm.ActionHeader `actionType:"PLEASE_PROVISION"`
121
121
  *types.MsgProvision
122
122
  AutoProvision bool `json:"autoProvision"`
123
123
  }
@@ -141,7 +141,7 @@ func (keeper msgServer) provisionIfNeeded(ctx sdk.Context, owner sdk.AccAddress)
141
141
  PowerFlags: []string{types.PowerFlagSmartWallet},
142
142
  }
143
143
 
144
- action := &provisionAction{
144
+ action := provisionAction{
145
145
  MsgProvision: msg,
146
146
  AutoProvision: true,
147
147
  }
@@ -163,7 +163,7 @@ func (keeper msgServer) Provision(goCtx context.Context, msg *types.MsgProvision
163
163
  return nil, err
164
164
  }
165
165
 
166
- action := &provisionAction{
166
+ action := provisionAction{
167
167
  MsgProvision: msg,
168
168
  }
169
169
 
@@ -184,7 +184,7 @@ func (keeper msgServer) Provision(goCtx context.Context, msg *types.MsgProvision
184
184
  }
185
185
 
186
186
  type installBundleAction struct {
187
- vm.ActionHeader `actionType:"INSTALL_BUNDLE"`
187
+ *vm.ActionHeader `actionType:"INSTALL_BUNDLE"`
188
188
  *types.MsgInstallBundle
189
189
  }
190
190
 
@@ -195,7 +195,7 @@ func (keeper msgServer) InstallBundle(goCtx context.Context, msg *types.MsgInsta
195
195
  if err != nil {
196
196
  return nil, err
197
197
  }
198
- action := &installBundleAction{
198
+ action := installBundleAction{
199
199
  MsgInstallBundle: msg,
200
200
  }
201
201
 
@@ -1,22 +1,32 @@
1
1
  package keeper
2
2
 
3
3
  import (
4
+ "context"
5
+
4
6
  sdk "github.com/cosmos/cosmos-sdk/types"
5
7
 
6
8
  "github.com/Agoric/agoric-sdk/golang/cosmos/vm"
7
9
  "github.com/Agoric/agoric-sdk/golang/cosmos/x/swingset/types"
10
+ "github.com/cosmos/cosmos-sdk/baseapp"
8
11
  )
9
12
 
10
13
  type coreEvalAction struct {
11
- vm.ActionHeader `actionType:"CORE_EVAL"`
12
- Evals []types.CoreEval `json:"evals"`
14
+ *vm.ActionHeader `actionType:"CORE_EVAL"`
15
+ Evals []types.CoreEval `json:"evals"`
13
16
  }
14
17
 
15
18
  // CoreEvalProposal tells SwingSet to evaluate the given JS code.
16
19
  func (k Keeper) CoreEvalProposal(ctx sdk.Context, p *types.CoreEvalProposal) error {
17
- action := &coreEvalAction{
20
+ action := coreEvalAction{
18
21
  Evals: p.Evals,
19
22
  }
20
23
 
24
+ // While the CoreEvalProposal was originally created by a transaction, by the time it
25
+ // passes by governance, we no longer have its provenance information, so we need to
26
+ // synthesize unique context information.
27
+ // We use a fixed placeholder value for the txHash context. We use `0` for the message
28
+ // index which assumes there is a single proposal per block.
29
+ ctx = ctx.WithContext(context.WithValue(ctx.Context(), baseapp.TxHashContextKey, "x/gov"))
30
+ ctx = ctx.WithContext(context.WithValue(ctx.Context(), baseapp.TxMsgIdxContextKey, 0))
21
31
  return k.PushHighPriorityAction(ctx, action)
22
32
  }
@@ -6,6 +6,7 @@ import (
6
6
 
7
7
  abci "github.com/tendermint/tendermint/abci/types"
8
8
 
9
+ sdkioerrors "cosmossdk.io/errors"
9
10
  "github.com/cosmos/cosmos-sdk/codec"
10
11
  sdk "github.com/cosmos/cosmos-sdk/types"
11
12
  sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
@@ -31,12 +32,12 @@ func NewQuerier(keeper Keeper, legacyQuerierCdc *codec.LegacyAmino) sdk.Querier
31
32
  switch queryType {
32
33
  case QueryEgress:
33
34
  if len(path) < 2 || path[1] == "" {
34
- return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "missing egress address")
35
+ return nil, sdkioerrors.Wrap(sdkerrors.ErrInvalidRequest, "missing egress address")
35
36
  }
36
37
  return queryEgress(ctx, path[1], req, keeper, legacyQuerierCdc)
37
38
  case QueryMailbox:
38
39
  if len(path) < 2 || path[1] == "" {
39
- return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "missing mailbox peer")
40
+ return nil, sdkioerrors.Wrap(sdkerrors.ErrInvalidRequest, "missing mailbox peer")
40
41
  }
41
42
  return queryMailbox(ctx, path[1], req, keeper, legacyQuerierCdc)
42
43
  case LegacyQueryStorage:
@@ -44,7 +45,7 @@ func NewQuerier(keeper Keeper, legacyQuerierCdc *codec.LegacyAmino) sdk.Querier
44
45
  case LegacyQueryKeys:
45
46
  return legacyQueryKeys(ctx, strings.Join(path[1:], "/"), req, keeper, legacyQuerierCdc)
46
47
  default:
47
- return nil, sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, "unknown swingset query path")
48
+ return nil, sdkioerrors.Wrap(sdkerrors.ErrUnknownRequest, "unknown swingset query path")
48
49
  }
49
50
  }
50
51
  }
@@ -53,17 +54,17 @@ func NewQuerier(keeper Keeper, legacyQuerierCdc *codec.LegacyAmino) sdk.Querier
53
54
  func queryEgress(ctx sdk.Context, bech32 string, req abci.RequestQuery, keeper Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) {
54
55
  acc, err := sdk.AccAddressFromBech32(bech32)
55
56
  if err != nil {
56
- return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, err.Error())
57
+ return nil, sdkioerrors.Wrap(sdkerrors.ErrInvalidRequest, err.Error())
57
58
  }
58
59
 
59
60
  egress := keeper.GetEgress(ctx, acc)
60
61
  if egress.Peer.Empty() {
61
- return []byte{}, sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, fmt.Sprintf("egress %s not found", bech32))
62
+ return []byte{}, sdkioerrors.Wrap(sdkerrors.ErrUnknownRequest, fmt.Sprintf("egress %s not found", bech32))
62
63
  }
63
64
 
64
65
  bz, err := codec.MarshalJSONIndent(legacyQuerierCdc, egress)
65
66
  if err != nil {
66
- return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error())
67
+ return nil, sdkioerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error())
67
68
  }
68
69
 
69
70
  return bz, nil
@@ -74,12 +75,12 @@ func queryMailbox(ctx sdk.Context, peer string, req abci.RequestQuery, keeper Ke
74
75
  value := keeper.GetMailbox(ctx, peer)
75
76
 
76
77
  if value == "" {
77
- return []byte{}, sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, "could not get peer mailbox")
78
+ return []byte{}, sdkioerrors.Wrap(sdkerrors.ErrUnknownRequest, "could not get peer mailbox")
78
79
  }
79
80
 
80
81
  bz, err2 := codec.MarshalJSONIndent(legacyQuerierCdc, vstoragetypes.Data{Value: value})
81
82
  if err2 != nil {
82
- return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err2.Error())
83
+ return nil, sdkioerrors.Wrap(sdkerrors.ErrJSONMarshal, err2.Error())
83
84
  }
84
85
 
85
86
  return bz, nil
@@ -89,12 +90,12 @@ func queryMailbox(ctx sdk.Context, peer string, req abci.RequestQuery, keeper Ke
89
90
  func legacyQueryStorage(ctx sdk.Context, path string, req abci.RequestQuery, keeper Keeper, legacyQuerierCdc *codec.LegacyAmino) (res []byte, err error) {
90
91
  entry := keeper.vstorageKeeper.GetEntry(ctx, path)
91
92
  if !entry.HasValue() {
92
- return []byte{}, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "could not get swingset %+v", path)
93
+ return []byte{}, sdkioerrors.Wrapf(sdkerrors.ErrUnknownRequest, "could not get swingset %+v", path)
93
94
  }
94
95
 
95
96
  bz, err2 := codec.MarshalJSONIndent(legacyQuerierCdc, vstoragetypes.Data{Value: entry.StringValue()})
96
97
  if err2 != nil {
97
- return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err2.Error())
98
+ return nil, sdkioerrors.Wrap(sdkerrors.ErrJSONMarshal, err2.Error())
98
99
  }
99
100
 
100
101
  return bz, nil
@@ -111,7 +112,7 @@ func legacyQueryKeys(ctx sdk.Context, path string, req abci.RequestQuery, keeper
111
112
 
112
113
  bz, err2 := codec.MarshalJSONIndent(legacyQuerierCdc, vstoragetypes.Children{Children: chlist})
113
114
  if err2 != nil {
114
- return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err2.Error())
115
+ return nil, sdkioerrors.Wrap(sdkerrors.ErrJSONMarshal, err2.Error())
115
116
  }
116
117
 
117
118
  return bz, nil
@@ -9,10 +9,10 @@ import (
9
9
  "path/filepath"
10
10
  "regexp"
11
11
 
12
+ sdkioerrors "cosmossdk.io/errors"
12
13
  agoric "github.com/Agoric/agoric-sdk/golang/cosmos/types"
13
14
  "github.com/Agoric/agoric-sdk/golang/cosmos/vm"
14
15
  "github.com/Agoric/agoric-sdk/golang/cosmos/x/swingset/types"
15
- sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
16
16
  "github.com/tendermint/tendermint/libs/log"
17
17
  )
18
18
 
@@ -588,7 +588,7 @@ func (exportsHandler SwingStoreExportsHandler) InitiateExport(blockHeight uint64
588
588
  } else if discardErr != nil {
589
589
  // Safe to wrap error and use detailed error info since this error
590
590
  // will not go back into swingset layers
591
- err = sdkerrors.Wrapf(err, "failed to discard swing-store export after failing to process export: %+v", discardErr)
591
+ err = sdkioerrors.Wrapf(err, "failed to discard swing-store export after failing to process export: %+v", discardErr)
592
592
  }
593
593
  }()
594
594
 
@@ -751,11 +751,15 @@ func (exportsHandler SwingStoreExportsHandler) RestoreExport(provider SwingStore
751
751
  }
752
752
  defer os.RemoveAll(exportDir)
753
753
 
754
+ exportsHandler.logger.Info("creating swing-store restore", "exportDir", exportDir, "height", blockHeight)
755
+
754
756
  err = WriteSwingStoreExportToDirectory(provider, exportDir)
755
757
  if err != nil {
756
758
  return err
757
759
  }
758
760
 
761
+ exportsHandler.logger.Info("restoring swing-store", "exportDir", exportDir, "height", blockHeight)
762
+
759
763
  action := &swingStoreRestoreExportAction{
760
764
  Type: swingStoreExportActionType,
761
765
  BlockHeight: blockHeight,
@@ -772,7 +776,7 @@ func (exportsHandler SwingStoreExportsHandler) RestoreExport(provider SwingStore
772
776
  return err
773
777
  }
774
778
 
775
- exportsHandler.logger.Info("restored swing-store export", "exportDir", exportDir, "height", blockHeight)
779
+ exportsHandler.logger.Info("restored swing-store", "exportDir", exportDir, "height", blockHeight)
776
780
 
777
781
  return nil
778
782
  }
@@ -1,6 +1,7 @@
1
1
  package swingset
2
2
 
3
3
  import (
4
+ sdkioerrors "cosmossdk.io/errors"
4
5
  sdk "github.com/cosmos/cosmos-sdk/types"
5
6
  sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
6
7
  govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
@@ -17,7 +18,7 @@ func NewSwingSetProposalHandler(k keeper.Keeper) govv1beta1.Handler {
17
18
  return k.CoreEvalProposal(ctx, c)
18
19
 
19
20
  default:
20
- return sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized swingset proposal content type: %T", c)
21
+ return sdkioerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized swingset proposal content type: %T", c)
21
22
  }
22
23
  }
23
24
  }
@@ -1,6 +1,7 @@
1
1
  package types
2
2
 
3
3
  import (
4
+ sdkmath "cosmossdk.io/math"
4
5
  sdk "github.com/cosmos/cosmos-sdk/types"
5
6
  authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
6
7
  )
@@ -21,8 +22,8 @@ type AccountKeeper interface {
21
22
  }
22
23
 
23
24
  type SwingSetKeeper interface {
24
- GetBeansPerUnit(ctx sdk.Context) map[string]sdk.Uint
25
- ChargeBeans(ctx sdk.Context, addr sdk.AccAddress, beans sdk.Uint) error
25
+ GetBeansPerUnit(ctx sdk.Context) map[string]sdkmath.Uint
26
+ ChargeBeans(ctx sdk.Context, addr sdk.AccAddress, beans sdkmath.Uint) error
26
27
  IsHighPriorityAddress(ctx sdk.Context, addr sdk.AccAddress) (bool, error)
27
28
  GetSmartWalletState(ctx sdk.Context, addr sdk.AccAddress) SmartWalletState
28
29
  ChargeForSmartWallet(ctx sdk.Context, addr sdk.AccAddress) error
@@ -7,6 +7,7 @@ import (
7
7
  "io"
8
8
  "strings"
9
9
 
10
+ sdkioerrors "cosmossdk.io/errors"
10
11
  "github.com/Agoric/agoric-sdk/golang/cosmos/vm"
11
12
  sdk "github.com/cosmos/cosmos-sdk/types"
12
13
  sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
@@ -88,7 +89,7 @@ func NewMsgDeliverInbound(msgs *Messages, submitter sdk.AccAddress) *MsgDeliverI
88
89
  func (msg MsgDeliverInbound) CheckAdmissibility(ctx sdk.Context, data interface{}) error {
89
90
  keeper, ok := data.(SwingSetKeeper)
90
91
  if !ok {
91
- return sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "data must be a SwingSetKeeper, not a %T", data)
92
+ return sdkioerrors.Wrapf(sdkerrors.ErrInvalidRequest, "data must be a SwingSetKeeper, not a %T", data)
92
93
  }
93
94
 
94
95
  /*
@@ -120,14 +121,14 @@ func (msg MsgDeliverInbound) Type() string { return "eventualSend" }
120
121
  // ValidateBasic runs stateless checks on the message
121
122
  func (msg MsgDeliverInbound) ValidateBasic() error {
122
123
  if msg.Submitter.Empty() {
123
- return sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, "Submitter address cannot be empty")
124
+ return sdkioerrors.Wrap(sdkerrors.ErrInvalidAddress, "Submitter address cannot be empty")
124
125
  }
125
126
  if len(msg.Messages) != len(msg.Nums) {
126
- return sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, "Messages and Nums must be the same length")
127
+ return sdkioerrors.Wrap(sdkerrors.ErrUnknownRequest, "Messages and Nums must be the same length")
127
128
  }
128
129
  for _, m := range msg.Messages {
129
130
  if len(m) == 0 {
130
- return sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, "Messages cannot be empty")
131
+ return sdkioerrors.Wrap(sdkerrors.ErrUnknownRequest, "Messages cannot be empty")
131
132
  }
132
133
  }
133
134
  return nil
@@ -161,7 +162,7 @@ func NewMsgWalletAction(owner sdk.AccAddress, action string) *MsgWalletAction {
161
162
  func (msg MsgWalletAction) CheckAdmissibility(ctx sdk.Context, data interface{}) error {
162
163
  keeper, ok := data.(SwingSetKeeper)
163
164
  if !ok {
164
- return sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "data must be a SwingSetKeeper, not a %T", data)
165
+ return sdkioerrors.Wrapf(sdkerrors.ErrInvalidRequest, "data must be a SwingSetKeeper, not a %T", data)
165
166
  }
166
167
 
167
168
  err := checkSmartWalletProvisioned(ctx, keeper, msg.Owner)
@@ -211,13 +212,13 @@ func (msg MsgWalletSpendAction) GetSignBytes() []byte {
211
212
  // ValidateBasic runs stateless checks on the message
212
213
  func (msg MsgWalletAction) ValidateBasic() error {
213
214
  if msg.Owner.Empty() {
214
- return sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, "Owner address cannot be empty")
215
+ return sdkioerrors.Wrap(sdkerrors.ErrInvalidAddress, "Owner address cannot be empty")
215
216
  }
216
217
  if len(strings.TrimSpace(msg.Action)) == 0 {
217
- return sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, "Action cannot be empty")
218
+ return sdkioerrors.Wrap(sdkerrors.ErrUnknownRequest, "Action cannot be empty")
218
219
  }
219
220
  if !json.Valid([]byte(msg.Action)) {
220
- return sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, "Wallet action must be valid JSON")
221
+ return sdkioerrors.Wrap(sdkerrors.ErrJSONUnmarshal, "Wallet action must be valid JSON")
221
222
  }
222
223
  return nil
223
224
  }
@@ -233,7 +234,7 @@ func NewMsgWalletSpendAction(owner sdk.AccAddress, spendAction string) *MsgWalle
233
234
  func (msg MsgWalletSpendAction) CheckAdmissibility(ctx sdk.Context, data interface{}) error {
234
235
  keeper, ok := data.(SwingSetKeeper)
235
236
  if !ok {
236
- return sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "data must be a SwingSetKeeper, not a %T", data)
237
+ return sdkioerrors.Wrapf(sdkerrors.ErrInvalidRequest, "data must be a SwingSetKeeper, not a %T", data)
237
238
  }
238
239
 
239
240
  err := checkSmartWalletProvisioned(ctx, keeper, msg.Owner)
@@ -253,7 +254,7 @@ func (msg MsgWalletSpendAction) GetInboundMsgCount() int32 {
253
254
  func (msg MsgWalletSpendAction) IsHighPriority(ctx sdk.Context, data interface{}) (bool, error) {
254
255
  keeper, ok := data.(SwingSetKeeper)
255
256
  if !ok {
256
- return false, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "data must be a SwingSetKeeper, not a %T", data)
257
+ return false, sdkioerrors.Wrapf(sdkerrors.ErrInvalidRequest, "data must be a SwingSetKeeper, not a %T", data)
257
258
  }
258
259
 
259
260
  return keeper.IsHighPriorityAddress(ctx, msg.Owner)
@@ -266,13 +267,13 @@ func (msg MsgWalletSpendAction) GetSigners() []sdk.AccAddress {
266
267
  // ValidateBasic runs stateless checks on the message
267
268
  func (msg MsgWalletSpendAction) ValidateBasic() error {
268
269
  if msg.Owner.Empty() {
269
- return sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, "Owner address cannot be empty")
270
+ return sdkioerrors.Wrap(sdkerrors.ErrInvalidAddress, "Owner address cannot be empty")
270
271
  }
271
272
  if len(strings.TrimSpace(msg.SpendAction)) == 0 {
272
- return sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, "Spend action cannot be empty")
273
+ return sdkioerrors.Wrap(sdkerrors.ErrUnknownRequest, "Spend action cannot be empty")
273
274
  }
274
275
  if !json.Valid([]byte(msg.SpendAction)) {
275
- return sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, "Wallet spend action must be valid JSON")
276
+ return sdkioerrors.Wrap(sdkerrors.ErrJSONUnmarshal, "Wallet spend action must be valid JSON")
276
277
  }
277
278
  return nil
278
279
  }
@@ -295,13 +296,13 @@ func (msg MsgProvision) Type() string { return "provision" }
295
296
  // ValidateBasic runs stateless checks on the message
296
297
  func (msg MsgProvision) ValidateBasic() error {
297
298
  if msg.Submitter.Empty() {
298
- return sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, "Submitter address cannot be empty")
299
+ return sdkioerrors.Wrap(sdkerrors.ErrInvalidAddress, "Submitter address cannot be empty")
299
300
  }
300
301
  if msg.Address.Empty() {
301
- return sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, "Peer address cannot be empty")
302
+ return sdkioerrors.Wrap(sdkerrors.ErrInvalidAddress, "Peer address cannot be empty")
302
303
  }
303
304
  if len(msg.Nickname) == 0 {
304
- return sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, "Nickname cannot be empty")
305
+ return sdkioerrors.Wrap(sdkerrors.ErrUnknownRequest, "Nickname cannot be empty")
305
306
  }
306
307
  return nil
307
308
  }
@@ -351,7 +352,7 @@ func NewMsgInstallBundle(bundleJson string, submitter sdk.AccAddress) *MsgInstal
351
352
  func (msg MsgInstallBundle) CheckAdmissibility(ctx sdk.Context, data interface{}) error {
352
353
  keeper, ok := data.(SwingSetKeeper)
353
354
  if !ok {
354
- return sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "data must be a SwingSetKeeper, not a %T", data)
355
+ return sdkioerrors.Wrapf(sdkerrors.ErrInvalidRequest, "data must be a SwingSetKeeper, not a %T", data)
355
356
  }
356
357
  return chargeAdmission(ctx, keeper, msg.Submitter, []string{msg.Bundle}, msg.ExpectedUncompressedSize())
357
358
  }
@@ -375,23 +376,23 @@ func (msg MsgInstallBundle) Type() string { return "installBundle" }
375
376
  // ValidateBasic runs stateless checks on the message
376
377
  func (msg MsgInstallBundle) ValidateBasic() error {
377
378
  if msg.Submitter.Empty() {
378
- return sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, "Submitter address cannot be empty")
379
+ return sdkioerrors.Wrap(sdkerrors.ErrInvalidAddress, "Submitter address cannot be empty")
379
380
  }
380
381
  if len(msg.Bundle) == 0 && len(msg.CompressedBundle) == 0 {
381
- return sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, "Bundle cannot be empty")
382
+ return sdkioerrors.Wrap(sdkerrors.ErrUnknownRequest, "Bundle cannot be empty")
382
383
  }
383
384
  if len(msg.Bundle) != 0 && len(msg.CompressedBundle) != 0 {
384
- return sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, "Cannot submit both a compressed and an uncompressed bundle at the same time")
385
+ return sdkioerrors.Wrap(sdkerrors.ErrUnknownRequest, "Cannot submit both a compressed and an uncompressed bundle at the same time")
385
386
  }
386
387
  if len(msg.Bundle) > 0 && msg.UncompressedSize != 0 {
387
- return sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, "Uncompressed size cannot be set without a compressed bundle")
388
+ return sdkioerrors.Wrap(sdkerrors.ErrUnknownRequest, "Uncompressed size cannot be set without a compressed bundle")
388
389
  }
389
390
  if len(msg.CompressedBundle) > 0 && !(msg.UncompressedSize > 0) {
390
- return sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, "Uncompressed size must be positive")
391
+ return sdkioerrors.Wrap(sdkerrors.ErrUnknownRequest, "Uncompressed size must be positive")
391
392
  }
392
393
  if msg.UncompressedSize >= bundleUncompressedSizeLimit {
393
394
  // must enforce a limit to avoid overflow when computing its successor in Uncompress()
394
- return sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, "Uncompressed size out of range")
395
+ return sdkioerrors.Wrap(sdkerrors.ErrUnknownRequest, "Uncompressed size out of range")
395
396
  }
396
397
  // We don't check the accuracy of the uncompressed size here, since it could comsume significant CPU.
397
398
  return nil
@@ -454,7 +455,7 @@ func (msg *MsgInstallBundle) Uncompress() error {
454
455
  return err
455
456
  }
456
457
  if n != msg.UncompressedSize {
457
- return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Uncompressed size does not match expected value")
458
+ return sdkioerrors.Wrap(sdkerrors.ErrInvalidRequest, "Uncompressed size does not match expected value")
458
459
  }
459
460
  msg.Bundle = buf.String()
460
461
  msg.CompressedBundle = []byte{}
@@ -5,6 +5,7 @@ import (
5
5
 
6
6
  yaml "gopkg.in/yaml.v2"
7
7
 
8
+ sdkmath "cosmossdk.io/math"
8
9
  sdk "github.com/cosmos/cosmos-sdk/types"
9
10
  paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
10
11
  )
@@ -18,7 +19,7 @@ var (
18
19
  ParamStoreKeyQueueMax = []byte("queue_max")
19
20
  )
20
21
 
21
- func NewStringBeans(key string, beans sdk.Uint) StringBeans {
22
+ func NewStringBeans(key string, beans sdkmath.Uint) StringBeans {
22
23
  return StringBeans{
23
24
  Key: key,
24
25
  Beans: beans,