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

fix: BTC del Expired and Unbond in same block panics #597

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

RafilxTenfen
Copy link
Contributor

@RafilxTenfen RafilxTenfen commented Feb 28, 2025

If a BTC was about to get expired, but gets unbonded in the same BTC block
in the next babylon block when it was about to process the undelegation event, it would halt in the rewards as the expired event would already had deleted the btc delegation reward tracker information

@RafilxTenfen RafilxTenfen self-assigned this Feb 28, 2025
@RafilxTenfen RafilxTenfen changed the title chore: failing to insert btc headers work fix: BTC del Expired and Unbond in same block panics Feb 28, 2025
@RafilxTenfen RafilxTenfen added security consensus breaking change modifies `appHash` of the application backport-to-release/v1.x labels Feb 28, 2025
@RafilxTenfen RafilxTenfen marked this pull request as ready for review February 28, 2025 18:03
@@ -142,7 +142,7 @@ func (d *BTCDelegation) GetStatus(

// if the endheight is lower than the btc height + unbonding time
// the btc delegation should be considered expired
if btcHeight+d.UnbondingTime > d.EndHeight {
if btcHeight+d.UnbondingTime >= d.EndHeight {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

fix

Comment on lines +172 to +182
_, err = msgSrvrBtcStk.BTCUndelegate(ctx, msgUndelegate) // fails to unbond, since the BTC was expired
require.EqualError(t, err, bstypes.ErrInvalidBTCUndelegateReq.Wrap("cannot unbond an unbonded BTC delegation").Error(), "should error out")

// produce block
_, err = app.EndBlocker(ctx)
require.NoError(t, err)

// produces one more block to process the unbonding and it should not halt the chain
require.NotPanics(t, func() {
ProduceBlock(t, r, app, ctx)
})
Copy link
Contributor Author

@RafilxTenfen RafilxTenfen Feb 28, 2025

Choose a reason for hiding this comment

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-to-release/v1.x consensus breaking change modifies `appHash` of the application security
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant