Skip to content

p2p: Clean up signaling error types, doctests#2202

Open
iostat wants to merge 3 commits intoio/p2p-remove-legacy-multiaddrfrom
io/p2p-cleaner-errors
Open

p2p: Clean up signaling error types, doctests#2202
iostat wants to merge 3 commits intoio/p2p-remove-legacy-multiaddrfrom
io/p2p-cleaner-errors

Conversation

@iostat
Copy link
Copy Markdown
Contributor

@iostat iostat commented Mar 26, 2026

(stacked PRs: this is 3 of 3, merge #2200 then #2201 before this)

Description

Improve error types across WebRTC connection signaling:

  • Add OfferDecryptErrorKind enum to distinguish decryption failure from
    identity key mismatch, with a warning log for potential relay tampering.
  • Add AnswerNotProvided variant to P2pConnectionErrorResponse (previously
    mapped to the generic InternalError).
  • Fix all broken doc tests in the webrtc module (connection_auth,
    signaling_method/http, signaling_method/mod) by replacing pseudocode
    snippets with compilable examples.

Related Issue(s)

Closes #2193

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • Refactoring (no functional changes)

Testing

  • cargo test --doc -p mina-p2p passes (previously broken).
  • Existing unit tests pass.

Changelog Entry

Fixed: P2P: Improved error types for WebRTC connection signaling and fixed broken doc tests in the webrtc module (#2202)

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 26, 2026

✓ Code Reference Verification Passed

All code references in the documentation have been verified successfully!

Total references checked: 1
Valid references: 1

The documentation is in sync with the codebase on the develop branch.

@iostat iostat force-pushed the io/p2p-cleaner-errors branch from 36f9071 to 8727166 Compare March 26, 2026 20:59
@iostat iostat force-pushed the io/p2p-remove-legacy-multiaddr branch from 0dc9c49 to cf771bd Compare March 26, 2026 21:23
@iostat iostat force-pushed the io/p2p-cleaner-errors branch from 8727166 to c18a737 Compare March 26, 2026 21:28
//
// We deliberately respond with SignalDecryptionFailed
// rather than a specific mismatch error to avoid leaking
// information to a potential attacker.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

There should probably be some kind of log here, right?

@iostat iostat linked an issue Mar 30, 2026 that may be closed by this pull request
@iostat iostat force-pushed the io/p2p-remove-legacy-multiaddr branch 2 times, most recently from 8636532 to ce8ce87 Compare March 31, 2026 15:22
@iostat iostat force-pushed the io/p2p-cleaner-errors branch from c18a737 to a0366ff Compare March 31, 2026 15:22
@iostat iostat force-pushed the io/p2p-remove-legacy-multiaddr branch from ce8ce87 to 9ed333e Compare March 31, 2026 16:40
iostat added 3 commits March 31, 2026 12:41
(#2193)

Add AnswerNotProvided variant to P2pConnectionErrorResponse
to distinguish empty relay answers from generic internal
errors in the discovery signaling path.

Add OfferDecryptErrorKind enum to distinguish actual
decryption failures from identity key mismatches in the
exchange signaling path. Key mismatches now log a security
warning while still responding with SignalDecryptionFailed
to avoid leaking information to potential attackers.
Fix 11 doc tests that never compiled: wrong crate name
(mina:: -> mina_p2p::), missing imports, undefined
variables, and missing error handling wrappers. All doc
tests are now self-contained and pass.
@iostat iostat force-pushed the io/p2p-cleaner-errors branch from a0366ff to d7eb1e5 Compare March 31, 2026 16:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

p2p: Improve error types

2 participants