@agoric/cosmos 0.35.0-u18.4 → 0.35.0-u18.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/x/vbank/module.go CHANGED
@@ -91,7 +91,7 @@ func (AppModule) Name() string {
91
91
  return ModuleName
92
92
  }
93
93
 
94
- func (AppModule) ConsensusVersion() uint64 { return 1 }
94
+ func (AppModule) ConsensusVersion() uint64 { return 2 }
95
95
 
96
96
  // BeginBlock implements the AppModule interface
97
97
  func (am AppModule) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock) {
@@ -157,7 +157,7 @@ NextEvent:
157
157
  addressToUpdate = make(map[string]sdk.Coins, len(addressToUpdate))
158
158
  for addr, denoms := range unfilteredAddresses {
159
159
  accAddr, err := sdk.AccAddressFromBech32(addr)
160
- if err == nil && am.keeper.IsModuleAccount(ctx, accAddr) {
160
+ if err == nil && am.keeper.IsAllowedMonitoringAccount(ctx, accAddr) {
161
161
  // Pass through the module account.
162
162
  addressToUpdate[addr] = denoms
163
163
  }
@@ -204,6 +204,12 @@ func (am AppModule) RegisterServices(cfg module.Configurator) {
204
204
  tx := &types.UnimplementedMsgServer{}
205
205
  types.RegisterMsgServer(cfg.MsgServer(), tx)
206
206
  types.RegisterQueryServer(cfg.QueryServer(), am.keeper)
207
+
208
+ m := keeper.NewMigrator(am.keeper)
209
+ err := cfg.RegisterMigration(types.ModuleName, 1, m.Migrate1to2)
210
+ if err != nil {
211
+ panic(err)
212
+ }
207
213
  }
208
214
 
209
215
  // InitGenesis performs genesis initialization for the ibc-transfer module. It returns
@@ -6,14 +6,18 @@ import (
6
6
  yaml "gopkg.in/yaml.v2"
7
7
 
8
8
  sdk "github.com/cosmos/cosmos-sdk/types"
9
+ authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
9
10
  paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
10
11
  )
11
12
 
13
+ const AllowAllMonitoringAccountsPattern = "*"
14
+
12
15
  // Parameter keys
13
16
  var (
14
17
  ParamStoreKeyRewardEpochDurationBlocks = []byte("reward_epoch_duration_blocks")
15
18
  ParamStoreKeyRewardSmoothingBlocks = []byte("reward_smoothing_blocks")
16
19
  ParamStoreKeyPerEpochRewardFraction = []byte("per_epoch_reward_fraction")
20
+ ParamStoreKeyAllowedMonitoringAccounts = []byte("allowed_monitoring_accounts")
17
21
  )
18
22
 
19
23
  // ParamKeyTable returns the parameter key table.
@@ -21,12 +25,14 @@ func ParamKeyTable() paramtypes.KeyTable {
21
25
  return paramtypes.NewKeyTable().RegisterParamSet(&Params{})
22
26
  }
23
27
 
24
- // DefaultParams returns default distribution parameters
28
+ // DefaultParams returns default parameters
25
29
  func DefaultParams() Params {
30
+ provisionAddress := authtypes.NewModuleAddress(ProvisionPoolName)
26
31
  return Params{
27
32
  RewardEpochDurationBlocks: 0,
28
33
  RewardSmoothingBlocks: 1,
29
34
  PerEpochRewardFraction: sdk.OneDec(),
35
+ AllowedMonitoringAccounts: []string{provisionAddress.String()},
30
36
  }
31
37
  }
32
38
 
@@ -67,12 +73,27 @@ func (p Params) RewardRate(pool sdk.Coins, blocks int64) sdk.Coins {
67
73
  return sdk.NewCoins(coins...)
68
74
  }
69
75
 
76
+ // IsAllowedMonitoringAccount checks to see if a given address is allowed to monitor its balance.
77
+ func (p Params) IsAllowedMonitoringAccount(addr string) bool {
78
+ for _, pat := range p.AllowedMonitoringAccounts {
79
+ switch pat {
80
+ case AllowAllMonitoringAccountsPattern, addr:
81
+ // Got an AllowAll pattern or an exact match.
82
+ return true
83
+ }
84
+ }
85
+
86
+ // No match found.
87
+ return false
88
+ }
89
+
70
90
  // ParamSetPairs returns the parameter set pairs.
71
91
  func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs {
72
92
  return paramtypes.ParamSetPairs{
73
93
  paramtypes.NewParamSetPair(ParamStoreKeyRewardEpochDurationBlocks, &p.RewardEpochDurationBlocks, validateRewardEpochDurationBlocks),
74
94
  paramtypes.NewParamSetPair(ParamStoreKeyRewardSmoothingBlocks, &p.RewardSmoothingBlocks, validateRewardSmoothingBlocks),
75
95
  paramtypes.NewParamSetPair(ParamStoreKeyPerEpochRewardFraction, &p.PerEpochRewardFraction, validatePerEpochRewardFraction),
96
+ paramtypes.NewParamSetPair(ParamStoreKeyAllowedMonitoringAccounts, &p.AllowedMonitoringAccounts, validateAllowedMonitoringAccounts),
76
97
  }
77
98
  }
78
99
 
@@ -84,7 +105,12 @@ func (p Params) ValidateBasic() error {
84
105
  if err := validatePerEpochRewardFraction(p.PerEpochRewardFraction); err != nil {
85
106
  return err
86
107
  }
87
-
108
+ if err := validateRewardSmoothingBlocks(p.RewardSmoothingBlocks); err != nil {
109
+ return err
110
+ }
111
+ if err := validateAllowedMonitoringAccounts(p.AllowedMonitoringAccounts); err != nil {
112
+ return err
113
+ }
88
114
  return nil
89
115
  }
90
116
 
@@ -130,3 +156,18 @@ func validatePerEpochRewardFraction(i interface{}) error {
130
156
 
131
157
  return nil
132
158
  }
159
+
160
+ func validateAllowedMonitoringAccounts(i interface{}) error {
161
+ v, ok := i.([]string)
162
+ if !ok {
163
+ return fmt.Errorf("invalid parameter type: %T", i)
164
+ }
165
+
166
+ for a, acc := range v {
167
+ if acc == "" {
168
+ return fmt.Errorf("allowed monitoring accounts element[%d] cannot be empty", a)
169
+ }
170
+ }
171
+
172
+ return nil
173
+ }
@@ -39,6 +39,10 @@ type Params struct {
39
39
  // an epoch's rewards. If zero, use the same value as
40
40
  // reward_epoch_duration_blocks.
41
41
  RewardSmoothingBlocks int64 `protobuf:"varint,3,opt,name=reward_smoothing_blocks,json=rewardSmoothingBlocks,proto3" json:"reward_smoothing_blocks,omitempty" yaml:"reward_smoothing_blocks"`
42
+ // allowed_monitoring_accounts is an array of account addresses that can be
43
+ // monitored for sends and receives. An element of `"*"` will permit any
44
+ // address.
45
+ AllowedMonitoringAccounts []string `protobuf:"bytes,4,rep,name=allowed_monitoring_accounts,json=allowedMonitoringAccounts,proto3" json:"allowed_monitoring_accounts,omitempty" yaml:"allowed_monitoring_accounts"`
42
46
  }
43
47
 
44
48
  func (m *Params) Reset() { *m = Params{} }
@@ -87,6 +91,13 @@ func (m *Params) GetRewardSmoothingBlocks() int64 {
87
91
  return 0
88
92
  }
89
93
 
94
+ func (m *Params) GetAllowedMonitoringAccounts() []string {
95
+ if m != nil {
96
+ return m.AllowedMonitoringAccounts
97
+ }
98
+ return nil
99
+ }
100
+
90
101
  // The current state of the module.
91
102
  type State struct {
92
103
  // rewardPool is the current balance of rewards in the module account.
@@ -170,42 +181,45 @@ func init() {
170
181
  func init() { proto.RegisterFile("agoric/vbank/vbank.proto", fileDescriptor_5e89b3b9e5e671b4) }
171
182
 
172
183
  var fileDescriptor_5e89b3b9e5e671b4 = []byte{
173
- // 550 bytes of a gzipped FileDescriptorProto
174
- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x93, 0x31, 0x6f, 0xd3, 0x40,
175
- 0x14, 0xc7, 0x73, 0x49, 0xa8, 0xe0, 0x5a, 0x06, 0x4c, 0x01, 0x27, 0x20, 0x3b, 0x32, 0x02, 0xc2,
176
- 0x80, 0xad, 0xc2, 0x82, 0x22, 0x31, 0xd4, 0x84, 0x8e, 0xa8, 0x72, 0x06, 0xa4, 0x2e, 0xd1, 0xd9,
177
- 0x39, 0x1c, 0x2b, 0xb6, 0x9f, 0xb9, 0xbb, 0x14, 0xba, 0xf2, 0x09, 0x10, 0x13, 0x6c, 0x9d, 0xf9,
178
- 0x24, 0x1d, 0x3b, 0x22, 0x24, 0x0c, 0x4a, 0x16, 0x16, 0x96, 0x7c, 0x02, 0xe4, 0xbb, 0x8b, 0x9a,
179
- 0x20, 0x54, 0x60, 0x49, 0x7c, 0xfe, 0xbd, 0xf7, 0xfc, 0x7f, 0xff, 0x77, 0x0f, 0x9b, 0x24, 0x06,
180
- 0x96, 0x44, 0xde, 0x61, 0x48, 0xf2, 0x89, 0xfa, 0x75, 0x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0x58, 0x9e, 0x01, 0x88, 0x71, 0x92,
192
- 0xc7, 0xcb, 0xce, 0x1b, 0xb2, 0x73, 0x67, 0x51, 0xda, 0xd6, 0x5a, 0xe7, 0xbf, 0x07, 0x3a, 0xc1,
193
- 0x35, 0x45, 0x06, 0x4b, 0xa0, 0x1a, 0xee, 0x5d, 0xfc, 0x70, 0x6c, 0xd7, 0x7e, 0x1c, 0xdb, 0xc8,
194
- 0xf9, 0xda, 0xc0, 0x17, 0x06, 0x82, 0x08, 0x6a, 0xbc, 0x45, 0x78, 0x53, 0xd7, 0x29, 0x00, 0x52,
195
- 0x13, 0x75, 0x1a, 0xdd, 0xcd, 0x87, 0x2d, 0x57, 0x75, 0xe7, 0x56, 0x03, 0x73, 0xf5, 0xc0, 0xdc,
196
- 0xa7, 0x90, 0xe4, 0xfe, 0x5e, 0xe5, 0xc8, 0xa2, 0xb4, 0x8d, 0x35, 0x0d, 0x55, 0xae, 0xf3, 0xe9,
197
- 0x9b, 0xdd, 0xfd, 0x07, 0x9f, 0xaa, 0x32, 0x3c, 0xc0, 0x2a, 0x73, 0x1f, 0x20, 0x35, 0x3e, 0x22,
198
- 0x7c, 0x55, 0x17, 0x92, 0x2d, 0x0c, 0x49, 0x06, 0xd3, 0x5c, 0x98, 0xf5, 0xbf, 0x89, 0x79, 0xae,
199
- 0xc5, 0xb4, 0xd7, 0xc4, 0xac, 0xd6, 0xf8, 0x3f, 0x51, 0x57, 0x54, 0x05, 0xe9, 0xd7, 0xae, 0xcc,
200
- 0x37, 0x9e, 0xe0, 0xcb, 0x29, 0xe1, 0x62, 0xc8, 0xe9, 0xab, 0x29, 0xcd, 0x23, 0x2a, 0xc7, 0xd0,
201
- 0xf4, 0xcd, 0x45, 0x69, 0x6f, 0xab, 0xaf, 0xae, 0x61, 0x27, 0xd8, 0xaa, 0xce, 0x03, 0x7d, 0x34,
202
- 0x72, 0x6c, 0x49, 0xae, 0xa5, 0x8d, 0x12, 0x2e, 0x58, 0x12, 0x4e, 0xcf, 0xee, 0xa8, 0xd9, 0x94,
203
- 0x63, 0xbd, 0x7f, 0x76, 0x75, 0xce, 0x8f, 0x77, 0x82, 0x9b, 0x55, 0x80, 0xba, 0x36, 0xfd, 0x15,
204
- 0x2c, 0x45, 0xf7, 0x9a, 0xd5, 0x7c, 0xfd, 0xe0, 0x64, 0x66, 0xa1, 0xd3, 0x99, 0x85, 0xbe, 0xcf,
205
- 0x2c, 0xf4, 0x6e, 0x6e, 0xd5, 0x4e, 0xe7, 0x56, 0xed, 0xf3, 0xdc, 0xaa, 0x1d, 0x3c, 0x5e, 0xf1,
206
- 0x62, 0x57, 0xad, 0xb4, 0xda, 0x5f, 0xe9, 0x45, 0x0c, 0x29, 0xc9, 0xe3, 0xa5, 0x49, 0x6f, 0xf4,
207
- 0xb6, 0x4b, 0x87, 0xc2, 0x0d, 0xb9, 0xaa, 0x8f, 0x7e, 0x05, 0x00, 0x00, 0xff, 0xff, 0xbc, 0x95,
208
- 0x56, 0xb1, 0x0a, 0x04, 0x00, 0x00,
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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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,
209
223
  }
210
224
 
211
225
  func (this *Params) Equal(that interface{}) bool {
@@ -236,6 +250,14 @@ func (this *Params) Equal(that interface{}) bool {
236
250
  if this.RewardSmoothingBlocks != that1.RewardSmoothingBlocks {
237
251
  return false
238
252
  }
253
+ if len(this.AllowedMonitoringAccounts) != len(that1.AllowedMonitoringAccounts) {
254
+ return false
255
+ }
256
+ for i := range this.AllowedMonitoringAccounts {
257
+ if this.AllowedMonitoringAccounts[i] != that1.AllowedMonitoringAccounts[i] {
258
+ return false
259
+ }
260
+ }
239
261
  return true
240
262
  }
241
263
  func (this *State) Equal(that interface{}) bool {
@@ -301,6 +323,15 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) {
301
323
  _ = i
302
324
  var l int
303
325
  _ = l
326
+ if len(m.AllowedMonitoringAccounts) > 0 {
327
+ for iNdEx := len(m.AllowedMonitoringAccounts) - 1; iNdEx >= 0; iNdEx-- {
328
+ i -= len(m.AllowedMonitoringAccounts[iNdEx])
329
+ copy(dAtA[i:], m.AllowedMonitoringAccounts[iNdEx])
330
+ i = encodeVarintVbank(dAtA, i, uint64(len(m.AllowedMonitoringAccounts[iNdEx])))
331
+ i--
332
+ dAtA[i] = 0x22
333
+ }
334
+ }
304
335
  if m.RewardSmoothingBlocks != 0 {
305
336
  i = encodeVarintVbank(dAtA, i, uint64(m.RewardSmoothingBlocks))
306
337
  i--
@@ -410,6 +441,12 @@ func (m *Params) Size() (n int) {
410
441
  if m.RewardSmoothingBlocks != 0 {
411
442
  n += 1 + sovVbank(uint64(m.RewardSmoothingBlocks))
412
443
  }
444
+ if len(m.AllowedMonitoringAccounts) > 0 {
445
+ for _, s := range m.AllowedMonitoringAccounts {
446
+ l = len(s)
447
+ n += 1 + l + sovVbank(uint64(l))
448
+ }
449
+ }
413
450
  return n
414
451
  }
415
452
 
@@ -547,6 +584,38 @@ func (m *Params) Unmarshal(dAtA []byte) error {
547
584
  break
548
585
  }
549
586
  }
587
+ case 4:
588
+ if wireType != 2 {
589
+ return fmt.Errorf("proto: wrong wireType = %d for field AllowedMonitoringAccounts", wireType)
590
+ }
591
+ var stringLen uint64
592
+ for shift := uint(0); ; shift += 7 {
593
+ if shift >= 64 {
594
+ return ErrIntOverflowVbank
595
+ }
596
+ if iNdEx >= l {
597
+ return io.ErrUnexpectedEOF
598
+ }
599
+ b := dAtA[iNdEx]
600
+ iNdEx++
601
+ stringLen |= uint64(b&0x7F) << shift
602
+ if b < 0x80 {
603
+ break
604
+ }
605
+ }
606
+ intStringLen := int(stringLen)
607
+ if intStringLen < 0 {
608
+ return ErrInvalidLengthVbank
609
+ }
610
+ postIndex := iNdEx + intStringLen
611
+ if postIndex < 0 {
612
+ return ErrInvalidLengthVbank
613
+ }
614
+ if postIndex > l {
615
+ return io.ErrUnexpectedEOF
616
+ }
617
+ m.AllowedMonitoringAccounts = append(m.AllowedMonitoringAccounts, string(dAtA[iNdEx:postIndex]))
618
+ iNdEx = postIndex
550
619
  default:
551
620
  iNdEx = preIndex
552
621
  skippy, err := skipVbank(dAtA[iNdEx:])
@@ -439,6 +439,7 @@ func Test_Receive_GiveToRewardDistributor(t *testing.T) {
439
439
  params := types.DefaultParams()
440
440
  params.RewardEpochDurationBlocks = 0
441
441
  params.RewardSmoothingBlocks = tt.duration
442
+ params.AllowedMonitoringAccounts = []string{"*"}
442
443
 
443
444
  keeper.SetParams(ctx, params)
444
445
  keeper.SetState(ctx, types.State{RewardPool: tt.rewardPool})
@@ -524,7 +525,7 @@ func Test_EndBlock_Events(t *testing.T) {
524
525
  }
525
526
  keeper, ctx := makeTestKit(acct, bank)
526
527
  // Turn off rewards.
527
- keeper.SetParams(ctx, types.Params{PerEpochRewardFraction: sdk.ZeroDec()})
528
+ keeper.SetParams(ctx, types.Params{PerEpochRewardFraction: sdk.ZeroDec(), AllowedMonitoringAccounts: []string{"*"}})
528
529
  msgsSent := []string{}
529
530
  keeper.PushAction = func(ctx sdk.Context, action vm.Action) error {
530
531
  bz, err := json.Marshal(action)
@@ -804,15 +805,19 @@ func Test_Module_Account(t *testing.T) {
804
805
  }
805
806
 
806
807
  modAddr := sdk.MustAccAddressFromBech32(moduleBech32)
807
- if !keeper.IsModuleAccount(ctx, modAddr) {
808
- t.Errorf("got IsModuleAccount modAddr = false, want true")
808
+ if keeper.IsAllowedMonitoringAccount(ctx, modAddr) {
809
+ t.Errorf("got IsAllowedMonitoringAccount modAddr = true, want false")
810
+ }
811
+ provisionPool := authtypes.NewModuleAddress("vbank/provision")
812
+ if !keeper.IsAllowedMonitoringAccount(ctx, provisionPool) {
813
+ t.Errorf("got IsAllowedMonitoringAccount provisionPool = false, want true")
809
814
  }
810
815
  notModAddr := sdk.MustAccAddressFromBech32(addr1)
811
- if keeper.IsModuleAccount(ctx, notModAddr) {
812
- t.Errorf("got IsModuleAccount notModAddr = true, want false")
816
+ if keeper.IsAllowedMonitoringAccount(ctx, notModAddr) {
817
+ t.Errorf("got IsAllowedMonitoringAccount notModAddr = true, want false")
813
818
  }
814
819
  missingAddr := sdk.MustAccAddressFromBech32(addr2)
815
- if keeper.IsModuleAccount(ctx, missingAddr) {
816
- t.Errorf("got IsModuleAccount missingAddr = false, want true")
820
+ if keeper.IsAllowedMonitoringAccount(ctx, missingAddr) {
821
+ t.Errorf("got IsAllowedMonitoringAccount missingAddr = false, want true")
817
822
  }
818
823
  }
@@ -8,11 +8,12 @@ import (
8
8
  )
9
9
 
10
10
  func GetQueueItems(ctx sdk.Context, vstorageKeeper keeper.Keeper, queuePath string) ([]string, error) {
11
- head, err := vstorageKeeper.GetIntValue(ctx, queuePath+".head")
11
+ unlimitedCtx := ctx.WithGasMeter(sdk.NewInfiniteGasMeter())
12
+ head, err := vstorageKeeper.GetIntValue(unlimitedCtx, queuePath+".head")
12
13
  if err != nil {
13
14
  return nil, err
14
15
  }
15
- tail, err := vstorageKeeper.GetIntValue(ctx, queuePath+".tail")
16
+ tail, err := vstorageKeeper.GetIntValue(unlimitedCtx, queuePath+".tail")
16
17
  if err != nil {
17
18
  return nil, err
18
19
  }
@@ -21,7 +22,7 @@ func GetQueueItems(ctx sdk.Context, vstorageKeeper keeper.Keeper, queuePath stri
21
22
  var i int64
22
23
  for i = 0; i < length; i++ {
23
24
  path := fmt.Sprintf("%s.%s", queuePath, head.Add(sdk.NewInt(i)).String())
24
- values[i] = vstorageKeeper.GetEntry(ctx, path).StringValue()
25
+ values[i] = vstorageKeeper.GetEntry(unlimitedCtx, path).StringValue()
25
26
  }
26
27
  return values, nil
27
28
  }
@@ -16,6 +16,7 @@ import (
16
16
  "github.com/tendermint/tendermint/libs/log"
17
17
  dbm "github.com/tendermint/tm-db"
18
18
 
19
+ "github.com/Agoric/agoric-sdk/golang/cosmos/types"
19
20
  swingsettesting "github.com/Agoric/agoric-sdk/golang/cosmos/x/swingset/testing"
20
21
  swingsettypes "github.com/Agoric/agoric-sdk/golang/cosmos/x/swingset/types"
21
22
  vibckeeper "github.com/Agoric/agoric-sdk/golang/cosmos/x/vibc/keeper"
@@ -331,18 +332,21 @@ func (s *IntegrationTestSuite) TestTransferFromAgdToAgd() {
331
332
 
332
333
  s.Run("TransferFromAgdToAgd", func() {
333
334
  // create a transfer packet's data contents
335
+ baseReceiver := s.chainB.SenderAccounts[1].SenderAccount.GetAddress().String()
336
+ receiverHook, err := types.JoinHookedAddress(baseReceiver, []byte("?what=arbitrary-data&why=to-test-bridge-targets"))
337
+ s.Require().NoError(err)
334
338
  transferData := ibctransfertypes.NewFungibleTokenPacketData(
335
339
  "uosmo",
336
340
  "1000000",
337
341
  s.chainA.SenderAccount.GetAddress().String(),
338
- s.chainB.SenderAccounts[1].SenderAccount.GetAddress().String(),
342
+ receiverHook,
339
343
  `"This is a JSON memo"`,
340
344
  )
341
345
 
342
346
  // Register the sender and receiver as bridge targets on their specific
343
347
  // chain.
344
348
  s.RegisterBridgeTarget(s.chainA, transferData.Sender)
345
- s.RegisterBridgeTarget(s.chainB, transferData.Receiver)
349
+ s.RegisterBridgeTarget(s.chainB, baseReceiver)
346
350
 
347
351
  s.mintToAddress(s.chainA, s.chainA.SenderAccount.GetAddress(), transferData.Denom, transferData.Amount)
348
352
 
@@ -384,7 +388,7 @@ func (s *IntegrationTestSuite) TestTransferFromAgdToAgd() {
384
388
  BlockTime: writeAcknowledgementTime,
385
389
  },
386
390
  Event: "writeAcknowledgement",
387
- Target: transferData.Receiver,
391
+ Target: baseReceiver,
388
392
  Packet: packet,
389
393
  Acknowledgement: ack.Acknowledgement(),
390
394
  },
@@ -13,10 +13,11 @@ import (
13
13
  capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper"
14
14
  capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types"
15
15
 
16
+ "github.com/Agoric/agoric-sdk/golang/cosmos/types"
16
17
  "github.com/Agoric/agoric-sdk/golang/cosmos/vm"
17
18
  "github.com/Agoric/agoric-sdk/golang/cosmos/x/vibc"
18
19
  vibctypes "github.com/Agoric/agoric-sdk/golang/cosmos/x/vibc/types"
19
- transfertypes "github.com/cosmos/ibc-go/v6/modules/apps/transfer/types"
20
+
20
21
  channeltypes "github.com/cosmos/ibc-go/v6/modules/core/04-channel/types"
21
22
  porttypes "github.com/cosmos/ibc-go/v6/modules/core/05-port/types"
22
23
  host "github.com/cosmos/ibc-go/v6/modules/core/24-host"
@@ -106,7 +107,13 @@ func (k Keeper) GetReceiverImpl() vibctypes.ReceiverImpl {
106
107
  // to tell the IBC system that acknowledgment is async (i.e., that WriteAcknowledgement
107
108
  // will be called later, after the VM has dealt with the packet).
108
109
  func (k Keeper) InterceptOnRecvPacket(ctx sdk.Context, ibcModule porttypes.IBCModule, packet channeltypes.Packet, relayer sdk.AccAddress) ibcexported.Acknowledgement {
109
- ack := ibcModule.OnRecvPacket(ctx, packet, relayer)
110
+ // Pass every (stripped-receiver) inbound packet to the wrapped IBC module.
111
+ var strippedPacket channeltypes.Packet
112
+ _, err := types.ExtractBaseAddressFromPacket(k.cdc, packet, types.RoleReceiver, &strippedPacket)
113
+ if err != nil {
114
+ return channeltypes.NewErrorAcknowledgement(err)
115
+ }
116
+ ack := ibcModule.OnRecvPacket(ctx, strippedPacket, relayer)
110
117
 
111
118
  if ack == nil {
112
119
  // Already declared to be an async ack.
@@ -136,17 +143,21 @@ func (k Keeper) InterceptOnAcknowledgementPacket(
136
143
  acknowledgement []byte,
137
144
  relayer sdk.AccAddress,
138
145
  ) error {
139
- // Pass every acknowledgement to the wrapped IBC module.
140
- modErr := ibcModule.OnAcknowledgementPacket(ctx, packet, acknowledgement, relayer)
146
+ // Pass every (stripped-sender) acknowledgement to the wrapped IBC module.
147
+ var strippedPacket channeltypes.Packet
148
+ baseSender, err := types.ExtractBaseAddressFromPacket(k.cdc, packet, types.RoleSender, &strippedPacket)
149
+ if err != nil {
150
+ return err
151
+ }
152
+ modErr := ibcModule.OnAcknowledgementPacket(ctx, strippedPacket, acknowledgement, relayer)
141
153
 
142
- // If the sender is not a targeted account, we're done.
143
- sender, _, err := k.parseTransfer(ctx, packet)
144
- if err != nil || sender == "" {
154
+ // If the sender is not a watched account, we're done.
155
+ if !k.targetIsWatched(ctx, baseSender) {
145
156
  return modErr
146
157
  }
147
158
 
148
- // Trigger VM, regardless of errors in the ibcModule.
149
- vmErr := k.vibcKeeper.TriggerOnAcknowledgementPacket(ctx, sender, packet, acknowledgement, relayer)
159
+ // Trigger VM with the original packet, regardless of errors in the ibcModule.
160
+ vmErr := k.vibcKeeper.TriggerOnAcknowledgementPacket(ctx, baseSender, packet, acknowledgement, relayer)
150
161
 
151
162
  // Any error from the VM is trumped by one from the wrapped IBC module.
152
163
  if modErr != nil {
@@ -163,17 +174,21 @@ func (k Keeper) InterceptOnTimeoutPacket(
163
174
  packet channeltypes.Packet,
164
175
  relayer sdk.AccAddress,
165
176
  ) error {
166
- // Pass every timeout to the wrapped IBC module.
167
- modErr := ibcModule.OnTimeoutPacket(ctx, packet, relayer)
177
+ // Pass every (stripped-sender) timeout to the wrapped IBC module.
178
+ var strippedPacket channeltypes.Packet
179
+ baseSender, err := types.ExtractBaseAddressFromPacket(k.cdc, packet, types.RoleSender, &strippedPacket)
180
+ if err != nil {
181
+ return err
182
+ }
183
+ modErr := ibcModule.OnTimeoutPacket(ctx, strippedPacket, relayer)
168
184
 
169
- // If the sender is not a targeted account, we're done.
170
- sender, _, err := k.parseTransfer(ctx, packet)
171
- if err != nil || sender == "" {
185
+ // If the sender is not a watched account, we're done.
186
+ if !k.targetIsWatched(ctx, baseSender) {
172
187
  return modErr
173
188
  }
174
189
 
175
- // Trigger VM, regardless of errors in the app.
176
- vmErr := k.vibcKeeper.TriggerOnTimeoutPacket(ctx, sender, packet, relayer)
190
+ // Trigger VM with the original packet, regardless of errors in the app.
191
+ vmErr := k.vibcKeeper.TriggerOnTimeoutPacket(ctx, baseSender, packet, relayer)
177
192
 
178
193
  // Any error from the VM is trumped by one from the wrapped IBC module.
179
194
  if modErr != nil {
@@ -185,14 +200,15 @@ func (k Keeper) InterceptOnTimeoutPacket(
185
200
  // InterceptWriteAcknowledgement checks to see if the packet's receiver is a
186
201
  // targeted account, and if so, delegates to the VM.
187
202
  func (k Keeper) InterceptWriteAcknowledgement(ctx sdk.Context, chanCap *capabilitytypes.Capability, packet ibcexported.PacketI, ack ibcexported.Acknowledgement) error {
188
- _, receiver, err := k.parseTransfer(ctx, packet)
189
- if err != nil || receiver == "" {
190
- // We can't parse, but that means just to ack directly.
203
+ // Get the base baseReceiver from the packet, without computing a stripped packet.
204
+ baseReceiver, err := types.ExtractBaseAddressFromPacket(k.cdc, packet, types.RoleReceiver, nil)
205
+ if err != nil || !k.targetIsWatched(ctx, baseReceiver) {
206
+ // We can't parse, or not watching, but that means just to ack directly.
191
207
  return k.WriteAcknowledgement(ctx, chanCap, packet, ack)
192
208
  }
193
209
 
194
- // Trigger VM
195
- if err = k.vibcKeeper.TriggerWriteAcknowledgement(ctx, receiver, packet, ack); err != nil {
210
+ // Trigger VM with the original packet.
211
+ if err = k.vibcKeeper.TriggerWriteAcknowledgement(ctx, baseReceiver, packet, ack); err != nil {
196
212
  errAck := channeltypes.NewErrorAcknowledgement(err)
197
213
  return k.WriteAcknowledgement(ctx, chanCap, packet, errAck)
198
214
  }
@@ -200,27 +216,13 @@ func (k Keeper) InterceptWriteAcknowledgement(ctx sdk.Context, chanCap *capabili
200
216
  return nil
201
217
  }
202
218
 
203
- // parseTransfer checks if a packet's sender and/or receiver are targeted accounts.
204
- func (k Keeper) parseTransfer(ctx sdk.Context, packet ibcexported.PacketI) (string, string, error) {
205
- var transferData transfertypes.FungibleTokenPacketData
206
- err := k.cdc.UnmarshalJSON(packet.GetData(), &transferData)
207
- if err != nil {
208
- return "", "", err
209
- }
210
-
211
- var sender string
212
- var receiver string
219
+ // targetIsWatched checks if a target address has been watched by the VM.
220
+ func (k Keeper) targetIsWatched(ctx sdk.Context, target string) bool {
213
221
  prefixStore := prefix.NewStore(
214
222
  ctx.KVStore(k.key),
215
223
  []byte(watchedAddressStoreKeyPrefix),
216
224
  )
217
- if prefixStore.Has([]byte(transferData.Sender)) {
218
- sender = transferData.Sender
219
- }
220
- if prefixStore.Has([]byte(transferData.Receiver)) {
221
- receiver = transferData.Receiver
222
- }
223
- return sender, receiver, nil
225
+ return prefixStore.Has([]byte(target))
224
226
  }
225
227
 
226
228
  // GetWatchedAdresses returns the watched addresses from the keeper as a slice
@@ -26,6 +26,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
26
26
 
27
27
  // The initial and exported module state.
28
28
  type GenesisState struct {
29
+ // The list of account addresses that are being watched by the VM.
29
30
  WatchedAddresses []github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,1,rep,name=watched_addresses,json=watchedAddresses,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"watched_addresses" yaml:"watched_addresses"`
30
31
  }
31
32