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

NotEnoughSpendableUTXOs error for mainnet federation with sufficient UTXOs #5298

Closed
bradleystachurski opened this issue May 15, 2024 · 4 comments · Fixed by #5307
Closed
Assignees
Labels
bug Something isn't working wallet

Comments

@bradleystachurski
Copy link
Member

A mainnet federation is getting a NotEnoughSpendableUTXO error when attempting to withdraw on-chain. I've spoken out-of-band with a few of the guardians and we've accumulated some clues:

  • Federation on v0.2.2
  • 3 successful peg-ins
  • 2 successful withdrawals
  • Subsequent withdrawal requests show NotEnoughSpendableUTXO
  • Using fedimint-observer, we've identified the federation has 3 UTXOs with sufficient balance for subsequent withdrawal requests
  • fedimintd logs show repeated Broadcasting pending transactions
  • bitcoind backend running in pruned mode (550Mb)

Given this set of information, the current working theory is the wallet is unable to recognize change outputs from the previous two successful withdrawals. In the wallet server when we sync blocks up to consensus height, we call get_tx_block_height for all pending transactions each block.

.get_tx_block_height(txid)

If a peer is using bitcoind for a backend, this calls getrawtransaction.

By default this function only works for mempool transactions. ... When called without a blockhash argument, getrawtransaction will return the transaction if it is in the mempool, or if -txindex is enabled and the transaction is in a block in the blockchain.

This implies that if a peer is running bitcoind in pruned mode without enabling txindex, it will only query transactions stored in the mempool. Since the wallet syncs blocks up to consensus height once there's enough confirmations (10 blocks), the call to get_tx_block_height returns nothing since the transaction has been removed from the mempool for some time.

To test this theory, the guardians of this federation are going to attempt switching backends to esplora. If this is successful, this implies a material limitation to using a pruned bitcoind node for peers.

I'll update this issue as I learn more.

@elsirion elsirion added the bug Something isn't working label May 15, 2024
@elsirion
Copy link
Contributor

This looks like a potentially very severe bug. The get_tx_block_height approach sounds dangerous, I'd just get all transaction hashes of the block we are processing and then scan for inclusion of our change generating transactions. That would kill the electrum backend, but is anyone actually using it?

@joschisan
Copy link
Contributor

joschisan commented May 16, 2024

It seems to me that when the rpc call to get_tx_block_height happens to fail the change output is just not recognized. That would cause a consensus failure.

@bradleystachurski
Copy link
Member Author

It seems to me that when the rpc call to get_tx_block_height happens to fail the change output is just not recognized. That would cause a consensus failure.

@joschisan I think your interpretation is correct. @elsirion and I discussed out-of-band a high level approach that would force a rescan of already processed block heights that would recognize change from pending transactions. Do you see any problems with that approach?

@joschisan
Copy link
Contributor

@bradleystachurski Not on a high level, ping me for a review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working wallet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants