@agoric/cosmos 0.35.0-u20.0 → 0.35.0-u21.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 (113) hide show
  1. package/.clang-format +116 -0
  2. package/CHANGELOG.md +14 -2
  3. package/Makefile +38 -67
  4. package/ante/ante.go +2 -2
  5. package/ante/inbound_test.go +1 -1
  6. package/app/app.go +173 -142
  7. package/app/export.go +6 -6
  8. package/app/genesis.go +4 -0
  9. package/app/sim_test.go +299 -50
  10. package/app/upgrade.go +125 -24
  11. package/app/upgrade_test.go +1 -1
  12. package/cmd/agd/agvm.go +1 -1
  13. package/cmd/agd/main.go +1 -1
  14. package/cmd/libdaemon/main.go +34 -1
  15. package/daemon/cmd/root.go +26 -35
  16. package/daemon/cmd/root_test.go +5 -4
  17. package/daemon/cmd/testnet.go +221 -95
  18. package/daemon/main.go +1 -0
  19. package/git-revision.txt +1 -1
  20. package/go.mod +93 -58
  21. package/go.sum +148 -95
  22. package/package.json +6 -3
  23. package/proto/agoric/swingset/genesis.proto +7 -11
  24. package/proto/agoric/swingset/msgs.proto +56 -75
  25. package/proto/agoric/swingset/query.proto +7 -10
  26. package/proto/agoric/swingset/swingset.proto +79 -108
  27. package/proto/agoric/vbank/genesis.proto +5 -5
  28. package/proto/agoric/vbank/msgs.proto +1 -2
  29. package/proto/agoric/vbank/vbank.proto +42 -52
  30. package/proto/agoric/vibc/msgs.proto +8 -11
  31. package/proto/agoric/vstorage/genesis.proto +6 -9
  32. package/proto/agoric/vstorage/query.proto +19 -48
  33. package/proto/agoric/vstorage/vstorage.proto +4 -10
  34. package/proto/agoric/vtransfer/genesis.proto +7 -7
  35. package/proto/buf.gen.gogo.yaml +8 -0
  36. package/proto/buf.gen.pulsar.yaml +17 -0
  37. package/proto/buf.gen.swagger.yaml +5 -0
  38. package/proto/buf.yaml +10 -0
  39. package/scripts/protocgen.sh +14 -21
  40. package/third_party/proto/amino/amino.proto +79 -0
  41. package/third_party/proto/cosmos/base/v1beta1/coin.proto +7 -2
  42. package/third_party/proto/cosmos/ics23/v1/proofs.proto +243 -0
  43. package/third_party/proto/cosmos/msg/v1/msg.proto +30 -0
  44. package/third_party/proto/cosmos/upgrade/v1beta1/upgrade.proto +17 -5
  45. package/third_party/proto/cosmos_proto/cosmos.proto +16 -1
  46. package/third_party/proto/gogoproto/gogo.proto +2 -2
  47. package/third_party/proto/google/protobuf/any.proto +6 -3
  48. package/third_party/proto/ibc/core/channel/v1/channel.proto +1 -1
  49. package/third_party/proto/ibc/core/client/v1/client.proto +4 -2
  50. package/types/address_hooks.go +2 -2
  51. package/types/address_hooks_test.go +3 -3
  52. package/types/ibc_packet.go +3 -3
  53. package/types/ibc_packet_test.go +3 -3
  54. package/vm/client.go +32 -7
  55. package/vm/proto_json.go +2 -2
  56. package/x/swingset/abci.go +1 -1
  57. package/x/swingset/alias.go +0 -1
  58. package/x/swingset/config.go +1 -1
  59. package/x/swingset/keeper/extension_snapshotter.go +1 -1
  60. package/x/swingset/keeper/extension_snapshotter_test.go +1 -1
  61. package/x/swingset/keeper/keeper.go +1 -1
  62. package/x/swingset/keeper/keeper_test.go +1 -1
  63. package/x/swingset/keeper/querier.go +1 -30
  64. package/x/swingset/keeper/swing_store_exports_handler.go +1 -1
  65. package/x/swingset/keeper/swing_store_exports_handler_test.go +1 -1
  66. package/x/swingset/module.go +1 -14
  67. package/x/swingset/types/default-params.go +24 -16
  68. package/x/swingset/types/genesis.pb.go +2 -2
  69. package/x/swingset/types/msgs.pb.go +4 -3
  70. package/x/swingset/types/msgs_test.go +1 -1
  71. package/x/swingset/types/query.pb.go +4 -3
  72. package/x/swingset/types/swingset.pb.go +2 -2
  73. package/x/vbank/genesis.go +1 -1
  74. package/x/vbank/keeper/querier.go +1 -21
  75. package/x/vbank/module.go +1 -16
  76. package/x/vbank/types/genesis.pb.go +2 -2
  77. package/x/vbank/types/msgs.pb.go +3 -2
  78. package/x/vbank/types/query.pb.go +4 -3
  79. package/x/vbank/types/vbank.pb.go +2 -2
  80. package/x/vbank/vbank_test.go +95 -16
  81. package/x/vibc/keeper/keeper.go +8 -5
  82. package/x/vibc/keeper/migrations.go +36 -0
  83. package/x/vibc/keeper/triggers.go +1 -1
  84. package/x/vibc/module.go +9 -17
  85. package/x/vibc/types/expected_keepers.go +5 -10
  86. package/x/vibc/types/ibc_module.go +4 -4
  87. package/x/vibc/types/msgs.go +1 -1
  88. package/x/vibc/types/msgs.pb.go +5 -4
  89. package/x/vibc/types/receiver.go +2 -2
  90. package/x/vlocalchain/keeper/keeper.go +3 -3
  91. package/x/vlocalchain/types/vlocalchain.pb.go +1 -1
  92. package/x/vlocalchain/vlocalchain_test.go +6 -6
  93. package/x/vstorage/alias.go +0 -1
  94. package/x/vstorage/client/cli/query.go +1 -1
  95. package/x/vstorage/genesis.go +1 -1
  96. package/x/vstorage/keeper/keeper.go +6 -5
  97. package/x/vstorage/keeper/keeper_test.go +24 -24
  98. package/x/vstorage/keeper/querier.go +1 -32
  99. package/x/vstorage/keeper/querier_test.go +41 -6
  100. package/x/vstorage/module.go +1 -14
  101. package/x/vstorage/types/genesis.pb.go +2 -2
  102. package/x/vstorage/types/query.pb.go +8 -5
  103. package/x/vstorage/types/vstorage.pb.go +2 -2
  104. package/x/vstorage/vstorage_test.go +3 -3
  105. package/x/vtransfer/genesis.go +1 -1
  106. package/x/vtransfer/ibc_middleware.go +4 -4
  107. package/x/vtransfer/ibc_middleware_test.go +10 -11
  108. package/x/vtransfer/keeper/keeper.go +5 -5
  109. package/x/vtransfer/module.go +1 -14
  110. package/x/vtransfer/types/expected_keepers.go +2 -18
  111. package/x/vtransfer/types/genesis.pb.go +2 -2
  112. package/x/vtransfer/utils_test.go +15 -15
  113. package/daemon/cmd/genaccounts.go +0 -195
@@ -9,7 +9,7 @@ import (
9
9
 
10
10
  sdkmath "cosmossdk.io/math"
11
11
 
12
- "github.com/tendermint/tendermint/libs/log"
12
+ "github.com/cometbft/cometbft/libs/log"
13
13
 
14
14
  "github.com/cosmos/cosmos-sdk/baseapp"
15
15
  "github.com/cosmos/cosmos-sdk/codec"
@@ -11,7 +11,7 @@ import (
11
11
  storetypes "github.com/cosmos/cosmos-sdk/store/types"
12
12
  sdk "github.com/cosmos/cosmos-sdk/types"
13
13
 
14
- dbm "github.com/tendermint/tm-db"
14
+ dbm "github.com/cometbft/cometbft-db"
15
15
  )
16
16
 
17
17
  func mkcoin(denom string) func(amt int64) sdk.Coin {
@@ -2,9 +2,8 @@ package keeper
2
2
 
3
3
  import (
4
4
  "fmt"
5
- "strings"
6
5
 
7
- abci "github.com/tendermint/tendermint/abci/types"
6
+ abci "github.com/cometbft/cometbft/abci/types"
8
7
 
9
8
  sdkioerrors "cosmossdk.io/errors"
10
9
  "github.com/cosmos/cosmos-sdk/codec"
@@ -22,34 +21,6 @@ const (
22
21
  LegacyQueryKeys = "keys"
23
22
  )
24
23
 
25
- // NewQuerier is the module level router for state queries
26
- func NewQuerier(keeper Keeper, legacyQuerierCdc *codec.LegacyAmino) sdk.Querier {
27
- return func(ctx sdk.Context, path []string, req abci.RequestQuery) (res []byte, err error) {
28
- var queryType string
29
- if len(path) > 0 {
30
- queryType = path[0]
31
- }
32
- switch queryType {
33
- case QueryEgress:
34
- if len(path) < 2 || path[1] == "" {
35
- return nil, sdkioerrors.Wrap(sdkerrors.ErrInvalidRequest, "missing egress address")
36
- }
37
- return queryEgress(ctx, path[1], req, keeper, legacyQuerierCdc)
38
- case QueryMailbox:
39
- if len(path) < 2 || path[1] == "" {
40
- return nil, sdkioerrors.Wrap(sdkerrors.ErrInvalidRequest, "missing mailbox peer")
41
- }
42
- return queryMailbox(ctx, path[1], req, keeper, legacyQuerierCdc)
43
- case LegacyQueryStorage:
44
- return legacyQueryStorage(ctx, strings.Join(path[1:], "/"), req, keeper, legacyQuerierCdc)
45
- case LegacyQueryKeys:
46
- return legacyQueryKeys(ctx, strings.Join(path[1:], "/"), req, keeper, legacyQuerierCdc)
47
- default:
48
- return nil, sdkioerrors.Wrap(sdkerrors.ErrUnknownRequest, "unknown swingset query path")
49
- }
50
- }
51
- }
52
-
53
24
  // nolint: unparam
54
25
  func queryEgress(ctx sdk.Context, bech32 string, req abci.RequestQuery, keeper Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) {
55
26
  acc, err := sdk.AccAddressFromBech32(bech32)
@@ -13,7 +13,7 @@ import (
13
13
  agoric "github.com/Agoric/agoric-sdk/golang/cosmos/types"
14
14
  "github.com/Agoric/agoric-sdk/golang/cosmos/vm"
15
15
  "github.com/Agoric/agoric-sdk/golang/cosmos/x/swingset/types"
16
- "github.com/tendermint/tendermint/libs/log"
16
+ "github.com/cometbft/cometbft/libs/log"
17
17
  )
18
18
 
19
19
  // This module abstracts the generation and handling of swing-store exports,
@@ -6,7 +6,7 @@ import (
6
6
  "testing"
7
7
 
8
8
  "github.com/Agoric/agoric-sdk/golang/cosmos/vm"
9
- "github.com/tendermint/tendermint/libs/log"
9
+ "github.com/cometbft/cometbft/libs/log"
10
10
  )
11
11
 
12
12
  func newTestSwingStoreExportsHandler() *SwingStoreExportsHandler {
@@ -16,8 +16,8 @@ import (
16
16
  cdctypes "github.com/cosmos/cosmos-sdk/codec/types"
17
17
  "github.com/cosmos/cosmos-sdk/types/module"
18
18
 
19
+ abci "github.com/cometbft/cometbft/abci/types"
19
20
  sdk "github.com/cosmos/cosmos-sdk/types"
20
- abci "github.com/tendermint/tendermint/abci/types"
21
21
  )
22
22
 
23
23
  // type check to ensure the interface is properly implemented
@@ -115,19 +115,6 @@ func (am *AppModule) SetSwingStoreExportDir(dir string) {
115
115
 
116
116
  func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) {}
117
117
 
118
- func (am AppModule) Route() sdk.Route {
119
- return sdk.NewRoute(types.RouterKey, NewHandler(am.keeper))
120
- }
121
-
122
- func (am AppModule) QuerierRoute() string {
123
- return ModuleName
124
- }
125
-
126
- // LegacyQuerierHandler returns the sdk.Querier for deployment module
127
- func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sdk.Querier {
128
- return keeper.NewQuerier(am.keeper, legacyQuerierCdc)
129
- }
130
-
131
118
  func (am AppModule) RegisterServices(cfg module.Configurator) {
132
119
  types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper))
133
120
  querier := keeper.Querier{Keeper: am.keeper}
@@ -11,15 +11,16 @@ import (
11
11
  // experience if they don't.
12
12
 
13
13
  const (
14
+ BeansPerBlockComputeLimit = "blockComputeLimit"
15
+ BeansPerVatCreation = "vatCreation"
16
+ BeansPerXsnapComputron = "xsnapComputron"
17
+
14
18
  BeansPerFeeUnit = "feeUnit"
15
19
  BeansPerInboundTx = "inboundTx"
16
- BeansPerBlockComputeLimit = "blockComputeLimit"
17
20
  BeansPerMessage = "message"
18
21
  BeansPerMessageByte = "messageByte"
19
22
  BeansPerMinFeeDebit = "minFeeDebit"
20
23
  BeansPerStorageByte = "storageByte"
21
- BeansPerVatCreation = "vatCreation"
22
- BeansPerXsnapComputron = "xsnapComputron"
23
24
  BeansPerSmartWalletProvision = "smartWalletProvision"
24
25
 
25
26
  // PowerFlags.
@@ -52,18 +53,24 @@ var (
52
53
  // observed: 0.385 sec
53
54
  DefaultBeansPerVatCreation = sdk.NewUint(300000).Mul(DefaultBeansPerXsnapComputron)
54
55
 
55
- // Fees are denominated in this unit.
56
- DefaultFeeUnitPrice = sdk.NewCoins(sdk.NewInt64Coin("uist", 1_000_000)) // $1
57
-
56
+ // Fees are represented as integer "beans", where each bean is a uniform
57
+ // fraction of this `fee_unit_price` as controlled by the below
58
+ // `beans_per_unit` "feeUnit".
58
59
  // TODO: create the cost model we want, and update these to be more principled.
59
- // These defaults currently make deploying an ag-solo cost less than $1.00.
60
- DefaultBeansPerFeeUnit = sdk.NewUint(1_000_000_000_000) // $1
61
- DefaultBeansPerInboundTx = DefaultBeansPerFeeUnit.Quo(sdk.NewUint(100)) // $0.01
62
- DefaultBeansPerMessage = DefaultBeansPerFeeUnit.Quo(sdk.NewUint(1_000)) // $0.001
63
- DefaultBeansPerMessageByte = DefaultBeansPerFeeUnit.Quo(sdk.NewUint(50_000)) // $0.00002
64
- DefaultBeansPerMinFeeDebit = DefaultBeansPerFeeUnit.Quo(sdk.NewUint(5)) // $0.2
65
- DefaultBeansPerStorageByte = DefaultBeansPerFeeUnit.Quo(sdk.NewUint(500)) // $0.002
66
- DefaultBeansPerSmartWalletProvision = DefaultBeansPerFeeUnit // $1
60
+ DefaultFeeUnitPrice = sdk.NewCoins(sdk.NewInt64Coin("ubld", 1_000_000)) // 1 BLD
61
+
62
+ // The count of "beans" into which `fee_unit_price` is divided.
63
+ // Larger numbers make for smaller beans, and we expect values to be rather
64
+ // large for representing fees precisely in beans that each approximate
65
+ // a "picoUSD"--one trillionth of a USD.
66
+ DefaultBeansPerFeeUnit = sdk.NewUint(1_000_000_000_000) // 1e12 (assumes $1 per BLD)
67
+
68
+ DefaultBeansPerInboundTx = DefaultBeansPerFeeUnit.Quo(sdk.NewUint(100)) // 10e09, ~$0.01
69
+ DefaultBeansPerMessage = DefaultBeansPerFeeUnit.Quo(sdk.NewUint(1_000)) // 1e09, ~$0.001
70
+ DefaultBeansPerMessageByte = DefaultBeansPerFeeUnit.Quo(sdk.NewUint(50_000)) // 20e06, ~$0.00002
71
+ DefaultBeansPerMinFeeDebit = DefaultBeansPerFeeUnit.Quo(sdk.NewUint(5)) // 200e09, ~$0.2
72
+ DefaultBeansPerStorageByte = DefaultBeansPerFeeUnit.Quo(sdk.NewUint(500)) // 2e09, ~$0.002
73
+ DefaultBeansPerSmartWalletProvision = DefaultBeansPerFeeUnit // 1e12, ~$1
67
74
 
68
75
  DefaultBootstrapVatConfig = "@agoric/vm-config/decentral-core-config.json"
69
76
 
@@ -97,15 +104,16 @@ var (
97
104
  // move DefaultBeansPerUnit to a function to allow for boot overriding of the Default params
98
105
  func DefaultBeansPerUnit() []StringBeans {
99
106
  return []StringBeans{
107
+ NewStringBeans(BeansPerXsnapComputron, DefaultBeansPerXsnapComputron),
100
108
  NewStringBeans(BeansPerBlockComputeLimit, DefaultBeansPerBlockComputeLimit),
109
+ NewStringBeans(BeansPerVatCreation, DefaultBeansPerVatCreation),
110
+
101
111
  NewStringBeans(BeansPerFeeUnit, DefaultBeansPerFeeUnit),
102
112
  NewStringBeans(BeansPerInboundTx, DefaultBeansPerInboundTx),
103
113
  NewStringBeans(BeansPerMessage, DefaultBeansPerMessage),
104
114
  NewStringBeans(BeansPerMessageByte, DefaultBeansPerMessageByte),
105
115
  NewStringBeans(BeansPerMinFeeDebit, DefaultBeansPerMinFeeDebit),
106
116
  NewStringBeans(BeansPerStorageByte, DefaultBeansPerStorageByte),
107
- NewStringBeans(BeansPerVatCreation, DefaultBeansPerVatCreation),
108
- NewStringBeans(BeansPerXsnapComputron, DefaultBeansPerXsnapComputron),
109
117
  NewStringBeans(BeansPerSmartWalletProvision, DefaultBeansPerSmartWalletProvision),
110
118
  }
111
119
  }
@@ -5,8 +5,8 @@ package types
5
5
 
6
6
  import (
7
7
  fmt "fmt"
8
- _ "github.com/gogo/protobuf/gogoproto"
9
- proto "github.com/gogo/protobuf/proto"
8
+ _ "github.com/cosmos/gogoproto/gogoproto"
9
+ proto "github.com/cosmos/gogoproto/proto"
10
10
  io "io"
11
11
  math "math"
12
12
  math_bits "math/bits"
@@ -7,9 +7,9 @@ import (
7
7
  context "context"
8
8
  fmt "fmt"
9
9
  github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types"
10
- _ "github.com/gogo/protobuf/gogoproto"
11
- grpc1 "github.com/gogo/protobuf/grpc"
12
- proto "github.com/gogo/protobuf/proto"
10
+ _ "github.com/cosmos/gogoproto/gogoproto"
11
+ grpc1 "github.com/cosmos/gogoproto/grpc"
12
+ proto "github.com/cosmos/gogoproto/proto"
13
13
  grpc "google.golang.org/grpc"
14
14
  codes "google.golang.org/grpc/codes"
15
15
  status "google.golang.org/grpc/status"
@@ -811,6 +811,7 @@ func _Msg_Provision_Handler(srv interface{}, ctx context.Context, dec func(inter
811
811
  return interceptor(ctx, in, info, handler)
812
812
  }
813
813
 
814
+ var Msg_serviceDesc = _Msg_serviceDesc
814
815
  var _Msg_serviceDesc = grpc.ServiceDesc{
815
816
  ServiceName: "agoric.swingset.Msg",
816
817
  HandlerType: (*MsgServer)(nil),
@@ -7,7 +7,7 @@ import (
7
7
 
8
8
  "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
9
9
  sdk "github.com/cosmos/cosmos-sdk/types"
10
- "github.com/gogo/protobuf/proto"
10
+ "github.com/cosmos/gogoproto/proto"
11
11
  )
12
12
 
13
13
  var (
@@ -7,9 +7,9 @@ import (
7
7
  context "context"
8
8
  fmt "fmt"
9
9
  github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types"
10
- _ "github.com/gogo/protobuf/gogoproto"
11
- grpc1 "github.com/gogo/protobuf/grpc"
12
- proto "github.com/gogo/protobuf/proto"
10
+ _ "github.com/cosmos/gogoproto/gogoproto"
11
+ grpc1 "github.com/cosmos/gogoproto/grpc"
12
+ proto "github.com/cosmos/gogoproto/proto"
13
13
  _ "google.golang.org/genproto/googleapis/api/annotations"
14
14
  grpc "google.golang.org/grpc"
15
15
  codes "google.golang.org/grpc/codes"
@@ -476,6 +476,7 @@ func _Query_Mailbox_Handler(srv interface{}, ctx context.Context, dec func(inter
476
476
  return interceptor(ctx, in, info, handler)
477
477
  }
478
478
 
479
+ var Query_serviceDesc = _Query_serviceDesc
479
480
  var _Query_serviceDesc = grpc.ServiceDesc{
480
481
  ServiceName: "agoric.swingset.Query",
481
482
  HandlerType: (*QueryServer)(nil),
@@ -7,8 +7,8 @@ import (
7
7
  fmt "fmt"
8
8
  github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types"
9
9
  types "github.com/cosmos/cosmos-sdk/types"
10
- _ "github.com/gogo/protobuf/gogoproto"
11
- proto "github.com/gogo/protobuf/proto"
10
+ _ "github.com/cosmos/gogoproto/gogoproto"
11
+ proto "github.com/cosmos/gogoproto/proto"
12
12
  io "io"
13
13
  math "math"
14
14
  math_bits "math/bits"
@@ -4,8 +4,8 @@ import (
4
4
  "fmt"
5
5
 
6
6
  "github.com/Agoric/agoric-sdk/golang/cosmos/x/vbank/types"
7
+ abci "github.com/cometbft/cometbft/abci/types"
7
8
  sdk "github.com/cosmos/cosmos-sdk/types"
8
- abci "github.com/tendermint/tendermint/abci/types"
9
9
  )
10
10
 
11
11
  func NewGenesisState() *types.GenesisState {
@@ -1,34 +1,14 @@
1
1
  package keeper
2
2
 
3
3
  import (
4
- abci "github.com/tendermint/tendermint/abci/types"
4
+ abci "github.com/cometbft/cometbft/abci/types"
5
5
 
6
6
  sdkioerrors "cosmossdk.io/errors"
7
- "github.com/Agoric/agoric-sdk/golang/cosmos/x/vbank/types"
8
7
  "github.com/cosmos/cosmos-sdk/codec"
9
8
  sdk "github.com/cosmos/cosmos-sdk/types"
10
9
  sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
11
10
  )
12
11
 
13
- func NewQuerier(k Keeper, legacyQuerierCdc *codec.LegacyAmino) sdk.Querier {
14
- return func(ctx sdk.Context, path []string, req abci.RequestQuery) ([]byte, error) {
15
- var queryType string
16
- if len(path) > 0 {
17
- queryType = path[0]
18
- }
19
- switch queryType {
20
- case types.QueryParams:
21
- return queryParams(ctx, path[1:], req, k, legacyQuerierCdc)
22
-
23
- case types.QueryState:
24
- return queryState(ctx, path[1:], req, k, legacyQuerierCdc)
25
-
26
- default:
27
- return nil, sdkioerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unknown vbank query path")
28
- }
29
- }
30
- }
31
-
32
12
  func queryParams(ctx sdk.Context, _ []string, _ abci.RequestQuery, k Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) {
33
13
  params := k.GetParams(ctx)
34
14
 
package/x/vbank/module.go CHANGED
@@ -17,9 +17,9 @@ import (
17
17
  cdctypes "github.com/cosmos/cosmos-sdk/codec/types"
18
18
  "github.com/cosmos/cosmos-sdk/types/module"
19
19
 
20
+ abci "github.com/cometbft/cometbft/abci/types"
20
21
  sdk "github.com/cosmos/cosmos-sdk/types"
21
22
  banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
22
- abci "github.com/tendermint/tendermint/abci/types"
23
23
  )
24
24
 
25
25
  // type check to ensure the interface is properly implemented
@@ -184,21 +184,6 @@ func (AppModule) RegisterInvariants(ir sdk.InvariantRegistry) {
184
184
  // TODO
185
185
  }
186
186
 
187
- // Route implements the AppModule interface
188
- func (am AppModule) Route() sdk.Route {
189
- return sdk.NewRoute(RouterKey, NewHandler(am.keeper))
190
- }
191
-
192
- // QuerierRoute implements the AppModule interface
193
- func (AppModule) QuerierRoute() string {
194
- return ModuleName
195
- }
196
-
197
- // LegacyQuerierHandler implements the AppModule interface
198
- func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sdk.Querier {
199
- return keeper.NewQuerier(am.keeper, legacyQuerierCdc)
200
- }
201
-
202
187
  // RegisterServices registers module services.
203
188
  func (am AppModule) RegisterServices(cfg module.Configurator) {
204
189
  tx := &types.UnimplementedMsgServer{}
@@ -5,8 +5,8 @@ package types
5
5
 
6
6
  import (
7
7
  fmt "fmt"
8
- _ "github.com/gogo/protobuf/gogoproto"
9
- proto "github.com/gogo/protobuf/proto"
8
+ _ "github.com/cosmos/gogoproto/gogoproto"
9
+ proto "github.com/cosmos/gogoproto/proto"
10
10
  io "io"
11
11
  math "math"
12
12
  math_bits "math/bits"
@@ -6,8 +6,8 @@ package types
6
6
  import (
7
7
  context "context"
8
8
  fmt "fmt"
9
- grpc1 "github.com/gogo/protobuf/grpc"
10
- proto "github.com/gogo/protobuf/proto"
9
+ grpc1 "github.com/cosmos/gogoproto/grpc"
10
+ proto "github.com/cosmos/gogoproto/proto"
11
11
  grpc "google.golang.org/grpc"
12
12
  math "math"
13
13
  )
@@ -72,6 +72,7 @@ func RegisterMsgServer(s grpc1.Server, srv MsgServer) {
72
72
  s.RegisterService(&_Msg_serviceDesc, srv)
73
73
  }
74
74
 
75
+ var Msg_serviceDesc = _Msg_serviceDesc
75
76
  var _Msg_serviceDesc = grpc.ServiceDesc{
76
77
  ServiceName: "agoric.vbank.Msg",
77
78
  HandlerType: (*MsgServer)(nil),
@@ -6,9 +6,9 @@ package types
6
6
  import (
7
7
  context "context"
8
8
  fmt "fmt"
9
- _ "github.com/gogo/protobuf/gogoproto"
10
- grpc1 "github.com/gogo/protobuf/grpc"
11
- proto "github.com/gogo/protobuf/proto"
9
+ _ "github.com/cosmos/gogoproto/gogoproto"
10
+ grpc1 "github.com/cosmos/gogoproto/grpc"
11
+ proto "github.com/cosmos/gogoproto/proto"
12
12
  _ "google.golang.org/genproto/googleapis/api/annotations"
13
13
  grpc "google.golang.org/grpc"
14
14
  codes "google.golang.org/grpc/codes"
@@ -333,6 +333,7 @@ func _Query_State_Handler(srv interface{}, ctx context.Context, dec func(interfa
333
333
  return interceptor(ctx, in, info, handler)
334
334
  }
335
335
 
336
+ var Query_serviceDesc = _Query_serviceDesc
336
337
  var _Query_serviceDesc = grpc.ServiceDesc{
337
338
  ServiceName: "agoric.vbank.Query",
338
339
  HandlerType: (*QueryServer)(nil),
@@ -7,8 +7,8 @@ import (
7
7
  fmt "fmt"
8
8
  github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types"
9
9
  types "github.com/cosmos/cosmos-sdk/types"
10
- _ "github.com/gogo/protobuf/gogoproto"
11
- proto "github.com/gogo/protobuf/proto"
10
+ _ "github.com/cosmos/gogoproto/gogoproto"
11
+ proto "github.com/cosmos/gogoproto/proto"
12
12
  io "io"
13
13
  math "math"
14
14
  math_bits "math/bits"
@@ -10,17 +10,18 @@ import (
10
10
  "github.com/Agoric/agoric-sdk/golang/cosmos/app/params"
11
11
  "github.com/Agoric/agoric-sdk/golang/cosmos/vm"
12
12
  "github.com/Agoric/agoric-sdk/golang/cosmos/x/vbank/types"
13
+ dbm "github.com/cometbft/cometbft-db"
14
+ abci "github.com/cometbft/cometbft/abci/types"
15
+ "github.com/cometbft/cometbft/crypto/secp256k1"
16
+ "github.com/cometbft/cometbft/libs/log"
17
+ tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
13
18
  "github.com/cosmos/cosmos-sdk/store"
14
19
  storetypes "github.com/cosmos/cosmos-sdk/store/types"
15
20
  sdk "github.com/cosmos/cosmos-sdk/types"
21
+ sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
16
22
  authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
17
23
  paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper"
18
24
  paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
19
- abci "github.com/tendermint/tendermint/abci/types"
20
- "github.com/tendermint/tendermint/crypto/secp256k1"
21
- "github.com/tendermint/tendermint/libs/log"
22
- tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
23
- dbm "github.com/tendermint/tm-db"
24
25
  )
25
26
 
26
27
  var (
@@ -233,6 +234,24 @@ func (b *mockBank) MintCoins(ctx sdk.Context, moduleName string, amt sdk.Coins)
233
234
 
234
235
  func (b *mockBank) SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error {
235
236
  b.record(fmt.Sprintf("SendCoinsFromAccountToModule %s %s %s", senderAddr, recipientModule, amt))
237
+
238
+ // for each coin in the request, check spendable vs. requested
239
+ for _, coin := range amt {
240
+ // mimic GetBalance logic
241
+ have := b.balances[senderAddr.String()].AmountOf(coin.Denom)
242
+ spendable := sdk.NewCoin(coin.Denom, have)
243
+
244
+ if spendable.IsLT(coin) {
245
+ // wrap exactly like the real x/bank keeper
246
+ // https://github.com/agoric-labs/cosmos-sdk/blob/8b2b975304291c51991278734daa2ff5e57fcb83/x/bank/keeper/send.go#L252-L256
247
+ return sdkerrors.Wrapf(
248
+ sdkerrors.ErrInsufficientFunds,
249
+ "spendable balance %s is smaller than %s",
250
+ spendable, coin,
251
+ )
252
+ }
253
+ }
254
+
236
255
  return nil
237
256
  }
238
257
 
@@ -541,32 +560,32 @@ func Test_EndBlock_Events(t *testing.T) {
541
560
  {
542
561
  Type: "coin_received",
543
562
  Attributes: []abci.EventAttribute{
544
- {Key: []byte("receiver"), Value: []byte(addr1)},
545
- {Key: []byte("amount"), Value: []byte("500ubld,600urun,700ushmoo")},
563
+ {Key: "receiver", Value: addr1},
564
+ {Key: "amount", Value: "500ubld,600urun,700ushmoo"},
546
565
  },
547
566
  },
548
567
  {
549
568
  Type: "coin_spent",
550
569
  Attributes: []abci.EventAttribute{
551
- {Key: []byte("spender"), Value: []byte(addr2)},
552
- {Key: []byte("amount"), Value: []byte("500ubld,600urun,700ushmoo")},
553
- {Key: []byte("other"), Value: []byte(addr3)},
570
+ {Key: "spender", Value: addr2},
571
+ {Key: "amount", Value: "500ubld,600urun,700ushmoo"},
572
+ {Key: "other", Value: addr3},
554
573
  },
555
574
  },
556
575
  {
557
576
  Type: "something_else",
558
577
  Attributes: []abci.EventAttribute{
559
- {Key: []byte("receiver"), Value: []byte(addr4)},
560
- {Key: []byte("spender"), Value: []byte(addr4)},
561
- {Key: []byte("amount"), Value: []byte("500ubld,600urun,700ushmoo")},
578
+ {Key: "receiver", Value: addr4},
579
+ {Key: "spender", Value: addr4},
580
+ {Key: "amount", Value: "500ubld,600urun,700ushmoo"},
562
581
  },
563
582
  },
564
583
  {
565
584
  Type: "non_modaccount",
566
585
  Attributes: []abci.EventAttribute{
567
- {Key: []byte("receiver"), Value: []byte(addr3)},
568
- {Key: []byte("spender"), Value: []byte(addr4)},
569
- {Key: []byte("amount"), Value: []byte("100ubld")},
586
+ {Key: "receiver", Value: addr3},
587
+ {Key: "spender", Value: addr4},
588
+ {Key: "amount", Value: "100ubld"},
570
589
  },
571
590
  },
572
591
  }
@@ -821,3 +840,63 @@ func Test_Module_Account(t *testing.T) {
821
840
  t.Errorf("got IsAllowedMonitoringAccount missingAddr = false, want true")
822
841
  }
823
842
  }
843
+
844
+
845
+
846
+ func Test_Receive_Grab_InsufficientFunds(t *testing.T) {
847
+ tests := []struct {
848
+ name string
849
+ initialBalance sdk.Coin
850
+ }{
851
+ {
852
+ name: "only 100 available",
853
+ initialBalance: sdk.NewInt64Coin("ufoo", 100),
854
+ },
855
+ {
856
+ name: "zero available",
857
+ initialBalance: sdk.NewInt64Coin("ufoo", 0),
858
+ },
859
+ }
860
+
861
+ for _, tc := range tests {
862
+ t.Run(tc.name, func(t *testing.T) {
863
+ // set up mockBank with the desired starting balance
864
+ bank := &mockBank{balances: map[string]sdk.Coins{
865
+ addr1: sdk.NewCoins(tc.initialBalance),
866
+ }}
867
+
868
+ // wire into keeper
869
+ keeper, ctx := makeTestKit(nil, bank)
870
+ handler := NewPortHandler(AppModule{}, keeper)
871
+ ctl := sdk.WrapSDKContext(ctx)
872
+
873
+ // attempt to grab 500ufoo
874
+ grabAmt := sdk.NewCoins(sdk.NewInt64Coin("ufoo", 500))
875
+ _, err := handler.Receive(ctl, fmt.Sprintf(`{
876
+ "type":"VBANK_GRAB",
877
+ "sender":"%s",
878
+ "amount":"500",
879
+ "denom":"ufoo"
880
+ }`, addr1))
881
+ if err == nil {
882
+ t.Fatal("expected insufficient-funds error, got nil")
883
+ }
884
+
885
+ expected := fmt.Sprintf(
886
+ "cannot grab %s coins: spendable balance %s is smaller than %s: %s",
887
+ grabAmt.Sort().String(),
888
+ tc.initialBalance.String(),
889
+ grabAmt.Sort().String(),
890
+ sdkerrors.ErrInsufficientFunds.Error(),
891
+ )
892
+
893
+ t.Logf("actual error: %q", err.Error())
894
+
895
+ got := err.Error()
896
+ if got != expected {
897
+ t.Errorf("wrong error message:\n expected: %q\n got: %q",
898
+ expected, got)
899
+ }
900
+ })
901
+ }
902
+ }
@@ -9,11 +9,11 @@ import (
9
9
 
10
10
  sdkioerrors "cosmossdk.io/errors"
11
11
  capability "github.com/cosmos/cosmos-sdk/x/capability/types"
12
- clienttypes "github.com/cosmos/ibc-go/v6/modules/core/02-client/types"
13
- channeltypes "github.com/cosmos/ibc-go/v6/modules/core/04-channel/types"
14
- porttypes "github.com/cosmos/ibc-go/v6/modules/core/05-port/types"
15
- host "github.com/cosmos/ibc-go/v6/modules/core/24-host"
16
- ibcexported "github.com/cosmos/ibc-go/v6/modules/core/exported"
12
+ clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types"
13
+ channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types"
14
+ porttypes "github.com/cosmos/ibc-go/v7/modules/core/05-port/types"
15
+ host "github.com/cosmos/ibc-go/v7/modules/core/24-host"
16
+ ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported"
17
17
 
18
18
  "github.com/Agoric/agoric-sdk/golang/cosmos/vm"
19
19
  "github.com/Agoric/agoric-sdk/golang/cosmos/x/vibc/types"
@@ -31,6 +31,7 @@ type Keeper struct {
31
31
 
32
32
  channelKeeper types.ChannelKeeper
33
33
  portKeeper types.PortKeeper
34
+ clientKeeper types.ClientKeeper
34
35
 
35
36
  // Filled out by `WithScope`
36
37
  scopedKeeper types.ScopedKeeper
@@ -43,12 +44,14 @@ func NewKeeper(
43
44
  cdc codec.Codec,
44
45
  channelKeeper types.ChannelKeeper,
45
46
  portKeeper types.PortKeeper,
47
+ clientKeeper types.ClientKeeper,
46
48
  ) Keeper {
47
49
 
48
50
  return Keeper{
49
51
  cdc: cdc,
50
52
  channelKeeper: channelKeeper,
51
53
  portKeeper: portKeeper,
54
+ clientKeeper: clientKeeper,
52
55
  }
53
56
  }
54
57
 
@@ -0,0 +1,36 @@
1
+ package keeper
2
+
3
+ import (
4
+ sdk "github.com/cosmos/cosmos-sdk/types"
5
+
6
+ ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported"
7
+ )
8
+
9
+ // Migrator handles in-place store migrations.
10
+ type Migrator struct {
11
+ keeper Keeper
12
+ }
13
+
14
+ // NewMigrator returns a new migrator based on the keeper.
15
+ func NewMigrator(keeper Keeper) Migrator {
16
+ return Migrator{keeper: keeper}
17
+ }
18
+
19
+ // Migrate1to2 migrates from version 1 to 2.
20
+ func (m Migrator) Migrate1to2(ctx sdk.Context) error {
21
+ return m.AddLocalhostParams(ctx)
22
+ }
23
+
24
+ // explicitly update the IBC 02-client params, adding the localhost client type
25
+ func (m Migrator) AddLocalhostParams(ctx sdk.Context) error {
26
+ params := m.keeper.clientKeeper.GetParams(ctx)
27
+ for _, client := range params.AllowedClients {
28
+ if client == ibcexported.Localhost {
29
+ // Already added, return.
30
+ return nil
31
+ }
32
+ }
33
+ params.AllowedClients = append(params.AllowedClients, ibcexported.Localhost)
34
+ m.keeper.clientKeeper.SetParams(ctx, params)
35
+ return nil
36
+ }