Skip to content

refactor: add delegations by validator index#15731

Merged
tac0turtle merged 41 commits into
mainfrom
ap/delegations-by-validator
Apr 24, 2023
Merged

refactor: add delegations by validator index#15731
tac0turtle merged 41 commits into
mainfrom
ap/delegations-by-validator

Conversation

@atheeshp
Copy link
Copy Markdown
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)

Comment thread x/staking/keeper/delegation.go Fixed
Comment thread x/staking/keeper/grpc_query.go Fixed
Comment thread x/staking/keeper/delegation.go Fixed
Comment thread x/staking/keeper/delegation.go Fixed
@atheeshp atheeshp marked this pull request as ready for review April 7, 2023 11:08
@atheeshp atheeshp requested a review from a team April 7, 2023 11:08
@ghost ghost requested review from a team, kocubinski and likhita-809 and removed request for a team April 7, 2023 11:08
Comment thread x/staking/migrations/v5/store.go Outdated
"github.com/cosmos/cosmos-sdk/x/staking/types"
)

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

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

Comment thread tests/integration/staking/keeper/validator_bench_test.go
Comment thread x/staking/keeper/delegation.go Outdated
Comment thread x/staking/keeper/delegation.go Outdated
@atheeshp atheeshp requested a review from alexanderbez April 11, 2023 06:43
Comment thread x/staking/keeper/delegation.go Outdated
Comment thread x/staking/keeper/delegation.go Outdated
Comment thread x/staking/keeper/delegation.go Outdated
@atheeshp atheeshp requested a review from alexanderbez April 18, 2023 09:46
Comment thread x/staking/keeper/grpc_query.go Fixed
Comment thread tests/integration/staking/keeper/validator_bench_test.go Outdated
Comment thread tests/integration/staking/keeper/validator_bench_test.go Outdated
@atheeshp atheeshp requested a review from alexanderbez April 20, 2023 05:59
Comment thread x/staking/keeper/grpc_query.go
Copy link
Copy Markdown
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

Comment thread x/staking/keeper/grpc_query.go Outdated
Comment thread x/staking/migrations/v5/keys.go Outdated
Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

@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 enabled auto-merge April 23, 2023 16:14
@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
Comment thread x/staking/types/keys.go
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
Copy Markdown
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
Copy Markdown
Contributor

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
Copy Markdown
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 🙏 .

Copy link
Copy Markdown

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
Copy Markdown
Contributor

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

8 participants