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

polygon/p2p: add request chunking to FetchHeaders #9536

Merged
merged 15 commits into from
Feb 29, 2024

Conversation

taratorio
Copy link
Member

@taratorio taratorio commented Feb 28, 2024

This PR adds chunking logic to FetchHeaders and corresponding unit tests so that we stay within the soft limits:

  1. 2 MB response size
  2. 1024 headers

Base automatically changed from astrid-p2p-fetch-headers-validations to devel February 29, 2024 08:16
const responseTimeout = 5 * time.Second
const (
responseTimeout = 5 * time.Second
maxFetchHeadersRange = 16384
Copy link
Contributor

Choose a reason for hiding this comment

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

what's the reason for this limit? I feel that it should be up to the client to decide

Copy link
Member Author

Choose a reason for hiding this comment

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

this was so that we have an upper bound on number of requests sent to a peer at the same time - it is no longer applicable since we now changed to do 1 request at a time when chunking so ive removed it

requestId := f.requestIdGenerator()
requestIds[requestId] = i

if err := f.messageSender.SendGetBlockHeaders(ctx, peerId, eth.GetBlockHeadersPacket66{
Copy link
Contributor

Choose a reason for hiding this comment

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

we shouldn't spam a peer with requests. let's do it sequentially: send one, and wait for a response, then send a 2nd one. if the response doesn't come in time, we should retry the request a couple of times.

Copy link
Member Author

Choose a reason for hiding this comment

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

ok, this actually simplifies the code a lot - fixed
re: retrying - im doing this in a subsequent PR #9537 (it needs to be updated with the changes ive just done here)

@taratorio taratorio marked this pull request as ready for review February 29, 2024 12:14
Copy link
Contributor

@battlmonstr battlmonstr left a comment

Choose a reason for hiding this comment

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

LG ™️

@battlmonstr battlmonstr merged commit d18fdaa into devel Feb 29, 2024
7 checks passed
@battlmonstr battlmonstr deleted the astrid-p2p-chunk-fetch-headers branch February 29, 2024 12:47
mriccobene pushed a commit to mriccobene/erigon that referenced this pull request Mar 13, 2024
This PR adds chunking logic to FetchHeaders and corresponding unit tests
so that we stay within the soft limits:
1. 2 MB response size
2. 1024 headers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants