Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Low difficulty mining via translator with S9 with BraiinsOS 22.08.1-plus #856

Open
Sjors opened this issue Apr 17, 2024 · 14 comments
Open
Labels
translation proxy SV1>SV2 translation proxy issues

Comments

@Sjors
Copy link
Collaborator

Sjors commented Apr 17, 2024

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 and channel_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:

    Finished dev [optimized + debuginfo] target(s) in 0.06s
     Running `/home/sjors/dev/stratum/roles/target/debug/translator_sv2 .. -- -c /home/sjors/.stratum/testnet4-translator.toml`
2024-04-17T10:36:30.249052Z  INFO translator_sv2: PC: ProxyConfig { upstream_address: "127.0.0.1", upstream_port: 44254, upstream_authority_pubkey: Secp256k1PublicKey(XOnlyPublicKey(e76c2b09eed7baa394dbb794896e913c86a5f719ea803bc0a4aaa104383cee24ac5b32268edbcc58d105534c281f112f5e7a5c1ff0e2d113bd938dc7698e2cce)), downstream_address: "0.0.0.0", downstream_port: 34255, max_supported_version: 2, min_supported_version: 2, min_extranonce2_size: 8, downstream_difficulty_config: DownstreamDifficultyConfig { min_individual_miner_hashrate: 10000000000000.0, shares_per_minute: 6.0, submits_since_last_update: 0, timestamp_of_last_update: 0 }, upstream_difficulty_config: UpstreamDifficultyConfig { channel_diff_update_interval: 60, channel_nominal_hashrate: 10000000000000.0, timestamp_of_last_update: 0, should_aggregate: false } }
2024-04-17T10:36:30.249294Z  INFO translator_sv2::lib::upstream_sv2::upstream: PROXY SERVER - ACCEPTING FROM UPSTREAM: 127.0.0.1:44254
2024-04-17T10:36:30.250997Z  INFO roles_logic_sv2::handlers::common: Received SetupConnectionSuccess: version=2, flags=100
2024-04-17T10:36:30.251018Z  INFO translator_sv2: Connected to Upstream!
2024-04-17T10:36:30.251122Z  INFO roles_logic_sv2::handlers::mining: Received OpenExtendedMiningChannelSuccess with request id: 0 and channel id: 11
2024-04-17T10:36:30.251129Z  INFO translator_sv2::lib::upstream_sv2::upstream: Up: Successfully Opened Extended Mining Channel
2024-04-17T10:36:30.294230Z  INFO roles_logic_sv2::handlers::mining: Received new extended mining job for channel id: 0 with job id: 1068 is_future: true
2024-04-17T10:36:30.294260Z  INFO roles_logic_sv2::handlers::mining: Received SetNewPrevHash channel id: 11, job id: 1068
2024-04-17T10:36:35.688158Z  INFO translator_sv2::lib::downstream_sv1::downstream: PROXY SERVER - ACCEPTING FROM DOWNSTREAM: 192.168.1.44:49098
2024-04-17T10:36:35.689566Z  INFO translator_sv2::lib::downstream_sv1::downstream: Down: Configuring
2024-04-17T10:36:35.690707Z  INFO translator_sv2::lib::downstream_sv1::downstream: Down: Subscribing
2024-04-17T10:36:35.690953Z  INFO translator_sv2::lib::downstream_sv1::downstream: Down: Authorizing
2024-04-17T10:36:37.070023Z  INFO translator_sv2::lib::downstream_sv1::downstream: PROXY SERVER - ACCEPTING FROM DOWNSTREAM: 192.168.1.44:49136
2024-04-17T10:36:39.171242Z ERROR translator_sv2::lib::status: Error: BadSerdeJson(Error("expected value", line: 1, column: 2))
2024-04-17T10:36:39.171292Z  WARN translator_sv2::lib::downstream_sv1::downstream: Downstream: Shutting down sv1 downstream reader
2024-04-17T10:36:39.171309Z  WARN translator_sv2::lib::downstream_sv1::downstream: Downstream: Shutting down sv1 downstream writer: 192.168.1.44:49136
2024-04-17T10:36:39.171315Z  INFO translator_sv2: HEALTHY message: Bad serde json: `Error("expected value", line: 1, column: 2)`
2024-04-17T10:36:40.251665Z  INFO roles_logic_sv2::handlers::mining: Received SetTarget for channel id: 11
2024-04-17T10:36:40.251679Z  INFO translator_sv2::lib::upstream_sv2::upstream: SetTarget: SetTarget { channel_id: 11, maximum_target: Ref([3, 232, 154, 81, 119, 30, 135, 81, 73, 171, 16, 250, 171, 74, 231, 105, 221, 228, 84, 25, 224, 221, 102, 189, 245, 176, 4, 0, 0, 0, 0, 0]) }
2024-04-17T10:36:41.151316Z  INFO translator_sv2::lib::downstream_sv1::downstream: PROXY SERVER - ACCEPTING FROM DOWNSTREAM: 192.168.1.44:49150
2024-04-17T10:36:43.171580Z ERROR translator_sv2::lib::status: Error: BadSerdeJson(Error("expected value", line: 1, column: 2))
2024-04-17T10:36:43.171621Z  WARN translator_sv2::lib::downstream_sv1::downstream: Downstream: Shutting down sv1 downstream reader
2024-04-17T10:36:43.171630Z  INFO translator_sv2: HEALTHY message: Bad serde json: `Error("expected value", line: 1, column: 2)`
2024-04-17T10:36:43.171633Z  WARN translator_sv2::lib::downstream_sv1::downstream: Downstream: Shutting down sv1 downstream writer: 192.168.1.44:49150
2024-04-17T10:36:46.157850Z  INFO translator_sv2::lib::downstream_sv1::downstream: PROXY SERVER - ACCEPTING FROM DOWNSTREAM: 192.168.1.44:49152
2024-04-17T10:36:48.074070Z  WARN translator_sv2::lib::downstream_sv1::downstream: Downstream: Shutting down sv1 downstream job notifier for 192.168.1.44:49136
2024-04-17T10:36:48.170602Z ERROR translator_sv2::lib::status: Error: BadSerdeJson(Error("expected value", line: 1, column: 2))
2024-04-17T10:36:48.170638Z  WARN translator_sv2::lib::downstream_sv1::downstream: Downstream: Shutting down sv1 downstream reader
2024-04-17T10:36:48.170652Z  WARN translator_sv2::lib::downstream_sv1::downstream: Downstream: Shutting down sv1 downstream writer: 192.168.1.44:49152
2024-04-17T10:36:48.170663Z  INFO translator_sv2: HEALTHY message: Bad serde json: `Error("expected value", line: 1, column: 2)`
2024-04-17T10:36:49.498470Z ERROR translator_sv2::lib::status: Error: Io(Custom { kind: ConnectionAborted, error: "Connection closed by client" })
2024-04-17T10:36:49.498507Z  WARN translator_sv2::lib::downstream_sv1::downstream: Downstream: Shutting down sv1 downstream reader
2024-04-17T10:36:49.498525Z  WARN translator_sv2::lib::downstream_sv1::downstream: Downstream: Shutting down sv1 downstream job notifier for 192.168.1.44:49098
2024-04-17T10:36:49.498532Z  INFO translator_sv2: HEALTHY message: I/O error: `Custom { kind: ConnectionAborted, error: "Connection closed by client" }
2024-04-17T10:36:49.498540Z ERROR translator_sv2::lib::status: Error: ChannelErrorReceiver(RecvError)
2024-04-17T10:36:49.498554Z  WARN translator_sv2::lib::downstream_sv1::downstream: Downstream: Shutting down sv1 downstream writer: 192.168.1.44:49098
2024-04-17T10:36:49.498556Z  INFO translator_sv2: HEALTHY message: Channel receive error: `RecvError`
2024-04-17T10:36:52.154807Z  WARN translator_sv2::lib::downstream_sv1::downstream: Downstream: Shutting down sv1 downstream job notifier for 192.168.1.44:49150
2024-04-17T10:36:54.585697Z  INFO translator_sv2::lib::downstream_sv1::downstream: PROXY SERVER - ACCEPTING FROM DOWNSTREAM: 192.168.1.44:49158
2024-04-17T10:36:54.586760Z  INFO translator_sv2::lib::downstream_sv1::downstream: Down: Configuring
2024-04-17T10:36:54.587775Z  INFO translator_sv2::lib::downstream_sv1::downstream: Down: Subscribing
2024-04-17T10:36:54.588002Z  INFO translator_sv2::lib::downstream_sv1::downstream: Down: Authorizing
2024-04-17T10:36:55.887021Z  INFO translator_sv2::lib::downstream_sv1::downstream: PROXY SERVER - ACCEPTING FROM DOWNSTREAM: 192.168.1.44:49198
2024-04-17T10:36:57.160463Z  WARN translator_sv2::lib::downstream_sv1::downstream: Downstream: Shutting down sv1 downstream job notifier for 192.168.1.44:49152
2024-04-17T10:36:57.988091Z ERROR translator_sv2::lib::status: Error: BadSerdeJson(Error("expected value", line: 1, column: 2))
2024-04-17T10:36:57.988127Z  WARN translator_sv2::lib::downstream_sv1::downstream: Downstream: Shutting down sv1 downstream reader
2024-04-17T10:36:57.988140Z  WARN translator_sv2::lib::downstream_sv1::downstream: Downstream: Shutting down sv1 downstream writer: 192.168.1.44:49198
2024-04-17T10:36:57.988151Z  INFO translator_sv2: HEALTHY message: Bad serde json: `Error("expected value", line: 1, column: 2)`
2024-04-17T10:36:59.065161Z  INFO translator_sv2::lib::downstream_sv1::downstream: PROXY SERVER - ACCEPTING FROM DOWNSTREAM: 192.168.1.44:49212
2024-04-17T10:37:01.087671Z ERROR translator_sv2::lib::status: Error: BadSerdeJson(Error("expected value", line: 1, column: 2))
2024-04-17T10:37:01.087699Z  WARN translator_sv2::lib::downstream_sv1::downstream: Downstream: Shutting down sv1 downstream reader
2024-04-17T10:37:01.087707Z  INFO translator_sv2: HEALTHY message: Bad serde json: `Error("expected value", line: 1, column: 2)`
2024-04-17T10:37:01.087712Z  WARN translator_sv2::lib::downstream_sv1::downstream: Downstream: Shutting down sv1 downstream writer: 192.168.1.44:49212
2024-04-17T10:37:04.073533Z  INFO translator_sv2::lib::downstream_sv1::downstream: PROXY SERVER - ACCEPTING FROM DOWNSTREAM: 192.168.1.44:49214
2024-04-17T10:37:06.087329Z ERROR translator_sv2::lib::status: Error: BadSerdeJson(Error("expected value", line: 1, column: 2))
2024-04-17T10:37:06.087361Z  WARN translator_sv2::lib::downstream_sv1::downstream: Downstream: Shutting down sv1 downstream reader
2024-04-17T10:37:06.087372Z  WARN translator_sv2::lib::downstream_sv1::downstream: Downstream: Shutting down sv1 downstream writer: 192.168.1.44:49214
2024-04-17T10:37:06.087372Z  INFO translator_sv2: HEALTHY message: Bad serde json: `Error("expected value", line: 1, column: 2)`
2024-04-17T10:37:06.888018Z  WARN translator_sv2::lib::downstream_sv1::downstream: Downstream: Shutting down sv1 downstream job notifier for 192.168.1.44:49198
2024-04-17T10:37:08.227650Z ERROR translator_sv2::lib::status: Error: Io(Custom { kind: ConnectionAborted, error: "Connection closed by client" })
2024-04-17T10:37:08.227678Z  WARN translator_sv2::lib::downstream_sv1::downstream: Downstream: Shutting down sv1 downstream reader
2024-04-17T10:37:08.227695Z  WARN translator_sv2::lib::downstream_sv1::downstream: Downstream: Shutting down sv1 downstream job notifier for 192.168.1.44:49158
2024-04-17T10:37:08.227709Z ERROR translator_sv2::lib::status: Error: ChannelErrorReceiver(RecvError)
2024-04-17T10:37:08.227715Z  WARN translator_sv2::lib::downstream_sv1::downstream: Downstream: Shutting down sv1 downstream writer: 192.168.1.44:49158
2024-04-17T10:37:08.227880Z  INFO translator_sv2: HEALTHY message: I/O error: `Custom { kind: ConnectionAborted, error: "Connection closed by client" }
2024-04-17T10:37:08.227892Z  INFO translator_sv2: HEALTHY message: Channel receive error: `RecvError`
2024-04-17T10:37:10.065668Z  WARN translator_sv2::lib::downstream_sv1::downstream: Downstream: Shutting down sv1 downstream job notifier for 192.168.1.44:49212
2024-04-17T10:37:13.311490Z  INFO translator_sv2::lib::downstream_sv1::downstream: PROXY SERVER - ACCEPTING FROM DOWNSTREAM: 192.168.1.44:49216
2024-04-17T10:37:13.313071Z  INFO translator_sv2::lib::downstream_sv1::downstream: Down: Configuring
2024-04-17T10:37:13.314498Z  INFO translator_sv2::lib::downstream_sv1::downstream: Down: Subscribing
...

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:

Scherm­afbeelding 2024-04-17 om 12 38 32

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

Scherm­afbeelding 2024-04-17 om 12 45 30

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.

@emsit
Copy link

emsit commented Apr 17, 2024

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?

@Sjors
Copy link
Collaborator Author

Sjors commented Apr 17, 2024

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.

@Sjors
Copy link
Collaborator Author

Sjors commented Apr 19, 2024

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?

@Sjors
Copy link
Collaborator Author

Sjors commented Apr 19, 2024

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.

@nikicat
Copy link

nikicat commented Apr 19, 2024

@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>

@Sjors
Copy link
Collaborator Author

Sjors commented Apr 19, 2024

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?

@nikicat
Copy link

nikicat commented Apr 19, 2024

What do you mean by this?

#851 this one

seems to be that the miner hangs up

did you try to mine on other/public pools to check the miner?

@Sjors
Copy link
Collaborator Author

Sjors commented Apr 19, 2024

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.

@Sjors
Copy link
Collaborator Author

Sjors commented Apr 19, 2024

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.

@nikicat
Copy link

nikicat commented Apr 19, 2024

Is the race condition in the miner's code/pool's code or somewhere else?

@Sjors
Copy link
Collaborator Author

Sjors commented Apr 19, 2024

No idea.

@Fi3
Copy link
Collaborator

Fi3 commented Apr 20, 2024

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)

@pavlenex
Copy link
Collaborator

So what's a conclusion on this issue @Sjors ?

@Sjors
Copy link
Collaborator Author

Sjors commented Apr 30, 2024

Nothing, it's still unsolved.

@pavlenex pavlenex added the translation proxy SV1>SV2 translation proxy issues label Apr 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
translation proxy SV1>SV2 translation proxy issues
Projects
None yet
Development

No branches or pull requests

5 participants