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.
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.
https://github.com/kaspanet/kaspad/blob/d8350d62b0f26ca13f4db277dd5d0d883d227604/app/rpc/rpccontext/verbosedata.go#L33