Repository navigation
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. External sites
ReviewsSee the guideline and AI policy for information on the review process. ConflictsNo conflicts as of last run. |
d71aafb to
fbc975a
Compare
fbc975a to
77d4517
Compare
|
Before we spend precious human resources reviewing your submission, can you guarantee us that you have read our AI Policy and this particular contribution conforms to that policy? It's important for us to know that real human users have encountered the problem you are trying to solve and there is a worthwhile motivation for this work. |
I’ve read and completely understand the AI policy. Just to be clear, I wrote this patch myself with full understanding of the code. I have a background in blockchain development and have verified the fix end-to-end with unit tests and devnet testing. |
|
Great! Please add a thorough description to the PR. |
|
I haven't spent a lot of time reviewing the change, but instead of the complicated manual corruption we can probably reproduce the same partial rollback is even simpler to reproduce with AssumeUTXO without corrupting or deleting files. But given that I'm working on removing AssumeUTXO now, I think this remaining partial-state behavior should be documented as a known limitation instead of adding more AssumeUTXO-specific validation or regression code. Functional test reproducing the partial rollbackdiff --git a/test/functional/feature_assumeutxo.py b/test/functional/feature_assumeutxo.py
index 8727a9925ec..250d31a4b09 100755
--- a/test/functional/feature_assumeutxo.py
+++ b/test/functional/feature_assumeutxo.py
@@ -660,6 +660,24 @@ class AssumeutxoTest(BitcoinTestFramework):
self.assert_only_network_limited_service(n1)
dumb_sync_blocks(src=n0, dst=n1, height=PAUSE_HEIGHT)
+ self.log.info("Test invalidateblock stops at the unavailable snapshot base")
+
+ def active_state():
+ info = n1.gettxoutsetinfo(use_index=False)
+ return {key: info[key] for key in ("bestblock", "hash_serialized_3")}
+
+ before = active_state()
+ snapshot_base = n1.getblockhash(SNAPSHOT_BASE_HEIGHT)
+ first_removed = n1.getblockhash(SNAPSHOT_BASE_HEIGHT + 1)
+ assert_equal(n1.invalidateblock(snapshot_base), None) # TODO: should raise an RPC error
+ after = active_state()
+ assert_equal(after["bestblock"], snapshot_base) # TODO: should be before["bestblock"]
+ assert_not_equal(after["hash_serialized_3"], before["hash_serialized_3"]) # TODO: should be unchanged
+
+ self.log.info("Restore the snapshot chain after the characterization")
+ n1.reconsiderblock(first_removed)
+ assert_equal(active_state(), before)
+
self.log.info("Checking that blocks are segmented on disk")
assert self.has_blockfile(n1, "00000"), "normal blockfile missing"
assert self.has_blockfile(n1, "00001"), "assumed blockfile missing"Please try to simplify the tests and maybe add the AssumeUTXO reproducer in a collapsible section in the PR (if you agree that it characterizes the same problem). |
|
Reviewed the diff; I have not built or tested the branch. Concept makes sense — Two things on the implementation. The error message in the third hunk names the wrong block. if (m_chain.Contains(*to_mark_failed)) {
return state.Error(strprintf("Block %s was not invalidated because it is still in the active chain (interrupted?)", pindex->GetBlockHash().ToString()));
}The condition tests
nit: the two commits have near-identical subjects, and the second largely Does this want a release note? Finally, @l0rinc's point about documenting the partial-state behaviour instead |
|
@yusufyildiz34 Thanks for the review. You're right that it should print the block the check is about. It's to_mark_failed now. Genesis: agreed, a bad argument isn't a runtime error, the RPC now rejects it with -8 next to "Block not found" and InvalidateBlock() retains its old return false. Squashed the commits and added a body and a release note. I also tested on regtest with a corrupted undo record: invalidateblock now fails with the rollback height in the error and reconsiderblock restores the chain. |
|
In a helper-level fault-injection test, a |

invalidateblockreturnsnulleven when the block was not invalidated because the RPC does not pay attention toChainstate::InvalidateBlock()return value. If there is a problem disconnecting the block (for example, the undo data is corrupt), the chain remains partially rolled back when telling the user that the operation succeeded. This creates an error in every failure case, including the genesis block case, and makes RPC look at the return value. The error reports a failed block and how far the chain was rolled back before the block returned.Fixes #36546