aquachain / aquacppminer

Aquachain CPU Mining Tool (C++)
https://aquacha.in/latest/?sort=time&order=desc
GNU General Public License v3.0
5 stars 3 forks source link

Use HashVersion from getWork() response #5

Open aerth opened 4 years ago

aerth commented 4 years ago

Sample response from getWork()

{"id":74,"jsonrpc":"2.0","result":["0x7d2e314dc14cdd6a569d7dfda7a8e21517bd5ac90735d55c34ccdd7dedd0841b","0x0000000000000000000000000000000000000000000000000000000000000002","0x0f40840676d7f4bd5e873a429050313629fcdb74cbab030051fac5a2bec8"]}

Aquachain returns second param's last byte as 2, so the current hashing algorithm is 2 (1 was ethash)

When it switches to 3, the miner should use the 3rd algorithm

A small issue that comes up is that we cant switch the argon2 context after it has been set initially.

Related links: https://gitlab.com/aquachain/aquachain/blob/master/params/hf.go#L40 https://gitlab.com/aquachain/aquachain/blob/master/params/config.go#L36 https://gitlab.com/aquachain/aquachain/blob/master/crypto/crypto.go#L52-97

aerth commented 4 years ago

To test, use testnet2 which hardforks very quickly.

Testnet2HF = ForkMap{
        5: big.NewInt(0),
        8: big.NewInt(8),
        9: big.NewInt(19),
    }

The HF that we care about for mining is 5, 8 and 9 which are algorithm changes, so it starts in algo version 2, moves to version 3 at block 8, and version 4 at block 19.

aquachain -testnet2 -rpc -aquabase 0xf8a00cb30e5005d17f6065fd6d17e0f5bee4183c and mine: aquacppminer -F http://127.0.0.1:8543 --solo

You can see that without restarting, each hardfork breaks the miner (submits faulty hashes)

aerth commented 4 years ago

re-opening this issue because restart is still required between forks