{
 "number": 36357,
 "input_hash": "bcc8c0d9a0eb0ae1",
 "model": "ledger",
 "prompt_hash": null,
 "created": "2026-09-29T01:26:31+00:00",
 "result": {
  "summary": "Moves process-wide block template statistics from BlockAssembler into per-instance fields, recording them in BlockTemplateManager under cs_main. The getmininginfo RPC is updated to read currentblockweight and currentblocktx from BlockTemplateManager rather than process-wide statics.",
  "problem": "getmininginfo reads global static variables that lack thread-safety annotations and are overwritten by any call to BlockAssembler::CreateNewBlock(). Background operations like mempool fee estimation build templates with BlockAssembler, causing getmininginfo to report fee estimation templates instead of actual mining templates, while also hindering multi-node context isolation.",
  "card": "Moves process-wide block statistics from BlockAssembler into instance variables and stores mining stats in BlockTemplateManager under cs_main. Currently, getmininginfo reads unannotated global statics that are overwritten by any template build across the process, including non-mining templates generated by the mempool fee estimator. With this change, getmininginfo reports metrics solely from templates built for mining, and template state is cleanly scoped to each node context. Based on PR #36356.",
  "evidence": [
   "PR description: \"getmininginfo reports currentblockweight and currentblocktx from two process-wide statics, BlockAssembler::m_last_block_weight and m_last_block_num_txs, which every BlockAssembler::CreateNewBlock() call overwrites... the mempool fee estimator builds its own templates with BlockAssembler, so getmininginfo can report the fee estimator's template instead of the last mining template.\"",
   "Commit e47e7acca3: \"Behavior change: only templates built through BlockTemplateManager (getblocktemplate, the generate RPCs and the mining interface) update these fields. Templates that the mempool fee estimator builds with BlockAssembler directly no longer do...\"",
   "Issue #33758: completes the 'Remove remaining global states' item in the BlockTemplateManager tracking issue."
  ],
  "scope_notes": "Stacked on PR #36356; the diff includes commits from #36356 that move getblocktemplate caching into BlockTemplateManager.",
  "changed_since_previous": "",
  "thread": {
   "last_event_at": "2026-09-28T09:05:55Z",
   "events": 1,
   "head_sha": "e47e7acca377da1edb45616a6c0e3d9233841900",
   "schema_floor": 2,
   "schema": 2
  },
  "waiting_on": [
   {
    "at": "2026-09-28",
    "id": "c:5866835254",
    "on": "author",
    "url": "https://github.com/bitcoin/bitcoin/pull/36357#issuecomment-5866835254",
    "what": "response to ismaelsadeeq's suggestion to move the block template cache into BlockTemplateManager"
   },
   {
    "at": "2026-09-28",
    "id": "c:5866835254",
    "on": "author",
    "url": "https://github.com/bitcoin/bitcoin/pull/36357#issuecomment-5866835254",
    "what": "response to ismaelsadeeq's suggestion about caching in BlockTemplateManager"
   }
  ],
  "risk": {
   "level": "medium",
   "touches": [
    "rpc_api",
    "other"
   ],
   "why": "Holding cs_main across template creation or mishandling template cache state could introduce locking contention or report inaccurate mining statistics in RPC responses."
  },
  "discussion": {
   "author_status": "last statement processed 2026-09-28",
   "open_concerns": [
    "ismaelsadeeq: Move the block template cache into BlockTemplateManager to consolidate caching and reduce fee estimator dependencies"
   ],
   "resolved_concerns": []
  },
  "reviewability": {
   "state": "Paused",
   "label": "Waiting on author",
   "reason": "Open objection from ismaelsadeeq with no author reply for 34 days; review would repeat what has been asked."
  },
  "agreement": {
   "state": "Strong",
   "summary": "Strong: substantive support, no open objection (ismaelsadeeq)",
   "reason": "Initial record. ismaelsadeeq gave Concept ACK and suggested moving the template cache into BlockTemplateManager. / Initial record. ismaelsadeeq gave a Concept ACK and suggested extending the scope to include block template caching.",
   "evidence": [
    "ismaelsadeeq (suggestion, scope, must be answered, open): Move the block template cache into BlockTemplateManager to consolidate caching and reduce fee estimator dependencies",
    "ismaelsadeeq: Concept ACK \u2014 moving cache into BlockTemplateManager consolidates template caching and reduces fee estimator reliance on chainstate manager"
   ],
   "objections": [
    {
     "reviewer": "ismaelsadeeq",
     "association": "MEMBER",
     "type": "suggestion",
     "kind": "scope",
     "harm": "",
     "request": "Move the block template cache into BlockTemplateManager to consolidate caching and reduce fee estimator dependencies",
     "question": "",
     "text": "Move the block template cache into BlockTemplateManager to consolidate caching and reduce fee estimator dependencies",
     "clears_with": "answer",
     "blocking": false,
     "status": "open",
     "status_note": "",
     "cleared": false,
     "author_replied": false,
     "others_replied": false,
     "fix_pushed": false,
     "replies": [],
     "evidence": "2026-09-28: 'Now that #34075 is merged, we can also move its cache in there, i.e cache the block template based on time and tip changes.'",
     "url": "https://github.com/bitcoin/bitcoin/pull/36357#issuecomment-5866835254",
     "id": "c:5866835254",
     "at": "2026-09-28",
     "status_at": null,
     "status_by": null,
     "resolution_evidence": "",
     "pin": null,
     "from_schema": 2
    }
   ],
   "support": [
    {
     "reviewer": "ismaelsadeeq",
     "reason": "moving cache into BlockTemplateManager consolidates template caching and reduces fee estimator reliance on chainstate manager",
     "substantive": true,
     "verdict": "Concept ACK",
     "id": "c:5866835254",
     "url": "https://github.com/bitcoin/bitcoin/pull/36357#issuecomment-5866835254",
     "at": "2026-09-28",
     "association": "MEMBER",
     "evidence": "read",
     "areas": [
      "BlockTemplateManager"
     ]
    }
   ],
   "participants": [
    {
     "login": "ismaelsadeeq",
     "stance": "support",
     "note": "Concept ACK; suggests moving the #34075 block template cache into BlockTemplateManager",
     "association": "MEMBER",
     "comments": 1,
     "first": "2026-09-28",
     "last": "2026-09-28"
    }
   ],
   "derivation": "substantive support, no open objection (ismaelsadeeq)",
   "model_state": null,
   "corrections": [],
   "notes": "Initial record. ismaelsadeeq gave Concept ACK and suggested moving the template cache into BlockTemplateManager. / Initial record. ismaelsadeeq gave a Concept ACK and suggested extending the scope to include block template caching."
  },
  "dependencies": {
   "depends_on": [
    "#36356"
   ],
   "enables": []
  },
  "categories": [
   {
    "name": "mining",
    "member": true,
    "evidence": "Carries the Mining label and modifies src/node/miner.h, src/node/block_template_manager.{h,cpp}, and src/rpc/mining.cpp to manage block template metrics.",
    "band": "P3",
    "reason_tag": "bug fix",
    "score": 0.4,
    "factors": {
     "bug_severity": 1,
     "leverage": 1,
     "performance": 0,
     "security_stability": 1,
     "user_value": 1
    },
    "rationale": "Fixes inaccurate mining statistics reporting in getmininginfo and eliminates thread-unsafe global state. As noted in the description, 'the mempool fee estimator builds its own templates with BlockAssembler, so getmininginfo can report the fee estimator's template instead of the last mining template,' and moving these fields to BlockTemplateManager resolves this cross-subsystem contamination while progressing issue #33758."
   },
   {
    "name": "rpc",
    "member": false,
    "evidence": "Changes src/rpc/mining.cpp only to point getmininginfo to BlockTemplateManager instead of process-wide statics without changing RPC interfaces or handling.",
    "band": "Unranked",
    "reason_tag": "cleanup",
    "score": 0.0,
    "factors": {
     "bug_severity": 1,
     "leverage": 1,
     "performance": 0,
     "security_stability": 1,
     "user_value": 1
    },
    "rationale": "The change alters underlying mining state retrieval rather than RPC mechanics or wire protocols, which belongs strictly to mining per the rule that the behavior an RPC merely exposes belongs to its area."
   }
  ],
  "confidence": "high",
  "uncertainties": [],
  "needs": []
 },
 "cost_usd": 0.0,
 "source": {
  "record": "2026-09-29T01:26:31+00:00",
  "code": "2026-09-29T01:32:04+00:00",
  "judgments": 2
 }
}