Skip to content

Define and differentially verify the Bitcoin Core-compatible RPC, REST, and ZMQ contract #78

Description

@gosunuts

Problem

The project exposes a useful Bitcoin Core-shaped interface:

  • synchronous HTTP JSON-RPC with Core method names;
  • a deliberately small REST gateway for remote validators;
  • ZMQ hash/raw topics and pubsequence block connect/disconnect notifications;
  • Core-style configuration and getzmqnotifications metadata.

The implementation has handler smoke tests, selected response-schema tests, REST edge-case tests, and ZMQ transport/wiring tests. Those are a solid foundation but do not define a complete supported API contract or establish drop-in compatibility with Bitcoin Core.

Current gaps include:

Goal

Publish and enforce a narrow, explicit, versioned Bitcoin Core compatibility contract for RPC, REST, and ZMQ. Every claimed supported surface must be verified against a pinned Bitcoin Core reference through deterministic fixtures and differential tests. Unsupported and intentionally partial surfaces must fail or report capability status predictably.

This issue does not require implementing every Core API method.

Scope

1. Freeze the compatibility target and surface manifest

  • Pin the Bitcoin Core major/minor release used for each compatibility claim.
  • Add a machine-readable manifest for every exposed RPC, REST route, and ZMQ topic:
    • supported;
    • supported with documented deviations;
    • disabled by product policy;
    • not implemented.
  • State parameter forms, prerequisites, required indexes, pruning behavior, auth policy, and readiness behavior.
  • Generate or validate human API reference material from the manifest.

2. JSON-RPC differential harness

For each supported method, compare bitcoin-rs and the pinned Core reference using deterministic regtest and fixture chains.

Cover:

  • success JSON shape, types, optional fields, ordering where wire-visible, and numeric semantics;
  • positional and named parameters where applicable;
  • invalid params, unknown objects, pruned/missing data, disabled index, and auth failures;
  • RPC error code and stable error-category/message behavior;
  • batch, notification, malformed JSON, HTTP status, content type, and keep-alive behavior;
  • state transitions: initial sync, caught-up, reorg, index building/stale, pruning, and shutdown.

Do not normalize meaningful incompatibilities away. Record an explicit deviation only after it is reviewed.

3. REST contract and tests

  • Keep the REST surface intentionally small unless a concrete consumer needs expansion.
  • Differentially verify implemented chaininfo/header semantics, status codes, content types, binary/hex encoding, malformed values, side branches, header-only ranges, and disabled REST behavior.
  • Document that REST is unauthenticated and define safe listener/exposure guidance.
  • Add any enforcer-specific fixture necessary to prove the expected discovery and rescan behavior.

4. ZMQ contract and tests

5. Capability/readiness reporting

Expose enough status for clients to distinguish:

  • node applied tip versus header tip;
  • txindex/filter index absent, building, caught-up, failed, or stale;
  • pruning/body availability;
  • ZMQ configured topics/endpoints;
  • feature-disabled methods.

Avoid pretending a partial index or partial node state is complete Core-equivalent data.

Acceptance criteria

  • A pinned Core version and a machine-readable supported/deviation/disabled/not-implemented manifest exist.
  • Every method/route/topic advertised as supported has a deterministic differential test or a documented fixture-based reason it cannot be compared.
  • JSON-RPC happy path, invalid parameters, method-not-found, auth, malformed request, batch, and HTTP framing are covered.
  • Result schemas and semantic values are compared, not merely method names or selected key sets.
  • REST endpoint/status/encoding behavior is tested for the complete documented subset.
  • ZMQ frame layout, endianness, sequence behavior, C/D ordering, and configured-topic discovery are tested.
  • Mempool A/R pubsequence parity remains explicitly unavailable until Complete BIP300/301 enforcer integration with mempool A/R pubsequence events #74 is complete.
  • ZMQ delivery failure cannot affect apply/consensus, and event-loss recovery points to Architectural boundary: durable chain events and independent derived-state consumers #77's durable source.
  • Wallet methods without private-key support remain explicitly disabled with stable errors rather than partial imitation.
  • API docs describe prerequisites and incomplete-index/pruning/readiness behavior.
  • CI executes the portable deterministic compatibility suite; live Core integration runs are documented and reproducible.

Related issues

Non-goals

  • Implementing every Bitcoin Core RPC or REST endpoint.
  • Adding private-key wallet management.
  • Treating a Core method name as proof of behavioral compatibility.
  • Making ZMQ a durable queue or a consensus dependency.
  • Blocking default full-node work on optional API products.

Metadata

Metadata

Assignees

No one assigned

    Labels

    wayfinder:taskPrerequisite task for a decision

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions