Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Diff confusion #2199

Open
rdugan opened this issue Mar 8, 2023 · 0 comments
Open

Diff confusion #2199

rdugan opened this issue Mar 8, 2023 · 0 comments

Comments

@rdugan
Copy link

rdugan commented Mar 8, 2023

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant