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

chore: add check in finality for block height finality parameter to accept finality vote/pubrand #204

Merged
merged 51 commits into from
Oct 23, 2024

Conversation

RafilxTenfen
Copy link
Contributor

@RafilxTenfen RafilxTenfen commented Oct 15, 2024

Add finality param to minimum block height to allow receiving Finality and Pub Rand Commit of x/finality

This value is a module parameter and it can be updated by governance proposal

…tart to process events that updates the voting power table
@RafilxTenfen RafilxTenfen self-assigned this Oct 15, 2024
@RafilxTenfen RafilxTenfen marked this pull request as ready for review October 16, 2024 01:12
@RafilxTenfen RafilxTenfen requested a review from a team as a code owner October 16, 2024 01:12
@RafilxTenfen RafilxTenfen requested review from KonradStaniec, samricotta and gitferry and removed request for a team October 16, 2024 01:12
x/btcstaking/keeper/keeper.go Outdated Show resolved Hide resolved
x/btcstaking/keeper/keeper.go Outdated Show resolved Hide resolved
x/btcstaking/keeper/keeper.go Outdated Show resolved Hide resolved
x/btcstaking/keeper/keeper.go Outdated Show resolved Hide resolved
x/btcstaking/keeper/keeper.go Outdated Show resolved Hide resolved
x/btcstaking/keeper/keeper.go Outdated Show resolved Hide resolved
x/btcstaking/keeper/power_dist_change.go Outdated Show resolved Hide resolved
@RafilxTenfen RafilxTenfen marked this pull request as draft October 17, 2024 19:15
@RafilxTenfen
Copy link
Contributor Author

Will be modified to block finality vote and pub rand commit before activation height

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.

Pretty solid work 👏

proto/babylon/finality/v1/params.proto Outdated Show resolved Hide resolved
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.

Great work! After some offline discussion, I think adding the activation height in the abci of finality module is a good way to go 👍

Comment on lines 23 to 30
sdkCtx := sdk.UnwrapSDKContext(ctx)
if uint64(sdkCtx.HeaderInfo().Height) < k.GetParams(ctx).FinalityActivationHeight {
return []abci.ValidatorUpdate{}, nil
}

// if the BTC staking protocol is activated, i.e., there exists a height where a finality provider
// has voting power, start indexing and tallying blocks
if _, err := k.BTCStakingKeeper.GetBTCStakingActivatedHeight(ctx); err == nil {
Copy link
Member

Choose a reason for hiding this comment

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

nit: I think we can combine the two checks into one validation like validateActivation indication that we only handle finality when (1) the height higher than the activation height and (2) at least one fp has voting power at this height

Copy link
Member

@Lazar955 Lazar955 left a comment

Choose a reason for hiding this comment

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

🙌

@RafilxTenfen RafilxTenfen merged commit 9efe79b into main Oct 23, 2024
20 checks passed
@maurolacy maurolacy deleted the rafilx/btc-staking-activation-height branch October 25, 2024 12:21
Comment on lines +135 to +137
fmt.Printf("\n Debug: errOut %s", errBufString)
fmt.Printf("\n Debug: output %s", outBuf.String())

Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Remove debug statements.

ctx := sdk.UnwrapSDKContext(goCtx)
activationHeight, errMod := ms.validateActivationHeight(ctx, req.BlockHeight)
if errMod != nil {
return nil, errMod.Wrapf("finality block height: %d is lower than activation height %d", req.BlockHeight, activationHeight)
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: The error message should be returned from inside the validation function, for generality.

activationHeight, errMod := ms.validateActivationHeight(ctx, req.StartHeight)
if errMod != nil {
return nil, types.ErrFinalityNotActivated.Wrapf(
"public rand commit start block height: %d is lower than activation height %d",
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here.

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.

6 participants