Merge bitcoin/bitcoin#35044: contrib: Fix NameError in signet miner gbt()

701bc2dc02 contrib: Fix NameError in signet miner gbt() (Torkel Rogstad)

Pull request description:

  The logging.warning call referenced `bci["bestblockhash"]`, a variable from the calling scope `do_generate()` that is not available inside the `Generate.gbt()` method. This would crash with a NameError when getblocktemplate returned a template based on an unexpected previous block.

  Use the `bestblockhash` parameter that was already being passed in and used correctly in the comparison on the line above.

  The bug was introduced in 7b31332370 when the gbt logic was extracted into its own method — the if-condition was updated but the logging call was not.

ACKs for top commit:
  kevkevinpal:
    ACK [701bc2d](701bc2dc02)
  sedited:
    ACK 701bc2dc02

Tree-SHA512: 53764db954dd40b68d2f92279fd609732402fdbac4a1838aeee81d366b2b7fbc8da86b07f6f05cee62cb8ecdc514f6e0af1e59c65380eec38cbeaa58ec3c10ed
This commit is contained in:
merge-script
2026-05-13 12:34:20 +02:00

View File

@@ -333,7 +333,7 @@ class Generate:
def gbt(self, bcli, bestblockhash, now):
tmpl = json.loads(bcli("getblocktemplate", '{"rules":["signet","segwit"]}'))
if tmpl["previousblockhash"] != bestblockhash:
logging.warning("GBT based off unexpected block (%s not %s), retrying", tmpl["previousblockhash"], bci["bestblockhash"])
logging.warning("GBT based off unexpected block (%s not %s), retrying", tmpl["previousblockhash"], bestblockhash)
time.sleep(1)
return None