Skip to content

Diff confusion #2199

Open
Open
@rdugan

Description

Something i've been consistently confused by since my first interaction w/ kaspa is the multiple conflicting reports of network difficulty. The value reported by kaspad via rpc is in the TH range, and does not match the value expected, as per documentation at https://en.bitcoin.it/wiki/Difficulty. It appears to be inflated by a factor of 2^31 (i.e. pow max / diff 1, or 2^255 / 0xffff * 2^208). For example, we currently see a reported diff of ~251T, while the expected value is more like 117K. Numerous web sites seem to have noticed this, and adjusted the diff themselves.

Digging through the code, I stumbled on the following line. It appears the reported diff is calculated by taking PowMax / target (PowMax being 2^255), rather than max target / target (max target being 0xffff * 2^208). This clearly results in the scaling of diff by a factor of 2^31 as I mentioned above. I can't quite make out if this is a bug, or i'm missing something and this was done on purpose.

difficulty := new(big.Rat).SetFrac(params.PowMax, target)

Activity

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

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions