Update IBC host keys + cleanup (#7873)
* init changes * cleanup keys and remove redunancdy * revert unintentional changes * KeyChannel -> ChannelKey
This commit is contained in:
parent
fdcb028636
commit
300b7393ad
@ -109,7 +109,7 @@ func (suite *KeeperTestSuite) TestSendTransfer() {
|
||||
packet := channeltypes.NewPacket(fungibleTokenPacket.GetBytes(), 1, channelB.PortID, channelB.ID, channelA.PortID, channelA.ID, clienttypes.NewHeight(0, 110), 0)
|
||||
|
||||
// get proof of packet commitment from chainB
|
||||
packetKey := host.KeyPacketCommitment(packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence())
|
||||
packetKey := host.PacketCommitmentKey(packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence())
|
||||
proof, proofHeight := suite.chainB.QueryProof(packetKey)
|
||||
|
||||
recvMsg := channeltypes.NewMsgRecvPacket(packet, proof, proofHeight, suite.chainA.SenderAccount.GetAddress())
|
||||
|
||||
@ -38,7 +38,7 @@ func QueryClientState(
|
||||
func QueryClientStateABCI(
|
||||
clientCtx client.Context, clientID string,
|
||||
) (*types.QueryClientStateResponse, error) {
|
||||
key := host.FullKeyClientPath(clientID, host.KeyClientState())
|
||||
key := host.FullClientStateKey(clientID)
|
||||
|
||||
value, proofBz, proofHeight, err := ibcclient.QueryTendermintProof(clientCtx, key)
|
||||
if err != nil {
|
||||
@ -91,7 +91,7 @@ func QueryConsensusState(
|
||||
func QueryConsensusStateABCI(
|
||||
clientCtx client.Context, clientID string, height exported.Height,
|
||||
) (*types.QueryConsensusStateResponse, error) {
|
||||
key := host.FullKeyClientPath(clientID, host.KeyConsensusState(height))
|
||||
key := host.FullConsensusStateKey(clientID, height)
|
||||
|
||||
value, proofBz, proofHeight, err := ibcclient.QueryTendermintProof(clientCtx, key)
|
||||
if err != nil {
|
||||
|
||||
@ -152,7 +152,7 @@ func (q Keeper) ConsensusStates(c context.Context, req *types.QueryConsensusStat
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
|
||||
consensusStates := []types.ConsensusStateWithHeight{}
|
||||
store := prefix.NewStore(ctx.KVStore(q.storeKey), host.FullKeyClientPath(req.ClientId, []byte(fmt.Sprintf("%s/", host.KeyConsensusStatesPrefix))))
|
||||
store := prefix.NewStore(ctx.KVStore(q.storeKey), host.FullClientKey(req.ClientId, []byte(fmt.Sprintf("%s/", host.KeyConsensusStatePrefix))))
|
||||
|
||||
pageRes, err := query.Paginate(store, req.Pagination, func(key, value []byte) error {
|
||||
height, err := types.ParseHeight(string(key))
|
||||
|
||||
@ -46,7 +46,7 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger {
|
||||
// GetClientState gets a particular client from the store
|
||||
func (k Keeper) GetClientState(ctx sdk.Context, clientID string) (exported.ClientState, bool) {
|
||||
store := k.ClientStore(ctx, clientID)
|
||||
bz := store.Get(host.KeyClientState())
|
||||
bz := store.Get(host.ClientStateKey())
|
||||
if bz == nil {
|
||||
return nil, false
|
||||
}
|
||||
@ -58,13 +58,13 @@ func (k Keeper) GetClientState(ctx sdk.Context, clientID string) (exported.Clien
|
||||
// SetClientState sets a particular Client to the store
|
||||
func (k Keeper) SetClientState(ctx sdk.Context, clientID string, clientState exported.ClientState) {
|
||||
store := k.ClientStore(ctx, clientID)
|
||||
store.Set(host.KeyClientState(), k.MustMarshalClientState(clientState))
|
||||
store.Set(host.ClientStateKey(), k.MustMarshalClientState(clientState))
|
||||
}
|
||||
|
||||
// GetClientConsensusState gets the stored consensus state from a client at a given height.
|
||||
func (k Keeper) GetClientConsensusState(ctx sdk.Context, clientID string, height exported.Height) (exported.ConsensusState, bool) {
|
||||
store := k.ClientStore(ctx, clientID)
|
||||
bz := store.Get(host.KeyConsensusState(height))
|
||||
bz := store.Get(host.ConsensusStateKey(height))
|
||||
if bz == nil {
|
||||
return nil, false
|
||||
}
|
||||
@ -77,7 +77,7 @@ func (k Keeper) GetClientConsensusState(ctx sdk.Context, clientID string, height
|
||||
// height
|
||||
func (k Keeper) SetClientConsensusState(ctx sdk.Context, clientID string, height exported.Height, consensusState exported.ConsensusState) {
|
||||
store := k.ClientStore(ctx, clientID)
|
||||
store.Set(host.KeyConsensusState(height), k.MustMarshalConsensusState(consensusState))
|
||||
store.Set(host.ConsensusStateKey(height), k.MustMarshalConsensusState(consensusState))
|
||||
}
|
||||
|
||||
// IterateConsensusStates provides an iterator over all stored consensus states.
|
||||
@ -91,7 +91,7 @@ func (k Keeper) IterateConsensusStates(ctx sdk.Context, cb func(clientID string,
|
||||
for ; iterator.Valid(); iterator.Next() {
|
||||
keySplit := strings.Split(string(iterator.Key()), "/")
|
||||
// consensus key is in the format "clients/<clientID>/consensusStates/<height>"
|
||||
if len(keySplit) != 4 || keySplit[2] != string(host.KeyConsensusStatesPrefix) {
|
||||
if len(keySplit) != 4 || keySplit[2] != string(host.KeyConsensusStatePrefix) {
|
||||
continue
|
||||
}
|
||||
clientID := keySplit[1]
|
||||
@ -144,7 +144,7 @@ func (k Keeper) GetAllConsensusStates(ctx sdk.Context) types.ClientsConsensusSta
|
||||
// client at the given height
|
||||
func (k Keeper) HasClientConsensusState(ctx sdk.Context, clientID string, height exported.Height) bool {
|
||||
store := k.ClientStore(ctx, clientID)
|
||||
return store.Has(host.KeyConsensusState(height))
|
||||
return store.Has(host.ConsensusStateKey(height))
|
||||
}
|
||||
|
||||
// GetLatestClientConsensusState gets the latest ConsensusState stored for a given client
|
||||
@ -266,7 +266,7 @@ func (k Keeper) IterateClients(ctx sdk.Context, cb func(clientID string, cs expo
|
||||
defer iterator.Close()
|
||||
for ; iterator.Valid(); iterator.Next() {
|
||||
keySplit := strings.Split(string(iterator.Key()), "/")
|
||||
if keySplit[len(keySplit)-1] != "clientState" {
|
||||
if keySplit[len(keySplit)-1] != host.KeyClientState {
|
||||
continue
|
||||
}
|
||||
clientState := k.MustUnmarshalClientState(iterator.Value())
|
||||
@ -291,8 +291,6 @@ func (k Keeper) GetAllClients(ctx sdk.Context) (states []exported.ClientState) {
|
||||
// ClientStore returns isolated prefix store for each client so they can read/write in separate
|
||||
// namespace without being able to read/write other client's data
|
||||
func (k Keeper) ClientStore(ctx sdk.Context, clientID string) sdk.KVStore {
|
||||
// append here is safe, appends within a function won't cause
|
||||
// weird side effects when its singlethreaded
|
||||
clientPrefix := append([]byte("clients/"+clientID), '/')
|
||||
clientPrefix := []byte(fmt.Sprintf("%s/%s/", host.KeyClientStorePrefix, clientID))
|
||||
return prefix.NewStore(ctx.KVStore(k.storeKey), clientPrefix)
|
||||
}
|
||||
|
||||
@ -22,12 +22,12 @@ type ClientUnmarshaler interface {
|
||||
// Value to the corresponding client type.
|
||||
func NewDecodeStore(cdc ClientUnmarshaler, kvA, kvB kv.Pair) (string, bool) {
|
||||
switch {
|
||||
case bytes.HasPrefix(kvA.Key, host.KeyClientStorePrefix) && bytes.HasSuffix(kvA.Key, host.KeyClientState()):
|
||||
case bytes.HasPrefix(kvA.Key, host.KeyClientStorePrefix) && bytes.HasSuffix(kvA.Key, []byte(host.KeyClientState)):
|
||||
clientStateA := cdc.MustUnmarshalClientState(kvA.Value)
|
||||
clientStateB := cdc.MustUnmarshalClientState(kvB.Value)
|
||||
return fmt.Sprintf("ClientState A: %v\nClientState B: %v", clientStateA, clientStateB), true
|
||||
|
||||
case bytes.HasPrefix(kvA.Key, host.KeyClientStorePrefix) && bytes.Contains(kvA.Key, []byte("consensusState")):
|
||||
case bytes.HasPrefix(kvA.Key, host.KeyClientStorePrefix) && bytes.Contains(kvA.Key, []byte(host.KeyConsensusStatePrefix)):
|
||||
consensusStateA := cdc.MustUnmarshalConsensusState(kvA.Value)
|
||||
consensusStateB := cdc.MustUnmarshalConsensusState(kvB.Value)
|
||||
return fmt.Sprintf("ConsensusState A: %v\nConsensusState B: %v", consensusStateA, consensusStateB), true
|
||||
|
||||
@ -32,11 +32,11 @@ func TestDecodeStore(t *testing.T) {
|
||||
kvPairs := kv.Pairs{
|
||||
Pairs: []kv.Pair{
|
||||
{
|
||||
Key: host.FullKeyClientPath(clientID, host.KeyClientState()),
|
||||
Key: host.FullClientStateKey(clientID),
|
||||
Value: app.IBCKeeper.ClientKeeper.MustMarshalClientState(clientState),
|
||||
},
|
||||
{
|
||||
Key: host.FullKeyClientPath(clientID, host.KeyConsensusState(height)),
|
||||
Key: host.FullConsensusStateKey(clientID, height),
|
||||
Value: app.IBCKeeper.ClientKeeper.MustMarshalConsensusState(consState),
|
||||
},
|
||||
{
|
||||
|
||||
@ -38,7 +38,7 @@ func QueryConnection(
|
||||
}
|
||||
|
||||
func queryConnectionABCI(clientCtx client.Context, connectionID string) (*types.QueryConnectionResponse, error) {
|
||||
key := host.KeyConnection(connectionID)
|
||||
key := host.ConnectionKey(connectionID)
|
||||
|
||||
value, proofBz, proofHeight, err := ibcclient.QueryTendermintProof(clientCtx, key)
|
||||
if err != nil {
|
||||
@ -79,7 +79,7 @@ func QueryClientConnections(
|
||||
}
|
||||
|
||||
func queryClientConnectionsABCI(clientCtx client.Context, clientID string) (*types.QueryClientConnectionsResponse, error) {
|
||||
key := host.KeyClientConnections(clientID)
|
||||
key := host.ClientConnectionsKey(clientID)
|
||||
|
||||
value, proofBz, proofHeight, err := ibcclient.QueryTendermintProof(clientCtx, key)
|
||||
if err != nil {
|
||||
|
||||
@ -51,7 +51,7 @@ func (q Keeper) Connections(c context.Context, req *types.QueryConnectionsReques
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
|
||||
connections := []*types.IdentifiedConnection{}
|
||||
store := prefix.NewStore(ctx.KVStore(q.storeKey), host.KeyConnectionPrefix)
|
||||
store := prefix.NewStore(ctx.KVStore(q.storeKey), []byte(host.KeyConnectionPrefix))
|
||||
|
||||
pageRes, err := query.Paginate(store, req.Pagination, func(key, value []byte) error {
|
||||
var result types.ConnectionEnd
|
||||
|
||||
@ -306,18 +306,18 @@ func (suite *KeeperTestSuite) TestConnOpenTry() {
|
||||
counterpartyChosenConnectionID = connection.Counterparty.ConnectionId
|
||||
}
|
||||
|
||||
connectionKey := host.KeyConnection(connA.ID)
|
||||
connectionKey := host.ConnectionKey(connA.ID)
|
||||
proofInit, proofHeight := suite.chainA.QueryProof(connectionKey)
|
||||
|
||||
if consensusHeight.IsZero() {
|
||||
// retrieve consensus state height to provide proof for
|
||||
consensusHeight = counterpartyClient.GetLatestHeight()
|
||||
}
|
||||
consensusKey := host.FullKeyClientPath(clientA, host.KeyConsensusState(consensusHeight))
|
||||
consensusKey := host.FullConsensusStateKey(clientA, consensusHeight)
|
||||
proofConsensus, _ := suite.chainA.QueryProof(consensusKey)
|
||||
|
||||
// retrieve proof of counterparty clientstate on chainA
|
||||
clientKey := host.FullKeyClientPath(clientA, host.KeyClientState())
|
||||
clientKey := host.FullClientStateKey(clientA)
|
||||
proofClient, _ := suite.chainA.QueryProof(clientKey)
|
||||
|
||||
err := suite.chainB.App.IBCKeeper.ConnectionKeeper.ConnOpenTry(
|
||||
@ -661,10 +661,10 @@ func (suite *KeeperTestSuite) TestConnOpenAck() {
|
||||
for _, tc := range testCases {
|
||||
tc := tc
|
||||
suite.Run(tc.msg, func() {
|
||||
suite.SetupTest() // reset
|
||||
suite.SetupTest() // reset
|
||||
version = types.ExportedVersionsToProto(types.GetCompatibleVersions())[0] // must be explicitly changed in malleate
|
||||
consensusHeight = clienttypes.ZeroHeight() // must be explicitly changed in malleate
|
||||
counterpartyConnectionID = "" // must be explicitly changed in malleate
|
||||
consensusHeight = clienttypes.ZeroHeight() // must be explicitly changed in malleate
|
||||
counterpartyConnectionID = "" // must be explicitly changed in malleate
|
||||
|
||||
tc.malleate()
|
||||
|
||||
@ -675,7 +675,7 @@ func (suite *KeeperTestSuite) TestConnOpenAck() {
|
||||
counterpartyConnectionID = connB.ID
|
||||
}
|
||||
|
||||
connectionKey := host.KeyConnection(connB.ID)
|
||||
connectionKey := host.ConnectionKey(connB.ID)
|
||||
proofTry, proofHeight := suite.chainB.QueryProof(connectionKey)
|
||||
|
||||
if consensusHeight.IsZero() {
|
||||
@ -683,11 +683,11 @@ func (suite *KeeperTestSuite) TestConnOpenAck() {
|
||||
clientState := suite.chainB.GetClientState(clientB)
|
||||
consensusHeight = clientState.GetLatestHeight()
|
||||
}
|
||||
consensusKey := host.FullKeyClientPath(clientB, host.KeyConsensusState(consensusHeight))
|
||||
consensusKey := host.FullConsensusStateKey(clientB, consensusHeight)
|
||||
proofConsensus, _ := suite.chainB.QueryProof(consensusKey)
|
||||
|
||||
// retrieve proof of counterparty clientstate on chainA
|
||||
clientKey := host.FullKeyClientPath(clientB, host.KeyClientState())
|
||||
clientKey := host.FullClientStateKey(clientB)
|
||||
proofClient, _ := suite.chainB.QueryProof(clientKey)
|
||||
|
||||
err := suite.chainA.App.IBCKeeper.ConnectionKeeper.ConnOpenAck(
|
||||
@ -757,7 +757,7 @@ func (suite *KeeperTestSuite) TestConnOpenConfirm() {
|
||||
connA := suite.chainA.GetFirstTestConnection(clientA, clientB)
|
||||
connB := suite.chainB.GetFirstTestConnection(clientB, clientA)
|
||||
|
||||
connectionKey := host.KeyConnection(connA.ID)
|
||||
connectionKey := host.ConnectionKey(connA.ID)
|
||||
proofAck, proofHeight := suite.chainA.QueryProof(connectionKey)
|
||||
|
||||
err := suite.chainB.App.IBCKeeper.ConnectionKeeper.ConnOpenConfirm(
|
||||
|
||||
@ -48,7 +48,7 @@ func (k Keeper) GetCommitmentPrefix() exported.Prefix {
|
||||
// GetConnection returns a connection with a particular identifier
|
||||
func (k Keeper) GetConnection(ctx sdk.Context, connectionID string) (types.ConnectionEnd, bool) {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
bz := store.Get(host.KeyConnection(connectionID))
|
||||
bz := store.Get(host.ConnectionKey(connectionID))
|
||||
if bz == nil {
|
||||
return types.ConnectionEnd{}, false
|
||||
}
|
||||
@ -63,7 +63,7 @@ func (k Keeper) GetConnection(ctx sdk.Context, connectionID string) (types.Conne
|
||||
func (k Keeper) SetConnection(ctx sdk.Context, connectionID string, connection types.ConnectionEnd) {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
bz := k.cdc.MustMarshalBinaryBare(&connection)
|
||||
store.Set(host.KeyConnection(connectionID), bz)
|
||||
store.Set(host.ConnectionKey(connectionID), bz)
|
||||
}
|
||||
|
||||
// GetTimestampAtHeight returns the timestamp in nanoseconds of the consensus state at the
|
||||
@ -87,7 +87,7 @@ func (k Keeper) GetTimestampAtHeight(ctx sdk.Context, connection types.Connectio
|
||||
// particular client
|
||||
func (k Keeper) GetClientConnectionPaths(ctx sdk.Context, clientID string) ([]string, bool) {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
bz := store.Get(host.KeyClientConnections(clientID))
|
||||
bz := store.Get(host.ClientConnectionsKey(clientID))
|
||||
if bz == nil {
|
||||
return nil, false
|
||||
}
|
||||
@ -102,7 +102,7 @@ func (k Keeper) SetClientConnectionPaths(ctx sdk.Context, clientID string, paths
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
clientPaths := types.ClientPaths{Paths: paths}
|
||||
bz := k.cdc.MustMarshalBinaryBare(&clientPaths)
|
||||
store.Set(host.KeyClientConnections(clientID), bz)
|
||||
store.Set(host.ClientConnectionsKey(clientID), bz)
|
||||
}
|
||||
|
||||
// GetAllClientConnectionPaths returns all stored clients connection id paths. It
|
||||
@ -129,7 +129,7 @@ func (k Keeper) GetAllClientConnectionPaths(ctx sdk.Context) []types.ConnectionP
|
||||
// iterator will close and stop.
|
||||
func (k Keeper) IterateConnections(ctx sdk.Context, cb func(types.IdentifiedConnection) bool) {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
iterator := sdk.KVStorePrefixIterator(store, host.KeyConnectionPrefix)
|
||||
iterator := sdk.KVStorePrefixIterator(store, []byte(host.KeyConnectionPrefix))
|
||||
|
||||
defer iterator.Close()
|
||||
for ; iterator.Valid(); iterator.Next() {
|
||||
|
||||
@ -178,7 +178,7 @@ func (suite *KeeperTestSuite) TestVerifyConnectionState() {
|
||||
}
|
||||
expectedConnection := suite.chainB.GetConnection(connB)
|
||||
|
||||
connectionKey := host.KeyConnection(connB.ID)
|
||||
connectionKey := host.ConnectionKey(connB.ID)
|
||||
proof, proofHeight := suite.chainB.QueryProof(connectionKey)
|
||||
|
||||
if tc.changeConnectionState {
|
||||
@ -227,7 +227,7 @@ func (suite *KeeperTestSuite) TestVerifyChannelState() {
|
||||
connection.ClientId = ibctesting.InvalidID
|
||||
}
|
||||
|
||||
channelKey := host.KeyChannel(channelB.PortID, channelB.ID)
|
||||
channelKey := host.ChannelKey(channelB.PortID, channelB.ID)
|
||||
proof, proofHeight := suite.chainB.QueryProof(channelKey)
|
||||
|
||||
channel := suite.chainB.GetChannel(channelB)
|
||||
@ -282,7 +282,7 @@ func (suite *KeeperTestSuite) TestVerifyPacketCommitment() {
|
||||
err := suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
commitmentKey := host.KeyPacketCommitment(packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence())
|
||||
commitmentKey := host.PacketCommitmentKey(packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence())
|
||||
proof, proofHeight := suite.chainA.QueryProof(commitmentKey)
|
||||
|
||||
if tc.changePacketCommitmentState {
|
||||
@ -340,7 +340,7 @@ func (suite *KeeperTestSuite) TestVerifyPacketAcknowledgement() {
|
||||
err = suite.coordinator.RecvPacket(suite.chainA, suite.chainB, clientA, packet)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
packetAckKey := host.KeyPacketAcknowledgement(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence())
|
||||
packetAckKey := host.PacketAcknowledgementKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence())
|
||||
proof, proofHeight := suite.chainB.QueryProof(packetAckKey)
|
||||
|
||||
ack := ibcmock.MockAcknowledgement
|
||||
@ -405,7 +405,7 @@ func (suite *KeeperTestSuite) TestVerifyPacketReceiptAbsence() {
|
||||
suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint)
|
||||
}
|
||||
|
||||
packetReceiptKey := host.KeyPacketReceipt(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence())
|
||||
packetReceiptKey := host.PacketReceiptKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence())
|
||||
proof, proofHeight := suite.chainB.QueryProof(packetReceiptKey)
|
||||
|
||||
err = suite.chainA.App.IBCKeeper.ConnectionKeeper.VerifyPacketReceiptAbsence(
|
||||
@ -459,7 +459,7 @@ func (suite *KeeperTestSuite) TestVerifyNextSequenceRecv() {
|
||||
err = suite.coordinator.RecvPacket(suite.chainA, suite.chainB, clientA, packet)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
nextSeqRecvKey := host.KeyNextSequenceRecv(packet.GetDestPort(), packet.GetDestChannel())
|
||||
nextSeqRecvKey := host.NextSequenceRecvKey(packet.GetDestPort(), packet.GetDestChannel())
|
||||
proof, proofHeight := suite.chainB.QueryProof(nextSeqRecvKey)
|
||||
|
||||
err = suite.chainA.App.IBCKeeper.ConnectionKeeper.VerifyNextSequenceRecv(
|
||||
|
||||
@ -14,13 +14,13 @@ import (
|
||||
// Value to the corresponding connection type.
|
||||
func NewDecodeStore(cdc codec.BinaryMarshaler, kvA, kvB kv.Pair) (string, bool) {
|
||||
switch {
|
||||
case bytes.HasPrefix(kvA.Key, host.KeyClientStorePrefix) && bytes.HasSuffix(kvA.Key, host.KeyConnectionPrefix):
|
||||
case bytes.HasPrefix(kvA.Key, host.KeyClientStorePrefix) && bytes.HasSuffix(kvA.Key, []byte(host.KeyConnectionPrefix)):
|
||||
var clientConnectionsA, clientConnectionsB types.ClientPaths
|
||||
cdc.MustUnmarshalBinaryBare(kvA.Value, &clientConnectionsA)
|
||||
cdc.MustUnmarshalBinaryBare(kvB.Value, &clientConnectionsB)
|
||||
return fmt.Sprintf("ClientPaths A: %v\nClientPaths B: %v", clientConnectionsA, clientConnectionsB), true
|
||||
|
||||
case bytes.HasPrefix(kvA.Key, host.KeyConnectionPrefix):
|
||||
case bytes.HasPrefix(kvA.Key, []byte(host.KeyConnectionPrefix)):
|
||||
var connectionA, connectionB types.ConnectionEnd
|
||||
cdc.MustUnmarshalBinaryBare(kvA.Value, &connectionA)
|
||||
cdc.MustUnmarshalBinaryBare(kvB.Value, &connectionB)
|
||||
|
||||
@ -31,11 +31,11 @@ func TestDecodeStore(t *testing.T) {
|
||||
kvPairs := kv.Pairs{
|
||||
Pairs: []kv.Pair{
|
||||
{
|
||||
Key: host.KeyClientConnections(connection.ClientId),
|
||||
Key: host.ClientConnectionsKey(connection.ClientId),
|
||||
Value: cdc.MustMarshalBinaryBare(&paths),
|
||||
},
|
||||
{
|
||||
Key: host.KeyConnection(connectionID),
|
||||
Key: host.ConnectionKey(connectionID),
|
||||
Value: cdc.MustMarshalBinaryBare(&connection),
|
||||
},
|
||||
{
|
||||
|
||||
@ -35,7 +35,7 @@ func QueryChannel(
|
||||
}
|
||||
|
||||
func queryChannelABCI(clientCtx client.Context, portID, channelID string) (*types.QueryChannelResponse, error) {
|
||||
key := host.KeyChannel(portID, channelID)
|
||||
key := host.ChannelKey(portID, channelID)
|
||||
|
||||
value, proofBz, proofHeight, err := ibcclient.QueryTendermintProof(clientCtx, key)
|
||||
if err != nil {
|
||||
@ -176,7 +176,7 @@ func QueryNextSequenceReceive(
|
||||
}
|
||||
|
||||
func queryNextSequenceRecvABCI(clientCtx client.Context, portID, channelID string) (*types.QueryNextSequenceReceiveResponse, error) {
|
||||
key := host.KeyNextSequenceRecv(portID, channelID)
|
||||
key := host.NextSequenceRecvKey(portID, channelID)
|
||||
|
||||
value, proofBz, proofHeight, err := ibcclient.QueryTendermintProof(clientCtx, key)
|
||||
if err != nil {
|
||||
@ -217,7 +217,7 @@ func QueryPacketCommitment(
|
||||
func queryPacketCommitmentABCI(
|
||||
clientCtx client.Context, portID, channelID string, sequence uint64,
|
||||
) (*types.QueryPacketCommitmentResponse, error) {
|
||||
key := host.KeyPacketCommitment(portID, channelID, sequence)
|
||||
key := host.PacketCommitmentKey(portID, channelID, sequence)
|
||||
|
||||
value, proofBz, proofHeight, err := ibcclient.QueryTendermintProof(clientCtx, key)
|
||||
if err != nil {
|
||||
@ -256,7 +256,7 @@ func QueryPacketReceipt(
|
||||
func queryPacketReceiptABCI(
|
||||
clientCtx client.Context, portID, channelID string, sequence uint64,
|
||||
) (*types.QueryPacketReceiptResponse, error) {
|
||||
key := host.KeyPacketReceipt(portID, channelID, sequence)
|
||||
key := host.PacketReceiptKey(portID, channelID, sequence)
|
||||
|
||||
value, proofBz, proofHeight, err := ibcclient.QueryTendermintProof(clientCtx, key)
|
||||
if err != nil {
|
||||
@ -285,7 +285,7 @@ func QueryPacketAcknowledgement(clientCtx client.Context, portID, channelID stri
|
||||
}
|
||||
|
||||
func queryPacketAcknowledgementABCI(clientCtx client.Context, portID, channelID string, sequence uint64) (*types.QueryPacketAcknowledgementResponse, error) {
|
||||
key := host.KeyPacketAcknowledgement(portID, channelID, sequence)
|
||||
key := host.PacketAcknowledgementKey(portID, channelID, sequence)
|
||||
|
||||
value, proofBz, proofHeight, err := ibcclient.QueryTendermintProof(clientCtx, key)
|
||||
if err != nil {
|
||||
|
||||
@ -52,7 +52,7 @@ func (q Keeper) Channels(c context.Context, req *types.QueryChannelsRequest) (*t
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
|
||||
channels := []*types.IdentifiedChannel{}
|
||||
store := prefix.NewStore(ctx.KVStore(q.storeKey), []byte(host.KeyChannelPrefix))
|
||||
store := prefix.NewStore(ctx.KVStore(q.storeKey), []byte(host.KeyChannelEndPrefix))
|
||||
|
||||
pageRes, err := query.Paginate(store, req.Pagination, func(key, value []byte) error {
|
||||
var result types.Channel
|
||||
@ -95,7 +95,7 @@ func (q Keeper) ConnectionChannels(c context.Context, req *types.QueryConnection
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
|
||||
channels := []*types.IdentifiedChannel{}
|
||||
store := prefix.NewStore(ctx.KVStore(q.storeKey), []byte(host.KeyChannelPrefix))
|
||||
store := prefix.NewStore(ctx.KVStore(q.storeKey), []byte(host.KeyChannelEndPrefix))
|
||||
|
||||
pageRes, err := query.Paginate(store, req.Pagination, func(key, value []byte) error {
|
||||
var result types.Channel
|
||||
|
||||
@ -289,7 +289,7 @@ func (suite *KeeperTestSuite) TestChanOpenTry() {
|
||||
counterpartyChosenChannelID = channel.Counterparty.ChannelId
|
||||
}
|
||||
|
||||
channelKey := host.KeyChannel(counterparty.PortId, counterparty.ChannelId)
|
||||
channelKey := host.ChannelKey(counterparty.PortId, counterparty.ChannelId)
|
||||
proof, proofHeight := suite.chainA.QueryProof(channelKey)
|
||||
|
||||
cap, err := suite.chainB.App.IBCKeeper.ChannelKeeper.ChanOpenTry(
|
||||
@ -455,7 +455,7 @@ func (suite *KeeperTestSuite) TestChanOpenAck() {
|
||||
counterpartyChannelID = channelB.ID
|
||||
}
|
||||
|
||||
channelKey := host.KeyChannel(channelB.PortID, channelB.ID)
|
||||
channelKey := host.ChannelKey(channelB.PortID, channelB.ID)
|
||||
proof, proofHeight := suite.chainB.QueryProof(channelKey)
|
||||
|
||||
err := suite.chainA.App.IBCKeeper.ChannelKeeper.ChanOpenAck(
|
||||
@ -583,7 +583,7 @@ func (suite *KeeperTestSuite) TestChanOpenConfirm() {
|
||||
channelA := connA.FirstOrNextTestChannel(ibctesting.MockPort)
|
||||
channelB := connB.FirstOrNextTestChannel(ibctesting.MockPort)
|
||||
|
||||
channelKey := host.KeyChannel(channelA.PortID, channelA.ID)
|
||||
channelKey := host.ChannelKey(channelA.PortID, channelA.ID)
|
||||
proof, proofHeight := suite.chainA.QueryProof(channelKey)
|
||||
|
||||
err := suite.chainB.App.IBCKeeper.ChannelKeeper.ChanOpenConfirm(
|
||||
@ -784,7 +784,7 @@ func (suite *KeeperTestSuite) TestChanCloseConfirm() {
|
||||
channelA = connA.FirstOrNextTestChannel(ibctesting.MockPort)
|
||||
channelB = connB.FirstOrNextTestChannel(ibctesting.MockPort)
|
||||
|
||||
channelKey := host.KeyChannel(channelA.PortID, channelA.ID)
|
||||
channelKey := host.ChannelKey(channelA.PortID, channelA.ID)
|
||||
proof, proofHeight := suite.chainA.QueryProof(channelKey)
|
||||
|
||||
err := suite.chainB.App.IBCKeeper.ChannelKeeper.ChanCloseConfirm(
|
||||
|
||||
@ -58,7 +58,7 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger {
|
||||
// GetChannel returns a channel with a particular identifier binded to a specific port
|
||||
func (k Keeper) GetChannel(ctx sdk.Context, portID, channelID string) (types.Channel, bool) {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
bz := store.Get(host.KeyChannel(portID, channelID))
|
||||
bz := store.Get(host.ChannelKey(portID, channelID))
|
||||
if bz == nil {
|
||||
return types.Channel{}, false
|
||||
}
|
||||
@ -72,13 +72,13 @@ func (k Keeper) GetChannel(ctx sdk.Context, portID, channelID string) (types.Cha
|
||||
func (k Keeper) SetChannel(ctx sdk.Context, portID, channelID string, channel types.Channel) {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
bz := k.cdc.MustMarshalBinaryBare(&channel)
|
||||
store.Set(host.KeyChannel(portID, channelID), bz)
|
||||
store.Set(host.ChannelKey(portID, channelID), bz)
|
||||
}
|
||||
|
||||
// GetNextSequenceSend gets a channel's next send sequence from the store
|
||||
func (k Keeper) GetNextSequenceSend(ctx sdk.Context, portID, channelID string) (uint64, bool) {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
bz := store.Get(host.KeyNextSequenceSend(portID, channelID))
|
||||
bz := store.Get(host.NextSequenceSendKey(portID, channelID))
|
||||
if bz == nil {
|
||||
return 0, false
|
||||
}
|
||||
@ -90,13 +90,13 @@ func (k Keeper) GetNextSequenceSend(ctx sdk.Context, portID, channelID string) (
|
||||
func (k Keeper) SetNextSequenceSend(ctx sdk.Context, portID, channelID string, sequence uint64) {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
bz := sdk.Uint64ToBigEndian(sequence)
|
||||
store.Set(host.KeyNextSequenceSend(portID, channelID), bz)
|
||||
store.Set(host.NextSequenceSendKey(portID, channelID), bz)
|
||||
}
|
||||
|
||||
// GetNextSequenceRecv gets a channel's next receive sequence from the store
|
||||
func (k Keeper) GetNextSequenceRecv(ctx sdk.Context, portID, channelID string) (uint64, bool) {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
bz := store.Get(host.KeyNextSequenceRecv(portID, channelID))
|
||||
bz := store.Get(host.NextSequenceRecvKey(portID, channelID))
|
||||
if bz == nil {
|
||||
return 0, false
|
||||
}
|
||||
@ -108,13 +108,13 @@ func (k Keeper) GetNextSequenceRecv(ctx sdk.Context, portID, channelID string) (
|
||||
func (k Keeper) SetNextSequenceRecv(ctx sdk.Context, portID, channelID string, sequence uint64) {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
bz := sdk.Uint64ToBigEndian(sequence)
|
||||
store.Set(host.KeyNextSequenceRecv(portID, channelID), bz)
|
||||
store.Set(host.NextSequenceRecvKey(portID, channelID), bz)
|
||||
}
|
||||
|
||||
// GetNextSequenceAck gets a channel's next ack sequence from the store
|
||||
func (k Keeper) GetNextSequenceAck(ctx sdk.Context, portID, channelID string) (uint64, bool) {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
bz := store.Get(host.KeyNextSequenceAck(portID, channelID))
|
||||
bz := store.Get(host.NextSequenceAckKey(portID, channelID))
|
||||
if bz == nil {
|
||||
return 0, false
|
||||
}
|
||||
@ -126,13 +126,13 @@ func (k Keeper) GetNextSequenceAck(ctx sdk.Context, portID, channelID string) (u
|
||||
func (k Keeper) SetNextSequenceAck(ctx sdk.Context, portID, channelID string, sequence uint64) {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
bz := sdk.Uint64ToBigEndian(sequence)
|
||||
store.Set(host.KeyNextSequenceAck(portID, channelID), bz)
|
||||
store.Set(host.NextSequenceAckKey(portID, channelID), bz)
|
||||
}
|
||||
|
||||
// GetPacketReceipt gets a packet receipt from the store
|
||||
func (k Keeper) GetPacketReceipt(ctx sdk.Context, portID, channelID string, sequence uint64) (string, bool) {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
bz := store.Get(host.KeyPacketReceipt(portID, channelID, sequence))
|
||||
bz := store.Get(host.PacketReceiptKey(portID, channelID, sequence))
|
||||
if bz == nil {
|
||||
return "", false
|
||||
}
|
||||
@ -143,43 +143,43 @@ func (k Keeper) GetPacketReceipt(ctx sdk.Context, portID, channelID string, sequ
|
||||
// SetPacketReceipt sets an empty packet receipt to the store
|
||||
func (k Keeper) SetPacketReceipt(ctx sdk.Context, portID, channelID string, sequence uint64) {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
store.Set(host.KeyPacketReceipt(portID, channelID, sequence), []byte(""))
|
||||
store.Set(host.PacketReceiptKey(portID, channelID, sequence), []byte(""))
|
||||
}
|
||||
|
||||
// GetPacketCommitment gets the packet commitment hash from the store
|
||||
func (k Keeper) GetPacketCommitment(ctx sdk.Context, portID, channelID string, sequence uint64) []byte {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
bz := store.Get(host.KeyPacketCommitment(portID, channelID, sequence))
|
||||
bz := store.Get(host.PacketCommitmentKey(portID, channelID, sequence))
|
||||
return bz
|
||||
}
|
||||
|
||||
// HasPacketCommitment returns true if the packet commitment exists
|
||||
func (k Keeper) HasPacketCommitment(ctx sdk.Context, portID, channelID string, sequence uint64) bool {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
return store.Has(host.KeyPacketCommitment(portID, channelID, sequence))
|
||||
return store.Has(host.PacketCommitmentKey(portID, channelID, sequence))
|
||||
}
|
||||
|
||||
// SetPacketCommitment sets the packet commitment hash to the store
|
||||
func (k Keeper) SetPacketCommitment(ctx sdk.Context, portID, channelID string, sequence uint64, commitmentHash []byte) {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
store.Set(host.KeyPacketCommitment(portID, channelID, sequence), commitmentHash)
|
||||
store.Set(host.PacketCommitmentKey(portID, channelID, sequence), commitmentHash)
|
||||
}
|
||||
|
||||
func (k Keeper) deletePacketCommitment(ctx sdk.Context, portID, channelID string, sequence uint64) {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
store.Delete(host.KeyPacketCommitment(portID, channelID, sequence))
|
||||
store.Delete(host.PacketCommitmentKey(portID, channelID, sequence))
|
||||
}
|
||||
|
||||
// SetPacketAcknowledgement sets the packet ack hash to the store
|
||||
func (k Keeper) SetPacketAcknowledgement(ctx sdk.Context, portID, channelID string, sequence uint64, ackHash []byte) {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
store.Set(host.KeyPacketAcknowledgement(portID, channelID, sequence), ackHash)
|
||||
store.Set(host.PacketAcknowledgementKey(portID, channelID, sequence), ackHash)
|
||||
}
|
||||
|
||||
// GetPacketAcknowledgement gets the packet ack hash from the store
|
||||
func (k Keeper) GetPacketAcknowledgement(ctx sdk.Context, portID, channelID string, sequence uint64) ([]byte, bool) {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
bz := store.Get(host.KeyPacketAcknowledgement(portID, channelID, sequence))
|
||||
bz := store.Get(host.PacketAcknowledgementKey(portID, channelID, sequence))
|
||||
if bz == nil {
|
||||
return nil, false
|
||||
}
|
||||
@ -189,7 +189,7 @@ func (k Keeper) GetPacketAcknowledgement(ctx sdk.Context, portID, channelID stri
|
||||
// HasPacketAcknowledgement check if the packet ack hash is already on the store
|
||||
func (k Keeper) HasPacketAcknowledgement(ctx sdk.Context, portID, channelID string, sequence uint64) bool {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
return store.Has(host.KeyPacketAcknowledgement(portID, channelID, sequence))
|
||||
return store.Has(host.PacketAcknowledgementKey(portID, channelID, sequence))
|
||||
}
|
||||
|
||||
// IteratePacketSequence provides an iterator over all send, receive or ack sequences.
|
||||
@ -330,7 +330,7 @@ func (k Keeper) GetAllPacketAcks(ctx sdk.Context) (acks []types.PacketState) {
|
||||
// and stop.
|
||||
func (k Keeper) IterateChannels(ctx sdk.Context, cb func(types.IdentifiedChannel) bool) {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
iterator := sdk.KVStorePrefixIterator(store, []byte(host.KeyChannelPrefix))
|
||||
iterator := sdk.KVStorePrefixIterator(store, []byte(host.KeyChannelEndPrefix))
|
||||
|
||||
defer iterator.Close()
|
||||
for ; iterator.Valid(); iterator.Next() {
|
||||
|
||||
@ -345,7 +345,7 @@ func (suite *KeeperTestSuite) TestRecvPacket() {
|
||||
tc.malleate()
|
||||
|
||||
// get proof of packet commitment from chainA
|
||||
packetKey := host.KeyPacketCommitment(packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence())
|
||||
packetKey := host.PacketCommitmentKey(packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence())
|
||||
proof, proofHeight := suite.chainA.QueryProof(packetKey)
|
||||
|
||||
err := suite.chainB.App.IBCKeeper.ChannelKeeper.RecvPacket(suite.chainB.GetContext(), channelCap, packet, proof, proofHeight)
|
||||
@ -622,7 +622,7 @@ func (suite *KeeperTestSuite) TestAcknowledgePacket() {
|
||||
suite.SetupTest() // reset
|
||||
tc.malleate()
|
||||
|
||||
packetKey := host.KeyPacketAcknowledgement(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence())
|
||||
packetKey := host.PacketAcknowledgementKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence())
|
||||
proof, proofHeight := suite.chainB.QueryProof(packetKey)
|
||||
|
||||
err := suite.chainA.App.IBCKeeper.ChannelKeeper.AcknowledgePacket(suite.chainA.GetContext(), channelCap, packet, ack, proof, proofHeight)
|
||||
|
||||
@ -125,8 +125,8 @@ func (suite *KeeperTestSuite) TestTimeoutPacket() {
|
||||
nextSeqRecv = 1 // must be explicitly changed
|
||||
tc.malleate()
|
||||
|
||||
orderedPacketKey := host.KeyNextSequenceRecv(packet.GetDestPort(), packet.GetDestChannel())
|
||||
unorderedPacketKey := host.KeyPacketReceipt(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence())
|
||||
orderedPacketKey := host.NextSequenceRecvKey(packet.GetDestPort(), packet.GetDestChannel())
|
||||
unorderedPacketKey := host.PacketReceiptKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence())
|
||||
|
||||
if ordered {
|
||||
proof, proofHeight = suite.chainB.QueryProof(orderedPacketKey)
|
||||
@ -326,9 +326,9 @@ func (suite *KeeperTestSuite) TestTimeoutOnClose() {
|
||||
nextSeqRecv = 1 // must be explicitly changed
|
||||
tc.malleate()
|
||||
|
||||
channelKey := host.KeyChannel(packet.GetDestPort(), packet.GetDestChannel())
|
||||
unorderedPacketKey := host.KeyPacketReceipt(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence())
|
||||
orderedPacketKey := host.KeyNextSequenceRecv(packet.GetDestPort(), packet.GetDestChannel())
|
||||
channelKey := host.ChannelKey(packet.GetDestPort(), packet.GetDestChannel())
|
||||
unorderedPacketKey := host.PacketReceiptKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence())
|
||||
orderedPacketKey := host.NextSequenceRecvKey(packet.GetDestPort(), packet.GetDestChannel())
|
||||
|
||||
proofClosed, proofHeight := suite.chainB.QueryProof(channelKey)
|
||||
|
||||
|
||||
@ -15,7 +15,7 @@ import (
|
||||
// Value to the corresponding channel type.
|
||||
func NewDecodeStore(cdc codec.BinaryMarshaler, kvA, kvB kv.Pair) (string, bool) {
|
||||
switch {
|
||||
case bytes.HasPrefix(kvA.Key, []byte(host.KeyChannelPrefix)):
|
||||
case bytes.HasPrefix(kvA.Key, []byte(host.KeyChannelEndPrefix)):
|
||||
var channelA, channelB types.Channel
|
||||
cdc.MustUnmarshalBinaryBare(kvA.Value, &channelA)
|
||||
cdc.MustUnmarshalBinaryBare(kvB.Value, &channelB)
|
||||
|
||||
@ -31,27 +31,27 @@ func TestDecodeStore(t *testing.T) {
|
||||
kvPairs := kv.Pairs{
|
||||
Pairs: []kv.Pair{
|
||||
{
|
||||
Key: host.KeyChannel(portID, channelID),
|
||||
Key: host.ChannelKey(portID, channelID),
|
||||
Value: cdc.MustMarshalBinaryBare(&channel),
|
||||
},
|
||||
{
|
||||
Key: host.KeyNextSequenceSend(portID, channelID),
|
||||
Key: host.NextSequenceSendKey(portID, channelID),
|
||||
Value: sdk.Uint64ToBigEndian(1),
|
||||
},
|
||||
{
|
||||
Key: host.KeyNextSequenceRecv(portID, channelID),
|
||||
Key: host.NextSequenceRecvKey(portID, channelID),
|
||||
Value: sdk.Uint64ToBigEndian(1),
|
||||
},
|
||||
{
|
||||
Key: host.KeyNextSequenceAck(portID, channelID),
|
||||
Key: host.NextSequenceAckKey(portID, channelID),
|
||||
Value: sdk.Uint64ToBigEndian(1),
|
||||
},
|
||||
{
|
||||
Key: host.KeyPacketCommitment(portID, channelID, 1),
|
||||
Key: host.PacketCommitmentKey(portID, channelID, 1),
|
||||
Value: bz,
|
||||
},
|
||||
{
|
||||
Key: host.KeyPacketAcknowledgement(portID, channelID, 1),
|
||||
Key: host.PacketAcknowledgementKey(portID, channelID, 1),
|
||||
Value: bz,
|
||||
},
|
||||
{
|
||||
|
||||
@ -9,8 +9,7 @@ const SubModuleName = "host"
|
||||
|
||||
// IBC client sentinel errors
|
||||
var (
|
||||
ErrInvalidID = sdkerrors.Register(SubModuleName, 2, "invalid identifier")
|
||||
ErrInvalidPath = sdkerrors.Register(SubModuleName, 3, "invalid path")
|
||||
ErrInvalidPacket = sdkerrors.Register(SubModuleName, 4, "invalid packet")
|
||||
ErrInvalidVersion = sdkerrors.Register(SubModuleName, 5, "invalid version")
|
||||
ErrInvalidID = sdkerrors.Register(SubModuleName, 2, "invalid identifier")
|
||||
ErrInvalidPath = sdkerrors.Register(SubModuleName, 3, "invalid path")
|
||||
ErrInvalidPacket = sdkerrors.Register(SubModuleName, 4, "invalid packet")
|
||||
)
|
||||
|
||||
@ -22,14 +22,18 @@ const (
|
||||
|
||||
// KVStore key prefixes for IBC
|
||||
var (
|
||||
KeyClientStorePrefix = []byte("clients")
|
||||
KeyConsensusStatesPrefix = []byte("consensusStates")
|
||||
KeyConnectionPrefix = []byte("connections")
|
||||
KeyClientStorePrefix = []byte("clients")
|
||||
)
|
||||
|
||||
// KVStore key prefixes for IBC
|
||||
const (
|
||||
KeyChannelPrefix = "channelEnds"
|
||||
KeyClientState = "clientState"
|
||||
KeyConsensusStatePrefix = "consensusStates"
|
||||
KeyConnectionPrefix = "connections"
|
||||
KeyChannelEndPrefix = "channelEnds"
|
||||
KeyChannelPrefix = "channels"
|
||||
KeyPortPrefix = "ports"
|
||||
KeySequencePrefix = "sequences"
|
||||
KeyChannelCapabilityPrefix = "capabilities"
|
||||
KeyNextSeqSendPrefix = "nextSequenceSend"
|
||||
KeyNextSeqRecvPrefix = "nextSequenceRecv"
|
||||
@ -42,38 +46,57 @@ const (
|
||||
// FullClientPath returns the full path of a specific client path in the format:
|
||||
// "clients/{clientID}/{path}" as a string.
|
||||
func FullClientPath(clientID string, path string) string {
|
||||
return string(FullKeyClientPath(clientID, []byte(path)))
|
||||
return fmt.Sprintf("%s/%s/%s", KeyClientStorePrefix, clientID, path)
|
||||
}
|
||||
|
||||
// FullKeyClientPath returns the full path of specific client path in the format:
|
||||
// FullClientKey returns the full path of specific client path in the format:
|
||||
// "clients/{clientID}/{path}" as a byte array.
|
||||
func FullKeyClientPath(clientID string, path []byte) []byte {
|
||||
return append(KeyClientStorePrefix, append([]byte("/"+clientID+"/"), path...)...)
|
||||
func FullClientKey(clientID string, path []byte) []byte {
|
||||
return []byte(FullClientPath(clientID, string(path)))
|
||||
}
|
||||
|
||||
// ICS02
|
||||
// The following paths are the keys to the store as defined in https://github.com/cosmos/ics/tree/master/spec/ics-002-client-semantics#path-space
|
||||
|
||||
// ClientStatePath takes an Identifier and returns a Path under which to store a
|
||||
// FullClientStatePath takes a client identifier and returns a Path under which to store a
|
||||
// particular client state
|
||||
func ClientStatePath() string {
|
||||
return "clientState"
|
||||
func FullClientStatePath(clientID string) string {
|
||||
return FullClientPath(clientID, KeyClientState)
|
||||
}
|
||||
|
||||
// ConsensusStatePath takes an Identifier and returns a Path under which to
|
||||
// FullClientStateKey takes a client identifier and returns a Key under which to store a
|
||||
// particular client state.
|
||||
func FullClientStateKey(clientID string) []byte {
|
||||
return FullClientKey(clientID, []byte(KeyClientState))
|
||||
}
|
||||
|
||||
// ClientStateKey returns a store key under which a particular client state is stored
|
||||
// in a client prefixed store
|
||||
func ClientStateKey() []byte {
|
||||
return []byte(KeyClientState)
|
||||
}
|
||||
|
||||
// FullConsensusStatePath takes a client identifier and returns a Path under which to
|
||||
// store the consensus state of a client.
|
||||
func FullConsensusStatePath(clientID string, height exported.Height) string {
|
||||
return FullClientPath(clientID, fmt.Sprintf("%s/%s", KeyConsensusStatePrefix, height))
|
||||
}
|
||||
|
||||
// FullConsensusStateKey returns the store key for the consensus state of a particular
|
||||
// client.
|
||||
func FullConsensusStateKey(clientID string, height exported.Height) []byte {
|
||||
return []byte(FullConsensusStatePath(clientID, height))
|
||||
}
|
||||
|
||||
// ConsensusStatePath returns the suffix store key for the consensus state at a
|
||||
// particular height stored in a client prefixed store.
|
||||
func ConsensusStatePath(height exported.Height) string {
|
||||
return fmt.Sprintf("%s/%s", KeyConsensusStatesPrefix, height)
|
||||
return fmt.Sprintf("%s/%s", KeyConsensusStatePrefix, height)
|
||||
}
|
||||
|
||||
// KeyClientState returns the store key for a particular client state
|
||||
func KeyClientState() []byte {
|
||||
return []byte(ClientStatePath())
|
||||
}
|
||||
|
||||
// KeyConsensusState returns the store key for the consensus state of a particular
|
||||
// client
|
||||
func KeyConsensusState(height exported.Height) []byte {
|
||||
// ConsensusStateKey returns the store key for a the consensus state of a particular
|
||||
// client stored in a client prefixed store.
|
||||
func ConsensusStateKey(height exported.Height) []byte {
|
||||
return []byte(ConsensusStatePath(height))
|
||||
}
|
||||
|
||||
@ -82,7 +105,12 @@ func KeyConsensusState(height exported.Height) []byte {
|
||||
|
||||
// ClientConnectionsPath defines a reverse mapping from clients to a set of connections
|
||||
func ClientConnectionsPath(clientID string) string {
|
||||
return fmt.Sprintf("%s/%s/connections", KeyClientStorePrefix, clientID)
|
||||
return FullClientPath(clientID, KeyConnectionPrefix)
|
||||
}
|
||||
|
||||
// ClientConnectionsKey returns the store key for the connections of a given client
|
||||
func ClientConnectionsKey(clientID string) []byte {
|
||||
return []byte(ClientConnectionsPath(clientID))
|
||||
}
|
||||
|
||||
// ConnectionPath defines the path under which connection paths are stored
|
||||
@ -90,13 +118,8 @@ func ConnectionPath(connectionID string) string {
|
||||
return fmt.Sprintf("%s/%s", KeyConnectionPrefix, connectionID)
|
||||
}
|
||||
|
||||
// KeyClientConnections returns the store key for the connections of a given client
|
||||
func KeyClientConnections(clientID string) []byte {
|
||||
return []byte(ClientConnectionsPath(clientID))
|
||||
}
|
||||
|
||||
// KeyConnection returns the store key for a particular connection
|
||||
func KeyConnection(connectionID string) []byte {
|
||||
// ConnectionKey returns the store key for a particular connection
|
||||
func ConnectionKey(connectionID string) []byte {
|
||||
return []byte(ConnectionPath(connectionID))
|
||||
}
|
||||
|
||||
@ -105,98 +128,102 @@ func KeyConnection(connectionID string) []byte {
|
||||
|
||||
// ChannelPath defines the path under which channels are stored
|
||||
func ChannelPath(portID, channelID string) string {
|
||||
return fmt.Sprintf("%s/", KeyChannelPrefix) + channelPath(portID, channelID)
|
||||
return fmt.Sprintf("%s/%s", KeyChannelEndPrefix, channelPath(portID, channelID))
|
||||
}
|
||||
|
||||
// ChannelKey returns the store key for a particular channel
|
||||
func ChannelKey(portID, channelID string) []byte {
|
||||
return []byte(ChannelPath(portID, channelID))
|
||||
}
|
||||
|
||||
// ChannelCapabilityPath defines the path under which capability keys associated
|
||||
// with a channel are stored
|
||||
func ChannelCapabilityPath(portID, channelID string) string {
|
||||
return fmt.Sprintf("%s/", KeyChannelCapabilityPrefix) + channelPath(portID, channelID) + "/key"
|
||||
return fmt.Sprintf("%s/%s", KeyChannelCapabilityPrefix, channelPath(portID, channelID))
|
||||
}
|
||||
|
||||
// NextSequenceSendPath defines the next send sequence counter store path
|
||||
func NextSequenceSendPath(portID, channelID string) string {
|
||||
return fmt.Sprintf("%s/", KeyNextSeqSendPrefix) + channelPath(portID, channelID)
|
||||
return fmt.Sprintf("%s/%s", KeyNextSeqSendPrefix, channelPath(portID, channelID))
|
||||
}
|
||||
|
||||
// NextSequenceRecvPath defines the next receive sequence counter store path
|
||||
// NextSequenceSendKey returns the store key for the send sequence of a particular
|
||||
// channel binded to a specific port.
|
||||
func NextSequenceSendKey(portID, channelID string) []byte {
|
||||
return []byte(NextSequenceSendPath(portID, channelID))
|
||||
}
|
||||
|
||||
// NextSequenceRecvPath defines the next receive sequence counter store path.
|
||||
func NextSequenceRecvPath(portID, channelID string) string {
|
||||
return fmt.Sprintf("%s/", KeyNextSeqRecvPrefix) + channelPath(portID, channelID)
|
||||
return fmt.Sprintf("%s/%s", KeyNextSeqRecvPrefix, channelPath(portID, channelID))
|
||||
}
|
||||
|
||||
// NextSequenceRecvKey returns the store key for the receive sequence of a particular
|
||||
// channel binded to a specific port
|
||||
func NextSequenceRecvKey(portID, channelID string) []byte {
|
||||
return []byte(NextSequenceRecvPath(portID, channelID))
|
||||
}
|
||||
|
||||
// NextSequenceAckPath defines the next acknowledgement sequence counter store path
|
||||
func NextSequenceAckPath(portID, channelID string) string {
|
||||
return fmt.Sprintf("%s/", KeyNextSeqAckPrefix) + channelPath(portID, channelID)
|
||||
return fmt.Sprintf("%s/%s", KeyNextSeqAckPrefix, channelPath(portID, channelID))
|
||||
}
|
||||
|
||||
// NextSequenceAckKey returns the store key for the acknowledgement sequence of
|
||||
// a particular channel binded to a specific port.
|
||||
func NextSequenceAckKey(portID, channelID string) []byte {
|
||||
return []byte(NextSequenceAckPath(portID, channelID))
|
||||
}
|
||||
|
||||
// PacketCommitmentPath defines the commitments to packet data fields store path
|
||||
func PacketCommitmentPath(portID, channelID string, sequence uint64) string {
|
||||
return fmt.Sprintf("%s/", KeyPacketCommitmentPrefix) + channelPath(portID, channelID) + fmt.Sprintf("/packets/%d", sequence)
|
||||
return fmt.Sprintf("%s/%s/%s", KeyPacketCommitmentPrefix, channelPath(portID, channelID), sequencePath(sequence))
|
||||
}
|
||||
|
||||
// PacketCommitmentKey returns the store key of under which a packet commitment
|
||||
// is stored
|
||||
func PacketCommitmentKey(portID, channelID string, sequence uint64) []byte {
|
||||
return []byte(PacketCommitmentPath(portID, channelID, sequence))
|
||||
}
|
||||
|
||||
// PacketCommitmentPrefixPath defines the prefix for commitments to packet data fields store path.
|
||||
func PacketCommitmentPrefixPath(portID, channelID string) string {
|
||||
return fmt.Sprintf("%s/", KeyPacketCommitmentPrefix) + channelPath(portID, channelID)
|
||||
return fmt.Sprintf("%s/%s/%s", KeyPacketCommitmentPrefix, channelPath(portID, channelID), KeySequencePrefix)
|
||||
}
|
||||
|
||||
// PacketAcknowledgementPath defines the packet acknowledgement store path
|
||||
func PacketAcknowledgementPath(portID, channelID string, sequence uint64) string {
|
||||
return fmt.Sprintf("%s/", KeyPacketAckPrefix) + channelPath(portID, channelID) + fmt.Sprintf("/acknowledgements/%d", sequence)
|
||||
return fmt.Sprintf("%s/%s/%s", KeyPacketAckPrefix, channelPath(portID, channelID), sequencePath(sequence))
|
||||
}
|
||||
|
||||
// PacketAcknowledgementKey returns the store key of under which a packet
|
||||
// acknowledgement is stored
|
||||
func PacketAcknowledgementKey(portID, channelID string, sequence uint64) []byte {
|
||||
return []byte(PacketAcknowledgementPath(portID, channelID, sequence))
|
||||
}
|
||||
|
||||
// PacketAcknowledgementPrefixPath defines the prefix for commitments to packet data fields store path.
|
||||
func PacketAcknowledgementPrefixPath(portID, channelID string) string {
|
||||
return fmt.Sprintf("%s/", KeyPacketAckPrefix) + channelPath(portID, channelID)
|
||||
return fmt.Sprintf("%s/%s/%s", KeyPacketAckPrefix, channelPath(portID, channelID), KeySequencePrefix)
|
||||
}
|
||||
|
||||
// PacketReceiptPath defines the packet receipt store path
|
||||
func PacketReceiptPath(portID, channelID string, sequence uint64) string {
|
||||
return fmt.Sprintf("%s/", KeyPacketReceiptPrefix) + channelPath(portID, channelID) + fmt.Sprintf("/receipts/%d", sequence)
|
||||
return fmt.Sprintf("%s/%s/%s", KeyPacketReceiptPrefix, channelPath(portID, channelID), sequencePath(sequence))
|
||||
}
|
||||
|
||||
// KeyChannel returns the store key for a particular channel
|
||||
func KeyChannel(portID, channelID string) []byte {
|
||||
return []byte(ChannelPath(portID, channelID))
|
||||
}
|
||||
|
||||
// KeyNextSequenceSend returns the store key for the send sequence of a particular
|
||||
// channel binded to a specific port
|
||||
func KeyNextSequenceSend(portID, channelID string) []byte {
|
||||
return []byte(NextSequenceSendPath(portID, channelID))
|
||||
}
|
||||
|
||||
// KeyNextSequenceRecv returns the store key for the receive sequence of a particular
|
||||
// channel binded to a specific port
|
||||
func KeyNextSequenceRecv(portID, channelID string) []byte {
|
||||
return []byte(NextSequenceRecvPath(portID, channelID))
|
||||
}
|
||||
|
||||
// KeyNextSequenceAck returns the store key for the acknowledgement sequence of
|
||||
// a particular channel binded to a specific port.
|
||||
func KeyNextSequenceAck(portID, channelID string) []byte {
|
||||
return []byte(NextSequenceAckPath(portID, channelID))
|
||||
}
|
||||
|
||||
// KeyPacketCommitment returns the store key of under which a packet commitment
|
||||
// is stored
|
||||
func KeyPacketCommitment(portID, channelID string, sequence uint64) []byte {
|
||||
return []byte(PacketCommitmentPath(portID, channelID, sequence))
|
||||
}
|
||||
|
||||
// KeyPacketAcknowledgement returns the store key of under which a packet
|
||||
// acknowledgement is stored
|
||||
func KeyPacketAcknowledgement(portID, channelID string, sequence uint64) []byte {
|
||||
return []byte(PacketAcknowledgementPath(portID, channelID, sequence))
|
||||
}
|
||||
|
||||
// KeyPacketReceipt returns the store key of under which a packet
|
||||
// PacketReceiptKey returns the store key of under which a packet
|
||||
// receipt is stored
|
||||
func KeyPacketReceipt(portID, channelID string, sequence uint64) []byte {
|
||||
func PacketReceiptKey(portID, channelID string, sequence uint64) []byte {
|
||||
return []byte(PacketReceiptPath(portID, channelID, sequence))
|
||||
}
|
||||
|
||||
func channelPath(portID, channelID string) string {
|
||||
return fmt.Sprintf("ports/%s/channels/%s", portID, channelID)
|
||||
return fmt.Sprintf("%s/%s/%s/%s", KeyPortPrefix, portID, KeyChannelPrefix, channelID)
|
||||
}
|
||||
|
||||
func sequencePath(sequence uint64) string {
|
||||
return fmt.Sprintf("%s/%d", KeySequencePrefix, sequence)
|
||||
}
|
||||
|
||||
// ICS05
|
||||
@ -204,5 +231,5 @@ func channelPath(portID, channelID string) string {
|
||||
|
||||
// PortPath defines the path under which ports paths are stored on the capability module
|
||||
func PortPath(portID string) string {
|
||||
return fmt.Sprintf("ports/%s", portID)
|
||||
return fmt.Sprintf("%s/%s", KeyPortPrefix, portID)
|
||||
}
|
||||
|
||||
@ -25,7 +25,7 @@ func ParseChannelPath(path string) (string, string, error) {
|
||||
return "", "", sdkerrors.Wrapf(ErrInvalidPath, "cannot parse channel path %s", path)
|
||||
}
|
||||
|
||||
if split[1] != "ports" || split[3] != "channels" {
|
||||
if split[1] != KeyPortPrefix || split[3] != KeyChannelPrefix {
|
||||
return "", "", sdkerrors.Wrapf(ErrInvalidPath, "cannot parse channel path %s", path)
|
||||
}
|
||||
|
||||
|
||||
@ -142,7 +142,7 @@ func (suite *KeeperTestSuite) TestHandleRecvPacket() {
|
||||
tc.malleate()
|
||||
|
||||
// get proof of packet commitment from chainA
|
||||
packetKey := host.KeyPacketCommitment(packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence())
|
||||
packetKey := host.PacketCommitmentKey(packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence())
|
||||
proof, proofHeight := suite.chainA.QueryProof(packetKey)
|
||||
|
||||
msg := channeltypes.NewMsgRecvPacket(packet, proof, proofHeight, suite.chainB.SenderAccount.GetAddress())
|
||||
@ -281,7 +281,7 @@ func (suite *KeeperTestSuite) TestHandleAcknowledgePacket() {
|
||||
|
||||
tc.malleate()
|
||||
|
||||
packetKey := host.KeyPacketAcknowledgement(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence())
|
||||
packetKey := host.PacketAcknowledgementKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence())
|
||||
proof, proofHeight := suite.chainB.QueryProof(packetKey)
|
||||
|
||||
msg := channeltypes.NewMsgAcknowledgement(packet, ibcmock.MockAcknowledgement, proof, proofHeight, suite.chainA.SenderAccount.GetAddress())
|
||||
@ -333,7 +333,7 @@ func (suite *KeeperTestSuite) TestHandleTimeoutPacket() {
|
||||
// need to update chainA client to prove missing ack
|
||||
suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint)
|
||||
|
||||
packetKey = host.KeyNextSequenceRecv(packet.GetDestPort(), packet.GetDestChannel())
|
||||
packetKey = host.NextSequenceRecvKey(packet.GetDestPort(), packet.GetDestChannel())
|
||||
}, true},
|
||||
{"success: UNORDERED", func() {
|
||||
clientA, clientB, _, _, channelA, channelB := suite.coordinator.Setup(suite.chainA, suite.chainB, channeltypes.UNORDERED)
|
||||
@ -346,7 +346,7 @@ func (suite *KeeperTestSuite) TestHandleTimeoutPacket() {
|
||||
// need to update chainA client to prove missing ack
|
||||
suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint)
|
||||
|
||||
packetKey = host.KeyPacketReceipt(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence())
|
||||
packetKey = host.PacketReceiptKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence())
|
||||
}, true},
|
||||
{"success: UNORDERED timeout out of order packet", func() {
|
||||
// setup uses an UNORDERED channel
|
||||
@ -363,7 +363,7 @@ func (suite *KeeperTestSuite) TestHandleTimeoutPacket() {
|
||||
}
|
||||
|
||||
suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint)
|
||||
packetKey = host.KeyPacketReceipt(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence())
|
||||
packetKey = host.PacketReceiptKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence())
|
||||
}, true},
|
||||
{"success: ORDERED timeout out of order packet", func() {
|
||||
clientA, clientB, _, _, channelA, channelB := suite.coordinator.Setup(suite.chainA, suite.chainB, channeltypes.ORDERED)
|
||||
@ -379,19 +379,19 @@ func (suite *KeeperTestSuite) TestHandleTimeoutPacket() {
|
||||
}
|
||||
|
||||
suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint)
|
||||
packetKey = host.KeyNextSequenceRecv(packet.GetDestPort(), packet.GetDestChannel())
|
||||
packetKey = host.NextSequenceRecvKey(packet.GetDestPort(), packet.GetDestChannel())
|
||||
|
||||
}, true},
|
||||
{"channel does not exist", func() {
|
||||
// any non-nil value of packet is valid
|
||||
suite.Require().NotNil(packet)
|
||||
|
||||
packetKey = host.KeyNextSequenceRecv(packet.GetDestPort(), packet.GetDestChannel())
|
||||
packetKey = host.NextSequenceRecvKey(packet.GetDestPort(), packet.GetDestChannel())
|
||||
}, false},
|
||||
{"UNORDERED: packet not sent", func() {
|
||||
_, _, _, _, channelA, channelB := suite.coordinator.Setup(suite.chainA, suite.chainB, channeltypes.UNORDERED)
|
||||
packet = channeltypes.NewPacket(ibctesting.MockCommitment, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutHeight, 0)
|
||||
packetKey = host.KeyPacketReceipt(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence())
|
||||
packetKey = host.PacketReceiptKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence())
|
||||
}, false},
|
||||
}
|
||||
|
||||
@ -460,7 +460,7 @@ func (suite *KeeperTestSuite) TestHandleTimeoutOnClosePacket() {
|
||||
// need to update chainA client to prove missing ack
|
||||
suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint)
|
||||
|
||||
packetKey = host.KeyNextSequenceRecv(packet.GetDestPort(), packet.GetDestChannel())
|
||||
packetKey = host.NextSequenceRecvKey(packet.GetDestPort(), packet.GetDestChannel())
|
||||
|
||||
// close counterparty channel
|
||||
suite.coordinator.SetChannelClosed(suite.chainB, suite.chainA, counterpartyChannel)
|
||||
@ -481,7 +481,7 @@ func (suite *KeeperTestSuite) TestHandleTimeoutOnClosePacket() {
|
||||
// need to update chainA client to prove missing ack
|
||||
suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint)
|
||||
|
||||
packetKey = host.KeyPacketReceipt(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence())
|
||||
packetKey = host.PacketReceiptKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence())
|
||||
|
||||
// close counterparty channel
|
||||
suite.coordinator.SetChannelClosed(suite.chainB, suite.chainA, counterpartyChannel)
|
||||
@ -506,7 +506,7 @@ func (suite *KeeperTestSuite) TestHandleTimeoutOnClosePacket() {
|
||||
}
|
||||
|
||||
suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint)
|
||||
packetKey = host.KeyPacketReceipt(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence())
|
||||
packetKey = host.PacketReceiptKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence())
|
||||
|
||||
// close counterparty channel
|
||||
suite.coordinator.SetChannelClosed(suite.chainB, suite.chainA, counterpartyChannel)
|
||||
@ -530,7 +530,7 @@ func (suite *KeeperTestSuite) TestHandleTimeoutOnClosePacket() {
|
||||
}
|
||||
|
||||
suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint)
|
||||
packetKey = host.KeyNextSequenceRecv(packet.GetDestPort(), packet.GetDestChannel())
|
||||
packetKey = host.NextSequenceRecvKey(packet.GetDestPort(), packet.GetDestChannel())
|
||||
|
||||
// close counterparty channel
|
||||
suite.coordinator.SetChannelClosed(suite.chainB, suite.chainA, counterpartyChannel)
|
||||
@ -539,12 +539,12 @@ func (suite *KeeperTestSuite) TestHandleTimeoutOnClosePacket() {
|
||||
// any non-nil value of packet is valid
|
||||
suite.Require().NotNil(packet)
|
||||
|
||||
packetKey = host.KeyNextSequenceRecv(packet.GetDestPort(), packet.GetDestChannel())
|
||||
packetKey = host.NextSequenceRecvKey(packet.GetDestPort(), packet.GetDestChannel())
|
||||
}, false},
|
||||
{"UNORDERED: packet not sent", func() {
|
||||
clientA, _, _, _, channelA, channelB := suite.coordinator.Setup(suite.chainA, suite.chainB, channeltypes.UNORDERED)
|
||||
packet = channeltypes.NewPacket(ibctesting.MockCommitment, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutHeight, 0)
|
||||
packetKey = host.KeyPacketAcknowledgement(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence())
|
||||
packetKey = host.PacketAcknowledgementKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence())
|
||||
counterpartyChannel = ibctesting.TestChannel{
|
||||
PortID: channelB.PortID,
|
||||
ID: channelB.ID,
|
||||
@ -570,7 +570,7 @@ func (suite *KeeperTestSuite) TestHandleTimeoutOnClosePacket() {
|
||||
// need to update chainA client to prove missing ack
|
||||
suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint)
|
||||
|
||||
packetKey = host.KeyNextSequenceRecv(packet.GetDestPort(), packet.GetDestChannel())
|
||||
packetKey = host.NextSequenceRecvKey(packet.GetDestPort(), packet.GetDestChannel())
|
||||
}, false},
|
||||
}
|
||||
|
||||
@ -584,7 +584,7 @@ func (suite *KeeperTestSuite) TestHandleTimeoutOnClosePacket() {
|
||||
|
||||
proof, proofHeight := suite.chainB.QueryProof(packetKey)
|
||||
|
||||
channelKey := host.KeyChannel(counterpartyChannel.PortID, counterpartyChannel.ID)
|
||||
channelKey := host.ChannelKey(counterpartyChannel.PortID, counterpartyChannel.ID)
|
||||
proofClosed, _ := suite.chainB.QueryProof(channelKey)
|
||||
|
||||
msg := channeltypes.NewMsgTimeoutOnClose(packet, 1, proof, proofClosed, proofHeight, suite.chainA.SenderAccount.GetAddress())
|
||||
|
||||
@ -40,15 +40,15 @@ func TestDecodeStore(t *testing.T) {
|
||||
kvPairs := kv.Pairs{
|
||||
Pairs: []kv.Pair{
|
||||
{
|
||||
Key: host.FullKeyClientPath(clientID, host.KeyClientState()),
|
||||
Key: host.FullClientStateKey(clientID),
|
||||
Value: app.IBCKeeper.ClientKeeper.MustMarshalClientState(clientState),
|
||||
},
|
||||
{
|
||||
Key: host.KeyConnection(connectionID),
|
||||
Key: host.ConnectionKey(connectionID),
|
||||
Value: app.IBCKeeper.Codec().MustMarshalBinaryBare(&connection),
|
||||
},
|
||||
{
|
||||
Key: host.KeyChannel(portID, channelID),
|
||||
Key: host.ChannelKey(portID, channelID),
|
||||
Value: app.IBCKeeper.Codec().MustMarshalBinaryBare(&channel),
|
||||
},
|
||||
{
|
||||
|
||||
@ -16,10 +16,10 @@ The client type is not stored since it can be obtained through the client state.
|
||||
| "0/" | "connections/{identifier}" | ConnectionEnd |
|
||||
| "0/" | "ports/{identifier}" | CapabilityKey |
|
||||
| "0/" | "channelEnds/ports/{identifier}/channels/{identifier}" | ChannelEnd |
|
||||
| "0/" | "capabilities/ports/{identifier}/channels/{identifier}/key" | CapabilityKey |
|
||||
| "0/" | "seqSends/ports/{identifier}/channels/{identifier}/nextSequenceSend" | uint64 |
|
||||
| "0/" | "seqRecvs/ports/{identifier}/channels/{identifier}/nextSequenceRecv" | uint64 |
|
||||
| "0/" | "seqAcks/ports/{identifier}/channels/{identifier}/nextSequenceAck" | uint64 |
|
||||
| "0/" | "commitments/ports/{identifier}/channels/{identifier}/packets/{sequence}" | bytes |
|
||||
| "0/" | "receipts/ports/{identifier}/channels/{identifier}/receipts/{sequence}" | bytes |
|
||||
| "0/" | "acks/ports/{identifier}/channels/{identifier}/acknowledgements/{sequence}" | bytes |
|
||||
| "0/" | "capabilities/ports/{identifier}/channels/{identifier}" | CapabilityKey |
|
||||
| "0/" | "nextSequenceSend/ports/{identifier}/channels/{identifier}" | uint64 |
|
||||
| "0/" | "nextSequenceRecv/ports/{identifier}/channels/{identifier}" | uint64 |
|
||||
| "0/" | "nextSequenceAck/ports/{identifier}/channels/{identifier}" | uint64 |
|
||||
| "0/" | "commitments/ports/{identifier}/channels/{identifier}/sequences/{sequence}" | bytes |
|
||||
| "0/" | "receipts/ports/{identifier}/channels/{identifier}/sequences/{sequence}" | bytes |
|
||||
| "0/" | "acks/ports/{identifier}/channels/{identifier}/sequences/{sequence}" | bytes |
|
||||
|
||||
@ -100,7 +100,7 @@ func (cs ClientState) VerifyClientState(
|
||||
return err
|
||||
}
|
||||
|
||||
clientPrefixedPath := commitmenttypes.NewMerklePath("clients/" + counterpartyClientIdentifier + "/" + host.ClientStatePath())
|
||||
clientPrefixedPath := commitmenttypes.NewMerklePath(host.FullClientStatePath(counterpartyClientIdentifier))
|
||||
path, err := commitmenttypes.ApplyPrefix(prefix, clientPrefixedPath)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -138,7 +138,7 @@ func (cs ClientState) VerifyClientConsensusState(
|
||||
return err
|
||||
}
|
||||
|
||||
clientPrefixedPath := commitmenttypes.NewMerklePath("clients/" + counterpartyClientIdentifier + "/" + host.ConsensusStatePath(consensusHeight))
|
||||
clientPrefixedPath := commitmenttypes.NewMerklePath(host.FullConsensusStatePath(counterpartyClientIdentifier, consensusHeight))
|
||||
path, err := commitmenttypes.ApplyPrefix(prefix, clientPrefixedPath)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -460,5 +460,5 @@ func produceVerificationArgs(
|
||||
// sets the client state to the store
|
||||
func setClientState(store sdk.KVStore, cdc codec.BinaryMarshaler, clientState exported.ClientState) {
|
||||
bz := clienttypes.MustMarshalClientState(cdc, clientState)
|
||||
store.Set(host.KeyClientState(), bz)
|
||||
store.Set([]byte(host.KeyClientState), bz)
|
||||
}
|
||||
|
||||
@ -49,7 +49,7 @@ func TestSoloMachineTestSuite(t *testing.T) {
|
||||
}
|
||||
|
||||
func (suite *SoloMachineTestSuite) GetSequenceFromStore() uint64 {
|
||||
bz := suite.store.Get(host.KeyClientState())
|
||||
bz := suite.store.Get(host.ClientStateKey())
|
||||
suite.Require().NotNil(bz)
|
||||
|
||||
var clientState exported.ClientState
|
||||
|
||||
@ -180,7 +180,7 @@ func (cs ClientState) VerifyClientState(
|
||||
return err
|
||||
}
|
||||
|
||||
clientPrefixedPath := commitmenttypes.NewMerklePath("clients/" + counterpartyClientIdentifier + "/" + host.ClientStatePath())
|
||||
clientPrefixedPath := commitmenttypes.NewMerklePath(host.FullClientStatePath(counterpartyClientIdentifier))
|
||||
path, err := commitmenttypes.ApplyPrefix(prefix, clientPrefixedPath)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -220,7 +220,7 @@ func (cs ClientState) VerifyClientConsensusState(
|
||||
return err
|
||||
}
|
||||
|
||||
clientPrefixedPath := commitmenttypes.NewMerklePath("clients/" + counterpartyClientIdentifier + "/" + host.ConsensusStatePath(consensusHeight))
|
||||
clientPrefixedPath := commitmenttypes.NewMerklePath(host.FullConsensusStatePath(counterpartyClientIdentifier, consensusHeight))
|
||||
path, err := commitmenttypes.ApplyPrefix(prefix, clientPrefixedPath)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@ -230,7 +230,7 @@ func (suite *TendermintTestSuite) TestVerifyConnectionState() {
|
||||
prefix = suite.chainB.GetPrefix()
|
||||
|
||||
// make connection proof
|
||||
connectionKey := host.KeyConnection(connB.ID)
|
||||
connectionKey := host.ConnectionKey(connB.ID)
|
||||
proof, proofHeight = suite.chainB.QueryProof(connectionKey)
|
||||
|
||||
tc.malleate() // make changes as necessary
|
||||
@ -308,7 +308,7 @@ func (suite *TendermintTestSuite) TestVerifyChannelState() {
|
||||
prefix = suite.chainB.GetPrefix()
|
||||
|
||||
// make channel proof
|
||||
channelKey := host.KeyChannel(channelB.PortID, channelB.ID)
|
||||
channelKey := host.ChannelKey(channelB.PortID, channelB.ID)
|
||||
proof, proofHeight = suite.chainB.QueryProof(channelKey)
|
||||
|
||||
tc.malleate() // make changes as necessary
|
||||
@ -389,7 +389,7 @@ func (suite *TendermintTestSuite) TestVerifyPacketCommitment() {
|
||||
prefix = suite.chainB.GetPrefix()
|
||||
|
||||
// make packet commitment proof
|
||||
packetKey := host.KeyPacketCommitment(packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence())
|
||||
packetKey := host.PacketCommitmentKey(packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence())
|
||||
proof, proofHeight = suite.chainB.QueryProof(packetKey)
|
||||
|
||||
tc.malleate() // make changes as necessary
|
||||
@ -477,7 +477,7 @@ func (suite *TendermintTestSuite) TestVerifyPacketAcknowledgement() {
|
||||
prefix = suite.chainB.GetPrefix()
|
||||
|
||||
// make packet acknowledgement proof
|
||||
acknowledgementKey := host.KeyPacketAcknowledgement(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence())
|
||||
acknowledgementKey := host.PacketAcknowledgementKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence())
|
||||
proof, proofHeight = suite.chainB.QueryProof(acknowledgementKey)
|
||||
|
||||
tc.malleate() // make changes as necessary
|
||||
@ -564,7 +564,7 @@ func (suite *TendermintTestSuite) TestVerifyPacketReceiptAbsence() {
|
||||
prefix = suite.chainB.GetPrefix()
|
||||
|
||||
// make packet receipt absence proof
|
||||
receiptKey := host.KeyPacketReceipt(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence())
|
||||
receiptKey := host.PacketReceiptKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence())
|
||||
proof, proofHeight = suite.chainB.QueryProof(receiptKey)
|
||||
|
||||
tc.malleate() // make changes as necessary
|
||||
@ -655,7 +655,7 @@ func (suite *TendermintTestSuite) TestVerifyNextSeqRecv() {
|
||||
prefix = suite.chainB.GetPrefix()
|
||||
|
||||
// make next seq recv proof
|
||||
nextSeqRecvKey := host.KeyNextSequenceRecv(packet.GetDestPort(), packet.GetDestChannel())
|
||||
nextSeqRecvKey := host.NextSequenceRecvKey(packet.GetDestPort(), packet.GetDestChannel())
|
||||
proof, proofHeight = suite.chainB.QueryProof(nextSeqRecvKey)
|
||||
|
||||
tc.malleate() // make changes as necessary
|
||||
|
||||
@ -12,7 +12,7 @@ import (
|
||||
// GetConsensusState retrieves the consensus state from the client prefixed
|
||||
// store. An error is returned if the consensus state does not exist.
|
||||
func GetConsensusState(store sdk.KVStore, cdc codec.BinaryMarshaler, height exported.Height) (*ConsensusState, error) {
|
||||
bz := store.Get(host.KeyConsensusState(height))
|
||||
bz := store.Get(host.ConsensusStateKey(height))
|
||||
if bz == nil {
|
||||
return nil, sdkerrors.Wrapf(
|
||||
clienttypes.ErrConsensusStateNotFound,
|
||||
|
||||
@ -34,7 +34,7 @@ func (suite *TendermintTestSuite) TestGetConsensusState() {
|
||||
// marshal an empty client state and set as consensus state
|
||||
store := suite.chainA.App.IBCKeeper.ClientKeeper.ClientStore(suite.chainA.GetContext(), clientA)
|
||||
clientStateBz := suite.chainA.App.IBCKeeper.ClientKeeper.MustMarshalClientState(&types.ClientState{})
|
||||
store.Set(host.KeyConsensusState(height), clientStateBz)
|
||||
store.Set(host.ConsensusStateKey(height), clientStateBz)
|
||||
}, false,
|
||||
},
|
||||
{
|
||||
@ -42,7 +42,7 @@ func (suite *TendermintTestSuite) TestGetConsensusState() {
|
||||
// marshal and set solomachine consensus state
|
||||
store := suite.chainA.App.IBCKeeper.ClientKeeper.ClientStore(suite.chainA.GetContext(), clientA)
|
||||
consensusStateBz := suite.chainA.App.IBCKeeper.ClientKeeper.MustMarshalConsensusState(&solomachinetypes.ConsensusState{})
|
||||
store.Set(host.KeyConsensusState(height), consensusStateBz)
|
||||
store.Set(host.ConsensusStateKey(height), consensusStateBz)
|
||||
}, false,
|
||||
},
|
||||
}
|
||||
|
||||
@ -115,8 +115,8 @@ func (cs ClientState) VerifyClientState(
|
||||
store sdk.KVStore, cdc codec.BinaryMarshaler,
|
||||
_ exported.Height, _ exported.Prefix, _ string, _ []byte, clientState exported.ClientState,
|
||||
) error {
|
||||
path := host.KeyClientState()
|
||||
bz := store.Get(path)
|
||||
path := host.KeyClientState
|
||||
bz := store.Get([]byte(path))
|
||||
if bz == nil {
|
||||
return sdkerrors.Wrapf(clienttypes.ErrFailedClientStateVerification,
|
||||
"not found for path: %s", path)
|
||||
@ -154,7 +154,7 @@ func (cs ClientState) VerifyConnectionState(
|
||||
connectionID string,
|
||||
connectionEnd exported.ConnectionI,
|
||||
) error {
|
||||
path := host.KeyConnection(connectionID)
|
||||
path := host.ConnectionKey(connectionID)
|
||||
bz := store.Get(path)
|
||||
if bz == nil {
|
||||
return sdkerrors.Wrapf(clienttypes.ErrFailedConnectionStateVerification, "not found for path %s", path)
|
||||
@ -188,7 +188,7 @@ func (cs ClientState) VerifyChannelState(
|
||||
channelID string,
|
||||
channel exported.ChannelI,
|
||||
) error {
|
||||
path := host.KeyChannel(portID, channelID)
|
||||
path := host.ChannelKey(portID, channelID)
|
||||
bz := store.Get(path)
|
||||
if bz == nil {
|
||||
return sdkerrors.Wrapf(clienttypes.ErrFailedChannelStateVerification, "not found for path %s", path)
|
||||
@ -223,7 +223,7 @@ func (cs ClientState) VerifyPacketCommitment(
|
||||
sequence uint64,
|
||||
commitmentBytes []byte,
|
||||
) error {
|
||||
path := host.KeyPacketCommitment(portID, channelID, sequence)
|
||||
path := host.PacketCommitmentKey(portID, channelID, sequence)
|
||||
|
||||
data := store.Get(path)
|
||||
if len(data) == 0 {
|
||||
@ -253,7 +253,7 @@ func (cs ClientState) VerifyPacketAcknowledgement(
|
||||
sequence uint64,
|
||||
acknowledgement []byte,
|
||||
) error {
|
||||
path := host.KeyPacketAcknowledgement(portID, channelID, sequence)
|
||||
path := host.PacketAcknowledgementKey(portID, channelID, sequence)
|
||||
|
||||
data := store.Get(path)
|
||||
if len(data) == 0 {
|
||||
@ -283,7 +283,7 @@ func (cs ClientState) VerifyPacketReceiptAbsence(
|
||||
channelID string,
|
||||
sequence uint64,
|
||||
) error {
|
||||
path := host.KeyPacketReceipt(portID, channelID, sequence)
|
||||
path := host.PacketReceiptKey(portID, channelID, sequence)
|
||||
|
||||
data := store.Get(path)
|
||||
if data != nil {
|
||||
@ -305,7 +305,7 @@ func (cs ClientState) VerifyNextSequenceRecv(
|
||||
channelID string,
|
||||
nextSequenceRecv uint64,
|
||||
) error {
|
||||
path := host.KeyNextSequenceRecv(portID, channelID)
|
||||
path := host.NextSequenceRecvKey(portID, channelID)
|
||||
|
||||
data := store.Get(path)
|
||||
if len(data) == 0 {
|
||||
|
||||
@ -66,7 +66,7 @@ func (suite *LocalhostTestSuite) TestVerifyClientState() {
|
||||
clientState: clientState,
|
||||
malleate: func() {
|
||||
bz := clienttypes.MustMarshalClientState(suite.cdc, clientState)
|
||||
suite.store.Set(host.KeyClientState(), bz)
|
||||
suite.store.Set(host.ClientStateKey(), bz)
|
||||
},
|
||||
counterparty: clientState,
|
||||
expPass: true,
|
||||
@ -76,7 +76,7 @@ func (suite *LocalhostTestSuite) TestVerifyClientState() {
|
||||
clientState: clientState,
|
||||
malleate: func() {
|
||||
bz := clienttypes.MustMarshalClientState(suite.cdc, clientState)
|
||||
suite.store.Set(host.KeyClientState(), bz)
|
||||
suite.store.Set(host.ClientStateKey(), bz)
|
||||
},
|
||||
counterparty: invalidClient,
|
||||
expPass: false,
|
||||
@ -161,7 +161,7 @@ func (suite *LocalhostTestSuite) TestVerifyConnectionState() {
|
||||
malleate: func() {
|
||||
bz, err := suite.cdc.MarshalBinaryBare(&conn1)
|
||||
suite.Require().NoError(err)
|
||||
suite.store.Set(host.KeyConnection(testConnectionID), bz)
|
||||
suite.store.Set(host.ConnectionKey(testConnectionID), bz)
|
||||
},
|
||||
connection: conn1,
|
||||
expPass: true,
|
||||
@ -177,7 +177,7 @@ func (suite *LocalhostTestSuite) TestVerifyConnectionState() {
|
||||
name: "proof verification failed: unmarshal error",
|
||||
clientState: types.NewClientState("chainID", clientHeight),
|
||||
malleate: func() {
|
||||
suite.store.Set(host.KeyConnection(testConnectionID), []byte("connection"))
|
||||
suite.store.Set(host.ConnectionKey(testConnectionID), []byte("connection"))
|
||||
},
|
||||
connection: conn1,
|
||||
expPass: false,
|
||||
@ -188,7 +188,7 @@ func (suite *LocalhostTestSuite) TestVerifyConnectionState() {
|
||||
malleate: func() {
|
||||
bz, err := suite.cdc.MarshalBinaryBare(&conn2)
|
||||
suite.Require().NoError(err)
|
||||
suite.store.Set(host.KeyConnection(testConnectionID), bz)
|
||||
suite.store.Set(host.ConnectionKey(testConnectionID), bz)
|
||||
},
|
||||
connection: conn1,
|
||||
expPass: false,
|
||||
@ -233,7 +233,7 @@ func (suite *LocalhostTestSuite) TestVerifyChannelState() {
|
||||
malleate: func() {
|
||||
bz, err := suite.cdc.MarshalBinaryBare(&ch1)
|
||||
suite.Require().NoError(err)
|
||||
suite.store.Set(host.KeyChannel(testPortID, testChannelID), bz)
|
||||
suite.store.Set(host.ChannelKey(testPortID, testChannelID), bz)
|
||||
},
|
||||
channel: ch1,
|
||||
expPass: true,
|
||||
@ -249,7 +249,7 @@ func (suite *LocalhostTestSuite) TestVerifyChannelState() {
|
||||
name: "proof verification failed: unmarshal failed",
|
||||
clientState: types.NewClientState("chainID", clientHeight),
|
||||
malleate: func() {
|
||||
suite.store.Set(host.KeyChannel(testPortID, testChannelID), []byte("channel"))
|
||||
suite.store.Set(host.ChannelKey(testPortID, testChannelID), []byte("channel"))
|
||||
|
||||
},
|
||||
channel: ch1,
|
||||
@ -261,7 +261,7 @@ func (suite *LocalhostTestSuite) TestVerifyChannelState() {
|
||||
malleate: func() {
|
||||
bz, err := suite.cdc.MarshalBinaryBare(&ch2)
|
||||
suite.Require().NoError(err)
|
||||
suite.store.Set(host.KeyChannel(testPortID, testChannelID), bz)
|
||||
suite.store.Set(host.ChannelKey(testPortID, testChannelID), bz)
|
||||
|
||||
},
|
||||
channel: ch1,
|
||||
@ -302,7 +302,7 @@ func (suite *LocalhostTestSuite) TestVerifyPacketCommitment() {
|
||||
clientState: types.NewClientState("chainID", clientHeight),
|
||||
malleate: func() {
|
||||
suite.store.Set(
|
||||
host.KeyPacketCommitment(testPortID, testChannelID, testSequence), []byte("commitment"),
|
||||
host.PacketCommitmentKey(testPortID, testChannelID, testSequence), []byte("commitment"),
|
||||
)
|
||||
},
|
||||
commitment: []byte("commitment"),
|
||||
@ -313,7 +313,7 @@ func (suite *LocalhostTestSuite) TestVerifyPacketCommitment() {
|
||||
clientState: types.NewClientState("chainID", clientHeight),
|
||||
malleate: func() {
|
||||
suite.store.Set(
|
||||
host.KeyPacketCommitment(testPortID, testChannelID, testSequence), []byte("different"),
|
||||
host.PacketCommitmentKey(testPortID, testChannelID, testSequence), []byte("different"),
|
||||
)
|
||||
},
|
||||
commitment: []byte("commitment"),
|
||||
@ -361,7 +361,7 @@ func (suite *LocalhostTestSuite) TestVerifyPacketAcknowledgement() {
|
||||
clientState: types.NewClientState("chainID", clientHeight),
|
||||
malleate: func() {
|
||||
suite.store.Set(
|
||||
host.KeyPacketAcknowledgement(testPortID, testChannelID, testSequence), []byte("acknowledgement"),
|
||||
host.PacketAcknowledgementKey(testPortID, testChannelID, testSequence), []byte("acknowledgement"),
|
||||
)
|
||||
},
|
||||
ack: []byte("acknowledgement"),
|
||||
@ -372,7 +372,7 @@ func (suite *LocalhostTestSuite) TestVerifyPacketAcknowledgement() {
|
||||
clientState: types.NewClientState("chainID", clientHeight),
|
||||
malleate: func() {
|
||||
suite.store.Set(
|
||||
host.KeyPacketAcknowledgement(testPortID, testChannelID, testSequence), []byte("different"),
|
||||
host.PacketAcknowledgementKey(testPortID, testChannelID, testSequence), []byte("different"),
|
||||
)
|
||||
},
|
||||
ack: []byte("acknowledgement"),
|
||||
@ -416,7 +416,7 @@ func (suite *LocalhostTestSuite) TestVerifyPacketReceiptAbsence() {
|
||||
|
||||
suite.Require().NoError(err, "receipt absence failed")
|
||||
|
||||
suite.store.Set(host.KeyPacketReceipt(testPortID, testChannelID, testSequence), []byte("receipt"))
|
||||
suite.store.Set(host.PacketReceiptKey(testPortID, testChannelID, testSequence), []byte("receipt"))
|
||||
|
||||
err = clientState.VerifyPacketReceiptAbsence(
|
||||
suite.store, suite.cdc, clientHeight, nil, nil, testPortID, testChannelID, testSequence,
|
||||
@ -439,7 +439,7 @@ func (suite *LocalhostTestSuite) TestVerifyNextSeqRecv() {
|
||||
clientState: types.NewClientState("chainID", clientHeight),
|
||||
malleate: func() {
|
||||
suite.store.Set(
|
||||
host.KeyNextSequenceRecv(testPortID, testChannelID),
|
||||
host.NextSequenceRecvKey(testPortID, testChannelID),
|
||||
sdk.Uint64ToBigEndian(nextSeqRecv),
|
||||
)
|
||||
},
|
||||
@ -451,7 +451,7 @@ func (suite *LocalhostTestSuite) TestVerifyNextSeqRecv() {
|
||||
clientState: types.NewClientState("chainID", clientHeight),
|
||||
malleate: func() {
|
||||
suite.store.Set(
|
||||
host.KeyNextSequenceRecv(testPortID, testChannelID),
|
||||
host.NextSequenceRecvKey(testPortID, testChannelID),
|
||||
sdk.Uint64ToBigEndian(3),
|
||||
)
|
||||
},
|
||||
|
||||
@ -242,7 +242,7 @@ func (chain *TestChain) QueryClientStateProof(clientID string) (exported.ClientS
|
||||
clientState, found := chain.App.IBCKeeper.ClientKeeper.GetClientState(chain.GetContext(), clientID)
|
||||
require.True(chain.t, found)
|
||||
|
||||
clientKey := host.FullKeyClientPath(clientID, host.KeyClientState())
|
||||
clientKey := host.FullClientStateKey(clientID)
|
||||
proofClient, _ := chain.QueryProof(clientKey)
|
||||
|
||||
return clientState, proofClient
|
||||
@ -254,7 +254,7 @@ func (chain *TestChain) QueryConsensusStateProof(clientID string) ([]byte, clien
|
||||
clientState := chain.GetClientState(clientID)
|
||||
|
||||
consensusHeight := clientState.GetLatestHeight().(clienttypes.Height)
|
||||
consensusKey := host.FullKeyClientPath(clientID, host.KeyConsensusState(consensusHeight))
|
||||
consensusKey := host.FullConsensusStateKey(clientID, consensusHeight)
|
||||
proofConsensus, _ := chain.QueryProof(consensusKey)
|
||||
|
||||
return proofConsensus, consensusHeight
|
||||
@ -645,7 +645,7 @@ func (chain *TestChain) ConnectionOpenTry(
|
||||
) error {
|
||||
counterpartyClient, proofClient := counterparty.QueryClientStateProof(counterpartyConnection.ClientID)
|
||||
|
||||
connectionKey := host.KeyConnection(counterpartyConnection.ID)
|
||||
connectionKey := host.ConnectionKey(counterpartyConnection.ID)
|
||||
proofInit, proofHeight := counterparty.QueryProof(connectionKey)
|
||||
|
||||
proofConsensus, consensusHeight := counterparty.QueryConsensusStateProof(counterpartyConnection.ClientID)
|
||||
@ -668,7 +668,7 @@ func (chain *TestChain) ConnectionOpenAck(
|
||||
) error {
|
||||
counterpartyClient, proofClient := counterparty.QueryClientStateProof(counterpartyConnection.ClientID)
|
||||
|
||||
connectionKey := host.KeyConnection(counterpartyConnection.ID)
|
||||
connectionKey := host.ConnectionKey(counterpartyConnection.ID)
|
||||
proofTry, proofHeight := counterparty.QueryProof(connectionKey)
|
||||
|
||||
proofConsensus, consensusHeight := counterparty.QueryConsensusStateProof(counterpartyConnection.ClientID)
|
||||
@ -688,7 +688,7 @@ func (chain *TestChain) ConnectionOpenConfirm(
|
||||
counterparty *TestChain,
|
||||
connection, counterpartyConnection *TestConnection,
|
||||
) error {
|
||||
connectionKey := host.KeyConnection(counterpartyConnection.ID)
|
||||
connectionKey := host.ConnectionKey(counterpartyConnection.ID)
|
||||
proof, height := counterparty.QueryProof(connectionKey)
|
||||
|
||||
msg := connectiontypes.NewMsgConnectionOpenConfirm(
|
||||
@ -788,7 +788,7 @@ func (chain *TestChain) ChanOpenTry(
|
||||
order channeltypes.Order,
|
||||
connectionID string,
|
||||
) error {
|
||||
proof, height := counterparty.QueryProof(host.KeyChannel(counterpartyCh.PortID, counterpartyCh.ID))
|
||||
proof, height := counterparty.QueryProof(host.ChannelKey(counterpartyCh.PortID, counterpartyCh.ID))
|
||||
|
||||
msg := channeltypes.NewMsgChannelOpenTry(
|
||||
ch.PortID, ch.ID, ch.ID, // testing doesn't use flexible selection
|
||||
@ -806,7 +806,7 @@ func (chain *TestChain) ChanOpenAck(
|
||||
counterparty *TestChain,
|
||||
ch, counterpartyCh TestChannel,
|
||||
) error {
|
||||
proof, height := counterparty.QueryProof(host.KeyChannel(counterpartyCh.PortID, counterpartyCh.ID))
|
||||
proof, height := counterparty.QueryProof(host.ChannelKey(counterpartyCh.PortID, counterpartyCh.ID))
|
||||
|
||||
msg := channeltypes.NewMsgChannelOpenAck(
|
||||
ch.PortID, ch.ID,
|
||||
@ -822,7 +822,7 @@ func (chain *TestChain) ChanOpenConfirm(
|
||||
counterparty *TestChain,
|
||||
ch, counterpartyCh TestChannel,
|
||||
) error {
|
||||
proof, height := counterparty.QueryProof(host.KeyChannel(counterpartyCh.PortID, counterpartyCh.ID))
|
||||
proof, height := counterparty.QueryProof(host.ChannelKey(counterpartyCh.PortID, counterpartyCh.ID))
|
||||
|
||||
msg := channeltypes.NewMsgChannelOpenConfirm(
|
||||
ch.PortID, ch.ID,
|
||||
|
||||
@ -238,7 +238,7 @@ func (coord *Coordinator) RecvPacket(
|
||||
packet channeltypes.Packet,
|
||||
) error {
|
||||
// get proof of packet commitment on source
|
||||
packetKey := host.KeyPacketCommitment(packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence())
|
||||
packetKey := host.PacketCommitmentKey(packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence())
|
||||
proof, proofHeight := source.QueryProof(packetKey)
|
||||
|
||||
recvMsg := channeltypes.NewMsgRecvPacket(packet, proof, proofHeight, counterparty.SenderAccount.GetAddress())
|
||||
@ -277,7 +277,7 @@ func (coord *Coordinator) AcknowledgePacket(
|
||||
packet channeltypes.Packet, ack []byte,
|
||||
) error {
|
||||
// get proof of acknowledgement on counterparty
|
||||
packetKey := host.KeyPacketAcknowledgement(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence())
|
||||
packetKey := host.PacketAcknowledgementKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence())
|
||||
proof, proofHeight := counterparty.QueryProof(packetKey)
|
||||
|
||||
ackMsg := channeltypes.NewMsgAcknowledgement(packet, ack, proof, proofHeight, source.SenderAccount.GetAddress())
|
||||
|
||||
@ -251,8 +251,7 @@ func (solo *Solomachine) GenerateSignature(signBytes []byte) []byte {
|
||||
|
||||
// GetClientStatePath returns the commitment path for the client state.
|
||||
func (solo *Solomachine) GetClientStatePath(counterpartyClientIdentifier string) commitmenttypes.MerklePath {
|
||||
clientPrefixedPath := commitmenttypes.NewMerklePath("clients/" + counterpartyClientIdentifier + "/" + host.ClientStatePath())
|
||||
path, err := commitmenttypes.ApplyPrefix(prefix, clientPrefixedPath)
|
||||
path, err := commitmenttypes.ApplyPrefix(prefix, commitmenttypes.NewMerklePath(host.FullClientStatePath(counterpartyClientIdentifier)))
|
||||
require.NoError(solo.t, err)
|
||||
|
||||
return path
|
||||
@ -260,8 +259,7 @@ func (solo *Solomachine) GetClientStatePath(counterpartyClientIdentifier string)
|
||||
|
||||
// GetConsensusStatePath returns the commitment path for the consensus state.
|
||||
func (solo *Solomachine) GetConsensusStatePath(counterpartyClientIdentifier string, consensusHeight exported.Height) commitmenttypes.MerklePath {
|
||||
clientPrefixedPath := commitmenttypes.NewMerklePath("clients/" + counterpartyClientIdentifier + "/" + host.ConsensusStatePath(consensusHeight))
|
||||
path, err := commitmenttypes.ApplyPrefix(prefix, clientPrefixedPath)
|
||||
path, err := commitmenttypes.ApplyPrefix(prefix, commitmenttypes.NewMerklePath(host.FullConsensusStatePath(counterpartyClientIdentifier, consensusHeight)))
|
||||
require.NoError(solo.t, err)
|
||||
|
||||
return path
|
||||
|
||||
Loading…
Reference in New Issue
Block a user