Skip to content

Conversation

maflcko
Copy link
Member

@maflcko maflcko commented Nov 9, 2018

This hopefully fixes #14661, which I believe is caused by a race in send_blocks_and_test. By setting request_block=False we only effectively check node.getbestblockhash() != blocks[-1].hash before returning and checking the debug.log. By setting request_block=True (the default) we make sure that we send the block, then sync with a ping before asserting on the debug.log.

Even if this patch doesn't fix the issue, it is good cleanup: There is no reason to not wait for the blocks to be requested, since in all these cases the header gives no indication that the block is consensus invalid. So this patch makes the test also a bit stricter and more useful.

Unrelated to this, I also include a fix that makes the tests pass on latest CentOS.

@maflcko maflcko added the Tests label Nov 9, 2018
@maflcko maflcko added this to the 0.17.1 milestone Nov 9, 2018
@lucash-dev
Copy link
Contributor

utACK fa21568

@lucash-dev
Copy link
Contributor

I'm curious, have you been able to reproduce the issue locally? I've ran the test 1,000+ times and couldn't.

@sdaftuar
Copy link
Member

It seems to me that it would make more sense to separate p2p-layer behaviors that we want to test from consensus-layer behaviors that we want to test -- otherwise there's a risk that changes to one might break our tests for another.

I was surprised, when reviewing this just now, that the behavior of send_blocks_and_test when request_block=False is to not send the block at all, rather than force delivery of the block whether or not the peer requested it. Anyway I think we should just get rid of the request_block parameter altogether and test what happens if the block were delivered outright (which is the case that I think we care about in all the places we currently pass in False); ideally we'd do that both via p2p and via RPC's submitblock.

Separately, we should write a test that covers what we want the p2p behavior to be when various kinds of valid and invalid block headers are received. It'd be great if changing p2p behavior with respect to block download meant only changing p2p-related tests, and not worrying about the downstream effects of changes like that on our consensus tests.

Anyway, this PR is currently a strict improvement as the existing code is buggy, so utACK if you'd like to leave this as-is and leave discussion of the broader point for a future PR.

@DrahtBot
Copy link
Contributor

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

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #14696 (qa: Add explicit references to related CVE's in p2p_invalid_block test. by lucash-dev)

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.

@maflcko maflcko merged commit fa21568 into bitcoin:master Nov 13, 2018
maflcko pushed a commit that referenced this pull request Nov 13, 2018
…block request

fa21568 qa: Avoid race in p2p_invalid_block by waiting for the block request (MarcoFalke)
6c787d3 tests: Make feature_block pass on centos (MarcoFalke)

Pull request description:

  This hopefully fixes #14661, which I believe is caused by a race in `send_blocks_and_test`. By setting `request_block=False` we only effectively check `node.getbestblockhash() != blocks[-1].hash` before returning and checking the debug.log. By setting `request_block=True` (the default) we make sure that we send the block, then sync with a ping before asserting on the debug.log.

  Even if this patch doesn't fix the issue, it is good cleanup: There is no reason to not wait for the blocks to be requested, since in all these cases the header gives no indication that the block is consensus invalid. So this patch makes the test also a bit stricter and more useful.

  Unrelated to this, I also include a fix that makes the tests pass on latest CentOS.

Tree-SHA512: c7abee3b7dc790a8af6c289159a7751bd962f6fa16c1537e7e21a0a0ef05b9596d1f4eb75319614603c05cb803e021314fa3596508ba443edd03046b25527e0f
@maflcko maflcko deleted the Mf1811-qaPassOnCentOs branch November 13, 2018 15:29
fanquake pushed a commit to fanquake/bitcoin that referenced this pull request Nov 30, 2018
@fanquake
Copy link
Member

fa21568 has been backported in #14835. 6c787d3 shouldn't need a backport to 0.17.

deadalnix pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Jun 13, 2020
…block request

Summary:
fa21568208 qa: Avoid race in p2p_invalid_block by waiting for the block request (MarcoFalke)
6c787d340c tests: Make feature_block pass on centos (MarcoFalke)

Pull request description:

  This hopefully fixes #14661, which I believe is caused by a race in `send_blocks_and_test`. By setting `request_block=False` we only effectively check `node.getbestblockhash() != blocks[-1].hash` before returning and checking the debug.log. By setting `request_block=True` (the default) we make sure that we send the block, then sync with a ping before asserting on the debug.log.

  Even if this patch doesn't fix the issue, it is good cleanup: There is no reason to not wait for the blocks to be requested, since in all these cases the header gives no indication that the block is consensus invalid. So this patch makes the test also a bit stricter and more useful.

  Unrelated to this, I also include a fix that makes the tests pass on latest CentOS.

Tree-SHA512: c7abee3b7dc790a8af6c289159a7751bd962f6fa16c1537e7e21a0a0ef05b9596d1f4eb75319614603c05cb803e021314fa3596508ba443edd03046b25527e0f

Backport of Core [[bitcoin/bitcoin#14700 | PR14700]]

Test Plan:
  ./test_runner.py feature_block p2p_invalid_block

Reviewers: O1 Bitcoin ABC, #bitcoin_abc, majcosta

Reviewed By: O1 Bitcoin ABC, #bitcoin_abc, majcosta

Differential Revision: https://reviews.bitcoinabc.org/D6525
knst pushed a commit to knst/dash that referenced this pull request Aug 10, 2021
…or the block request

fa21568 qa: Avoid race in p2p_invalid_block by waiting for the block request (MarcoFalke)
6c787d3 tests: Make feature_block pass on centos (MarcoFalke)

Pull request description:

  This hopefully fixes bitcoin#14661, which I believe is caused by a race in `send_blocks_and_test`. By setting `request_block=False` we only effectively check `node.getbestblockhash() != blocks[-1].hash` before returning and checking the debug.log. By setting `request_block=True` (the default) we make sure that we send the block, then sync with a ping before asserting on the debug.log.

  Even if this patch doesn't fix the issue, it is good cleanup: There is no reason to not wait for the blocks to be requested, since in all these cases the header gives no indication that the block is consensus invalid. So this patch makes the test also a bit stricter and more useful.

  Unrelated to this, I also include a fix that makes the tests pass on latest CentOS.

Tree-SHA512: c7abee3b7dc790a8af6c289159a7751bd962f6fa16c1537e7e21a0a0ef05b9596d1f4eb75319614603c05cb803e021314fa3596508ba443edd03046b25527e0f
knst pushed a commit to knst/dash that referenced this pull request Aug 10, 2021
…or the block request

fa21568 qa: Avoid race in p2p_invalid_block by waiting for the block request (MarcoFalke)
6c787d3 tests: Make feature_block pass on centos (MarcoFalke)

Pull request description:

  This hopefully fixes bitcoin#14661, which I believe is caused by a race in `send_blocks_and_test`. By setting `request_block=False` we only effectively check `node.getbestblockhash() != blocks[-1].hash` before returning and checking the debug.log. By setting `request_block=True` (the default) we make sure that we send the block, then sync with a ping before asserting on the debug.log.

  Even if this patch doesn't fix the issue, it is good cleanup: There is no reason to not wait for the blocks to be requested, since in all these cases the header gives no indication that the block is consensus invalid. So this patch makes the test also a bit stricter and more useful.

  Unrelated to this, I also include a fix that makes the tests pass on latest CentOS.

Tree-SHA512: c7abee3b7dc790a8af6c289159a7751bd962f6fa16c1537e7e21a0a0ef05b9596d1f4eb75319614603c05cb803e021314fa3596508ba443edd03046b25527e0f
knst pushed a commit to knst/dash that referenced this pull request Aug 16, 2021
…aiting for the block request

fa21568 qa: Avoid race in p2p_invalid_block by waiting for the block request (MarcoFalke)
6c787d3 tests: Make feature_block pass on centos (MarcoFalke)

Pull request description:

  This hopefully fixes bitcoin#14661, which I believe is caused by a race in `send_blocks_and_test`. By setting `request_block=False` we only effectively check `node.getbestblockhash() != blocks[-1].hash` before returning and checking the debug.log. By setting `request_block=True` (the default) we make sure that we send the block, then sync with a ping before asserting on the debug.log.

  Even if this patch doesn't fix the issue, it is good cleanup: There is no reason to not wait for the blocks to be requested, since in all these cases the header gives no indication that the block is consensus invalid. So this patch makes the test also a bit stricter and more useful.

  Unrelated to this, I also include a fix that makes the tests pass on latest CentOS.

Tree-SHA512: c7abee3b7dc790a8af6c289159a7751bd962f6fa16c1537e7e21a0a0ef05b9596d1f4eb75319614603c05cb803e021314fa3596508ba443edd03046b25527e0f
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Aug 23, 2021
…aiting for the block request

fa21568 qa: Avoid race in p2p_invalid_block by waiting for the block request (MarcoFalke)
6c787d3 tests: Make feature_block pass on centos (MarcoFalke)

Pull request description:

  This hopefully fixes bitcoin#14661, which I believe is caused by a race in `send_blocks_and_test`. By setting `request_block=False` we only effectively check `node.getbestblockhash() != blocks[-1].hash` before returning and checking the debug.log. By setting `request_block=True` (the default) we make sure that we send the block, then sync with a ping before asserting on the debug.log.

  Even if this patch doesn't fix the issue, it is good cleanup: There is no reason to not wait for the blocks to be requested, since in all these cases the header gives no indication that the block is consensus invalid. So this patch makes the test also a bit stricter and more useful.

  Unrelated to this, I also include a fix that makes the tests pass on latest CentOS.

Tree-SHA512: c7abee3b7dc790a8af6c289159a7751bd962f6fa16c1537e7e21a0a0ef05b9596d1f4eb75319614603c05cb803e021314fa3596508ba443edd03046b25527e0f
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 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.

p2p_invalid_block occasionally fails "bad-txns-inputs-duplicate"
6 participants