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

Don't abandon the first mining.notify #492

Merged
merged 1 commit into from
Nov 20, 2024
Merged

Don't abandon the first mining.notify #492

merged 1 commit into from
Nov 20, 2024

Conversation

eandersson
Copy link
Collaborator

@eandersson eandersson commented Nov 18, 2024

When we call cleanQueue during the connection setup phase, it sets abandon_work to 1 and does not clear it until after processing the first mining.notify. As a result, we were effectively abandoning all of the work from the first mining.notify, leading to a loss of hashing performance at startup until the second mining.notify from the pool arrives which can take 30 seconds or more depending on the pool.

@mutatrum
Copy link
Contributor

Verified behaviour before and after patch.

@mutatrum
Copy link
Contributor

Verification of change working, an accepted share almost immediately after the first mining.notify after startup:

I (18228) stratum_api: tx: {"id": 1, "method": "mining.configure", "params": [["version-rolling"], {"version-rolling.mask": "ffffffff"}]}
I (18238) stratum_api: tx: {"id": 2, "method": "mining.subscribe", "params": ["bitaxe/BM1368/v2.4.0-8-g00b8411"]}
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 (18438) stratum_task: rx: {"result":{"version-rolling":true,"version-rolling.mask":"1fffe000"},"id":1,"error":null}
I (18438) stratum_api: Set version mask: 1fffe000
I (18438) stratum_task: Set version mask: 1fffe000
I (18548) stratum_task: rx: {"result":[[["mining.notify","803fb29a"]],"b9280b7b",8],"id":2,"error":null}
I (18548) stratum_api: extranonce_str: b9280b7b
I (18548) stratum_api: extranonce_2_len: 8
I (18548) stratum_task: rx: {"params":[10000],"id":null,"method":"mining.set_difficulty"}
I (18558) stratum_task: Set stratum difficulty: 10000
I (18568) stratum_task: rx: {"params":["64851638001868c5","16d4be36a72550c5e03b6ac7fa9bdb68fd8d6651000111f60000000000000000","01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff35031e4b0d0004f9f03d67042140560b0c","0a636b706f6f6c112f736f6c6f2e636b706f6f6c2e6f72672fffffffff03cb94c7120000000016001480bded37e3f86a1a546e099b15e2b02855d3843c281d62000000000016001451ed61d2f6aa260cc72cdf743e4e436a82c010270000000000000000266a24aa21a9ed21b4c43595f77cf0210b8336131c799e86f4726ebeb831b2547100ed1b63b62800000000",["e4ed727027c8906b6c1b62982ab9249d6286a479593f69f281ffbb3c8b121d17","c479cbbf677019fa9d6f82e4ca2355eddae3089606ac34667edf82073fcab65f","d493ef915e52c7ff0034f42691386cd4309a0150197250a20ea5cfbad1ad2185","0c166434a21815619b42611bc3a4ecee18533a00de89742e5e7139d7d574c4a8","fb34147c076a28cff5c5a4d2a31c65a2b08de7eb8e5108ee2463f7617967ad82","fcb007f9e78c28dd6be6be3ef53dc0fd17f23019bee229dfd5b80d43a5e20c15","03a80f7a80a9a5783d1010bb950d52a1e85f88800b6bee06979bd53a67183123","a42903949d97db7c3fa00dde0542441f83eddac8d455d2185ec2f063e8418b29","6612f69a543265ac03239ef448ad36d682d47aa2f2d221ba492352a027fdf771","139286fe91d50a39e835950936b872accd49fd62cf8493c60d019edd5deba57a","767f6fbb5502625933dfcf396f8dbb535c470bd0445d7ffbe1711dca462a54d4","8b8a095d2594710c8ada98ba6e8d77ff37c9722246dc580fc7ea6038bc486043","508545591148cd22a9d05fdd09589fbd45bbb6c86a4e2adbb032d25f868ffa73"],"20000000","1702c070","673df0f9",true],"id":null,"method":"mining.notify"}
I (18698) SystemModule: Syncing clock
I (18698) create_jobs_task: Set chip version rolls 65535
I (18698) stratum_task: rx: {"params":[10000],"id":null,"method":"mining.set_difficulty"}
I (18698) create_jobs_task: New Work Dequeued 64851638001868c5
I (18718) ASIC_task: New pool difficulty 10000
I (18718) stratum_task: rx: {"result":true,"error":null,"id":3}
I (18728) stratum_task: setup message accepted
I (20228) bm1368Module: Job ID: 60, Core: 75/14, Ver: 003DC000
I (20228) asic_result: Ver: 203DC000 Nonce AFF70196 diff 768.8 of 10000.
I (20668) bm1368Module: Job ID: 60, Core: 60/9, Ver: 07E12000
I (20678) asic_result: Ver: 27E12000 Nonce 9EB30278 diff 331.5 of 10000.
I (22068) bm1368Module: Job ID: 28, Core: 57/14, Ver: 060BC000
I (22068) asic_result: Ver: 260BC000 Nonce 8C5B0172 diff 120251.6 of 10000.
I (22068) stratum_api: tx: {"id": 5, "method": "mining.submit", "params": ["bc1q######################################.bitaxe", "64851638001868c5", "0600000000000000", "673df0f9", "8c5b0172", "060bc000"]}
I (22228) stratum_task: rx: {"result":true,"error":null,"id":5}
I (22228) stratum_task: message result accepted

@skot
Copy link
Owner

skot commented Nov 20, 2024

Confirmed this works on 601 and 401, nice job @eandersson !

before, no nonces from first mining.notify

I (17707) stratum_task: rx: {"id":3,"error":null,"result":true}
I (17717) stratum_task: setup message accepted
I (17717) stratum_task: rx: {"id":null,"method":"mining.set_difficulty","params":[1000]}
I (17727) stratum_task: Set stratum difficulty: 1000
I (17737) stratum_task: rx: {"id":null,"method":"mining.notify","params":["50c909d","6fecd83de73c9a3e0da33ff7cd3289c51ea71a170000b8900000000000000000","02000000010000000000000000000000000000000000000000000000000000000000000000ffffffff1703214b0d5075626c69632d506f6f6c","ffffffff02a9349613000000001600140587968c66c3c209070409edc88c95d66af586af0000000000000000266a24aa21a9ed7f75e097ca9f5334e16d7ea06cb0fa72317497867712b732dfa8f3f2709cb55a00000000",["10e96931e3b72063dd0a587777c03439bfedf61ca4fc536481e7e3902f8d32fd","db50a373b7dc4830489e6b39fc06b87041c7ff35797cfb930d481bae55d02058","3d11eeed262a21186ea2714ebd09dcdea6f847e95a9e5c495a99fd8331353815","31833ad230439aa078c170990095ccc0be572e64963eb3b43c81d44bf44374c0","61281947fcbe4a46639cdee4ba737864a3e468e3adb0b9136fd7e24dddd96186","9c6d188e6cef0346d021e0c35dcf933b8a3d7a25282bbea45ac1110d4661b852","5e44ffee8e966ca0dc4b858a0d796c2cfa8969b60f2bc4ddbb111941f924b1d4","3face88a284cd4cea6ceb097b3d767c022b07f93aa199528e04e5a7547fcc6a9","aca44fa9d0f45965f774275936a9b1924f6268fafec55d9c0d0f1498d3b05af5","92090adf8490c568cd9f441d839d1a85c18f83a5f425634c098bc743950f50e5","597ce5db2f1d11bfaaf23408100ade7e19cba947637a4998a6810e9ee25c59b0","1fa9cb28e3e963489a3d17fbb4e024a9faad6efa99c064535f13a5315197a903","e7658c57641b2d6dab5cb89f825c5cd5502e3035bfb548eaee488318061d1da7"],"20000000","1702c070","673df789",true]}
I (17857) SystemModule: Syncing clock
I (17857) create_jobs_task: Set chip version rolls 65535
I (17867) create_jobs_task: New Work Dequeued 50c909d
I (17867) create_jobs_task: Job processed and queued: 50c909d
I (17867) ASIC_task: New pool difficulty 1000
I (51917) stratum_task: rx: {"id":null,"method":"mining.notify","params":["50c90b7","6fecd83de73c9a3e0da33ff7cd3289c51ea71a170000b8900000000000000000","02000000010000000000000000000000000000000000000000000000000000000000000000ffffffff1703214b0d5075626c69632d506f6f6c","ffffffff0202c99a13000000001600140587968c66c3c209070409edc88c95d66af586af0000000000000000266a24aa21a9edde3648b69b8c68b195e9b6479ff5457e1ff0b7e177c9f701d79b69e359617f2b00000000",["10e96931e3b72063dd0a587777c03439bfedf61ca4fc536481e7e3902f8d32fd","db50a373b7dc4830489e6b39fc06b87041c7ff35797cfb930d481bae55d02058","3d11eeed262a21186ea2714ebd09dcdea6f847e95a9e5c495a99fd8331353815","31833ad230439aa078c170990095ccc0be572e64963eb3b43c81d44bf44374c0","61281947fcbe4a46639cdee4ba737864a3e468e3adb0b9136fd7e24dddd96186","dec19af4d9a019675bd1eb79676c3e70e769eab3657ef2e2e9ca834076aca314","5e1230b2b3433355f15dcd9ecb3156513460d77dc150742af9f6e8700fb9332e","b71eadd2bcb45059e15622fb16c721cb7ce9bab9f2811e38600bb1358f0e0e15","18b430ecb7bd6e2255a70f8774650adeb5bac93966b06a200b9e94aaafa88fca","6ed668fa4e12ba70393e0231f67ebe938973283b4cfafab253a4ea4ee5025457","d164b8f31af07adfad785dfc6dd30f2439e2357acee342bd8fd9d3d78ed5a5dc","6792b4aae3d3c52dedf827496181fdf27eb7a5664b72b22a5bc9e03a16ea423e","0a128d12c09a59a2982b6406240c1c9b6838b4050769f19052dbc2bf64f5cc75"],"20000000","1702c070","673df7c5",false]}
I (52027) create_jobs_task: New Work Dequeued 50c90b7
I (52037) create_jobs_task: Job processed and queued: 50c90b7
I (52157) bm1368Module: Job ID: 30, Core: 30/13, Ver: 0207A000
I (52157) asic_result: Ver: 2207A000 Nonce 0432023C diff 852.1 of 1000.

after, with nonces after first mining.notify:

I (17693) stratum_task: rx: {"id":3,"error":null,"result":true}
I (17703) stratum_task: setup message accepted
I (17703) stratum_task: rx: {"id":null,"method":"mining.set_difficulty","params":[1000000]}
I (17713) stratum_task: Set stratum difficulty: 1000000
I (17723) stratum_task: rx: {"id":null,"method":"mining.notify","params":["52ecb69","6fecd83de73c9a3e0da33ff7cd3289c51ea71a170000b8900000000000000000","02000000010000000000000000000000000000000000000000000000000000000000000000ffffffff1703214b0d5075626c69632d506f6f6c","ffffffff02f1f3a013000000001600140587968c66c3c209070409edc88c95d66af586af0000000000000000266a24aa21a9ed053453646ce4b9f4b58bf459f7b7e877974a0dcd988e1bf8f3c2262242e2531300000000",["10e96931e3b72063dd0a587777c03439bfedf61ca4fc536481e7e3902f8d32fd","db50a373b7dc4830489e6b39fc06b87041c7ff35797cfb930d481bae55d02058","3d11eeed262a21186ea2714ebd09dcdea6f847e95a9e5c495a99fd8331353815","31833ad230439aa078c170990095ccc0be572e64963eb3b43c81d44bf44374c0","baca25c2b16e2b6a45f6c2acea07ec963986406871e99e0c440aeb9a5a2ed189","9fa92abdfaf560f3d9117a5abcb78c6506042267d62c476c7af76545b1381176","4150d59893f2cc8c998a7265d065e1eb69ef6ff3dc01bd92095204bb2e6c6bc4","18c90ce747de5f8c11abccdfad73e4123fa7a0b1cdf41a817a19cd85ea333f71","a1cf450d474ac63f56076fd312d2ac1d367f2241f10cd86b22041b6f3364a48f","272941dd543895bad941362835e4684d3dc7531608e8fd9810a2d4b11fc509fc","f816fdf97e89c933a84f9aa5a8bc93a2c4c3082c892d0cfa5e96b6aabb89a126","9d07ec78054e4ee195d564dd5590dbfaa9c7a0d7df2c15ea91752bda23811b24","2780c1ebbe6b1570787b9c4a3aa51698f460b66e481b812f233e8628c73832df"],"20000000","1702c070","673df808",true]}
I (17843) SystemModule: Syncing clock
I (17843) create_jobs_task: Set chip version rolls 65535
I (17843) stratum_task: rx: {"id":null,"method":"mining.set_difficulty","params":[1000]}
I (17853) create_jobs_task: New Work Dequeued 52ecb69
I (17863) stratum_task: Set stratum difficulty: 1000
I (17863) create_jobs_task: Job processed and queued: 52ecb69
I (17863) ASIC_task: New pool difficulty 1000000
I (19633) bm1368Module: Job ID: 60, Core: 70/5, Ver: 0466A000
I (19633) asic_result: Ver: 2466A000 Nonce 2A84028C diff 485.8 of 1000000.
I (20093) bm1368Module: Job ID: 78, Core: 17/7, Ver: 0396E000
I (20093) asic_result: Ver: 2396E000 Nonce 9ACE0222 diff 1196.8 of 1000000.

@skot skot merged commit d22b956 into master Nov 20, 2024
2 checks passed
@eandersson eandersson deleted the abandon_work branch November 29, 2024 08:25
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.

3 participants