@agoric/cosmos 0.35.0-u19.2 → 0.35.0-u20.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 +6 -18
- package/app/app.go +1 -1
- package/app/upgrade.go +38 -93
- package/app/upgrade_test.go +63 -0
- package/git-revision.txt +1 -1
- package/package.json +2 -2
- package/types/address_hooks.go +3 -10
- package/types/address_hooks_test.go +31 -31
- package/types/codec.go +23 -0
- package/types/ibc_packet.go +64 -0
- package/types/ibc_packet_test.go +117 -0
- package/x/vibc/keeper/triggers.go +5 -31
- package/x/vibc/types/expected_keepers.go +1 -0
- package/x/vibc/types/ibc_module.go +26 -16
- package/x/vibc/types/receiver.go +15 -15
- package/x/vstorage/README.md +0 -8
- package/x/vstorage/keeper/keeper.go +38 -4
- package/x/vstorage/types/path_keys.go +7 -8
- package/x/vtransfer/handler.go +4 -2
- package/x/vtransfer/ibc_middleware_test.go +4 -5
- package/x/vtransfer/keeper/keeper.go +33 -43
- package/e2e_test/Makefile +0 -29
- package/e2e_test/README.md +0 -100
- package/e2e_test/go.mod +0 -239
- package/e2e_test/go.sum +0 -1323
- package/e2e_test/ibc_conformance_test.go +0 -56
- package/e2e_test/pfm_test.go +0 -613
- package/e2e_test/util.go +0 -271
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
package types_test
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"bytes"
|
|
5
|
+
"encoding/json"
|
|
6
|
+
fmt "fmt"
|
|
7
|
+
"reflect"
|
|
8
|
+
"testing"
|
|
9
|
+
|
|
10
|
+
agtypes "github.com/Agoric/agoric-sdk/golang/cosmos/types"
|
|
11
|
+
"github.com/stretchr/testify/assert"
|
|
12
|
+
"github.com/stretchr/testify/require"
|
|
13
|
+
|
|
14
|
+
clienttypes "github.com/cosmos/ibc-go/v6/modules/core/02-client/types"
|
|
15
|
+
channeltypes "github.com/cosmos/ibc-go/v6/modules/core/04-channel/types"
|
|
16
|
+
ibcexported "github.com/cosmos/ibc-go/v6/modules/core/exported"
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
func CreateTestChannelPacket() channeltypes.Packet {
|
|
20
|
+
return channeltypes.NewPacket(
|
|
21
|
+
[]byte("data"),
|
|
22
|
+
987654321098765432,
|
|
23
|
+
"port-src", "channel-13",
|
|
24
|
+
"port-dst", "channel-42",
|
|
25
|
+
clienttypes.Height{},
|
|
26
|
+
123456789012345678,
|
|
27
|
+
)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
func TestPacket(t *testing.T) {
|
|
31
|
+
testCases := []struct {
|
|
32
|
+
name string
|
|
33
|
+
packet ibcexported.PacketI
|
|
34
|
+
}{
|
|
35
|
+
{
|
|
36
|
+
name: "ibc-go channel Packet",
|
|
37
|
+
packet: CreateTestChannelPacket(),
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
name: "agoric-sdk IBCPacket",
|
|
41
|
+
packet: agtypes.CopyToIBCPacket(CreateTestChannelPacket()),
|
|
42
|
+
},
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Check that the packets have the expected values
|
|
46
|
+
for _, tc := range testCases {
|
|
47
|
+
t.Run(tc.name, func(t *testing.T) {
|
|
48
|
+
pi := tc.packet
|
|
49
|
+
assert.Equal(t, "port-src", pi.GetSourcePort())
|
|
50
|
+
assert.Equal(t, "channel-13", pi.GetSourceChannel())
|
|
51
|
+
assert.Equal(t, "port-dst", pi.GetDestPort())
|
|
52
|
+
assert.Equal(t, "channel-42", pi.GetDestChannel())
|
|
53
|
+
assert.Equal(t, uint64(987654321098765432), pi.GetSequence())
|
|
54
|
+
assert.Equal(t, uint64(123456789012345678), pi.GetTimeoutTimestamp())
|
|
55
|
+
assert.Equal(t, []byte("data"), pi.GetData())
|
|
56
|
+
assert.Equal(t, clienttypes.Height{}, pi.GetTimeoutHeight())
|
|
57
|
+
})
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
func TestPacketJSON(t *testing.T) {
|
|
62
|
+
testCases := []struct {
|
|
63
|
+
name string
|
|
64
|
+
packet ibcexported.PacketI
|
|
65
|
+
quoted bool
|
|
66
|
+
}{
|
|
67
|
+
{
|
|
68
|
+
name: "ibc-go channel Packet",
|
|
69
|
+
packet: CreateTestChannelPacket(),
|
|
70
|
+
quoted: false,
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
name: "agoric-sdk IBCPacket",
|
|
74
|
+
packet: agtypes.CopyToIBCPacket(CreateTestChannelPacket()),
|
|
75
|
+
quoted: true,
|
|
76
|
+
},
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
for _, tc := range testCases {
|
|
80
|
+
t.Run(tc.name, func(t *testing.T) {
|
|
81
|
+
bz, err := json.Marshal(tc.packet)
|
|
82
|
+
require.NoError(t, err)
|
|
83
|
+
|
|
84
|
+
seqStr := fmt.Sprintf("%d", tc.packet.GetSequence())
|
|
85
|
+
if !bytes.Contains(bz, []byte(seqStr)) {
|
|
86
|
+
assert.Failf(t, "packet sequence should be present in JSON", "sequence %s, json %s", seqStr, string(bz))
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if bytes.Contains(bz, []byte(`"`+seqStr+`"`)) != tc.quoted {
|
|
90
|
+
if tc.quoted {
|
|
91
|
+
assert.Failf(t, "packet sequence should be quoted in JSON", "sequence %s, json %s", seqStr, string(bz))
|
|
92
|
+
} else {
|
|
93
|
+
assert.Failf(t, "packet sequence should not be quoted in JSON", "sequence %s, json %s", seqStr, string(bz))
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
var packet2 ibcexported.PacketI
|
|
98
|
+
switch p := tc.packet.(type) {
|
|
99
|
+
case channeltypes.Packet:
|
|
100
|
+
var p2 channeltypes.Packet
|
|
101
|
+
err = json.Unmarshal(bz, &p2)
|
|
102
|
+
packet2 = p2
|
|
103
|
+
case agtypes.IBCPacket:
|
|
104
|
+
var p2 agtypes.IBCPacket
|
|
105
|
+
err = json.Unmarshal(bz, &p2)
|
|
106
|
+
packet2 = p2
|
|
107
|
+
default:
|
|
108
|
+
t.Fatalf("unexpected packet type %T", p)
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
require.NoError(t, err)
|
|
112
|
+
if !reflect.DeepEqual(tc.packet, packet2) {
|
|
113
|
+
assert.Failf(t, "nested packet not equal after JSON round trip", "src %q, dst %q", tc.packet, packet2)
|
|
114
|
+
}
|
|
115
|
+
})
|
|
116
|
+
}
|
|
117
|
+
}
|
|
@@ -3,47 +3,21 @@ package keeper
|
|
|
3
3
|
import (
|
|
4
4
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
5
5
|
|
|
6
|
-
clienttypes "github.com/cosmos/ibc-go/v6/modules/core/02-client/types"
|
|
7
|
-
channeltypes "github.com/cosmos/ibc-go/v6/modules/core/04-channel/types"
|
|
8
6
|
ibcexported "github.com/cosmos/ibc-go/v6/modules/core/exported"
|
|
9
7
|
|
|
10
|
-
"github.com/Agoric/agoric-sdk/golang/cosmos/
|
|
8
|
+
agtypes "github.com/Agoric/agoric-sdk/golang/cosmos/types"
|
|
11
9
|
"github.com/Agoric/agoric-sdk/golang/cosmos/x/vibc/types"
|
|
12
10
|
)
|
|
13
11
|
|
|
14
|
-
func reifyPacket(packet ibcexported.PacketI) channeltypes.Packet {
|
|
15
|
-
|
|
16
|
-
timeoutHeight := clienttypes.MustParseHeight(packet.GetTimeoutHeight().String())
|
|
17
|
-
return channeltypes.Packet{
|
|
18
|
-
Sequence: packet.GetSequence(),
|
|
19
|
-
SourcePort: packet.GetSourcePort(),
|
|
20
|
-
SourceChannel: packet.GetSourceChannel(),
|
|
21
|
-
DestinationPort: packet.GetDestPort(),
|
|
22
|
-
DestinationChannel: packet.GetDestChannel(),
|
|
23
|
-
Data: packet.GetData(),
|
|
24
|
-
TimeoutHeight: timeoutHeight,
|
|
25
|
-
TimeoutTimestamp: packet.GetTimeoutTimestamp(),
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
type WriteAcknowledgementEvent struct {
|
|
30
|
-
*vm.ActionHeader `actionType:"IBC_EVENT"`
|
|
31
|
-
Event string `json:"event" default:"writeAcknowledgement"`
|
|
32
|
-
Target string `json:"target"`
|
|
33
|
-
Packet channeltypes.Packet `json:"packet"`
|
|
34
|
-
Acknowledgement []byte `json:"acknowledgement"`
|
|
35
|
-
Relayer sdk.AccAddress `json:"relayer"`
|
|
36
|
-
}
|
|
37
|
-
|
|
38
12
|
func (k Keeper) TriggerWriteAcknowledgement(
|
|
39
13
|
ctx sdk.Context,
|
|
40
14
|
target string,
|
|
41
15
|
packet ibcexported.PacketI,
|
|
42
16
|
acknowledgement ibcexported.Acknowledgement,
|
|
43
17
|
) error {
|
|
44
|
-
event := WriteAcknowledgementEvent{
|
|
18
|
+
event := types.WriteAcknowledgementEvent{
|
|
45
19
|
Target: target,
|
|
46
|
-
Packet:
|
|
20
|
+
Packet: agtypes.CopyToIBCPacket(packet),
|
|
47
21
|
Acknowledgement: acknowledgement.Acknowledgement(),
|
|
48
22
|
}
|
|
49
23
|
|
|
@@ -64,7 +38,7 @@ func (k Keeper) TriggerOnAcknowledgementPacket(
|
|
|
64
38
|
) error {
|
|
65
39
|
event := types.AcknowledgementPacketEvent{
|
|
66
40
|
Target: target,
|
|
67
|
-
Packet:
|
|
41
|
+
Packet: agtypes.CopyToIBCPacket(packet),
|
|
68
42
|
Acknowledgement: acknowledgement,
|
|
69
43
|
Relayer: relayer,
|
|
70
44
|
}
|
|
@@ -85,7 +59,7 @@ func (k Keeper) TriggerOnTimeoutPacket(
|
|
|
85
59
|
) error {
|
|
86
60
|
event := types.TimeoutPacketEvent{
|
|
87
61
|
Target: target,
|
|
88
|
-
Packet:
|
|
62
|
+
Packet: agtypes.CopyToIBCPacket(packet),
|
|
89
63
|
Relayer: relayer,
|
|
90
64
|
}
|
|
91
65
|
|
|
@@ -33,6 +33,7 @@ type ChannelKeeper interface {
|
|
|
33
33
|
connectionHops []string, counterparty channel.Counterparty, version string)
|
|
34
34
|
WriteOpenTryChannel(ctx sdk.Context, portID, channelID string, order channel.Order,
|
|
35
35
|
connectionHops []string, counterparty channel.Counterparty, version string)
|
|
36
|
+
WriteOpenAckChannel(ctx sdk.Context, portID, channelID, counterpartyVersion, counterpartyChannelID string)
|
|
36
37
|
ChanCloseInit(ctx sdk.Context, portID, channelID string, chanCap *capability.Capability) error
|
|
37
38
|
TimeoutExecuted(ctx sdk.Context, channelCap *capability.Capability, packet ibcexported.PacketI) error
|
|
38
39
|
}
|
|
@@ -4,6 +4,7 @@ import (
|
|
|
4
4
|
fmt "fmt"
|
|
5
5
|
|
|
6
6
|
sdkioerrors "cosmossdk.io/errors"
|
|
7
|
+
agtypes "github.com/Agoric/agoric-sdk/golang/cosmos/types"
|
|
7
8
|
"github.com/Agoric/agoric-sdk/golang/cosmos/vm"
|
|
8
9
|
capability "github.com/cosmos/cosmos-sdk/x/capability/types"
|
|
9
10
|
channeltypes "github.com/cosmos/ibc-go/v6/modules/core/04-channel/types"
|
|
@@ -45,6 +46,15 @@ func NewIBCModule(impl IBCModuleImpl) IBCModule {
|
|
|
45
46
|
}
|
|
46
47
|
}
|
|
47
48
|
|
|
49
|
+
type WriteAcknowledgementEvent struct {
|
|
50
|
+
*vm.ActionHeader `actionType:"IBC_EVENT"`
|
|
51
|
+
Event string `json:"event" default:"writeAcknowledgement"`
|
|
52
|
+
Target string `json:"target"`
|
|
53
|
+
Packet agtypes.IBCPacket `json:"packet"`
|
|
54
|
+
Acknowledgement []byte `json:"acknowledgement"`
|
|
55
|
+
Relayer sdk.AccAddress `json:"relayer"`
|
|
56
|
+
}
|
|
57
|
+
|
|
48
58
|
type ChannelOpenInitEvent struct {
|
|
49
59
|
*vm.ActionHeader `actionType:"IBC_EVENT"`
|
|
50
60
|
Event string `json:"event" default:"channelOpenInit"`
|
|
@@ -253,10 +263,10 @@ func (im IBCModule) OnChanCloseConfirm(
|
|
|
253
263
|
|
|
254
264
|
type ReceivePacketEvent struct {
|
|
255
265
|
*vm.ActionHeader `actionType:"IBC_EVENT"`
|
|
256
|
-
Event string
|
|
257
|
-
Target string
|
|
258
|
-
Packet
|
|
259
|
-
Relayer sdk.AccAddress
|
|
266
|
+
Event string `json:"event" default:"receivePacket"`
|
|
267
|
+
Target string `json:"target,omitempty"`
|
|
268
|
+
Packet agtypes.IBCPacket `json:"packet"`
|
|
269
|
+
Relayer sdk.AccAddress `json:"relayer"`
|
|
260
270
|
}
|
|
261
271
|
|
|
262
272
|
func (im IBCModule) OnRecvPacket(
|
|
@@ -273,7 +283,7 @@ func (im IBCModule) OnRecvPacket(
|
|
|
273
283
|
// the same packets.
|
|
274
284
|
|
|
275
285
|
event := ReceivePacketEvent{
|
|
276
|
-
Packet: packet,
|
|
286
|
+
Packet: agtypes.CopyToIBCPacket(packet),
|
|
277
287
|
Relayer: relayer,
|
|
278
288
|
}
|
|
279
289
|
|
|
@@ -287,11 +297,11 @@ func (im IBCModule) OnRecvPacket(
|
|
|
287
297
|
|
|
288
298
|
type AcknowledgementPacketEvent struct {
|
|
289
299
|
*vm.ActionHeader `actionType:"IBC_EVENT"`
|
|
290
|
-
Event string
|
|
291
|
-
Target string
|
|
292
|
-
Packet
|
|
293
|
-
Acknowledgement []byte
|
|
294
|
-
Relayer sdk.AccAddress
|
|
300
|
+
Event string `json:"event" default:"acknowledgementPacket"`
|
|
301
|
+
Target string `json:"target,omitempty"`
|
|
302
|
+
Packet agtypes.IBCPacket `json:"packet"`
|
|
303
|
+
Acknowledgement []byte `json:"acknowledgement"`
|
|
304
|
+
Relayer sdk.AccAddress `json:"relayer"`
|
|
295
305
|
}
|
|
296
306
|
|
|
297
307
|
func (im IBCModule) OnAcknowledgementPacket(
|
|
@@ -301,7 +311,7 @@ func (im IBCModule) OnAcknowledgementPacket(
|
|
|
301
311
|
relayer sdk.AccAddress,
|
|
302
312
|
) error {
|
|
303
313
|
event := AcknowledgementPacketEvent{
|
|
304
|
-
Packet: packet,
|
|
314
|
+
Packet: agtypes.CopyToIBCPacket(packet),
|
|
305
315
|
Acknowledgement: acknowledgement,
|
|
306
316
|
Relayer: relayer,
|
|
307
317
|
}
|
|
@@ -316,10 +326,10 @@ func (im IBCModule) OnAcknowledgementPacket(
|
|
|
316
326
|
|
|
317
327
|
type TimeoutPacketEvent struct {
|
|
318
328
|
*vm.ActionHeader `actionType:"IBC_EVENT"`
|
|
319
|
-
Event string
|
|
320
|
-
Target string
|
|
321
|
-
Packet
|
|
322
|
-
Relayer sdk.AccAddress
|
|
329
|
+
Event string `json:"event" default:"timeoutPacket"`
|
|
330
|
+
Target string `json:"target,omitempty"`
|
|
331
|
+
Packet agtypes.IBCPacket `json:"packet"`
|
|
332
|
+
Relayer sdk.AccAddress `json:"relayer"`
|
|
323
333
|
}
|
|
324
334
|
|
|
325
335
|
func (im IBCModule) OnTimeoutPacket(
|
|
@@ -328,7 +338,7 @@ func (im IBCModule) OnTimeoutPacket(
|
|
|
328
338
|
relayer sdk.AccAddress,
|
|
329
339
|
) error {
|
|
330
340
|
event := TimeoutPacketEvent{
|
|
331
|
-
Packet: packet,
|
|
341
|
+
Packet: agtypes.CopyToIBCPacket(packet),
|
|
332
342
|
Relayer: relayer,
|
|
333
343
|
}
|
|
334
344
|
|
package/x/vibc/types/receiver.go
CHANGED
|
@@ -5,6 +5,7 @@ import (
|
|
|
5
5
|
"encoding/json"
|
|
6
6
|
"fmt"
|
|
7
7
|
|
|
8
|
+
"github.com/Agoric/agoric-sdk/golang/cosmos/types"
|
|
8
9
|
"github.com/Agoric/agoric-sdk/golang/cosmos/vm"
|
|
9
10
|
channeltypes "github.com/cosmos/ibc-go/v6/modules/core/04-channel/types"
|
|
10
11
|
|
|
@@ -39,14 +40,14 @@ func NewReceiver(impl ReceiverImpl) Receiver {
|
|
|
39
40
|
}
|
|
40
41
|
|
|
41
42
|
type portMessage struct { // comes from swingset's IBC handler
|
|
42
|
-
Type string
|
|
43
|
-
Method string
|
|
44
|
-
Packet
|
|
45
|
-
RelativeTimeoutNs uint64
|
|
46
|
-
Order string
|
|
47
|
-
Hops []string
|
|
48
|
-
Version string
|
|
49
|
-
Ack []byte
|
|
43
|
+
Type string `json:"type"` // IBC_METHOD
|
|
44
|
+
Method string `json:"method"`
|
|
45
|
+
Packet types.IBCPacket `json:"packet"`
|
|
46
|
+
RelativeTimeoutNs uint64 `json:"relativeTimeoutNs,string"`
|
|
47
|
+
Order string `json:"order"`
|
|
48
|
+
Hops []string `json:"hops"`
|
|
49
|
+
Version string `json:"version"`
|
|
50
|
+
Ack []byte `json:"ack"`
|
|
50
51
|
}
|
|
51
52
|
|
|
52
53
|
func stringToOrder(order string) channeltypes.Order {
|
|
@@ -121,21 +122,20 @@ func (ir Receiver) Receive(cctx context.Context, jsonRequest string) (jsonReply
|
|
|
121
122
|
timeoutTimestamp = uint64(ctx.BlockTime().UnixNano()) + msg.RelativeTimeoutNs
|
|
122
123
|
}
|
|
123
124
|
|
|
124
|
-
packet :=
|
|
125
|
-
|
|
126
|
-
msg.Packet.SourcePort, msg.Packet.SourceChannel,
|
|
127
|
-
msg.Packet.DestinationPort, msg.Packet.DestinationChannel,
|
|
128
|
-
msg.Packet.TimeoutHeight, timeoutTimestamp,
|
|
129
|
-
)
|
|
125
|
+
packet := types.CopyToIBCPacket(msg.Packet)
|
|
126
|
+
packet.TimeoutTimestamp = timeoutTimestamp
|
|
130
127
|
seq, err := impl.ReceiveSendPacket(ctx, packet)
|
|
131
128
|
if err == nil {
|
|
132
129
|
packet.Sequence = seq
|
|
133
|
-
bytes, err := json.Marshal(
|
|
130
|
+
bytes, err := json.Marshal(packet)
|
|
134
131
|
if err == nil {
|
|
135
132
|
jsonReply = string(bytes)
|
|
136
133
|
}
|
|
137
134
|
}
|
|
138
135
|
|
|
136
|
+
case "initOpenExecuted":
|
|
137
|
+
err = fmt.Errorf("initOpenExecuted not yet implemented")
|
|
138
|
+
|
|
139
139
|
case "tryOpenExecuted":
|
|
140
140
|
err = impl.ReceiveWriteOpenTryChannel(
|
|
141
141
|
ctx, msg.Packet,
|
package/x/vstorage/README.md
CHANGED
|
@@ -128,11 +128,3 @@ $ curl -sS 'https://main.api.agoric.net/agoric/vstorage/children/published.commi
|
|
|
128
128
|
"pagination": null
|
|
129
129
|
}
|
|
130
130
|
```
|
|
131
|
-
|
|
132
|
-
## Arbitrary-response HTTP interface
|
|
133
|
-
|
|
134
|
-
This depends upon appModule `LegacyQuerierHandler` functionality that is [removed from cosmos-sdk as of v0.47](https://github.com/cosmos/cosmos-sdk/blob/fa4d87ef7e6d87aaccc94c337ffd2fe90fcb7a9d/CHANGELOG.md#api-breaking-changes-3)
|
|
135
|
-
|
|
136
|
-
[legacy querier](./keeper/querier.go)
|
|
137
|
-
* /custom/vstorage/children/$path
|
|
138
|
-
* /custom/vstorage/data/$path
|
|
@@ -11,7 +11,9 @@ import (
|
|
|
11
11
|
"strings"
|
|
12
12
|
|
|
13
13
|
sdkmath "cosmossdk.io/math"
|
|
14
|
+
metrics "github.com/armon/go-metrics"
|
|
14
15
|
storetypes "github.com/cosmos/cosmos-sdk/store/types"
|
|
16
|
+
"github.com/cosmos/cosmos-sdk/telemetry"
|
|
15
17
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
16
18
|
db "github.com/tendermint/tm-db"
|
|
17
19
|
|
|
@@ -117,6 +119,27 @@ func NewKeeper(storeKey storetypes.StoreKey) Keeper {
|
|
|
117
119
|
}
|
|
118
120
|
}
|
|
119
121
|
|
|
122
|
+
// size_increase and size_decrease metrics represent total writes and deletes *issued*
|
|
123
|
+
// respectively, which may differ from the total number of bytes committed/freed
|
|
124
|
+
// to/from the store due to the store's internal implementation.
|
|
125
|
+
var MetricKeyStoreSizeIncrease = []string{"store", "size_increase"}
|
|
126
|
+
var MetricKeyStoreSizeDecrease = []string{"store", "size_decrease"}
|
|
127
|
+
const MetricLabelStoreKey = "storeKey"
|
|
128
|
+
|
|
129
|
+
// reportStoreSizeMetrics exports store size increase/decrease metrics
|
|
130
|
+
// when Cosmos telemetry is enabled.
|
|
131
|
+
func (k Keeper) reportStoreSizeMetrics(increase int, decrease int) {
|
|
132
|
+
metricsLabel := []metrics.Label{
|
|
133
|
+
telemetry.NewLabel(MetricLabelStoreKey, k.storeKey.Name()),
|
|
134
|
+
}
|
|
135
|
+
if increase > 0 {
|
|
136
|
+
telemetry.IncrCounterWithLabels(MetricKeyStoreSizeIncrease, float32(increase), metricsLabel)
|
|
137
|
+
}
|
|
138
|
+
if decrease > 0 {
|
|
139
|
+
telemetry.IncrCounterWithLabels(MetricKeyStoreSizeDecrease, float32(decrease), metricsLabel)
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
120
143
|
// ExportStorage fetches all storage
|
|
121
144
|
func (k Keeper) ExportStorage(ctx sdk.Context) []*types.DataEntry {
|
|
122
145
|
return k.ExportStorageFromPrefix(ctx, "")
|
|
@@ -215,6 +238,8 @@ func (k Keeper) RemoveEntriesWithPrefix(ctx sdk.Context, pathPrefix string) {
|
|
|
215
238
|
keys := getEncodedKeysWithPrefixFromIterator(iterator, descendantPrefix)
|
|
216
239
|
|
|
217
240
|
for _, key := range keys {
|
|
241
|
+
rawValue := store.Get(key)
|
|
242
|
+
k.reportStoreSizeMetrics(0, len(key) + len(rawValue))
|
|
218
243
|
store.Delete(key)
|
|
219
244
|
}
|
|
220
245
|
|
|
@@ -366,18 +391,23 @@ func (k Keeper) SetStorage(ctx sdk.Context, entry agoric.KVEntry) {
|
|
|
366
391
|
store := ctx.KVStore(k.storeKey)
|
|
367
392
|
path := entry.Key()
|
|
368
393
|
encodedKey := types.PathToEncodedKey(path)
|
|
394
|
+
oldRawValue := store.Get(encodedKey)
|
|
369
395
|
|
|
370
396
|
if !entry.HasValue() {
|
|
371
397
|
if !k.HasChildren(ctx, path) {
|
|
372
398
|
// We have no children, can delete.
|
|
399
|
+
k.reportStoreSizeMetrics(0, len(encodedKey) + len(oldRawValue))
|
|
373
400
|
store.Delete(encodedKey)
|
|
374
401
|
} else {
|
|
402
|
+
// We have children, mark as an empty placeholder without deleting.
|
|
403
|
+
k.reportStoreSizeMetrics(len(types.EncodedNoDataValue), len(oldRawValue))
|
|
375
404
|
store.Set(encodedKey, types.EncodedNoDataValue)
|
|
376
405
|
}
|
|
377
406
|
} else {
|
|
378
407
|
// Update the value.
|
|
379
|
-
|
|
380
|
-
|
|
408
|
+
newRawValue := bytes.Join([][]byte{types.EncodedDataPrefix, []byte(entry.StringValue())}, []byte{})
|
|
409
|
+
k.reportStoreSizeMetrics(len(newRawValue), len(oldRawValue))
|
|
410
|
+
store.Set(encodedKey, newRawValue)
|
|
381
411
|
}
|
|
382
412
|
|
|
383
413
|
// Update our other parent children.
|
|
@@ -390,7 +420,9 @@ func (k Keeper) SetStorage(ctx sdk.Context, entry agoric.KVEntry) {
|
|
|
390
420
|
// this and further ancestors are needed, skip out
|
|
391
421
|
break
|
|
392
422
|
}
|
|
393
|
-
|
|
423
|
+
encodedAncestor := types.PathToEncodedKey(ancestor)
|
|
424
|
+
k.reportStoreSizeMetrics(0, len(encodedAncestor) + len(types.EncodedNoDataValue))
|
|
425
|
+
store.Delete(encodedAncestor)
|
|
394
426
|
}
|
|
395
427
|
} else {
|
|
396
428
|
// add placeholders as needed
|
|
@@ -400,7 +432,9 @@ func (k Keeper) SetStorage(ctx sdk.Context, entry agoric.KVEntry) {
|
|
|
400
432
|
// The ancestor exists, implying all further ancestors exist, so we can break.
|
|
401
433
|
break
|
|
402
434
|
}
|
|
403
|
-
|
|
435
|
+
encodedAncestor := types.PathToEncodedKey(ancestor)
|
|
436
|
+
k.reportStoreSizeMetrics(len(encodedAncestor) + len(types.EncodedNoDataValue), 0)
|
|
437
|
+
store.Set(encodedAncestor, types.EncodedNoDataValue)
|
|
404
438
|
}
|
|
405
439
|
}
|
|
406
440
|
}
|
|
@@ -10,14 +10,13 @@ import (
|
|
|
10
10
|
// - A "path" is a sequence of zero or more dot-separated nonempty segments
|
|
11
11
|
// using a restricted alphabet of ASCII alphanumerics plus underscore and dash,
|
|
12
12
|
// consistent with packages/internal/src/lib-chainStorage.js but not currently
|
|
13
|
-
// enforcing a length restriction on path segments.
|
|
14
|
-
//
|
|
15
|
-
// `"
|
|
16
|
-
//
|
|
17
|
-
//
|
|
18
|
-
//
|
|
19
|
-
//
|
|
20
|
-
// be reserved for adding escape sequences).
|
|
13
|
+
// enforcing a length restriction on path segments. So `""`, `"foo"`, and
|
|
14
|
+
// `"foo.bar__baz.qux--quux"` are paths but `"."`, `"foo/bar"`, `"fo\to"`, and
|
|
15
|
+
// `"foö"` are not. This alphabet might be expanded in the future, but such
|
|
16
|
+
// expansion SHOULD NOT include control characters (including those that are not
|
|
17
|
+
// ASCII, such as U+202E RIGHT-TO-LEFT OVERRIDE), slash `/` (which separates
|
|
18
|
+
// ABCI request path segments in e.g. `/agoric.vstorage.Query/Data`), or
|
|
19
|
+
// backslash `\` (which should be reserved for adding escape sequences).
|
|
21
20
|
//
|
|
22
21
|
// - An encoded key for a path is the path prefixed with its length (in ASCII
|
|
23
22
|
// digits), separated by nul, followed by the path with dots replaced with nul.
|
package/x/vtransfer/handler.go
CHANGED
|
@@ -5,7 +5,9 @@ import (
|
|
|
5
5
|
|
|
6
6
|
"github.com/Agoric/agoric-sdk/golang/cosmos/x/vtransfer/keeper"
|
|
7
7
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
8
|
-
|
|
8
|
+
|
|
9
|
+
sdkioerrors "cosmossdk.io/errors"
|
|
10
|
+
sdktypeserrors "github.com/cosmos/cosmos-sdk/types/errors"
|
|
9
11
|
)
|
|
10
12
|
|
|
11
13
|
// NewHandler returns a handler for "vtransfer" type messages.
|
|
@@ -14,7 +16,7 @@ func NewHandler(keeper keeper.Keeper) sdk.Handler {
|
|
|
14
16
|
switch msg := msg.(type) {
|
|
15
17
|
default:
|
|
16
18
|
errMsg := fmt.Sprintf("Unrecognized vtransfer Msg type: %T", msg)
|
|
17
|
-
return nil,
|
|
19
|
+
return nil, sdkioerrors.Wrap(sdktypeserrors.ErrUnknownRequest, errMsg)
|
|
18
20
|
}
|
|
19
21
|
}
|
|
20
22
|
}
|
|
@@ -23,7 +23,6 @@ import (
|
|
|
23
23
|
"github.com/Agoric/agoric-sdk/golang/cosmos/types"
|
|
24
24
|
swingsettesting "github.com/Agoric/agoric-sdk/golang/cosmos/x/swingset/testing"
|
|
25
25
|
swingsettypes "github.com/Agoric/agoric-sdk/golang/cosmos/x/swingset/types"
|
|
26
|
-
vibckeeper "github.com/Agoric/agoric-sdk/golang/cosmos/x/vibc/keeper"
|
|
27
26
|
vibctypes "github.com/Agoric/agoric-sdk/golang/cosmos/x/vibc/types"
|
|
28
27
|
|
|
29
28
|
"github.com/cosmos/cosmos-sdk/baseapp"
|
|
@@ -653,7 +652,7 @@ func (s *IntegrationTestSuite) TestHops() {
|
|
|
653
652
|
expectedRecords := []swingsettypes.InboundQueueRecord{}
|
|
654
653
|
if tc.receiverIsTarget {
|
|
655
654
|
expectedRecords = append(expectedRecords, swingsettypes.InboundQueueRecord{
|
|
656
|
-
Action: &
|
|
655
|
+
Action: &vibctypes.WriteAcknowledgementEvent{
|
|
657
656
|
ActionHeader: &vm.ActionHeader{
|
|
658
657
|
Type: "VTRANSFER_IBC_EVENT",
|
|
659
658
|
BlockHeight: writeAcknowledgementHeight,
|
|
@@ -661,7 +660,7 @@ func (s *IntegrationTestSuite) TestHops() {
|
|
|
661
660
|
},
|
|
662
661
|
Event: "writeAcknowledgement",
|
|
663
662
|
Target: baseReceiver,
|
|
664
|
-
Packet: sendPacket,
|
|
663
|
+
Packet: types.CopyToIBCPacket(sendPacket),
|
|
665
664
|
Acknowledgement: expectedAck.Acknowledgement(),
|
|
666
665
|
},
|
|
667
666
|
Context: swingsettypes.ActionContext{
|
|
@@ -765,7 +764,7 @@ func (s *IntegrationTestSuite) TestHops() {
|
|
|
765
764
|
expectedRecords := []swingsettypes.InboundQueueRecord{}
|
|
766
765
|
if tc.senderIsTarget {
|
|
767
766
|
expectedRecords = append(expectedRecords, swingsettypes.InboundQueueRecord{
|
|
768
|
-
Action: &
|
|
767
|
+
Action: &vibctypes.AcknowledgementPacketEvent{
|
|
769
768
|
ActionHeader: &vm.ActionHeader{
|
|
770
769
|
Type: "VTRANSFER_IBC_EVENT",
|
|
771
770
|
BlockHeight: acknowledgementHeight,
|
|
@@ -773,7 +772,7 @@ func (s *IntegrationTestSuite) TestHops() {
|
|
|
773
772
|
},
|
|
774
773
|
Event: "acknowledgementPacket",
|
|
775
774
|
Target: baseSender,
|
|
776
|
-
Packet: expectedPacket,
|
|
775
|
+
Packet: types.CopyToIBCPacket(expectedPacket),
|
|
777
776
|
Acknowledgement: ack.Acknowledgement(),
|
|
778
777
|
Relayer: s.chainA.SenderAccount.GetAddress(),
|
|
779
778
|
},
|