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

refactor: add delegations by validator index #15731

Merged
merged 41 commits into from
Apr 24, 2023
Merged

Conversation

atheeshp
Copy link
Contributor

@atheeshp atheeshp commented Apr 7, 2023

Description

  • This PR adds an index to iterate over delegations by a validator
  • This is a subtask of rotating operator keys.
  • Current design to iterate over delegations of a validator is takes longer time since there is no index.

ref: #3863 , #5231
Closes: #15162
part of work related to: #15494


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • followed the guidelines for building modules
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

x/staking/keeper/delegation.go Fixed Show fixed Hide fixed
x/staking/keeper/grpc_query.go Fixed Show fixed Hide fixed
x/staking/keeper/delegation.go Fixed Show fixed Hide fixed
x/staking/keeper/delegation.go Fixed Show fixed Hide fixed
@atheeshp atheeshp marked this pull request as ready for review April 7, 2023 11:08
@atheeshp atheeshp requested a review from a team as a code owner April 7, 2023 11:08
"github.com/cosmos/cosmos-sdk/x/staking/types"
)

func MigrateStore(ctx sdk.Context, storeKey storetypes.StoreKey, cdc codec.BinaryCodec) (storetypes.KVStore, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would be good if we had some tooling to grab a state export from any mainnet then run the migration to see what the time will be. This would allow us to add warnings for users when upgrading.

Out of scope for this pr but something we should so in the near future

x/staking/keeper/delegation.go Outdated Show resolved Hide resolved
x/staking/keeper/delegation.go Outdated Show resolved Hide resolved
x/staking/keeper/delegation.go Outdated Show resolved Hide resolved
x/staking/keeper/delegation.go Outdated Show resolved Hide resolved
x/staking/keeper/delegation.go Outdated Show resolved Hide resolved
Copy link
Contributor

@alexanderbez alexanderbez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the patience in review. LGTM

x/staking/keeper/grpc_query.go Outdated Show resolved Hide resolved
x/staking/migrations/v5/keys.go Outdated Show resolved Hide resolved
Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
Copy link
Member

@tac0turtle tac0turtle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK

Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
@tac0turtle tac0turtle added this pull request to the merge queue Apr 24, 2023
Merged via the queue into main with commit 7b56024 Apr 24, 2023
@tac0turtle tac0turtle deleted the ap/delegations-by-validator branch April 24, 2023 14:16
cool-develope pushed a commit that referenced this pull request Apr 26, 2023
Co-authored-by: Marko <marbar3778@yahoo.com>
Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
@@ -40,6 +40,7 @@ var (
RedelegationKey = []byte{0x34} // 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
DelegationByValIndexKey = []byte{0x37} // key for delegations by a validator
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry to poke my head here, but this is a bug no? Looks like the same key value as UnbondingIDKey below?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup that is right, cant wait to rewrite this module to use colletions. @atheeshp can you fix this please

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, haven't noticed it. Raised fix PR(#16176) thanks for finding it 🙏 .

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tac0turtle has this PR been backported to SDK47?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feature isn't included in v0.47, but is in v0.50.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Optimising querying for validator delegations
7 participants