Skip to content

Conversation

maflcko
Copy link
Member

@maflcko maflcko commented Aug 5, 2019

To prevent OOM, Bitcoin Core will reject chain forks at low difficulty by default. This is the only use-case of checkpoints, so add a test for it to make sure the feature works as expected. If it didn't work, checkpoints would have no use-case and we might as well remove them

@maflcko maflcko force-pushed the 1908-testDosLowHeader branch from fa898ef to fae28b4 Compare August 5, 2019 22:12
@fanquake fanquake added the Tests label Aug 5, 2019
@DrahtBot
Copy link
Contributor

DrahtBot commented Aug 6, 2019

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

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #8994 (Testchains: Introduce custom chain whose constructor... by jtimon)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

Coverage

Coverage Change (pull 16551, 308ed29) Reference (master, e5fdda6)
Lines +0.0119 % 89.1963 %
Functions +0.0940 % 82.1787 %
Branches +0.0129 % 46.6003 %

Updated at: 2019-08-07T12:48:33.276456.

@practicalswift
Copy link
Contributor

Concept ACK

1 similar comment
@laanwj
Copy link
Member

laanwj commented Aug 14, 2019

Concept ACK

@jamesob
Copy link
Contributor

jamesob commented Aug 14, 2019

Concept ACK, will review in next few days.

@Sjors
Copy link
Member

Sjors commented Aug 16, 2019

Concept ACK, but I find the test hard to read atm. I'm confused about what's actually in blockheader_testnet3.hex. Are those the headers without the block hash of the real testnet3 chain? Because I don't see the checkpoint hash in there. Also, rather than having two lines with fork: and a parser to deal with that, maybe just hard code those in the test itself? Alternatively, create a seperate file for the fork? At what height does this fork start? Genesis or same height as checkpoint?

@maflcko maflcko force-pushed the 1908-testDosLowHeader branch from fa982dd to fa0c247 Compare August 16, 2019 14:34
@maflcko
Copy link
Member Author

maflcko commented Aug 16, 2019

Added an inline comment to hopefully explain it better, @Sjors

Are those the headers without the block hash of the real testnet3 chain? Because I don't see the checkpoint hash in there.

Serialized headers include only the hash of the previous block, so if the last header is the checkpoint, the block hash of the checkpoint will never appear in the data file.

Copy link
Member

@Sjors Sjors left a comment

Choose a reason for hiding this comment

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

ACK fa0c247, but added some suggestions for clearer wording.

To make the behavior more clear, it helps to include non DoS examples. Can you generate a testnet fork with more proof of work? It should be shorter than the real chain so it doesn't reach checkpoint height.

With and without checkpoints enabled I would expect this fork to be accepted if it's the first thing we see.

If we see it after we've already seen headers up to the checkpoint, then with checkpoints enabled I expect this to be rejected. With checkpoints disabled, I expect a reorg.

@maflcko maflcko force-pushed the 1908-testDosLowHeader branch from fa0c247 to 333317c Compare August 16, 2019 17:02
@maflcko
Copy link
Member Author

maflcko commented Aug 16, 2019

With and without checkpoints enabled I would expect this fork to be accepted if it's the first thing we see.

Added test case (and node 1). Also, fixed up your comment suggestions.

@Sjors
Copy link
Member

Sjors commented Aug 16, 2019

Thanks for adding the node 1 example. Code review ACK 333317c

maflcko pushed a commit that referenced this pull request Sep 12, 2019
333317c test: Test that low difficulty chain fork is rejected (MarcoFalke)
fa31dc1 test: Pass down correct chain name in tests (MarcoFalke)

Pull request description:

  To prevent OOM, Bitcoin Core will reject chain forks at low difficulty by default. This is the only use-case of checkpoints, so add a test for it to make sure the feature works as expected. If it didn't work, checkpoints would have no use-case and we might as well remove them

ACKs for top commit:
  Sjors:
    Thanks for adding the node 1 example. Code review ACK 333317c

Tree-SHA512: 90dffa540d0904f3cffb61d2382b1a26f84fe9560b7013e4461546383add31a8757b350616a6d43217c59ef7b8b2a1b62bb3bab582c679cbb2c660a782ce7be1
@maflcko maflcko merged commit 333317c into bitcoin:master Sep 12, 2019
@maflcko maflcko deleted the 1908-testDosLowHeader branch September 12, 2019 14:09
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Sep 12, 2019
…ected

333317c test: Test that low difficulty chain fork is rejected (MarcoFalke)
fa31dc1 test: Pass down correct chain name in tests (MarcoFalke)

Pull request description:

  To prevent OOM, Bitcoin Core will reject chain forks at low difficulty by default. This is the only use-case of checkpoints, so add a test for it to make sure the feature works as expected. If it didn't work, checkpoints would have no use-case and we might as well remove them

ACKs for top commit:
  Sjors:
    Thanks for adding the node 1 example. Code review ACK 333317c

Tree-SHA512: 90dffa540d0904f3cffb61d2382b1a26f84fe9560b7013e4461546383add31a8757b350616a6d43217c59ef7b8b2a1b62bb3bab582c679cbb2c660a782ce7be1
deadalnix pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Jun 7, 2020
Summary:
bitcoin/bitcoin@fa31dc1

---

Partial backport of Core [[bitcoin/bitcoin#16551 | PR16551]]

Test Plan:
  ./test/functional/test_runner.py

Reviewers: #bitcoin_abc, deadalnix

Reviewed By: #bitcoin_abc, deadalnix

Differential Revision: https://reviews.bitcoinabc.org/D6430
deadalnix pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Jun 7, 2020
Summary:
bitcoin/bitcoin@333317c

---

Concludes backport of Core [[bitcoin/bitcoin#16551 | PR16551]]

Test Plan:
  ./test/functional/test_runner.py p2p_dos_header_tree.py

Reviewers: #bitcoin_abc, deadalnix

Reviewed By: #bitcoin_abc, deadalnix

Differential Revision: https://reviews.bitcoinabc.org/D6431
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Dec 16, 2021
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