Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

contrib/signet/miner: increase miner search space #30130

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

edilmedeiros
Copy link
Contributor

@edilmedeiros edilmedeiros commented May 17, 2024

The miner script will call bitcoin-util grind to compute PoW which will try to exhaust the block's nonce field and fail if it can't find a valid hash. This behavior does not appear for low difficulty chains, but make the miner unusable for higher difficulty settings.

We capture bitcoin-util grind failure, build a new block header by changing the block time and try to grind again.

Fixes #30102.

How this was tested

This is a follow-up from #30091 and #30102.

I've started a new signet chain with --nbits=1d008d28 (which accounts for 600 seconds difficulty per the calibrate command) and the first block's date 30 days in the past and let the miner run as fast as it can. Starting from block 10080 (after 5 difficulty adjustment periods) the miner will occasionally fail with a Could not satisfy difficulty target message.

There's a functional test for the miner, but this fix requires a high difficulty chain to be observable (after block 10080 on my machine). A functional test would take many hours to run if there's no mechanism of loading a pre-mined chain (with at least 10080 blocks), so I did not try to include one in this PR.

Below is a mining session in which blocks 10097 to 10101 were mined in the first try of bitcoin-util grind and block 10102 required one retry (debug info at time 2024-05-17 12:56:01). The session was interrupted with SIGINT (Ctrl-C) after mining block 10102 (during mining of block 10103).

Debug messages from mining session
$BTC_PATH/../contrib/signet/miner --debug --cli "$BTC_PATH/bitcoin-cli -datadir=$DATADIR_PATH" generate --address $MINER_ADDR --grind-cmd "$BTC_PATH/bitcoin-util grind" --nbits $NBITS --ongoing
2024-05-17 12:44:30 DEBUG Calling bitcoin-cli: ['/Users/jose.edil/2-development/bitcoin/bitcoin-core/src/bitcoin-cli', '-datadir=/Users/jose.edil/2-development/bitcoin/signet-mining-experiments/signet-fix-hashing', '-signet', 'getblockchaininfo']
2024-05-17 12:44:30 DEBUG Calling bitcoin-cli: ['/Users/jose.edil/2-development/bitcoin/bitcoin-core/src/bitcoin-cli', '-datadir=/Users/jose.edil/2-development/bitcoin/signet-mining-experiments/signet-fix-hashing', '-signet', 'getblockheader', '00000001403650dc3f806132c32ab17e8087e01a620ae685d1e3b469ed629ab9']
2024-05-17 12:44:30 DEBUG Calling bitcoin-cli: ['/Users/jose.edil/2-development/bitcoin/bitcoin-core/src/bitcoin-cli', '-datadir=/Users/jose.edil/2-development/bitcoin/signet-mining-experiments/signet-fix-hashing', '-signet', 'getblocktemplate', '{"rules":["signet","segwit"]}']
2024-05-17 12:44:30 DEBUG GBT template: {'capabilities': ['proposal'], 'version': 536870912, 'rules': ['csv', '!segwit', '!signet', 'taproot'], 'vbavailable': {}, 'vbrequired': 0, 'previousblockhash': '00000001403650dc3f806132c32ab17e8087e01a620ae685d1e3b469ed629ab9', 'transactions': [], 'coinbaseaux': {}, 'coinbasevalue': 5000000000, 'longpollid': '00000001403650dc3f806132c32ab17e8087e01a620ae685d1e3b469ed629ab918', 'target': '0000000377ac0000000000000000000000000000000000000000000000000000', 'mintime': 1714546817, 'mutable': ['time', 'transactions', 'prevblock'], 'noncerange': '00000000ffffffff', 'sigoplimit': 80000, 'sizelimit': 4000000, 'weightlimit': 4000000, 'curtime': 1715960670, 'bits': '1d0377ac', 'height': 10097, 'signet_challenge': '0014f64c3c86285a5a14521fc05fd7e599a13f953350', 'default_witness_commitment': '6a24aa21a9ede2f61c3f71d1defd3fa999dfa36953755c690689799962b48bebd836974e8cf9'}
2024-05-17 12:44:30 DEBUG Calling bitcoin-cli: ['/Users/jose.edil/2-development/bitcoin/bitcoin-core/src/bitcoin-cli', '-datadir=/Users/jose.edil/2-development/bitcoin/signet-mining-experiments/signet-fix-hashing', '-signet', 'getaddressinfo', 'tb1qylfujt900rjxzfxjj7sktpu7dpm2n9j60ch7jt']
2024-05-17 12:44:30 DEBUG Mining block delta=2m30s start=1714547717 mine=True
2024-05-17 12:44:30 DEBUG Calling bitcoin-cli: ['/Users/jose.edil/2-development/bitcoin/bitcoin-core/src/bitcoin-cli', '-datadir=/Users/jose.edil/2-development/bitcoin/signet-mining-experiments/signet-fix-hashing', '-signet', '-stdin', 'walletprocesspsbt']
2024-05-17 12:44:30 DEBUG grinding headhex: 00000020b99a62ed69b4e3d185e60a621ae087807eb12ac33261803fdc503640010000003defccce7c49fc8e5d49e5fdfac5179424caa643d93dd2fce318737a73acbd3c05ec3166ac77031d00000000
2024-05-17 12:44:59 DEBUG Calling bitcoin-cli: ['/Users/jose.edil/2-development/bitcoin/bitcoin-core/src/bitcoin-cli', '-datadir=/Users/jose.edil/2-development/bitcoin/signet-mining-experiments/signet-fix-hashing', '-signet', '-stdin', 'submitblock']
2024-05-17 12:44:59 DEBUG Block hash 000000027f40f8a9ea5af6aecd5c3040365e5647c76c0a51bf3972f683d4921a payout to tb1qylfujt900rjxzfxjj7sktpu7dpm2n9j60ch7jt
2024-05-17 12:44:59 INFO Mined block at height 10097; next in -392h27m12s (mine)
2024-05-17 12:44:59 DEBUG Calling bitcoin-cli: ['/Users/jose.edil/2-development/bitcoin/bitcoin-core/src/bitcoin-cli', '-datadir=/Users/jose.edil/2-development/bitcoin/signet-mining-experiments/signet-fix-hashing', '-signet', 'getblockchaininfo']
2024-05-17 12:44:59 DEBUG Calling bitcoin-cli: ['/Users/jose.edil/2-development/bitcoin/bitcoin-core/src/bitcoin-cli', '-datadir=/Users/jose.edil/2-development/bitcoin/signet-mining-experiments/signet-fix-hashing', '-signet', 'getblockheader', '000000027f40f8a9ea5af6aecd5c3040365e5647c76c0a51bf3972f683d4921a']
2024-05-17 12:44:59 DEBUG Calling bitcoin-cli: ['/Users/jose.edil/2-development/bitcoin/bitcoin-core/src/bitcoin-cli', '-datadir=/Users/jose.edil/2-development/bitcoin/signet-mining-experiments/signet-fix-hashing', '-signet', 'getblocktemplate', '{"rules":["signet","segwit"]}']
2024-05-17 12:44:59 DEBUG GBT template: {'capabilities': ['proposal'], 'version': 536870912, 'rules': ['csv', '!segwit', '!signet', 'taproot'], 'vbavailable': {}, 'vbrequired': 0, 'previousblockhash': '000000027f40f8a9ea5af6aecd5c3040365e5647c76c0a51bf3972f683d4921a', 'transactions': [], 'coinbaseaux': {}, 'coinbasevalue': 5000000000, 'longpollid': '000000027f40f8a9ea5af6aecd5c3040365e5647c76c0a51bf3972f683d4921a19', 'target': '0000000377ac0000000000000000000000000000000000000000000000000000', 'mintime': 1714546967, 'mutable': ['time', 'transactions', 'prevblock'], 'noncerange': '00000000ffffffff', 'sigoplimit': 80000, 'sizelimit': 4000000, 'weightlimit': 4000000, 'curtime': 1715960699, 'bits': '1d0377ac', 'height': 10098, 'signet_challenge': '0014f64c3c86285a5a14521fc05fd7e599a13f953350', 'default_witness_commitment': '6a24aa21a9ede2f61c3f71d1defd3fa999dfa36953755c690689799962b48bebd836974e8cf9'}
2024-05-17 12:44:59 DEBUG Mining block delta=2m30s start=1714547867 mine=True
2024-05-17 12:44:59 DEBUG Calling bitcoin-cli: ['/Users/jose.edil/2-development/bitcoin/bitcoin-core/src/bitcoin-cli', '-datadir=/Users/jose.edil/2-development/bitcoin/signet-mining-experiments/signet-fix-hashing', '-signet', '-stdin', 'walletprocesspsbt']
2024-05-17 12:44:59 DEBUG grinding headhex: 000000201a92d483f67239bf510a6cc747565e3640305ccdaef65aeaa9f8407f02000000fded29d2c7f696e68ab1412404ce7216faac9f9132d70d345fe055c2a4bd9fd39bec3166ac77031d00000000
2024-05-17 12:45:04 DEBUG Calling bitcoin-cli: ['/Users/jose.edil/2-development/bitcoin/bitcoin-core/src/bitcoin-cli', '-datadir=/Users/jose.edil/2-development/bitcoin/signet-mining-experiments/signet-fix-hashing', '-signet', '-stdin', 'submitblock']
2024-05-17 12:45:04 DEBUG Block hash 000000028b973069c60568f304b09095fe601ee1dd2b9c56ebd9846247f0cd90 payout to tb1qylfujt900rjxzfxjj7sktpu7dpm2n9j60ch7jt
2024-05-17 12:45:04 INFO Mined block at height 10098; next in -392h24m47s (mine)
2024-05-17 12:45:04 DEBUG Calling bitcoin-cli: ['/Users/jose.edil/2-development/bitcoin/bitcoin-core/src/bitcoin-cli', '-datadir=/Users/jose.edil/2-development/bitcoin/signet-mining-experiments/signet-fix-hashing', '-signet', 'getblockchaininfo']
2024-05-17 12:45:04 DEBUG Calling bitcoin-cli: ['/Users/jose.edil/2-development/bitcoin/bitcoin-core/src/bitcoin-cli', '-datadir=/Users/jose.edil/2-development/bitcoin/signet-mining-experiments/signet-fix-hashing', '-signet', 'getblockheader', '000000028b973069c60568f304b09095fe601ee1dd2b9c56ebd9846247f0cd90']
2024-05-17 12:45:04 DEBUG Calling bitcoin-cli: ['/Users/jose.edil/2-development/bitcoin/bitcoin-core/src/bitcoin-cli', '-datadir=/Users/jose.edil/2-development/bitcoin/signet-mining-experiments/signet-fix-hashing', '-signet', 'getblocktemplate', '{"rules":["signet","segwit"]}']
2024-05-17 12:45:04 DEBUG GBT template: {'capabilities': ['proposal'], 'version': 536870912, 'rules': ['csv', '!segwit', '!signet', 'taproot'], 'vbavailable': {}, 'vbrequired': 0, 'previousblockhash': '000000028b973069c60568f304b09095fe601ee1dd2b9c56ebd9846247f0cd90', 'transactions': [], 'coinbaseaux': {}, 'coinbasevalue': 5000000000, 'longpollid': '000000028b973069c60568f304b09095fe601ee1dd2b9c56ebd9846247f0cd9020', 'target': '0000000377ac0000000000000000000000000000000000000000000000000000', 'mintime': 1714547117, 'mutable': ['time', 'transactions', 'prevblock'], 'noncerange': '00000000ffffffff', 'sigoplimit': 80000, 'sizelimit': 4000000, 'weightlimit': 4000000, 'curtime': 1715960704, 'bits': '1d0377ac', 'height': 10099, 'signet_challenge': '0014f64c3c86285a5a14521fc05fd7e599a13f953350', 'default_witness_commitment': '6a24aa21a9ede2f61c3f71d1defd3fa999dfa36953755c690689799962b48bebd836974e8cf9'}
2024-05-17 12:45:04 DEBUG Mining block delta=2m30s start=1714548017 mine=True
2024-05-17 12:45:04 DEBUG Calling bitcoin-cli: ['/Users/jose.edil/2-development/bitcoin/bitcoin-core/src/bitcoin-cli', '-datadir=/Users/jose.edil/2-development/bitcoin/signet-mining-experiments/signet-fix-hashing', '-signet', '-stdin', 'walletprocesspsbt']
2024-05-17 12:45:04 DEBUG grinding headhex: 0000002090cdf0476284d9eb569c2bdde11e60fe9590b004f36805c66930978b02000000e42cc72231e1dc1e9159b6e61f64ccd496b53e30b9f9a210016790a19c5b937331ed3166ac77031d00000000
2024-05-17 12:48:29 DEBUG Calling bitcoin-cli: ['/Users/jose.edil/2-development/bitcoin/bitcoin-core/src/bitcoin-cli', '-datadir=/Users/jose.edil/2-development/bitcoin/signet-mining-experiments/signet-fix-hashing', '-signet', '-stdin', 'submitblock']
2024-05-17 12:48:29 DEBUG Block hash 00000001b4e230b77edd93e706fb579aab0e8eefff0bc39f19bd671fb88d9e31 payout to tb1qylfujt900rjxzfxjj7sktpu7dpm2n9j60ch7jt
2024-05-17 12:48:29 INFO Mined block at height 10099; next in -392h25m42s (mine)
2024-05-17 12:48:29 DEBUG Calling bitcoin-cli: ['/Users/jose.edil/2-development/bitcoin/bitcoin-core/src/bitcoin-cli', '-datadir=/Users/jose.edil/2-development/bitcoin/signet-mining-experiments/signet-fix-hashing', '-signet', 'getblockchaininfo']
2024-05-17 12:48:29 DEBUG Calling bitcoin-cli: ['/Users/jose.edil/2-development/bitcoin/bitcoin-core/src/bitcoin-cli', '-datadir=/Users/jose.edil/2-development/bitcoin/signet-mining-experiments/signet-fix-hashing', '-signet', 'getblockheader', '00000001b4e230b77edd93e706fb579aab0e8eefff0bc39f19bd671fb88d9e31']
2024-05-17 12:48:29 DEBUG Calling bitcoin-cli: ['/Users/jose.edil/2-development/bitcoin/bitcoin-core/src/bitcoin-cli', '-datadir=/Users/jose.edil/2-development/bitcoin/signet-mining-experiments/signet-fix-hashing', '-signet', 'getblocktemplate', '{"rules":["signet","segwit"]}']
2024-05-17 12:48:29 DEBUG GBT template: {'capabilities': ['proposal'], 'version': 536870912, 'rules': ['csv', '!segwit', '!signet', 'taproot'], 'vbavailable': {}, 'vbrequired': 0, 'previousblockhash': '00000001b4e230b77edd93e706fb579aab0e8eefff0bc39f19bd671fb88d9e31', 'transactions': [], 'coinbaseaux': {}, 'coinbasevalue': 5000000000, 'longpollid': '00000001b4e230b77edd93e706fb579aab0e8eefff0bc39f19bd671fb88d9e3121', 'target': '0000000377ac0000000000000000000000000000000000000000000000000000', 'mintime': 1714547267, 'mutable': ['time', 'transactions', 'prevblock'], 'noncerange': '00000000ffffffff', 'sigoplimit': 80000, 'sizelimit': 4000000, 'weightlimit': 4000000, 'curtime': 1715960909, 'bits': '1d0377ac', 'height': 10100, 'signet_challenge': '0014f64c3c86285a5a14521fc05fd7e599a13f953350', 'default_witness_commitment': '6a24aa21a9ede2f61c3f71d1defd3fa999dfa36953755c690689799962b48bebd836974e8cf9'}
2024-05-17 12:48:29 DEBUG Mining block delta=2m30s start=1714548167 mine=True
2024-05-17 12:48:29 DEBUG Calling bitcoin-cli: ['/Users/jose.edil/2-development/bitcoin/bitcoin-core/src/bitcoin-cli', '-datadir=/Users/jose.edil/2-development/bitcoin/signet-mining-experiments/signet-fix-hashing', '-signet', '-stdin', 'walletprocesspsbt']
2024-05-17 12:48:29 DEBUG grinding headhex: 00000020319e8db81f67bd199fc30bffef8e0eab9a57fb06e793dd7eb730e2b4010000000fcbbe2ca7f16269b8c7c348a2756b158312ad7745f496ef7de244e626e905fbc7ed3166ac77031d00000000
2024-05-17 12:49:58 DEBUG Calling bitcoin-cli: ['/Users/jose.edil/2-development/bitcoin/bitcoin-core/src/bitcoin-cli', '-datadir=/Users/jose.edil/2-development/bitcoin/signet-mining-experiments/signet-fix-hashing', '-signet', '-stdin', 'submitblock']
2024-05-17 12:49:58 DEBUG Block hash 00000002e3dd1d7dca6438c609a665362d45b2123cb5e86160492f91d2e711ea payout to tb1qylfujt900rjxzfxjj7sktpu7dpm2n9j60ch7jt
2024-05-17 12:49:58 INFO Mined block at height 10100; next in -392h24m41s (mine)
2024-05-17 12:49:58 DEBUG Calling bitcoin-cli: ['/Users/jose.edil/2-development/bitcoin/bitcoin-core/src/bitcoin-cli', '-datadir=/Users/jose.edil/2-development/bitcoin/signet-mining-experiments/signet-fix-hashing', '-signet', 'getblockchaininfo']
2024-05-17 12:49:58 DEBUG Calling bitcoin-cli: ['/Users/jose.edil/2-development/bitcoin/bitcoin-core/src/bitcoin-cli', '-datadir=/Users/jose.edil/2-development/bitcoin/signet-mining-experiments/signet-fix-hashing', '-signet', 'getblockheader', '00000002e3dd1d7dca6438c609a665362d45b2123cb5e86160492f91d2e711ea']
2024-05-17 12:49:58 DEBUG Calling bitcoin-cli: ['/Users/jose.edil/2-development/bitcoin/bitcoin-core/src/bitcoin-cli', '-datadir=/Users/jose.edil/2-development/bitcoin/signet-mining-experiments/signet-fix-hashing', '-signet', 'getblocktemplate', '{"rules":["signet","segwit"]}']
2024-05-17 12:49:58 DEBUG GBT template: {'capabilities': ['proposal'], 'version': 536870912, 'rules': ['csv', '!segwit', '!signet', 'taproot'], 'vbavailable': {}, 'vbrequired': 0, 'previousblockhash': '00000002e3dd1d7dca6438c609a665362d45b2123cb5e86160492f91d2e711ea', 'transactions': [], 'coinbaseaux': {}, 'coinbasevalue': 5000000000, 'longpollid': '00000002e3dd1d7dca6438c609a665362d45b2123cb5e86160492f91d2e711ea22', 'target': '0000000377ac0000000000000000000000000000000000000000000000000000', 'mintime': 1714547417, 'mutable': ['time', 'transactions', 'prevblock'], 'noncerange': '00000000ffffffff', 'sigoplimit': 80000, 'sizelimit': 4000000, 'weightlimit': 4000000, 'curtime': 1715960998, 'bits': '1d0377ac', 'height': 10101, 'signet_challenge': '0014f64c3c86285a5a14521fc05fd7e599a13f953350', 'default_witness_commitment': '6a24aa21a9ede2f61c3f71d1defd3fa999dfa36953755c690689799962b48bebd836974e8cf9'}
2024-05-17 12:49:58 DEBUG Mining block delta=2m30s start=1714548317 mine=True
2024-05-17 12:49:58 DEBUG Calling bitcoin-cli: ['/Users/jose.edil/2-development/bitcoin/bitcoin-core/src/bitcoin-cli', '-datadir=/Users/jose.edil/2-development/bitcoin/signet-mining-experiments/signet-fix-hashing', '-signet', '-stdin', 'walletprocesspsbt']
2024-05-17 12:49:58 DEBUG grinding headhex: 00000020ea11e7d2912f496061e8b53c12b2452d3665a609c63864ca7d1ddde3020000003f7bc2a2b69affa45d9b1999f07a13865daf3e3d60602cb9679f2dcd0414097d5dee3166ac77031d00000000
2024-05-17 12:51:26 DEBUG Calling bitcoin-cli: ['/Users/jose.edil/2-development/bitcoin/bitcoin-core/src/bitcoin-cli', '-datadir=/Users/jose.edil/2-development/bitcoin/signet-mining-experiments/signet-fix-hashing', '-signet', '-stdin', 'submitblock']
2024-05-17 12:51:26 DEBUG Block hash 00000000188967c76f5435dea79939af5abb957b80bc352cf703e33392ba19f6 payout to tb1qylfujt900rjxzfxjj7sktpu7dpm2n9j60ch7jt
2024-05-17 12:51:26 INFO Mined block at height 10101; next in -392h23m39s (mine)
2024-05-17 12:51:26 DEBUG Calling bitcoin-cli: ['/Users/jose.edil/2-development/bitcoin/bitcoin-core/src/bitcoin-cli', '-datadir=/Users/jose.edil/2-development/bitcoin/signet-mining-experiments/signet-fix-hashing', '-signet', 'getblockchaininfo']
2024-05-17 12:51:26 DEBUG Calling bitcoin-cli: ['/Users/jose.edil/2-development/bitcoin/bitcoin-core/src/bitcoin-cli', '-datadir=/Users/jose.edil/2-development/bitcoin/signet-mining-experiments/signet-fix-hashing', '-signet', 'getblockheader', '00000000188967c76f5435dea79939af5abb957b80bc352cf703e33392ba19f6']
2024-05-17 12:51:26 DEBUG Calling bitcoin-cli: ['/Users/jose.edil/2-development/bitcoin/bitcoin-core/src/bitcoin-cli', '-datadir=/Users/jose.edil/2-development/bitcoin/signet-mining-experiments/signet-fix-hashing', '-signet', 'getblocktemplate', '{"rules":["signet","segwit"]}']
2024-05-17 12:51:26 DEBUG GBT template: {'capabilities': ['proposal'], 'version': 536870912, 'rules': ['csv', '!segwit', '!signet', 'taproot'], 'vbavailable': {}, 'vbrequired': 0, 'previousblockhash': '00000000188967c76f5435dea79939af5abb957b80bc352cf703e33392ba19f6', 'transactions': [], 'coinbaseaux': {}, 'coinbasevalue': 5000000000, 'longpollid': '00000000188967c76f5435dea79939af5abb957b80bc352cf703e33392ba19f623', 'target': '0000000377ac0000000000000000000000000000000000000000000000000000', 'mintime': 1714547568, 'mutable': ['time', 'transactions', 'prevblock'], 'noncerange': '00000000ffffffff', 'sigoplimit': 80000, 'sizelimit': 4000000, 'weightlimit': 4000000, 'curtime': 1715961086, 'bits': '1d0377ac', 'height': 10102, 'signet_challenge': '0014f64c3c86285a5a14521fc05fd7e599a13f953350', 'default_witness_commitment': '6a24aa21a9ede2f61c3f71d1defd3fa999dfa36953755c690689799962b48bebd836974e8cf9'}
2024-05-17 12:51:26 DEBUG Mining block delta=2m30s start=1714548467 mine=True
2024-05-17 12:51:26 DEBUG Calling bitcoin-cli: ['/Users/jose.edil/2-development/bitcoin/bitcoin-core/src/bitcoin-cli', '-datadir=/Users/jose.edil/2-development/bitcoin/signet-mining-experiments/signet-fix-hashing', '-signet', '-stdin', 'walletprocesspsbt']
2024-05-17 12:51:26 DEBUG grinding headhex: 00000020f619ba9233e303f72c35bc807b95bb5aaf3999a7de35546fc7678918000000003e178dfed2d76249f0808057a88fcd97569670dbe0dfab79bd2da12840691dddf3ee3166ac77031d00000000
Could not satisfy difficulty target
2024-05-17 12:56:01 DEBUG exception: Command '['/Users/jose.edil/2-development/bitcoin/bitcoin-core/src/bitcoin-util', 'grind', '00000020f619ba9233e303f72c35bc807b95bb5aaf3999a7de35546fc7678918000000003e178dfed2d76249f0808057a88fcd97569670dbe0dfab79bd2da12840691dddf3ee3166ac77031d00000000']' returned non-zero exit status 1.
2024-05-17 12:56:01 DEBUG finish_block failed, retrying
2024-05-17 12:56:01 DEBUG Calling bitcoin-cli: ['/Users/jose.edil/2-development/bitcoin/bitcoin-core/src/bitcoin-cli', '-datadir=/Users/jose.edil/2-development/bitcoin/signet-mining-experiments/signet-fix-hashing', '-signet', 'getblockchaininfo']
2024-05-17 12:56:01 DEBUG Calling bitcoin-cli: ['/Users/jose.edil/2-development/bitcoin/bitcoin-core/src/bitcoin-cli', '-datadir=/Users/jose.edil/2-development/bitcoin/signet-mining-experiments/signet-fix-hashing', '-signet', 'getblocktemplate', '{"rules":["signet","segwit"]}']
2024-05-17 12:56:01 DEBUG GBT template: {'capabilities': ['proposal'], 'version': 536870912, 'rules': ['csv', '!segwit', '!signet', 'taproot'], 'vbavailable': {}, 'vbrequired': 0, 'previousblockhash': '00000000188967c76f5435dea79939af5abb957b80bc352cf703e33392ba19f6', 'transactions': [], 'coinbaseaux': {}, 'coinbasevalue': 5000000000, 'longpollid': '00000000188967c76f5435dea79939af5abb957b80bc352cf703e33392ba19f623', 'target': '0000000377ac0000000000000000000000000000000000000000000000000000', 'mintime': 1714547568, 'mutable': ['time', 'transactions', 'prevblock'], 'noncerange': '00000000ffffffff', 'sigoplimit': 80000, 'sizelimit': 4000000, 'weightlimit': 4000000, 'curtime': 1715961361, 'bits': '1d0377ac', 'height': 10102, 'signet_challenge': '0014f64c3c86285a5a14521fc05fd7e599a13f953350', 'default_witness_commitment': '6a24aa21a9ede2f61c3f71d1defd3fa999dfa36953755c690689799962b48bebd836974e8cf9'}
2024-05-17 12:56:01 DEBUG Mining block delta=2m31s start=1714548468 mine=True
2024-05-17 12:56:01 DEBUG Calling bitcoin-cli: ['/Users/jose.edil/2-development/bitcoin/bitcoin-core/src/bitcoin-cli', '-datadir=/Users/jose.edil/2-development/bitcoin/signet-mining-experiments/signet-fix-hashing', '-signet', '-stdin', 'walletprocesspsbt']
2024-05-17 12:56:01 DEBUG grinding headhex: 00000020f619ba9233e303f72c35bc807b95bb5aaf3999a7de35546fc76789180000000068c1d0b368ed7df6cc78fe0ad4f3312bdd396bf429e28d89b91ba82deea0645cf4ee3166ac77031d00000000
2024-05-17 12:56:39 DEBUG Calling bitcoin-cli: ['/Users/jose.edil/2-development/bitcoin/bitcoin-core/src/bitcoin-cli', '-datadir=/Users/jose.edil/2-development/bitcoin/signet-mining-experiments/signet-fix-hashing', '-signet', '-stdin', 'submitblock']
2024-05-17 12:56:39 DEBUG Block hash 00000000cadb825d6cd3009dc82144d64dd604dff072c524c31c5b8cad163eda payout to tb1qylfujt900rjxzfxjj7sktpu7dpm2n9j60ch7jt
2024-05-17 12:56:39 INFO Mined block at height 10102; next in -392h26m21s (mine)
2024-05-17 12:56:39 DEBUG Calling bitcoin-cli: ['/Users/jose.edil/2-development/bitcoin/bitcoin-core/src/bitcoin-cli', '-datadir=/Users/jose.edil/2-development/bitcoin/signet-mining-experiments/signet-fix-hashing', '-signet', 'getblockchaininfo']
2024-05-17 12:56:39 DEBUG Calling bitcoin-cli: ['/Users/jose.edil/2-development/bitcoin/bitcoin-core/src/bitcoin-cli', '-datadir=/Users/jose.edil/2-development/bitcoin/signet-mining-experiments/signet-fix-hashing', '-signet', 'getblockheader', '00000000cadb825d6cd3009dc82144d64dd604dff072c524c31c5b8cad163eda']
2024-05-17 12:56:39 DEBUG Calling bitcoin-cli: ['/Users/jose.edil/2-development/bitcoin/bitcoin-core/src/bitcoin-cli', '-datadir=/Users/jose.edil/2-development/bitcoin/signet-mining-experiments/signet-fix-hashing', '-signet', 'getblocktemplate', '{"rules":["signet","segwit"]}']
2024-05-17 12:56:39 DEBUG GBT template: {'capabilities': ['proposal'], 'version': 536870912, 'rules': ['csv', '!segwit', '!signet', 'taproot'], 'vbavailable': {}, 'vbrequired': 0, 'previousblockhash': '00000000cadb825d6cd3009dc82144d64dd604dff072c524c31c5b8cad163eda', 'transactions': [], 'coinbaseaux': {}, 'coinbasevalue': 5000000000, 'longpollid': '00000000cadb825d6cd3009dc82144d64dd604dff072c524c31c5b8cad163eda24', 'target': '0000000377ac0000000000000000000000000000000000000000000000000000', 'mintime': 1714547718, 'mutable': ['time', 'transactions', 'prevblock'], 'noncerange': '00000000ffffffff', 'sigoplimit': 80000, 'sizelimit': 4000000, 'weightlimit': 4000000, 'curtime': 1715961399, 'bits': '1d0377ac', 'height': 10103, 'signet_challenge': '0014f64c3c86285a5a14521fc05fd7e599a13f953350', 'default_witness_commitment': '6a24aa21a9ede2f61c3f71d1defd3fa999dfa36953755c690689799962b48bebd836974e8cf9'}
2024-05-17 12:56:39 DEBUG Mining block delta=2m30s start=1714548618 mine=True
2024-05-17 12:56:39 DEBUG Calling bitcoin-cli: ['/Users/jose.edil/2-development/bitcoin/bitcoin-core/src/bitcoin-cli', '-datadir=/Users/jose.edil/2-development/bitcoin/signet-mining-experiments/signet-fix-hashing', '-signet', '-stdin', 'walletprocesspsbt']
2024-05-17 12:56:39 DEBUG grinding headhex: 00000020da3e16ad8c5b1cc324c572f0df04d64dd64421c89d00d36c5d82dbca00000000a3780b24488f4cb399f58b76d28c8b5a90e68fef188f81fb91e83b2a894b2bca8aef3166ac77031d00000000
^C2024-05-17 12:56:47 DEBUG mining aborted by the user
Chain info after the mining session
$BTC_PATH/bitcoin-cli -datadir=$DATADIR_PATH -signet getblockchaininfo
{
  "chain": "signet",
  "blocks": 10102,
  "headers": 10102,
  "bestblockhash": "00000000cadb825d6cd3009dc82144d64dd604dff072c524c31c5b8cad163eda",
  "difficulty": 0.2883904525532027,
  "time": 1714548468,
  "mediantime": 1714547717,
  "verificationprogress": 1,
  "initialblockdownload": true,
  "chainwork": "000000000000000000000000000000000000000000000000000000c9f2cdeb92",
  "size_on_disk": 4162114,
  "pruned": false,
  "warnings": ""
}

@DrahtBot
Copy link
Contributor

DrahtBot commented May 17, 2024

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

Code Coverage

For detailed information about the code coverage, see the test coverage report.

Reviews

See the guideline for information on the review process.

Type Reviewers
ACK AngusP

If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #29032 (signet: fixing mining for OP_TRUE challenge by Sjors)
  • #28417 (contrib/signet/miner updates by ajtowns)

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.

@edilmedeiros edilmedeiros changed the title Increase contrib/signet/miner search space contrib/signet/miner: increase miner search space May 17, 2024
@edilmedeiros
Copy link
Contributor Author

Force pushed so that the commit message is the same as the PR title.

@edilmedeiros
Copy link
Contributor Author

edilmedeiros commented May 17, 2024

A small caveat: I couldn't get rid of the Could not satisfy difficulty target message (see the debug log just before timestamp 2024-05-17 12:56:01). This is emitted by bitcoin-util itself before failing. I could not find a way to make the Python script intercept that to keep the terminal clean. I fear the complexity to achieve such an effect would not justify the benefit.

Copy link
Contributor

@AngusP AngusP left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approach ACK, one suggestion to explicitly check for the exhaustion case and a couple of nits

contrib/signet/miner Outdated Show resolved Hide resolved
contrib/signet/miner Outdated Show resolved Hide resolved
@edilmedeiros
Copy link
Contributor Author

Thanks for the review, @AngusP. Your suggestion did the trick, indeed.

Log from mining two blocks. The first exhausted the grinder search space. The second didn't.
2024-05-20 15:05:53 INFO Mined block at height 10142; next in -464h55m33s (mine)
2024-05-20 15:05:53 DEBUG Calling bitcoin-cli: ['/Users/jose.edil/2-development/bitcoin/bitcoin-core/src/bitcoin-cli', '-datadir=/Users/jose.edil/2-development/bitcoin/signet-mining-experiments/signet-fix-hashing', '-signet', 'getblockchaininfo']
2024-05-20 15:05:53 DEBUG Calling bitcoin-cli: ['/Users/jose.edil/2-development/bitcoin/bitcoin-core/src/bitcoin-cli', '-datadir=/Users/jose.edil/2-development/bitcoin/signet-mining-experiments/signet-fix-hashing', '-signet', 'getblockheader', '00000002135f8a02a04fd924c9e02901bf1682c4992988e2873450a955088f60']
2024-05-20 15:05:53 DEBUG Calling bitcoin-cli: ['/Users/jose.edil/2-development/bitcoin/bitcoin-core/src/bitcoin-cli', '-datadir=/Users/jose.edil/2-development/bitcoin/signet-mining-experiments/signet-fix-hashing', '-signet', 'getblocktemplate', '{"rules":["signet","segwit"]}']
2024-05-20 15:05:53 DEBUG GBT template: {'capabilities': ['proposal'], 'version': 536870912, 'rules': ['csv', '!segwit', '!signet', 'taproot'], 'vbavailable': {}, 'vbrequired': 0, 'previousblockhash': '00000002135f8a02a04fd924c9e02901bf1682c4992988e2873450a955088f60', 'transactions': [], 'coinbaseaux': {}, 'coinbasevalue': 5000000000, 'longpollid': '00000002135f8a02a04fd924c9e02901bf1682c4992988e2873450a955088f6064', 'target': '0000000377ac0000000000000000000000000000000000000000000000000000', 'mintime': 1714553720, 'mutable': ['time', 'transactions', 'prevblock'], 'noncerange': '00000000ffffffff', 'sigoplimit': 80000, 'sizelimit': 4000000, 'weightlimit': 4000000, 'curtime': 1716228353, 'bits': '1d0377ac', 'height': 10143, 'signet_challenge': '0014f64c3c86285a5a14521fc05fd7e599a13f953350', 'default_witness_commitment': '6a24aa21a9ede2f61c3f71d1defd3fa999dfa36953755c690689799962b48bebd836974e8cf9'}
2024-05-20 15:05:53 DEBUG Mining block delta=2m30s start=1714554619 mine=True
2024-05-20 15:05:53 DEBUG Calling bitcoin-cli: ['/Users/jose.edil/2-development/bitcoin/bitcoin-core/src/bitcoin-cli', '-datadir=/Users/jose.edil/2-development/bitcoin/signet-mining-experiments/signet-fix-hashing', '-signet', '-stdin', 'walletprocesspsbt']
2024-05-20 15:05:53 DEBUG grinding headhex: 00000020608f0855a9503487e2882999c48216bf0129e0c924d94fa0028a5f130200000063a1ad7c6fb413991c25e793160cdd4a3c3ef5681252711fb984a822b07ed2c6fb063266ac77031d00000000
2024-05-20 15:10:36 DEBUG grinder exhausted the nonce search space, retrying with new block header
2024-05-20 15:10:36 DEBUG Calling bitcoin-cli: ['/Users/jose.edil/2-development/bitcoin/bitcoin-core/src/bitcoin-cli', '-datadir=/Users/jose.edil/2-development/bitcoin/signet-mining-experiments/signet-fix-hashing', '-signet', 'getblockchaininfo']
2024-05-20 15:10:36 DEBUG Calling bitcoin-cli: ['/Users/jose.edil/2-development/bitcoin/bitcoin-core/src/bitcoin-cli', '-datadir=/Users/jose.edil/2-development/bitcoin/signet-mining-experiments/signet-fix-hashing', '-signet', 'getblocktemplate', '{"rules":["signet","segwit"]}']
2024-05-20 15:10:36 DEBUG GBT template: {'capabilities': ['proposal'], 'version': 536870912, 'rules': ['csv', '!segwit', '!signet', 'taproot'], 'vbavailable': {}, 'vbrequired': 0, 'previousblockhash': '00000002135f8a02a04fd924c9e02901bf1682c4992988e2873450a955088f60', 'transactions': [], 'coinbaseaux': {}, 'coinbasevalue': 5000000000, 'longpollid': '00000002135f8a02a04fd924c9e02901bf1682c4992988e2873450a955088f6064', 'target': '0000000377ac0000000000000000000000000000000000000000000000000000', 'mintime': 1714553720, 'mutable': ['time', 'transactions', 'prevblock'], 'noncerange': '00000000ffffffff', 'sigoplimit': 80000, 'sizelimit': 4000000, 'weightlimit': 4000000, 'curtime': 1716228636, 'bits': '1d0377ac', 'height': 10143, 'signet_challenge': '0014f64c3c86285a5a14521fc05fd7e599a13f953350', 'default_witness_commitment': '6a24aa21a9ede2f61c3f71d1defd3fa999dfa36953755c690689799962b48bebd836974e8cf9'}
2024-05-20 15:10:36 DEBUG Mining block delta=2m31s start=1714554620 mine=True
2024-05-20 15:10:36 DEBUG Calling bitcoin-cli: ['/Users/jose.edil/2-development/bitcoin/bitcoin-core/src/bitcoin-cli', '-datadir=/Users/jose.edil/2-development/bitcoin/signet-mining-experiments/signet-fix-hashing', '-signet', '-stdin', 'walletprocesspsbt']
2024-05-20 15:10:36 DEBUG grinding headhex: 00000020608f0855a9503487e2882999c48216bf0129e0c924d94fa0028a5f1302000000891fb5f93c91c9ffbe1cfcfd31f0c1cbce05ad41a9cd7c6f9da5cfa7efc36814fc063266ac77031d00000000
2024-05-20 15:11:42 DEBUG Calling bitcoin-cli: ['/Users/jose.edil/2-development/bitcoin/bitcoin-core/src/bitcoin-cli', '-datadir=/Users/jose.edil/2-development/bitcoin/signet-mining-experiments/signet-fix-hashing', '-signet', '-stdin', 'submitblock']
2024-05-20 15:11:42 DEBUG Block hash 00000000bd1904f056ab49c086438fdc779f8249219dd99ce92218dacc9045a3 payout to tb1qylfujt900rjxzfxjj7sktpu7dpm2n9j60ch7jt
2024-05-20 15:11:42 INFO Mined block at height 10143; next in -464h58m52s (mine)
2024-05-20 15:11:42 DEBUG Calling bitcoin-cli: ['/Users/jose.edil/2-development/bitcoin/bitcoin-core/src/bitcoin-cli', '-datadir=/Users/jose.edil/2-development/bitcoin/signet-mining-experiments/signet-fix-hashing', '-signet', 'getblockchaininfo']
2024-05-20 15:11:42 DEBUG Calling bitcoin-cli: ['/Users/jose.edil/2-development/bitcoin/bitcoin-core/src/bitcoin-cli', '-datadir=/Users/jose.edil/2-development/bitcoin/signet-mining-experiments/signet-fix-hashing', '-signet', 'getblockheader', '00000000bd1904f056ab49c086438fdc779f8249219dd99ce92218dacc9045a3']
2024-05-20 15:11:42 DEBUG Calling bitcoin-cli: ['/Users/jose.edil/2-development/bitcoin/bitcoin-core/src/bitcoin-cli', '-datadir=/Users/jose.edil/2-development/bitcoin/signet-mining-experiments/signet-fix-hashing', '-signet', 'getblocktemplate', '{"rules":["signet","segwit"]}']
2024-05-20 15:11:42 DEBUG GBT template: {'capabilities': ['proposal'], 'version': 536870912, 'rules': ['csv', '!segwit', '!signet', 'taproot'], 'vbavailable': {}, 'vbrequired': 0, 'previousblockhash': '00000000bd1904f056ab49c086438fdc779f8249219dd99ce92218dacc9045a3', 'transactions': [], 'coinbaseaux': {}, 'coinbasevalue': 5000000000, 'longpollid': '00000000bd1904f056ab49c086438fdc779f8249219dd99ce92218dacc9045a365', 'target': '0000000377ac0000000000000000000000000000000000000000000000000000', 'mintime': 1714553870, 'mutable': ['time', 'transactions', 'prevblock'], 'noncerange': '00000000ffffffff', 'sigoplimit': 80000, 'sizelimit': 4000000, 'weightlimit': 4000000, 'curtime': 1716228702, 'bits': '1d0377ac', 'height': 10144, 'signet_challenge': '0014f64c3c86285a5a14521fc05fd7e599a13f953350', 'default_witness_commitment': '6a24aa21a9ede2f61c3f71d1defd3fa999dfa36953755c690689799962b48bebd836974e8cf9'}
2024-05-20 15:11:42 DEBUG Mining block delta=2m30s start=1714554770 mine=True
2024-05-20 15:11:42 DEBUG Calling bitcoin-cli: ['/Users/jose.edil/2-development/bitcoin/bitcoin-core/src/bitcoin-cli', '-datadir=/Users/jose.edil/2-development/bitcoin/signet-mining-experiments/signet-fix-hashing', '-signet', '-stdin', 'walletprocesspsbt']
2024-05-20 15:11:42 DEBUG grinding headhex: 00000020a34590ccda1822e99cd99d2149829f77dc8f4386c049ab56f00419bd00000000868b1b8cf4e05c4691a2b8e09b7e8eacac344de1a5aa8b00cbd9ca4ebbb5fd1492073266ac77031d00000000
2024-05-20 15:15:10 DEBUG Calling bitcoin-cli: ['/Users/jose.edil/2-development/bitcoin/bitcoin-core/src/bitcoin-cli', '-datadir=/Users/jose.edil/2-development/bitcoin/signet-mining-experiments/signet-fix-hashing', '-signet', '-stdin', 'submitblock']
2024-05-20 15:15:10 DEBUG Block hash 000000010a8e7590525e9b727d118dfd07add9e7a6b1cc7e176449319a8b5c35 payout to tb1qylfujt900rjxzfxjj7sktpu7dpm2n9j60ch7jt
2024-05-20 15:15:10 INFO Mined block at height 10144; next in -464h59m50s (mine)
Mining interrupted with SIGINT.
2024-05-20 15:19:39 INFO Mined block at height 10156; next in -464h34m19s (mine)
2024-05-20 15:19:39 DEBUG Calling bitcoin-cli: ['/Users/jose.edil/2-development/bitcoin/bitcoin-core/src/bitcoin-cli', '-datadir=/Users/jose.edil/2-development/bitcoin/signet-mining-experiments/signet-fix-hashing', '-signet', 'getblockchaininfo']
2024-05-20 15:19:39 DEBUG Calling bitcoin-cli: ['/Users/jose.edil/2-development/bitcoin/bitcoin-core/src/bitcoin-cli', '-datadir=/Users/jose.edil/2-development/bitcoin/signet-mining-experiments/signet-fix-hashing', '-signet', 'getblockheader', '00000001981d44c6e3e2a2db2ac279057ffca654fc9e14082368e37d7c867d97']
2024-05-20 15:19:39 DEBUG Calling bitcoin-cli: ['/Users/jose.edil/2-development/bitcoin/bitcoin-core/src/bitcoin-cli', '-datadir=/Users/jose.edil/2-development/bitcoin/signet-mining-experiments/signet-fix-hashing', '-signet', 'getblocktemplate', '{"rules":["signet","segwit"]}']
2024-05-20 15:19:39 DEBUG GBT template: {'capabilities': ['proposal'], 'version': 536870912, 'rules': ['csv', '!segwit', '!signet', 'taproot'], 'vbavailable': {}, 'vbrequired': 0, 'previousblockhash': '00000001981d44c6e3e2a2db2ac279057ffca654fc9e14082368e37d7c867d97', 'transactions': [], 'coinbaseaux': {}, 'coinbasevalue': 5000000000, 'longpollid': '00000001981d44c6e3e2a2db2ac279057ffca654fc9e14082368e37d7c867d9778', 'target': '0000000377ac0000000000000000000000000000000000000000000000000000', 'mintime': 1714555821, 'mutable': ['time', 'transactions', 'prevblock'], 'noncerange': '00000000ffffffff', 'sigoplimit': 80000, 'sizelimit': 4000000, 'weightlimit': 4000000, 'curtime': 1716229179, 'bits': '1d0377ac', 'height': 10157, 'signet_challenge': '0014f64c3c86285a5a14521fc05fd7e599a13f953350', 'default_witness_commitment': '6a24aa21a9ede2f61c3f71d1defd3fa999dfa36953755c690689799962b48bebd836974e8cf9'}
2024-05-20 15:19:39 DEBUG Mining block delta=2m30s start=1714556720 mine=True
2024-05-20 15:19:39 DEBUG Calling bitcoin-cli: ['/Users/jose.edil/2-development/bitcoin/bitcoin-core/src/bitcoin-cli', '-datadir=/Users/jose.edil/2-development/bitcoin/signet-mining-experiments/signet-fix-hashing', '-signet', '-stdin', 'walletprocesspsbt']
2024-05-20 15:19:39 DEBUG grinding headhex: 00000020977d867c7de3682308149efc54a6fc7f0579c22adba2e2e3c6441d980100000027a2307dc3799e62088c8aec04cb69018572135edf9db5f3daee4ebfd6f79daf300f3266ac77031d00000000
^C2024-05-20 15:19:50 DEBUG mining aborted by the user
Killing bitcoin-util to simulate an unrecoverable failure
$BTC_PATH/../contrib/signet/miner --debug --cli "$BTC_PATH/bitcoin-cli -datadir=$DATADIR_PATH" generate --address $MINER_ADDR --grind-cmd "$BTC_PATH/bitcoin-util grind" --nbits $NBITS --ongoing
2024-05-20 15:20:06 DEBUG Calling bitcoin-cli: ['/Users/jose.edil/2-development/bitcoin/bitcoin-core/src/bitcoin-cli', '-datadir=/Users/jose.edil/2-development/bitcoin/signet-mining-experiments/signet-fix-hashing', '-signet', 'getblockchaininfo']
2024-05-20 15:20:06 DEBUG Calling bitcoin-cli: ['/Users/jose.edil/2-development/bitcoin/bitcoin-core/src/bitcoin-cli', '-datadir=/Users/jose.edil/2-development/bitcoin/signet-mining-experiments/signet-fix-hashing', '-signet', 'getblockheader', '00000001981d44c6e3e2a2db2ac279057ffca654fc9e14082368e37d7c867d97']
2024-05-20 15:20:06 DEBUG Calling bitcoin-cli: ['/Users/jose.edil/2-development/bitcoin/bitcoin-core/src/bitcoin-cli', '-datadir=/Users/jose.edil/2-development/bitcoin/signet-mining-experiments/signet-fix-hashing', '-signet', 'getblocktemplate', '{"rules":["signet","segwit"]}']
2024-05-20 15:20:06 DEBUG GBT template: {'capabilities': ['proposal'], 'version': 536870912, 'rules': ['csv', '!segwit', '!signet', 'taproot'], 'vbavailable': {}, 'vbrequired': 0, 'previousblockhash': '00000001981d44c6e3e2a2db2ac279057ffca654fc9e14082368e37d7c867d97', 'transactions': [], 'coinbaseaux': {}, 'coinbasevalue': 5000000000, 'longpollid': '00000001981d44c6e3e2a2db2ac279057ffca654fc9e14082368e37d7c867d9778', 'target': '0000000377ac0000000000000000000000000000000000000000000000000000', 'mintime': 1714555821, 'mutable': ['time', 'transactions', 'prevblock'], 'noncerange': '00000000ffffffff', 'sigoplimit': 80000, 'sizelimit': 4000000, 'weightlimit': 4000000, 'curtime': 1716229206, 'bits': '1d0377ac', 'height': 10157, 'signet_challenge': '0014f64c3c86285a5a14521fc05fd7e599a13f953350', 'default_witness_commitment': '6a24aa21a9ede2f61c3f71d1defd3fa999dfa36953755c690689799962b48bebd836974e8cf9'}
2024-05-20 15:20:06 DEBUG Calling bitcoin-cli: ['/Users/jose.edil/2-development/bitcoin/bitcoin-core/src/bitcoin-cli', '-datadir=/Users/jose.edil/2-development/bitcoin/signet-mining-experiments/signet-fix-hashing', '-signet', 'getaddressinfo', 'tb1qylfujt900rjxzfxjj7sktpu7dpm2n9j60ch7jt']
2024-05-20 15:20:06 DEBUG Mining block delta=2m30s start=1714556720 mine=True
2024-05-20 15:20:06 DEBUG Calling bitcoin-cli: ['/Users/jose.edil/2-development/bitcoin/bitcoin-core/src/bitcoin-cli', '-datadir=/Users/jose.edil/2-development/bitcoin/signet-mining-experiments/signet-fix-hashing', '-signet', '-stdin', 'walletprocesspsbt']
2024-05-20 15:20:06 DEBUG grinding headhex: 00000020977d867c7de3682308149efc54a6fc7f0579c22adba2e2e3c6441d980100000027a2307dc3799e62088c8aec04cb69018572135edf9db5f3daee4ebfd6f79daf300f3266ac77031d00000000
Traceback (most recent call last):
  File "/Users/jose.edil/2-development/bitcoin/bitcoin-core/src/../contrib/signet/miner", line 567, in <module>
    main()
  File "/Users/jose.edil/2-development/bitcoin/bitcoin-core/src/../contrib/signet/miner", line 561, in main
    return args.fn(args)
           ^^^^^^^^^^^^^
  File "/Users/jose.edil/2-development/bitcoin/bitcoin-core/src/../contrib/signet/miner", line 433, in do_generate
    raise e
  File "/Users/jose.edil/2-development/bitcoin/bitcoin-core/src/../contrib/signet/miner", line 425, in do_generate
    block = finish_block(block, signet_solution, args.grind_cmd)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jose.edil/2-development/bitcoin/bitcoin-core/src/../contrib/signet/miner", line 108, in finish_block
    newheadhex = subprocess.run(cmd, capture_output=True, input=b"", check=True).stdout.strip()
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/subprocess.py", line 571, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['/Users/jose.edil/2-development/bitcoin/bitcoin-core/src/bitcoin-util', 'grind', '00000020977d867c7de3682308149efc54a6fc7f0579c22adba2e2e3c6441d980100000027a2307dc3799e62088c8aec04cb69018572135edf9db5f3daee4ebfd6f79daf300f3266ac77031d00000000']' died with <Signals.SIGTERM: 15>.

Copy link
Contributor

@AngusP AngusP left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM apart from style nit

contrib/signet/miner Outdated Show resolved Hide resolved
contrib/signet/miner Outdated Show resolved Hide resolved
contrib/signet/miner Outdated Show resolved Hide resolved
The miner script will call `bitcoin-util grind` to compute PoW which will try to
exhaust the block's nonce field and fail if it can't find a valid hash. This
behavior does not appear for low difficulty chains, but make the miner unusable
for higher difficulty settings.

We capture `bitcoin-util grind` exception, build a new block header with
different time and try to grind again.

Fixes bitcoin#30102
@edilmedeiros
Copy link
Contributor Author

Fair enough, committed the style suggestions.

Copy link
Contributor

@AngusP AngusP left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK 1cf174a

@@ -350,7 +352,7 @@ def do_generate(args):
is_mine = True
else:
time_delta = next_block_delta(int(bestheader["bits"], 16), bci["bestblockhash"], ultimate_target, args.poisson, args.max_interval)
mine_time = bestheader["time"] + time_delta
mine_time = bestheader["time"] + time_delta + retries
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you also would want to change:

        if tmpl["mintime"] > mine_time:
            logging.info("Updating block time from %d to %d", mine_time, tmpl["mintime"])
            mine_time = tmpl["mintime"]

to be

    mintime = tmpl["mintime"] + retries
    if mine_time < mintime:
         logging.info(...)
         mine_time = mintime

@edilmedeiros
Copy link
Contributor Author

Returned to draft so I can refactor this PR on top of #28417 recently merged.

@DrahtBot
Copy link
Contributor

DrahtBot commented Sep 4, 2024

🐙 This pull request conflicts with the target branch and needs rebase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

contrib/signet/miner: grind will fail for high difficulty chain
5 participants