-
Notifications
You must be signed in to change notification settings - Fork 37.6k
Remove RewindBlockIndex logic #21009
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1956,22 +1956,33 @@ def test_non_standard_witness(self): | |
def test_upgrade_after_activation(self): | ||
"""Test the behavior of starting up a segwit-aware node after the softfork has activated.""" | ||
|
||
self.restart_node(2, extra_args=["-segwitheight={}".format(SEGWIT_HEIGHT)]) | ||
# All nodes are caught up and node 2 is a pre-segwit node that will soon upgrade. | ||
for n in range(2): | ||
assert_equal(self.nodes[n].getblockcount(), self.nodes[2].getblockcount()) | ||
assert softfork_active(self.nodes[n], "segwit") | ||
assert SEGWIT_HEIGHT < self.nodes[2].getblockcount() | ||
assert 'segwit' not in self.nodes[2].getblockchaininfo()['softforks'] | ||
jnewbery marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
# Restarting node 2 should result in a shutdown because the blockchain consists of | ||
# insufficiently validated blocks per segwit consensus rules. | ||
self.stop_node(2) | ||
with self.nodes[2].assert_debug_log(expected_msgs=[ | ||
f"Witness data for blocks after height {SEGWIT_HEIGHT} requires validation. Please restart with -reindex."], timeout=10): | ||
self.nodes[2].start([f"-segwitheight={SEGWIT_HEIGHT}"]) | ||
|
||
# As directed, the user restarts the node with -reindex | ||
self.start_node(2, extra_args=["-reindex", f"-segwitheight={SEGWIT_HEIGHT}"]) | ||
|
||
# With the segwit consensus rules, the node is able to validate only up to SEGWIT_HEIGHT - 1 | ||
assert_equal(self.nodes[2].getblockcount(), SEGWIT_HEIGHT - 1) | ||
self.connect_nodes(0, 2) | ||
|
||
# We reconnect more than 100 blocks, give it plenty of time | ||
# sync_blocks() also verifies the best block hash is the same for all nodes | ||
self.sync_blocks(timeout=240) | ||
|
||
# Make sure that this peer thinks segwit has activated. | ||
assert softfork_active(self.nodes[2], 'segwit') | ||
|
||
# Make sure this peer's blocks match those of node0. | ||
height = self.nodes[2].getblockcount() | ||
while height >= 0: | ||
block_hash = self.nodes[2].getblockhash(height) | ||
assert_equal(block_hash, self.nodes[0].getblockhash(height)) | ||
assert_equal(self.nodes[0].getblock(block_hash), self.nodes[2].getblock(block_hash)) | ||
height -= 1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So based on the removal of this test code (and the If we expect users to remove their blocksdir before restarting with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reindexing will result in the node discarding the blocks without witness after segwit activation and redownloading them from peers and validating. See #21009 (comment). The reason the node doesn't sync to tip here is because in our functional tests, the nodes don't make automatic connections to each other. As soon as the nodes are connected, the upgraded node will resync from its peers. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, I should have updated the PR description. Updated to now say:
Sorry for the confusion. As for the Using
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, thanks all. Makes sense. |
||
# The upgraded node should now have segwit activated | ||
assert softfork_active(self.nodes[2], "segwit") | ||
|
||
@subtest # type: ignore | ||
def test_witness_sigops(self): | ||
|
Uh oh!
There was an error while loading. Please reload this page.
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.
I did a quick grep for
BLOCK_OPT_WITNESS
and came across #19806 which added a "fake"BLOCK_OPT_WITNESS
"so that RewindBlockIndex() doesn't zealously unwind the assumed-valid chain." I don't have much background on AssumeUTXO but is there an interaction there? Should that be cleaned up as well?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.
Good call, @glozow. I'll make a note to look at whether that's still necessary after the merge of this PR.