DurianStallSingapore / ZILMiner

Mining software for Zilliqa
GNU General Public License v3.0
38 stars 21 forks source link

ZILminer crash with 'Json::LogicError' from time to time #24

Open renheren opened 3 years ago

renheren commented 3 years ago

Describe the bug While mining on shardpool.io, zilminer crash upexpectedly with 'Json::LogicError'

i 19:57:12 zilminer Job: d5703775… us1-zil.shardpool.io [ip-of-shardpool:5000]
terminate called after throwing an instance of 'Json::LogicError'
what():  Value is not convertible to bool.

To Reproduce Steps to reproduce the behavior:

  1. Just mining on shardpool with zilminer, it will happen from time to time. For me, it's a few times a day.

Expected behavior continous mining without crash

Environment (please complete the following information):

dentatar commented 3 years ago

Same for me. Shardpool + zilminer 0.4.01

Kgonla commented 3 years ago

me too

moette commented 3 years ago

The issue was caused by malformed answers to the eth_getWork call that shardpool.io send out randomly. These answers contained two json objects, the first not being in expected ZIL format:

`{"id":0,"jsonrpc":"2.0","result":["0x6ea9c64b8b48f6d8ff36805f5b58af599c040560b54d7c8120b4a97a5cbcd0ee","0x0000000000000000000000000000000000000000000000000000000000000000","0x0100010001000100010001000100010001000100010001000100010001","12382"] } {"id":1,"jsonrpc":"2.0","result":["0x6ea9c64b8b48f6d8ff36805f5b58af599c040560b54d7c8120b4a97a5cbcd0ee","0x0000000000000000000000000000000000000000000000000000000000000000","0x00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff",true,0]}

OR

{"id":0,"jsonrpc":"2.0","result":["0xa8e787d3d85597e20702cc584d09c7e3e727a20bf0d0f86dd8b4dbebfb5cdb28","0x0000000000000000000000000000000000000000000000000000000000000000","0x0100010001000100010001000100010001000100010001000100010001","12374"]}{"id":1,"jsonrpc":"2.0","result":["","","",true,0]}`

ZILminer expects the result array to have 5 elements, the 4th being a bool. The current code accesses and converts the array elements without checking them. I prepared a fix and will add a PR later.

In the meantime shardpool.io have fixed the issue on their side. So single mining zil should work without the miner crashing now.