-
Notifications
You must be signed in to change notification settings - Fork 37.7k
Bugfix: net_processing: Restore "Already requested" error for FetchBlock #28055
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
…error, even if we already have the block
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code CoverageFor detailed information about the code coverage, see the test coverage report. ReviewsSee the guideline for information on the review process. ConflictsNo conflicts as of last run. |
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.
The result of this PR would be that it would return an error IFF that particular block was requested by that specific peer last. If you request the block from another peer, the behavior would be unchanged. Is that acceptable?
slow_peer_id = peers[2]["id"] | ||
assert_equal(self.nodes[0].getblockfrompeer(short_tip, slow_peer_id), {}) | ||
assert_raises_rpc_error(-1, "Already requested from this peer", self.nodes[0].getblockfrompeer, short_tip, slow_peer_id) | ||
|
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.
self.log.info("But every fetch to another peer causes us to forget previous attempts for same block") | |
self.nodes[0].add_p2p_connection(P2PInterface()) | |
peers = self.nodes[0].getpeerinfo() | |
assert_equal(len(peers), 4) | |
slow_peer_id_2 = peers[3]["id"] | |
assert_equal(self.nodes[0].getblockfrompeer(short_tip, slow_peer_id_2), {}) | |
assert_equal(self.nodes[0].getblockfrompeer(short_tip, slow_peer_id), {}) | |
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.
example test covering the behavior I'm mentioning
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.
The result of this PR would be that it would return an error IFF that particular block was requested by that specific peer last. If you request the block from another peer, the behavior would be unchanged. Is that acceptable?
I think that I would find that acceptable.
I guess one alternative would be to drop the "Already requested from this peer" error that is currently not triggerable, and just forget about the prior request unconditionally on a new request.
I think @mzumsande's suggestion is better. But the current PR, with @instagibbs's tests to document the existing weirdness, is fine too. Either behaviour is "covered" by the RPC doc warning:
Could be improved by saying:
|
if (IsBlockRequestedFromPeer(hash, peer_id)) return "Already requested from this peer"; | ||
|
||
// Forget about all prior requests | ||
RemoveBlockRequest(block_index.GetBlockHash(), std::nullopt); | ||
RemoveBlockRequest(hash, std::nullopt); | ||
|
||
// Mark block as in-flight | ||
if (!BlockRequested(peer_id, block_index)) return "Already requested from this peer"; | ||
Assume(BlockRequested(peer_id, block_index)); |
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.
In 2b67ea4:
Instead of adding the new function, could just delete the RemoveBlockRequest()
line and directly call BlockRequested()
. Failing with a Already requested from this peer
if the call return false.
BlockRequested()
only fails when the block is already in-flight for that peer (it does the same as your new IsBlockRequestedFromPeer()
function).
@luke-jr are you going to followup with the questions, test suggestions, code-review and general feedback here? |
ping @luke-jr. |
Discussed this with some other contributors, and for now, I'm removing this from the 25.1 milestone. I don't currently consider this a blocker for 25.1, and, it cannot be merged or reviewed in any case, until the review feedback is addressed. |
Can be marked as draft, while it is waiting on the author? |
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.
I could take this forward if there's no progress here. I actually fixed the issue before this PR was created, in #27837 (27a2592). So, it would just be matter of gathering this PR test commits with my little fix commit in a new PR.
Side shilling note, would be nice to progress on #28170 and #28170 bug fixes.
I don't think it's clear that is something that actually needs fixing, or that we want to change at this point. |
well, if the node has requested a block from a certain peer and is waiting for the response. It should not allow the user (or an external software) to re-request the same block multiple times. It is a waste of bandwidth and the other peer could end up banning the node for misbehaving. It's better to notify the misbehavior rather than get silently banned from the network. |
🤔 There hasn't been much activity lately and the CI seems to be failing. If no one reviewed the current pull request by commit hash, a rebase can be considered. While the CI failure may be a false positive, the CI hasn't been running for some time, so there may be a real issue hiding as well. A rebase triggers the latest CI and makes sure that no silent merge conflicts have snuck in. |
🤔 There hasn't been much activity lately and the CI seems to be failing. If no one reviewed the current pull request by commit hash, a rebase can be considered. While the CI failure may be a false positive, the CI hasn't been running for some time, so there may be a real issue hiding as well. A rebase triggers the latest CI and makes sure that no silent merge conflicts have snuck in. |
🤔 There hasn't been much activity lately and the CI seems to be failing. If no one reviewed the current pull request by commit hash, a rebase can be considered. While the CI failure may be a false positive, the CI hasn't been running for some time, so there may be a real issue hiding as well. A rebase triggers the latest CI and makes sure that no silent merge conflicts have snuck in. |
Closing, given no followup. |
Regression introduced by #27626
Adds new tests