Skip to content

Review finding: photon relays only a small fraction of native-lane blocks, because it identifies blocks by the leading 64 bits of their hash #388

Closed

Description

@kiwidream

Summary

qbit-photon identifies a block by the leading 64 bits of its hash. For native-lane (non-AuxPoW) blocks, those bits are bounded by the proof-of-work target and take only a handful of values. Most native-lane blocks are therefore treated as already known and are not relayed.

Severity: high (functional). Blocks still propagate over normal P2P, so this costs PHOTON's latency benefit for native-lane blocks, not correctness. Found in a 2026-11-09 review of 1.x.x d647580885; the PHOTON code is unchanged since v1.0.0.

Observed

Confidence: high from code and from a replay of mainnet block hashes. There is no end-to-end harness run against live relays.

  • Identifier. HashPrefixFromHex (contrib/photon/src/relay_engine.cpp:70-86) packs the first 16 display-hex characters, which are the most significant 64 bits of the hash. The hash comes from ZMQ hashblock in display order (contrib/photon/src/app.cpp:374-381).

  • Proof of work. Native-lane proof of work is checked on the block hash itself (src/auxpow_validation.cpp:157), so its high bits are bounded by the target. At the current native-lane nBits (0x19027c8e) the prefix can only be 0, 1 or 2. AuxPoW-lane block hashes are unconstrained, because their proof of work is on the parent.

  • Seen set. The seen set holds 16 prefixes (relay_engine.h:27). A known prefix is dropped without refreshing it, in three places:

    • outbound, relay_engine.cpp:162-168;
    • inbound header and chunk, :203-213 and :291-301.

    Entries leave the set only when 16 newer, distinct prefixes are inserted (:396-424), and in practice only AuxPoW-lane blocks supply new prefixes.

  • Replay. Replaying the mainnet chain's block hashes through this logic:

    • 74 of the last 1,595 native-lane blocks would be relayed;
    • all AuxPoW-lane blocks would be relayed;
    • native-lane prefixes in the last 20,000 blocks took only 7 distinct values.

Impact

Miners and pools that rely on PHOTON for low-latency propagation of native-lane blocks get it for only about 5% of those blocks. The known counter rises, but nothing reports the drop as a fault.

Suggested fix

  • Identify blocks by bits that proof of work does not constrain, such as the least significant 64 bits of the hash. Alternatively, carry the full 32-byte hash in the header packet and derive the chunk identifier from unconstrained bits.
  • Tests:
    • a relay-engine test with consecutive hashes that share the leading 64 bits but differ in the low bits, both relayed;
    • a replay test over a recorded sequence of mainnet hashes, every block relayed exactly once.

Related: #381 (per-peer limits and checks before submission) does not change the identifier scheme.

Activity

  1. added
    bug
    on Nov 11, 2026
  2. kiwidream commented on Nov 12, 2026

    @kiwidream
    MemberAuthor

    Fixed on 1.x.x by #410 (a811585271), which ships in v1.0.1: qbit-photon now identifies a block by the low-order 64 bits of its hash (BlockIdFromHex), which proof of work does not constrain, and still recognizes the leading-bits form that earlier versions announce. Tests in contrib/photon/test/relay_engine_tests.cpp: blocks_sharing_leading_hash_bits_all_relayed and mainnet_hash_sequence_relayed_without_suppression.

    Closing by hand, because a merge into 1.x.x does not close issues automatically.

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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions