Skip to content

test: end a failed v2 handshake without resetting the connection - #254

Merged
djh58 merged 1 commit into
feature/pq-transportfrom
djh58/pq233-p2p-half-close
Oct 26, 2026
Merged

djh58 merged 1 commit into
feature/pq-transportfrom
djh58/pq233-p2p-half-close

Conversation

@djh58

@djh58 djh58 commented Oct 26, 2026 •

Copy link
Copy Markdown
Member

Fixes a timing-dependent failure from #246 that failed #233's Full Validation on 36868cc. The job was Windows native, VS 2022, and the test was p2p_v2_pq_misbehaving.py, in the case "the same responder failing the node's confirmation in turn" (run 40363459177).

Cause.

  • When the Python v2 peer fails the node's key confirmation, it writes out what it has sent and closes the connection (i2p, test: steady SAM creation deadline, test framework fixes #246).
  • The node sends its version packet right after its confirmation. If those bytes are still unread on the peer's socket when it closes, the close resets the connection.
  • On Windows, the reset discards what the node hasn't read yet, the peer's confirmation included. The node logged socket recv error ... forcibly closed by the remote host (10054) and closed_after_switch cause=reset instead of the first_packet_failed the test expects.
  • Earlier Windows runs passed because the race went the other way.

Fix. The peer ends its stream with write_eof() and lets the node close the connection, discarding what the node still sends until then. Sends after that are dropped, because a write after write_eof() raises. Only this case reaches the code: it is the only one where the Python peer fails the node's confirmation.

Tests run.

  • The socket behaviour, standalone. An asyncio peer answers a plain socket's first bytes and ends the connection while the second bytes are unread on its side. With close() the other side read the answer, then a reset, in 3 of 3 runs. With write_eof() it read the answer, then the end of the stream, in 3 of 3 runs.

  • The functional tests:

    • p2p_v2_pq_misbehaving.py five times;
    • p2p_v2_misbehaving, p2p_v2_encrypted, p2p_v2_transport, p2p_v2_pq and p2p_v2_pq_fallback;
    • rpc_pqtransport, feature_framework_unit_tests and feature_assumevalid;
    • p2p_invalid_messages, p2p_ping and p2p_disconnect_ban (v1 and v2).

    All passed on Linux.

  • Not run: Windows, where the failure happened. Hybrid post-quantum v2 transport (#184) — integration #233's CI runs it once this merges. Since ci: stop validating feature/pq-transport by name #245, pull requests into feature/pq-transport don't run CI.

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

When the Python v2 peer fails the node's key confirmation, it writes out
what it has sent and closes the connection, so that the node sees the
peer's own confirmation fail (#246). But a close with the node's later
bytes still unread on the peer's socket resets the connection, and on
Windows the reset discards what the node has not read yet: the node then
records closed_after_switch (reset) instead of first_packet_failed, and
p2p_v2_pq_misbehaving.py fails. The node sends its version packet right
after its confirmation, so this depends on timing.

End the peer's stream with write_eof() instead and let the node close the
connection, discarding what the node still sends until then. Sends after
that are dropped, since a write after write_eof() raises.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@djh58

djh58 commented Oct 26, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 26, 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-10-26T17:34:25.848687Z 6111007 Manual request
ℹ️ 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.

@qbit-reviewer

qbit-reviewer Bot commented Oct 26, 2026

Copy link
Copy Markdown

Reviewed at 6111007: 0 findings shared privately with maintainers.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: 6111007051

ℹ️ 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".

@djh58
djh58 merged commit 543fc53 into feature/pq-transport Oct 26, 2026
@djh58 djh58 mentioned this pull request Oct 26, 2026
6 of 15 tasks
djh58 added a commit that referenced this pull request Oct 27, 2026
* ci: check mainnet publication posture for 1.1.0

The "mainnet publication posture" job checks that the source being
released keeps the mainnet launch posture: the AuxPoW chain ID, the
genesis and ASERT launch data, the mainnet bootstrap, and the
default-mainnet build. The "Classify release target" step only set
mainnet_publish_gate_required for target branch 1.0.0, so pull
requests, merge-queue runs and pushes into 1.1.0, the next mainnet
release line, skipped the job and the Core Checks Gate never asked for
its result.

Set the output for 1.1.0 as well, and keep 1.0.0. The job's `if:` and
the Core Checks Gate both read this output, so for source and
release-policy changes into 1.1.0 the job now runs and a failure blocks
the gate. Pin both branches in the existing workflow contract test, and
update the release process, which names the branches the job runs for.

Refs #222

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* build: bump version to v1.1.0-rc1

Set CLIENT_VERSION_MINOR to 1, CLIENT_VERSION_BUILD to 0 and
CLIENT_VERSION_RC to 1 so the source identifies as v1.1.0-rc1, the
first release candidate of v1.1.0, the release after v1.0.1 that adds
the hybrid post-quantum v2 transport (#184). CLIENT_VERSION_IS_RELEASE
stays true: 1.1.0 is a release line, so candidate binaries carry no
commit suffix, as for v1.0.0 and the v1.0.1 candidates.

CMake appends "-rc1" to CLIENT_VERSION_STRING, so every binary reports
v1.1.0-rc1, the user agent becomes /qbit:1.1.0-rc1/, and the Windows
installer metadata and the RPC docs manifest's project version derive
from the same string. The Guix archive name comes from the v1.1.0-rc1
tag itself.

Regenerate the seven manual pages with contrib/devtools/gen-manpages.py
(help2man 1.49.3) from a build of this tree with the GUI, the wallet
and every tool. Besides the version and date lines, qbitd.1 and
qbit-qt.1 gain -v2pqtransport, which #184 added as a connection option.
The other options #184 added (-mlkemportable and the regtest-only
-test values) are debug options that only -help-debug lists, so the
pages don't show them.

util_tests/test_FormatSubVersion expected the "Test" client name to
format as CLIENT_VERSION_STRING, which fails for every version with a
release-candidate suffix: FormatSubVersion uses that string only for
the qbit user agent and formats any other name numerically. Apply the
same fix as the v1.0.1-rc1 preparation (#181), byte for byte, so that
merging 1.x.x into 1.1.0 brings an identical change: expect the
numeric form built from the version components. The qbit user-agent
checks on the next lines still cover CLIENT_VERSION_STRING.

Refs #222

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* doc: draft v1.1.0 release notes

Add doc/release-notes-1.1.0.md in the structure of the v1.0.1 notes
(#181). It covers every change merged to 1.1.0 since it branched from
1.x.x at 45e9e72: the hybrid post-quantum v2 transport, with the
parts and fixes merged through #233 (#223 to #254), and #249.

Behavior changes come first: the hybrid transport is on by default, how
to switch it off, the numeric -v2pqtransport value, the single I2P
session-creation limit and qbit-photon's OpenSSL configuration loading.
A compatibility table states how v1.1.0 nodes connect with v1.0.0 and
v1.0.1 nodes and over v1, in both directions, as
p2p_v2_previous_release.py and rpc_pqtransport.py test it. Known
limitations summarize the release fuzz campaign and the limits its
report on #222 states, the basis of the load-shedding threshold, the
portable ML-KEM code on AArch64 Linux, and the unsigned-platform waiver
(#70). The only performance figures are the handshake benchmark results
published in #240.

Fold in and delete the 1.1.0 fragments doc/release-notes-223.md, -240.md
and -249.md, and point the specification's and the operator guide's
release-note links at the new notes' hybrid transport section. The
v1.0.0 and v1.0.1 fragments are left alone.

The notes say that v1.1.0 contains every change in v1.0.1. That holds
once 1.x.x is merged into 1.1.0 after v1.0.1 ships; the short "Changes
in v1.0.1" section then gains a link to the v1.0.1 notes.

Refs #222

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* net: say how the load-shedding threshold was set

The comment on DEFAULT_PQ_SHED_THRESHOLD_PER_S said that the release
gate's flood measurement (#222, R3) would set its final value. R3 was
settled with CPU benchmarks of the handshake instead, and the threshold
stays at 1,000 offers per second, as the v1.1.0 release notes say. Say
so, so the comment no longer points at a change that is not coming.

Refs #222

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* doc: cite the new fuzz seeds in the v1.1.0 notes

#255 merged into 1.1.0 after the notes were drafted. It adds generated
seeds to the required fuzz corpus for the hybrid transport's targets, so
the test section now cites it alongside the earlier seed changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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