@agoric/cosmos 0.35.0-u21.0 → 0.35.0-u22.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/CHANGELOG.md +11 -187
  2. package/Makefile +2 -2
  3. package/ante/ante.go +2 -2
  4. package/ante/inbound.go +1 -2
  5. package/ante/inbound_test.go +3 -1
  6. package/ante/vm_admission.go +1 -2
  7. package/app/app.go +255 -174
  8. package/app/encoding.go +6 -3
  9. package/app/export.go +50 -21
  10. package/app/genesis.go +7 -5
  11. package/app/params/encoding.go +1 -1
  12. package/app/params/proto.go +6 -4
  13. package/app/sim_test.go +11 -13
  14. package/app/txconfig/tx_config.go +169 -0
  15. package/app/upgrade.go +52 -97
  16. package/app/upgrade_test.go +1 -1
  17. package/cmd/agd/agvm.go +1 -1
  18. package/cmd/agd/main.go +1 -1
  19. package/cmd/libdaemon/main.go +2 -2
  20. package/daemon/cmd/root.go +99 -30
  21. package/daemon/cmd/root_test.go +12 -27
  22. package/daemon/main.go +2 -9
  23. package/git-revision.txt +1 -1
  24. package/go.mod +129 -109
  25. package/go.sum +228 -469
  26. package/package.json +2 -2
  27. package/proto/agoric/swingset/msgs.proto +46 -9
  28. package/proto/agoric/swingset/swingset.proto +7 -2
  29. package/proto/agoric/vbank/vbank.proto +1 -1
  30. package/proto/agoric/vibc/msgs.proto +4 -0
  31. package/tests/e2e/vbank/vbank_test.go +172 -0
  32. package/tests/integrations/types/aminojson_test.go +214 -0
  33. package/tests/integrations/vbank/vbank_test.go +348 -0
  34. package/third_party/proto/amino/amino.proto +6 -1
  35. package/third_party/proto/cosmos/base/v1beta1/coin.proto +18 -5
  36. package/third_party/proto/cosmos/upgrade/v1beta1/upgrade.proto +4 -8
  37. package/third_party/proto/ibc/core/channel/v1/channel.proto +42 -17
  38. package/third_party/proto/ibc/core/client/v1/client.proto +48 -40
  39. package/types/address_hooks.go +2 -2
  40. package/types/address_hooks_test.go +3 -3
  41. package/types/ibc_packet.go +3 -3
  42. package/types/ibc_packet_test.go +3 -3
  43. package/types/kv_entry_helpers.go +3 -3
  44. package/types/kv_entry_helpers_test.go +2 -2
  45. package/types/legacy_address_encoder.go +58 -0
  46. package/vm/proto_json_test.go +1 -1
  47. package/vm/server.go +2 -1
  48. package/x/swingset/abci.go +2 -2
  49. package/x/swingset/client/cli/tx.go +16 -14
  50. package/x/swingset/config.go +1 -1
  51. package/x/swingset/genesis.go +2 -1
  52. package/x/swingset/handler.go +2 -1
  53. package/x/swingset/keeper/extension_snapshotter.go +14 -5
  54. package/x/swingset/keeper/extension_snapshotter_test.go +1 -1
  55. package/x/swingset/keeper/keeper.go +21 -17
  56. package/x/swingset/keeper/keeper_test.go +10 -7
  57. package/x/swingset/keeper/msg_server.go +26 -5
  58. package/x/swingset/keeper/swing_store_exports_handler.go +1 -1
  59. package/x/swingset/keeper/swing_store_exports_handler_test.go +1 -1
  60. package/x/swingset/module.go +20 -22
  61. package/x/swingset/types/codec.go +10 -5
  62. package/x/swingset/types/default-params.go +13 -12
  63. package/x/swingset/types/expected_keepers.go +5 -4
  64. package/x/swingset/types/msgs.go +50 -36
  65. package/x/swingset/types/msgs.pb.go +60 -51
  66. package/x/swingset/types/params_test.go +21 -20
  67. package/x/swingset/types/swingset.pb.go +67 -61
  68. package/x/vbank/genesis.go +12 -8
  69. package/x/vbank/handler.go +2 -1
  70. package/x/vbank/keeper/grpc_query.go +4 -1
  71. package/x/vbank/keeper/keeper.go +108 -23
  72. package/x/vbank/keeper/querier.go +4 -1
  73. package/x/vbank/keeper/rewards.go +6 -2
  74. package/x/vbank/module.go +47 -75
  75. package/x/vbank/types/expected_keepers.go +15 -10
  76. package/x/vbank/types/key.go +3 -0
  77. package/x/vbank/types/params.go +4 -3
  78. package/x/vbank/types/vbank.pb.go +41 -40
  79. package/x/vbank/vbank.go +25 -10
  80. package/x/vbank/vbank_test.go +213 -154
  81. package/x/vibc/handler.go +2 -1
  82. package/x/vibc/keeper/keeper.go +10 -10
  83. package/x/vibc/keeper/migrations.go +1 -1
  84. package/x/vibc/keeper/triggers.go +1 -1
  85. package/x/vibc/module.go +5 -22
  86. package/x/vibc/types/codec.go +2 -1
  87. package/x/vibc/types/expected_keepers.go +7 -5
  88. package/x/vibc/types/ibc_module.go +5 -5
  89. package/x/vibc/types/msgs.go +30 -7
  90. package/x/vibc/types/msgs.pb.go +29 -25
  91. package/x/vibc/types/receiver.go +2 -2
  92. package/x/vlocalchain/handler.go +2 -1
  93. package/x/vlocalchain/keeper/keeper.go +17 -5
  94. package/x/vlocalchain/keeper/keeper_test.go +3 -2
  95. package/x/vlocalchain/types/expected_keepers.go +7 -4
  96. package/x/vlocalchain/vlocalchain_test.go +38 -26
  97. package/x/vstorage/genesis.go +10 -10
  98. package/x/vstorage/handler.go +2 -1
  99. package/x/vstorage/keeper/keeper.go +68 -46
  100. package/x/vstorage/keeper/keeper_test.go +35 -19
  101. package/x/vstorage/module.go +27 -13
  102. package/x/vstorage/testing/queue.go +5 -3
  103. package/x/vstorage/vstorage.go +2 -1
  104. package/x/vstorage/vstorage_test.go +21 -17
  105. package/x/vtransfer/genesis.go +1 -3
  106. package/x/vtransfer/handler.go +3 -2
  107. package/x/vtransfer/ibc_middleware.go +5 -5
  108. package/x/vtransfer/ibc_middleware_test.go +43 -29
  109. package/x/vtransfer/keeper/keeper.go +35 -33
  110. package/x/vtransfer/module.go +8 -11
  111. package/x/vtransfer/types/expected_keepers.go +3 -3
  112. package/x/vtransfer/utils_test.go +26 -11
  113. package/daemon/cmd/testnet.go +0 -539
package/x/vbank/module.go CHANGED
@@ -5,6 +5,7 @@ import (
5
5
  "encoding/json"
6
6
  stdlog "log"
7
7
 
8
+ "cosmossdk.io/core/appmodule"
8
9
  "github.com/grpc-ecosystem/grpc-gateway/runtime"
9
10
  "github.com/spf13/cobra"
10
11
 
@@ -17,21 +18,27 @@ import (
17
18
  cdctypes "github.com/cosmos/cosmos-sdk/codec/types"
18
19
  "github.com/cosmos/cosmos-sdk/types/module"
19
20
 
20
- abci "github.com/cometbft/cometbft/abci/types"
21
21
  sdk "github.com/cosmos/cosmos-sdk/types"
22
- banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
23
22
  )
24
23
 
25
24
  // type check to ensure the interface is properly implemented
26
25
  var (
27
- _ module.AppModule = AppModule{}
28
- _ module.AppModuleBasic = AppModuleBasic{}
26
+ _ module.AppModule = AppModule{}
27
+ _ module.AppModuleBasic = AppModuleBasic{}
28
+ _ module.HasGenesis = AppModule{}
29
+ _ appmodule.HasEndBlocker = AppModule{}
29
30
  )
30
31
 
31
32
  // app module Basics object
32
33
  type AppModuleBasic struct {
33
34
  }
34
35
 
36
+ // IsAppModule implements the appmodule.AppModule interface.
37
+ func (am AppModule) IsAppModule() {}
38
+
39
+ // IsOnePerModuleType is a marker function just indicates that this is a one-per-module type.
40
+ func (am AppModule) IsOnePerModuleType() {}
41
+
35
42
  func (AppModuleBasic) Name() string {
36
43
  return ModuleName
37
44
  }
@@ -93,90 +100,52 @@ func (AppModule) Name() string {
93
100
 
94
101
  func (AppModule) ConsensusVersion() uint64 { return 2 }
95
102
 
96
- // BeginBlock implements the AppModule interface
97
- func (am AppModule) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock) {
98
- }
99
-
100
103
  // EndBlock implements the AppModule interface
101
- func (am AppModule) EndBlock(ctx sdk.Context, req abci.RequestEndBlock) []abci.ValidatorUpdate {
102
- events := ctx.EventManager().GetABCIEventHistory()
103
- addressToUpdate := make(map[string]sdk.Coins, len(events)*2)
104
-
105
- // records that we want to emit an balance update for the address
106
- // for the given denoms. We use the Coins only to track the set of
107
- // denoms, not for the amounts.
108
- ensureAddressUpdate := func(address string, denoms sdk.Coins) {
109
- if denoms.IsZero() {
110
- return
111
- }
112
- currentDenoms := sdk.NewCoins()
113
- if coins, ok := addressToUpdate[address]; ok {
114
- currentDenoms = coins
115
- }
116
- addressToUpdate[address] = currentDenoms.Add(denoms...)
117
- }
118
-
119
- /* Scan for all the events matching (taken from cosmos-sdk/x/bank/spec/04_events.md):
120
-
121
- type: "coin_received"
122
- "receiver": {recipient address}
123
- "amount": {Coins string}
124
- type: "coin_spent"
125
- "spender": {spender address}
126
- "amount": {Coins string}
127
- */
128
- NextEvent:
129
- for _, event := range events {
130
- switch event.Type {
131
- case banktypes.EventTypeCoinReceived, banktypes.EventTypeCoinSpent:
132
- var addr string
133
- denoms := sdk.NewCoins()
134
- for _, attr := range event.GetAttributes() {
135
- switch string(attr.GetKey()) {
136
- case banktypes.AttributeKeyReceiver, banktypes.AttributeKeySpender:
137
- addr = string(attr.GetValue())
138
- case sdk.AttributeKeyAmount:
139
- coins, err := sdk.ParseCoinsNormalized(string(attr.GetValue()))
140
- if err != nil {
141
- stdlog.Println("Cannot ensure vbank balance for", addr, err)
142
- break NextEvent
143
- }
144
- denoms = coins
145
- }
146
- }
147
- if addr != "" && !denoms.IsZero() {
148
- ensureAddressUpdate(addr, denoms)
149
- }
150
- }
151
- }
104
+ func (am AppModule) EndBlock(ctx context.Context) error {
105
+ sdkCtx := sdk.UnwrapSDKContext(ctx)
152
106
 
153
- // Prune the addressToUpdate map to only include module accounts. We prune
107
+ // Prune the AddressToUpdate map to only include module accounts. We prune
154
108
  // only after recording and consolidating all account updates to minimize the
155
109
  // number of account keeper queries.
156
- unfilteredAddresses := addressToUpdate
157
- addressToUpdate = make(map[string]sdk.Coins, len(addressToUpdate))
158
- for addr, denoms := range unfilteredAddresses {
159
- accAddr, err := sdk.AccAddressFromBech32(addr)
160
- if err == nil && am.keeper.IsAllowedMonitoringAccount(ctx, accAddr) {
161
- // Pass through the module account.
162
- addressToUpdate[addr] = denoms
110
+ filteredAddresses := make(map[string]sdk.Coins, len(am.keeper.AddressToUpdate))
111
+ adStore := am.keeper.OpenAddressToUpdateStore(sdkCtx)
112
+ iterator := adStore.Iterator(nil, nil)
113
+ defer iterator.Close()
114
+ for ; iterator.Valid(); iterator.Next() {
115
+ addrBz := iterator.Key()
116
+ addr, err := am.keeper.AddressCodec().BytesToString(addrBz)
117
+ if err != nil {
118
+ return err
119
+ }
120
+ if am.keeper.IsAllowedMonitoringAccount(sdkCtx, addr) {
121
+ // We're committed to monitor this address, so parse the denoms.
122
+ denomsBz := iterator.Value()
123
+ denoms, err := sdk.ParseCoinsNormalized(string(denomsBz))
124
+ if err != nil {
125
+ return err
126
+ }
127
+ filteredAddresses[addr] = denoms
163
128
  }
164
129
  }
165
130
 
166
131
  // Dump all the addressToBalances entries to SwingSet.
167
- action := getBalanceUpdate(ctx, am.keeper, addressToUpdate)
132
+ action, err := getBalanceUpdate(sdkCtx, am.keeper, filteredAddresses)
133
+ if err != nil {
134
+ return err
135
+ }
168
136
  if action != nil {
169
- err := am.PushAction(ctx, action)
137
+ err := am.PushAction(sdkCtx, action)
170
138
  if err != nil {
171
- panic(err)
139
+ return err
172
140
  }
173
141
  }
174
142
 
175
- if err := am.keeper.DistributeRewards(ctx); err != nil {
143
+ if err := am.keeper.DistributeRewards(sdkCtx); err != nil {
176
144
  stdlog.Println("Cannot distribute rewards", err.Error())
145
+ return err
177
146
  }
178
147
 
179
- return []abci.ValidatorUpdate{}
148
+ return nil
180
149
  }
181
150
 
182
151
  // RegisterInvariants implements the AppModule interface
@@ -199,15 +168,18 @@ func (am AppModule) RegisterServices(cfg module.Configurator) {
199
168
 
200
169
  // InitGenesis performs genesis initialization for the ibc-transfer module. It returns
201
170
  // no validator updates.
202
- func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate {
171
+ func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) {
203
172
  var genesisState types.GenesisState
204
173
  cdc.MustUnmarshalJSON(data, &genesisState)
205
- return InitGenesis(ctx, am.keeper, &genesisState)
174
+ InitGenesis(ctx, am.keeper, &genesisState)
206
175
  }
207
176
 
208
177
  // ExportGenesis returns the exported genesis state as raw bytes for the ibc-transfer
209
178
  // module.
210
179
  func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage {
211
- gs := ExportGenesis(ctx, am.keeper)
180
+ gs, err := ExportGenesis(ctx, am.keeper)
181
+ if err != nil {
182
+ panic(err)
183
+ }
212
184
  return cdc.MustMarshalJSON(gs)
213
185
  }
@@ -1,22 +1,27 @@
1
1
  package types
2
2
 
3
3
  import (
4
+ context "context"
5
+
6
+ address "cosmossdk.io/core/address"
4
7
  sdk "github.com/cosmos/cosmos-sdk/types"
5
- authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
8
+ banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
6
9
  )
7
10
 
8
11
  // A subset of github.com/cosmos/cosmos-sdk/x/bank/keeper.Keeper
9
12
  type BankKeeper interface {
10
- BurnCoins(ctx sdk.Context, moduleName string, amt sdk.Coins) error
11
- GetAllBalances(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins
12
- GetBalance(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin
13
- MintCoins(ctx sdk.Context, moduleName string, amt sdk.Coins) error
14
- SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error
15
- SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error
16
- SendCoinsFromModuleToModule(ctx sdk.Context, senderModule, recipientModule string, amt sdk.Coins) error
13
+ AppendSendRestriction(restriction banktypes.SendRestrictionFn)
14
+ BurnCoins(ctx context.Context, moduleName string, amt sdk.Coins) error
15
+ GetAllBalances(ctx context.Context, addr sdk.AccAddress) sdk.Coins
16
+ GetBalance(ctx context.Context, addr sdk.AccAddress, denom string) sdk.Coin
17
+ MintCoins(ctx context.Context, moduleName string, amt sdk.Coins) error
18
+ SendCoinsFromAccountToModule(ctx context.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error
19
+ SendCoinsFromModuleToAccount(ctx context.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error
20
+ SendCoinsFromModuleToModule(ctx context.Context, senderModule, recipientModule string, amt sdk.Coins) error
17
21
  }
18
22
 
19
23
  type AccountKeeper interface {
20
- GetModuleAccount(ctx sdk.Context, name string) authtypes.ModuleAccountI
21
- GetAccount(ctx sdk.Context, addr sdk.AccAddress) authtypes.AccountI
24
+ GetModuleAccount(ctx context.Context, name string) sdk.ModuleAccountI
25
+ GetAccount(ctx context.Context, addr sdk.AccAddress) sdk.AccountI
26
+ AddressCodec() address.Codec
22
27
  }
@@ -7,6 +7,9 @@ const (
7
7
  // StoreKey to be used when creating the KVStore
8
8
  StoreKey = ModuleName
9
9
 
10
+ // TStoreKey to be used when creating the transient store.
11
+ TStoreKey = "transient_" + ModuleName
12
+
10
13
  ReservePoolName = "vbank/reserve"
11
14
  GiveawayPoolName = "vbank/giveaway"
12
15
  ProvisionPoolName = "vbank/provision"
@@ -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
  authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
10
11
  paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
@@ -31,7 +32,7 @@ func DefaultParams() Params {
31
32
  return Params{
32
33
  RewardEpochDurationBlocks: 0,
33
34
  RewardSmoothingBlocks: 1,
34
- PerEpochRewardFraction: sdk.OneDec(),
35
+ PerEpochRewardFraction: sdkmath.LegacyOneDec(),
35
36
  AllowedMonitoringAccounts: []string{provisionAddress.String()},
36
37
  }
37
38
  }
@@ -141,7 +142,7 @@ func validateRewardEpochDurationBlocks(i interface{}) error {
141
142
  }
142
143
 
143
144
  func validatePerEpochRewardFraction(i interface{}) error {
144
- v, ok := i.(sdk.Dec)
145
+ v, ok := i.(sdkmath.LegacyDec)
145
146
  if !ok {
146
147
  return fmt.Errorf("invalid parameter type: %T", i)
147
148
  }
@@ -150,7 +151,7 @@ func validatePerEpochRewardFraction(i interface{}) error {
150
151
  return fmt.Errorf("per epoch reward fraction must be nonnegative: %s", v)
151
152
  }
152
153
 
153
- if v.GT(sdk.OneDec()) {
154
+ if v.GT(sdkmath.LegacyOneDec()) {
154
155
  return fmt.Errorf("per epoch reward fraction must be less than or equal to one: %s", v)
155
156
  }
156
157
 
@@ -4,6 +4,7 @@
4
4
  package types
5
5
 
6
6
  import (
7
+ cosmossdk_io_math "cosmossdk.io/math"
7
8
  fmt "fmt"
8
9
  github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types"
9
10
  types "github.com/cosmos/cosmos-sdk/types"
@@ -34,7 +35,7 @@ type Params struct {
34
35
  // per_epoch_reward_fraction is a fraction of the reward pool to distrubute
35
36
  // once every reward epoch. If less than zero, use approximately continuous
36
37
  // per-block distribution.
37
- PerEpochRewardFraction github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=per_epoch_reward_fraction,json=perEpochRewardFraction,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"per_epoch_reward_fraction" yaml:"discrete_epoch_reward_fraction"`
38
+ PerEpochRewardFraction cosmossdk_io_math.LegacyDec `protobuf:"bytes,2,opt,name=per_epoch_reward_fraction,json=perEpochRewardFraction,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"per_epoch_reward_fraction" yaml:"discrete_epoch_reward_fraction"`
38
39
  // reward_smoothing_blocks is the number of blocks over which to distribute
39
40
  // an epoch's rewards. If zero, use the same value as
40
41
  // reward_epoch_duration_blocks.
@@ -181,45 +182,45 @@ func init() {
181
182
  func init() { proto.RegisterFile("agoric/vbank/vbank.proto", fileDescriptor_5e89b3b9e5e671b4) }
182
183
 
183
184
  var fileDescriptor_5e89b3b9e5e671b4 = []byte{
184
- // 597 bytes of a gzipped FileDescriptorProto
185
- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x94, 0x3f, 0x6f, 0xd3, 0x4e,
186
- 0x18, 0xc7, 0xe3, 0x26, 0xbf, 0xea, 0xd7, 0x6b, 0x19, 0x30, 0x05, 0x9c, 0x16, 0xd9, 0xd1, 0x21,
187
- 0x4a, 0x18, 0xb0, 0x55, 0x58, 0x50, 0x25, 0x86, 0x9a, 0xd2, 0x0d, 0x54, 0xb9, 0x03, 0x52, 0x97,
188
- 0xe8, 0x7c, 0xb9, 0x3a, 0x56, 0x6d, 0x3f, 0xe1, 0xee, 0xd2, 0xd2, 0x95, 0x57, 0x80, 0x98, 0x60,
189
- 0xeb, 0xcc, 0x2b, 0xe9, 0xd8, 0x05, 0x09, 0x21, 0x61, 0x50, 0xbb, 0x30, 0xe7, 0x15, 0xa0, 0xfb,
190
- 0x53, 0xda, 0x20, 0x14, 0x60, 0x49, 0xe2, 0x7c, 0xbe, 0xcf, 0x93, 0xef, 0xf3, 0x27, 0x0f, 0xf2,
191
- 0x48, 0x06, 0x3c, 0xa7, 0xd1, 0x7e, 0x4a, 0xaa, 0x3d, 0xf3, 0x1a, 0x0e, 0x39, 0x48, 0x70, 0x17,
192
- 0x0c, 0x09, 0xf5, 0x77, 0x4b, 0x8b, 0x19, 0x64, 0xa0, 0x41, 0xa4, 0x3e, 0x19, 0xcd, 0x92, 0x4f,
193
- 0x41, 0x94, 0x20, 0xa2, 0x94, 0x08, 0x16, 0xed, 0xaf, 0xa6, 0x4c, 0x92, 0xd5, 0x88, 0x42, 0x5e,
194
- 0x19, 0x8e, 0x3f, 0x36, 0xd1, 0xec, 0x16, 0xe1, 0xa4, 0x14, 0xee, 0x00, 0xdd, 0xe2, 0xec, 0x80,
195
- 0xf0, 0x7e, 0x8f, 0x0d, 0x81, 0x0e, 0x7a, 0xfd, 0x11, 0x27, 0x32, 0x87, 0xaa, 0x97, 0x16, 0x40,
196
- 0xf7, 0x84, 0xe7, 0x74, 0x9c, 0x6e, 0x33, 0xbe, 0x3b, 0xae, 0x83, 0xdb, 0x87, 0xa4, 0x2c, 0xd6,
197
- 0xf0, 0x34, 0x35, 0x4e, 0xda, 0x06, 0x3f, 0x55, 0x74, 0xc3, 0xc2, 0x58, 0x33, 0xf7, 0xad, 0x83,
198
- 0xda, 0x43, 0xc6, 0x6d, 0xa4, 0x4d, 0xb3, 0xcb, 0x09, 0x55, 0x1a, 0x6f, 0xa6, 0xe3, 0x74, 0xe7,
199
- 0xe2, 0x17, 0xc7, 0x75, 0xd0, 0xf8, 0x5c, 0x07, 0x2b, 0x59, 0x2e, 0x07, 0xa3, 0x34, 0xa4, 0x50,
200
- 0x46, 0xb6, 0x16, 0xf3, 0x76, 0x5f, 0xf4, 0xf7, 0x22, 0x79, 0x38, 0x64, 0x22, 0xdc, 0x60, 0x74,
201
- 0x5c, 0x07, 0x77, 0x8c, 0xab, 0x7e, 0x2e, 0x28, 0x67, 0x92, 0xfd, 0x3e, 0x3b, 0x4e, 0x6e, 0x0c,
202
- 0x19, 0xd7, 0xa6, 0x12, 0x4d, 0x36, 0x2d, 0x70, 0x77, 0xd0, 0x4d, 0xab, 0x15, 0x25, 0x80, 0x1c,
203
- 0xe4, 0x55, 0x76, 0x5e, 0x79, 0x53, 0x57, 0x8e, 0xc7, 0x75, 0xe0, 0x4f, 0x54, 0xfe, 0xab, 0x10,
204
- 0x27, 0xd7, 0x0d, 0xd9, 0x3e, 0x07, 0xb6, 0xe0, 0x5d, 0xb4, 0x4c, 0x8a, 0x02, 0x0e, 0x58, 0xbf,
205
- 0x57, 0x42, 0x95, 0x4b, 0xe0, 0x2a, 0x88, 0x50, 0x0a, 0xa3, 0x4a, 0x0a, 0xaf, 0xd5, 0x69, 0x76,
206
- 0xe7, 0xe2, 0x95, 0x71, 0x1d, 0x60, 0x93, 0x7f, 0x8a, 0x18, 0x27, 0x6d, 0x4b, 0x9f, 0xfd, 0x84,
207
- 0xeb, 0x96, 0xad, 0xfd, 0xff, 0xee, 0x28, 0x68, 0x7c, 0x3f, 0x0a, 0x1c, 0xfc, 0xa5, 0x89, 0xfe,
208
- 0xdb, 0x96, 0x44, 0x32, 0xf7, 0xb5, 0x83, 0xe6, 0xad, 0xdf, 0x21, 0x40, 0xe1, 0x39, 0x9d, 0x66,
209
- 0x77, 0xfe, 0x41, 0x3b, 0x34, 0x5d, 0x0c, 0xd5, 0x62, 0x84, 0x76, 0x31, 0xc2, 0x27, 0x90, 0x57,
210
- 0xf1, 0xa6, 0xea, 0xfc, 0xb8, 0x0e, 0xdc, 0x89, 0x5a, 0x55, 0x2c, 0xfe, 0xf0, 0x35, 0xe8, 0xfe,
211
- 0xc5, 0x3c, 0x54, 0x1a, 0x91, 0x20, 0x13, 0xb9, 0x05, 0x50, 0xb8, 0xef, 0x1d, 0x74, 0xcd, 0x26,
212
- 0xd2, 0xad, 0xea, 0x91, 0x52, 0x39, 0xf6, 0x66, 0xfe, 0x64, 0xe6, 0xb9, 0x35, 0xb3, 0x34, 0x61,
213
- 0xe6, 0x72, 0x8e, 0x7f, 0x33, 0x75, 0xd5, 0x64, 0xd0, 0x73, 0x59, 0xd7, 0xf1, 0xee, 0x63, 0x74,
214
- 0xa5, 0x20, 0x42, 0xf6, 0x04, 0x7b, 0x39, 0x62, 0x15, 0x65, 0x7a, 0xdc, 0xad, 0xd8, 0x1b, 0xd7,
215
- 0xc1, 0xa2, 0xf9, 0xd5, 0x09, 0x8c, 0x93, 0x05, 0xf5, 0xbc, 0x6d, 0x1f, 0xdd, 0x0a, 0xf9, 0x9a,
216
- 0x5b, 0x6b, 0xfd, 0x5c, 0x48, 0x9e, 0xa7, 0xa3, 0x8b, 0xff, 0x82, 0xd7, 0xd2, 0xeb, 0x73, 0xef,
217
- 0x62, 0x45, 0xa7, 0xeb, 0x71, 0xb2, 0xac, 0x04, 0x66, 0x3d, 0x37, 0x2e, 0x61, 0x6d, 0x7a, 0xad,
218
- 0xa5, 0xe6, 0x1b, 0x27, 0xc7, 0xa7, 0xbe, 0x73, 0x72, 0xea, 0x3b, 0xdf, 0x4e, 0x7d, 0xe7, 0xcd,
219
- 0x99, 0xdf, 0x38, 0x39, 0xf3, 0x1b, 0x9f, 0xce, 0xfc, 0xc6, 0xce, 0xa3, 0x4b, 0xbd, 0x58, 0x37,
220
- 0xa7, 0xc3, 0xdc, 0x09, 0xdd, 0x8b, 0x0c, 0x0a, 0x52, 0x65, 0xe7, 0x4d, 0x7a, 0x65, 0xaf, 0x8a,
221
- 0xee, 0x50, 0x3a, 0xab, 0x4f, 0xc2, 0xc3, 0x1f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x60, 0x18, 0x80,
222
- 0x8f, 0x72, 0x04, 0x00, 0x00,
185
+ // 606 bytes of a gzipped FileDescriptorProto
186
+ 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x94, 0x31, 0x6f, 0xd3, 0x40,
187
+ 0x14, 0xc7, 0xe3, 0x26, 0x54, 0xf4, 0x5a, 0x06, 0x4c, 0x01, 0xa7, 0x45, 0x76, 0x74, 0x08, 0x08,
188
+ 0x03, 0xb6, 0x0a, 0x0b, 0xaa, 0xc4, 0x50, 0x53, 0x3a, 0x15, 0x54, 0xb9, 0x5b, 0x97, 0xe8, 0x7c,
189
+ 0xbe, 0x3a, 0x56, 0x6c, 0xbf, 0x70, 0x77, 0x69, 0xe9, 0xca, 0xc2, 0xca, 0x08, 0x5b, 0x67, 0x3e,
190
+ 0x49, 0xc5, 0xd4, 0x11, 0x21, 0x61, 0x50, 0xbb, 0x30, 0xfb, 0x13, 0x20, 0xdf, 0x5d, 0x69, 0x83,
191
+ 0x50, 0x11, 0x4b, 0x92, 0xcb, 0xef, 0xff, 0x9e, 0xff, 0xef, 0xdd, 0xf3, 0x43, 0x0e, 0x49, 0x81,
192
+ 0x67, 0x34, 0xd8, 0x8b, 0x49, 0x39, 0xd2, 0x9f, 0xfe, 0x98, 0x83, 0x04, 0x7b, 0x41, 0x13, 0x5f,
193
+ 0xfd, 0xb7, 0xb4, 0x98, 0x42, 0x0a, 0x0a, 0x04, 0xcd,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0x78, 0xfb, 0x19, 0xba, 0x96, 0x13, 0x21, 0x07, 0x82, 0xbd, 0x9e,
216
+ 0xb0, 0x92, 0x32, 0x75, 0xdd, 0x9d, 0xd0, 0xa9, 0x2b, 0x6f, 0x51, 0x3f, 0x75, 0x0a, 0xe3, 0x68,
217
+ 0xa1, 0x39, 0x6f, 0x9b, 0xa3, 0x5d, 0x22, 0x57, 0x71, 0x63, 0x2d, 0xc9, 0x84, 0xe4, 0x59, 0x3c,
218
+ 0x39, 0x7f, 0x01, 0x9c, 0x8e, 0x1a, 0x9f, 0x87, 0xe7, 0x23, 0x7a, 0xb9, 0x1e, 0x47, 0xcb, 0x8d,
219
+ 0x40, 0x8f, 0xe7, 0xfa, 0x05, 0xac, 0x4c, 0xaf, 0x76, 0x9a, 0xfb, 0x0d, 0xa3, 0xa3, 0x13, 0xd7,
220
+ 0x3a, 0x3e, 0x71, 0xad, 0x1f, 0x27, 0xae, 0xf5, 0xfe, 0xd4, 0x6d, 0x1d, 0x9f, 0xba, 0xad, 0x2f,
221
+ 0xa7, 0x6e, 0x6b, 0xe7, 0xe9, 0x85, 0x5e, 0xac, 0xe9, 0x7d, 0xa1, 0x97, 0x83, 0xea, 0x45, 0x0a,
222
+ 0x39, 0x29, 0xd3, 0xb3, 0x26, 0xbd, 0x31, 0xab, 0x44, 0x75, 0x28, 0x9e, 0x55, 0x7b, 0xe0, 0xc9,
223
+ 0xaf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x8e, 0xe4, 0xc6, 0x3a, 0x67, 0x04, 0x00, 0x00,
223
224
  }
224
225
 
225
226
  func (this *Params) Equal(that interface{}) bool {
package/x/vbank/vbank.go CHANGED
@@ -7,6 +7,7 @@ import (
7
7
  stdlog "log"
8
8
  "sort"
9
9
 
10
+ sdkmath "cosmossdk.io/math"
10
11
  "github.com/Agoric/agoric-sdk/golang/cosmos/vm"
11
12
  "github.com/cosmos/cosmos-sdk/baseapp"
12
13
  sdk "github.com/cosmos/cosmos-sdk/types"
@@ -76,13 +77,16 @@ type VbankBalanceUpdate struct {
76
77
  // getBalanceUpdate returns a bridge message containing the current bank balance
77
78
  // for the given addresses each for the specified denominations. Coins are used
78
79
  // only to track the set of denoms, not for the particular nonzero amounts.
79
- func getBalanceUpdate(ctx sdk.Context, keeper Keeper, addressToUpdate map[string]sdk.Coins) vm.Action {
80
+ func getBalanceUpdate(ctx sdk.Context, keeper Keeper, addressToUpdate map[string]sdk.Coins) (vm.Action, error) {
80
81
  nentries := len(addressToUpdate)
81
82
  if nentries == 0 {
82
- return nil
83
+ return nil, nil
83
84
  }
84
85
 
85
- nonce := keeper.GetNextSequence(ctx)
86
+ nonce, err := keeper.GetNextSequence(ctx)
87
+ if err != nil {
88
+ return nil, err
89
+ }
86
90
  event := VbankBalanceUpdate{
87
91
  Nonce: nonce,
88
92
  Updated: make([]VbankSingleBalanceUpdate, 0, nentries),
@@ -112,7 +116,7 @@ func getBalanceUpdate(ctx sdk.Context, keeper Keeper, addressToUpdate map[string
112
116
  sort.Sort(event.Updated)
113
117
 
114
118
  // Populate the event default fields (even though event does not embed vm.ActionHeader)
115
- return vm.PopulateAction(ctx, event)
119
+ return vm.PopulateAction(ctx, event), nil
116
120
  }
117
121
 
118
122
  func marshal(event vm.Jsonable) ([]byte, error) {
@@ -157,7 +161,7 @@ func (ch portHandler) Receive(cctx context.Context, str string) (ret string, err
157
161
  if err = sdk.ValidateDenom(msg.Denom); err != nil {
158
162
  return "", fmt.Errorf("invalid denom %s: %s", msg.Denom, err)
159
163
  }
160
- value, ok := sdk.NewIntFromString(msg.Amount)
164
+ value, ok := sdkmath.NewIntFromString(msg.Amount)
161
165
  if !ok {
162
166
  return "", fmt.Errorf("cannot convert %s to int", msg.Amount)
163
167
  }
@@ -167,7 +171,11 @@ func (ch portHandler) Receive(cctx context.Context, str string) (ret string, err
167
171
  }
168
172
  addressToBalances := make(map[string]sdk.Coins, 1)
169
173
  addressToBalances[msg.Sender] = sdk.NewCoins(sdk.NewInt64Coin(msg.Denom, 1))
170
- bz, err := marshal(getBalanceUpdate(ctx, keeper, addressToBalances))
174
+ action, err := getBalanceUpdate(ctx, keeper, addressToBalances)
175
+ if err != nil {
176
+ return "", err
177
+ }
178
+ bz, err := marshal(action)
171
179
  if err != nil {
172
180
  return "", err
173
181
  }
@@ -185,7 +193,7 @@ func (ch portHandler) Receive(cctx context.Context, str string) (ret string, err
185
193
  if err = sdk.ValidateDenom(msg.Denom); err != nil {
186
194
  return "", fmt.Errorf("invalid denom %s: %s", msg.Denom, err)
187
195
  }
188
- value, ok := sdk.NewIntFromString(msg.Amount)
196
+ value, ok := sdkmath.NewIntFromString(msg.Amount)
189
197
  if !ok {
190
198
  return "", fmt.Errorf("cannot convert %s to int", msg.Amount)
191
199
  }
@@ -195,7 +203,11 @@ func (ch portHandler) Receive(cctx context.Context, str string) (ret string, err
195
203
  }
196
204
  addressToBalances := make(map[string]sdk.Coins, 1)
197
205
  addressToBalances[msg.Recipient] = sdk.NewCoins(sdk.NewInt64Coin(msg.Denom, 1))
198
- bz, err := marshal(getBalanceUpdate(ctx, keeper, addressToBalances))
206
+ action, err := getBalanceUpdate(ctx, keeper, addressToBalances)
207
+ if err != nil {
208
+ return "", err
209
+ }
210
+ bz, err := marshal(action)
199
211
  if err != nil {
200
212
  return "", err
201
213
  }
@@ -206,7 +218,7 @@ func (ch portHandler) Receive(cctx context.Context, str string) (ret string, err
206
218
  }
207
219
 
208
220
  case "VBANK_GIVE_TO_REWARD_DISTRIBUTOR":
209
- value, ok := sdk.NewIntFromString(msg.Amount)
221
+ value, ok := sdkmath.NewIntFromString(msg.Amount)
210
222
  if !ok {
211
223
  return "", fmt.Errorf("cannot convert %s to int", msg.Amount)
212
224
  }
@@ -214,7 +226,10 @@ func (ch portHandler) Receive(cctx context.Context, str string) (ret string, err
214
226
  if err := keeper.StoreRewardCoins(ctx, coins); err != nil {
215
227
  return "", fmt.Errorf("cannot store reward %s coins: %s", coins.Sort().String(), err)
216
228
  }
217
- state := keeper.GetState(ctx)
229
+ state, err := keeper.GetState(ctx)
230
+ if err != nil {
231
+ return "", err
232
+ }
218
233
  state.RewardPool = state.RewardPool.Add(coins...)
219
234
  keeper.SetState(ctx, state)
220
235
  // We don't supply the module balance, since the controller shouldn't know.