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

[Bug]: Disallow coinbase transactions as donations or deposits #1196

Open
1 task
djordon opened this issue Jan 9, 2025 · 0 comments
Open
1 task

[Bug]: Disallow coinbase transactions as donations or deposits #1196

djordon opened this issue Jan 9, 2025 · 0 comments
Labels
bug Something isn't working deposit The deposit sBTC operation. design making a design decision. sbtc signer binary The sBTC Bootstrap Signer.

Comments

@djordon
Copy link
Contributor

djordon commented Jan 9, 2025

Bug - Disallow coinbase transactions as donations or deposits

1. Description

Right now, we allow any bitcoin transaction to serve as a donation or a deposit. Unfortunately, coinbase transactions screw everything up. We cannot spend them immediately, and the getrawtransaction RPC on bitcoin core does not give us all of the expected fields when the verbosity level is set to 2. So we should just disallow them as deposits and donations.

1.1 Context & Purpose

If a coinbase transaction is spent to the signers, we will encounter an error while processing the block. This could be problematic if there are sweep transactions confirmed within the block, as it would prevent us from correctly processing all transactions in the block. Although it is highly unlikely for a coinbase transaction to be spent to the signers, such an occurrence could block the signers from sweeping deposits and withdrawals until the issue is resolved.

2. Technical Details:

When processing transactions within a bitcoin block or a deposit request, check to see if each potential donation and deposit transaction is a coinbase transaction. For the deposit code path, check around here:

// Fetch the transaction from either a block or from the mempool
let Some(response) = client.get_tx(&self.outpoint.txid).await? else {
return Ok(None);
};
// If the transaction has not been confirmed yet, then the block
// hash will be None. The trasnaction has not failed validation,
// let's try again when it gets confirmed.
let Some(block_hash) = response.block_hash else {
return Ok(None);
};

log it and return an error if it's a coinbase transaction.

For the donations code path log it and continue around here:

for tx in txs {
tracing::trace!(txid = %tx.compute_txid(), "attempting to extract sbtc transaction");

These changes should effectively prevent signing deposits from coinbase transactions since we will never have a record of the deposit request in our database.

2.1 Acceptance Criteria:

  • We do not accept coinbase transactions when processing a bitcoin block.

3. Related Issues and Pull Requests (optional):

Doing this with #1194 will help shore up processing of a bitcoin block.

@djordon djordon added bug Something isn't working design making a design decision. sbtc signer binary The sBTC Bootstrap Signer. deposit The deposit sBTC operation. labels Jan 9, 2025
@djordon djordon added this to the sBTC: Key rotation milestone Jan 9, 2025
@djordon djordon added this to sBTC Jan 9, 2025
@github-project-automation github-project-automation bot moved this to Needs Triage in sBTC Jan 9, 2025
@djordon djordon moved this from Needs Triage to Todo in sBTC Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working deposit The deposit sBTC operation. design making a design decision. sbtc signer binary The sBTC Bootstrap Signer.
Projects
Status: Todo
Development

No branches or pull requests

1 participant