Currently the system uses the hard coded parameters for mainnet, which gives weird results for non-mainnet nets (e.g. testnet). This pulls the Params().GetConsensus().powLimit and uses that instead.
[rpc] Bug-fix: getdifficulty: use network parameters for minimum difficulty #9597
pull kallewoof wants to merge 2 commits into bitcoin:master from kallewoof:getdifficulty-use-net-params changing 2 files +10 −4-
kallewoof commented at 8:23 AM on January 20, 2017: member
-
Bug-fix: use network parameters for minimum difficulty rather than hard coded mainnet params. 6e3a6e2662
- kallewoof closed this on Jan 20, 2017
- kallewoof reopened this on Jan 20, 2017
-
Testing: fix getdifficulty check as it can be an integer sometimes, and add check to ensure it is always >= 1.0 c60ed72552
- kallewoof force-pushed on Jan 20, 2017
- fanquake added the label RPC/REST/ZMQ on Jan 20, 2017
-
morcos commented at 6:52 PM on January 20, 2017: member
testnet actually has the same powLimit as mainnet, so this would change results only on regtest, but doesn't it make more sense for difficulty to always reference the same minimum value and regtest just allows it to go less than 1?
-
kallewoof commented at 8:53 PM on January 20, 2017: member
Hm, I didn't realize that (testnet had same powLimit as mainnet). I do know that when running on an experimental network with a different pow limit we got very weird values which go against the comment about being a factor of minimum difficulty. I guess it comes down to, "do we care about that case?"
-
luke-jr commented at 11:40 PM on January 20, 2017: member
NACK, let's not try to redefine difficulty for each network. It's okay if some networks might have <1 difficulties.
-
sipa commented at 11:43 PM on January 20, 2017: member
I believe that in the first testnet iteration, at least in some versions of the software, the powLimit was defined as 2x higher than the mainnet one, and 1 testnet difficulty corresponded to 0.5 mainnet difficulty in hashrate. It was pretty confusing, and I think it's indeed easier to just everywhere treat 1 difficulty as 4295032833 hashes.
- kallewoof closed this on Jan 23, 2017
- kallewoof deleted the branch on Oct 17, 2019
- DrahtBot locked this on Dec 16, 2021