Merge pull request #464 from TheBlueMatt/2020-08-pow-clarification

Set Params::pow_limit to an attainable value not a theoretical one
This commit is contained in:
Andrew Poelstra 2020-09-10 16:46:40 +00:00 committed by GitHub
commit 440005b16e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 22 additions and 15 deletions

View File

@ -20,26 +20,26 @@
use network::constants::Network; use network::constants::Network;
use util::uint::Uint256; use util::uint::Uint256;
/// Lowest possible difficulty for Mainnet. /// Lowest possible difficulty for Mainnet. See comment on Params::pow_limit for more info.
const MAX_BITS_BITCOIN: Uint256 = Uint256([ const MAX_BITS_BITCOIN: Uint256 = Uint256([
0xffffffffffffffffu64, 0x0000000000000000u64,
0xffffffffffffffffu64, 0x0000000000000000u64,
0xffffffffffffffffu64, 0x0000000000000000u64,
0x00000000ffffffffu64, 0x00000000ffff0000u64,
]); ]);
/// Lowest possible difficulty for Testnet. /// Lowest possible difficulty for Testnet. See comment on Params::pow_limit for more info.
const MAX_BITS_TESTNET: Uint256 = Uint256([ const MAX_BITS_TESTNET: Uint256 = Uint256([
0xffffffffffffffffu64, 0x0000000000000000u64,
0xffffffffffffffffu64, 0x0000000000000000u64,
0xffffffffffffffffu64, 0x0000000000000000u64,
0x00000000ffffffffu64, 0x00000000ffff0000u64,
]); ]);
/// Lowest possible difficulty for Regtest. /// Lowest possible difficulty for Regtest. See comment on Params::pow_limit for more info.
const MAX_BITS_REGTEST: Uint256 = Uint256([ const MAX_BITS_REGTEST: Uint256 = Uint256([
0xffffffffffffffffu64, 0x0000000000000000u64,
0xffffffffffffffffu64, 0x0000000000000000u64,
0xffffffffffffffffu64, 0x0000000000000000u64,
0x7fffffffffffffffu64, 0x7fffff0000000000u64,
]); ]);
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
@ -62,6 +62,13 @@ pub struct Params {
/// Number of blocks with the same set of rules. /// Number of blocks with the same set of rules.
pub miner_confirmation_window: u32, pub miner_confirmation_window: u32,
/// Proof of work limit value. It contains the lowest possible difficulty. /// Proof of work limit value. It contains the lowest possible difficulty.
///
/// Note that this value differs from Bitcoin Core's powLimit field in that this value is
/// attainable, but Bitcoin Core's is not. Specifically, because targets in Bitcoin are always
/// rounded to the nearest float expressible in "compact form", not all targets are attainable.
/// Still, this should not affect consensus as the only place where the non-compact form of
/// this is used in Bitcoin Core's consensus algorithm is in comparison and there are no
/// compact-expressible values between Bitcoin Core's and the limit expressed here.
pub pow_limit: Uint256, pub pow_limit: Uint256,
/// Expected amount of time to mine one block. /// Expected amount of time to mine one block.
pub pow_target_spacing: u64, pub pow_target_spacing: u64,