project-bitmark / bitmark

Bitmark Core
The Unlicense
47 stars 33 forks source link

getmininginfo displays incorrect diff #45

Closed crackfoo closed 6 years ago

crackfoo commented 6 years ago

bitmark-cli getmininginfo { "blocks" : 451365, "currentblocksize" : 1000, "currentblocktx" : 0, "reward_next" : 15.00000000, "reward_max" : 15.00000000, "hashrate_4max_reward" : 35000000000, "difficulty" : 31.24732609, "errors" : "", "genproclimit" : -1, "networkhashps" : 40838757117513.62500000, "pooledtx" : 0, "testnet" : false, "generate" : false, "algo" : 0, "algoname" : "SCRYPT", "hashespersec" : 0 }

bitmark-cli getinfo { "version" : 90700, "protocolversion" : 70002, "walletversion" : 60000, "balance" : 0.00016242, "blocks" : 451365, "timeoffset" : 0, "connections" : 18, "proxy" : "", "difficulty SCRYPT" : 204207957.39825028, "difficulty SHA256D" : 1.00000000, "difficulty YESCRYPT" : 96.10301716, "difficulty ARGON2" : 277.43863202, "difficulty X17" : 475146.84641310, "difficulty LYRA2REv2" : 1590063.61880842, "difficulty EQUIHASH" : 21.33334915, "difficulty CRYPTONIGHT" : 31.24732609, "moneysupply" : 8740490.00000000, "testnet" : false, "keypoololdest" : 1509137009, "keypoolsize" : 101, "paytxfee" : 0.00000000, "relayfee" : 0.00001000, "errors" : "" }

Seems the difficulty in getmininginfo just randomly picks a diff to display rather than the diff that the wallet is set for, which is scrypt.

piratelinux commented 6 years ago

ok we see how to do this, but for now you can use the weights in GetAlgoWeight() in core.cpp to scale the difficulty.

crackfoo commented 6 years ago

great thanks. Is equihash an auxpow algo?

piratelinux commented 6 years ago

They are all merge minable. But for equihash transactions are in "vector format" and for cryptonight both transactions and block headers are in vector format so that I don't have to parse the structure, just search the vector for the hash I need. No mining pool exists for this yet, I just tested this with my cpuminer-multi fork (branch mm).

dbkeys commented 6 years ago

Resolved in dev branch for v0.9.7.1 release.

The difficulties displayed are weighted difficulties ( a weight factor is applied to harmonize the relative value of hashes amongst the 8 algorithms.)

Now also displaying 'sdifficulty' or "simple" difficulty (before application of weighting factor)

bitmark-cli getmininginfo
{
    "blocks" : 460029,
    "currentblocksize" : 0,
    "currentblocktx" : 0,
    "pow_algo_id" : 6,
    "pow_algo" : "EQUIHASH",
    "reward_next" : 13.60873642,
    "reward_max" : 13.91284218,
    "hashrate_4max_reward" : 35000000000,
    "pow_algo_id" : 6,
    "pow_algo" : "EQUIHASH",
    "difficulty" : 102.52967548,
    "sdifficulty" : 0.00001282,
    "difficulty SCRYPT" : 37094126.96716188,
    "difficulty SHA256D" : 123719896.11868501,
    "difficulty YESCRYPT" : 33769.93954931,
    "difficulty ARGON2" : 2595.24984730,
    "difficulty X17" : 975801.77979410,
    "difficulty LYRA2REv2" : 2143506.82743751,
    "difficulty EQUIHASH" : 102.52967548,
    "difficulty CRYPTONIGHT" : 234.82088557,
    "errors" : "",
    "genproclimit" : -1,
    "networkhashps" : 155642457591204.43750000,
    "pooledtx" : 0,
    "testnet" : false,
    "generate" : false,
    "hashespersec" : 0
}

Weights applied, from core.cpp:

// Based on tests with general purpose CPUs,
//       ( Except for SHA256 which was designed for simplicity and suited for ASICs,
//       so given a factor of 16 decrease in weight. )
//   Weighing gives more value to hashes from some algos over others,
//      because, for example a Cryptonight hash is much more computationally expensive
//      than a SHA256d hash.
//   Weights should ultimately reflect the market value of hashes by different algorithms;
//      this will vary constantly (and more significantly long-term with hardware developement)
//   As of June, 2018 these values are closely reflective of market values seen on
//      nicehash.com and miningrigrentals.com
unsigned int GetAlgoWeight (const int algo) {
  unsigned int weight = 8000; // scrypt, lyra2rev2 and 17 share this value.
  switch (algo)
    {
    case ALGO_SHA256D:
      weight = 1;
      break;
    case ALGO_ARGON2:
      weight = 4000000;
      break;
    case ALGO_EQUIHASH:
      weight = 8000000;
      break;
    case ALGO_CRYPTONIGHT:
      weight = 8000000;
      break;
    case ALGO_YESCRYPT:
      weight = 800000;
      break;
    }
  return weight;
}