Skip to content

Conversation

instagibbs
Copy link
Member

@instagibbs instagibbs commented Aug 22, 2024

Basic addition to test case added in #30681

@DrahtBot
Copy link
Contributor

DrahtBot commented Aug 22, 2024

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Code Coverage

For detailed information about the code coverage, see the test coverage report.

Reviews

See the guideline for information on the review process.

Type Reviewers
ACK fjahr, tdb3, achow101
Concept ACK Sjors

If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

@fjahr
Copy link
Contributor

fjahr commented Aug 22, 2024

Code review ACK 31378d4

@fanquake fanquake added this to the 28.0 milestone Aug 23, 2024
Copy link
Contributor

@tdb3 tdb3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 31378d4

Great addition (testing the boundary, i.e. MAX_FUTURE_BLOCK_TIME - MAX_TIMEWARP).
Tested locally (and sanity checked that the assert would catch removing the -1 from bad_block.nTime = t + MAX_FUTURE_BLOCK_TIME - MAX_TIMEWARP - 1).

Left one comment, but it doesn't block the ACK.

@@ -159,6 +159,15 @@ def test_timewarp(self):
bad_block.solve()
assert_raises_rpc_error(-25, 'time-timewarp-attack', lambda: node.submitheader(hexdata=CBlockHeader(bad_block).serialize().hex()))
Copy link
Contributor

@tdb3 tdb3 Aug 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not immediately seeing why the previous check (for the bad_block.nTime = t case) is needed anymore now that the check closer to the boundary is being added (bad_block.nTime = t + MAX_FUTURE_BLOCK_TIME - MAX_TIMEWARP - 1 case). Maybe I'm overlooking something?

If not, then could add a commit that removes the check for the bad_block.nTime = t case.

bad_block.solve()
assert_raises_rpc_error(-25, 'time-timewarp-attack', lambda: node.submitheader(hexdata=CBlockHeader(bad_block).serialize().hex()))

bad_block.nTime = t + MAX_FUTURE_BLOCK_TIME - MAX_TIMEWARP
Copy link
Member

@Sjors Sjors Aug 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use block here, since it's not actually bad.

Alternatively you could modify the test above to not bother copying block to bad_block.

@Sjors
Copy link
Member

Sjors commented Aug 26, 2024

Concept ACK

@achow101
Copy link
Member

ACK 31378d4

Going to merge this now in the interest of having test coverage of the boundary before the 28.x branch off.

@DrahtBot DrahtBot requested a review from Sjors August 26, 2024 18:28
@achow101 achow101 merged commit 5116dd4 into bitcoin:master Aug 26, 2024
16 checks passed
@bitcoin bitcoin locked and limited conversation to collaborators Aug 26, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants