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: tx fee refunding follow-up #130

Merged
merged 5 commits into from
Oct 7, 2024

Conversation

SebastianElvis
Copy link
Member

@SebastianElvis SebastianElvis commented Oct 4, 2024

This follow-up PR fixes the comments in #125, including

  • changelog and typo comments in BTCCheckpoint module
  • allow covenant signatures after covenant quorum are reached, and return error if the covenant signature is duplicated. This is to ensure covenants won't have operational cost when submitting covenant sig late, and avoid refunding to duplicated covenant signatures
  • reject duplicated finality signature. This is to avoid refunding to duplicated covenant signatures
  • add a dedup check in the PostHandler, to ensure one won't exploit the refunding by having many duplicated messages in a single tx. Also added a fuzz test for this.

@SebastianElvis SebastianElvis marked this pull request as ready for review October 4, 2024 07:40
@SebastianElvis SebastianElvis requested a review from a team as a code owner October 4, 2024 07:40
@SebastianElvis SebastianElvis requested review from KonradStaniec and RafilxTenfen and removed request for a team October 4, 2024 07:40
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.

Looks good!

ms.Logger(ctx).Debug("Received duplicated finality vote", "block height", req.BlockHeight, "finality provider", req.FpBtcPk)
// exactly same vote already exists, return error
// this is to secure the tx refunding against duplicated messages
return nil, types.ErrDuplicatedFinalitySig
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would wait for @gitferry review here as he may have some insight how this will influence finality provider side

Copy link
Member Author

@SebastianElvis SebastianElvis Oct 4, 2024

Choose a reason for hiding this comment

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

I think we will need to add this error as expected error here. After that it should be good. Will wait for Gai to confirm this

Copy link
Member

@gitferry gitferry Oct 7, 2024

Choose a reason for hiding this comment

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

I agree with @SebastianElvis that we can add the duplicate error as expected in the finality provider. I guess this applies in covenant emulator sending duplicate sigs as well. Added issue babylonlabs-io/finality-provider#84 and babylonlabs-io/covenant-emulator#17 to track this

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 🎉

if status != types.BTCDelegationStatus_PENDING {
ms.Logger(ctx).Debug("Received covenant signature after the BTC delegation is already expired", "covenant pk", req.Pk.MarshalHex())
return &types.MsgAddCovenantSigsResponse{}, nil
if status == types.BTCDelegationStatus_UNBONDED {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just note here: I guess this change allow to accept more signatures than the quorum. I imagine slasher or some other tool may relay of there being only quorum of signatures when building witness for sending slashing transactions. This may require some updates there. ( I definitely remember staker, assumes there is only quorum of sigs on Babylon chain)

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm will check when bumping peripheral repositories. In which situation BTC staker will need to rely on this behaviour? As far as I know in other repositories (eg vigilante) it does not even rely on how many covenant signatures are in a BTC delegation, as slashing only uses one of all covenant signatures. Did I miss anything?

Copy link
Collaborator

Choose a reason for hiding this comment

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

What do you mean by as slashing only uses one of all covenant signatures ?

The problem I have in mind is for example here: https://github.com/babylonlabs-io/vigilante/blob/main/btcstaking-tracker/btcslasher/slasher_utils.go#L344.

We build the wittness from all covenant signatures in the delegation. Up until now it was fine, because we accepted only quorum of signatures in the delegation.

After this change this is not fine now we can have more that quorum signatures in delegation, but BTC script expects the witness to have exactly quorum of signatures.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm right, maybe some programs (esp. those involving slashing) might assume somewhere that there is only a quorum number of cov sigs. Good point 👍

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.

nice work!

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.

Thanks for the waiting! Great work!

ms.Logger(ctx).Debug("Received duplicated finality vote", "block height", req.BlockHeight, "finality provider", req.FpBtcPk)
// exactly same vote already exists, return error
// this is to secure the tx refunding against duplicated messages
return nil, types.ErrDuplicatedFinalitySig
Copy link
Member

@gitferry gitferry Oct 7, 2024

Choose a reason for hiding this comment

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

I agree with @SebastianElvis that we can add the duplicate error as expected in the finality provider. I guess this applies in covenant emulator sending duplicate sigs as well. Added issue babylonlabs-io/finality-provider#84 and babylonlabs-io/covenant-emulator#17 to track this

@SebastianElvis SebastianElvis merged commit 6a74ebc into main Oct 7, 2024
18 checks passed
@SebastianElvis SebastianElvis deleted the fix-duplicated-submission-bug branch October 7, 2024 04:51
KonradStaniec added a commit that referenced this pull request Oct 8, 2024
Pr: #130 allowed for
accepting covenant signatures after quorum is reached.

This change introduces regression i.e covenant signatures accepted after
quorum is reached also generated voting power events, this could lead to
weird results in processing voting power events.

This pr fixes that by making sure that events of any kind are generated
only if this is first time quorum is reached.
gitferry added a commit to babylonlabs-io/finality-provider that referenced this pull request Nov 13, 2024
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.

5 participants