{
 "number": 36619,
 "repo": "bitcoin/bitcoin",
 "url": "https://github.com/bitcoin/bitcoin/pull/36619",
 "title": "rest: don't log an error for /spenttxouts on a block without undo data",
 "author": "kriss39",
 "author_association": "CONTRIBUTOR",
 "created_at": "2026-10-23T09:21:11Z",
 "updated_at": "2026-10-27T15:00:42Z",
 "description_hash": "643c5505e3ca223e",
 "age_days": 9,
 "draft": false,
 "labels": [
  "RPC/REST/ZMQ"
 ],
 "milestone": null,
 "base": "master",
 "head_sha": "eebc145847b4f05da61e95fcae1b420a6ce3ea0f",
 "head_ref": "fix-rest-spenttxouts-no-undo",
 "head_repo": "kriss39/bitcoin",
 "head_history": [
  {
   "t": "2026-10-23T10:59:13Z",
   "sha": "e8af2c7488925e35ffeaf64e523cef48b70280eb"
  },
  {
   "t": "2026-10-27T12:21:40Z",
   "sha": "eebc145847b4f05da61e95fcae1b420a6ce3ea0f"
  }
 ],
 "additions": 14,
 "deletions": 2,
 "changed_files": 2,
 "commit_count": 1,
 "size_bucket": "S",
 "mergeable_state": "clean",
 "bot": {
  "drahtbot": {
   "present": true,
   "reviews": {
    "ack": [
     {
      "login": "maflcko",
      "url": "https://github.com/bitcoin/bitcoin/pull/36619#issuecomment-6443682061"
     },
     {
      "login": "stickies-v",
      "url": "https://github.com/bitcoin/bitcoin/pull/36619#issuecomment-6445394644"
     }
    ]
   },
   "conflicts": []
  }
 },
 "acks_parsed": {
  "stickies-v": {
   "kind": "ack",
   "hash": "eebc145847b4f05da61e95fcae1b420a6ce3ea0f",
   "t": "2026-10-27T15:00:37Z",
   "stale": false
  }
 },
 "acks_tally": {
  "ack": 1,
  "stale_ack": 0,
  "concept_ack": 0,
  "approach_ack": 0,
  "nack": 0,
  "concept_nack": 0,
  "approach_nack": 0
 },
 "reviews": {
  "approved": 1,
  "changes_requested": 0,
  "distinct_reviewers": [
   "maflcko",
   "stickies-v"
  ]
 },
 "signals": {
  "needs_rebase": false,
  "ci_failed": false,
  "mergeable_state": "clean",
  "last_author_activity": "2026-10-27T12:22:43Z",
  "last_reviewer_activity": "2026-10-27T15:00:37Z",
  "last_reviewer": "stickies-v",
  "author_silent_days": 5,
  "waiting_on_author_days": 5,
  "days_since_update": 5
 },
 "refs": {
  "mentioned": [],
  "depends_on": [],
  "fixes": [],
  "linked_issues": [],
  "references": [],
  "conflicts": []
 },
 "stack": {
  "shares_commits_with": [],
  "based_on": [],
  "base_for": []
 },
 "review_paths": [
  "src/rest.cpp"
 ],
 "body": "`/rest/spenttxouts/<hash>` reads the undo file for every block above genesis. For a block that was stored but never connected (a side branch) or whose undo data was pruned, there is no undo position, so `OpenUndoFile()` fails and `ReadBlockUndo()` writes `OpenUndoFile failed for FlatFilePos(nFile=-1, nPos=0)` to debug.log with `LogError`. The request itself already returns 404, but each unauthenticated request for such a block adds an `[error]` line that looks like disk corruption.\n\nThis checks `CheckBlockDataAvailability()` for `BLOCK_HAVE_UNDO` before reading, so nothing is logged. Pruning clears `BLOCK_HAVE_UNDO`, so pruned blocks are covered too. The response is unchanged.\n\nThe new check at the end of `interface_rest.py` requests a stale block and fails on master because of the logged error.",
 "commits": [
  {
   "sha": "eebc145847b4f05da61e95fcae1b420a6ce3ea0f",
   "date": "2026-10-27T12:17:54Z",
   "message": "rest: don't log an error for /spenttxouts on a block without undo data\n\n`/rest/spenttxouts/<hash>` calls `ReadBlockUndo()` for every block above\ngenesis. For a block that was stored but never connected (a side branch)\nor whose undo data was pruned, `GetUndoPos()` is null, so\n`OpenUndoFile()` fails and `ReadBlockUndo()` writes \"OpenUndoFile failed\nfor FlatFilePos(nFile=-1, nPos=0)\" to debug.log with `LogError`. The\nendpoint then correctly answers 404, but every unauthenticated request\nfor such a block adds an `[error]` line that looks like disk corruption.\n\nCheck `BLOCK_HAVE_UNDO` first and only read the undo file when it can\nexist. Pruning clears `BLOCK_HAVE_UNDO`, so this covers pruned blocks\ntoo. The response is unchanged.\n\nThe new interface_rest.py check requests a side-branch block and fails\non master because of the logged error."
  }
 ],
 "timeline": [
  {
   "t": "2026-10-23T10:13:13Z",
   "kind": "review_comment",
   "who": "stickies-v",
   "assoc": "MEMBER",
   "path": "src/rest.cpp",
   "commit": "be3c1db50f66926b4f7cebfae91665cd0a950995",
   "in_reply_to": null,
   "text": "I think the `&& !chainman->m_blockman.IsBlockPruned(*pblockindex)` check here is redundant?",
   "id": "rc:4358444111",
   "url": "https://github.com/bitcoin/bitcoin/pull/36619#discussion_r4358444111",
   "hash": "ddcc024f7e6391d6",
   "edited": "2026-10-23T10:17:01Z"
  },
  {
   "t": "2026-10-23T10:17:01Z",
   "kind": "review",
   "who": "stickies-v",
   "assoc": "MEMBER",
   "state": "COMMENTED",
   "commit": "be3c1db50f66926b4f7cebfae91665cd0a950995",
   "text": "Approach ACK",
   "id": "r:5626851079",
   "url": "https://github.com/bitcoin/bitcoin/pull/36619#pullrequestreview-5626851079",
   "hash": "66f1e8680fcf3d24",
   "edited": null
  },
  {
   "t": "2026-10-23T10:39:42Z",
   "kind": "review_comment",
   "who": "maflcko",
   "assoc": "MEMBER",
   "path": "src/rest.cpp",
   "commit": "be3c1db50f66926b4f7cebfae91665cd0a950995",
   "in_reply_to": 4358444111,
   "text": "Can this use `CheckBlockDataAvailability` to avoid duplicating the impl?",
   "id": "rc:4358648834",
   "url": "https://github.com/bitcoin/bitcoin/pull/36619#discussion_r4358648834",
   "hash": "5782412d048e7954",
   "edited": null
  },
  {
   "t": "2026-10-23T10:59:13Z",
   "kind": "force_push",
   "who": "kriss39",
   "commit": "e8af2c7488925e35ffeaf64e523cef48b70280eb",
   "id": "push:e8af2c7488925e35ffeaf64e523cef48b70280eb"
  },
  {
   "t": "2026-10-23T10:59:26Z",
   "kind": "review_comment",
   "who": "kriss39",
   "assoc": "CONTRIBUTOR",
   "path": "src/rest.cpp",
   "commit": "be3c1db50f66926b4f7cebfae91665cd0a950995",
   "in_reply_to": 4358444111,
   "text": "Thanks, both right. `PruneOneBlockFile()` clears `BLOCK_HAVE_UNDO`, so the `IsBlockPruned()` check added nothing. It now uses `CheckBlockDataAvailability(*pblockindex, *pblockindex, BlockStatus{BLOCK_HAVE_UNDO})`, in e8af2c7488925e35ffeaf64e523cef48b70280eb.",
   "id": "rc:4358800508",
   "url": "https://github.com/bitcoin/bitcoin/pull/36619#discussion_r4358800508",
   "hash": "1d7d08927df32902",
   "edited": null
  },
  {
   "t": "2026-10-23T11:13:17Z",
   "kind": "review_comment",
   "who": "maflcko",
   "assoc": "MEMBER",
   "path": "src/rest.cpp",
   "commit": "e8af2c7488925e35ffeaf64e523cef48b70280eb",
   "in_reply_to": null,
   "text": "heh, that's funny. I was talking about `src/rpc/blockchain.h:void CheckBlockDataAvailability(node::BlockManager& blockman, const CBlockIndex& blockindex, bool check_for_undo) EXCLUSIVE_LOCKS_REQUIRED(::cs_main);`, but I guess this works as well.\n\nedit: I was thinking about `CheckBlockDataAvailability` from the rpc, to have more accurate error messages, but maybe that is not too important for the rest interface.",
   "id": "rc:4358908499",
   "url": "https://github.com/bitcoin/bitcoin/pull/36619#discussion_r4358908499",
   "hash": "b914882d5317faeb",
   "edited": "2026-10-23T12:14:38Z"
  },
  {
   "t": "2026-10-23T11:13:24Z",
   "kind": "review",
   "who": "maflcko",
   "assoc": "MEMBER",
   "state": "APPROVED",
   "commit": "e8af2c7488925e35ffeaf64e523cef48b70280eb",
   "text": "lgtm ACK e8af2c7488925e35ffeaf64e523cef48b70280eb",
   "id": "r:5627442260",
   "url": "https://github.com/bitcoin/bitcoin/pull/36619#pullrequestreview-5627442260",
   "hash": "28b549aba619ce04",
   "edited": "2026-10-23T14:56:36Z"
  },
  {
   "t": "2026-10-23T11:33:06Z",
   "kind": "review_comment",
   "who": "stickies-v",
   "assoc": "MEMBER",
   "path": "src/rest.cpp",
   "commit": "be3c1db50f66926b4f7cebfae91665cd0a950995",
   "in_reply_to": 4358444111,
   "text": "I think a simple `pblockindex->nStatus & BLOCK_HAVE_UNDO` is more straightforward tbh but either way works.",
   "id": "rc:4359063293",
   "url": "https://github.com/bitcoin/bitcoin/pull/36619#discussion_r4359063293",
   "hash": "cd10cbb93447c008",
   "edited": "2026-10-23T11:33:07Z"
  },
  {
   "t": "2026-10-23T11:33:22Z",
   "kind": "comment",
   "who": "stickies-v",
   "assoc": "MEMBER",
   "text": "ACK e8af2c7488925e35ffeaf64e523cef48b70280eb",
   "id": "c:6363921935",
   "url": "https://github.com/bitcoin/bitcoin/pull/36619#issuecomment-6363921935",
   "hash": "2c42a20892fb8920",
   "edited": null
  },
  {
   "t": "2026-10-23T14:56:21Z",
   "kind": "review_comment",
   "who": "maflcko",
   "assoc": "MEMBER",
   "path": "src/rest.cpp",
   "commit": "be3c1db50f66926b4f7cebfae91665cd0a950995",
   "in_reply_to": 4358444111,
   "text": "yeah, i was thinking that the rpc `CheckBlockDataAvailability` would provide better error messages, but if they are not used, a plain `nStatus & BLOCK_HAVE_UNDO` seems fine.",
   "id": "rc:4360912651",
   "url": "https://github.com/bitcoin/bitcoin/pull/36619#discussion_r4360912651",
   "hash": "5de8d9a8548e9c79",
   "edited": "2026-10-23T14:56:22Z"
  },
  {
   "t": "2026-10-27T11:56:33Z",
   "kind": "review_comment",
   "who": "maflcko",
   "assoc": "MEMBER",
   "path": "src/rest.cpp",
   "commit": "be3c1db50f66926b4f7cebfae91665cd0a950995",
   "in_reply_to": 4358444111,
   "text": "@kriss39 Can you address the nit? I think both reviewers would be happy to re-ack a `nStatus & BLOCK_HAVE_UNDO`",
   "id": "rc:4388370425",
   "url": "https://github.com/bitcoin/bitcoin/pull/36619#discussion_r4388370425",
   "hash": "999ca302b8301efc",
   "edited": null
  },
  {
   "t": "2026-10-27T12:21:40Z",
   "kind": "force_push",
   "who": "kriss39",
   "commit": "eebc145847b4f05da61e95fcae1b420a6ce3ea0f",
   "id": "push:eebc145847b4f05da61e95fcae1b420a6ce3ea0f"
  },
  {
   "t": "2026-10-27T12:22:43Z",
   "kind": "review_comment",
   "who": "kriss39",
   "assoc": "CONTRIBUTOR",
   "path": "src/rest.cpp",
   "commit": "be3c1db50f66926b4f7cebfae91665cd0a950995",
   "in_reply_to": 4358444111,
   "text": "Done, switched to a plain `nStatus & BLOCK_HAVE_UNDO` in eebc145847b4f05da61e95fcae1b420a6ce3ea0f.",
   "id": "rc:4388601219",
   "url": "https://github.com/bitcoin/bitcoin/pull/36619#discussion_r4388601219",
   "hash": "0e66bd8f27912337",
   "edited": null
  },
  {
   "t": "2026-10-27T13:54:08Z",
   "kind": "comment",
   "who": "maflcko",
   "assoc": "MEMBER",
   "text": "review ACK eebc145847b4f05da61e95fcae1b420a6ce3ea0f \ud83d\udee0\n\nShow signature\n\nSignature:\n\n```\nuntrusted comment: signature from minisign secret key on empty file; verify via: minisign -Vm \"${path_to_any_empty_file}\" -P RWTRmVTMeKV5noAMqVlsMugDDCyyTSbA3Re5AkUrhvLVln0tSaFWglOw -x \"${path_to_this_whole_four_line_signature_blob}\"\nRUTRmVTMeKV5npGrKx1nqXCw5zeVHdtdYURB/KlyA/LMFgpNCs+SkW9a8N95d+U4AP1RJMi+krxU1A3Yux4bpwZNLvVBKy0wLgM=\ntrusted comment: review ACK eebc145847b4f05da61e95fcae1b420a6ce3ea0f \ud83d\udee0\nyo6CqrBQUYQJcnbpnkRphcLtq07ySn/lKcrM2Wdeyl1eP6uBy0nsbiggPPNrSEGDfyrHwX4GqMgczZx401+sBQ==\n```",
   "id": "c:6443682061",
   "url": "https://github.com/bitcoin/bitcoin/pull/36619#issuecomment-6443682061",
   "hash": "dc0fc33d4476077c",
   "edited": null
  },
  {
   "t": "2026-10-27T15:00:37Z",
   "kind": "comment",
   "who": "stickies-v",
   "assoc": "MEMBER",
   "text": "re-ACK eebc145847b4f05da61e95fcae1b420a6ce3ea0f",
   "id": "c:6445394644",
   "url": "https://github.com/bitcoin/bitcoin/pull/36619#issuecomment-6445394644",
   "hash": "c4656e1bf7e35694",
   "edited": null
  }
 ],
 "labels_log": [
  {
   "t": "2026-10-23T09:21:16Z",
   "action": "labeled",
   "label": "RPC/REST/ZMQ",
   "who": "DrahtBot"
  }
 ],
 "state_log": [],
 "text_chars": 3798,
 "text_tokens_estimate": 949,
 "changed_paths": [
  "src/rest.cpp",
  "test/functional/interface_rest.py"
 ],
 "files": [
  {
   "path": "src/rest.cpp",
   "add": 6,
   "del": 2
  },
  {
   "path": "test/functional/interface_rest.py",
   "add": 8,
   "del": 0
  }
 ],
 "test_lines": 8,
 "git": {
  "head": "eebc145847b4f05da61e95fcae1b420a6ce3ea0f",
  "head_matches_backup": true,
  "base": "152a55397e451fed9c10041bddf01aa6839847d5",
  "patch_id": "8b62bc616f30000a",
  "commits": [
   {
    "sha": "eebc145847",
    "subject": "rest: don't log an error for /spenttxouts on a block without undo data",
    "files": 2,
    "add": 14,
    "del": 2
   }
  ],
  "patch_truncated": false
 },
 "patch_id": "8b62bc616f30000a",
 "input_hash": "a4fad58bcf38ab05",
 "extracted_at": "2026-11-02T01:09:49+00:00"
}