@agoric/cosmos 0.35.0-upgrade-14-dev-0169c7e.0 → 0.35.0-upgrade-16-dev-07b0130.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 +121 -77
- package/MAINTAINERS.md +3 -0
- package/Makefile +49 -26
- package/ante/ante.go +11 -11
- package/ante/inbound_test.go +3 -2
- package/ante/vm_admission.go +2 -1
- package/app/app.go +260 -175
- package/app/export.go +13 -6
- package/app/upgrade.go +76 -0
- package/cmd/agd/agvm.go +42 -0
- package/cmd/agd/main.go +132 -11
- package/cmd/libdaemon/main.go +67 -53
- package/cmd/libdaemon/main_test.go +2 -1
- package/daemon/cmd/genaccounts.go +13 -9
- package/daemon/cmd/root.go +186 -73
- package/daemon/cmd/root_test.go +190 -2
- package/daemon/cmd/testnet.go +17 -6
- package/daemon/main.go +6 -3
- package/e2e_test/Makefile +29 -0
- package/e2e_test/README.md +100 -0
- package/e2e_test/go.mod +217 -0
- package/e2e_test/go.sum +1323 -0
- package/e2e_test/ibc_conformance_test.go +56 -0
- package/e2e_test/pfm_test.go +613 -0
- package/e2e_test/util.go +271 -0
- package/git-revision.txt +1 -1
- package/go.mod +110 -68
- package/go.sum +601 -248
- package/package.json +9 -5
- package/proto/agoric/swingset/genesis.proto +4 -0
- package/proto/agoric/swingset/swingset.proto +1 -1
- package/proto/agoric/vlocalchain/.clang-format +7 -0
- package/proto/agoric/vlocalchain/vlocalchain.proto +31 -0
- package/proto/agoric/vstorage/query.proto +53 -1
- package/proto/agoric/vtransfer/genesis.proto +18 -0
- package/scripts/protocgen.sh +16 -6
- package/third_party/proto/buf.yaml +1 -0
- package/third_party/proto/cosmos/base/query/v1beta1/pagination.proto +4 -1
- package/third_party/proto/cosmos/base/v1beta1/coin.proto +7 -4
- package/third_party/proto/cosmos/upgrade/v1beta1/upgrade.proto +16 -6
- package/third_party/proto/cosmos_proto/cosmos.proto +97 -0
- package/third_party/proto/google/api/annotations.proto +1 -1
- package/third_party/proto/google/api/http.proto +181 -120
- package/third_party/proto/google/api/httpbody.proto +9 -6
- package/third_party/proto/google/protobuf/any.proto +1 -7
- package/third_party/proto/ibc/core/channel/v1/channel.proto +15 -1
- package/third_party/proto/ibc/core/client/v1/client.proto +9 -6
- package/types/kv_entry_helpers.go +42 -0
- package/upgradegaia.sh +21 -12
- package/vm/action.go +28 -24
- package/vm/action_test.go +36 -16
- package/vm/client.go +113 -0
- package/vm/client_test.go +182 -0
- package/vm/controller.go +18 -42
- package/vm/core_proposals.go +22 -2
- package/vm/jsonrpcconn/jsonrpcconn.go +160 -0
- package/vm/jsonrpcconn/jsonrpcconn_test.go +126 -0
- package/vm/proto_json.go +38 -0
- package/vm/proto_json_test.go +103 -0
- package/vm/server.go +124 -0
- package/x/swingset/abci.go +10 -10
- package/x/swingset/alias.go +2 -0
- package/x/swingset/client/cli/query.go +2 -2
- package/x/swingset/client/cli/tx.go +52 -33
- package/x/swingset/client/proposal_handler.go +2 -17
- package/x/swingset/genesis.go +84 -24
- package/x/swingset/handler.go +2 -1
- package/x/swingset/keeper/extension_snapshotter.go +2 -2
- package/x/swingset/keeper/keeper.go +21 -36
- package/x/swingset/keeper/keeper_test.go +1 -1
- package/x/swingset/keeper/msg_server.go +20 -22
- package/x/swingset/keeper/proposal.go +13 -3
- package/x/swingset/keeper/querier.go +23 -14
- package/x/swingset/keeper/swing_store_exports_handler.go +21 -6
- package/x/swingset/keeper/test_utils.go +16 -0
- package/x/swingset/module.go +7 -7
- package/x/swingset/proposal_handler.go +5 -4
- package/x/swingset/swingset.go +4 -2
- package/x/swingset/testing/queue.go +17 -0
- package/x/swingset/types/codec.go +2 -2
- package/x/swingset/types/default-params.go +1 -1
- package/x/swingset/types/expected_keepers.go +3 -2
- package/x/swingset/types/genesis.pb.go +78 -25
- package/x/swingset/types/msgs.go +44 -24
- package/x/swingset/types/msgs.pb.go +16 -16
- package/x/swingset/types/params.go +2 -1
- package/x/swingset/types/proposal.go +10 -9
- package/x/swingset/types/swingset.pb.go +1 -1
- package/x/swingset/types/types.go +30 -28
- package/x/vbank/genesis.go +0 -2
- package/x/vbank/handler.go +2 -1
- package/x/vbank/keeper/keeper.go +3 -2
- package/x/vbank/keeper/querier.go +9 -4
- package/x/vbank/keeper/rewards.go +1 -1
- package/x/vbank/module.go +0 -5
- package/x/vbank/types/msgs.go +0 -12
- package/x/vbank/vbank.go +20 -19
- package/x/vbank/vbank_test.go +10 -10
- package/x/vibc/alias.go +3 -0
- package/x/vibc/handler.go +16 -9
- package/x/vibc/keeper/keeper.go +112 -74
- package/x/vibc/keeper/triggers.go +101 -0
- package/x/vibc/module.go +5 -8
- package/x/vibc/types/expected_keepers.go +26 -5
- package/x/vibc/types/ibc_module.go +336 -0
- package/x/vibc/types/msgs.go +1 -1
- package/x/vibc/types/msgs.pb.go +1 -1
- package/x/vibc/types/receiver.go +170 -0
- package/x/vlocalchain/alias.go +19 -0
- package/x/vlocalchain/handler.go +21 -0
- package/x/vlocalchain/keeper/keeper.go +279 -0
- package/x/vlocalchain/keeper/keeper_test.go +97 -0
- package/x/vlocalchain/types/codec.go +34 -0
- package/x/vlocalchain/types/key.go +27 -0
- package/x/vlocalchain/types/msgs.go +16 -0
- package/x/vlocalchain/types/vlocalchain.pb.go +1072 -0
- package/x/vlocalchain/vlocalchain.go +114 -0
- package/x/vlocalchain/vlocalchain_test.go +434 -0
- package/x/vstorage/README.md +138 -0
- package/x/vstorage/capdata/capdata.go +298 -0
- package/x/vstorage/capdata/capdata_test.go +352 -0
- package/x/vstorage/client/cli/query.go +51 -4
- package/x/vstorage/handler.go +2 -1
- package/x/vstorage/keeper/grpc_query.go +220 -0
- package/x/vstorage/keeper/keeper.go +16 -22
- package/x/vstorage/keeper/keeper_grpc_test.go +300 -0
- package/x/vstorage/keeper/keeper_test.go +1 -1
- package/x/vstorage/keeper/querier.go +11 -6
- package/x/vstorage/keeper/querier_test.go +4 -3
- package/x/vstorage/module.go +0 -5
- package/x/vstorage/testing/queue.go +27 -0
- package/x/vstorage/types/query.pb.go +646 -36
- package/x/vstorage/types/query.pb.gw.go +119 -0
- package/x/vstorage/vstorage.go +16 -15
- package/x/vstorage/vstorage_test.go +5 -5
- package/x/vtransfer/alias.go +13 -0
- package/x/vtransfer/genesis.go +39 -0
- package/x/vtransfer/genesis_test.go +12 -0
- package/x/vtransfer/handler.go +20 -0
- package/x/vtransfer/ibc_middleware.go +186 -0
- package/x/vtransfer/ibc_middleware_test.go +448 -0
- package/x/vtransfer/keeper/keeper.go +281 -0
- package/x/vtransfer/module.go +124 -0
- package/x/vtransfer/types/expected_keepers.go +38 -0
- package/x/vtransfer/types/genesis.pb.go +327 -0
- package/x/vtransfer/types/key.go +9 -0
- package/x/vtransfer/types/msgs.go +9 -0
- package/ante/fee.go +0 -96
- package/proto/agoric/lien/genesis.proto +0 -25
- package/proto/agoric/lien/lien.proto +0 -25
- package/x/lien/alias.go +0 -17
- package/x/lien/genesis.go +0 -58
- package/x/lien/genesis_test.go +0 -101
- package/x/lien/keeper/account.go +0 -290
- package/x/lien/keeper/keeper.go +0 -254
- package/x/lien/keeper/keeper_test.go +0 -623
- package/x/lien/lien.go +0 -203
- package/x/lien/lien_test.go +0 -529
- package/x/lien/module.go +0 -115
- package/x/lien/spec/01_concepts.md +0 -146
- package/x/lien/spec/02_messages.md +0 -96
- package/x/lien/types/accountkeeper.go +0 -81
- package/x/lien/types/accountstate.go +0 -27
- package/x/lien/types/expected_keepers.go +0 -18
- package/x/lien/types/genesis.pb.go +0 -567
- package/x/lien/types/key.go +0 -25
- package/x/lien/types/lien.pb.go +0 -403
- package/x/vibc/ibc.go +0 -393
- /package/{src/index.cjs → index.cjs} +0 -0
package/x/vibc/keeper/keeper.go
CHANGED
|
@@ -4,63 +4,77 @@ import (
|
|
|
4
4
|
"fmt"
|
|
5
5
|
|
|
6
6
|
"github.com/cosmos/cosmos-sdk/codec"
|
|
7
|
+
storetypes "github.com/cosmos/cosmos-sdk/store/types"
|
|
7
8
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper"
|
|
10
|
+
sdkioerrors "cosmossdk.io/errors"
|
|
11
11
|
capability "github.com/cosmos/cosmos-sdk/x/capability/types"
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
clienttypes "github.com/cosmos/ibc-go/v6/modules/core/02-client/types"
|
|
13
|
+
channeltypes "github.com/cosmos/ibc-go/v6/modules/core/04-channel/types"
|
|
14
|
+
porttypes "github.com/cosmos/ibc-go/v6/modules/core/05-port/types"
|
|
15
|
+
host "github.com/cosmos/ibc-go/v6/modules/core/24-host"
|
|
16
|
+
ibcexported "github.com/cosmos/ibc-go/v6/modules/core/exported"
|
|
16
17
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
vm "github.com/Agoric/agoric-sdk/golang/cosmos/vm"
|
|
18
|
+
"github.com/Agoric/agoric-sdk/golang/cosmos/vm"
|
|
20
19
|
"github.com/Agoric/agoric-sdk/golang/cosmos/x/vibc/types"
|
|
21
20
|
)
|
|
22
21
|
|
|
22
|
+
var (
|
|
23
|
+
_ porttypes.ICS4Wrapper = Keeper{}
|
|
24
|
+
_ types.IBCModuleImpl = Keeper{}
|
|
25
|
+
_ types.ReceiverImpl = Keeper{}
|
|
26
|
+
)
|
|
27
|
+
|
|
23
28
|
// Keeper maintains the link to data storage and exposes getter/setter methods for the various parts of the state machine
|
|
24
29
|
type Keeper struct {
|
|
25
|
-
|
|
26
|
-
cdc codec.Codec
|
|
30
|
+
cdc codec.Codec
|
|
27
31
|
|
|
28
32
|
channelKeeper types.ChannelKeeper
|
|
29
33
|
portKeeper types.PortKeeper
|
|
30
|
-
scopedKeeper capabilitykeeper.ScopedKeeper
|
|
31
|
-
bankKeeper bankkeeper.Keeper
|
|
32
34
|
|
|
33
|
-
|
|
35
|
+
// Filled out by `WithScope`
|
|
36
|
+
scopedKeeper types.ScopedKeeper
|
|
37
|
+
storeKey storetypes.StoreKey
|
|
38
|
+
pushAction vm.ActionPusher
|
|
34
39
|
}
|
|
35
40
|
|
|
36
|
-
// NewKeeper creates a new
|
|
41
|
+
// NewKeeper creates a new vibc Keeper instance
|
|
37
42
|
func NewKeeper(
|
|
38
|
-
cdc codec.Codec,
|
|
39
|
-
channelKeeper types.ChannelKeeper,
|
|
40
|
-
|
|
41
|
-
scopedKeeper capabilitykeeper.ScopedKeeper,
|
|
42
|
-
pushAction vm.ActionPusher,
|
|
43
|
+
cdc codec.Codec,
|
|
44
|
+
channelKeeper types.ChannelKeeper,
|
|
45
|
+
portKeeper types.PortKeeper,
|
|
43
46
|
) Keeper {
|
|
44
47
|
|
|
45
48
|
return Keeper{
|
|
46
|
-
storeKey: key,
|
|
47
49
|
cdc: cdc,
|
|
48
|
-
bankKeeper: bankKeeper,
|
|
49
50
|
channelKeeper: channelKeeper,
|
|
50
51
|
portKeeper: portKeeper,
|
|
51
|
-
scopedKeeper: scopedKeeper,
|
|
52
|
-
PushAction: pushAction,
|
|
53
52
|
}
|
|
54
53
|
}
|
|
55
54
|
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
// WithScope returns a new Keeper copied from the receiver, but with the given
|
|
56
|
+
// store key, scoped keeper, and push action.
|
|
57
|
+
func (k Keeper) WithScope(storeKey storetypes.StoreKey, scopedKeeper types.ScopedKeeper, pushAction vm.ActionPusher) Keeper {
|
|
58
|
+
k.storeKey = storeKey
|
|
59
|
+
k.scopedKeeper = scopedKeeper
|
|
60
|
+
k.pushAction = pushAction
|
|
61
|
+
return k
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// PushAction sends a vm.Action to the VM controller.
|
|
65
|
+
func (k Keeper) PushAction(ctx sdk.Context, action vm.Action) error {
|
|
66
|
+
return k.pushAction(ctx, action)
|
|
58
67
|
}
|
|
59
68
|
|
|
60
|
-
//
|
|
69
|
+
// GetICS4Wrapper returns the ICS4Wrapper interface for the keeper.
|
|
70
|
+
func (k Keeper) GetICS4Wrapper() porttypes.ICS4Wrapper {
|
|
71
|
+
return k
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// GetAppVersion defines a wrapper function for the channel Keeper's function
|
|
61
75
|
// in order to expose it to the vibc IBC handler.
|
|
62
|
-
func (k Keeper)
|
|
63
|
-
return k.channelKeeper.
|
|
76
|
+
func (k Keeper) GetAppVersion(ctx sdk.Context, portID, channelID string) (string, bool) {
|
|
77
|
+
return k.channelKeeper.GetAppVersion(ctx, portID, channelID)
|
|
64
78
|
}
|
|
65
79
|
|
|
66
80
|
// GetChannel defines a wrapper function for the channel Keeper's function
|
|
@@ -69,15 +83,14 @@ func (k Keeper) GetChannel(ctx sdk.Context, portID, channelID string) (channelty
|
|
|
69
83
|
return k.channelKeeper.GetChannel(ctx, portID, channelID)
|
|
70
84
|
}
|
|
71
85
|
|
|
72
|
-
//
|
|
73
|
-
|
|
74
|
-
func (k Keeper) ChanOpenInit(ctx sdk.Context, order channeltypes.Order, connectionHops []string,
|
|
86
|
+
// ReceiveChanOpenInit wraps the keeper's ChanOpenInit function.
|
|
87
|
+
func (k Keeper) ReceiveChanOpenInit(ctx sdk.Context, order channeltypes.Order, connectionHops []string,
|
|
75
88
|
portID, rPortID, version string,
|
|
76
89
|
) error {
|
|
77
90
|
capName := host.PortPath(portID)
|
|
78
91
|
portCap, ok := k.GetCapability(ctx, capName)
|
|
79
92
|
if !ok {
|
|
80
|
-
return
|
|
93
|
+
return sdkioerrors.Wrapf(porttypes.ErrInvalidPort, "could not retrieve port capability at: %s", capName)
|
|
81
94
|
}
|
|
82
95
|
counterparty := channeltypes.Counterparty{
|
|
83
96
|
PortId: rPortID,
|
|
@@ -96,56 +109,79 @@ func (k Keeper) ChanOpenInit(ctx sdk.Context, order channeltypes.Order, connecti
|
|
|
96
109
|
return nil
|
|
97
110
|
}
|
|
98
111
|
|
|
99
|
-
//
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
112
|
+
// ReceiveSendPacket wraps the keeper's SendPacket function.
|
|
113
|
+
func (k Keeper) ReceiveSendPacket(ctx sdk.Context, packet ibcexported.PacketI) (uint64, error) {
|
|
114
|
+
sourcePort := packet.GetSourcePort()
|
|
115
|
+
sourceChannel := packet.GetSourceChannel()
|
|
116
|
+
timeoutHeight := packet.GetTimeoutHeight()
|
|
117
|
+
timeoutRevisionNumber := timeoutHeight.GetRevisionNumber()
|
|
118
|
+
timeoutRevisionHeight := timeoutHeight.GetRevisionHeight()
|
|
119
|
+
clientTimeoutHeight := clienttypes.NewHeight(timeoutRevisionNumber, timeoutRevisionHeight)
|
|
120
|
+
timeoutTimestamp := packet.GetTimeoutTimestamp()
|
|
121
|
+
data := packet.GetData()
|
|
122
|
+
|
|
123
|
+
capName := host.ChannelCapabilityPath(sourcePort, sourceChannel)
|
|
105
124
|
chanCap, ok := k.GetCapability(ctx, capName)
|
|
106
125
|
if !ok {
|
|
107
|
-
return
|
|
126
|
+
return 0, sdkioerrors.Wrapf(channeltypes.ErrChannelCapabilityNotFound, "could not retrieve channel capability at: %s", capName)
|
|
108
127
|
}
|
|
109
|
-
return k.
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
var _ ibcexported.Acknowledgement = (*rawAcknowledgement)(nil)
|
|
113
|
-
|
|
114
|
-
type rawAcknowledgement struct {
|
|
115
|
-
data []byte
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
func (r rawAcknowledgement) Acknowledgement() []byte {
|
|
119
|
-
return r.data
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
func (r rawAcknowledgement) Success() bool {
|
|
123
|
-
return true
|
|
128
|
+
return k.SendPacket(ctx, chanCap, sourcePort, sourceChannel, clientTimeoutHeight, timeoutTimestamp, data)
|
|
124
129
|
}
|
|
125
130
|
|
|
126
|
-
//
|
|
131
|
+
// SendPacket defines a wrapper function for the channel Keeper's function
|
|
127
132
|
// in order to expose it to the vibc IBC handler.
|
|
128
|
-
func (k Keeper)
|
|
133
|
+
func (k Keeper) SendPacket(
|
|
134
|
+
ctx sdk.Context,
|
|
135
|
+
chanCap *capability.Capability,
|
|
136
|
+
sourcePort string,
|
|
137
|
+
sourceChannel string,
|
|
138
|
+
timeoutHeight clienttypes.Height,
|
|
139
|
+
timeoutTimestamp uint64,
|
|
140
|
+
data []byte,
|
|
141
|
+
) (uint64, error) {
|
|
142
|
+
return k.channelKeeper.SendPacket(ctx, chanCap, sourcePort, sourceChannel, timeoutHeight, timeoutTimestamp, data)
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// ReceiveWriteAcknowledgement wraps the keeper's WriteAcknowledgment function.
|
|
146
|
+
func (k Keeper) ReceiveWriteAcknowledgement(ctx sdk.Context, packet ibcexported.PacketI, ack ibcexported.Acknowledgement) error {
|
|
129
147
|
portID := packet.GetDestPort()
|
|
130
148
|
channelID := packet.GetDestChannel()
|
|
131
149
|
capName := host.ChannelCapabilityPath(portID, channelID)
|
|
132
150
|
chanCap, ok := k.GetCapability(ctx, capName)
|
|
133
151
|
if !ok {
|
|
134
|
-
return
|
|
135
|
-
}
|
|
136
|
-
ack := rawAcknowledgement{
|
|
137
|
-
data: acknowledgement,
|
|
152
|
+
return sdkioerrors.Wrapf(channeltypes.ErrChannelCapabilityNotFound, "could not retrieve channel capability at: %s", capName)
|
|
138
153
|
}
|
|
154
|
+
return k.WriteAcknowledgement(ctx, chanCap, packet, ack)
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// WriteAcknowledgement defines a wrapper function for the channel Keeper's function
|
|
158
|
+
// in order to expose it to the vibc IBC handler.
|
|
159
|
+
func (k Keeper) WriteAcknowledgement(ctx sdk.Context, chanCap *capability.Capability, packet ibcexported.PacketI, ack ibcexported.Acknowledgement) error {
|
|
139
160
|
return k.channelKeeper.WriteAcknowledgement(ctx, chanCap, packet, ack)
|
|
140
161
|
}
|
|
141
162
|
|
|
142
|
-
//
|
|
163
|
+
// ReceiveWriteOpenTryChannel wraps the keeper's WriteOpenTryChannel function.
|
|
164
|
+
func (k Keeper) ReceiveWriteOpenTryChannel(ctx sdk.Context, packet ibcexported.PacketI, order channeltypes.Order, connectionHops []string, version string) error {
|
|
165
|
+
portID := packet.GetDestPort()
|
|
166
|
+
channelID := packet.GetDestChannel()
|
|
167
|
+
counterparty := channeltypes.NewCounterparty(packet.GetSourcePort(), packet.GetSourceChannel())
|
|
168
|
+
k.WriteOpenTryChannel(ctx, portID, channelID, order, connectionHops, counterparty, version)
|
|
169
|
+
return nil
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// WriteOpenTryChannel is a wrapper function for the channel Keeper's function
|
|
173
|
+
func (k Keeper) WriteOpenTryChannel(ctx sdk.Context, portID, channelID string, order channeltypes.Order,
|
|
174
|
+
connectionHops []string, counterparty channeltypes.Counterparty, version string) {
|
|
175
|
+
k.channelKeeper.WriteOpenTryChannel(ctx, portID, channelID, order, connectionHops, counterparty, version)
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// ReceiveChanCloseInit is a wrapper function for the channel Keeper's function
|
|
143
179
|
// in order to expose it to the vibc IBC handler.
|
|
144
|
-
func (k Keeper)
|
|
180
|
+
func (k Keeper) ReceiveChanCloseInit(ctx sdk.Context, portID, channelID string) error {
|
|
145
181
|
capName := host.ChannelCapabilityPath(portID, channelID)
|
|
146
182
|
chanCap, ok := k.GetCapability(ctx, capName)
|
|
147
183
|
if !ok {
|
|
148
|
-
return
|
|
184
|
+
return sdkioerrors.Wrapf(channeltypes.ErrChannelCapabilityNotFound, "could not retrieve channel capability at: %s", capName)
|
|
149
185
|
}
|
|
150
186
|
err := k.channelKeeper.ChanCloseInit(ctx, portID, channelID, chanCap)
|
|
151
187
|
if err != nil {
|
|
@@ -154,36 +190,38 @@ func (k Keeper) ChanCloseInit(ctx sdk.Context, portID, channelID string) error {
|
|
|
154
190
|
return nil
|
|
155
191
|
}
|
|
156
192
|
|
|
157
|
-
//
|
|
158
|
-
//
|
|
159
|
-
func (k Keeper)
|
|
160
|
-
|
|
193
|
+
// ReceiveBindPort is a wrapper function for the port Keeper's function in order
|
|
194
|
+
// to expose it to the vibc IBC handler.
|
|
195
|
+
func (k Keeper) ReceiveBindPort(ctx sdk.Context, portID string) error {
|
|
196
|
+
portPath := host.PortPath(portID)
|
|
197
|
+
_, ok := k.GetCapability(ctx, portPath)
|
|
161
198
|
if ok {
|
|
162
199
|
return fmt.Errorf("port %s is already bound", portID)
|
|
163
200
|
}
|
|
164
201
|
cap := k.portKeeper.BindPort(ctx, portID)
|
|
165
|
-
return k.ClaimCapability(ctx, cap,
|
|
202
|
+
return k.ClaimCapability(ctx, cap, portPath)
|
|
166
203
|
}
|
|
167
204
|
|
|
168
|
-
//
|
|
169
|
-
// in order to expose it to the vibc IBC handler.
|
|
170
|
-
func (k Keeper)
|
|
205
|
+
// ReceiveTimeoutExecuted is a wrapper function for the channel Keeper's
|
|
206
|
+
// function in order to expose it to the vibc IBC handler.
|
|
207
|
+
func (k Keeper) ReceiveTimeoutExecuted(ctx sdk.Context, packet ibcexported.PacketI) error {
|
|
171
208
|
portID := packet.GetSourcePort()
|
|
172
209
|
channelID := packet.GetSourceChannel()
|
|
173
210
|
capName := host.ChannelCapabilityPath(portID, channelID)
|
|
174
211
|
chanCap, ok := k.GetCapability(ctx, capName)
|
|
175
212
|
if !ok {
|
|
176
|
-
return
|
|
213
|
+
return sdkioerrors.Wrapf(channeltypes.ErrChannelCapabilityNotFound, "could not retrieve channel capability at: %s", capName)
|
|
177
214
|
}
|
|
178
215
|
return k.channelKeeper.TimeoutExecuted(ctx, chanCap, packet)
|
|
179
216
|
}
|
|
180
217
|
|
|
181
218
|
// ClaimCapability allows the vibc module to claim a capability that IBC module
|
|
182
|
-
// passes to it
|
|
219
|
+
// passes to it.
|
|
183
220
|
func (k Keeper) ClaimCapability(ctx sdk.Context, cap *capability.Capability, name string) error {
|
|
184
221
|
return k.scopedKeeper.ClaimCapability(ctx, cap, name)
|
|
185
222
|
}
|
|
186
223
|
|
|
224
|
+
// GetCapability allows the vibc module to retrieve a capability.
|
|
187
225
|
func (k Keeper) GetCapability(ctx sdk.Context, name string) (*capability.Capability, bool) {
|
|
188
226
|
return k.scopedKeeper.GetCapability(ctx, name)
|
|
189
227
|
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
package keeper
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
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
|
+
ibcexported "github.com/cosmos/ibc-go/v6/modules/core/exported"
|
|
9
|
+
|
|
10
|
+
"github.com/Agoric/agoric-sdk/golang/cosmos/vm"
|
|
11
|
+
"github.com/Agoric/agoric-sdk/golang/cosmos/x/vibc/types"
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
func reifyPacket(packet ibcexported.PacketI) channeltypes.Packet {
|
|
15
|
+
height := packet.GetTimeoutHeight()
|
|
16
|
+
ctHeight := clienttypes.Height{
|
|
17
|
+
RevisionHeight: height.GetRevisionHeight(),
|
|
18
|
+
RevisionNumber: height.GetRevisionNumber(),
|
|
19
|
+
}
|
|
20
|
+
return channeltypes.Packet{
|
|
21
|
+
Sequence: packet.GetSequence(),
|
|
22
|
+
SourcePort: packet.GetSourcePort(),
|
|
23
|
+
SourceChannel: packet.GetSourceChannel(),
|
|
24
|
+
DestinationPort: packet.GetDestPort(),
|
|
25
|
+
DestinationChannel: packet.GetDestChannel(),
|
|
26
|
+
Data: packet.GetData(),
|
|
27
|
+
TimeoutHeight: ctHeight,
|
|
28
|
+
TimeoutTimestamp: packet.GetTimeoutTimestamp(),
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
type WriteAcknowledgementEvent struct {
|
|
33
|
+
*vm.ActionHeader `actionType:"IBC_EVENT"`
|
|
34
|
+
Event string `json:"event" default:"writeAcknowledgement"`
|
|
35
|
+
Target string `json:"target"`
|
|
36
|
+
Packet channeltypes.Packet `json:"packet"`
|
|
37
|
+
Acknowledgement []byte `json:"acknowledgement"`
|
|
38
|
+
Relayer sdk.AccAddress `json:"relayer"`
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
func (k Keeper) TriggerWriteAcknowledgement(
|
|
42
|
+
ctx sdk.Context,
|
|
43
|
+
target string,
|
|
44
|
+
packet ibcexported.PacketI,
|
|
45
|
+
acknowledgement ibcexported.Acknowledgement,
|
|
46
|
+
) error {
|
|
47
|
+
event := WriteAcknowledgementEvent{
|
|
48
|
+
Target: target,
|
|
49
|
+
Packet: reifyPacket(packet),
|
|
50
|
+
Acknowledgement: acknowledgement.Acknowledgement(),
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
err := k.PushAction(ctx, event)
|
|
54
|
+
if err != nil {
|
|
55
|
+
return err
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return nil
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
func (k Keeper) TriggerOnAcknowledgementPacket(
|
|
62
|
+
ctx sdk.Context,
|
|
63
|
+
target string,
|
|
64
|
+
packet ibcexported.PacketI,
|
|
65
|
+
acknowledgement []byte,
|
|
66
|
+
relayer sdk.AccAddress,
|
|
67
|
+
) error {
|
|
68
|
+
event := types.AcknowledgementPacketEvent{
|
|
69
|
+
Target: target,
|
|
70
|
+
Packet: reifyPacket(packet),
|
|
71
|
+
Acknowledgement: acknowledgement,
|
|
72
|
+
Relayer: relayer,
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
err := k.PushAction(ctx, event)
|
|
76
|
+
if err != nil {
|
|
77
|
+
return err
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return nil
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
func (k Keeper) TriggerOnTimeoutPacket(
|
|
84
|
+
ctx sdk.Context,
|
|
85
|
+
target string,
|
|
86
|
+
packet ibcexported.PacketI,
|
|
87
|
+
relayer sdk.AccAddress,
|
|
88
|
+
) error {
|
|
89
|
+
event := types.TimeoutPacketEvent{
|
|
90
|
+
Target: target,
|
|
91
|
+
Packet: reifyPacket(packet),
|
|
92
|
+
Relayer: relayer,
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
err := k.PushAction(ctx, event)
|
|
96
|
+
if err != nil {
|
|
97
|
+
return err
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return nil
|
|
101
|
+
}
|
package/x/vibc/module.go
CHANGED
|
@@ -3,7 +3,6 @@ package vibc
|
|
|
3
3
|
import (
|
|
4
4
|
"encoding/json"
|
|
5
5
|
|
|
6
|
-
"github.com/gorilla/mux"
|
|
7
6
|
"github.com/grpc-ecosystem/grpc-gateway/runtime"
|
|
8
7
|
"github.com/spf13/cobra"
|
|
9
8
|
|
|
@@ -51,10 +50,6 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncod
|
|
|
51
50
|
return nil
|
|
52
51
|
}
|
|
53
52
|
|
|
54
|
-
// Register rest routes
|
|
55
|
-
func (AppModuleBasic) RegisterRESTRoutes(ctx client.Context, rtr *mux.Router) {
|
|
56
|
-
}
|
|
57
|
-
|
|
58
53
|
func (AppModuleBasic) RegisterGRPCGatewayRoutes(_ client.Context, _ *runtime.ServeMux) {
|
|
59
54
|
}
|
|
60
55
|
|
|
@@ -70,14 +65,16 @@ func (AppModuleBasic) GetQueryCmd() *cobra.Command {
|
|
|
70
65
|
|
|
71
66
|
type AppModule struct {
|
|
72
67
|
AppModuleBasic
|
|
73
|
-
keeper
|
|
68
|
+
keeper Keeper
|
|
69
|
+
bankKeeper types.BankKeeper
|
|
74
70
|
}
|
|
75
71
|
|
|
76
72
|
// NewAppModule creates a new AppModule Object
|
|
77
|
-
func NewAppModule(k Keeper) AppModule {
|
|
73
|
+
func NewAppModule(k Keeper, bankKeeper types.BankKeeper) AppModule {
|
|
78
74
|
am := AppModule{
|
|
79
75
|
AppModuleBasic: AppModuleBasic{},
|
|
80
76
|
keeper: k,
|
|
77
|
+
bankKeeper: bankKeeper,
|
|
81
78
|
}
|
|
82
79
|
return am
|
|
83
80
|
}
|
|
@@ -104,7 +101,7 @@ func (AppModule) RegisterInvariants(ir sdk.InvariantRegistry) {
|
|
|
104
101
|
|
|
105
102
|
// Route implements the AppModule interface
|
|
106
103
|
func (am AppModule) Route() sdk.Route {
|
|
107
|
-
return sdk.NewRoute(RouterKey, NewHandler(am.keeper))
|
|
104
|
+
return sdk.NewRoute(RouterKey, NewHandler(am.keeper, am.bankKeeper))
|
|
108
105
|
}
|
|
109
106
|
|
|
110
107
|
// QuerierRoute implements the AppModule interface
|
|
@@ -3,21 +3,36 @@ package types
|
|
|
3
3
|
import (
|
|
4
4
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
5
5
|
capability "github.com/cosmos/cosmos-sdk/x/capability/types"
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
clienttypes "github.com/cosmos/ibc-go/v6/modules/core/02-client/types"
|
|
7
|
+
connection "github.com/cosmos/ibc-go/v6/modules/core/03-connection/types"
|
|
8
|
+
channel "github.com/cosmos/ibc-go/v6/modules/core/04-channel/types"
|
|
9
|
+
ibcexported "github.com/cosmos/ibc-go/v6/modules/core/exported"
|
|
9
10
|
)
|
|
10
11
|
|
|
12
|
+
type BankKeeper interface {
|
|
13
|
+
GetBalance(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin
|
|
14
|
+
}
|
|
15
|
+
|
|
11
16
|
// ChannelKeeper defines the expected IBC channel keeper
|
|
12
17
|
type ChannelKeeper interface {
|
|
18
|
+
GetAppVersion(ctx sdk.Context, portID, channelID string) (string, bool)
|
|
13
19
|
GetChannel(ctx sdk.Context, srcPort, srcChan string) (channel channel.Channel, found bool)
|
|
14
|
-
|
|
15
|
-
|
|
20
|
+
SendPacket(
|
|
21
|
+
ctx sdk.Context,
|
|
22
|
+
channelCap *capability.Capability,
|
|
23
|
+
sourcePort string,
|
|
24
|
+
sourceChannel string,
|
|
25
|
+
timeoutHeight clienttypes.Height,
|
|
26
|
+
timeoutTimestamp uint64,
|
|
27
|
+
data []byte,
|
|
28
|
+
) (uint64, error)
|
|
16
29
|
WriteAcknowledgement(ctx sdk.Context, channelCap *capability.Capability, packet ibcexported.PacketI, acknowledgement ibcexported.Acknowledgement) error
|
|
17
30
|
ChanOpenInit(ctx sdk.Context, order channel.Order, connectionHops []string, portID string,
|
|
18
31
|
portCap *capability.Capability, counterparty channel.Counterparty, version string) (string, *capability.Capability, error)
|
|
19
32
|
WriteOpenInitChannel(ctx sdk.Context, portID, channelID string, order channel.Order,
|
|
20
33
|
connectionHops []string, counterparty channel.Counterparty, version string)
|
|
34
|
+
WriteOpenTryChannel(ctx sdk.Context, portID, channelID string, order channel.Order,
|
|
35
|
+
connectionHops []string, counterparty channel.Counterparty, version string)
|
|
21
36
|
ChanCloseInit(ctx sdk.Context, portID, channelID string, chanCap *capability.Capability) error
|
|
22
37
|
TimeoutExecuted(ctx sdk.Context, channelCap *capability.Capability, packet ibcexported.PacketI) error
|
|
23
38
|
}
|
|
@@ -36,3 +51,9 @@ type ConnectionKeeper interface {
|
|
|
36
51
|
type PortKeeper interface {
|
|
37
52
|
BindPort(ctx sdk.Context, portID string) *capability.Capability
|
|
38
53
|
}
|
|
54
|
+
|
|
55
|
+
// ScopedKeeper defines the expected scoped capability keeper
|
|
56
|
+
type ScopedKeeper interface {
|
|
57
|
+
ClaimCapability(ctx sdk.Context, cap *capability.Capability, name string) error
|
|
58
|
+
GetCapability(ctx sdk.Context, name string) (*capability.Capability, bool)
|
|
59
|
+
}
|