Skip to content

security(consensus): fp_pow2 linear interpolation error may cause consensus split between nodes #210

Description

@AlphaB135

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.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions