@agoric/cosmos 0.34.2-dev-64cb69f.0 → 0.34.2-dev-c5284e4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/Makefile +8 -1
  2. package/ante/ante.go +8 -7
  3. package/ante/fee.go +8 -7
  4. package/ante/inbound_test.go +3 -2
  5. package/ante/vm_admission.go +2 -1
  6. package/app/app.go +126 -78
  7. package/app/export.go +13 -6
  8. package/cmd/libdaemon/main_test.go +2 -1
  9. package/daemon/cmd/root.go +12 -5
  10. package/e2e_test/Makefile +29 -0
  11. package/e2e_test/README.md +100 -0
  12. package/e2e_test/go.mod +217 -0
  13. package/e2e_test/go.sum +1323 -0
  14. package/e2e_test/ibc_conformance_test.go +56 -0
  15. package/e2e_test/pfm_test.go +613 -0
  16. package/e2e_test/util.go +271 -0
  17. package/git-revision.txt +1 -1
  18. package/go.mod +16 -8
  19. package/go.sum +8 -5
  20. package/package.json +3 -3
  21. package/proto/agoric/vlocalchain/.clang-format +7 -0
  22. package/proto/agoric/vlocalchain/vlocalchain.proto +31 -0
  23. package/third_party/proto/ibc/core/channel/v1/channel.proto +1 -1
  24. package/third_party/proto/ibc/core/client/v1/client.proto +1 -1
  25. package/vm/action.go +5 -4
  26. package/vm/action_test.go +31 -11
  27. package/vm/controller.go +22 -1
  28. package/vm/server.go +1 -1
  29. package/x/swingset/abci.go +10 -10
  30. package/x/swingset/client/cli/tx.go +4 -0
  31. package/x/swingset/handler.go +2 -1
  32. package/x/swingset/keeper/keeper.go +6 -12
  33. package/x/swingset/keeper/msg_server.go +18 -18
  34. package/x/swingset/keeper/proposal.go +13 -3
  35. package/x/swingset/keeper/querier.go +12 -11
  36. package/x/swingset/keeper/swing_store_exports_handler.go +7 -3
  37. package/x/swingset/proposal_handler.go +2 -1
  38. package/x/swingset/types/expected_keepers.go +3 -2
  39. package/x/swingset/types/msgs.go +25 -24
  40. package/x/swingset/types/params.go +2 -1
  41. package/x/swingset/types/proposal.go +5 -4
  42. package/x/vbank/handler.go +2 -1
  43. package/x/vbank/keeper/querier.go +4 -3
  44. package/x/vbank/vbank.go +3 -3
  45. package/x/vibc/alias.go +3 -0
  46. package/x/vibc/handler.go +16 -9
  47. package/x/vibc/keeper/keeper.go +111 -74
  48. package/x/vibc/keeper/triggers.go +101 -0
  49. package/x/vibc/module.go +4 -2
  50. package/x/vibc/types/expected_keepers.go +26 -5
  51. package/x/vibc/types/ibc_module.go +335 -0
  52. package/x/vibc/types/msgs.go +1 -1
  53. package/x/vibc/types/msgs.pb.go +1 -1
  54. package/x/vibc/types/receiver.go +160 -0
  55. package/x/vlocalchain/alias.go +19 -0
  56. package/x/vlocalchain/handler.go +20 -0
  57. package/x/vlocalchain/keeper/keeper.go +279 -0
  58. package/x/vlocalchain/keeper/keeper_test.go +32 -0
  59. package/x/vlocalchain/types/codec.go +34 -0
  60. package/x/vlocalchain/types/key.go +27 -0
  61. package/x/vlocalchain/types/msgs.go +16 -0
  62. package/x/vlocalchain/types/vlocalchain.pb.go +1072 -0
  63. package/x/vlocalchain/vlocalchain.go +109 -0
  64. package/x/vlocalchain/vlocalchain_test.go +305 -0
  65. package/x/vstorage/handler.go +2 -1
  66. package/x/vstorage/keeper/keeper.go +5 -4
  67. package/x/vstorage/keeper/querier.go +6 -5
  68. package/x/vstorage/keeper/querier_test.go +4 -3
  69. package/proto/agoric/lien/genesis.proto +0 -25
  70. package/proto/agoric/lien/lien.proto +0 -25
  71. package/x/lien/alias.go +0 -17
  72. package/x/lien/genesis.go +0 -58
  73. package/x/lien/genesis_test.go +0 -101
  74. package/x/lien/keeper/account.go +0 -290
  75. package/x/lien/keeper/keeper.go +0 -255
  76. package/x/lien/keeper/keeper_test.go +0 -623
  77. package/x/lien/lien.go +0 -205
  78. package/x/lien/lien_test.go +0 -533
  79. package/x/lien/module.go +0 -115
  80. package/x/lien/spec/01_concepts.md +0 -146
  81. package/x/lien/spec/02_messages.md +0 -96
  82. package/x/lien/types/accountkeeper.go +0 -81
  83. package/x/lien/types/accountstate.go +0 -27
  84. package/x/lien/types/expected_keepers.go +0 -18
  85. package/x/lien/types/genesis.pb.go +0 -567
  86. package/x/lien/types/key.go +0 -25
  87. package/x/lien/types/lien.pb.go +0 -403
  88. package/x/vibc/ibc.go +0 -395
  89. /package/{src/index.cjs → index.cjs} +0 -0
package/x/vibc/ibc.go DELETED
@@ -1,395 +0,0 @@
1
- package vibc
2
-
3
- import (
4
- "context"
5
- "encoding/json"
6
- "fmt"
7
-
8
- "github.com/Agoric/agoric-sdk/golang/cosmos/vm"
9
- sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
10
- capability "github.com/cosmos/cosmos-sdk/x/capability/types"
11
- channeltypes "github.com/cosmos/ibc-go/v5/modules/core/04-channel/types"
12
- porttypes "github.com/cosmos/ibc-go/v5/modules/core/05-port/types"
13
- host "github.com/cosmos/ibc-go/v5/modules/core/24-host"
14
-
15
- "github.com/cosmos/ibc-go/v5/modules/core/exported"
16
-
17
- sdk "github.com/cosmos/cosmos-sdk/types"
18
- )
19
-
20
- var (
21
- _ porttypes.IBCModule = IBCModule{}
22
- )
23
-
24
- type IBCModule struct {
25
- keeper Keeper
26
- }
27
-
28
- type portMessage struct { // comes from swingset's IBC handler
29
- Type string `json:"type"` // IBC_METHOD
30
- Method string `json:"method"`
31
- Packet channeltypes.Packet `json:"packet"`
32
- RelativeTimeoutNs uint64 `json:"relativeTimeoutNs,string"`
33
- Order string `json:"order"`
34
- Hops []string `json:"hops"`
35
- Version string `json:"version"`
36
- Ack []byte `json:"ack"`
37
- }
38
-
39
- func stringToOrder(order string) channeltypes.Order {
40
- switch order {
41
- case "ORDERED":
42
- return channeltypes.ORDERED
43
- case "UNORDERED":
44
- return channeltypes.UNORDERED
45
- default:
46
- return channeltypes.NONE
47
- }
48
- }
49
-
50
- func orderToString(order channeltypes.Order) string {
51
- switch order {
52
- case channeltypes.ORDERED:
53
- return "ORDERED"
54
- case channeltypes.UNORDERED:
55
- return "UNORDERED"
56
- default:
57
- return "NONE"
58
- }
59
- }
60
-
61
- func NewIBCModule(keeper Keeper) IBCModule {
62
- return IBCModule{
63
- keeper: keeper,
64
- }
65
- }
66
-
67
- func (ch IBCModule) Receive(cctx context.Context, str string) (ret string, err error) {
68
- // fmt.Println("ibc.go downcall", str)
69
- ctx := sdk.UnwrapSDKContext(cctx)
70
- keeper := ch.keeper
71
-
72
- msg := new(portMessage)
73
- err = json.Unmarshal([]byte(str), &msg)
74
- if err != nil {
75
- return ret, err
76
- }
77
-
78
- if msg.Type != "IBC_METHOD" {
79
- return "", fmt.Errorf(`channel handler only accepts messages of "type": "IBC_METHOD"`)
80
- }
81
-
82
- switch msg.Method {
83
- case "sendPacket":
84
- seq, ok := keeper.GetNextSequenceSend(
85
- ctx,
86
- msg.Packet.SourcePort,
87
- msg.Packet.SourceChannel,
88
- )
89
- if !ok {
90
- return "", fmt.Errorf("unknown sequence number")
91
- }
92
-
93
- timeoutTimestamp := msg.Packet.TimeoutTimestamp
94
- if msg.Packet.TimeoutHeight.IsZero() && msg.Packet.TimeoutTimestamp == 0 {
95
- // Use the relative timeout if no absolute timeout is specifiied.
96
- timeoutTimestamp = uint64(ctx.BlockTime().UnixNano()) + msg.RelativeTimeoutNs
97
- }
98
-
99
- packet := channeltypes.NewPacket(
100
- msg.Packet.Data, seq,
101
- msg.Packet.SourcePort, msg.Packet.SourceChannel,
102
- msg.Packet.DestinationPort, msg.Packet.DestinationChannel,
103
- msg.Packet.TimeoutHeight, timeoutTimestamp,
104
- )
105
- err = keeper.SendPacket(ctx, packet)
106
- if err == nil {
107
- bytes, err := json.Marshal(&packet)
108
- if err == nil {
109
- ret = string(bytes)
110
- }
111
- }
112
-
113
- case "receiveExecuted":
114
- err = keeper.WriteAcknowledgement(ctx, msg.Packet, msg.Ack)
115
- if err == nil {
116
- ret = "true"
117
- }
118
-
119
- case "startChannelOpenInit":
120
- err = keeper.ChanOpenInit(
121
- ctx, stringToOrder(msg.Order), msg.Hops,
122
- msg.Packet.SourcePort,
123
- msg.Packet.DestinationPort,
124
- msg.Version,
125
- )
126
- if err == nil {
127
- ret = "true"
128
- }
129
-
130
- case "startChannelCloseInit":
131
- err = keeper.ChanCloseInit(ctx, msg.Packet.SourcePort, msg.Packet.SourceChannel)
132
- if err == nil {
133
- ret = "true"
134
- }
135
-
136
- case "bindPort":
137
- err = keeper.BindPort(ctx, msg.Packet.SourcePort)
138
- if err == nil {
139
- ret = "true"
140
- }
141
-
142
- case "timeoutExecuted":
143
- err = keeper.TimeoutExecuted(ctx, msg.Packet)
144
- if err == nil {
145
- ret = "true"
146
- }
147
-
148
- default:
149
- err = fmt.Errorf("unrecognized method %s", msg.Method)
150
- }
151
-
152
- // fmt.Println("ibc.go downcall reply", ret, err)
153
- return
154
- }
155
-
156
- func (im IBCModule) PushAction(ctx sdk.Context, action vm.Action) error {
157
- // fmt.Println("ibc.go upcall", send)
158
- return im.keeper.PushAction(ctx, action)
159
- // fmt.Println("ibc.go upcall reply", reply, err)
160
- }
161
-
162
- // Implement IBCModule callbacks
163
- func (im IBCModule) OnChanOpenInit(
164
- ctx sdk.Context,
165
- order channeltypes.Order,
166
- connectionHops []string,
167
- portID string,
168
- channelID string,
169
- channelCap *capability.Capability,
170
- counterparty channeltypes.Counterparty,
171
- version string,
172
- ) (string, error) {
173
- return "", sdkerrors.Wrap(
174
- channeltypes.ErrChannelNotFound,
175
- fmt.Sprintf("vibc does not allow synthetic channelOpenInit for port %s", portID),
176
- )
177
- }
178
-
179
- type channelOpenTryEvent struct {
180
- vm.ActionHeader `actionType:"IBC_EVENT"`
181
- Event string `json:"event" default:"channelOpenTry"`
182
- Order string `json:"order"`
183
- ConnectionHops []string `json:"connectionHops"`
184
- PortID string `json:"portID"`
185
- ChannelID string `json:"channelID"`
186
- Counterparty channeltypes.Counterparty `json:"counterparty"`
187
- Version string `json:"version"`
188
- }
189
-
190
- func (im IBCModule) OnChanOpenTry(
191
- ctx sdk.Context,
192
- order channeltypes.Order,
193
- connectionHops []string,
194
- portID,
195
- channelID string,
196
- channelCap *capability.Capability,
197
- counterparty channeltypes.Counterparty,
198
- counterpartyVersion string,
199
- ) (string, error) {
200
- event := channelOpenTryEvent{
201
- Order: orderToString(order),
202
- ConnectionHops: connectionHops,
203
- PortID: portID,
204
- ChannelID: channelID,
205
- Counterparty: counterparty,
206
- Version: counterpartyVersion, // TODO: don't just use the counterparty version
207
- }
208
-
209
- err := im.PushAction(ctx, event)
210
- if err != nil {
211
- return "", err
212
- }
213
-
214
- // Claim channel capability passed back by IBC module
215
- if err = im.keeper.ClaimCapability(ctx, channelCap, host.ChannelCapabilityPath(portID, channelID)); err != nil {
216
- return "", sdkerrors.Wrap(channeltypes.ErrChannelCapabilityNotFound, err.Error())
217
- }
218
-
219
- return event.Version, err
220
- }
221
-
222
- type channelOpenAckEvent struct {
223
- vm.ActionHeader `actionType:"IBC_EVENT"`
224
- Event string `json:"event" default:"channelOpenAck"`
225
- PortID string `json:"portID"`
226
- ChannelID string `json:"channelID"`
227
- CounterpartyVersion string `json:"counterpartyVersion"`
228
- Counterparty channeltypes.Counterparty `json:"counterparty"`
229
- ConnectionHops []string `json:"connectionHops"`
230
- }
231
-
232
- func (im IBCModule) OnChanOpenAck(
233
- ctx sdk.Context,
234
- portID,
235
- channelID string,
236
- counterpartyChannelID string,
237
- counterpartyVersion string,
238
- ) error {
239
- // We don't care if the channel was found. If it wasn't then GetChannel
240
- // returns an empty channel object that we can still use without crashing.
241
- channel, _ := im.keeper.GetChannel(ctx, portID, channelID)
242
-
243
- channel.Counterparty.ChannelId = counterpartyChannelID
244
- event := channelOpenAckEvent{
245
- PortID: portID,
246
- ChannelID: channelID,
247
- CounterpartyVersion: counterpartyVersion,
248
- Counterparty: channel.Counterparty,
249
- ConnectionHops: channel.ConnectionHops,
250
- }
251
-
252
- return im.PushAction(ctx, event)
253
- }
254
-
255
- type channelOpenConfirmEvent struct {
256
- vm.ActionHeader `actionType:"IBC_EVENT"`
257
- Event string `json:"event" default:"channelOpenConfirm"`
258
- PortID string `json:"portID"`
259
- ChannelID string `json:"channelID"`
260
- }
261
-
262
- func (im IBCModule) OnChanOpenConfirm(
263
- ctx sdk.Context,
264
- portID,
265
- channelID string,
266
- ) error {
267
- event := channelOpenConfirmEvent{
268
- PortID: portID,
269
- ChannelID: channelID,
270
- }
271
-
272
- return im.PushAction(ctx, event)
273
- }
274
-
275
- type channelCloseInitEvent struct {
276
- vm.ActionHeader `actionType:"IBC_EVENT"`
277
- Event string `json:"event" default:"channelCloseInit"`
278
- PortID string `json:"portID"`
279
- ChannelID string `json:"channelID"`
280
- }
281
-
282
- func (im IBCModule) OnChanCloseInit(
283
- ctx sdk.Context,
284
- portID,
285
- channelID string,
286
- ) error {
287
- event := channelCloseInitEvent{
288
- PortID: portID,
289
- ChannelID: channelID,
290
- }
291
-
292
- err := im.PushAction(ctx, event)
293
- return err
294
- }
295
-
296
- type channelCloseConfirmEvent struct {
297
- vm.ActionHeader `actionType:"IBC_EVENT"`
298
- Event string `json:"event" default:"channelCloseConfirm"`
299
- PortID string `json:"portID"`
300
- ChannelID string `json:"channelID"`
301
- }
302
-
303
- func (im IBCModule) OnChanCloseConfirm(
304
- ctx sdk.Context,
305
- portID,
306
- channelID string,
307
- ) error {
308
- event := channelCloseConfirmEvent{
309
- PortID: portID,
310
- ChannelID: channelID,
311
- }
312
-
313
- err := im.PushAction(ctx, event)
314
- return err
315
- }
316
-
317
- type receivePacketEvent struct {
318
- vm.ActionHeader `actionType:"IBC_EVENT"`
319
- Event string `json:"event" default:"receivePacket"`
320
- Packet channeltypes.Packet `json:"packet"`
321
- }
322
-
323
- func (im IBCModule) OnRecvPacket(
324
- ctx sdk.Context,
325
- packet channeltypes.Packet,
326
- relayer sdk.AccAddress,
327
- ) exported.Acknowledgement {
328
- // Sometimes we receive duplicate packets, just with a
329
- // missing packet.TimeoutTimestamp. This causes duplicate
330
- // acks, with one of them being rejected.
331
- //
332
- // This turns out to happen when you run both "rly start"
333
- // and also "rly tx xfer"-- they both are trying to relay
334
- // the same packets.
335
-
336
- event := receivePacketEvent{
337
- Packet: packet,
338
- }
339
-
340
- err := im.PushAction(ctx, event)
341
- if err != nil {
342
- return channeltypes.NewErrorAcknowledgement(err)
343
- }
344
-
345
- return nil
346
- }
347
-
348
- type acknowledgementPacketEvent struct {
349
- vm.ActionHeader `actionType:"IBC_EVENT"`
350
- Event string `json:"event" default:"acknowledgementPacket"`
351
- Packet channeltypes.Packet `json:"packet"`
352
- Acknowledgement []byte `json:"acknowledgement"`
353
- }
354
-
355
- func (im IBCModule) OnAcknowledgementPacket(
356
- ctx sdk.Context,
357
- packet channeltypes.Packet,
358
- acknowledgement []byte,
359
- relayer sdk.AccAddress,
360
- ) error {
361
- event := acknowledgementPacketEvent{
362
- Packet: packet,
363
- Acknowledgement: acknowledgement,
364
- }
365
-
366
- err := im.PushAction(ctx, event)
367
- if err != nil {
368
- return err
369
- }
370
-
371
- return nil
372
- }
373
-
374
- type timeoutPacketEvent struct {
375
- vm.ActionHeader `actionType:"IBC_EVENT"`
376
- Event string `json:"event" default:"timeoutPacket"`
377
- Packet channeltypes.Packet `json:"packet"`
378
- }
379
-
380
- func (im IBCModule) OnTimeoutPacket(
381
- ctx sdk.Context,
382
- packet channeltypes.Packet,
383
- relayer sdk.AccAddress,
384
- ) error {
385
- event := timeoutPacketEvent{
386
- Packet: packet,
387
- }
388
-
389
- err := im.PushAction(ctx, event)
390
- if err != nil {
391
- return err
392
- }
393
-
394
- return nil
395
- }
File without changes