Skip to content

eth/protocols/eth, eth/downloader: backport partial receipt deadlock … - #3825

Merged
joey0612 merged 3 commits into
bnb-chain:developfrom
flywukong:fix/eth70-partial-receipt-deadlock
Sep 23, 2026
Merged

joey0612 merged 3 commits into
bnb-chain:developfrom
flywukong:fix/eth70-partial-receipt-deadlock

Conversation

@flywukong

@flywukong flywukong commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Description

Cherry-picks of ethereum/go-ethereum#35537 and ethereum/go-ethereum#35593 (both merged upstream after v1.17.3), kept as separate commits with their original authorship; a third commit adds BSC-side regression tests..

During SnapSync, an eth/70 partial-receipt continuation can deadlock with a concurrent request cancellation on the same peer. The receipt handler holds receiptBufferLock while waiting for the dispatcher, while the dispatcher processes cancellation and waits for that lock. This can also block the downloader’s receipt-fetching or cancellation flow and stall synchronization on the affected node. A malicious peer can influence when the continuation path runs, but deterministic remote triggering has not been demonstrated.

Rationale

  • The follow-up request is routed through the dispatcher as a resend operation and only sent while the original request is still pending; the receipt buffer entry is released through a per-request cleanup callback instead of the dispatcher touching receiptBufferLock (#35537).
  • An incomplete response that delivers no receipt is rejected, and deliveries assembled over several round trips are scaled to one round trip for peer capacity estimation (#35593).
  • Tests: TestBufferReceiptsNoProgress (upstream), TestPartialReceiptsCancelDoesNotDeadlock (sets the racing interleaving up explicitly; deadlocks on the old code within a few rounds) and TestPartialReceiptsContinuation (happy path: follow-up cont

Example

add an example CLI or API response...

Changes

Notable changes:

  • add each change in a bullet point here
  • ...

@hashdit-bot

hashdit-bot Bot commented Sep 17, 2026

Copy link
Copy Markdown

Pull Request Review

This Go/Ethereum P2P protocol backport fixes an eth/70 partial-receipt cancellation deadlock by routing continuation requests through the peer dispatcher and tying receipt-buffer cleanup to request lifecycle callbacks. It also rejects incomplete responses that make no progress, normalizes downloader capacity estimates across multiple round trips, and adds regression and continuation tests.

Sensitive Content

No sensitive content detected.

Security Issues

No serious security issues detected.


Generated by Hashdit Bot. This tool can absolutely NOT replace manual audits.

0xSHKWON and others added 3 commits September 17, 2026 13:19
…#35537)

When an eth/70 receipts response arrives with LastBlockIncomplete set,
requestPartialReceipts re-requested the remainder while holding
receiptBufferLock across the dispatch. That dispatch blocks until the
dispatcher loop accepts the request. If the loop is concurrently
cancelling a request for that peer, its cleanup takes the same
receiptBufferLock. The dispatcher then waits for the lock the re-request
holds while the re-request waits on a channel only the dispatcher reads.

The fix releases the lock before sending and routes the follow-up through
the dispatcher as a new resend request.

---------

Co-authored-by: Gary Rong <garyrong0905@gmail.com>
(cherry picked from commit c57bbe4)
…nses (#35593)

eth/70 can complete a receipts request over multiple round trips.
Current implementation has two issues in requester side.

1. A peer could keep a request loop alive with incomplete responses that
deliver no receipt. An incomplete response must now add at least one
receipt. A trailing empty list after other blocks is still accepted. We
already have a grace period and peer-dropping logic covering this, but
an additional guard is nice to have.

2. Response.Time is recorded across all rounds, making the peer's
roundtrip estimate incorrect. The dispatcher now counts the rounds
made under a request id, and the downloader divides the delivered
items and elapsed time to one round trip.

(cherry picked from commit 596096a)
@flywukong
flywukong force-pushed the fix/eth70-partial-receipt-deadlock branch from 679c2fb to 370a8b1 Compare September 17, 2026 05:20
@hashdit-bot

hashdit-bot Bot commented Sep 17, 2026

Copy link
Copy Markdown

Pull Request Review

This Go Ethereum P2P protocol backport fixes an eth/70 partial-receipt cancellation deadlock by routing continuation requests through the dispatcher and tying receipt-buffer cleanup to request lifecycle events. It also rejects incomplete responses that make no progress, normalizes peer-capacity measurements across multiple round trips, and adds regression and continuation tests.

Sensitive Content

No sensitive content detected.

Security Issues

No serious security issues detected.


Generated by Hashdit Bot. This tool can absolutely NOT replace manual audits.

@joey0612
joey0612 merged commit 8d50661 into bnb-chain:develop Sep 23, 2026
8 of 9 checks passed
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.

5 participants