@agoric/cosmos 0.34.1 → 0.34.2-calypso-dev-84eb287.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 (193) hide show
  1. package/MAINTAINERS.md +3 -0
  2. package/Makefile +67 -41
  3. package/agoric/config.go +35 -0
  4. package/ante/ante.go +65 -0
  5. package/ante/expected_keepers.go +26 -0
  6. package/ante/inbound.go +137 -0
  7. package/ante/inbound_test.go +228 -0
  8. package/ante/vm_admission.go +65 -0
  9. package/app/app.go +396 -211
  10. package/app/export.go +13 -9
  11. package/app/sim_test.go +4 -4
  12. package/app/upgrade.go +215 -0
  13. package/binding.gyp.in +29 -4
  14. package/buf.work.yaml +4 -0
  15. package/cmd/agd/agvm.go +42 -0
  16. package/cmd/agd/find_binary.go +22 -7
  17. package/cmd/agd/main.go +133 -10
  18. package/cmd/libdaemon/main.go +67 -53
  19. package/cmd/libdaemon/main_test.go +37 -0
  20. package/daemon/cmd/genaccounts.go +22 -18
  21. package/daemon/cmd/root.go +253 -52
  22. package/daemon/cmd/root_test.go +190 -2
  23. package/daemon/cmd/testnet.go +17 -6
  24. package/daemon/main.go +6 -3
  25. package/e2e_test/Makefile +29 -0
  26. package/e2e_test/README.md +100 -0
  27. package/e2e_test/go.mod +217 -0
  28. package/e2e_test/go.sum +1323 -0
  29. package/e2e_test/ibc_conformance_test.go +56 -0
  30. package/e2e_test/pfm_test.go +613 -0
  31. package/e2e_test/util.go +271 -0
  32. package/git-revision.txt +1 -0
  33. package/go.mod +207 -0
  34. package/go.sum +1877 -0
  35. package/package.json +13 -21
  36. package/proto/agoric/swingset/genesis.proto +14 -0
  37. package/proto/agoric/swingset/swingset.proto +6 -3
  38. package/proto/agoric/vlocalchain/.clang-format +7 -0
  39. package/proto/agoric/vlocalchain/vlocalchain.proto +31 -0
  40. package/proto/agoric/vstorage/query.proto +53 -1
  41. package/proto/agoric/vtransfer/genesis.proto +18 -0
  42. package/scripts/protocgen.sh +16 -6
  43. package/third_party/proto/buf.yaml +1 -0
  44. package/third_party/proto/cosmos/base/query/v1beta1/pagination.proto +4 -1
  45. package/third_party/proto/cosmos/base/v1beta1/coin.proto +7 -4
  46. package/third_party/proto/cosmos/upgrade/v1beta1/upgrade.proto +16 -6
  47. package/third_party/proto/cosmos_proto/cosmos.proto +97 -0
  48. package/third_party/proto/google/api/annotations.proto +1 -1
  49. package/third_party/proto/google/api/http.proto +181 -120
  50. package/third_party/proto/google/api/httpbody.proto +9 -6
  51. package/third_party/proto/google/protobuf/any.proto +1 -7
  52. package/third_party/proto/ibc/core/channel/v1/channel.proto +15 -1
  53. package/third_party/proto/ibc/core/client/v1/client.proto +9 -6
  54. package/tools/tools.go +11 -0
  55. package/types/events.go +41 -0
  56. package/types/kv_entry.go +114 -0
  57. package/types/kv_entry_helpers.go +276 -0
  58. package/types/kv_entry_helpers_test.go +237 -0
  59. package/types/kv_entry_test.go +143 -0
  60. package/upgradegaia.sh +75 -0
  61. package/vm/action.go +134 -0
  62. package/vm/action_test.go +149 -0
  63. package/vm/client.go +113 -0
  64. package/vm/client_test.go +182 -0
  65. package/vm/controller.go +49 -0
  66. package/vm/core_proposals.go +51 -0
  67. package/vm/jsonrpcconn/jsonrpcconn.go +160 -0
  68. package/vm/jsonrpcconn/jsonrpcconn_test.go +126 -0
  69. package/vm/proto_json.go +38 -0
  70. package/vm/proto_json_test.go +103 -0
  71. package/vm/server.go +124 -0
  72. package/x/swingset/abci.go +26 -37
  73. package/x/swingset/alias.go +9 -6
  74. package/x/swingset/client/cli/query.go +2 -2
  75. package/x/swingset/client/cli/tx.go +52 -33
  76. package/x/swingset/client/proposal_handler.go +2 -17
  77. package/x/swingset/genesis.go +163 -37
  78. package/x/swingset/handler.go +2 -1
  79. package/x/swingset/keeper/extension_snapshotter.go +309 -0
  80. package/x/swingset/keeper/extension_snapshotter_test.go +104 -0
  81. package/x/swingset/keeper/keeper.go +95 -48
  82. package/x/swingset/keeper/keeper_test.go +77 -0
  83. package/x/swingset/keeper/migrations.go +7 -2
  84. package/x/swingset/keeper/msg_server.go +71 -56
  85. package/x/swingset/keeper/proposal.go +15 -9
  86. package/x/swingset/keeper/querier.go +24 -15
  87. package/x/swingset/keeper/swing_store_exports_handler.go +872 -0
  88. package/x/swingset/keeper/swing_store_exports_handler_test.go +247 -0
  89. package/x/swingset/keeper/test_utils.go +16 -0
  90. package/x/swingset/module.go +33 -11
  91. package/x/swingset/proposal_handler.go +5 -4
  92. package/x/swingset/swingset.go +73 -0
  93. package/x/swingset/testing/queue.go +17 -0
  94. package/x/swingset/types/codec.go +2 -2
  95. package/x/swingset/types/default-params.go +23 -17
  96. package/x/swingset/types/expected_keepers.go +14 -2
  97. package/x/swingset/types/genesis.pb.go +361 -18
  98. package/x/swingset/types/msgs.go +87 -26
  99. package/x/swingset/types/msgs.pb.go +16 -16
  100. package/x/swingset/types/params.go +76 -1
  101. package/x/swingset/types/params_test.go +116 -0
  102. package/x/swingset/types/proposal.go +10 -9
  103. package/x/swingset/types/swingset.pb.go +83 -81
  104. package/x/swingset/types/types.go +30 -28
  105. package/x/vbank/genesis.go +0 -2
  106. package/x/vbank/handler.go +2 -1
  107. package/x/vbank/keeper/keeper.go +3 -2
  108. package/x/vbank/keeper/querier.go +9 -4
  109. package/x/vbank/keeper/rewards.go +1 -1
  110. package/x/vbank/module.go +0 -5
  111. package/x/vbank/types/msgs.go +0 -12
  112. package/x/vbank/vbank.go +34 -32
  113. package/x/vbank/vbank_test.go +20 -20
  114. package/x/vibc/alias.go +3 -0
  115. package/x/vibc/handler.go +17 -15
  116. package/x/vibc/keeper/keeper.go +113 -89
  117. package/x/vibc/keeper/triggers.go +101 -0
  118. package/x/vibc/module.go +5 -8
  119. package/x/vibc/types/expected_keepers.go +28 -6
  120. package/x/vibc/types/ibc_module.go +336 -0
  121. package/x/vibc/types/msgs.go +1 -1
  122. package/x/vibc/types/msgs.pb.go +1 -1
  123. package/x/vibc/types/receiver.go +170 -0
  124. package/x/vlocalchain/alias.go +19 -0
  125. package/x/vlocalchain/handler.go +21 -0
  126. package/x/vlocalchain/keeper/keeper.go +279 -0
  127. package/x/vlocalchain/keeper/keeper_test.go +97 -0
  128. package/x/vlocalchain/types/codec.go +34 -0
  129. package/x/vlocalchain/types/key.go +27 -0
  130. package/x/vlocalchain/types/msgs.go +16 -0
  131. package/x/vlocalchain/types/vlocalchain.pb.go +1072 -0
  132. package/x/vlocalchain/vlocalchain.go +114 -0
  133. package/x/vlocalchain/vlocalchain_test.go +434 -0
  134. package/x/vstorage/README.md +138 -0
  135. package/x/vstorage/capdata/capdata.go +298 -0
  136. package/x/vstorage/capdata/capdata_test.go +352 -0
  137. package/x/vstorage/client/cli/query.go +51 -4
  138. package/x/vstorage/genesis.go +0 -3
  139. package/x/vstorage/handler.go +2 -1
  140. package/x/vstorage/keeper/grpc_query.go +220 -0
  141. package/x/vstorage/keeper/keeper.go +75 -57
  142. package/x/vstorage/keeper/keeper_grpc_test.go +300 -0
  143. package/x/vstorage/keeper/keeper_test.go +40 -62
  144. package/x/vstorage/keeper/querier.go +39 -14
  145. package/x/vstorage/keeper/querier_test.go +113 -0
  146. package/x/vstorage/module.go +0 -5
  147. package/x/vstorage/testing/queue.go +27 -0
  148. package/x/vstorage/types/path_keys.go +22 -10
  149. package/x/vstorage/types/path_keys_test.go +84 -18
  150. package/x/vstorage/types/query.pb.go +646 -36
  151. package/x/vstorage/types/query.pb.gw.go +119 -0
  152. package/x/vstorage/types/types.go +0 -66
  153. package/x/vstorage/vstorage.go +33 -35
  154. package/x/vstorage/vstorage_test.go +19 -19
  155. package/x/vtransfer/alias.go +13 -0
  156. package/x/vtransfer/genesis.go +39 -0
  157. package/x/vtransfer/genesis_test.go +12 -0
  158. package/x/vtransfer/handler.go +20 -0
  159. package/x/vtransfer/ibc_middleware.go +186 -0
  160. package/x/vtransfer/ibc_middleware_test.go +448 -0
  161. package/x/vtransfer/keeper/keeper.go +281 -0
  162. package/x/vtransfer/module.go +124 -0
  163. package/x/vtransfer/types/expected_keepers.go +38 -0
  164. package/x/vtransfer/types/genesis.pb.go +327 -0
  165. package/x/vtransfer/types/key.go +9 -0
  166. package/x/vtransfer/types/msgs.go +9 -0
  167. package/app/const.go +0 -6
  168. package/cmd/helper/main.go +0 -21
  169. package/proto/agoric/lien/genesis.proto +0 -25
  170. package/proto/agoric/lien/lien.proto +0 -25
  171. package/x/lien/alias.go +0 -17
  172. package/x/lien/genesis.go +0 -58
  173. package/x/lien/genesis_test.go +0 -101
  174. package/x/lien/keeper/account.go +0 -285
  175. package/x/lien/keeper/keeper.go +0 -254
  176. package/x/lien/keeper/keeper_test.go +0 -623
  177. package/x/lien/lien.go +0 -203
  178. package/x/lien/lien_test.go +0 -529
  179. package/x/lien/module.go +0 -115
  180. package/x/lien/spec/01_concepts.md +0 -146
  181. package/x/lien/spec/02_messages.md +0 -96
  182. package/x/lien/types/accountkeeper.go +0 -81
  183. package/x/lien/types/accountstate.go +0 -27
  184. package/x/lien/types/expected_keepers.go +0 -18
  185. package/x/lien/types/genesis.pb.go +0 -567
  186. package/x/lien/types/key.go +0 -25
  187. package/x/lien/types/lien.pb.go +0 -403
  188. package/x/swingset/keeper/snapshotter.go +0 -491
  189. package/x/swingset/keeper/snapshotter_test.go +0 -185
  190. package/x/swingset/legacy/v32/params.go +0 -37
  191. package/x/swingset/legacy/v32/params_test.go +0 -133
  192. package/x/vibc/ibc.go +0 -442
  193. /package/{src/index.cjs → index.cjs} +0 -0
@@ -1,133 +0,0 @@
1
- package v32
2
-
3
- import (
4
- "reflect"
5
- "testing"
6
-
7
- "github.com/Agoric/agoric-sdk/golang/cosmos/x/swingset/types"
8
- sdk "github.com/cosmos/cosmos-sdk/types"
9
- )
10
-
11
- type beans = types.StringBeans
12
-
13
- func TestAddStorageBeanCost(t *testing.T) {
14
- var defaultStorageCost beans
15
- for _, b := range types.DefaultParams().BeansPerUnit {
16
- if b.Key == types.BeansPerStorageByte {
17
- defaultStorageCost = b
18
- }
19
- }
20
- if defaultStorageCost.Key == "" {
21
- t.Fatalf("no beans per storage byte in default params")
22
- }
23
-
24
- for _, tt := range []struct {
25
- name string
26
- in []beans
27
- want []beans
28
- }{
29
- {
30
- name: "empty",
31
- in: []beans{},
32
- want: []beans{defaultStorageCost},
33
- },
34
- {
35
- name: "already_only_same",
36
- in: []beans{defaultStorageCost},
37
- want: []beans{defaultStorageCost},
38
- },
39
- {
40
- name: "already_only_different",
41
- in: []beans{types.NewStringBeans(types.BeansPerStorageByte, sdk.NewUint(123))},
42
- want: []beans{types.NewStringBeans(types.BeansPerStorageByte, sdk.NewUint(123))},
43
- },
44
- {
45
- name: "already_same",
46
- in: []beans{
47
- types.NewStringBeans("foo", sdk.NewUint(123)),
48
- defaultStorageCost,
49
- types.NewStringBeans("bar", sdk.NewUint(456)),
50
- },
51
- want: []beans{
52
- types.NewStringBeans("foo", sdk.NewUint(123)),
53
- defaultStorageCost,
54
- types.NewStringBeans("bar", sdk.NewUint(456)),
55
- },
56
- },
57
- {
58
- name: "already_different",
59
- in: []beans{
60
- types.NewStringBeans("foo", sdk.NewUint(123)),
61
- types.NewStringBeans(types.BeansPerStorageByte, sdk.NewUint(789)),
62
- types.NewStringBeans("bar", sdk.NewUint(456)),
63
- },
64
- want: []beans{
65
- types.NewStringBeans("foo", sdk.NewUint(123)),
66
- types.NewStringBeans(types.BeansPerStorageByte, sdk.NewUint(789)),
67
- types.NewStringBeans("bar", sdk.NewUint(456)),
68
- },
69
- },
70
- {
71
- name: "missing",
72
- in: []beans{
73
- types.NewStringBeans("foo", sdk.NewUint(123)),
74
- types.NewStringBeans("bar", sdk.NewUint(456)),
75
- },
76
- want: []beans{
77
- types.NewStringBeans("foo", sdk.NewUint(123)),
78
- types.NewStringBeans("bar", sdk.NewUint(456)),
79
- defaultStorageCost,
80
- },
81
- },
82
- } {
83
- t.Run(tt.name, func(t *testing.T) {
84
- got, err := addStorageBeanCost(tt.in)
85
- if err != nil {
86
- t.Errorf("got error %v", err)
87
- } else if !reflect.DeepEqual(got, tt.want) {
88
- t.Errorf("want %v, got %v", tt.want, got)
89
- }
90
- })
91
- }
92
- }
93
-
94
- func TestUpdateParams(t *testing.T) {
95
- var defaultStorageCost beans
96
- for _, b := range types.DefaultParams().BeansPerUnit {
97
- if b.Key == types.BeansPerStorageByte {
98
- defaultStorageCost = b
99
- }
100
- }
101
- if defaultStorageCost.Key == "" {
102
- t.Fatalf("no beans per storage byte in default params")
103
- }
104
-
105
- in := types.Params{
106
- BeansPerUnit: []beans{
107
- types.NewStringBeans("foo", sdk.NewUint(123)),
108
- types.NewStringBeans("bar", sdk.NewUint(456)),
109
- },
110
- BootstrapVatConfig: "baz",
111
- FeeUnitPrice: sdk.NewCoins(sdk.NewInt64Coin("denom", 789)),
112
- PowerFlagFees: types.DefaultPowerFlagFees,
113
- QueueMax: types.DefaultQueueMax,
114
- }
115
- want := types.Params{
116
- BeansPerUnit: []beans{
117
- types.NewStringBeans("foo", sdk.NewUint(123)),
118
- types.NewStringBeans("bar", sdk.NewUint(456)),
119
- defaultStorageCost,
120
- },
121
- BootstrapVatConfig: "baz",
122
- FeeUnitPrice: sdk.NewCoins(sdk.NewInt64Coin("denom", 789)),
123
- PowerFlagFees: types.DefaultPowerFlagFees,
124
- QueueMax: types.DefaultQueueMax,
125
- }
126
- got, err := UpdateParams(in)
127
- if err != nil {
128
- t.Fatalf("UpdateParam error %v", err)
129
- }
130
- if !reflect.DeepEqual(got, want) {
131
- t.Errorf("got %v, want %v", got, want)
132
- }
133
- }
package/x/vibc/ibc.go DELETED
@@ -1,442 +0,0 @@
1
- package vibc
2
-
3
- import (
4
- "encoding/json"
5
- "fmt"
6
-
7
- "github.com/Agoric/agoric-sdk/golang/cosmos/vm"
8
- sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
9
- capability "github.com/cosmos/cosmos-sdk/x/capability/types"
10
- channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types"
11
- porttypes "github.com/cosmos/ibc-go/v3/modules/core/05-port/types"
12
- host "github.com/cosmos/ibc-go/v3/modules/core/24-host"
13
-
14
- "github.com/cosmos/ibc-go/v3/modules/core/exported"
15
-
16
- sdk "github.com/cosmos/cosmos-sdk/types"
17
- )
18
-
19
- var (
20
- _ porttypes.IBCModule = IBCModule{}
21
- )
22
-
23
- type IBCModule struct {
24
- keeper Keeper
25
- }
26
-
27
- type portMessage struct { // comes from swingset's IBC handler
28
- Type string `json:"type"` // IBC_METHOD
29
- Method string `json:"method"`
30
- Packet channeltypes.Packet `json:"packet"`
31
- RelativeTimeoutNs uint64 `json:"relativeTimeoutNs,string"`
32
- Order string `json:"order"`
33
- Hops []string `json:"hops"`
34
- Version string `json:"version"`
35
- Ack []byte `json:"ack"`
36
- }
37
-
38
- func stringToOrder(order string) channeltypes.Order {
39
- switch order {
40
- case "ORDERED":
41
- return channeltypes.ORDERED
42
- case "UNORDERED":
43
- return channeltypes.UNORDERED
44
- default:
45
- return channeltypes.NONE
46
- }
47
- }
48
-
49
- func orderToString(order channeltypes.Order) string {
50
- switch order {
51
- case channeltypes.ORDERED:
52
- return "ORDERED"
53
- case channeltypes.UNORDERED:
54
- return "UNORDERED"
55
- default:
56
- return "NONE"
57
- }
58
- }
59
-
60
- func NewIBCModule(keeper Keeper) IBCModule {
61
- return IBCModule{
62
- keeper: keeper,
63
- }
64
- }
65
-
66
- func (ch IBCModule) Receive(ctx *vm.ControllerContext, str string) (ret string, err error) {
67
- // fmt.Println("ibc.go downcall", str)
68
- keeper := ch.keeper
69
-
70
- msg := new(portMessage)
71
- err = json.Unmarshal([]byte(str), &msg)
72
- if err != nil {
73
- return ret, err
74
- }
75
-
76
- if msg.Type != "IBC_METHOD" {
77
- return "", fmt.Errorf(`channel handler only accepts messages of "type": "IBC_METHOD"`)
78
- }
79
-
80
- switch msg.Method {
81
- case "sendPacket":
82
- seq, ok := keeper.GetNextSequenceSend(
83
- ctx.Context,
84
- msg.Packet.SourcePort,
85
- msg.Packet.SourceChannel,
86
- )
87
- if !ok {
88
- return "", fmt.Errorf("unknown sequence number")
89
- }
90
-
91
- timeoutTimestamp := msg.Packet.TimeoutTimestamp
92
- if msg.Packet.TimeoutHeight.IsZero() && msg.Packet.TimeoutTimestamp == 0 {
93
- // Use the relative timeout if no absolute timeout is specifiied.
94
- timeoutTimestamp = uint64(ctx.Context.BlockTime().UnixNano()) + msg.RelativeTimeoutNs
95
- }
96
-
97
- packet := channeltypes.NewPacket(
98
- msg.Packet.Data, seq,
99
- msg.Packet.SourcePort, msg.Packet.SourceChannel,
100
- msg.Packet.DestinationPort, msg.Packet.DestinationChannel,
101
- msg.Packet.TimeoutHeight, timeoutTimestamp,
102
- )
103
- err = keeper.SendPacket(ctx.Context, packet)
104
- if err == nil {
105
- bytes, err := json.Marshal(&packet)
106
- if err == nil {
107
- ret = string(bytes)
108
- }
109
- }
110
-
111
- case "receiveExecuted":
112
- err = keeper.WriteAcknowledgement(ctx.Context, msg.Packet, msg.Ack)
113
- if err == nil {
114
- ret = "true"
115
- }
116
-
117
- case "startChannelOpenInit":
118
- err = keeper.ChanOpenInit(
119
- ctx.Context, stringToOrder(msg.Order), msg.Hops,
120
- msg.Packet.SourcePort,
121
- msg.Packet.DestinationPort,
122
- msg.Version,
123
- )
124
- if err == nil {
125
- ret = "true"
126
- }
127
-
128
- case "startChannelCloseInit":
129
- err = keeper.ChanCloseInit(ctx.Context, msg.Packet.SourcePort, msg.Packet.SourceChannel)
130
- if err == nil {
131
- ret = "true"
132
- }
133
-
134
- case "bindPort":
135
- err = keeper.BindPort(ctx.Context, msg.Packet.SourcePort)
136
- if err == nil {
137
- ret = "true"
138
- }
139
-
140
- case "timeoutExecuted":
141
- err = keeper.TimeoutExecuted(ctx.Context, msg.Packet)
142
- if err == nil {
143
- ret = "true"
144
- }
145
-
146
- default:
147
- err = fmt.Errorf("unrecognized method %s", msg.Method)
148
- }
149
-
150
- // fmt.Println("ibc.go downcall reply", ret, err)
151
- return
152
- }
153
-
154
- func (im IBCModule) PushAction(ctx sdk.Context, action vm.Jsonable) error {
155
- // fmt.Println("ibc.go upcall", send)
156
- return im.keeper.PushAction(ctx, action)
157
- // fmt.Println("ibc.go upcall reply", reply, err)
158
- }
159
-
160
- // Implement IBCModule callbacks
161
- func (im IBCModule) OnChanOpenInit(
162
- ctx sdk.Context,
163
- order channeltypes.Order,
164
- connectionHops []string,
165
- portID string,
166
- channelID string,
167
- channelCap *capability.Capability,
168
- counterparty channeltypes.Counterparty,
169
- version string,
170
- ) error {
171
- return sdkerrors.Wrap(
172
- channeltypes.ErrChannelNotFound,
173
- fmt.Sprintf("vibc does not allow synthetic channelOpenInit for port %s", portID),
174
- )
175
- }
176
-
177
- type channelOpenTryEvent struct {
178
- Type string `json:"type"` // IBC
179
- Event string `json:"event"` // channelOpenTry
180
- Order string `json:"order"`
181
- ConnectionHops []string `json:"connectionHops"`
182
- PortID string `json:"portID"`
183
- ChannelID string `json:"channelID"`
184
- Counterparty channeltypes.Counterparty `json:"counterparty"`
185
- Version string `json:"version"`
186
- BlockHeight int64 `json:"blockHeight"`
187
- BlockTime int64 `json:"blockTime"`
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
- Type: "IBC_EVENT",
202
- Event: "channelOpenTry",
203
- Order: orderToString(order),
204
- ConnectionHops: connectionHops,
205
- PortID: portID,
206
- ChannelID: channelID,
207
- Counterparty: counterparty,
208
- Version: counterpartyVersion, // TODO: don't just use the counterparty version
209
- BlockHeight: ctx.BlockHeight(),
210
- BlockTime: ctx.BlockTime().Unix(),
211
- }
212
-
213
- err := im.PushAction(ctx, event)
214
- if err != nil {
215
- return "", err
216
- }
217
-
218
- // Claim channel capability passed back by IBC module
219
- if err = im.keeper.ClaimCapability(ctx, channelCap, host.ChannelCapabilityPath(portID, channelID)); err != nil {
220
- return "", sdkerrors.Wrap(channeltypes.ErrChannelCapabilityNotFound, err.Error())
221
- }
222
-
223
- return event.Version, err
224
- }
225
-
226
- type channelOpenAckEvent struct {
227
- Type string `json:"type"` // IBC
228
- Event string `json:"event"` // channelOpenAck
229
- PortID string `json:"portID"`
230
- ChannelID string `json:"channelID"`
231
- CounterpartyChannelID string `json:"counterpartyChannelID"`
232
- CounterpartyVersion string `json:"counterpartyVersion"`
233
- Counterparty channeltypes.Counterparty `json:"counterparty"`
234
- ConnectionHops []string `json:"connectionHops"`
235
- BlockHeight int64 `json:"blockHeight"`
236
- BlockTime int64 `json:"blockTime"`
237
- }
238
-
239
- func (im IBCModule) OnChanOpenAck(
240
- ctx sdk.Context,
241
- portID,
242
- channelID string,
243
- counterpartyChannelID string,
244
- counterpartyVersion string,
245
- ) error {
246
- // We don't care if the channel was found. If it wasn't then GetChannel
247
- // returns an empty channel object that we can still use without crashing.
248
- channel, _ := im.keeper.GetChannel(ctx, portID, channelID)
249
-
250
- event := channelOpenAckEvent{
251
- Type: "IBC_EVENT",
252
- Event: "channelOpenAck",
253
- PortID: portID,
254
- ChannelID: channelID,
255
- CounterpartyChannelID: counterpartyChannelID,
256
- CounterpartyVersion: counterpartyVersion,
257
- Counterparty: channel.Counterparty,
258
- ConnectionHops: channel.ConnectionHops,
259
- BlockHeight: ctx.BlockHeight(),
260
- BlockTime: ctx.BlockTime().Unix(),
261
- }
262
-
263
- return im.PushAction(ctx, event)
264
- }
265
-
266
- type channelOpenConfirmEvent struct {
267
- Type string `json:"type"` // IBC
268
- Event string `json:"event"` // channelOpenConfirm
269
- PortID string `json:"portID"`
270
- ChannelID string `json:"channelID"`
271
- BlockHeight int64 `json:"blockHeight"`
272
- BlockTime int64 `json:"blockTime"`
273
- }
274
-
275
- func (im IBCModule) OnChanOpenConfirm(
276
- ctx sdk.Context,
277
- portID,
278
- channelID string,
279
- ) error {
280
- event := channelOpenConfirmEvent{
281
- Type: "IBC_EVENT",
282
- Event: "channelOpenConfirm",
283
- PortID: portID,
284
- ChannelID: channelID,
285
- BlockHeight: ctx.BlockHeight(),
286
- BlockTime: ctx.BlockTime().Unix(),
287
- }
288
-
289
- return im.PushAction(ctx, event)
290
- }
291
-
292
- type channelCloseInitEvent struct {
293
- Type string `json:"type"` // IBC
294
- Event string `json:"event"` // channelCloseInit
295
- PortID string `json:"portID"`
296
- ChannelID string `json:"channelID"`
297
- BlockHeight int64 `json:"blockHeight"`
298
- BlockTime int64 `json:"blockTime"`
299
- }
300
-
301
- func (im IBCModule) OnChanCloseInit(
302
- ctx sdk.Context,
303
- portID,
304
- channelID string,
305
- ) error {
306
- event := channelCloseInitEvent{
307
- Type: "IBC_EVENT",
308
- Event: "channelCloseInit",
309
- PortID: portID,
310
- ChannelID: channelID,
311
- BlockHeight: ctx.BlockHeight(),
312
- BlockTime: ctx.BlockTime().Unix(),
313
- }
314
-
315
- err := im.PushAction(ctx, event)
316
- return err
317
- }
318
-
319
- type channelCloseConfirmEvent struct {
320
- Type string `json:"type"` // IBC
321
- Event string `json:"event"` // channelCloseConfirm
322
- PortID string `json:"portID"`
323
- ChannelID string `json:"channelID"`
324
- BlockHeight int64 `json:"blockHeight"`
325
- BlockTime int64 `json:"blockTime"`
326
- }
327
-
328
- func (im IBCModule) OnChanCloseConfirm(
329
- ctx sdk.Context,
330
- portID,
331
- channelID string,
332
- ) error {
333
- event := channelCloseConfirmEvent{
334
- Type: "IBC_EVENT",
335
- Event: "channelCloseConfirm",
336
- PortID: portID,
337
- ChannelID: channelID,
338
- BlockHeight: ctx.BlockHeight(),
339
- BlockTime: ctx.BlockTime().Unix(),
340
- }
341
-
342
- err := im.PushAction(ctx, event)
343
- return err
344
- }
345
-
346
- type receivePacketEvent struct {
347
- Type string `json:"type"` // IBC
348
- Event string `json:"event"` // receivePacket
349
- Packet channeltypes.Packet `json:"packet"`
350
- BlockHeight int64 `json:"blockHeight"`
351
- BlockTime int64 `json:"blockTime"`
352
- }
353
-
354
- func (im IBCModule) OnRecvPacket(
355
- ctx sdk.Context,
356
- packet channeltypes.Packet,
357
- relayer sdk.AccAddress,
358
- ) exported.Acknowledgement {
359
- // Sometimes we receive duplicate packets, just with a
360
- // missing packet.TimeoutTimestamp. This causes duplicate
361
- // acks, with one of them being rejected.
362
- //
363
- // This turns out to happen when you run both "rly start"
364
- // and also "rly tx xfer"-- they both are trying to relay
365
- // the same packets.
366
-
367
- event := receivePacketEvent{
368
- Type: "IBC_EVENT",
369
- Event: "receivePacket",
370
- Packet: packet,
371
- BlockHeight: ctx.BlockHeight(),
372
- BlockTime: ctx.BlockTime().Unix(),
373
- }
374
-
375
- err := im.PushAction(ctx, event)
376
- if err != nil {
377
- return channeltypes.NewErrorAcknowledgement(err.Error())
378
- }
379
-
380
- return nil
381
- }
382
-
383
- type acknowledgementPacketEvent struct {
384
- Type string `json:"type"` // IBC
385
- Event string `json:"event"` // acknowledgementPacket
386
- Packet channeltypes.Packet `json:"packet"`
387
- Acknowledgement []byte `json:"acknowledgement"`
388
- BlockHeight int64 `json:"blockHeight"`
389
- BlockTime int64 `json:"blockTime"`
390
- }
391
-
392
- func (im IBCModule) OnAcknowledgementPacket(
393
- ctx sdk.Context,
394
- packet channeltypes.Packet,
395
- acknowledgement []byte,
396
- relayer sdk.AccAddress,
397
- ) error {
398
- event := acknowledgementPacketEvent{
399
- Type: "IBC_EVENT",
400
- Event: "acknowledgementPacket",
401
- Packet: packet,
402
- Acknowledgement: acknowledgement,
403
- BlockHeight: ctx.BlockHeight(),
404
- BlockTime: ctx.BlockTime().Unix(),
405
- }
406
-
407
- err := im.PushAction(ctx, event)
408
- if err != nil {
409
- return err
410
- }
411
-
412
- return nil
413
- }
414
-
415
- type timeoutPacketEvent struct {
416
- Type string `json:"type"` // IBC
417
- Event string `json:"event"` // timeoutPacket
418
- Packet channeltypes.Packet `json:"packet"`
419
- BlockHeight int64 `json:"blockHeight"`
420
- BlockTime int64 `json:"blockTime"`
421
- }
422
-
423
- func (im IBCModule) OnTimeoutPacket(
424
- ctx sdk.Context,
425
- packet channeltypes.Packet,
426
- relayer sdk.AccAddress,
427
- ) error {
428
- event := timeoutPacketEvent{
429
- Type: "IBC_EVENT",
430
- Event: "timeoutPacket",
431
- Packet: packet,
432
- BlockHeight: ctx.BlockHeight(),
433
- BlockTime: ctx.BlockTime().Unix(),
434
- }
435
-
436
- err := im.PushAction(ctx, event)
437
- if err != nil {
438
- return err
439
- }
440
-
441
- return nil
442
- }
File without changes