-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
blockchain: don't rely on BlockHeightByHash for prune height calculations #2122
blockchain: don't rely on BlockHeightByHash for prune height calculations #2122
Conversation
Pull Request Test Coverage Report for Build 8160298701Details
💛 - Coveralls |
How can I help test this? Restarting with this patch? |
I don't think we have reconsiderblock here (should push it from utreexod) so you'd have to restart syncing from scratch unfortunately |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we re-create the scenarios we've see in the wlid via the full block tests?
btcd/blockchain/fullblocktests/generate.go
Lines 783 to 790 in 13152b3
// Generate returns a slice of tests that can be used to exercise the consensus | |
// validation rules. The tests are intended to be flexible enough to allow both | |
// unit-style tests directly against the blockchain code as well as integration | |
// style tests over the peer-to-peer network. To achieve that goal, each test | |
// contains additional information about the expected result, however that | |
// information can be ignored when doing comparison tests between two | |
// independent versions over the peer-to-peer network. | |
func Generate(includeLargeReorg bool) (tests [][]TestInstance, err error) { |
btcd/blockchain/fullblocks_test.go
Lines 132 to 134 in 13152b3
// TestFullBlocks ensures all tests generated by the fullblocktests package | |
// have the expected result when processed via ProcessBlock. | |
func TestFullBlocks(t *testing.T) { |
I've modified the existing I've verified that this error only happens when the node is pruned by running an archive node with The error message given out in the test matches that of the logs from @0xB10C and Sjors and with the logs from when I tested it locally. |
Calling t.Fatal inside db.View makes the test hang on failures. Return the error and call t.Fatal outside of db.View avoids this.
Pruning stale blocks will make the block validation fail for the block that the prune was triggered on as BlockHeightByHash will not return the height for blocks that are not in the main chain. We add a test case to ensure that the test fails in the above case.
17837af
to
42f313c
Compare
Here's my logs for running Without pruning:
With pruning:
|
Alright, done that. I still have a copy of the old datadir in-case anyone needs it for testing or further debugging. I'll re-add the btcd v0.24 to fork-observer once it's synced. I also made sure to add an RSS feed for lagging nodes. |
42f313c
to
7ff38e7
Compare
Added additional comments in the new code |
calculations Since BlockHeightByHash only returns the heights for blocks that are in the main chain, when a block that is stale gets pruned, this will cause an error in the block height lookup and cause an error in block processing. Look up the node directly from the index and if the node isn't found, just skip that node. For utxoCache.lastFlushHash, if that isn't found, just force a flush.
7ff38e7
to
f2caa8f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🥯
Since BlockHeightByHash only returns the heights for blocks that are in the main chain, when a block that is stale gets pruned, this will cause an error in the block height lookup and cause an error in block processing.
Look up the node directly from the index and if the node isn't found, just skip that node. For utxoCache.lastFlushHash, if that isn't found, just force a flush.
Fixes #2121