Skip to content
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

feat: increase the number of block headers able to be downloaded at once to 8000 in protocol version 70235 #6239

Open
wants to merge 11 commits into
base: develop
Choose a base branch
from

Conversation

PastaPastaPasta
Copy link
Member

@PastaPastaPasta PastaPastaPasta commented Aug 28, 2024

Issue being fixed or feature implemented

We did some testing quite a while ago that found that sending 8000 headers at a time could speed stuff up. But we wanted to wait until compressed headers were implemented. Well, they've been implemented!

What was done?

Bump 2000 -> 8000 triggered by protocol version

How Has This Been Tested?

Hasn't, we should setup a few nodes running this and sync them from each other

Breaking Changes

New protocol version, not breaking but should add notes? I should probably add release notes

Checklist:

Go over all the following points, and put an x in all the boxes that apply.

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have made corresponding changes to the documentation
  • I have assigned this pull request to a milestone (for repository code-owners and collaborators only)

@PastaPastaPasta PastaPastaPasta added this to the 21.2 milestone Aug 29, 2024
@PastaPastaPasta PastaPastaPasta marked this pull request as ready for review August 29, 2024 15:33
Copy link
Collaborator

@kwvg kwvg left a comment

Choose a reason for hiding this comment

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

Consider f69f410 and 08878d6

knst
knst previously approved these changes Sep 4, 2024
Copy link
Collaborator

@knst knst left a comment

Choose a reason for hiding this comment

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

utACK fa6dd58

@@ -3110,7 +3110,7 @@ void PeerManagerImpl::ProcessHeadersMessage(CNode& pfrom, Peer& peer,
}

// Consider fetching more headers.
if (nCount == MAX_HEADERS_RESULTS) {
if (nCount == (pfrom.GetCommonVersion() >= INCREASE_MAX_HEADERS_VERSION ? MAX_HEADERS_RESULTS_NEW : MAX_HEADERS_RESULTS_OLD)) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: can you add instead a helper function?

such as pfrom.MaxHeadersResults()

@PastaPastaPasta
Copy link
Member Author

TODO: tie increase to only apply to headers2 and not headers message

src/validation.h Outdated
@@ -85,10 +85,9 @@ static const int MAX_SCRIPTCHECK_THREADS = 15;
static const int DEFAULT_SCRIPTCHECK_THREADS = 0;
/** Number of headers sent in one getheaders result. We rely on the assumption that if a peer sends
* less than this number, we reached its tip. Changing this value is a protocol upgrade. */
static const unsigned int MAX_HEADERS_RESULTS = 8000;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should not use old name for better error resistance for backports. So, it won't be mistakenly used directly this constant instead helper function

@UdjinM6
Copy link

UdjinM6 commented Sep 4, 2024

TODO: tie increase to only apply to headers2 and not headers message

pls check b2f3593

@PastaPastaPasta
Copy link
Member Author

TODO: tie increase to only apply to headers2 and not headers message

pls check b2f3593

What about knst's concern around changing the name of the old variable to avoid incidental backport silent errors?

@UdjinM6
Copy link

UdjinM6 commented Sep 4, 2024

TODO: tie increase to only apply to headers2 and not headers message

pls check b2f3593

What about knst's concern around changing the name of the old variable to avoid incidental backport silent errors?

agree, and this issue is addressed in my commit too

@PastaPastaPasta
Copy link
Member Author

How so? you still have the variable

static const unsigned int MAX_HEADERS_RESULTS = 2000;

@UdjinM6
Copy link

UdjinM6 commented Sep 4, 2024

diff for src/validation.h with my commit applied looks like this

diff --git a/src/validation.h b/src/validation.h
index 8dc4d7e656..75b7590ffe 100644
--- a/src/validation.h
+++ b/src/validation.h
@@ -86,6 +86,7 @@ static const int DEFAULT_SCRIPTCHECK_THREADS = 0;
 /** Number of headers sent in one getheaders result. We rely on the assumption that if a peer sends
  *  less than this number, we reached its tip. Changing this value is a protocol upgrade. */
 static const unsigned int MAX_HEADERS_RESULTS = 2000;
+static const unsigned int MAX_HEADERS2_RESULTS = 8000;
 
 static const int64_t DEFAULT_MAX_TIP_AGE = 6 * 60 * 60; // ~144 blocks behind -> 2 x fork detection time, was 24 * 60 * 60 in bitcoin
 

@PastaPastaPasta
Copy link
Member Author

Yes, but if bitcoin changes stuff, and uses MAX_HEADERS_RESULTS we may actually want to be using MAX_HEADERS2_RESULTS for some reason, but the backport will merge w/o issue. If we change the name of MAX_HEADERS_RESULTS to something else, then we'll have to make a manual decision as to which applies in that situation during the merge. I guess it is better that in your commit the default logic would be the conservative one. Just want to make sure you don't think it'd be valuable to change it to something else and force us to evaluate it.

@UdjinM6
Copy link

UdjinM6 commented Sep 4, 2024

oh, sorry, I misunderstood his comment. I thought his concerns were that we change MAX_HEADERS_RESULTS value and it might affect smth once we do backports that rely on it. My bad.

@UdjinM6
Copy link

UdjinM6 commented Sep 4, 2024

yeah, then you need s/MAX_HEADERS_RESULTS/<some new name>/ on top of my commit indeed. I don't like _OLD suffix though... maybe simply MAX_HEADERS_RESULTS_ so that it would look close enough but still cause backport conflicts/issues?

@knst
Copy link
Collaborator

knst commented Sep 4, 2024

I don't like _OLD suffix though... maybe simply MAX_HEADERS_RESULT

MAX_HEADERS_UNCOMPRESSED_RESULTS
MAX_HEADERS_COMPRESSED_RESULT

?

@PastaPastaPasta
Copy link
Member Author

please advise how ya'll think I should move forward :)

@UdjinM6
Copy link

UdjinM6 commented Sep 5, 2024

please advise how ya'll think I should move forward :)

b2f3593 +

MAX_HEADERS_UNCOMPRESSED_RESULTS and MAX_HEADERS_COMPRESSED_RESULT

I guess

@PastaPastaPasta PastaPastaPasta force-pushed the feat-introduce-increased-block-headers-requests branch from 2a98834 to 3b142a4 Compare September 6, 2024 20:13
@UdjinM6
Copy link

UdjinM6 commented Sep 6, 2024

pls see ac8fa39 and 5a28ca0

also, Gitlab CI won't pick the branch... try rebasing maybe?

@PastaPastaPasta PastaPastaPasta force-pushed the feat-introduce-increased-block-headers-requests branch from 8adfad9 to 07f6b4f Compare September 10, 2024 03:04
@PastaPastaPasta PastaPastaPasta force-pushed the feat-introduce-increased-block-headers-requests branch from 07f6b4f to b423f42 Compare September 10, 2024 15:25
Copy link

@UdjinM6 UdjinM6 left a comment

Choose a reason for hiding this comment

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

pls see 0e66be4 + below

also needs release notes I guess

test/functional/test_framework/p2p.py Outdated Show resolved Hide resolved
@PastaPastaPasta PastaPastaPasta changed the title feat: increase the number of block headers able to be downloaded at once to 8000 in protocol version 70234 feat: increase the number of block headers able to be downloaded at once to 8000 in protocol version 70235 Sep 10, 2024
PastaPastaPasta and others added 3 commits September 10, 2024 12:56
Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
…or it to accept `compressed` instead of `msg_type`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Awaiting Review
Development

Successfully merging this pull request may close these issues.

4 participants