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-024): Enable BTC-timestamping public randomness #51

Merged
merged 7 commits into from
Sep 4, 2024

Conversation

…ed pub rand (#23)

This closes the second part of #8. In particular, this PR:
* Implemented `HasTimestampedPubRand` in the finality keeper to check
whether a pub rand at a given height is BTC-timestamped
* Added expected finality keeper to btcstaking keeper so that
`HasTimestampedPubRand` can be called within the module
* When signing voting power to fps in `btcstaking`'s begin blocker, if
the fp does not have timestamped pub rand, voting power will not be
assigned

Note that this PR introduced circular dependency between the btc staking
module and finality module, which should be addressed by moving the
voting power table to the finality module, tracked by issue #24
This PR fixed some issues in assigning the voting power, in particular
* even if no new delegations are included, we should also update the
cache about the timestamping status
* fixed return value of `HasTimestampedPubRand`
* e2e tests are fixed
* added table-driven tests for the voting table
@gitferry gitferry requested a review from a team as a code owner September 3, 2024 03:53
@gitferry gitferry requested review from KonradStaniec and RafilxTenfen and removed request for a team September 3, 2024 03:53
@KonradStaniec KonradStaniec added consensus breaking change modifies `appHash` of the application api breaking breaks grpc api in non-compatible way labels Sep 3, 2024
Copy link
Member

@SebastianElvis SebastianElvis left a comment

Choose a reason for hiding this comment

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

Great work putting everything together!

Only super minor comments but these can be done in subsequent PRs

uint64 total_voting_power = 1;
// finality_providers is a list of finality providers' voting power information
repeated FinalityProviderDistInfo finality_providers = 2;
// num_active_fps is the number of finality providers that have positive voting power
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// num_active_fps is the number of finality providers that have positive voting power
// num_active_fps is the number of finality providers that have active BTC delegations

a FP has positive voting power at a height only when it has active BTC
delegations at this height AND has timestamped public randomness at this height

Copy link
Member Author

Choose a reason for hiding this comment

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

Agreed. The two conditions combined lead to fp having voting power

Comment on lines +183 to +185
if err != nil {
return nil, err
}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if err != nil {
return nil, err
}
require.NoError(n.t, err)

Failing to query the node should not happen so we can panick here

Comment on lines +99 to +107
if err != nil {
return 0, err
}

var resp bstypes.QueryActivatedHeightResponse
err = util.Cdc.UnmarshalJSON(bz, &resp)
require.NoError(n.t, err)
if err != nil {
return 0, err
}
Copy link
Member

@SebastianElvis SebastianElvis Sep 4, 2024

Choose a reason for hiding this comment

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

We can do require.NoError(n.t, err) at L99 and L105 as this means there is something fishy in the setup

Copy link
Collaborator

@KonradStaniec KonradStaniec left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Contributor

@RafilxTenfen RafilxTenfen left a comment

Choose a reason for hiding this comment

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

LGTM

@gitferry
Copy link
Member Author

gitferry commented Sep 4, 2024

I have validated that the db schema change introduced by this PR will not affect upgrade via https://github.com/babylonlabs-io/babylon-deployment/pull/4. This is done by adding the start of fpd and eostd after the upgrade is done. Then we can query the new pub rand commit is made without breaking the chain. Thanks @RafilxTenfen for the help!

@gitferry gitferry merged commit 00330e4 into main Sep 4, 2024
17 checks passed
@gitferry gitferry deleted the gai/fix-conflicts branch September 4, 2024 16:04
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.

BTC-timestamping public randomness
4 participants