-
Notifications
You must be signed in to change notification settings - Fork 586
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor!: remove 24-host path function in favour of sybling key func…
…tions (#7016) * refactor: remove all Path functions from 24-host in favour of Key functions * docs: migration + changelog * Update docs/docs/05-migrations/13-v8-to-v9.md * lint
- Loading branch information
1 parent
b8f944e
commit f4eba71
Showing
13 changed files
with
104 additions
and
210 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,46 @@ | ||
package host | ||
|
||
import "fmt" | ||
|
||
const ( | ||
KeyChannelEndPrefix = "channelEnds" | ||
KeyChannelPrefix = "channels" | ||
KeyChannelUpgradePrefix = "channelUpgrades" | ||
KeyUpgradePrefix = "upgrades" | ||
KeyUpgradeErrorPrefix = "upgradeError" | ||
KeyCounterpartyUpgrade = "counterpartyUpgrade" | ||
KeyChannelCapabilityPrefix = "capabilities" | ||
) | ||
|
||
// ICS04 | ||
// The following paths are the keys to the store as defined in https://github.com/cosmos/ibc/tree/master/spec/core/ics-004-channel-and-packet-semantics#store-paths | ||
|
||
// ChannelKey returns the store key for a particular channel | ||
func ChannelKey(portID, channelID string) []byte { | ||
return []byte(ChannelPath(portID, channelID)) | ||
return []byte(fmt.Sprintf("%s/%s", KeyChannelEndPrefix, 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/%s", KeyChannelCapabilityPrefix, channelPath(portID, channelID)) | ||
} | ||
|
||
// ChannelUpgradeErrorKey returns the store key for a particular channelEnd used to stor the ErrorReceipt in the case that a chain does not accept the proposed upgrade | ||
func ChannelUpgradeErrorKey(portID, channelID string) []byte { | ||
return []byte(ChannelUpgradeErrorPath(portID, channelID)) | ||
return []byte(fmt.Sprintf("%s/%s/%s", KeyChannelUpgradePrefix, KeyUpgradeErrorPrefix, channelPath(portID, channelID))) | ||
} | ||
|
||
// ChannelUpgradeKey returns the store key for a particular channel upgrade attempt | ||
func ChannelUpgradeKey(portID, channelID string) []byte { | ||
return []byte(ChannelUpgradePath(portID, channelID)) | ||
return []byte(fmt.Sprintf("%s/%s/%s", KeyChannelUpgradePrefix, KeyUpgradePrefix, channelPath(portID, channelID))) | ||
} | ||
|
||
// ChannelCounterpartyUpgradeKey returns the store key for the upgrade used on the counterparty channel. | ||
func ChannelCounterpartyUpgradeKey(portID, channelID string) []byte { | ||
return []byte(ChannelCounterpartyUpgradePath(portID, channelID)) | ||
return []byte(fmt.Sprintf("%s/%s/%s", KeyChannelUpgradePrefix, KeyCounterpartyUpgrade, channelPath(portID, channelID))) | ||
} | ||
|
||
func channelPath(portID, channelID string) string { | ||
return fmt.Sprintf("%s/%s/%s/%s", KeyPortPrefix, portID, KeyChannelPrefix, channelID) | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,18 @@ | ||
package host | ||
|
||
import "fmt" | ||
|
||
const KeyConnectionPrefix = "connections" | ||
|
||
// ICS03 | ||
// The following paths are the keys to the store as defined in https://github.com/cosmos/ibc/blob/master/spec/core/ics-003-connection-semantics#store-paths | ||
|
||
// ClientConnectionsKey returns the store key for the connections of a given client | ||
func ClientConnectionsKey(clientID string) []byte { | ||
return []byte(ClientConnectionsPath(clientID)) | ||
return FullClientKey(clientID, []byte(KeyConnectionPrefix)) | ||
} | ||
|
||
// ConnectionKey returns the store key for a particular connection | ||
func ConnectionKey(connectionID string) []byte { | ||
return []byte(ConnectionPath(connectionID)) | ||
return []byte(fmt.Sprintf("%s/%s", KeyConnectionPrefix, connectionID)) | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,78 @@ | ||
package host | ||
|
||
import "fmt" | ||
|
||
const ( | ||
KeySequencePrefix = "sequences" | ||
KeyNextSeqSendPrefix = "nextSequenceSend" | ||
KeyNextSeqRecvPrefix = "nextSequenceRecv" | ||
KeyNextSeqAckPrefix = "nextSequenceAck" | ||
KeyPacketCommitmentPrefix = "commitments" | ||
KeyPacketAckPrefix = "acks" | ||
KeyPacketReceiptPrefix = "receipts" | ||
KeyPruningSequenceStart = "pruningSequenceStart" | ||
KeyRecvStartSequence = "recvStartSequence" | ||
) | ||
|
||
// ICS04 | ||
// The following paths are the keys to the store as defined in https://github.com/cosmos/ibc/tree/master/spec/core/ics-004-channel-and-packet-semantics#store-paths | ||
|
||
// 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)) | ||
return []byte(fmt.Sprintf("%s/%s", KeyNextSeqSendPrefix, 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)) | ||
return []byte(fmt.Sprintf("%s/%s", KeyNextSeqRecvPrefix, 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)) | ||
return []byte(fmt.Sprintf("%s/%s", KeyNextSeqAckPrefix, channelPath(portID, channelID))) | ||
} | ||
|
||
// 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)) | ||
return []byte(fmt.Sprintf("%s/%d", PacketCommitmentPrefixKey(portID, channelID), sequence)) | ||
} | ||
|
||
// PacketCommitmentPrefixKey defines the prefix for commitments to packet data fields store path. | ||
func PacketCommitmentPrefixKey(portID, channelID string) []byte { | ||
return []byte(fmt.Sprintf("%s/%s/%s", KeyPacketCommitmentPrefix, channelPath(portID, channelID), KeySequencePrefix)) | ||
} | ||
|
||
// 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)) | ||
return []byte(fmt.Sprintf("%s/%d", PacketAcknowledgementPrefixKey(portID, channelID), sequence)) | ||
} | ||
|
||
// PacketAcknowledgementPrefixKey defines the prefix for commitments to packet data fields store path. | ||
func PacketAcknowledgementPrefixKey(portID, channelID string) []byte { | ||
return []byte(fmt.Sprintf("%s/%s/%s", KeyPacketAckPrefix, channelPath(portID, channelID), KeySequencePrefix)) | ||
} | ||
|
||
// PacketReceiptKey returns the store key of under which a packet | ||
// receipt is stored | ||
func PacketReceiptKey(portID, channelID string, sequence uint64) []byte { | ||
return []byte(PacketReceiptPath(portID, channelID, sequence)) | ||
return []byte(fmt.Sprintf("%s/%s/%s", KeyPacketReceiptPrefix, channelPath(portID, channelID), sequencePath(sequence))) | ||
} | ||
|
||
// PruningSequenceStartKey returns the store key for the pruning sequence start of a particular channel | ||
func PruningSequenceStartKey(portID, channelID string) []byte { | ||
return []byte(PruningSequenceStartPath(portID, channelID)) | ||
return []byte(fmt.Sprintf("%s/%s", KeyPruningSequenceStart, channelPath(portID, channelID))) | ||
} | ||
|
||
// RecvStartSequenceKey returns the store key for the recv start sequence of a particular channel | ||
func RecvStartSequenceKey(portID, channelID string) []byte { | ||
return []byte(RecvStartSequencePath(portID, channelID)) | ||
return []byte(fmt.Sprintf("%s/%s", KeyRecvStartSequence, channelPath(portID, channelID))) | ||
} | ||
|
||
func sequencePath(sequence uint64) string { | ||
return fmt.Sprintf("%s/%d", KeySequencePrefix, sequence) | ||
} |
Oops, something went wrong.