Skip to content

rpc: getchainlockbyheight help doesn't say the best ChainLock and skipped heights can't be returned #7872

Closed

Description

@thephez

getchainlockbyheight only returns ChainLocks that a later block has embedded in its coinbase (CbTx). Its help only says "Read a historical ChainLock from coinbases on disk", so it's easy to expect any ChainLocked height to work, including the current best ChainLock from getbestchainlock. Two cases return Chainlock not found for height and the help mentions neither.

Expected behavior

Either the help explains which heights can be returned, or the RPC returns the requested ChainLock.

Actual behavior

  • Current best ChainLock: getbestchainlock usually reports a ChainLock that no block has embedded yet, often at the tip height. CoinbaseChainLockReader::Find returns nothing when the requested height is at or above the tip (src/chainlock/clsig.cpp:216), so getchainlockbyheight <best CL height> fails until a later block carries that ChainLock.
  • Skipped heights: a coinbase stores the best ChainLock known at the time, and ChainLock heights can jump. If the first coinbase that reaches the requested height carries a ChainLock for a higher height, the lookup returns nothing (src/chainlock/clsig.cpp:245). A skipped height always returns "not found".

Both are reasonable for a coinbase-backed lookup, but the help gives no hint. Suggested addition to the help:

Only ChainLocks that have been embedded in a later block's coinbase can be returned; the current best ChainLock and any heights skipped by coinbase ChainLocks return "Chainlock not found for height".

To reproduce

Reproducible every time on a synced testnet node:

  1. dash-cli -testnet getbestchainlock and note height (usually the tip height).
  2. dash-cli -testnet getchainlockbyheight <that height> returns error code: -5 / Chainlock not found for height.
  3. After another block is mined that carries that ChainLock in its CbTx, the same call succeeds, with cbtx_height showing the carrier block.

System information

Dash Core v24.0.0-rc.3 (help text and source at 0364ed626e). Observed on testnet with a self-compiled dash-qt built from v24.0.0-rc.2-118-g2fb1e393. getchainlockbyheight and CoinbaseChainLockReader are unchanged between that build and rc.3.

Activity

  1. thephez commented on Oct 13, 2026

    @thephez
    CollaboratorAuthor

    @thepastaclaw can you take this?

  2. thepastaclaw commented on Oct 13, 2026

    @thepastaclaw
    Collaborator

    @thephez on it — I have handed this to an agent and will link a PR here.

  3. thepastaclaw commented on Oct 13, 2026

    @thepastaclaw
    Collaborator

    Opened #7875. The help now explains the later-coinbase requirement, best-ChainLock availability, skipped heights, and the exact not-found error, with a pointer to getbestchainlock. Lookup behavior is unchanged because an in-memory fallback would not have the cbtx_height promised by this RPC. Added the required short release note; whitespace/format-string lint and compilation of the changed RPC translation unit passed.

  4. added 3 commits that reference this issue on Oct 14, 2026
    09174e0
    d60b248
    dc1a6b2
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