-
Notifications
You must be signed in to change notification settings - Fork 646
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor!: remove 24-host path function in favour of sybling key functions #7016
Merged
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
e0697a7
refactor: remove all Path functions from 24-host in favour of Key fun…
colin-axner 9f02b57
Merge branch 'main' of github.com:cosmos/ibc-go into colin/6882-host-…
colin-axner 81dc19c
docs: migration + changelog
colin-axner aba0a5c
Update docs/docs/05-migrations/13-v8-to-v9.md
colin-axner f64c2ff
lint
colin-axner 0a0ba7c
Merge branch 'colin/6882-host-path' of github.com:cosmos/ibc-go into …
colin-axner File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ported over, will be removed in v10 |
||
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
full copy/paste from _path.go