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(ADR-025): Enable jailing and unjailing #80

Merged
merged 3 commits into from
Sep 19, 2024
Merged

Conversation

gitferry
Copy link
Contributor

@gitferry gitferry commented Sep 18, 2024

This PR partially closes #64 by jailing sluggish finality providers by
not assigning voting power to them in the voting power table. In
particular, this PR made the following changes:
1. Change the `sluggish` label of a finality provider to `jailed`.
2. Implement `AfterSluggishFinalityProviderDetected` hook in the
`x/btcstaking` module to set the label of a finality provider to
`jailed`.
3. Introduce `EventJailedFinalityProvider` event as
`EventPowerDistUpdate`, which is emitted after a finality provider is
jailed.
4. Introduce a new parameter `jail_duration` to `x/finality` (needs to
handle upgrade in a separate PR).
5. Introduce a new field `jailed_until` to `FinalityProviderSigningInfo`
in `x/finality`, which is calculated as the timestamp of the jailing
block plus the `jail_duration` of the parameter.
6. Clear the signing info record of the jailed finality provider and set
`jailed_until=jailingBlock.Time.Add(params.JailDuration)`.
7. Within the `BeginBlocker` of the next block, upon
`EventJailedFinalityProvider`, record the finality provider public key
and do not assign voting power to it.
8. Modify relevant tests
This PR partially closes
#64 by introducing
`MsgUnjailFinalityProviders` to allow the fp operator to unjail a jailed
finality provider after the jailing period is passed. In particular,
this PR made the following changes:
- introduce `MsgUnjailFinalityProvider`, within the handler:
    - get signing info and check current block timestamp
    - call `UnjailFinalityProvider` from the btcstaking module, which
        - checks fp existence
        - checks if the fp is jailed
        - changes the IsJailed flag to false
- creats and emits EventUnjailFinalityProvider, which will be consumed
in the `BeginBlocker` of the next block
- within `BeginBlocker` of the btcstaking module, upon
`EventUnjailFinalityProvider`
- change the `IsJailed` flag of the finality provider dist info to
`false` so that its accumulated delegated value will be transferred to
actual voting power
- fuzz tests
This is required for upgrading from the TGE chain
@gitferry gitferry marked this pull request as ready for review September 19, 2024 03:03
@gitferry gitferry requested a review from a team as a code owner September 19, 2024 03:03
@gitferry gitferry requested review from KonradStaniec, RafilxTenfen, SebastianElvis, Lazar955 and a team and removed request for a team September 19, 2024 03:03
@gitferry gitferry added consensus breaking change modifies `appHash` of the application api breaking breaks grpc api in non-compatible way labels Sep 19, 2024
@gitferry gitferry merged commit e7ac8fd into main Sep 19, 2024
17 checks passed
SebastianElvis pushed a commit that referenced this pull request Sep 19, 2024
Closes #64.

TODOs:
- [x] #65
- [x] #74
- [x] babylonlabs-io/finality-provider#56
- [x] #81

We still need to update the docs, add CLI cmd, and e2e tests but can be
done in separate PRs
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.

Jail sluggish finality providers
2 participants