Skip to content

feat: add inverse index and pruning of peers#40

Draft
facundomedica wants to merge 1 commit intomainfrom
facu/add-pruning-peers
Draft

feat: add inverse index and pruning of peers#40
facundomedica wants to merge 1 commit intomainfrom
facu/add-pruning-peers

Conversation

@facundomedica
Copy link
Copy Markdown

This is a naive approach to the pruning problem:

  • Create an inverse index and maintain it every time a validator updates its peers
  • Implement staking hooks so when a validator is removed from the valset, its peers get all deleted
  • Add tests

This has the problem that the existing entries won't be pruned, because we don't have a reverse index of those.

Alternative, which I like the most: do a bigger rewrite of the module (do it simpler, maybe using collections), with a migration that will only keep the entries for the validators that are in the valset at the time of the upgrade.

// AfterValidatorRemoved implements types.StakingHooks.
func (h Hooks) AfterValidatorRemoved(ctx context.Context, consAddr types.ConsAddress, valAddr types.ValAddress) error {
sdkCtx := sdk.UnwrapSDKContext(ctx)
h.k.DeleteAllValidatorData(sdkCtx, valAddr.String())

Check warning

Code scanning / gosec

Errors unhandled Warning

Errors unhandled
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants