-
Notifications
You must be signed in to change notification settings - Fork 38.7k
net: Better askfor request management #4831
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
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.
"tx" instead of "netaskfor"? And should this be added to the command line syntax messages in init.cpp?
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.
Could be called 'tx' but I tried to keep it as general as possible. It requests inventory items.
ACK on adding it to command-line syntax.
ff901f6 to
6256fdb
Compare
9b13825 to
a2afa1d
Compare
src/netaskfor.cpp
Outdated
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.
What is the trailing .first->second for?
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.
That's a leftover from the commented code above it. Basically, the CNodeAskForState had some initial assignments here so a reference to it was stored. This is not necessary at the moment so both the commented code and the .first->second should go.
|
This is excellent. Could we unify the handling and scheduling of transactions getdata/invs with block getdata/invs ? |
|
We are actually doing already something very similar for blocks, and the headersfirst branch extends it (#4468). It's a bit more complicated there, as we want a moving window of block fetching to limit out-of-orderness in which blocks arrive. |
|
Big +1 on code organization: implementing independent pieces of protocol handling should definitely move to separate files, with separate data structures and separate locks (other examples that afaik could easily be converted into this style are ping/pong and alerts). It's a bit unfortunate that the block fetching and tx fetching code are separated but implement similar functionality. It's a strict improvement though as they were already separate (originally my fault I guess, as I didn't touch the tx handling code when rewriting the block handling part), and unifying them now would probably interfere with other changes. |
|
@SergioDemianLerner As I see it, blocks handling is much more closely bound to main/core than this (basically independent) inventory item fetcher, making it enough of a separate concern to warrant being a different module. I'm not against unifying them if it can be done sanely, of course. But block handling is essentially different especially after headers-first. |
|
Malicious block invs? What is one of those? |
|
Currently, the logic is such that large orphan txs are requested repeatedly and ignored repeatedly:- 2014-09-06 00:01:46 ignoring large orphan tx (size: 5057, hash: 18098a192869ef0f9128be9bf1f3bb243575f88d072bb24f918c4e4f5a894b80) peer=1 Is it possible to make the node remember recently ignored txs so that they don't keep being requested? This was working in the previous implementation thanks to #4542 |
|
@rebroad This should simply work with #4542? It doesn't touch any part of the same code. As I see it, the logic of whether to request something is outside scope of this module. If you ask netaskfor to retrieve a transaction for you, it will do so, until being told to stop :) (or until it runs out of peers) |
|
@laanwj oh.. yes, you are right. Ok, I'll re-merge 4542 in that case (which didn't touch large orphan txs anyway I've just noticed!). |
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 should skip nodes whose sendbuffer is full.
What is the correct way to check this? This would be something like pnode->nSendSize < SendBufferSize(), but I'm not sure what lock is needed for that.
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 theory you would need pnode->cs_vSend, but if you can argue that the system keeps working correctly even if the test returns the right result only most of the time, put a big comment, and use no lock...
|
Looks like the timeout could indeed be reduced. In by-far most cases the transaction is returned in a few seconds. At the same time, invs for it are still coming in from other nodes. |
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.
There is nothing in place at the moment to make sure that data items are requested in the same order that they're announced (std::multimap does not preserve insertion order). There probably needs to be.
OTOH when requesting from multiple nodes (or when timeouts are involved) there is no guarantee that the response will come in the same order as the requests. So maybe it's not an issue.
A condition that can wait for a specified timeout, this is useful when it is known in advance that events have to be processed at some time in the future.
This allows modules to maintain their own threads.
a2afa1d to
9cbaaf6
Compare
|
Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/p4831_9cbaaf61ade4b91469f3d728795ec83859c25192/ for binaries and test log. |
|
Going to test this. |
|
Works without problems (even in valgrind, after running for a few days). I didn't actually check whether it fetches/relays things correctly, though. |
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.
Nit: This should go below our headers, so just flip this with the block below.
|
Just a general question, why are most/all comments beginning with |
|
@Diapolo It's so that they'll be picked up by doxygen. It doesn't recognise comments starting with // |
|
I hope you pick this up soon after 0.10 :) |
|
Needs rebase - is this still in progress? |
|
Ping. Needs refresh. I think the general consensus is that we want this, but needs more review? Seems to have positive noises in the security discussion and on here, but no ACKs. |
|
I tested this previously (at some version...) but it got put down after being punted out of 0.10. Seems to have been forgotten. Lets unforget it. |
|
concept ACK |
|
concept ACK - let this not be forgotten |
|
Perhaps this will be pushed back until after Cory's P2P refactor?
|
|
Needs to be picked back up at some point, I'm not sure when. |
I also think it can serve as an example of how to 'peel off' a single concern from net/main.
Uses CTimeoutCondition from @ashleyholman (#4230).
Cases to test:
REQUEST_TIMEOUTI've tested these cases using custom pynode clients, as well as by running this with full debugging on my node to see how it behaves,
TODO:
FlushGetdata's handling of CNode locking is correctKnown issues:
Doesn't currently group getdata requests (sends a getdata request per item instead of one getdata for many invs) - wouldn't be too difficult to fit in but I'm not sure it is worth the complexity, as usually only one inv is sent at a time(done now)Supercedes: #4828 #4547 #4827