colonelwatch / nonceMiner

Casual project implementing hash midstate caching to make a very fast miner for revoxhere's duino-coin
GNU General Public License v3.0
39 stars 13 forks source link

Shares rejected with xxhash and odd rejected shares / server graceful disconnects #14

Closed Painadath closed 3 years ago

Painadath commented 3 years ago

when i try to mine with my pi this hapens

pi@raspberrypi:~/nonceMiner/bin $ ./nonceMiner -u whitelizard -t 2
Initializing nonceMiner v2.0.0...
Configured with username 'whitelizard', identifier '', difficulty 'EXTREME', and 2 thread(s).
Starting threads...
12:36:48 [cpu0] Connected to 149.91.88.18:6000 with response: 2.5
12:36:48 [cpu0] New job from 149.91.88.18 with difficulty 950000
12:36:49 [cpu1] Connected to 149.91.88.18:6000 with response: 2.5
12:36:49 [cpu1] New job from 149.91.88.18 with difficulty 950000
12:36:51 [cpu1] Share accepted, work-time 2.0 s
12:36:51 [cpu1] New job from 149.91.88.18 with difficulty 1778843

12:36:59 [rprt] Hashrate: 1.03 MH/s, Accepted 1, Rejected 0

12:37:09 [rprt] Hashrate: 1.03 MH/s, Accepted 0, Rejected 0

12:37:15 [cpu0] Share accepted, work-time 27.220 s
12:37:16 [cpu0] New job from 149.91.88.18 with difficulty 173090
12:37:17 [cpu0] Share accepted, work-time 1.532 s
12:37:17 [cpu0] New job from 149.91.88.18 with difficulty 1816843

12:37:19 [rprt] Hashrate: 1.69 MH/s, Accepted 2, Rejected 0

12:37:29 [rprt] Hashrate: 1.69 MH/s, Accepted 0, Rejected 0

12:37:39 [rprt] Hashrate: 1.69 MH/s, Accepted 0, Rejected 0

12:37:49 [rprt] Hashrate: 1.69 MH/s, Accepted 0, Rejected 0

12:37:59 [rprt] Hashrate: 1.69 MH/s, Accepted 0, Rejected 0

12:38:09 [rprt] Hashrate: 1.69 MH/s, Accepted 0, Rejected 0

12:38:19 [rprt] Hashrate: 1.69 MH/s, Accepted 0, Rejected 0

12:38:29 [rprt] Hashrate: 1.69 MH/s, Accepted 0, Rejected 0

12:38:39 [rprt] Hashrate: 1.69 MH/s, Accepted 0, Rejected 0

12:38:49 [rprt] Hashrate: 1.69 MH/s, Accepted 0, Rejected 0

12:38:53 [cpu0] Error receiving feedback: server closed gracefully
12:38:55 [cpu0] Restarted due to an unexpected error
12:38:56 [cpu0] Connected to 149.91.88.18:6000 with response: 2.5
12:38:56 [cpu0] New job from 149.91.88.18 with difficulty 950000

12:38:59 [rprt] Hashrate: 1.03 MH/s, Accepted 0, Rejected 0

12:39:09 [rprt] Hashrate: 1.03 MH/s, Accepted 0, Rejected 0

12:39:17 [cpu1] Error receiving feedback: server closed gracefully

12:39:19 [rprt] Hashrate: 0.00 MH/s, Accepted 0, Rejected 0

12:39:19 [cpu1] Restarted due to an unexpected error
12:39:20 [cpu1] Connected to 149.91.88.18:6000 with response: 2.5
12:39:20 [cpu1] New job from 149.91.88.18 with difficulty 950000
^C
pi@raspberrypi:~/nonceMiner/bin $ ./nonceMiner -u whitelizard -t 2 -i NET
Initializing nonceMiner v2.0.0...
Configured with username 'whitelizard', identifier '', difficulty 'NET', and 2 thread(s).
Starting threads...
12:39:33 [cpu0] Connected to 149.91.88.18:6000 with response: 2.5
12:39:33 [cpu0] New job from 149.91.88.18 with difficulty 100000
12:39:34 [cpu1] Connected to 149.91.88.18:6000 with response: 2.5
12:39:34 [cpu1] New job from 149.91.88.18 with difficulty 100000
12:39:35 [cpu0] Share accepted, work-time 1.869 s
12:39:36 [cpu0] New job from 149.91.88.18 with difficulty 185473
12:39:36 [cpu1] Share accepted, work-time 1.938 s
12:39:36 [cpu1] New job from 149.91.88.18 with difficulty 187980

12:39:44 [rprt] Hashrate: 1.84 MH/s, Accepted 2, Rejected 0

12:39:50 [cpu1] Share rejected, work-time 13.947 s
12:39:50 [cpu1] New job from 149.91.88.18 with difficulty 950000
12:39:52 [cpu0] Share rejected, work-time 16.694 s
12:39:52 [cpu0] New job from 149.91.88.18 with difficulty 882106

12:39:54 [rprt] Hashrate: 2.14 MH/s, Accepted 0, Rejected 2

12:40:04 [rprt] Hashrate: 2.14 MH/s, Accepted 0, Rejected 0

^C
pi@raspberrypi:~/nonceMiner/bin $ ./nonceMiner -u whitelizard -t 2 -i NET -a xxhash
Initializing nonceMiner v2.0.0...
Configured with username 'whitelizard', identifier '', difficulty 'NET', and 2 thread(s).
Running in xxhash mode. WARNING: Per-thread hashrates over 0.9 MH/s may be rejected.
Starting threads...
12:40:14 [cpu0] Connected to 149.91.88.18:6000 with response: 2.5
12:40:15 [cpu1] Connected to 149.91.88.18:6000 with response: 2.5
12:40:15 [cpu0] Share rejected, work-time 1.358 s
12:40:17 [cpu1] Share rejected, work-time 2.427 s
12:40:20 [cpu1] Share rejected, work-time 3.33 s
12:40:21 [cpu0] Share rejected, work-time 6.53 s
^C
pi@raspberrypi:~/nonceMiner/bin $ ./nonceMiner -u whitelizard -t 2 -i EXTREME -a xxhash
Initializing nonceMiner v2.0.0...
Configured with username 'whitelizard', identifier '', difficulty 'EXTREME', and 2 thread(s).
Running in xxhash mode. WARNING: Per-thread hashrates over 0.9 MH/s may be rejected.
Starting threads...
12:40:30 [cpu0] Connected to 149.91.88.18:6000 with response: 2.5
12:40:31 [cpu1] Connected to 149.91.88.18:6000 with response: 2.5
12:40:35 [cpu1] Share rejected, work-time 3.222 s
12:40:35 [cpu0] Share rejected, work-time 4.106 s
12:40:38 [cpu1] Share rejected, work-time 3.937 s

12:40:41 [rprt] Hashrate: 3.63 MH/s, Accepted 0, Rejected 3

12:40:42 [cpu0] Share rejected, work-time 7.358 s
12:40:43 [cpu1] Share rejected, work-time 4.740 s
12:40:45 [cpu0] Share rejected, work-time 2.890 s
12:40:46 [cpu1] Share rejected, work-time 2.889 s
12:40:49 [cpu0] Share rejected, work-time 4.216 s
^C
pi@raspberrypi:~/nonceMiner/bin $ cd
pi@raspberrypi:~ $ 
colonelwatch commented 3 years ago

Hello, the xxhash rejections definitely have to do with the Raspberry Pi being too fast. I can see in the line

12:40:41 [rprt] Hashrate: 3.63 MH/s, Accepted 0, Rejected 3

that the per-thread speed was about 1.815 MH/s, and that's faster than 0.9 MH/s. The server will reject those shares because of that. I suspect the workaround would be to delay sending the result so that the observed speed falls under 0.9 MH/s. I think I'll make such a hashrate limiter a configurable option.

Also, the server doesn't offer selectable difficulty for xxhash. I should probably add in a warning for that.

That said, the first two runs are odd. Thanks for posting the log, it will definitely help diagnosing things.

colonelwatch commented 3 years ago

Hello, and I'm sorry that I took so long to get back to this. I've gotten around to figuring out what happened with my own Raspberry Pi 3, and the issue seems to be surprisingly simple. It occurs when a relatively slow PC running nonceMiner interacts with duino-coin's KOLKA, and it boils down to the server sending completely unreasonable jobs.

The second run (NET tier) leads into the first run, so let's start with that. The NET difficulty has a cap of 1 MH/s, over which you get force-promoted to the EXTREME tier. When this happens, the shares are rejected, and after this we reach the same point at which the first run starts.

Here's the timeline of the first run from the perspective of cpu1: 1) 12:36:51 [cpu1] New job from 149.91.88.18 with difficulty 1778843 - The difficulty here is way too high. At 1 MH/s (about the Pi 3's speed on a single thread), the maximum possible time to complete this job of this difficulty is 178 seconds. 2) 12:37:21 - The master server is appears to be programmed to kill the connection at the 30 second mark, guessing the client went dead. 3) 12:39:17 [cpu1] Error receiving feedback: server closed gracefully - After 146 seconds, the Raspberry Pi is done, but on sending the result it learns the server has killed the connection. 4) 12:39:19 [cpu1] Restarted due to an unexpected error

Now, in my own testing, I saw a share accepted after 44 seconds, so it might not be at the 30 second mark at which the connection is killed anymore. That says nothing about a share accepted after 146 seconds, though.

colonelwatch commented 3 years ago

Taking this into account, the starting difficulty of EXTREME is 950000, and the maximum possible time for that is 95 seconds. This means that the EXTREME difficulty is impossible for a Pi to run, but it's just fast enough to get force-promoted into it. Right now, a Raspberry Pi 3 is effectively unable to run nonceMiner because of this.

On the client side, this can also be solved with a hashrate limiter, set under 1 MH/s. It will never enter the EXTREME difficulty that way, and it's otherwise a great way to navigate around the server's strict reward policy. On the other hand, this issue shows that their reward policy has a hole in it, and that should be patched.

Edit: Sorry, I used KOLKA and reward policy interchangeably.

Painadath commented 3 years ago

@colonelwatch any idea to limit the speed in pi with nonceminer?

colonelwatch commented 3 years ago

I'm thinking of something like this: 1) Solve the job 2) Calculate how long the job should have taken using the correct nonce and the desired hashrate 3) Sleep for the extra time necessary plus a second or so for safety