Open Sjors opened 2 months ago
I have been trying to set up mining for my faucet for several days but without success. But I only compiled "fjahr:2024-04-testnet-4-fix".
I also tried CPU mining "bitcoin-cli generatetoaddress 1 tb1q3fplfy4g........095q 2000000000"
If it's not a secret, what pool, stratum... did you use?
I ran my own "pool" with SRI (this code).
I'm not sure if generatetoaddress actually works outside of regtest these days.
I CPU mined the first 20 blocks (due to #849) by slightly modifying the signet miner python script.
The current difficulty is 4 so CPU mining should work fine, it's just a matter of figuring out how.
I used a little stratum proxy script by @Fi3 to monitor communication between the S9 and the translator role.
This itself seems to make the process more stable, typically mining 10+ blocks before it fails.
But with a few seconds it does fail:
Forwarding <: b'{"id":47,"method":"mining.submit","params":["provoost","190","0000000000000000","66224aca","8ac6ca4c","0006e000"]}\n'
Forwarding >: b'{"id":47,"error":null,"result":true}\n'
Forwarding <: b'{"id":48,"method":"mining.submit","params":["provoost","190","0000000000000000","66224aca","96619ee1","0006e000"]}\n'
Forwarding >: b'{"id":48,"error":null,"result":true}\n'
Forwarding <: b'{"id":49,"method":"mining.submit","params":["provoost","190","0000000000000000","66224aca","db84fd8e","00068000"]}\n'
Forwarding >: b'{"id":49,"error":null,"result":true}\n'
Forwarding <: b'{"id":50,"method":"mining.submit","params":["provoost","190","0000000000000000","66224aca","f6807083","00068000"]}\n'
Forwarding >: b'{"id":50,"error":null,"result":true}\n'
Forwarding <: b'{"id":51,"method":"mining.submit","params":["provoost","190","0000000000000000","66224aca","50897de1","00074000"]}\n'
Forwarding >: b'{"id":51,"error":null,"result":true}\n'
Forwarding <: b'{"id":52,"method":"mining.submit","params":["provoost","190","0000000000000000","66224aca","aae26422","00076000"]}\n'
Forwarding >: b'{"method":"mining.notify","params":["191","2213b21235591c00032a6210c8ba924ed5ee223e5fdbddbc023b571300000000","02000000010000000000000000000000000000000000000000000000000000000000000000ffffffff2d02e71700536a6f72736e61646f","ffffffff0200f2052a01000000225120596bd2585eee0959f6105f396cac2c3036823c34aebc1f42ce84483d760e6b540000000000000000266a24aa21a9ede2f61c3f71d1defd3fa999dfa36953755c690689799962b48bebd836974e8cf900000000",[],"20000000","1c0ffff0","66224acb",true]}\n'
Forwarding >: b'{"id":52,"error":null,"result":true}\n'
No more data to forward.
Forwarding >: b'{"method":"mining.notify","params":["192","d05d566c09a3aa699181c1af9cf62c28790bee6b7bb92c790001729e00000000","02000000010000000000000000000000000000000000000000000000000000000000000000ffffffff2d02e81700536a6f72736e61646f","ffffffff0200f2052a01000000225120596bd2585eee0959f6105f396cac2c3036823c34aebc1f42ce84483d760e6b540000000000000000266a24aa21a9ede2f61c3f71d1defd3fa999dfa36953755c690689799962b48bebd836974e8cf900000000",[],"20000000","1c0ffff0","66224ad3",true]}\n'
Forwarding >: b'{"method":"mining.notify","params":["193","835698d615f217613ebddaf6a17e3f027af6eeaeaa0e05e70001a35800000000","02000000010000000000000000000000000000000000000000000000000000000000000000ffffffff2d02e91700536a6f72736e61646f","ffffffff0200f2052a01000000225120596bd2585eee0959f6105f396cac2c3036823c34aebc1f42ce84483d760e6b540000000000000000266a24aa21a9ede2f61c3f71d1defd3fa999dfa36953755c690689799962b48bebd836974e8cf900000000",[],"20000000","1c0ffff0","66224ad6",true]}\n'
Traceback (most recent call last):
File "/home/sjors/./s9-monitor.py", line 45, in <module>
start_proxy(target_host, target_port)
File "/home/sjors/./s9-monitor.py", line 35, in start_proxy
handle_client(client_socket, target_host, target_port)
File "/home/sjors/./s9-monitor.py", line 21, in handle_client
forward_data(target_socket, client_socket,">")
File "/home/sjors/./s9-monitor.py", line 12, in forward_data
destination.sendall(data)
Could the problem be receiving a mining.notify
message for the next work template before "result":true
on the previous block?
If I set the hashrate to 10 THs the following exchange happens:
Listening on port 34255...
Received connection from ('192.168.1.44', 58522)
Forwarding <: b'{"id":0,"method":"mining.configure","params":[["version-rolling"],{"version-rolling.mask":"1fffe000","version-rolling.min-bit-count":16}]}\n'
Forwarding >: b'{"id":0,"error":null,"result":{"minimum-difficulty":false,"version-rolling":true,"version-rolling.mask":"1fffe000","version-rolling.min-bit-count":"00000010"}}\n'
Forwarding <: b'{"id":1,"method":"mining.subscribe","params":["2022-09-27-0-26ba61b9-22.08.1-plus;bosminer-plus-am1-s9 0.9.0-26ba61b9",null,"192.168.1.207:34255",null]}\n'
Forwarding >: b'{"id":1,"error":null,"result":[[["mining.set_difficulty","ae6812eb4cd7735a302a8a9dd95cf71f"],["mining.notify","ae6812eb4cd7735a302a8a9dd95cf71f"]],"000000000000000000000000000000030000000000000001",8]}\n'
Forwarding <: b'{"id":2,"method":"mining.authorize","params":["provoost",""]}\n'
Forwarding >: b'{"id":2,"error":null,"result":true}\n'
Forwarding >: b'{"method":"mining.set_difficulty","params":[1164.0]}\n{"method":"mining.notify","params":["255","deb9f35e6bc9f4edf6a3913978f37c9580dfe0efad123c8600024a6700000000","02000000010000000000000000000000000000000000000000000000000000000000000000ffffffff2d02271800536a6f72736e61646f","ffffffff0200f2052a01000000225120596bd2585eee0959f6105f396cac2c3036823c34aebc1f42ce84483d760e6b540000000000000000266a24aa21a9ede2f61c3f71d1defd3fa999dfa36953755c690689799962b48bebd836974e8cf900000000",[],"20000000","1c0ffff0","66224cc7",true]}\n'
Forwarding >: b'{"method":"mining.notify","params":["256","6e96ff070ca57aec990698a2722e45d4b3ff0113c7a1828b0002264400000000","02000000010000000000000000000000000000000000000000000000000000000000000000ffffffff2d02281800536a6f72736e61646f","ffffffff0200f2052a01000000225120596bd2585eee0959f6105f396cac2c3036823c34aebc1f42ce84483d760e6b540000000000000000266a24aa21a9ede2f61c3f71d1defd3fa999dfa36953755c690689799962b48bebd836974e8cf900000000",[],"20000000","1c0ffff0","66224ce2",true]}\n'
Forwarding >: b'{"method":"mining.notify","params":["257","2c71278ef8a565bf9961cd1e91930f057e865c1a0e5fa4800001260f00000000","02000000010000000000000000000000000000000000000000000000000000000000000000ffffffff2d02291800536a6f72736e61646f","ffffffff0200f2052a01000000225120596bd2585eee0959f6105f396cac2c3036823c34aebc1f42ce84483d760e6b540000000000000000266a24aa21a9ede2f61c3f71d1defd3fa999dfa36953755c690689799962b48bebd836974e8cf900000000",[],"20000000","1c0ffff0","66224ce2",true]}\n'
Forwarding >: b'{"method":"mining.notify","params":["258","3b8b2ce74973c04cade7d79cf6f7d15ffa8a7d14b6b052560001f2e600000000","02000000010000000000000000000000000000000000000000000000000000000000000000ffffffff2d022a1800536a6f72736e61646f","ffffffff0200f2052a01000000225120596bd2585eee0959f6105f396cac2c3036823c34aebc1f42ce84483d760e6b540000000000000000266a24aa21a9ede2f61c3f71d1defd3fa999dfa36953755c690689799962b48bebd836974e8cf900000000",[],"20000000","1c0ffff0","66224ce3",true]}\n'
Forwarding >: b'{"method":"mining.notify","params":["259","89f24f4b0eb96ecd2074cb500caf6c386f742681c18cde7900015a0e00000000","02000000010000000000000000000000000000000000000000000000000000000000000000ffffffff2d022b1800536a6f72736e61646f","ffffffff0200f2052a01000000225120596bd2585eee0959f6105f396cac2c3036823c34aebc1f42ce84483d760e6b540000000000000000266a24aa21a9ede2f61c3f71d1defd3fa999dfa36953755c690689799962b48bebd836974e8cf900000000",[],"20000000","1c0ffff0","66224ce4",true]}\n'
Forwarding >: b'{"method":"mining.notify","params":["260","526cfae58453dc02a8512fb7364b97b574eaca647119d2970001064300000000","02000000010000000000000000000000000000000000000000000000000000000000000000ffffffff2d022c1800536a6f72736e61646f","ffffffff0200f2052a01000000225120596bd2585eee0959f6105f396cac2c3036823c34aebc1f42ce84483d760e6b540000000000000000266a24aa21a9ede2f61c3f71d1defd3fa999dfa36953755c690689799962b48bebd836974e8cf900000000",[],"20000000","1c0ffff0","66224ceb",true]}\n'
Forwarding >: b'{"method":"mining.notify","params":["261","2a053b0724d18ed108426ef337a3fa602f1c7408dcf078370000e2c500000000","02000000010000000000000000000000000000000000000000000000000000000000000000ffffffff2d022d1800536a6f72736e61646f","ffffffff0200f2052a01000000225120596bd2585eee0959f6105f396cac2c3036823c34aebc1f42ce84483d760e6b540000000000000000266a24aa21a9ede2f61c3f71d1defd3fa999dfa36953755c690689799962b48bebd836974e8cf900000000",[],"20000000","1c0ffff0","66224cec",true]}\n'
No more data to forward.
Notably the difficulty 1164
is much higher than the actual network difficulty 4
.
@Sjors Hello, I run Stratum together with some rented S9 without any problems, though I've applied a fix for odd-sized extranonces. I suggest using tcpdump
or ngrep
to dump network traffic without interfering with the communication:
ngrep -d eth0 -W byline port <tproxy-port>
tcpdump -i eth0 -s0 -A -qn tcp and port <tproxy-port>
I tweaked the hash rate so that it neatly set the difficulty to 4.
The pattern seems to be that the miner hangs up at the first "mining.notify
message, after some shares have been submitted.
Forwarding <: b'{"id":121,"method":"mining.submit","params":["provoost","571","0000000000000000","66225783","a6f17109","00458000"]}\n'
Forwarding >: b'{"id":120,"error":null,"result":true}\n'
Forwarding <: b'{"id":122,"method":"mining.submit","params":["provoost","571","0000000000000000","66225783","8389bb22","00464000"]}\n'
Forwarding >: b'{"id":121,"error":null,"result":true}\n'
Forwarding <: b'{"id":123,"method":"mining.submit","params":["provoost","571","0000000000000000","66225783","930a84e3","00460000"]}\n'
Forwarding >: b'{"id":122,"error":null,"result":true}\n'
Forwarding <: b'{"id":124,"method":"mining.submit","params":["provoost","571","0000000000000000","66225783","9aa45120","0047a000"]}\n'
Forwarding >: b'{"id":123,"error":null,"result":true}\n'
Forwarding <: b'{"id":125,"method":"mining.submit","params":["provoost","571","0000000000000000","66225783","85a6730d","00486000"]}\n'
Forwarding >: b'{"id":124,"error":null,"result":true}\n{"method":"mining.notify","params":["572","91fdb5f55707618f52bab2291fac2df147e987af51729aae005f57c400000000","02000000010000000000000000000000000000000000000000000000000000000000000000ffffffff2d02641900536a6f72736e61646f","ffffffff0200f2052a01000000225120596bd2585eee0959f6105f396cac2c3036823c34aebc1f42ce84483d760e6b540000000000000000266a24aa21a9ede2f61c3f71d1defd3fa999dfa36953755c690689799962b48bebd836974e8cf900000000",[],"20000000","1c0ffff0","66225788",true]}\n'
Forwarding >: b'{"id":125,"error":null,"result":true}\n'
No more data to forward.
though I've applied a fix for odd-sized extranonces
What do you mean by this?
What do you mean by this?
seems to be that the miner hangs up
did you try to mine on other/public pools to check the miner?
So in mining.notify
the third argument contains an extranonce: https://en.bitcoin.it/wiki/Stratum_mining_protocol#mining.notify
E.g. in the last message this argument is 02000000010000000000000000000000000000000000000000000000000000000000000000ffffffff2d02641900536a6f72736e61646f
, which has 110 characters. I also don't see any OddLength
messages in the translator log. So I don't think my issue is related to #851.
did you try to mine on other/public pools to check the miner?
Yes, it works fine with Ocean pool, Braiins and my most recent DMND pool stratum v1 endpoint.
Solo mining against my own sv2 mainnet "pool" also works. Well, at least it submits shares and doesn't crash.
Your ngrep
command works great by the way, thanks.
IIRC I've previously also mined on testnet3.
I don't have time now, but one thing I could try is adding a slight delay to (whatever causes) the mining.notify
messages, to see if it's indeed a race condition.
On mainnet it takes longer to validate newly submitted blocks as to generate block templates. On testnet4 blocks are currently empty. Testnet3 is somewhere in the middle. So that might explain why a race condition only shows up on my fake testnet.
Is the race condition in the miner's code/pool's code or somewhere else?
No idea.
For any one wondering here you can find the above mentioned script:
#! /usr/bin/python
import socket
import threading
def forward_data(source, destination,direction):
while True:
data = source.recv(1024)
if not data:
print("No more data to forward.")
break
print(f"Forwarding {direction}: {data}")
destination.sendall(data)
def handle_client(client_socket, target_host, target_port):
target_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
target_socket.connect((target_host, target_port))
client_to_target = threading.Thread(target=forward_data, args=(client_socket, target_socket,"<"))
client_to_target.start()
forward_data(target_socket, client_socket,">")
client_socket.close()
target_socket.close()
def start_proxy(target_host, target_port):
listen_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
listen_socket.bind(('', 0))
assigned_port = listen_socket.getsockname()[1]
listen_socket.listen(5)
print(f"Listening on port {assigned_port}...")
client_socket, addr = listen_socket.accept()
print(f"Received connection from {addr}")
handle_client(client_socket, target_host, target_port)
if __name__ == "__main__":
#target_host = 'stratum.braiins.com'
#target_port = 3333
#target_host = 'localhost'
#target_port = 34255
target_host = 'mining.dmnd.work'
target_port = 1000
start_proxy(target_host, target_port)
So what's a conclusion on this issue @Sjors ?
Nothing, it's still unsolved.
I'm having a hard time mining on the newly proposed testnet4 with my S9.
I run the pool and translator roles. For the latter I've been trying different values for
min_individual_miner_hashrate
andchannel_nominal_hashrate
(keeping them the same).My S9 normally runs at about 10 TH/s (for noise and efficiency reasons). So correct value should be
10_000_000_000_000.0
, but when I use that it doesn't mine anything, the BOS miner firmware keeps restarting and the translator log is full of errors:Note that the serde error is apparently innocent, see #770.
In the Braiins dashboard I get "BOS miner is not running" popups frequently, with the usual pattern of fans going to 100%. All the stats stay 0:
Using
1_000_000_000.0
(1 GH/s) improves the situation, but many shares seem to get lost, resulting in effectively only hashing a few blocks per minute. Sometimes a bunch in a short burst.Here's just the first 30 seconds: https://zerobin.org/?bc33618e9559776c#BecMMsL4Np9uzEn55QxkpwdwAbeZkqL4bJ3S5FwPBkxb
The miner thinks it found 500 blocks, but the blockchain only grew by 8.
If I set it 10x higher the BOS miner starts crashing again, not producing blocks.
I'm guessing part of the problem is in how fast blocks are found, perhaps the S9 ends up working on outdated templates.
At the time of testing the difficulty on testnet4 is 4, I'll keep pointing hash power at it to increase that. IIRC difficulty 1 million is about the equivalent of a single S9 on the network.