Skip to content

fix(p2p/pex): do not send PEX request in fast dial mode (backport #4644)#4649

Merged
jmalicevic merged 2 commits intov0.38.xfrom
mergify/bp/v0.38.x/pr-4644
Dec 12, 2024
Merged

fix(p2p/pex): do not send PEX request in fast dial mode (backport #4644)#4649
jmalicevic merged 2 commits intov0.38.xfrom
mergify/bp/v0.38.x/pr-4644

Conversation

@mergify
Copy link
Contributor

@mergify mergify bot commented Dec 12, 2024

Solves #4620.

Fixes an issue introduced by #3360.

In short, when receiving addresses from a configured seed node, the peer immediately dials the received addresses, without waiting for the defaultEnsurePeersPeriod (30s). This is a desired behavior, the "fast dial mode" in the title.

However, for preventing abuse, a node only accepts PEX requests from a peer every minReceiveRequestInterval() time, set to defaultEnsurePeersPeriod/3 (10s). When running this "fast dial mode", however, a PEX request can be send, in some unlucky setup, to the same peer without waiting for the full defaultEnsurePeersPeriod` (30s).

The problem is that at the receive side, a node keeps track of the latest PEX request received from each peer. If two requests are received with an interval lower than minReceiveRequestInterval(), the peer is considered abusive: it is disconnected with an ErrReceivedPEXRequestTooSoon error and banned from the address book.

This PR proposes a workaround to prevent the above mentioned scenario.


PR checklist

Solves #4620.

Fixes an issue introduced by
#3360.

In short, when receiving addresses from a configured seed node, the peer
immediately dials the received addresses, without waiting for the
`defaultEnsurePeersPeriod` (30s). This is a desired behavior, the "fast
dial mode" in the title.

However, for preventing abuse, a node only accepts PEX requests from a
peer every `minReceiveRequestInterval()` time, set to
`defaultEnsurePeersPeriod/3` (10s). When running this "fast dial mode",
however, a PEX request can be send, in some unlucky setup, to the same
peer without waiting for the full defaultEnsurePeersPeriod` (30s).

The problem is that at the receive side, a node keeps track of the
latest PEX request received from each peer. If two requests are received
with an interval lower than `minReceiveRequestInterval()`, the peer is
considered abusive: it is disconnected with an
`ErrReceivedPEXRequestTooSoon` error and banned from the address book.

This PR proposes a workaround to prevent the above mentioned scenario.

---

#### PR checklist

- [ ] Tests written/updated
- [ ] Changelog entry added in `.changelog` (we use
[unclog](https://github.com/informalsystems/unclog) to manage our
changelog)
- [ ] Updated relevant documentation (`docs/` or `spec/`) and code
comments

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
(cherry picked from commit 491379f)

# Conflicts:
#	p2p/pex/pex_reactor.go
@mergify mergify bot requested a review from a team as a code owner December 12, 2024 10:35
@mergify mergify bot added the conflicts label Dec 12, 2024
@mergify
Copy link
Contributor Author

mergify bot commented Dec 12, 2024

Cherry-pick of 491379f has failed:

On branch mergify/bp/v0.38.x/pr-4644
Your branch is up to date with 'origin/v0.38.x'.

You are currently cherry-picking commit 491379f20.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   p2p/pex/pex_reactor.go

no changes added to commit (use "git add" and/or "git commit -a")

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

@mergify mergify bot assigned cason Dec 12, 2024
@jmalicevic jmalicevic assigned jmalicevic and unassigned cason Dec 12, 2024
@jmalicevic jmalicevic added this to the 2024-Q4 milestone Dec 12, 2024
@jmalicevic jmalicevic merged commit fbd6f8d into v0.38.x Dec 12, 2024
@jmalicevic jmalicevic deleted the mergify/bp/v0.38.x/pr-4644 branch December 12, 2024 11:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants