fix: do not break UTXO chain
Bad timing between the Stacks node's processing and the Bitcoin network including a block commit can cause a miner to submit a block commit which breaks the UTXO chain, severly hurting its chances of winning blocks. It is better to just miss this commit than to break the UTXO chain.
TODO: this still needs an integration test
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 83.90%. Comparing base (
d23c861) to head (52fcf78). Report is 288 commits behind head on develop.
Additional details and impacted files
@@ Coverage Diff @@
## develop #6157 +/- ##
===========================================
+ Coverage 82.91% 83.90% +0.98%
===========================================
Files 543 538 -5
Lines 390327 389503 -824
Branches 323 0 -323
===========================================
+ Hits 323654 326814 +3160
+ Misses 66665 62689 -3976
+ Partials 8 0 -8
| Files with missing lines | Coverage Δ | |
|---|---|---|
| ...-node/src/burnchains/bitcoin_regtest_controller.rs | 89.72% <100.00%> (+0.41%) |
:arrow_up: |
... and 70 files with indirect coverage changes
Continue to review full report in Codecov by Sentry.
Legend - Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing dataPowered by Codecov. Last update d23c861...52fcf78. Read the comment docs.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
- :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
I am failing to come up with a way to test this without intrusive changes in the code that are more likely to cause a new bug then test this one. If someone else is able to help come up with a test for this, please feel free to contribute, otherwise, I am leaning towards just having this reviewed as-is.
I am failing to come up with a way to test this without intrusive changes in the code that are more likely to cause a new bug then test this one. If someone else is able to help come up with a test for this, please feel free to contribute, otherwise, I am leaning towards just having this reviewed as-is.
As discussed during the Nakasync:
- Writing a true unit test doesn't seem feasible at the moment due to the current architecture of
BitcoinRegtestController, which is tightly coupled with bitcoind APIs viaBitcoinRPCRequest(used for fetching unspent UTXOs and other blockchain data). - Unless we're open to refactoring the design to decouple these dependencies, an alternative would be to write an integration test. This would involve setting up bitcoind using BitcoinCoreController and generating blocks to produce UTXOs, possibly allowing us to simulate the behavior of
BitcoinRegtestController::build_leader_block_commit_tx.
Trying creating tests in this PR: #6219
Closing -- included in #6219
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.