-
Notifications
You must be signed in to change notification settings - Fork 37.7k
Implement BIP159 NODE_NETWORK_LIMITED (pruned peers) *signaling only* #11740
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
Conversation
e874478a42eded1c5952fc0407f04279dd4837c1 forgot to add |
a26d177
to
af05b92
Compare
@fanquake! Thanks. Done. |
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.
utACK
utACK af05b92 |
utACK af05b92591b72c34f8fa04a0917b3c1225e2417c |
src/net_processing.cpp
Outdated
@@ -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) ) |
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.
This needs a buffer beyond NODE_NETWORK_LIMITED_MIN_BLOCK. Because it gets a disconnect, one or two blocks should suffice.
src/net_processing.cpp
Outdated
)) { | ||
LogPrint(BCLog::NET, "Ignore block request below NODE_NETWORK_LIMITED threshold from peer=%d\n", pfrom->GetId()); | ||
|
||
//disconnect node |
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.
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() |
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.
Can you move this into the try block? This checks that the node disconnected us, we didn't just timeout in the fail case.
The current pruning implementation does ensure to always conform to BIP159
f06c84e
to
d57a4e5
Compare
Fixed points reported by @TheBlueMatt. |
try: | ||
node.wait_for_block(int(blockhash, 16), 3) | ||
res = True | ||
assert_equal(res, result) |
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.
It seems we never check anything if we got disconnected, I guess this check needs to move to after the except?
d57a4e5
to
de74c62
Compare
Improved the disconnect test (amend commit). |
utACK de74c62 |
utACK de74c62 |
…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
test is racy:
fix is here: https://github.com/jnewbery/bitcoin/tree/improve_node_network_test . I'll open a PR. |
Thanks @jnewbery! |
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
…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
…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
…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
…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
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
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
…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
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
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).