Skip to content
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

fix: proper consumer key prefix ordering #991

Merged
merged 5 commits into from
Jun 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 22 additions & 17 deletions x/ccv/consumer/types/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,23 @@ const (
// received over CCV channel but not yet flushed over ABCI
PendingChangesByteKey

// NOTE: This prefix is depreciated, but left in place to avoid consumer state migrations
// [DEPRECATED]
PendingDataPacketsByteKey
shaspitz marked this conversation as resolved.
Show resolved Hide resolved

// PreCCVByteKey is the byte to store the consumer is running on democracy staking module without consumer
PreCCVByteKey

// InitialValSetByteKey is the byte to store the initial validator set for a consumer
InitialValSetByteKey

// NOTE: This prefix is depreciated, but left in place to avoid consumer state migrations
// [DEPRECATED]
LastStandaloneHeightByteKey

// SmallestNonOptOutPowerByteKey is the byte that will store the smallest val power that cannot opt out
SmallestNonOptOutPowerByteKey

// HistoricalInfoKey is the byte prefix that will store the historical info for a given height
HistoricalInfoBytePrefix

Expand All @@ -61,30 +78,18 @@ const (
// OutstandingDowntimePrefix is the byte prefix that will store the validators outstanding downtime by consensus address
OutstandingDowntimeBytePrefix

// NOTE: This prefix is depreciated, but left in place to avoid consumer state migrations
PendingDataPacketsBytePrefix

// CrossChainValidatorPrefix is the byte prefix that will store cross-chain validators by consensus address
CrossChainValidatorBytePrefix

// PendingDataPacketsByteKey is the byte key for storing
// PendingDataPacketsBytePrefix is the byte prefix for storing
// a list of data packets that cannot be sent yet to the provider
// chain either because the CCV channel is not established or
// because the client is expired
PendingDataPacketsByteKey

// PreCCVByteKey is the byte to store the consumer is running on democracy staking module without consumer
PreCCVByteKey
PendingDataPacketsBytePrefix

// InitialValSetByteKey is the byte to store the initial validator set for a consumer
InitialValSetByteKey
// CrossChainValidatorPrefix is the byte prefix that will store cross-chain validators by consensus address
CrossChainValidatorBytePrefix

// InitGenesisHeightByteKey is the byte that will store the init genesis height
InitGenesisHeightByteKey

// SmallestNonOptOutPowerByteKey is the byte that will store the smallest val power that cannot opt out
SmallestNonOptOutPowerByteKey

// StandaloneTransferChannelIDByteKey is the byte storing the channelID of transfer channel
// that existed from a standalone chain changing over to a consumer
StandaloneTransferChannelIDByteKey
Expand Down Expand Up @@ -170,7 +175,7 @@ func CrossChainValidatorKey(addr []byte) []byte {
// that cannot be sent yet to the provider chain either because the CCV channel
// is not established or because the client is expired.
func PendingDataPacketsKey() []byte {
return []byte{PendingDataPacketsByteKey}
return []byte{PendingDataPacketsBytePrefix}
}

func PreCCVKey() []byte {
Expand Down
20 changes: 12 additions & 8 deletions x/ccv/consumer/types/keys_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,18 @@ func getAllKeyPrefixes() []byte {
ProviderClientByteKey,
ProviderChannelByteKey,
PendingChangesByteKey,
PendingDataPacketsByteKey,
PreCCVByteKey,
InitialValSetByteKey,
LastStandaloneHeightByteKey,
SmallestNonOptOutPowerByteKey,
HistoricalInfoBytePrefix,
PacketMaturityTimeBytePrefix,
HeightValsetUpdateIDBytePrefix,
OutstandingDowntimeBytePrefix,
PendingDataPacketsBytePrefix,
CrossChainValidatorBytePrefix,
PendingDataPacketsByteKey,
PreCCVByteKey,
InitialValSetByteKey,
InitGenesisHeightByteKey,
SmallestNonOptOutPowerByteKey,
StandaloneTransferChannelIDByteKey,
PrevStandaloneChainByteKey,
}
Expand All @@ -61,16 +63,18 @@ func getAllFullyDefinedKeys() [][]byte {
ProviderClientIDKey(),
ProviderChannelKey(),
PendingChangesKey(),
// PendingDataPacketsKey() does not use duplicated prefix with value of 0x06
PreCCVKey(),
InitialValSetKey(),
// LastStandaloneHeightKey() is depreciated
SmallestNonOptOutPowerKey(),
HistoricalInfoKey(0),
PacketMaturityTimeKey(0, time.Time{}),
HeightValsetUpdateIDKey(0),
OutstandingDowntimeKey([]byte{}),
CrossChainValidatorKey([]byte{}),
PendingDataPacketsKey(),
PreCCVKey(),
InitialValSetKey(),
CrossChainValidatorKey([]byte{}),
InitGenesisHeightKey(),
SmallestNonOptOutPowerKey(),
StandaloneTransferChannelIDKey(),
PrevStandaloneChainKey(),
}
Expand Down