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

Fix stratum message order #498

Merged
merged 1 commit into from
Nov 21, 2024
Merged

Conversation

mutatrum
Copy link
Contributor

Missing TODO from #84, it should start with mining.configure.

@mutatrum
Copy link
Contributor Author

On Braiins pool, before:

I (17862) stratum_api: tx: {"id": 1, "method": "mining.subscribe", "params": ["bitaxe/BM1368/v2.3.1b1-23-g6d29557"]}
I (17872) stratum_api: tx: {"id": 2, "method": "mining.configure", "params": [["version-rolling"], {"version-rolling.mask": "ffffffff"}]}
I (17882) stratum_api: tx: {"id": 3, "method": "mining.authorize", "params": ["poemechr.bitaxe", "anything123"]}
I (17892) stratum_api: tx: {"id": 4, "method": "mining.suggest_difficulty", "params": [1000]}
I (17952) stratum_task: rx: {"id":1,"result":[[["mining.set_difficulty","1"],["mining.notify","1"]],"00",6],"error":null}
I (17952) stratum_api: extranonce_str: 00
I (17962) stratum_api: extranonce_2_len: 6
I (18042) stratum_task: rx: {"id":2,"result":null,"error":[21,"ConfigurationOutOfOrder",null]}
E (18042) stratum_task: setup message rejected
I (18052) stratum_task: rx: {"id":3,"result":true,"error":null}
I (18062) stratum_task: setup message accepted
I (18062) stratum_task: rx: {"id":4,"result":true,"error":null}
I (18062) stratum_task: setup message accepted

after:

I (17787) stratum_api: tx: {"id": 1, "method": "mining.configure", "params": [["version-rolling"], {"version-rolling.mask": "ffffffff"}]}
I (17797) stratum_api: tx: {"id": 2, "method": "mining.subscribe", "params": ["bitaxe/BM1368/v2.3.1b1-23-g6d29557"]}
I (17807) stratum_api: tx: {"id": 3, "method": "mining.authorize", "params": ["poemechr.bitaxe", "anything123"]}
I (17817) stratum_api: tx: {"id": 4, "method": "mining.suggest_difficulty", "params": [1000]}
I (17827) stratum_task: rx: {"id":1,"result":{"version-rolling":true,"version-rolling.mask":"1fffe000"},"error":null}
I (17837) stratum_api: Set version mask: 1fffe000
I (17837) stratum_task: Set version mask: 1fffe000
I (17847) stratum_task: rx: {"id":null,"method":"mining.set_version_mask","params":["1fffe000"]}
I (17847) stratum_task: Set version mask: 1fffe000
I (17857) stratum_task: rx: {"id":2,"result":[[["mining.set_difficulty","1"],["mining.notify","1"]],"00",6],"error":null}
I (17867) stratum_api: extranonce_str: 00
I (17867) stratum_api: extranonce_2_len: 6
I (18017) stratum_task: rx: {"id":3,"result":true,"error":null}
I (18017) stratum_task: setup message accepted
I (18017) stratum_task: rx: {"id":4,"result":true,"error":null}
I (18017) stratum_task: setup message accepted

Copy link
Collaborator

@Georges760 Georges760 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Collaborator

@eandersson eandersson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Would you be able to test this on a few other pools as well?

@mutatrum
Copy link
Contributor Author

mutatrum commented Nov 19, 2024

Next to Braiins only ckpool, no difference there. Would be good to have someone check Public and Ocean as well. I haven't set those up yet.

Can anyone enlighten me on what happens if the pool doesn't acknowledge the version mask, as seen in the first log?

@mutatrum
Copy link
Contributor Author

Sidenote: should it actually continue hashing if a setup message failed? At least it should flag it somewhere that the init didn't completely succeeded so the user can be warned.

@mutatrum
Copy link
Contributor Author

mutatrum commented Nov 20, 2024

Ocean before:

I (17778) stratum_api: tx: {"id": 1, "method": "mining.subscribe", "params": ["bitaxe/BM1368/v2.4.0-8-g00b8411-dirty"]}
I (17788) stratum_api: tx: {"id": 2, "method": "mining.configure", "params": [["version-rolling"], {"version-rolling.mask": "ffffffff"}]}
I (17798) stratum_api: tx: {"id": 3, "method": "mining.authorize", "params": ["bc1q######################################.bitaxe", "x"]}
I (17808) stratum_api: tx: {"id": 4, "method": "mining.suggest_difficulty", "params": [1000]}
I (17948) stratum_task: rx: {"error":null,"id":1,"result":[[["mining.notify","b18cf05f1"],["mining.set_difficulty","b18cf05f2"]],"b18cf05f",8]}
I (17958) stratum_task: rx: {"id":null,"method":"mining.set_difficulty","params":[262144]}
I (18368) stratum_task: rx: {"error":null,"id":2,"result":{"version-rolling":true,"version-rolling.mask":"1fffe000"}}
I (18398) stratum_task: rx: {"id":null,"method":"mining.set_version_mask","params":["1fffe000"]}
I (18408) stratum_task: rx: {"error":null,"id":3,"result":true}
I (18418) stratum_task: rx: {"error":[-3,"Method not found",null],"id":4,"result":null}
E (18558) stratum_task: setup message rejected: Method not found

After:

I (18467) stratum_api: tx: {"id": 1, "method": "mining.configure", "params": [["version-rolling"], {"version-rolling.mask": "ffffffff"}]}
I (18477) stratum_api: tx: {"id": 2, "method": "mining.subscribe", "params": ["bitaxe/BM1368/v2.4.0-8-g00b8411"]}
I (18487) stratum_api: tx: {"id": 3, "method": "mining.authorize", "params": ["bc1q######################################.bitaxe", "x"]}
I (18497) stratum_api: tx: {"id": 4, "method": "mining.suggest_difficulty", "params": [1000]}
I (18667) stratum_task: rx: {"error":null,"id":1,"result":{"version-rolling":true,"version-rolling.mask":"1fffe000"}}
I (18677) stratum_task: rx: {"id":null,"method":"mining.set_version_mask","params":["1fffe000"]}
I (18837) stratum_task: rx: {"error":null,"id":2,"result":[[["mining.notify","b34cf02f1"],["mining.set_difficulty","b34cf02f2"]],"b34cf02f",8]}
I (18847) stratum_task: rx: {"id":null,"method":"mining.set_difficulty","params":[262144]}
I (19247) stratum_task: rx: {"error":null,"id":3,"result":true}
I (19277) stratum_task: rx: {"error":[-3,"Method not found",null],"id":4,"result":null}
E (18558) stratum_task: setup message rejected: Method not found

Error on mining.suggest_difficulty seems not relevant.

@mutatrum
Copy link
Contributor Author

Public Pool is also fine. Before:

I (18228) stratum_api: tx: {"id": 1, "method": "mining.subscribe", "params": ["bitaxe/BM1368/v2.4.0-8-g00b8411-dirty"]}
I (18238) stratum_api: tx: {"id": 2, "method": "mining.configure", "params": [["version-rolling"], {"version-rolling.mask": "ffffffff"}]}
I (18248) stratum_api: tx: {"id": 3, "method": "mining.authorize", "params": ["bc1q######################################.bitaxe", "x"]}
I (18258) stratum_api: tx: {"id": 4, "method": "mining.suggest_difficulty", "params": [1000]}
I (18428) stratum_task: rx: {"id":1,"error":null,"result":[[["mining.notify","b7fb32b8"]],"b7fb32b8",4]}
I (18598) stratum_task: rx: {"id":2,"error":null,"result":{"version-rolling":true,"version-rolling.mask":"1fffe000"}}
I (18608) stratum_task: rx: {"id":3,"error":null,"result":true}
I (18618) stratum_task: rx: {"id":null,"method":"mining.set_difficulty","params":[1000]}
I (18638) stratum_task: rx: {"id":null,"method":"mining.notify",

After:

I (17788) stratum_api: tx: {"id": 1, "method": "mining.configure", "params": [["version-rolling"], {"version-rolling.mask": "ffffffff"}]}
I (17798) stratum_api: tx: {"id": 2, "method": "mining.subscribe", "params": ["bitaxe/BM1368/v2.4.0-8-g00b8411-dirty"]}
I (17808) stratum_api: tx: {"id": 3, "method": "mining.authorize", "params": ["bc1q######################################.bitaxe", "x"]}
I (17818) stratum_api: tx: {"id": 4, "method": "mining.suggest_difficulty", "params": [1000]}
I (17988) stratum_task: rx: {"id":1,"error":null,"result":{"version-rolling":true,"version-rolling.mask":"1fffe000"}}
I (18188) stratum_task: rx: {"id":2,"error":null,"result":[[["mining.notify","6c84ea02"]],"6c84ea02",4]}
I (18188) stratum_task: rx: {"id":3,"error":null,"result":true}
I (18198) stratum_task: rx: {"id":null,"method":"mining.set_difficulty","params":[1000]}
I (18218) stratum_task: rx: {"id":null,"method":"mining.notify",

Fun observation: it never responds with id 4 of the mining.suggest_difficulty, but it does accept the suggestion as the only pool I've tested:

I (18258) stratum_api: tx: {"id": 4, "method": "mining.suggest_difficulty", "params": [2000]}
I (18608) stratum_task: rx: {"id":null,"method":"mining.set_difficulty","params":[2000]}

@skot
Copy link
Owner

skot commented Nov 21, 2024

Here are a couple more... is this looking good?

---antpool
I (17482) stratum_task: Connecting to: stratum+tcp://ss.antpool.com:443 (172.65.195.40)
I (17492) stratum_task: Socket created, connecting to 172.65.195.40:443
I (17512) stratum_api: Resetting stratum uid
I (17512) stratum_task: Clean Jobs: clearing queue
I (17512) stratum_api: tx: {"id": 1, "method": "mining.configure", "params": [["version-rolling"], {"version-rolling.mask": "ffffffff"}]}
I (17522) stratum_api: tx: {"id": 2, "method": "mining.subscribe", "params": ["bitaxe/BM1368/v2.4.0-6-g04d027b"]}
I (17542) stratum_api: tx: {"id": 3, "method": "mining.authorize", "params": ["xvf9u.001", "123"]}
I (17542) stratum_api: tx: {"id": 4, "method": "mining.suggest_difficulty", "params": [1000]}
I (17552) stratum_task: rx: {"error":null,"id":1,"result":{"version-rolling":true,"version-rolling.mask":"1fffe000"}}
I (17562) stratum_api: Set version mask: 1fffe000
I (17572) stratum_task: Set version mask: 1fffe000
I (17572) stratum_task: rx: {"error":null,"id":2,"result":[[["mining.notify","0000d85d1"],["mining.set_difficulty","0000d85d2"]],"0000d85d",8]}
I (17592) stratum_api: extranonce_str: 0000d85d
I (17592) stratum_api: extranonce_2_len: 8
I (17612) stratum_task: rx: {"error":[40,"unfit, ignore"],"id":4,"result":null}
E (17612) stratum_task: setup message rejected
I (17662) stratum_task: rx: {"error":null,"id":3,"result":true}
I (17662) stratum_task: setup message accepted
I (17662) stratum_task: rx: {"id":null,"method":"mining.set_difficulty","params":[65536]}

---sbi
I (17482) stratum_task: Connecting to: stratum+tcp://us1.sbicrypto.com:3333 (35.155.64.195)
I (17492) stratum_task: Socket created, connecting to 35.155.64.195:3333
I (17672) stratum_api: Resetting stratum uid
I (17672) stratum_task: Clean Jobs: clearing queue
I (17672) stratum_api: tx: {"id": 1, "method": "mining.configure", "params": [["version-rolling"], {"version-rolling.mask": "ffffffff"}]}
I (17692) stratum_api: tx: {"id": 2, "method": "mining.subscribe", "params": ["bitaxe/BM1368/v2.4.0-6-g04d027b"]}
I (17702) stratum_api: tx: {"id": 3, "method": "mining.authorize", "params": ["skot.001", "123"]}
I (17712) stratum_api: tx: {"id": 4, "method": "mining.suggest_difficulty", "params": [1000]}
I (17882) stratum_task: rx: {"id":1,"result":{"version-rolling":true,"version-rolling.mask":"1fffe000"},"error":null}
I (17882) stratum_api: Set version mask: 1fffe000
I (17892) stratum_task: Set version mask: 1fffe000
I (17892) stratum_task: rx: {"id":null,"method":"mining.set_version_mask","params":["1fffe000"]}
I (17902) stratum_task: Set version mask: 1fffe000
I (18002) stratum_task: rx: {"id":2,"result":[[["mining.set_difficulty","0b1a16cc"],["mining.notify","0b1a16cc"]],"0b1a16cc",8],"error":null}
I (18002) stratum_api: extranonce_str: 0b1a16cc
I (18012) stratum_api: extranonce_2_len: 8
I (18012) stratum_task: rx: {"id":3,"result":true,"error":null}
I (18022) stratum_task: setup message accepted
I (18022) stratum_task: rx: {"id":null,"method":"mining.set_difficulty","params":[16384]}

---emcd
I (17472) stratum_task: Connecting to: stratum+tcp://us.emcd.io:3333 (174.138.94.195)
I (17492) stratum_task: Socket created, connecting to 174.138.94.195:3333
I (17532) stratum_api: Resetting stratum uid
I (17532) stratum_task: Clean Jobs: clearing queue
I (17532) stratum_api: tx: {"id": 1, "method": "mining.configure", "params": [["version-rolling"], {"version-rolling.mask": "ffffffff"}]}
I (17542) stratum_api: tx: {"id": 2, "method": "mining.subscribe", "params": ["bitaxe/BM1368/v2.4.0-6-g04d027b"]}
I (17552) stratum_api: tx: {"id": 3, "method": "mining.authorize", "params": ["skot.001", "123"]}
I (17562) stratum_api: tx: {"id": 4, "method": "mining.suggest_difficulty", "params": [1000]}
I (17872) stratum_task: rx: {"error":null,"id":1,"result":{"version-rolling":true,"version-rolling.mask":"1fffe000"}}
I (17882) stratum_api: Set version mask: 1fffe000
I (17882) stratum_task: Set version mask: 1fffe000
I (17882) stratum_task: rx: {"error":null,"id":2,"result":[[["mining.notify","00002ffc1"],["mining.set_difficulty","00002ffc2"]],"00002ffc",4]}
I (17902) stratum_api: extranonce_str: 00002ffc
I (17902) stratum_api: extranonce_2_len: 4
I (17912) stratum_task: rx: {"error":[40,"unfit, ignore"],"id":4,"result":null}
E (17922) stratum_task: setup message rejected
I (17922) stratum_task: rx: {"error":null,"id":3,"result":true}
I (17932) stratum_task: setup message accepted
I (17932) stratum_task: rx: {"id":0,"method":"mining.set_difficulty","params":[65536]}

---lincoin
I (17482) stratum_task: Connecting to: stratum+tcp://na.lincoin.com:3333 (216.128.176.190)
I (17492) stratum_task: Socket created, connecting to 216.128.176.190:3333
I (17532) stratum_api: Resetting stratum uid
I (17532) stratum_task: Clean Jobs: clearing queue
I (17532) stratum_api: tx: {"id": 1, "method": "mining.configure", "params": [["version-rolling"], {"version-rolling.mask": "ffffffff"}]}
I (17552) stratum_api: tx: {"id": 2, "method": "mining.subscribe", "params": ["bitaxe/BM1368/v2.4.0-6-g04d027b"]}
I (17562) stratum_api: tx: {"id": 3, "method": "mining.authorize", "params": ["xvf9u.worker1", "123"]}
I (17572) stratum_api: tx: {"id": 4, "method": "mining.suggest_difficulty", "params": [1000]}
I (17782) stratum_task: rx: {"id":1,"result":{"version-rolling":true,"version-rolling.mask":"1fffe000"},"error":null}
I (17782) stratum_api: Set version mask: 1fffe000
I (17792) stratum_task: Set version mask: 1fffe000
I (17792) stratum_task: rx: {"id":null,"method":"mining.set_version_mask","params":["1fffe000"]}
I (17802) stratum_task: Set version mask: 1fffe000
I (17812) stratum_task: rx: {"id":2,"result":[[["mining.set_difficulty","021a60e3"],["mining.notify","021a60e3"]],"021a60e3",8],"error":null}
I (17822) stratum_api: extranonce_str: 021a60e3
I (17822) stratum_api: extranonce_2_len: 8
I (17832) stratum_task: rx: {"id":3,"result":true,"error":null}
I (17842) stratum_task: setup message accepted
I (17842) stratum_task: rx: {"id":null,"method":"mining.set_difficulty","params":[16384]}

---luxor
I (17762) stratum_task: Connecting to: stratum+tcp://btc.global.luxor.tech:700 (34.117.46.215)
I (17762) stratum_task: Socket created, connecting to 34.117.46.215:700
I (17782) stratum_api: Resetting stratum uid
I (17782) stratum_task: Clean Jobs: clearing queue
I (17782) stratum_api: tx: {"id": 1, "method": "mining.configure", "params": [["version-rolling"], {"version-rolling.mask": "ffffffff"}]}
I (17802) stratum_api: tx: {"id": 2, "method": "mining.subscribe", "params": ["bitaxe/BM1368/v2.4.0-6-g04d027b"]}
I (17812) stratum_api: tx: {"id": 3, "method": "mining.authorize", "params": ["skot.001", "123"]}
I (17822) stratum_api: tx: {"id": 4, "method": "mining.suggest_difficulty", "params": [1000]}
I (17842) stratum_task: rx: {"id":1,"result":{"version-rolling":true,"version-rolling.mask":"1fffe000"},"error":null}
I (17842) stratum_api: Set version mask: 1fffe000
I (17842) stratum_task: Set version mask: 1fffe000
I (17852) stratum_task: rx: {"id":null,"method":"mining.set_version_mask","params":["1fffe000"]}
I (17862) stratum_task: Set version mask: 1fffe000
I (17872) stratum_task: rx: {"id":4,"result":false,"error":[20,"not supported",null]}
E (17882) stratum_task: setup message rejected
I (18192) stratum_task: rx: {"id":2,"result":[[["mining.notify","00"],["mining.set_difficulty","00"]],"00",7],"error":null}
I (18192) stratum_api: extranonce_str: 00
I (18192) stratum_api: extranonce_2_len: 7
I (18202) stratum_task: rx: {"id":null,"method":"mining.set_difficulty","params":[65536]}

@mutatrum
Copy link
Contributor Author

LGTM, they all respond with the version mask set, which is the response on the mining.configure.

There might need to a bit better handing of setup message errors, f.e. the antpool with the unfit, ignore response. But that's a different issue.

Copy link
Collaborator

@eandersson eandersson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@skot skot merged commit 48711ef into skot:master Nov 21, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants