litecoincash-project / cpuminer-multi

Features the Minotaur and MinotaurX hash algorithms, and segwit support, for Ring [RNG] and Litecoin Cash [LCC].
Other
42 stars 32 forks source link

Does not request block template well when using MinotaurX algorithm, lack of arguments in request. #4

Closed OBTfx closed 3 years ago

OBTfx commented 3 years ago

Ok, checking why my mining processes only get blocks with SHA and not with MinX, I see that the problem is in the cpuminer; when it goes with the MinX algorithm to request the block template from the node, the template delivered is not correct, because it was not passed between the "minotaurx" arguments to obtain a template for MinX, therefore, the node delivers a template by default , which is the one corresponding to SHA-256d and the target between the algorithms are very different

https://github.com/litecoincash-project/cpuminer-multi/blob/d9e61f9c8f1e4476120f5326ed793de31e33aa64/cpu-miner.c#L1473-L1475 https://github.com/litecoincash-project/cpuminer-multi/blob/d9e61f9c8f1e4476120f5326ed793de31e33aa64/cpu-miner.c#L1476-L1478

#

TEMPLATE.- Requesting through the litecoincash-cli

litecoincash-cli getblocktemplate '{"powalgo":"minotaurx"}'

{
  "capabilities": [
    "proposal"
  ],
  "version": 65536,
  "rules": [
    "csv",
    "segwit",
    "hive",
    "hive_1_1",
    "minotaurx"
  ],
  "vbavailable": {
  },
  "vbrequired": 0,
  "previousblockhash": "21cd1a0d044cf63c288abebd5a79ca047108f7e73ce7b4fe2adafccc17f63b34",
  "transactions": [
  ],
  "coinbaseaux": {
    "flags": ""
  },
  "coinbasevalue": 5000000000,
  "longpollid": "21cd1a0d044cf63c288abebd5a79ca047108f7e73ce7b4fe2adafccc17f63b345",
  "target": "00000071a11e0000000000000000000000000000000000000000000000000000",
  "mintime": 1621670420,
  "mutable": [
    "time",
    "transactions",
    "prevblock"
  ],
  "noncerange": "00000000ffffffff",
  "sigoplimit": 80000,
  "sizelimit": 4000000,
  "weightlimit": 4000000,
  "curtime": 1621687310,
  "bits": "1d71a11e",
  "height": 2268
}

CPUMINER Algo MinotaurX

./cpuminer -a minotaurx -o http://127.0.0.1:62455 -O user:pass --threads=1 --coinbase-addr=t9dJdqruJ7XybguxLMTR3JK5yu2hgqZAFn --coinbase-sig=OBTfx_MTX_NX --api-bind 127.0.0.1:4049 -R 5 --no-longpoll --cpu-affinity 2 -PD

** cpuminer-multi 1.5 by Tanner^LCC **
LCC donation address: CashCFfv8CmdWo6wyMGQWtmQnaToyhgsWr

[2021-05-22 14:42:25] Binding process to cpu mask 2
[2021-05-22 14:42:25] 1 miner threads started, using 'minotaurx' algorithm.
[2021-05-22 14:42:25] Binding thread 0 to cpu mask 2
[2021-05-22 14:42:25] JSON protocol request:
{"method": "getblocktemplate", "params": [{"capabilities": ["coinbasetxn", "coinbasevalue", "longpoll", "workid"], "rules": ["segwit"]}], "id":0}

* Rebuilt URL to: http://127.0.0.1:62455/
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to 127.0.0.1 (127.0.0.1) port 62455 (#0)
* Server auth using Basic with user 'user'
> POST / HTTP/1.1
Host: 127.0.0.1:62455
Authorization: Basic dXNlcjpwYXNz
Accept: */*
Accept-Encoding: deflate, gzip
Content-Type: application/json
Content-Length: 147
User-Agent: cpuminer-multi/1.5
X-Mining-Extensions: longpoll reject-reason
Expect: 100-continue

< HTTP/1.1 100 Continue
< HTTP/1.1 200 OK
< Content-Type: application/json
< Date: Sat, 22 May 2021 12:42:25 GMT
< Content-Length: 797
< 
* Connection #0 to host 127.0.0.1 left intact
[2021-05-22 14:42:25] JSON protocol response:
{
   "result": {
      "capabilities": [
         "proposal"
      ],
      "version": 0,
      "rules": [
         "csv",
         "segwit",
         "hive",
         "hive_1_1",
         "minotaurx"
      ],
      "vbavailable": {},
      "vbrequired": 0,
      "previousblockhash": "21cd1a0d044cf63c288abebd5a79ca047108f7e73ce7b4fe2adafccc17f63b34",
      "transactions": [],
      "coinbaseaux": {
         "flags": ""
      },
      "coinbasevalue": 5000000000,
      "longpollid": "21cd1a0d044cf63c288abebd5a79ca047108f7e73ce7b4fe2adafccc17f63b345",
      "target": "00000000230c8f00000000000000000000000000000000000000000000000000",
      "mintime": 1621670420,
      "mutable": [
         "time",
         "transactions",
         "prevblock"
      ],
      "noncerange": "00000000ffffffff",
      "sigoplimit": 80000,
      "sizelimit": 4000000,
      "weightlimit": 4000000,
      "curtime": 1621687345,
      "bits": "1c230c8f",
      "height": 2268,
      "default_witness_commitment": "6a24aa21a9ede2f61c3f71d1defd3fa999dfa36953755c690689799962b48bebd836974e8cf9"
   },
   "error": null,
   "id": 0
}
[2021-05-22 14:42:25] Current block is 2268
[2021-05-22 14:42:25] got new work in 1.42 ms
[2021-05-22 14:42:25] JSON protocol request:
{"method": "getmininginfo", "params": [], "id":8}

* Rebuilt URL to: http://127.0.0.1:62455/
* Found bundle for host 127.0.0.1: 0x7f166c014d60 [can pipeline]
* Re-using existing connection! (#0) with host 127.0.0.1
* Connected to 127.0.0.1 (127.0.0.1) port 62455 (#0)
* Server auth using Basic with user 'user'
> POST / HTTP/1.1
Host: 127.0.0.1:62455
Authorization: Basic dXNlcjpwYXNz
Accept: */*
Accept-Encoding: deflate, gzip
Content-Type: application/json
Content-Length: 51
User-Agent: cpuminer-multi/1.5
X-Mining-Extensions: longpoll reject-reason
Expect: 100-continue

< HTTP/1.1 100 Continue
< HTTP/1.1 200 OK
< Content-Type: application/json
< Date: Sat, 22 May 2021 12:42:25 GMT
< Content-Length: 235
< 
* Connection #0 to host 127.0.0.1 left intact
[2021-05-22 14:42:25] JSON protocol response:
{
   "result": {
      "blocks": 2267,
      "currentblockweight": 4000,
      "currentblocktx": 0,
      "difficulty": 0.00390625,
      "minotaurxdifficulty": 0.0058990711989584292,
      "networkhashps": 4709546.3935919385,
      "pooledtx": 0,
      "chain": "test",
      "warnings": ""
   },
   "error": null,
   "id": 8
}
[2021-05-22 14:42:26] CPU #0: 726.18 H/s
^C[2021-05-22 14:42:27] SIGINT received, exiting

#

TEMPLATE.- Requesting through the litecoincash-cli

litecoincash-cli getblocktemplate '{"powalgo":"sha256d"}'

{
  "capabilities": [
    "proposal"
  ],
  "version": 0,
  "rules": [
    "csv",
    "segwit",
    "hive",
    "hive_1_1",
    "minotaurx"
  ],
  "vbavailable": {
  },
  "vbrequired": 0,
  "previousblockhash": "21cd1a0d044cf63c288abebd5a79ca047108f7e73ce7b4fe2adafccc17f63b34",
  "transactions": [
  ],
  "coinbaseaux": {
    "flags": ""
  },
  "coinbasevalue": 5000000000,
  "longpollid": "21cd1a0d044cf63c288abebd5a79ca047108f7e73ce7b4fe2adafccc17f63b345",
  "target": "00000000230c8f00000000000000000000000000000000000000000000000000",
  "mintime": 1621670420,
  "mutable": [
    "time",
    "transactions",
    "prevblock"
  ],
  "noncerange": "00000000ffffffff",
  "sigoplimit": 80000,
  "sizelimit": 4000000,
  "weightlimit": 4000000,
  "curtime": 1621687303,
  "bits": "1c230c8f",
  "height": 2268
}

CPUMINER Algo SHA-256d

./cpuminer -a sha256d -o http://127.0.0.1:62455 -O user:pass --threads=1 --coinbase-addr=t7vGHuMvy18cXSaXngCDcj6sVyaL643kQZ --coinbase-sig=OBTfx_SHA_NX --api-bind 127.0.0.1:4050 -R 5 --no-longpoll --cpu-affinity 8 -PD

** cpuminer-multi 1.5 by Tanner^LCC **
LCC donation address: CashCFfv8CmdWo6wyMGQWtmQnaToyhgsWr

[2021-05-22 14:42:19] Binding process to cpu mask 8
[2021-05-22 14:42:19] 1 miner threads started, using 'sha256d' algorithm.
[2021-05-22 14:42:19] Binding thread 0 to cpu mask 8
[2021-05-22 14:42:19] JSON protocol request:
{"method": "getblocktemplate", "params": [{"capabilities": ["coinbasetxn", "coinbasevalue", "longpoll", "workid"], "rules": ["segwit"]}], "id":0}

* Rebuilt URL to: http://127.0.0.1:62455/
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to 127.0.0.1 (127.0.0.1) port 62455 (#0)
* Server auth using Basic with user 'user'
> POST / HTTP/1.1
Host: 127.0.0.1:62455
Authorization: Basic dXNlcjpwYXNz
Accept: */*
Accept-Encoding: deflate, gzip
Content-Type: application/json
Content-Length: 147
User-Agent: cpuminer-multi/1.5
X-Mining-Extensions: longpoll reject-reason
Expect: 100-continue

< HTTP/1.1 100 Continue
< HTTP/1.1 200 OK
< Content-Type: application/json
< Date: Sat, 22 May 2021 12:42:19 GMT
< Content-Length: 797
< 
* Connection #0 to host 127.0.0.1 left intact
[2021-05-22 14:42:19] JSON protocol response:
{
   "result": {
      "capabilities": [
         "proposal"
      ],
      "version": 0,
      "rules": [
         "csv",
         "segwit",
         "hive",
         "hive_1_1",
         "minotaurx"
      ],
      "vbavailable": {},
      "vbrequired": 0,
      "previousblockhash": "21cd1a0d044cf63c288abebd5a79ca047108f7e73ce7b4fe2adafccc17f63b34",
      "transactions": [],
      "coinbaseaux": {
         "flags": ""
      },
      "coinbasevalue": 5000000000,
      "longpollid": "21cd1a0d044cf63c288abebd5a79ca047108f7e73ce7b4fe2adafccc17f63b345",
      "target": "00000000230c8f00000000000000000000000000000000000000000000000000",
      "mintime": 1621670420,
      "mutable": [
         "time",
         "transactions",
         "prevblock"
      ],
      "noncerange": "00000000ffffffff",
      "sigoplimit": 80000,
      "sizelimit": 4000000,
      "weightlimit": 4000000,
      "curtime": 1621687339,
      "bits": "1c230c8f",
      "height": 2268,
      "default_witness_commitment": "6a24aa21a9ede2f61c3f71d1defd3fa999dfa36953755c690689799962b48bebd836974e8cf9"
   },
   "error": null,
   "id": 0
}
[2021-05-22 14:42:19] Current block is 2268
[2021-05-22 14:42:19] got new work in 13.71 ms
[2021-05-22 14:42:19] JSON protocol request:
{"method": "getmininginfo", "params": [], "id":8}

* Rebuilt URL to: http://127.0.0.1:62455/
* Found bundle for host 127.0.0.1: 0x7f24a4014d60 [can pipeline]
* Re-using existing connection! (#0) with host 127.0.0.1
* Connected to 127.0.0.1 (127.0.0.1) port 62455 (#0)
* Server auth using Basic with user 'user'
> POST / HTTP/1.1
Host: 127.0.0.1:62455
Authorization: Basic dXNlcjpwYXNz
Accept: */*
Accept-Encoding: deflate, gzip
Content-Type: application/json
Content-Length: 51
User-Agent: cpuminer-multi/1.5
X-Mining-Extensions: longpoll reject-reason
Expect: 100-continue

< HTTP/1.1 100 Continue
< HTTP/1.1 200 OK
< Content-Type: application/json
< Date: Sat, 22 May 2021 12:42:19 GMT
< Content-Length: 235
< 
* Connection #0 to host 127.0.0.1 left intact
[2021-05-22 14:42:19] JSON protocol response:
{
   "result": {
      "blocks": 2267,
      "currentblockweight": 4000,
      "currentblocktx": 0,
      "difficulty": 0.00390625,
      "minotaurxdifficulty": 0.0058990711989584292,
      "networkhashps": 4709546.3935919385,
      "pooledtx": 0,
      "chain": "test",
      "warnings": ""
   },
   "error": null,
   "id": 8
}
[2021-05-22 14:42:19] CPU #0: 4575 kH/s
^C[2021-05-22 14:42:20] SIGINT received, exiting
OBTfx commented 3 years ago

So for those who want to try mining with the "MinotaurX" algorithm, they have to put in the node configuration file "powalgo=minotaurx" Regards

litecoincash-project commented 3 years ago

Indeed the powalgo conf argument allows this to be specified at wallet level. However, it's more versatile to have cpuminer request a specific template. I'll approve your PR with pleasure, thanks!