{
 "number": 36548,
 "input_hash": "57f527c80a7fa395",
 "model": "ledger",
 "prompt_hash": null,
 "created": "2026-11-02T01:11:22+00:00",
 "result": {
  "summary": "Optimizes serving disk-backed `MSG_BLOCK` P2P requests by stripping witness data directly from serialized block buffers in place instead of decoding into `CBlock` and reserializing. It refactors transaction deserialization to share `UnserializeTransactionBody` between standard decoding and witness skipping, verifying proof-of-work and block hash before stripping. Signet requests continue to use `ReadBlock` to preserve its block solution check.",
  "problem": "Serving witness-stripped blocks to legacy nodes or future witnessless sync clients decodes full blocks and transactions into heap allocations and recomputes transaction hashes, only to discard witness fields during reserialization. This introduces significant CPU and memory overhead compared to `MSG_WITNESS_BLOCK`, which is streamed directly from disk.",
  "card": "Serves disk-backed MSG_BLOCK peer requests by reading raw block bytes and stripping witness data in place rather than fully deserializing and reserializing transactions. This eliminates unnecessary object allocations and transaction rehashing when serving legacy peers or clients syncing without witnesses. Benchmarks report an 8.9x to 9.3x speedup when preparing witness-free block payloads from disk. The optimization also unblocks efficient block serving for proposed witnessless assumevalid IBD (#36476).",
  "evidence": [
   "PR description benchmarks show reading and serializing a non-witness message drops from 1.31 ms to 0.147 ms (8.9x speedup) for block 413567 and from 3.47 ms to 0.374 ms (9.3x speedup) for the same block with synthetic witness data",
   "Enables fast non-witness block serving needed by proposed witnessless assumevalid IBD in issue #36476"
  ],
  "scope_notes": "Touches transaction deserialization primitives in `src/primitives/transaction.h` by extracting common parsing logic into `UnserializeTransactionBody`, and introduces in-place buffer manipulation using `std::memmove` in `StripBlockWitness`.",
  "changed_since_previous": "No structural changes; the implementation continues to use in-place buffer stripping and shared transaction parsing rules with minor rebasing or test adjustments.",
  "thread": {
   "last_event_at": "2026-11-01T18:25:24Z",
   "events": 2,
   "head_sha": "d36943b49ce321cd622a8ae5a885227c7b3189cf",
   "schema_floor": 2,
   "schema": 2
  },
  "waiting_on": [
   {
    "at": null,
    "id": "",
    "on": "nothing",
    "url": null,
    "what": "nothing pending; waiting for further review"
   }
  ],
  "risk": {
   "level": "medium",
   "touches": [
    "p2p",
    "validation"
   ],
   "why": "A parsing or memory offset bug in in-place witness stripping could corrupt block messages sent to peers, causing peer disconnections or potential memory safety violations."
  },
  "discussion": {
   "author_status": "last statement processed 2026-11-01",
   "open_concerns": [],
   "resolved_concerns": []
  },
  "reviewability": {
   "state": "Ready",
   "label": "Ready",
   "reason": "Nothing known that would invalidate a review now."
  },
  "agreement": {
   "state": "Strong",
   "summary": "Strong: substantive support, no open objection (fametrano, fametrano)",
   "reason": "Added fametrano's updated tACK review on rebase.",
   "evidence": [
    "fametrano: Tested ACK \u2014 verified byte-for-byte equivalence of MSG_BLOCK output on 214 blocks, tested mutants against blockmanager_tests, and confirmed 7.2x-9.0x speedups and heap reduction",
    "fametrano: Tested ACK \u2014 re-ran byte-for-byte check on rebased head against 263 regtest blocks with extreme witness stacks and annexes, verified P2P MSG_BLOCK and MSG_WITNESS_BLOCK serialization, and confirmed test suite passes"
   ],
   "objections": [],
   "support": [
    {
     "reviewer": "fametrano",
     "reason": "verified byte-for-byte equivalence of MSG_BLOCK output on 214 blocks, tested mutants against blockmanager_tests, and confirmed 7.2x-9.0x speedups and heap reduction",
     "substantive": true,
     "verdict": "Tested ACK",
     "id": "c:6397181019",
     "url": "https://github.com/bitcoin/bitcoin/pull/36548#issuecomment-6397181019",
     "at": "2026-10-25",
     "association": "NONE",
     "evidence": "both",
     "areas": [
      "blockmanager_tests"
     ]
    },
    {
     "reviewer": "fametrano",
     "reason": "re-ran byte-for-byte check on rebased head against 263 regtest blocks with extreme witness stacks and annexes, verified P2P MSG_BLOCK and MSG_WITNESS_BLOCK serialization, and confirmed test suite passes",
     "substantive": true,
     "verdict": "Tested ACK",
     "id": "r:5729574972",
     "url": "https://github.com/bitcoin/bitcoin/pull/36548#pullrequestreview-5729574972",
     "at": "2026-11-01",
     "association": "NONE",
     "evidence": "both",
     "areas": [
      "ReadBlockWithoutWitness",
      "blockmanager_tests",
      "p2p_getdata",
      "p2p_segwit",
      "p2p_compactblocks"
     ]
    }
   ],
   "participants": [
    {
     "login": "fametrano",
     "stance": "support",
     "note": "tested ACK after re-testing byte-for-byte equivalence and functional tests on rebase",
     "association": "NONE",
     "comments": 2,
     "first": "2026-10-25",
     "last": "2026-11-01"
    }
   ],
   "derivation": "substantive support, no open objection (fametrano, fametrano)",
   "model_state": null,
   "corrections": [],
   "notes": "Added fametrano's updated tACK review on rebase."
  },
  "dependencies": {
   "depends_on": [],
   "enables": [
    "#36476"
   ]
  },
  "categories": [
   {
    "name": "p2p",
    "member": true,
    "evidence": "Carries the P2P label and modifies block serving logic in `src/net_processing.cpp` for `MSG_BLOCK` requests.",
    "band": "P3",
    "reason_tag": "speedup",
    "score": 0.4,
    "factors": {
     "bug_severity": 0,
     "leverage": 1,
     "performance": 2,
     "security_stability": 1,
     "user_value": 1
    },
    "rationale": "Optimizes serving non-witness `MSG_BLOCK` requests by stripping witnesses in-place from serialized buffers, achieving an 8.9x\u20139.3x speedup and reducing heap allocations in benchmarks. While legacy `MSG_BLOCK` traffic is currently minor, this mitigates resource overhead when serving blocks and unblocks proposed witnessless IBD (#36476)."
   },
   {
    "name": "tests",
    "member": false,
    "evidence": "Changes to `src/bench/readwriteblock.cpp` and `src/test/fuzz/block.cpp` are specific to block serialization benchmarking and fuzzing rather than test framework infrastructure.",
    "band": "Unranked",
    "reason_tag": "test coverage",
    "score": 0.0,
    "factors": {
     "bug_severity": 0,
     "leverage": 1,
     "performance": 2,
     "security_stability": 1,
     "user_value": 1
    },
    "rationale": "The PR adds fuzzing and benchmarks for the new in-place witness stripping logic, but does not alter general test framework machinery."
   },
   {
    "name": "validation",
    "member": false,
    "evidence": "Touches `src/node/blockstorage.cpp` and `src/primitives/transaction.h` only to extract deserialization helpers and strip witnesses for network serving.",
    "band": "Unranked",
    "reason_tag": "speedup",
    "score": 0.0,
    "factors": {
     "bug_severity": 0,
     "leverage": 1,
     "performance": 2,
     "security_stability": 1,
     "user_value": 1
    },
    "rationale": "The PR does not substantively alter validation rules, block verification, or chainstate management, restricting its changes to block reading for peer delivery."
   }
  ],
  "confidence": "high",
  "uncertainties": [],
  "needs": []
 },
 "cost_usd": 0.0,
 "source": {
  "record": "2026-11-02T01:11:22+00:00",
  "code": "2026-11-02T01:15:06+00:00",
  "judgments": 3
 }
}