Skip to content

Conversation

jonasschnelli
Copy link
Contributor

Extracted from #10387.
Does implement BIP159, but only the signalling part. No connections are made to NODE_NETWORK_LIMITED in this PR.

The address relay and connection work (the more complicated part) can then be separated (probably in #10387).

@fanquake
Copy link
Member

e874478a42eded1c5952fc0407f04279dd4837c1 forgot to add node_network_limited.py to test_runner.py.

@jonasschnelli
Copy link
Contributor Author

@fanquake! Thanks. Done.

Copy link
Contributor

@gmaxwell gmaxwell left a comment

Choose a reason for hiding this comment

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

utACK

@laanwj
Copy link
Member

laanwj commented Nov 29, 2017

utACK af05b92

@fanquake fanquake changed the title Implement BIP159 NODE_NETWORK_LIMITED (pruned peers) *signalling only* Implement BIP159 NODE_NETWORK_LIMITED (pruned peers) *signaling only* Nov 29, 2017
@theuni
Copy link
Member

theuni commented Nov 30, 2017

utACK af05b92591b72c34f8fa04a0917b3c1225e2417c

@@ -1091,6 +1091,16 @@ void static ProcessGetData(CNode* pfrom, const Consensus::Params& consensusParam
pfrom->fDisconnect = true;
send = false;
}
// Avoid leaking prune-height by never sending blocks below the NODE_NETWORK_LIMITED threshold
if (send && !pfrom->fWhitelisted && (
(((pfrom->GetLocalServices() & NODE_NETWORK_LIMITED) == NODE_NETWORK_LIMITED) && ((pfrom->GetLocalServices() & NODE_NETWORK) != NODE_NETWORK) && (chainActive.Tip()->nHeight - mi->second->nHeight > (int)NODE_NETWORK_LIMITED_MIN_BLOCKS) )
Copy link
Contributor

Choose a reason for hiding this comment

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

This needs a buffer beyond NODE_NETWORK_LIMITED_MIN_BLOCK. Because it gets a disconnect, one or two blocks should suffice.

)) {
LogPrint(BCLog::NET, "Ignore block request below NODE_NETWORK_LIMITED threshold from peer=%d\n", pfrom->GetId());

//disconnect node
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you fill out this comment a bit more? Something about how we could otherwise stall a node if we were just finishing IBD and announced blocks to our peers which they wanted?

except:
pass
assert_equal(res, result)
self.nodes[0].disconnect_p2ps()
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you move this into the try block? This checks that the node disconnected us, we didn't just timeout in the fail case.

@jonasschnelli
Copy link
Contributor Author

Fixed points reported by @TheBlueMatt.
Had to rebase and therefor amend changed the fixes.
The only code change is the two blocks buffer extension for possible race conditions.

try:
node.wait_for_block(int(blockhash, 16), 3)
res = True
assert_equal(res, result)
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems we never check anything if we got disconnected, I guess this check needs to move to after the except?

@jonasschnelli
Copy link
Contributor Author

Improved the disconnect test (amend commit).

@TheBlueMatt
Copy link
Contributor

utACK de74c62

@jonasschnelli
Copy link
Contributor Author

@laanwj, @gmaxwell: mind to re-ack?

@laanwj
Copy link
Member

laanwj commented Dec 9, 2017

utACK de74c62

@laanwj laanwj merged commit de74c62 into bitcoin:master Dec 9, 2017
laanwj added a commit that referenced this pull request Dec 9, 2017
…ignaling only*

de74c62 [Doc] Update bip.md, add support for BIP 159 (Jonas Schnelli)
e054d0e [QA] Add node_network_limited test (Jonas Schnelli)
bd09416 Avoid leaking the prune height through getdata (fingerprinting countermeasure) (Jonas Schnelli)
27df193 Always set NODE_NETWORK_LIMITED bit (Jonas Schnelli)
7caba38 Add NODE_NETWORK_LIMITED flags and min block amount constants (Jonas Schnelli)

Pull request description:

  Extracted from #10387.
  Does implement BIP159, but only the signalling part. No connections are made to NODE_NETWORK_LIMITED in this PR.

  The address relay and connection work (the more complicated part) can then be separated (probably in #10387).

Tree-SHA512: e3218eb4789a9320b0f42dc10f62d30c13c49bdef00443fbe653bee22933477adcfc1cf8f6a95269324560b5721203ed41f3c5e2dd8a98ec2791f6a9d8346b1a
@jnewbery
Copy link
Contributor

test is racy:

node_network_limited.py failed, Duration: 61 s

stdout:
2017-12-11 18:39:35.906000 TestFramework (INFO): Initializing test directory /tmp/user/1000/bitcoin_test_runner_20171211_183839/node_network_limited_227
2017-12-11 18:39:36.171000 TestFramework.mininode (INFO): Connecting to Bitcoin Node: 127.0.0.1:12816
2017-12-11 18:39:36.498000 TestFramework.mininode (INFO): Connecting to Bitcoin Node: 127.0.0.1:12816
2017-12-11 18:39:36.604000 TestFramework.mininode (INFO): Connecting to Bitcoin Node: 127.0.0.1:12816
2017-12-11 18:39:36.757000 TestFramework.mininode (INFO): Connecting to Bitcoin Node: 127.0.0.1:12816
2017-12-11 18:40:36.768000 TestFramework (ERROR): Assertion failed
Traceback (most recent call last):
  File "/home/ubuntu/bitcoin/test/functional/test_framework/test_framework.py", line 118, in main
    self.run_test()
  File "/home/ubuntu/bitcoin/test/functional/node_network_limited.py", line 65, in run_test
    self.tryGetBlockViaGetData(blocks[0], True) #first block outside of the 288+2 limit
  File "/home/ubuntu/bitcoin/test/functional/node_network_limited.py", line 33, in tryGetBlockViaGetData
    node.wait_for_verack()
  File "/home/ubuntu/bitcoin/test/functional/test_framework/mininode.py", line 373, in wait_for_verack
    wait_until(test_function, timeout=timeout, lock=mininode_lock)
  File "/home/ubuntu/bitcoin/test/functional/test_framework/util.py", line 222, in wait_until
    assert_greater_than(timeout, time.time())
  File "/home/ubuntu/bitcoin/test/functional/test_framework/util.py", line 42, in assert_greater_than
    raise AssertionError("%s <= %s" % (str(thing1), str(thing2)))
AssertionError: 1513017636.75866 <= 1513017636.7688699
2017-12-11 18:40:36.769000 TestFramework (INFO): Stopping nodes
2017-12-11 18:40:36.931000 TestFramework (WARNING): Not cleaning up dir /tmp/user/1000/bitcoin_test_runner_20171211_183839/node_network_limited_227
2017-12-11 18:40:36.931000 TestFramework (ERROR): Test failed. Test logging available at /tmp/user/1000/bitcoin_test_runner_20171211_183839/node_network_limited_227/test_framework.log
2017-12-11 18:40:36.931000 TestFramework (ERROR): Hint: Call /home/ubuntu/bitcoin/test/functional/combine_logs.py '/tmp/user/1000/bitcoin_test_runner_20171211_183839/node_network_limited_227' to consolidate all logs

fix is here: https://github.com/jnewbery/bitcoin/tree/improve_node_network_test . I'll open a PR.

@jonasschnelli
Copy link
Contributor Author

Thanks @jnewbery!

maflcko pushed a commit that referenced this pull request Dec 19, 2017
ee5efad [tests] refactor node_network_limited (John Newbery)
b425131 [tests] remove redundant duplicate tests from node_network_limited (John Newbery)
2e02984 [tests] node_network_limited - remove race condition (John Newbery)
dbfe294 [tests] define NODE_NETWORK_LIMITED in test framework (John Newbery)
1285312 [tests] fix flake8 warnings in node_network_limited.py (John Newbery)

Pull request description:

  Fixes race condition in the node_network_limited test case introduced in #11740. Also tidies up the test and removes redundant duplicate tests.

Tree-SHA512: a5240fe35509d81a47c3d3b141a956378675926093e658d24be43027b20d3b5f0ba7c6017c8208487a1849d4fdfb911a361911d571423db7c50711250aba3011
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jan 26, 2020
…ers) *signaling only*

de74c62 [Doc] Update bip.md, add support for BIP 159 (Jonas Schnelli)
e054d0e [QA] Add node_network_limited test (Jonas Schnelli)
bd09416 Avoid leaking the prune height through getdata (fingerprinting countermeasure) (Jonas Schnelli)
27df193 Always set NODE_NETWORK_LIMITED bit (Jonas Schnelli)
7caba38 Add NODE_NETWORK_LIMITED flags and min block amount constants (Jonas Schnelli)

Pull request description:

  Extracted from bitcoin#10387.
  Does implement BIP159, but only the signalling part. No connections are made to NODE_NETWORK_LIMITED in this PR.

  The address relay and connection work (the more complicated part) can then be separated (probably in bitcoin#10387).

Tree-SHA512: e3218eb4789a9320b0f42dc10f62d30c13c49bdef00443fbe653bee22933477adcfc1cf8f6a95269324560b5721203ed41f3c5e2dd8a98ec2791f6a9d8346b1a
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Feb 13, 2020
…ers) *signaling only*

de74c62 [Doc] Update bip.md, add support for BIP 159 (Jonas Schnelli)
e054d0e [QA] Add node_network_limited test (Jonas Schnelli)
bd09416 Avoid leaking the prune height through getdata (fingerprinting countermeasure) (Jonas Schnelli)
27df193 Always set NODE_NETWORK_LIMITED bit (Jonas Schnelli)
7caba38 Add NODE_NETWORK_LIMITED flags and min block amount constants (Jonas Schnelli)

Pull request description:

  Extracted from bitcoin#10387.
  Does implement BIP159, but only the signalling part. No connections are made to NODE_NETWORK_LIMITED in this PR.

  The address relay and connection work (the more complicated part) can then be separated (probably in bitcoin#10387).

Tree-SHA512: e3218eb4789a9320b0f42dc10f62d30c13c49bdef00443fbe653bee22933477adcfc1cf8f6a95269324560b5721203ed41f3c5e2dd8a98ec2791f6a9d8346b1a
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Feb 27, 2020
…ers) *signaling only*

de74c62 [Doc] Update bip.md, add support for BIP 159 (Jonas Schnelli)
e054d0e [QA] Add node_network_limited test (Jonas Schnelli)
bd09416 Avoid leaking the prune height through getdata (fingerprinting countermeasure) (Jonas Schnelli)
27df193 Always set NODE_NETWORK_LIMITED bit (Jonas Schnelli)
7caba38 Add NODE_NETWORK_LIMITED flags and min block amount constants (Jonas Schnelli)

Pull request description:

  Extracted from bitcoin#10387.
  Does implement BIP159, but only the signalling part. No connections are made to NODE_NETWORK_LIMITED in this PR.

  The address relay and connection work (the more complicated part) can then be separated (probably in bitcoin#10387).

Tree-SHA512: e3218eb4789a9320b0f42dc10f62d30c13c49bdef00443fbe653bee22933477adcfc1cf8f6a95269324560b5721203ed41f3c5e2dd8a98ec2791f6a9d8346b1a
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Feb 27, 2020
…ers) *signaling only*

de74c62 [Doc] Update bip.md, add support for BIP 159 (Jonas Schnelli)
e054d0e [QA] Add node_network_limited test (Jonas Schnelli)
bd09416 Avoid leaking the prune height through getdata (fingerprinting countermeasure) (Jonas Schnelli)
27df193 Always set NODE_NETWORK_LIMITED bit (Jonas Schnelli)
7caba38 Add NODE_NETWORK_LIMITED flags and min block amount constants (Jonas Schnelli)

Pull request description:

  Extracted from bitcoin#10387.
  Does implement BIP159, but only the signalling part. No connections are made to NODE_NETWORK_LIMITED in this PR.

  The address relay and connection work (the more complicated part) can then be separated (probably in bitcoin#10387).

Tree-SHA512: e3218eb4789a9320b0f42dc10f62d30c13c49bdef00443fbe653bee22933477adcfc1cf8f6a95269324560b5721203ed41f3c5e2dd8a98ec2791f6a9d8346b1a
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Apr 4, 2020
ee5efad [tests] refactor node_network_limited (John Newbery)
b425131 [tests] remove redundant duplicate tests from node_network_limited (John Newbery)
2e02984 [tests] node_network_limited - remove race condition (John Newbery)
dbfe294 [tests] define NODE_NETWORK_LIMITED in test framework (John Newbery)
1285312 [tests] fix flake8 warnings in node_network_limited.py (John Newbery)

Pull request description:

  Fixes race condition in the node_network_limited test case introduced in bitcoin#11740. Also tidies up the test and removes redundant duplicate tests.

Tree-SHA512: a5240fe35509d81a47c3d3b141a956378675926093e658d24be43027b20d3b5f0ba7c6017c8208487a1849d4fdfb911a361911d571423db7c50711250aba3011
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Apr 5, 2020
ee5efad [tests] refactor node_network_limited (John Newbery)
b425131 [tests] remove redundant duplicate tests from node_network_limited (John Newbery)
2e02984 [tests] node_network_limited - remove race condition (John Newbery)
dbfe294 [tests] define NODE_NETWORK_LIMITED in test framework (John Newbery)
1285312 [tests] fix flake8 warnings in node_network_limited.py (John Newbery)

Pull request description:

  Fixes race condition in the node_network_limited test case introduced in bitcoin#11740. Also tidies up the test and removes redundant duplicate tests.

Tree-SHA512: a5240fe35509d81a47c3d3b141a956378675926093e658d24be43027b20d3b5f0ba7c6017c8208487a1849d4fdfb911a361911d571423db7c50711250aba3011
gades pushed a commit to cosanta/cosanta-core that referenced this pull request Jun 30, 2021
…ers) *signaling only*

de74c62 [Doc] Update bip.md, add support for BIP 159 (Jonas Schnelli)
e054d0e [QA] Add node_network_limited test (Jonas Schnelli)
bd09416 Avoid leaking the prune height through getdata (fingerprinting countermeasure) (Jonas Schnelli)
27df193 Always set NODE_NETWORK_LIMITED bit (Jonas Schnelli)
7caba38 Add NODE_NETWORK_LIMITED flags and min block amount constants (Jonas Schnelli)

Pull request description:

  Extracted from bitcoin#10387.
  Does implement BIP159, but only the signalling part. No connections are made to NODE_NETWORK_LIMITED in this PR.

  The address relay and connection work (the more complicated part) can then be separated (probably in bitcoin#10387).

Tree-SHA512: e3218eb4789a9320b0f42dc10f62d30c13c49bdef00443fbe653bee22933477adcfc1cf8f6a95269324560b5721203ed41f3c5e2dd8a98ec2791f6a9d8346b1a
gades pushed a commit to cosanta/cosanta-core that referenced this pull request Jun 30, 2021
ee5efad [tests] refactor node_network_limited (John Newbery)
b425131 [tests] remove redundant duplicate tests from node_network_limited (John Newbery)
2e02984 [tests] node_network_limited - remove race condition (John Newbery)
dbfe294 [tests] define NODE_NETWORK_LIMITED in test framework (John Newbery)
1285312 [tests] fix flake8 warnings in node_network_limited.py (John Newbery)

Pull request description:

  Fixes race condition in the node_network_limited test case introduced in bitcoin#11740. Also tidies up the test and removes redundant duplicate tests.

Tree-SHA512: a5240fe35509d81a47c3d3b141a956378675926093e658d24be43027b20d3b5f0ba7c6017c8208487a1849d4fdfb911a361911d571423db7c50711250aba3011
@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.

7 participants