mining: add getInfo() IPC method #35712

pull Sjors wants to merge 1 commits into bitcoin:master from Sjors:2026/07/mining-info changing 7 files +70 −0
  1. Sjors commented at 2:06 PM on July 13, 2026: member

    This lets IPC clients fetch information relevant to the next block, without having to generate a template.

    Similar to the getmininginfo RPC, but with a minimal set of fields based on known needs for the Stratum v2 Job Declarator Server Role^0, including minTime and time which the RPC doesn't provide. Can easily be expanded later for other use cases.

    It echos the tip so clients can check for race conditions, e.g. when they call getInfo() immediately after waitTipChanged().

    Based on discussion in https://github.com/stratum-mining/sv2-apps/issues/268. Two alternative solutions to that issue:

    1. add min_time to the getmininginfo RPC
    2. call createNewBlock(mempool: false) followed by getBlockHeader() on the empty block to get nBits, but for minTime you need getblocktemplate (which returns a full block)
  2. mining: add getInfo()
    This lets IPC clients fetch information relevant to the next block,
    without having to generate a template.
    
    Similar to the getmininginfo RPC, but with a minimal set of fields
    based on known needs for the Stratum v2 Job Declarator Server Role,
    including minTime and time which the RPC doesn't provide.
    
    It echos the tip so clients can check for race conditions if e.g.
    they call getInfo() immediately after waitTipChanged().
    d3798cb4f0
  3. DrahtBot added the label Mining on Jul 13, 2026
  4. DrahtBot commented at 2:06 PM on July 13, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--006a51241073e994b41acfe9ec718e94-->

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/35712.

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline and AI policy for information on the review process.

    Type Reviewers
    ACK w0xlt

    If your review is incorrectly listed, please copy-paste <code>&lt;!--meta-tag:bot-skip--&gt;</code> into the comment that the bot should ignore.

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #35675 (mining: add block template manager by ismaelsadeeq)
    • #35671 (mining: add TxCollection to bandwidth-efficiently validate external block templates by Sjors)
    • #35581 (node: add block template manager and track waitNext fee inflow by ismaelsadeeq)
    • #33922 (mining: add getMemoryLoad() and track template non-mempool memory footprint by Sjors)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  5. w0xlt commented at 7:09 AM on July 14, 2026: contributor

    Concept ACK

  6. w0xlt commented at 8:18 PM on July 14, 2026: contributor

    ACK d3798cb4f024a0c702c4040126580734a48528d4

  7. in test/functional/interface_ipc_mining.py:153 in d3798cb4f0
     148 | +            assert ipc_info.hasResult
     149 | +            assert_equal(ipc_info.result.tip.height + 1, rpc_info["next"]["height"])
     150 | +            assert_equal(bytes(ipc_info.result.tip.hash)[::-1].hex(), block_template["previousblockhash"])
     151 | +            assert_equal(nbits_str(ipc_info.result.bits), rpc_info["next"]["bits"])
     152 | +            assert_equal(ipc_info.result.minTime, block_template["mintime"])
     153 | +            assert_equal(ipc_info.result.time, block_template["curtime"])
    


    w0xlt commented at 9:03 PM on July 14, 2026:

    nit:

    diff --git a/test/functional/interface_ipc_mining.py b/test/functional/interface_ipc_mining.py
    index 73b17650de..1abb54a106 100755
    --- a/test/functional/interface_ipc_mining.py
    +++ b/test/functional/interface_ipc_mining.py
    @@ -151,6 +151,13 @@ class IPCMiningTest(BitcoinTestFramework):
                 assert_equal(nbits_str(ipc_info.result.bits), rpc_info["next"]["bits"])
                 assert_equal(ipc_info.result.minTime, block_template["mintime"])
                 assert_equal(ipc_info.result.time, block_template["curtime"])
    +
    +            min_time = ipc_info.result.minTime
    +            self.nodes[0].setmocktime(min_time - 1)
    +            ipc_info = await mining.getInfo(ctx)
    +            assert ipc_info.hasResult
    +            assert_equal(ipc_info.result.minTime, min_time)
    +            assert_equal(ipc_info.result.time, min_time)
                 self.nodes[0].setmocktime(0)
     
                 self.log.debug("Mine a block")
    
  8. Sjors commented at 8:38 AM on July 15, 2026: member

    Marking this as draft pending conceptual re-evaluation in https://github.com/stratum-mining/sv2-apps/issues/268#issuecomment-4978598647.

    It looks like JDS might not need this. In that case I will close this and we can revisit if some other application actually needs it.

  9. Sjors marked this as a draft on Jul 15, 2026
  10. Sjors commented at 11:45 AM on July 18, 2026: member

    @plebhash wrote in https://github.com/stratum-mining/sv2-apps/issues/268#issuecomment-5007778446:

    TLDR: SRI doesn't need bitcoin/bitcoin#35712

    for v32x, we can populate ChainTipState with waitTipChanged() + getblockheader RPC

    Closing this so we can focus on higher priority issues.

  11. Sjors closed this on Jul 18, 2026

Contributors
Labels

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-07-22 06:50 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me