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

feat(finality): move voting power table to finality module #217

Merged
merged 2 commits into from
Oct 29, 2024

Conversation

SebastianElvis
Copy link
Member

@SebastianElvis SebastianElvis commented Oct 22, 2024

Resolves #24

This PR moves voting power table to finality module, including all relevant KV stores, APIs and functions. This ensures that

  • BTC staking module becomes the "staking hub" for storing all FPs and BTC delegations of Babylon and consumer chains
  • Finality module becomes the 1st use case of this staking hub, namely providing BTC staking finality for Babylon chain

@KonradStaniec KonradStaniec added consensus breaking change modifies `appHash` of the application api breaking breaks grpc api in non-compatible way labels Oct 22, 2024
@SebastianElvis SebastianElvis changed the title finality: move voting power table to finality module feat(finality): move voting power table to finality module Oct 23, 2024
@SebastianElvis SebastianElvis force-pushed the feat/voting-power-table-refactor branch 3 times, most recently from 1be8537 to e8dd7f5 Compare October 25, 2024 04:32
@SebastianElvis SebastianElvis marked this pull request as ready for review October 25, 2024 04:41
@SebastianElvis SebastianElvis requested a review from a team as a code owner October 25, 2024 04:41
@SebastianElvis SebastianElvis requested review from gitferry, KonradStaniec, Lazar955 and RafilxTenfen and removed request for a team October 25, 2024 04:41
Copy link
Member

@gitferry gitferry left a comment

Choose a reason for hiding this comment

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

lgtm apart from the conflicts

First step of #24

This PR moves the voting power distribution update algorithm to
`x/finality`. This is a major refactoring that includes

- moving `max_active_finality_providers` parameter to `x/finality`
- moving many functions in `x/btcstaking/power_dist_change.go` and
relevant tests to `x/finality`
- moving test utilities under `x/btcstaking/keeper_test.go` to a new
module `testutil/btcstaking-helper`, and use it for existing tests of
`x/btcstaking` and `x/finality`
- removing the cyclic dependency between `x/btcstaking` and
`x/finality`, as well as their hooks. Now the hooks in these 2 modules
are not necessary, as the only dependency between them is that
`x/finality` will invoke `x/btcstaking`, but not the other way

TODOs in subsequent PRs:

- moving some relevant query APIs to `x/finality`
- moving the voting power dist cache and voting power table KV stores to
`x/finality`
Second half of #24

This PR moves the voting power table/cache and relevant APIs to
`x/finality`. This includes the following

- [x] move voting power table KV store to `x/finality`
- [x] move voting power dist cache to `x/finality`
- [x] move 4 APIs `ActiveFinalityProvidersAtHeight`,
`FinalityProviderPowerAtHeight`, `FinalityProviderCurrentPower`,
`ActivatedHeight` to `x/finality`
- [x] fix fuzz tests
- [x] fix e2e tests
- [x] fix doc
- [x] fix changelog

Note that this affects many LoCs since it touches a bunch of proto
files. The actual modification is much smaller than it looks like.
@SebastianElvis SebastianElvis merged commit fcc6fdc into main Oct 29, 2024
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api breaking breaks grpc api in non-compatible way consensus breaking change modifies `appHash` of the application
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Moving voting power table from btcstaking module to finality module
3 participants