-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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(x/staking): migrate RedelegationByValDstIndexKey key to collections #17336
Merged
Merged
Changes from 25 commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
b902f71
refactor(x/staking): migrate redelegation key to use collections
atheeshp 19fa78e
tests
atheeshp 1e6c102
all redelegations
atheeshp df4cd76
Merge branch 'main' of github.com:cosmos/cosmos-sdk into ap/redelegat…
atheeshp ef48759
fix tests
atheeshp dcbba95
conflicts
atheeshp 948e9bd
Merge branch 'main' of github.com:cosmos/cosmos-sdk into ap/redelegat…
atheeshp cd46d89
fix tests
atheeshp 54b97c3
Merge branch 'main' of github.com:cosmos/cosmos-sdk into ap/redelegat…
atheeshp eb0ac8d
handle errors
atheeshp 910493c
Merge branch 'main' of github.com:cosmos/cosmos-sdk into ap/redelegat…
atheeshp 74f28cf
Merge branch 'main' into ap/redelegation-key-to-collections
atheeshp fa6fe54
refactor(x/staking): migrate `RedelegationByValDstIndexKey` key to co…
atheeshp 8e37291
fix tests
atheeshp dea9749
Merge branch 'ap/redelegation-key-to-collections' of github.com:cosmo…
atheeshp 3829443
Merge branch 'ap/redelegation-key-to-collections' of github.com:cosmo…
atheeshp 235427a
lint
atheeshp 7f3d119
Merge branch 'ap/redelegation-key-to-collections' of github.com:cosmo…
atheeshp 67c0c40
Merge branch 'main' into ap/redelegation-key-to-collections
atheeshp 63874f6
Merge branch 'main' into ap/redelegation-key-to-collections
atheeshp eb2e900
fix tests
atheeshp 8e17907
Merge branch 'ap/redelegation-key-to-collections' of github.com:cosmo…
atheeshp 6c61681
Merge branch 'main' of github.com:cosmos/cosmos-sdk into ap/red-from-…
atheeshp a3d20e6
review changes
atheeshp aef6358
Merge branch 'main' of github.com:cosmos/cosmos-sdk into ap/red-from-…
atheeshp 96df42d
add tests to check diff collection
atheeshp 817c525
Merge branch 'main' of github.com:cosmos/cosmos-sdk into ap/red-from-…
atheeshp fbaf112
inline docs
atheeshp 768f623
fix lint
atheeshp f92e5d6
Merge branch 'main' into ap/red-from-val-dst-to-coll
atheeshp 3032596
Merge branch 'main' into ap/red-from-val-dst-to-coll
atheeshp 06fe202
Merge branch 'main' into ap/red-from-val-dst-to-coll
atheeshp 1c31f42
Merge branch 'main' of github.com:cosmos/cosmos-sdk into ap/red-from-…
atheeshp ec066b7
fix build
atheeshp 317a614
Merge branch 'main' of github.com:cosmos/cosmos-sdk into ap/red-from-…
atheeshp 9741e77
Merge branch 'ap/red-from-val-dst-to-coll' of github.com:cosmos/cosmo…
atheeshp 1291f65
fix doc
atheeshp f22d905
doc
atheeshp 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 |
---|---|---|
|
@@ -44,7 +44,7 @@ var ( | |
UnbondingDelegationByValIndexKey = []byte{0x33} // prefix for each key for an unbonding-delegation, by validator operator | ||
RedelegationKey = collections.NewPrefix(52) // key for a redelegation | ||
RedelegationByValSrcIndexKey = []byte{0x35} // prefix for each key for an redelegation, by source validator operator | ||
RedelegationByValDstIndexKey = []byte{0x36} // prefix for each key for an redelegation, by destination validator operator | ||
RedelegationByValDstIndexKey = collections.NewPrefix(54) // prefix for each key for an redelegation, by destination validator operator | ||
|
||
UnbondingIDKey = collections.NewPrefix(55) // key for the counter for the incrementing id for UnbondingOperations | ||
UnbondingIndexKey = collections.NewPrefix(56) // prefix for an index for looking up unbonding operations by their IDs | ||
|
@@ -264,23 +264,6 @@ func GetREDByValSrcIndexKey(delAddr sdk.AccAddress, valSrcAddr, valDstAddr sdk.V | |
return key | ||
} | ||
|
||
// GetREDByValDstIndexKey creates the index-key for a redelegation, stored by destination-validator-index | ||
// VALUE: none (key rearrangement used) | ||
func GetREDByValDstIndexKey(delAddr sdk.AccAddress, valSrcAddr, valDstAddr sdk.ValAddress) []byte { | ||
REDSToValsDstKey := GetREDsToValDstIndexKey(valDstAddr) | ||
offset := len(REDSToValsDstKey) | ||
|
||
// key is of the form REDSToValsDstKey || delAddrLen (1 byte) || delAddr || valSrcAddrLen (1 byte) || valSrcAddr | ||
key := make([]byte, offset+2+len(delAddr)+len(valSrcAddr)) | ||
copy(key[0:offset], REDSToValsDstKey) | ||
key[offset] = byte(len(delAddr)) | ||
copy(key[offset+1:offset+1+len(delAddr)], delAddr.Bytes()) | ||
key[offset+1+len(delAddr)] = byte(len(valSrcAddr)) | ||
copy(key[offset+2+len(delAddr):], valSrcAddr.Bytes()) | ||
|
||
return key | ||
} | ||
|
||
// GetREDKeyFromValSrcIndexKey rearranges the ValSrcIndexKey to get the REDKey | ||
func GetREDKeyFromValSrcIndexKey(indexKey []byte) []byte { | ||
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. why is this needed? 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. This is removed in other branch of migrating |
||
// note that first byte is prefix byte, which we remove | ||
|
@@ -299,24 +282,6 @@ func GetREDKeyFromValSrcIndexKey(indexKey []byte) []byte { | |
return GetREDKey(delAddr, valSrcAddr, valDstAddr) | ||
} | ||
|
||
// GetREDKeyFromValDstIndexKey rearranges the ValDstIndexKey to get the REDKey | ||
func GetREDKeyFromValDstIndexKey(indexKey []byte) []byte { | ||
// note that first byte is prefix byte, which we remove | ||
kv.AssertKeyAtLeastLength(indexKey, 2) | ||
addrs := indexKey[1:] | ||
|
||
valDstAddrLen := addrs[0] | ||
kv.AssertKeyAtLeastLength(addrs, int(valDstAddrLen)+2) | ||
valDstAddr := addrs[1 : valDstAddrLen+1] | ||
delAddrLen := addrs[valDstAddrLen+1] | ||
kv.AssertKeyAtLeastLength(addrs, int(valDstAddrLen)+int(delAddrLen)+3) | ||
delAddr := addrs[valDstAddrLen+2 : valDstAddrLen+2+delAddrLen] | ||
kv.AssertKeyAtLeastLength(addrs, int(valDstAddrLen)+int(delAddrLen)+4) | ||
valSrcAddr := addrs[valDstAddrLen+delAddrLen+3:] | ||
|
||
return GetREDKey(delAddr, valSrcAddr, valDstAddr) | ||
} | ||
|
||
// GetRedelegationTimeKey returns a key prefix for indexing an unbonding | ||
// redelegation based on a completion time. | ||
func GetRedelegationTimeKey(timestamp time.Time) []byte { | ||
|
@@ -335,15 +300,3 @@ func GetREDsKey(delAddr sdk.AccAddress) []byte { | |
func GetREDsFromValSrcIndexKey(valSrcAddr sdk.ValAddress) []byte { | ||
return append(RedelegationByValSrcIndexKey, address.MustLengthPrefix(valSrcAddr)...) | ||
} | ||
|
||
// GetREDsToValDstIndexKey returns a key prefix for indexing a redelegation to a | ||
// destination (target) validator. | ||
func GetREDsToValDstIndexKey(valDstAddr sdk.ValAddress) []byte { | ||
return append(RedelegationByValDstIndexKey, address.MustLengthPrefix(valDstAddr)...) | ||
} | ||
|
||
// GetREDsByDelToValDstIndexKey returns a key prefix for indexing a redelegation | ||
// from an address to a source validator. | ||
func GetREDsByDelToValDstIndexKey(delAddr sdk.AccAddress, valDstAddr sdk.ValAddress) []byte { | ||
return append(GetREDsToValDstIndexKey(valDstAddr), address.MustLengthPrefix(delAddr)...) | ||
} |
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
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.
Changelog missing
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.
missed it, will raise a PR.