Skip to content

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

Merged
jmalicevic merged 1 commit intov1.xfrom
mergify/bp/v1.x/pr-4644
Dec 12, 2024
Merged

fix(p2p/pex): do not send PEX request in fast dial mode (backport #4644)#4648
jmalicevic merged 1 commit intov1.xfrom
mergify/bp/v1.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)
@mergify mergify bot assigned cason Dec 12, 2024
@mergify mergify bot requested a review from a team as a code owner December 12, 2024 10:35
@mergify mergify bot requested a review from a team December 12, 2024 10:35
@jmalicevic jmalicevic merged commit a4d9e85 into v1.x Dec 12, 2024
@jmalicevic jmalicevic deleted the mergify/bp/v1.x/pr-4644 branch December 12, 2024 11:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants