Skip to content

Connect admitted hash exchange to bounded peer transport - #189

Closed
linroid wants to merge 2 commits into
torrent-v2-08-hash-exchangefrom
torrent-v2-08-hash-transport
Closed

linroid wants to merge 2 commits into
torrent-v2-08-hash-exchangefrom
torrent-v2-08-hash-transport

Conversation

@linroid

@linroid linroid commented Sep 12, 2026

Copy link
Copy Markdown
Owner

Connects hash-request ownership to frame issuance, bounded body reads and actor response dispatch on an already negotiated v2 connection. Body/decode credit is reserved before reading the payload and retained through dispatch; authenticated results keep separate exchange credit. Failed or canceled writes close potentially partial streams, and failed/timed-out/unadmitted reads close the connection and release frame credit.

Stacked on #188; advances step 08 of #162. One actor owns request/accept/expiry/close and joins its separately serialized reader after closing. Handshake routing, the complete runtime actor, timers, reply serving and payload integration remain pending. The inherited 64 KiB generic frame ceiling also needs profile-aware replacement for one-million-piece desktop bitfields; the production target is unchanged.

Validation: all four focused JVM transport tests pass, including loopback TCP request/response authentication, control-message dispatch, body admission before read, write failure and timeout cleanup. All 390 iOS simulator torrent tests executed and passed with zero failures/errors/skips using -PenableIosSimulatorTests=true. This framing test does not establish v2 handshake or independent-client interoperability.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 12, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-12T16:46:54.096969Z 880eca8 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 880eca8d4a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +43 to +45
withTimeout(timeoutMs) {
connection.write(PeerWire.encode(PeerHashWire.encode(PeerHashMessage.Request(selector))))
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Align write timeout with the exchange deadline

With the defaults, exchange.request(selector) starts a 30-second response deadline before this block, while the write may remain suspended for up to the transport's 180-second timeout. If socket backpressure delays a successful write beyond 30 seconds, request() returns a ticket that is already expired, so even an immediate valid response is rejected by PeerHashExchange.receive; because request and expiry are actor-owned, the blocked write also prevents that actor from expiring the ticket meanwhile. Bound the write by the exchange deadline or verify/cancel the ticket before returning it.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Fixed in bd9c0a8. Request writes now use the lesser of the transport timeout and the exact exchange ticket's remaining deadline, and recheck that deadline before returning. Failure closes the stream and releases request/frame credit. The regression failed on the previous code by returning an expired ticket; it now covers both suspended backpressure and a write that finishes at the deadline without suspending. All nine focused transport/exchange tests and iOS test-source compilation pass.

@github-actions

github-actions Bot commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

Test Results

  617 files  + 5    617 suites  +5   4m 1s ⏱️ -1s
2 615 tests +15  2 615 ✅ +15  0 💤 ±0  0 ❌ ±0 
3 437 runs  +25  3 437 ✅ +25  0 💤 ±0  0 ❌ ±0 

Results for commit bd9c0a8. ± Comparison against base commit e18b978.

♻️ This comment has been updated with latest results.

@linroid

linroid commented Sep 20, 2026

Copy link
Copy Markdown
Owner Author

Superseded by #235 (V2 handshake, hash exchange and bounded transport) in the consolidated eight-PR stack for #162.

The replacement preserves this PR's code and subsequent fixes; its description links the original head and review discussions. The only additional consolidation fix is the CI-discovered listener cancellation regression, documented on the replacement. All eight replacements have passed their required CI checks.

Closing without merging. This branch and its discussions remain available for reference. Review index: #162 (comment)

@linroid linroid closed this Sep 20, 2026
@linroid
linroid deleted the torrent-v2-08-hash-transport branch September 20, 2026 11:13
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.

1 participant