@agoric/cosmos 0.35.0-u18.4 → 0.35.0-u18a.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +40 -0
- package/ante/inbound_test.go +2 -2
- package/app/app.go +26 -9
- package/app/upgrade.go +47 -134
- package/daemon/cmd/root.go +48 -15
- package/git-revision.txt +1 -1
- package/go.mod +82 -71
- package/go.sum +200 -167
- package/package.json +2 -2
- package/proto/agoric/swingset/swingset.proto +25 -0
- package/proto/agoric/vbank/vbank.proto +7 -0
- package/types/address_hooks.go +242 -0
- package/types/address_hooks_test.go +221 -0
- package/x/swingset/genesis.go +99 -21
- package/x/swingset/keeper/keeper.go +16 -7
- package/x/swingset/module.go +17 -2
- package/x/swingset/testing/queue.go +8 -0
- package/x/swingset/types/default-params.go +31 -5
- package/x/swingset/types/expected_keepers.go +2 -2
- package/x/swingset/types/msgs.go +34 -12
- package/x/swingset/types/params.go +53 -43
- package/x/swingset/types/params_test.go +75 -9
- package/x/swingset/types/swingset.pb.go +386 -56
- package/x/vbank/README.md +6 -1
- package/x/vbank/keeper/keeper.go +4 -9
- package/x/vbank/keeper/migrations.go +30 -0
- package/x/vbank/module.go +8 -2
- package/x/vbank/types/params.go +43 -2
- package/x/vbank/types/vbank.pb.go +105 -36
- package/x/vbank/vbank_test.go +12 -7
- package/x/vibc/keeper/keeper.go +2 -5
- package/x/vibc/keeper/triggers.go +3 -6
- package/x/vibc/types/receiver.go +11 -5
- package/x/vstorage/testing/queue.go +10 -3
- package/x/vtransfer/ibc_middleware.go +5 -1
- package/x/vtransfer/ibc_middleware_test.go +511 -145
- package/x/vtransfer/keeper/keeper.go +215 -50
- package/x/vtransfer/types/genesis.pb.go +1 -0
- package/x/vtransfer/utils_test.go +111 -0
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
|
|
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.
|
|
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
|
package/x/vbank/types/params.go
CHANGED
|
@@ -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
|
|
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
|
-
//
|
|
174
|
-
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94,
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
0x20,
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
0x72,
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
0x62,
|
|
207
|
-
|
|
208
|
-
|
|
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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, 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:])
|
package/x/vbank/vbank_test.go
CHANGED
|
@@ -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
|
|
808
|
-
t.Errorf("got
|
|
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.
|
|
812
|
-
t.Errorf("got
|
|
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.
|
|
816
|
-
t.Errorf("got
|
|
820
|
+
if keeper.IsAllowedMonitoringAccount(ctx, missingAddr) {
|
|
821
|
+
t.Errorf("got IsAllowedMonitoringAccount missingAddr = false, want true")
|
|
817
822
|
}
|
|
818
823
|
}
|
package/x/vibc/keeper/keeper.go
CHANGED
|
@@ -113,10 +113,7 @@ func (k Keeper) ReceiveChanOpenInit(ctx sdk.Context, order channeltypes.Order, c
|
|
|
113
113
|
func (k Keeper) ReceiveSendPacket(ctx sdk.Context, packet ibcexported.PacketI) (uint64, error) {
|
|
114
114
|
sourcePort := packet.GetSourcePort()
|
|
115
115
|
sourceChannel := packet.GetSourceChannel()
|
|
116
|
-
timeoutHeight := packet.GetTimeoutHeight()
|
|
117
|
-
timeoutRevisionNumber := timeoutHeight.GetRevisionNumber()
|
|
118
|
-
timeoutRevisionHeight := timeoutHeight.GetRevisionHeight()
|
|
119
|
-
clientTimeoutHeight := clienttypes.NewHeight(timeoutRevisionNumber, timeoutRevisionHeight)
|
|
116
|
+
timeoutHeight := clienttypes.MustParseHeight(packet.GetTimeoutHeight().String())
|
|
120
117
|
timeoutTimestamp := packet.GetTimeoutTimestamp()
|
|
121
118
|
data := packet.GetData()
|
|
122
119
|
|
|
@@ -125,7 +122,7 @@ func (k Keeper) ReceiveSendPacket(ctx sdk.Context, packet ibcexported.PacketI) (
|
|
|
125
122
|
if !ok {
|
|
126
123
|
return 0, sdkioerrors.Wrapf(channeltypes.ErrChannelCapabilityNotFound, "could not retrieve channel capability at: %s", capName)
|
|
127
124
|
}
|
|
128
|
-
return k.SendPacket(ctx, chanCap, sourcePort, sourceChannel,
|
|
125
|
+
return k.SendPacket(ctx, chanCap, sourcePort, sourceChannel, timeoutHeight, timeoutTimestamp, data)
|
|
129
126
|
}
|
|
130
127
|
|
|
131
128
|
// SendPacket defines a wrapper function for the channel Keeper's function
|
|
@@ -12,11 +12,8 @@ import (
|
|
|
12
12
|
)
|
|
13
13
|
|
|
14
14
|
func reifyPacket(packet ibcexported.PacketI) channeltypes.Packet {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
RevisionHeight: height.GetRevisionHeight(),
|
|
18
|
-
RevisionNumber: height.GetRevisionNumber(),
|
|
19
|
-
}
|
|
15
|
+
|
|
16
|
+
timeoutHeight := clienttypes.MustParseHeight(packet.GetTimeoutHeight().String())
|
|
20
17
|
return channeltypes.Packet{
|
|
21
18
|
Sequence: packet.GetSequence(),
|
|
22
19
|
SourcePort: packet.GetSourcePort(),
|
|
@@ -24,7 +21,7 @@ func reifyPacket(packet ibcexported.PacketI) channeltypes.Packet {
|
|
|
24
21
|
DestinationPort: packet.GetDestPort(),
|
|
25
22
|
DestinationChannel: packet.GetDestChannel(),
|
|
26
23
|
Data: packet.GetData(),
|
|
27
|
-
TimeoutHeight:
|
|
24
|
+
TimeoutHeight: timeoutHeight,
|
|
28
25
|
TimeoutTimestamp: packet.GetTimeoutTimestamp(),
|
|
29
26
|
}
|
|
30
27
|
}
|
package/x/vibc/types/receiver.go
CHANGED
|
@@ -15,7 +15,7 @@ import (
|
|
|
15
15
|
|
|
16
16
|
var (
|
|
17
17
|
_ vm.PortHandler = (*Receiver)(nil)
|
|
18
|
-
_ exported.Acknowledgement = (*
|
|
18
|
+
_ exported.Acknowledgement = (*RawAcknowledgement)(nil)
|
|
19
19
|
)
|
|
20
20
|
|
|
21
21
|
type ReceiverImpl interface {
|
|
@@ -71,15 +71,21 @@ func orderToString(order channeltypes.Order) string {
|
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
type
|
|
74
|
+
type RawAcknowledgement struct {
|
|
75
75
|
data []byte
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
func (
|
|
78
|
+
func NewRawAcknowledgement(data []byte) RawAcknowledgement {
|
|
79
|
+
return RawAcknowledgement{
|
|
80
|
+
data: data,
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
func (r RawAcknowledgement) Acknowledgement() []byte {
|
|
79
85
|
return r.data
|
|
80
86
|
}
|
|
81
87
|
|
|
82
|
-
func (r
|
|
88
|
+
func (r RawAcknowledgement) Success() bool {
|
|
83
89
|
return true
|
|
84
90
|
}
|
|
85
91
|
|
|
@@ -137,7 +143,7 @@ func (ir Receiver) Receive(cctx context.Context, jsonRequest string) (jsonReply
|
|
|
137
143
|
)
|
|
138
144
|
|
|
139
145
|
case "receiveExecuted":
|
|
140
|
-
ack :=
|
|
146
|
+
ack := RawAcknowledgement{
|
|
141
147
|
data: msg.Ack,
|
|
142
148
|
}
|
|
143
149
|
err = impl.ReceiveWriteAcknowledgement(ctx, msg.Packet, ack)
|
|
@@ -8,11 +8,12 @@ import (
|
|
|
8
8
|
)
|
|
9
9
|
|
|
10
10
|
func GetQueueItems(ctx sdk.Context, vstorageKeeper keeper.Keeper, queuePath string) ([]string, error) {
|
|
11
|
-
|
|
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(
|
|
16
|
+
tail, err := vstorageKeeper.GetIntValue(unlimitedCtx, queuePath+".tail")
|
|
16
17
|
if err != nil {
|
|
17
18
|
return nil, err
|
|
18
19
|
}
|
|
@@ -21,7 +22,13 @@ 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(
|
|
25
|
+
values[i] = vstorageKeeper.GetEntry(unlimitedCtx, path).StringValue()
|
|
25
26
|
}
|
|
26
27
|
return values, nil
|
|
27
28
|
}
|
|
29
|
+
|
|
30
|
+
func ResetQueue(ctx sdk.Context, vstorageKeeper keeper.Keeper, queuePath string) error {
|
|
31
|
+
unlimitedCtx := ctx.WithGasMeter(sdk.NewInfiniteGasMeter())
|
|
32
|
+
vstorageKeeper.RemoveEntriesWithPrefix(unlimitedCtx, queuePath)
|
|
33
|
+
return nil
|
|
34
|
+
}
|
|
@@ -160,7 +160,11 @@ func (im IBCMiddleware) WriteAcknowledgement(
|
|
|
160
160
|
packet exported.PacketI,
|
|
161
161
|
ack exported.Acknowledgement,
|
|
162
162
|
) error {
|
|
163
|
-
|
|
163
|
+
syncAck, origPacket := im.vtransferKeeper.InterceptWriteAcknowledgement(ctx, chanCap, packet, ack)
|
|
164
|
+
if syncAck != nil {
|
|
165
|
+
return im.vtransferKeeper.WriteAcknowledgement(ctx, chanCap, origPacket, syncAck)
|
|
166
|
+
}
|
|
167
|
+
return nil
|
|
164
168
|
}
|
|
165
169
|
|
|
166
170
|
///////////////////////////////////
|