Skip to content

p2p: implement BIP434 peer feature negotiation #1634

Closed

Description

@gosunuts

Goal

Implement BIP434 Peer Feature Negotiation in crates/p2p so bitcoin-rs can negotiate independent P2P extensions with compatible peers. Bitcoin Core implements BIP434 (PR #35221); BIP332 depends on it.

Implementation

  • Raise the advertised P2P protocol version to 70017 when BIP434 is supported, preserving normal compatibility with older peers.
  • Add the feature message codec: featureid length 4–80, featuredata length ≤512, minimal CompactSize encoding, exact payload consumption, and bounded parsing. Support the BIP324 v2 short message ID 37 for pre-verack messages.
  • Send and accept feature announcements after version and before verack, within the existing handshake FSM and peer capability state. Never send them to peers advertising a protocol version below 70017.
  • Ignore well-formed unknown feature IDs. Make enabled features available to existing peer dispatch/relay logic without introducing an independent handshake/peer-state owner.
  • Keep existing BIP339 wtxidrelay, BIP155 sendaddrv2, BIP324 transport, and older-peer fallback working.

Acceptance criteria

  • Exchange BIP434 feature announcements with a Core implementation supporting BIP434; verify v1 and v2 transports.
  • Cover supported/unsupported feature IDs, bounds, malformed/trailing bytes, duplicate announcements, version gating, and pre-/post-verack ordering.
  • Verify normal 70016 and older-peer sessions establish without negotiation or disconnects.
  • Update crates/p2p/src/compat.rs and docs/policies/p2p-compatibility.md with the precise version/message change.

Related

  • BIP332 Stale Tip Relay requires BIP434.
  • Current P2P code advertises 70016 in crates/p2p/src/wire.rs and has no typed feature message.
  • This is a P2P-only extension; block validity and chain selection are unchanged.

Activity

  1. gosunuts commented on Oct 28, 2026

    @gosunuts
    MemberAuthor

    Closing the implementation issue: the BIP434 feature-message codec, protocol-version/handshake integration, v1/v2 transport handling, version-gated announcements, and malformed/legacy-peer regression coverage are present on main (see the merged protocol stack, #1697, and crates/p2p/src/feature.rs, handshake.rs, fsm.rs).

    Live interoperability with a BIP434-capable Bitcoin Core build and further external qualification have not been claimed or measured here. Those are follow-up qualification activities, not a reason to keep the implemented feature request indefinitely open. Reopen or file a focused issue if a concrete interoperability failure is reproduced. Closing as completed for the implementation scope.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions