Merge bitcoin/bitcoin#33965: mining: fix -blockreservedweight shadows IPC option
b623fab1bamining: enforce minimum reserved weight for IPC (Sjors Provoost)d3e49528d4mining: fix -blockreservedweight shadows IPC option (Sjors Provoost)418b7995ddtest: have mining template helpers return None (Sjors Provoost) Pull request description: Also enforce `MINIMUM_BLOCK_RESERVED_WEIGHT` for IPC clients. The `-blockreservedweight` startup option should only affect RPC code, because IPC clients (currently) do not have a way to signal their intent to use the node default (the `BlockCreateOptions` struct defaults merely document a recommendation for client software). Before this PR however, if the user set `-blockreservedweight` then `ApplyArgsManOptions` would cause the `block_reserved_weight` option passed by IPC clients to be ignored. _Users who don't set this value were not affected._ Fix this by making BlockCreateOptions::block_reserved_weight an std::optional. Internal interface users, such as the RPC call sites, don't set a value so -blockreservedweight is used. Whereas IPC clients do set a value which is no longer ignored. Test coverage is added, with a preliminary commit that refactors the `create_block_template` and `wait_next_template` helpers. `mining_basic.py` already ensured `-blockreservedweight` is enforced by mining RPC methods. The second commit adds coverage for Mining interface IPC clients. It also verifies that `-blockreservedweight` has no effect on them. The third commit enforces `MINIMUM_BLOCK_RESERVED_WEIGHT` for IPC clients. Previously lower values were quietly clamped. --- Merge order preference: #34452 should ideally go first. ACKs for top commit: sedited: Re-ACKb623fab1baryanofsky: Code review ACKb623fab1ba. Was rebased and test split up and comment updated since last review. ismaelsadeeq: ACKb623fab1baTree-SHA512: 9e651a520d8e4aeadb330da86788744b6ecad8060fa21d50dc8e6012a60083e7b262aaa08a64676b9ef18ba65b651bc1272d8383d184030342e4c0f2c6a9866d
This commit is contained in:
6 files changed
+87
-15
No files matched your search
@@ -108,12 +108,18 @@ async def make_capnp_init_ctx(self):
|
||||
|
||||
async def mining_create_block_template(mining, stack, ctx, opts):
|
||||
"""Call mining.createNewBlock() and return template, then call template.destroy() when stack exits."""
|
||||
return await stack.enter_async_context(destroying((await mining.createNewBlock(opts)).result, ctx))
|
||||
response = await mining.createNewBlock(opts)
|
||||
if not response._has("result"):
|
||||
return None
|
||||
return await stack.enter_async_context(destroying(response.result, ctx))
|
||||
|
||||
|
||||
async def mining_wait_next_template(template, stack, ctx, opts):
|
||||
"""Call template.waitNext() and return template, then call template.destroy() when stack exits."""
|
||||
return await stack.enter_async_context(destroying((await template.waitNext(ctx, opts)).result, ctx))
|
||||
response = await template.waitNext(ctx, opts)
|
||||
if not response._has("result"):
|
||||
return None
|
||||
return await stack.enter_async_context(destroying(response.result, ctx))
|
||||
|
||||
|
||||
async def mining_get_block(block_template, ctx):
|
||||
|
||||
Reference in new issue
Block a user