@agoric/cosmos 0.34.2-upgrade-19-dev-2a71f04.0 → 0.34.2-upgrade-20-dev-31be299.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.
@@ -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/vm"
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: reifyPacket(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: reifyPacket(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: reifyPacket(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 `json:"event" default:"receivePacket"`
257
- Target string `json:"target,omitempty"`
258
- Packet channeltypes.Packet `json:"packet"`
259
- Relayer sdk.AccAddress `json:"relayer"`
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 `json:"event" default:"acknowledgementPacket"`
291
- Target string `json:"target,omitempty"`
292
- Packet channeltypes.Packet `json:"packet"`
293
- Acknowledgement []byte `json:"acknowledgement"`
294
- Relayer sdk.AccAddress `json:"relayer"`
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 `json:"event" default:"timeoutPacket"`
320
- Target string `json:"target,omitempty"`
321
- Packet channeltypes.Packet `json:"packet"`
322
- Relayer sdk.AccAddress `json:"relayer"`
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
 
@@ -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 `json:"type"` // IBC_METHOD
43
- Method string `json:"method"`
44
- Packet channeltypes.Packet `json:"packet"`
45
- RelativeTimeoutNs uint64 `json:"relativeTimeoutNs,string"`
46
- Order string `json:"order"`
47
- Hops []string `json:"hops"`
48
- Version string `json:"version"`
49
- Ack []byte `json:"ack"`
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 := channeltypes.NewPacket(
125
- msg.Packet.Data, 0,
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(&packet)
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,
@@ -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
- bz := bytes.Join([][]byte{types.EncodedDataPrefix, []byte(entry.StringValue())}, []byte{})
380
- store.Set(encodedKey, bz)
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
- store.Delete(types.PathToEncodedKey(ancestor))
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
- store.Set(types.PathToEncodedKey(ancestor), types.EncodedNoDataValue)
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
- // So `""`, `"foo"`, and `"foo.bar__baz.qux--quux"` are paths but `"."`,
15
- // `"foo/bar"`, `"fo\to"`, and `"foö"` are not.
16
- // This alphabet might be expanded in the future, but such expansion SHOULD NOT
17
- // include control characters (including those that are not ASCII, such as
18
- // U+202E RIGHT-TO-LEFT OVERRIDE), slash `/` (which separates ABCI request path
19
- // segments in e.g. `custom/vstorage/data/foo`), or backslash `\` (which should
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.
@@ -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
- sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
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, sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, errMsg)
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: &vibckeeper.WriteAcknowledgementEvent{
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: &vibckeeper.WriteAcknowledgementEvent{
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
  },
@@ -10,12 +10,14 @@ import (
10
10
  "github.com/cosmos/cosmos-sdk/store/prefix"
11
11
  storetypes "github.com/cosmos/cosmos-sdk/store/types"
12
12
  sdk "github.com/cosmos/cosmos-sdk/types"
13
- sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
13
+
14
+ sdkioerrors "cosmossdk.io/errors"
15
+ sdktypeserrors "github.com/cosmos/cosmos-sdk/types/errors"
14
16
 
15
17
  capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper"
16
18
  capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types"
17
19
 
18
- "github.com/Agoric/agoric-sdk/golang/cosmos/types"
20
+ agtypes "github.com/Agoric/agoric-sdk/golang/cosmos/types"
19
21
  "github.com/Agoric/agoric-sdk/golang/cosmos/vm"
20
22
  "github.com/Agoric/agoric-sdk/golang/cosmos/x/vibc"
21
23
  vibctypes "github.com/Agoric/agoric-sdk/golang/cosmos/x/vibc/types"
@@ -92,7 +94,7 @@ func (i4 *ics4Wrapper) SendPacket(
92
94
  }
93
95
 
94
96
  var strippedData []byte
95
- _, err = types.ExtractBaseAddressFromData(i4.k.cdc, data, types.RoleSender, &strippedData)
97
+ _, err = agtypes.ExtractBaseAddressFromData(i4.k.cdc, data, agtypes.RoleSender, &strippedData)
96
98
  if err != nil {
97
99
  return sequence, err
98
100
  }
@@ -105,7 +107,7 @@ func (i4 *ics4Wrapper) SendPacket(
105
107
 
106
108
  // Store the original data if it is hooked for later retrieval by middleware.
107
109
  if !i4.k.debug.DoNotStore && !bytes.Equal(strippedData, data) {
108
- packetStore, packetKey := i4.k.PacketStore(ctx, types.PacketSrc, sourcePort, sourceChannel, sequence)
110
+ packetStore, packetKey := i4.k.PacketStore(ctx, agtypes.PacketSrc, sourcePort, sourceChannel, sequence)
109
111
  packetStore.Set(packetKey, data)
110
112
  }
111
113
 
@@ -118,14 +120,8 @@ func (i4 *ics4Wrapper) WriteAcknowledgement(
118
120
  packet ibcexported.PacketI,
119
121
  ack ibcexported.Acknowledgement,
120
122
  ) error {
121
- origPacket := channeltypes.NewPacket(
122
- packet.GetData(), packet.GetSequence(),
123
- packet.GetSourcePort(), packet.GetSourceChannel(),
124
- packet.GetDestPort(), packet.GetDestChannel(),
125
- clienttypes.MustParseHeight(packet.GetTimeoutHeight().String()),
126
- packet.GetTimeoutTimestamp(),
127
- )
128
- packetStore, packetKey := i4.k.PacketStoreFromOrigin(ctx, types.PacketDst, packet)
123
+ origPacket := agtypes.CopyToIBCPacket(packet)
124
+ packetStore, packetKey := i4.k.PacketStoreFromOrigin(ctx, agtypes.PacketDst, packet)
129
125
  if packetStore.Has(packetKey) {
130
126
  origPacket.Data = packetStore.Get(packetKey)
131
127
  packetStore.Delete(packetKey)
@@ -209,20 +205,20 @@ func sequencePath(sequence uint64) string {
209
205
  // PacketStore returns a new KVStore for storing packet data, and a key for
210
206
  // that store. The KVStore is divided into src or dst PacketOrigins because we
211
207
  // need to record separate data for packets travelling in each direction.
212
- func (k Keeper) PacketStore(ctx sdk.Context, ourOrigin types.PacketOrigin, ourPort string, ourChannel string, sequence uint64) (storetypes.KVStore, []byte) {
208
+ func (k Keeper) PacketStore(ctx sdk.Context, ourOrigin agtypes.PacketOrigin, ourPort string, ourChannel string, sequence uint64) (storetypes.KVStore, []byte) {
213
209
  key := fmt.Sprintf("%s/%s/%s", ourOrigin, channelPath(ourPort, ourChannel), sequencePath(sequence))
214
210
  packetKey := []byte(key)
215
211
  return prefix.NewStore(ctx.KVStore(k.key), []byte(packetDataStoreKeyPrefix)), packetKey
216
212
  }
217
213
 
218
- func (k Keeper) PacketStoreFromOrigin(ctx sdk.Context, ourOrigin types.PacketOrigin, packet ibcexported.PacketI) (storetypes.KVStore, []byte) {
214
+ func (k Keeper) PacketStoreFromOrigin(ctx sdk.Context, ourOrigin agtypes.PacketOrigin, packet ibcexported.PacketI) (storetypes.KVStore, []byte) {
219
215
  var ourPort, ourChannel string
220
216
 
221
217
  switch ourOrigin {
222
- case types.PacketSrc:
218
+ case agtypes.PacketSrc:
223
219
  ourPort = packet.GetSourcePort()
224
220
  ourChannel = packet.GetSourceChannel()
225
- case types.PacketDst:
221
+ case agtypes.PacketDst:
226
222
  ourPort = packet.GetDestPort()
227
223
  ourChannel = packet.GetDestChannel()
228
224
  default:
@@ -236,10 +232,10 @@ func (k Keeper) PacketStoreFromOrigin(ctx sdk.Context, ourOrigin types.PacketOri
236
232
  // Many error acknowledgments are sent synchronously, but most cases instead return nil
237
233
  // to tell the IBC system that acknowledgment is async (i.e., that WriteAcknowledgement
238
234
  // will be called later, after the VM has dealt with the packet).
239
- func (k Keeper) InterceptOnRecvPacket(ctx sdk.Context, ibcModule porttypes.IBCModule, packet channeltypes.Packet, relayer sdk.AccAddress) ibcexported.Acknowledgement {
235
+ func (k Keeper) InterceptOnRecvPacket(ctx sdk.Context, ibcModule porttypes.IBCModule, packet ibcexported.PacketI, relayer sdk.AccAddress) ibcexported.Acknowledgement {
240
236
  // Pass every (stripped-receiver) inbound packet to the wrapped IBC module.
241
- var strippedPacket channeltypes.Packet
242
- _, err := types.ExtractBaseAddressFromPacket(k.cdc, packet, types.RoleReceiver, &strippedPacket)
237
+ var strippedPacket agtypes.IBCPacket
238
+ _, err := agtypes.ExtractBaseAddressFromPacket(k.cdc, packet, agtypes.RoleReceiver, &strippedPacket)
243
239
  if err != nil {
244
240
  return channeltypes.NewErrorAcknowledgement(err)
245
241
  }
@@ -249,16 +245,16 @@ func (k Keeper) InterceptOnRecvPacket(ctx sdk.Context, ibcModule porttypes.IBCMo
249
245
  capName := host.ChannelCapabilityPath(portID, channelID)
250
246
  chanCap, ok := k.vibcKeeper.GetCapability(ctx, capName)
251
247
  if !ok {
252
- err := sdkerrors.Wrapf(channeltypes.ErrChannelCapabilityNotFound, "could not retrieve channel capability at: %s", capName)
248
+ err := sdkioerrors.Wrapf(channeltypes.ErrChannelCapabilityNotFound, "could not retrieve channel capability at: %s", capName)
253
249
  return channeltypes.NewErrorAcknowledgement(err)
254
250
  }
255
251
 
256
252
  if !k.debug.DoNotStore && !bytes.Equal(strippedPacket.GetData(), packet.GetData()) {
257
- packetStore, packetKey := k.PacketStore(ctx, types.PacketDst, portID, channelID, packet.GetSequence())
253
+ packetStore, packetKey := k.PacketStore(ctx, agtypes.PacketDst, portID, channelID, packet.GetSequence())
258
254
  packetStore.Set(packetKey, packet.GetData())
259
255
  }
260
256
 
261
- ack := ibcModule.OnRecvPacket(ctx, strippedPacket, relayer)
257
+ ack := ibcModule.OnRecvPacket(ctx, agtypes.CopyToChannelPacket(strippedPacket), relayer)
262
258
  if ack == nil {
263
259
  // Already declared to be an async ack. Will be cleaned up by ics4Wrapper.WriteAcknowledgement.
264
260
  return nil
@@ -274,23 +270,23 @@ func (k Keeper) InterceptOnRecvPacket(ctx sdk.Context, ibcModule porttypes.IBCMo
274
270
  func (k Keeper) InterceptOnAcknowledgementPacket(
275
271
  ctx sdk.Context,
276
272
  ibcModule porttypes.IBCModule,
277
- packet channeltypes.Packet,
273
+ packet ibcexported.PacketI,
278
274
  acknowledgement []byte,
279
275
  relayer sdk.AccAddress,
280
276
  ) error {
281
- baseSender, err := types.ExtractBaseAddressFromData(k.cdc, packet.GetData(), types.RoleSender, nil)
277
+ baseSender, err := agtypes.ExtractBaseAddressFromData(k.cdc, packet.GetData(), agtypes.RoleSender, nil)
282
278
  if err != nil {
283
279
  return err
284
280
  }
285
281
 
286
- origPacket := packet
287
- packetStore, packetKey := k.PacketStoreFromOrigin(ctx, types.PacketSrc, packet)
282
+ origPacket := agtypes.CopyToIBCPacket(packet)
283
+ packetStore, packetKey := k.PacketStoreFromOrigin(ctx, agtypes.PacketSrc, packet)
288
284
  if packetStore.Has(packetKey) {
289
285
  origPacket.Data = packetStore.Get(packetKey)
290
286
  packetStore.Delete(packetKey)
291
287
  }
292
288
 
293
- modErr := ibcModule.OnAcknowledgementPacket(ctx, packet, acknowledgement, relayer)
289
+ modErr := ibcModule.OnAcknowledgementPacket(ctx, agtypes.CopyToChannelPacket(packet), acknowledgement, relayer)
294
290
 
295
291
  // If the sender is not a watched account, we're done.
296
292
  if !k.targetIsWatched(ctx, baseSender) {
@@ -312,23 +308,23 @@ func (k Keeper) InterceptOnAcknowledgementPacket(
312
308
  func (k Keeper) InterceptOnTimeoutPacket(
313
309
  ctx sdk.Context,
314
310
  ibcModule porttypes.IBCModule,
315
- packet channeltypes.Packet,
311
+ packet ibcexported.PacketI,
316
312
  relayer sdk.AccAddress,
317
313
  ) error {
318
- baseSender, err := types.ExtractBaseAddressFromData(k.cdc, packet.GetData(), types.RoleSender, nil)
314
+ baseSender, err := agtypes.ExtractBaseAddressFromData(k.cdc, packet.GetData(), agtypes.RoleSender, nil)
319
315
  if err != nil {
320
316
  return err
321
317
  }
322
318
 
323
- origPacket := packet
324
- packetStore, packetKey := k.PacketStoreFromOrigin(ctx, types.PacketSrc, packet)
319
+ origPacket := agtypes.CopyToIBCPacket(packet)
320
+ packetStore, packetKey := k.PacketStoreFromOrigin(ctx, agtypes.PacketSrc, packet)
325
321
  if packetStore.Has(packetKey) {
326
322
  origPacket.Data = packetStore.Get(packetKey)
327
323
  packetStore.Delete(packetKey)
328
324
  }
329
325
 
330
326
  // Pass every stripped-sender timeout to the wrapped IBC module.
331
- modErr := ibcModule.OnTimeoutPacket(ctx, packet, relayer)
327
+ modErr := ibcModule.OnTimeoutPacket(ctx, agtypes.CopyToChannelPacket(packet), relayer)
332
328
 
333
329
  // If the sender is not a watched account, we're done.
334
330
  if !k.targetIsWatched(ctx, baseSender) {
@@ -349,16 +345,10 @@ func (k Keeper) InterceptOnTimeoutPacket(
349
345
  // targeted account, and if so, delegates to the VM.
350
346
  func (k Keeper) InterceptWriteAcknowledgement(ctx sdk.Context, chanCap *capabilitytypes.Capability, packet ibcexported.PacketI, ack ibcexported.Acknowledgement) (ibcexported.Acknowledgement, ibcexported.PacketI) {
351
347
  // Get the base receiver from the packet, without computing a stripped packet.
352
- baseReceiver, err := types.ExtractBaseAddressFromPacket(k.cdc, packet, types.RoleReceiver, nil)
353
-
354
- origPacket := channeltypes.NewPacket(
355
- packet.GetData(), packet.GetSequence(),
356
- packet.GetSourcePort(), packet.GetSourceChannel(),
357
- packet.GetDestPort(), packet.GetDestChannel(),
358
- clienttypes.MustParseHeight(packet.GetTimeoutHeight().String()),
359
- packet.GetTimeoutTimestamp(),
360
- )
361
- packetStore, packetKey := k.PacketStoreFromOrigin(ctx, types.PacketDst, packet)
348
+ baseReceiver, err := agtypes.ExtractBaseAddressFromPacket(k.cdc, packet, agtypes.RoleReceiver, nil)
349
+
350
+ origPacket := agtypes.CopyToIBCPacket(packet)
351
+ packetStore, packetKey := k.PacketStoreFromOrigin(ctx, agtypes.PacketDst, packet)
362
352
  if packetStore.Has(packetKey) {
363
353
  origPacket.Data = packetStore.Get(packetKey)
364
354
  packetStore.Delete(packetKey)
@@ -440,7 +430,7 @@ func (k Keeper) Receive(cctx context.Context, jsonRequest string) (jsonReply str
440
430
  case "BRIDGE_TARGET_UNREGISTER":
441
431
  prefixStore.Delete([]byte(msg.Target))
442
432
  default:
443
- return "", sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unknown action type: %s", msg.Type)
433
+ return "", sdkioerrors.Wrapf(sdktypeserrors.ErrUnknownRequest, "unknown action type: %s", msg.Type)
444
434
  }
445
435
  return "true", nil
446
436
  }
package/e2e_test/Makefile DELETED
@@ -1,29 +0,0 @@
1
- # It is possible to use environment variables to change how the tests run
2
- # - `E2ETEST_CHAINNAME0` - set to `"agoric"`, `"gaia"`, or another chain known by interchaintest to choose which chain runs as the first chain
3
- # - `E2ETEST_CHAINNAME1` - set to `"agoric"`, `"gaia"`, or another chain known by interchaintest to choose which chain runs as the second chain
4
- # - `E2ETEST_CHAINNAME2` - set to `"agoric"`, `"gaia"`, or another chain known by interchaintest to choose which chain runs as the third chain
5
- # - `E2ETEST_CHAINNAME3` - set to `"agoric"`, `"gaia"`, or another chain known by interchaintest to choose which chain runs as the fourth chain
6
- # - `E2ETEST_CHAINIMAGE_AGORIC` - the value of this will be used specific the repository & version of docker image to use for the agoric chain. a valid value must have a semicolon and be formatted as `repository:tag`. ex: `E2ETEST_CHAINIMAGE_AGORIC="ghcr.io/agoric/agoricinterchain:latest"`
7
- # - `E2ETEST_RELAYERNAME` - set to `"cosmos"` or `"hermes"` to choose the relayer type
8
- # - `E2ETEST_BLOCKS_TO_WAIT` - set to a number to control how many blocks to wait for an ACK from an IBC transfer and how many blocks to wait for TX settlement.
9
- all: TestConformance TestPFM
10
-
11
- # build - Sanity compile the tests
12
- build:
13
- go test -c -o ./bin/agoricinterchaintest
14
-
15
- # TestPFM - use 4 chains to test PFM
16
- TestPFM:
17
- # Add a 20min timeout since tests are slow
18
- # Add failfast since each test depends on the next
19
- go test -failfast -timeout 20m -v -run ^TestPFM
20
-
21
- # TestConformance - use 2 chains to test basic IBC conformance
22
- TestConformance:
23
- # Add a 20min timeout since tests are slow
24
- go test -timeout 20m -v -run ^TestConformance
25
-
26
- # TestChainPair - Minimal version of TestConformance does less permutations
27
- TestChainPair:
28
- # Add a 20min timeout since tests are slow
29
- go test -timeout 20m -v -run ^TestChainPair