-
Notifications
You must be signed in to change notification settings - Fork 38.2k
Introduce a maximum size for locators. #13907
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2018,6 +2018,12 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr | |
| uint256 hashStop; | ||
| vRecv >> locator >> hashStop; | ||
|
|
||
| if (locator.vHave.size() > MAX_LOCATOR_SZ) { | ||
| LogPrint(BCLog::NET, "getblocks locator size %lld > %d, disconnect peer=%d\n", locator.vHave.size(), MAX_LOCATOR_SZ, pfrom->GetId()); | ||
| pfrom->fDisconnect = true; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a specific reason why you use
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because I don't see any particular reason to ban the peer. We only need to disconnect rather than just ignoring the message because the peer might be counting on our response and ignoring it could make it get stuck when otherwise it might make progress with someone else. We similarly disconnect for some messges when OutboundTargetReached, when we're limited and someone requests a block before the limited horizon, when the peer requests BIP37 services that we're not offering, etc.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Makes sense, thanks for the clarification! |
||
| return true; | ||
| } | ||
|
|
||
| // We might have announced the currently-being-connected tip using a | ||
| // compact block, which resulted in the peer sending a getblocks | ||
| // request, which we would otherwise respond to without the new block. | ||
|
|
@@ -2131,6 +2137,12 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr | |
| uint256 hashStop; | ||
| vRecv >> locator >> hashStop; | ||
|
|
||
| if (locator.vHave.size() > MAX_LOCATOR_SZ) { | ||
| LogPrint(BCLog::NET, "getheaders locator size %lld > %d, disconnect peer=%d\n", locator.vHave.size(), MAX_LOCATOR_SZ, pfrom->GetId()); | ||
| pfrom->fDisconnect = true; | ||
| return true; | ||
| } | ||
|
|
||
| LOCK(cs_main); | ||
| if (IsInitialBlockDownload() && !pfrom->fWhitelisted) { | ||
| LogPrint(BCLog::NET, "Ignoring getheaders from peer=%d because node is in initial block download\n", pfrom->GetId()); | ||
|
|
||
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.
Note that your BIP says: "A locator included in a getblock or getheaders message may include no more
than 64 hashes, including the final hash_stop hash", so unless I am mistaken, the
>should be replaced with a>=?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.
Yes, if we end up following the BIP. I'm giving it about equal odds that we need to use a threshold higher than the BIP for now, after we see whats showing up on the network.