-
Notifications
You must be signed in to change notification settings - Fork 35.5k
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: grind will fail for high difficulty chain #30102
Comments
Can reproduce. Been running a signet network whose miner stalled a few dozens of blocks after the block 10080 difficulty adjustment. The miner (v26.1 script) is ran as a systemd service like this, and the nbits parameter was determined by running the calibrating utility set to 600s. Despite this, before block 10080 the miner used to mine a block every 2.5 min instead of 10. I don't quite understand how it works, honestly. miner --cli="bitcoin-cli" generate --address $rewards_addy --grind-cmd="bitcoin-util grind" --nbits=1d02257e --ongoing |
Thanks for reporting. About the 2m30s interval, see #30091. |
Thanks for the pointer. A bit off-topic, but since there are not so many people yet who are familiar with operating a signet let me ask you a follow up question: I'm don't really understand why the signet miner has so much logic and is so opinionated. My initial idea was to keep the difficulty as low as possible then fire a cronjob every 10 minutes to insta-mine a block at the current timestamp, so the consensus algorithm would be tricked into thinking that is the real difficulty. I was never able to use the miner like this though, it seems to have a life of its own. No matter which Is it possible to have a signet mining setup like that, that is not constantly raising the difficulty and wasting CPU? |
Yeah, I had some difficulty understanding its behavior and I believe I grasped after studying the miner source code. It has an internal timer whose logic is capable of doing what you want. Instead of using the See https://edil.com.br/blog/creating-a-custom-bitcoin-signet. |
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 bitcoin#30102
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
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
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
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
Is there an existing issue for this?
Current behaviour
Mining will fail with a
Could not satisfy difficulty target
.This is a follow-up of the discussion in #30091: I started a signet with difficulty
--nbits 1d008d28
and mined the first block with a date 30 days in the past. That would let the miner run as fast as it can until difficulty is so high it will converge to the 10 minute average time between blocks.After each 2016 blocks, the difficulty is adjusted as per the network consensus and it gets increasingly harder to find new blocks. After 5 adjustments, the grinder eventually exhausts the nonce search space and fails, making the python script to fail as well.
I inspected the bitcoin-util grinder source, but could not find any problem there. Indeed, it does what one would expect: look for PoW and fail if the
nonce
search space is exhausted. That's where the stdout message comes.Expected behaviour
I tracked down the problem to this section of the code.
The
finish_block
function should be able to catch the exception that can arise from the grinder subprocess and in case of failure try another block header. In case of signet, I believe it is a matter of resigning it as in and looking for PoW again until it finds something.I started a fix to submit a PR, but wanted to see if someone else could reproduce this behavior in the meantime. It's not clear to me how to make a (unit) test to systematically expose the problem, though.
Steps to reproduce
Follow the outline discussed in #30091 and let the miner run (for a few hours) until the difficulty gets high enough so that one needs a bigger search space to find valid PoW for new blocks.
Relevant log output
Current chain info
How did you obtain Bitcoin Core
Compiled from source
What version of Bitcoin Core are you using?
v27.0
Operating system and version
MacOS Sonoma 14.4
Machine specifications
Macbook Pro M3 Pro
18GB Memory
The text was updated successfully, but these errors were encountered: