Severity: HIGH
Location
crates/consensus/src/asert.rs lines 105–196
Description
2^x is not a linear function. The linear interpolation used in fp_pow2() has an error of ~5,000 units in 32.32 fixed-point at the midpoint of each segment. Two independent implementations (e.g., a mining pool's node vs a validator's node) computing the same block's difficulty target may disagree on whether a borderline hash meets the target, causing a consensus split.
Fix
Replace with a higher-order approximation. The reference ASERT integer implementation (aserti3-2d) uses a minimax polynomial that keeps error below 1 ULP:
// Use the reference polynomial from: https://github.com/bitcoin-cash-node/bitcoin-cash-node
// Alternatively, use a 4-term Chebyshev approximation on each 1/8 segment
Alternatively, adopt the Bitcoin Cash reference implementation of aserti3-2d directly as it has been production-verified.
Severity: HIGH
Location
crates/consensus/src/asert.rslines 105–196Description
2^xis not a linear function. The linear interpolation used infp_pow2()has an error of ~5,000 units in 32.32 fixed-point at the midpoint of each segment. Two independent implementations (e.g., a mining pool's node vs a validator's node) computing the same block's difficulty target may disagree on whether a borderline hash meets the target, causing a consensus split.Fix
Replace with a higher-order approximation. The reference ASERT integer implementation (aserti3-2d) uses a minimax polynomial that keeps error below 1 ULP:
Alternatively, adopt the Bitcoin Cash reference implementation of aserti3-2d directly as it has been production-verified.