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

Improve coinbase #1248

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open

Improve coinbase #1248

wants to merge 8 commits into from

Conversation

Fi3
Copy link
Collaborator

@Fi3 Fi3 commented Nov 13, 2024

Better management of the coinbase's input script:

  • rename the pool signature field of the channel factory into coinbase_script_additional_data, and change the type from String to Vec<u8>. Sv2 do not say anything about pool's signature, but we still want to let the user add some arbitrary data and the beginning of the extranonce. We do not assume that this data is a pool signature. We do not assume that this data is valid utf8.
  • send downstream coinbase_script_additional_data as part of the extranonce_prefix and not as part of the coinbase_prefix. This make the implementation of a JDC more straightforward, as it do not need anymore to observe the jobs sent and created by the pool and reconstruct and parse the coinbase to know the coinbase_script_additional_data.
  • add a method that the pool can use in order to change coinbase_script_additional_data of an already opened channel and send downstream the new extranonce_prefix

Copy link
Contributor

github-actions bot commented Nov 13, 2024

🐰 Bencher Report

BranchImproveCoinbase
Testbedsv1
Click to view all benchmark results
BenchmarkLatencyBenchmark Result
nanoseconds (ns)
(Result Δ%)
Upper Boundary
nanoseconds (ns)
(Limit %)
client-submit-serialize📈 view plot
🚷 view threshold
6,925.80
(+2.79%)
7,406.19
(93.51%)
client-submit-serialize-deserialize📈 view plot
🚷 view threshold
8,009.20
(+4.30%)
8,620.00
(92.91%)
client-submit-serialize-deserialize-handle/client-submit-serialize-deserialize-handle📈 view plot
🚷 view threshold
8,577.20
(+4.19%)
9,241.13
(92.82%)
client-sv1-authorize-serialize-deserialize-handle/client-sv1-authorize-serialize-deserialize-handle📈 view plot
🚷 view threshold
880.92
(+0.93%)
947.47
(92.98%)
client-sv1-authorize-serialize-deserialize/client-sv1-authorize-serialize-deserialize📈 view plot
🚷 view threshold
679.23
(+0.87%)
735.27
(92.38%)
client-sv1-authorize-serialize/client-sv1-authorize-serialize📈 view plot
🚷 view threshold
247.14
(-0.50%)
261.99
(94.33%)
client-sv1-get-authorize/client-sv1-get-authorize📈 view plot
🚷 view threshold
156.14
(-0.78%)
165.70
(94.23%)
client-sv1-get-submit📈 view plot
🚷 view threshold
6,557.50
(+1.01%)
7,201.26
(91.06%)
client-sv1-get-subscribe/client-sv1-get-subscribe📈 view plot
🚷 view threshold
283.91
(+1.77%)
304.80
(93.15%)
client-sv1-subscribe-serialize-deserialize-handle/client-sv1-subscribe-serialize-deserialize-handle📈 view plot
🚷 view threshold
734.43
(+0.09%)
810.26
(90.64%)
client-sv1-subscribe-serialize-deserialize/client-sv1-subscribe-serialize-deserialize📈 view plot
🚷 view threshold
595.80
(-0.16%)
633.56
(94.04%)
client-sv1-subscribe-serialize/client-sv1-subscribe-serialize📈 view plot
🚷 view threshold
211.61
(+1.80%)
231.78
(91.30%)
🐰 View full continuous benchmarking report in Bencher

Copy link
Contributor

github-actions bot commented Nov 13, 2024

🐰 Bencher Report

BranchImproveCoinbase
Testbedsv1
Click to view all benchmark results
BenchmarkEstimated CyclesBenchmark Result
estimated cycles
(Result Δ%)
Upper Boundary
estimated cycles
(Limit %)
InstructionsBenchmark Result
instructions
(Result Δ%)
Upper Boundary
instructions
(Limit %)
L1 AccessesBenchmark Result
accesses
(Result Δ%)
Upper Boundary
accesses
(Limit %)
L2 AccessesBenchmark Result
accesses
(Result Δ%)
Upper Boundary
accesses
(Limit %)
RAM AccessesBenchmark Result
accesses
(Result Δ%)
Upper Boundary
accesses
(Limit %)
get_authorize📈 view plot
🚷 view threshold
8,323.00
(-1.56%)
8,831.78
(94.24%)
📈 view plot
🚷 view threshold
3,689.00
(-1.55%)
3,892.73
(94.77%)
📈 view plot
🚷 view threshold
5,158.00
(-1.84%)
5,462.67
(94.42%)
📈 view plot
🚷 view threshold
10.00
(+39.13%)
12.94
(77.27%)
📈 view plot
🚷 view threshold
89.00
(-1.56%)
96.20
(92.52%)
get_submit📈 view plot
🚷 view threshold
95,385.00
(-0.05%)
96,077.26
(99.28%)
📈 view plot
🚷 view threshold
59,346.00
(-0.20%)
59,768.99
(99.29%)
📈 view plot
🚷 view threshold
85,220.00
(-0.22%)
85,855.47
(99.26%)
📈 view plot
🚷 view threshold
45.00
(-0.40%)
64.63
(69.63%)
📈 view plot
🚷 view threshold
284.00
(+1.48%)
289.44
(98.12%)
get_subscribe📈 view plot
🚷 view threshold
7,808.00
(-2.55%)
8,390.51
(93.06%)
📈 view plot
🚷 view threshold
2,765.00
(-2.41%)
2,972.69
(93.01%)
📈 view plot
🚷 view threshold
3,848.00
(-2.84%)
4,155.87
(92.59%)
📈 view plot
🚷 view threshold
15.00
(+25.08%)
20.72
(72.40%)
📈 view plot
🚷 view threshold
111.00
(-2.68%)
120.20
(92.35%)
serialize_authorize📈 view plot
🚷 view threshold
12,146.00
(-1.03%)
12,654.41
(95.98%)
📈 view plot
🚷 view threshold
5,266.00
(-0.99%)
5,462.52
(96.40%)
📈 view plot
🚷 view threshold
7,326.00
(-1.23%)
7,624.00
(96.09%)
📈 view plot
🚷 view threshold
12.00
(+32.30%)
15.87
(75.61%)
📈 view plot
🚷 view threshold
136.00
(-1.05%)
143.65
(94.68%)
serialize_deserialize_authorize📈 view plot
🚷 view threshold
24,306.00
(-1.52%)
25,290.58
(96.11%)
📈 view plot
🚷 view threshold
9,838.00
(-0.53%)
10,056.69
(97.83%)
📈 view plot
🚷 view threshold
13,891.00
(-0.51%)
14,212.41
(97.74%)
📈 view plot
🚷 view threshold
32.00
(-7.89%)
44.28
(72.27%)
📈 view plot
🚷 view threshold
293.00
(-2.74%)
315.89
(92.75%)
serialize_deserialize_handle_authorize📈 view plot
🚷 view threshold
29,988.00
(-1.08%)
30,800.49
(97.36%)
📈 view plot
🚷 view threshold
12,015.00
(-0.54%)
12,227.44
(98.26%)
📈 view plot
🚷 view threshold
17,008.00
(-0.58%)
17,321.77
(98.19%)
📈 view plot
🚷 view threshold
55.00
(-1.29%)
68.29
(80.54%)
📈 view plot
🚷 view threshold
363.00
(-1.73%)
382.00
(95.03%)
serialize_deserialize_handle_submit📈 view plot
🚷 view threshold
126,365.00
(-0.08%)
127,147.96
(99.38%)
📈 view plot
🚷 view threshold
73,200.00
(-0.12%)
73,652.02
(99.39%)
📈 view plot
🚷 view threshold
104,915.00
(-0.14%)
105,611.11
(99.34%)
📈 view plot
🚷 view threshold
104.00
(-2.93%)
133.58
(77.85%)
📈 view plot
🚷 view threshold
598.00
(+0.30%)
605.55
(98.75%)
serialize_deserialize_handle_subscribe📈 view plot
🚷 view threshold
27,372.00
(-1.62%)
28,654.99
(95.52%)
📈 view plot
🚷 view threshold
9,584.00
(-0.65%)
9,791.58
(97.88%)
📈 view plot
🚷 view threshold
13,552.00
(-0.68%)
13,852.74
(97.83%)
📈 view plot
🚷 view threshold
62.00
(-2.28%)
75.99
(81.59%)
📈 view plot
🚷 view threshold
386.00
(-2.53%)
417.31
(92.50%)
serialize_deserialize_submit📈 view plot
🚷 view threshold
115,125.00
(-0.10%)
115,962.10
(99.28%)
📈 view plot
🚷 view threshold
68,060.00
(-0.06%)
68,477.12
(99.39%)
📈 view plot
🚷 view threshold
97,655.00
(-0.08%)
98,312.69
(99.33%)
📈 view plot
🚷 view threshold
64.00
(+1.84%)
78.56
(81.47%)
📈 view plot
🚷 view threshold
490.00
(-0.20%)
499.68
(98.06%)
serialize_deserialize_subscribe📈 view plot
🚷 view threshold
22,808.00
(-1.87%)
24,080.37
(94.72%)
📈 view plot
🚷 view threshold
8,143.00
(-0.72%)
8,348.13
(97.54%)
📈 view plot
🚷 view threshold
11,468.00
(-0.74%)
11,760.13
(97.52%)
📈 view plot
🚷 view threshold
35.00
(-6.20%)
44.71
(78.28%)
📈 view plot
🚷 view threshold
319.00
(-2.93%)
349.15
(91.36%)
serialize_submit📈 view plot
🚷 view threshold
99,766.00
(-0.08%)
100,462.42
(99.31%)
📈 view plot
🚷 view threshold
61,408.00
(-0.16%)
61,811.62
(99.35%)
📈 view plot
🚷 view threshold
88,081.00
(-0.20%)
88,699.59
(99.30%)
📈 view plot
🚷 view threshold
48.00
(+2.16%)
65.18
(73.64%)
📈 view plot
🚷 view threshold
327.00
(+0.77%)
334.08
(97.88%)
serialize_subscribe📈 view plot
🚷 view threshold
11,249.00
(-1.28%)
11,768.37
(95.59%)
📈 view plot
🚷 view threshold
4,118.00
(-1.50%)
4,318.33
(95.36%)
📈 view plot
🚷 view threshold
5,709.00
(-1.86%)
6,011.26
(94.97%)
📈 view plot
🚷 view threshold
16.00
(+24.73%)
20.54
(77.90%)
📈 view plot
🚷 view threshold
156.00
(-0.96%)
164.13
(95.05%)
🐰 View full continuous benchmarking report in Bencher

Copy link
Contributor

github-actions bot commented Nov 13, 2024

🐰 Bencher Report

BranchImproveCoinbase
Testbedsv2
Click to view all benchmark results
BenchmarkLatencyBenchmark Result
nanoseconds (ns)
(Result Δ%)
Upper Boundary
nanoseconds (ns)
(Limit %)
client_sv2_handle_message_common📈 view plot
🚷 view threshold
44.25
(-0.88%)
47.71
(92.74%)
client_sv2_handle_message_mining📈 view plot
🚷 view threshold
75.23
(-0.52%)
86.82
(86.66%)
client_sv2_mining_message_submit_standard📈 view plot
🚷 view threshold
14.66
(-0.02%)
14.70
(99.76%)
client_sv2_mining_message_submit_standard_serialize📈 view plot
🚷 view threshold
270.42
(+1.30%)
324.58
(83.31%)
client_sv2_mining_message_submit_standard_serialize_deserialize📈 view plot
🚷 view threshold
619.39
(+4.12%)
710.23
(87.21%)
client_sv2_open_channel📈 view plot
🚷 view threshold
149.25
(+1.31%)
155.23
(96.15%)
client_sv2_open_channel_serialize📈 view plot
🚷 view threshold
288.30
(+0.58%)
316.12
(91.20%)
client_sv2_open_channel_serialize_deserialize📈 view plot
🚷 view threshold
403.24
(+6.15%)
453.33
(88.95%)
client_sv2_setup_connection📈 view plot
🚷 view threshold
167.76
(+3.52%)
185.19
(90.59%)
client_sv2_setup_connection_serialize📈 view plot
🚷 view threshold
452.81
(-1.82%)
571.70
(79.20%)
client_sv2_setup_connection_serialize_deserialize📈 view plot
🚷 view threshold
984.33
(+1.43%)
1,081.64
(91.00%)
🐰 View full continuous benchmarking report in Bencher

Copy link
Contributor

github-actions bot commented Nov 13, 2024

🐰 Bencher Report

BranchImproveCoinbase
Testbedsv2
🚨 2 ALERTS: Threshold Boundary Limits exceeded!
BenchmarkMeasure
Units
ViewBenchmark Result
(Result Δ%)
Lower Boundary
(Limit %)
Upper Boundary
(Limit %)
client_sv2_mining_message_submit_standard_serialize_deserializeInstructions
instructions
📈 plot
🚨 alert
🚷 threshold
10,645.00
(+0.62%)
10,643.34
(100.02%)
client_sv2_mining_message_submit_standard_serialize_deserializeL1 Accesses
accesses
📈 plot
🚨 alert
🚷 threshold
15,506.00
(+0.73%)
15,494.92
(100.07%)
Click to view all benchmark results
BenchmarkEstimated CyclesBenchmark Result
estimated cycles
(Result Δ%)
Upper Boundary
estimated cycles
(Limit %)
InstructionsBenchmark Result
instructions
(Result Δ%)
Upper Boundary
instructions
(Limit %)
L1 AccessesBenchmark Result
accesses
(Result Δ%)
Upper Boundary
accesses
(Limit %)
L2 AccessesBenchmark Result
accesses
(Result Δ%)
Upper Boundary
accesses
(Limit %)
RAM AccessesBenchmark Result
accesses
(Result Δ%)
Upper Boundary
accesses
(Limit %)
client_sv2_handle_message_common📈 view plot
🚷 view threshold
2,061.00
(-1.48%)
2,203.59
(93.53%)
📈 view plot
🚷 view threshold
473.00
(-0.04%)
488.74
(96.78%)
📈 view plot
🚷 view threshold
736.00
(+0.04%)
757.86
(97.12%)
📈 view plot
🚷 view threshold
6.00
(+9.56%)
14.23
(42.18%)
📈 view plot
🚷 view threshold
37.00
(-2.55%)
41.10
(90.03%)
client_sv2_handle_message_mining📈 view plot
🚷 view threshold
8,132.00
(-0.88%)
8,290.79
(98.08%)
📈 view plot
🚷 view threshold
2,137.00
(-0.03%)
2,143.08
(99.72%)
📈 view plot
🚷 view threshold
3,162.00
(+0.04%)
3,170.59
(99.73%)
📈 view plot
🚷 view threshold
35.00
(-1.58%)
42.23
(82.88%)
📈 view plot
🚷 view threshold
137.00
(-1.46%)
141.01
(97.15%)
client_sv2_mining_message_submit_standard📈 view plot
🚷 view threshold
6,221.00
(-0.90%)
6,387.53
(97.39%)
📈 view plot
🚷 view threshold
1,750.00
(-0.04%)
1,767.13
(99.03%)
📈 view plot
🚷 view threshold
2,551.00
(-0.10%)
2,576.14
(99.02%)
📈 view plot
🚷 view threshold
20.00
(+17.49%)
24.77
(80.75%)
📈 view plot
🚷 view threshold
102.00
(-1.89%)
107.00
(95.33%)
client_sv2_mining_message_submit_standard_serialize📈 view plot
🚷 view threshold
14,652.00
(-0.53%)
14,965.54
(97.90%)
📈 view plot
🚷 view threshold
4,694.00
(-0.02%)
4,711.13
(99.64%)
📈 view plot
🚷 view threshold
6,757.00
(-0.02%)
6,782.84
(99.62%)
📈 view plot
🚷 view threshold
46.00
(+5.65%)
53.54
(85.92%)
📈 view plot
🚷 view threshold
219.00
(-1.15%)
227.74
(96.16%)
client_sv2_mining_message_submit_standard_serialize_deserialize📈 view plot
🚷 view threshold
27,716.00
(+0.69%)
27,738.93
(99.92%)
📈 view plot
🚨 view alert
🚷 view threshold
10,645.00
(+0.62%)
10,643.34
(100.02%)
📈 view plot
🚨 view alert
🚷 view threshold
15,506.00
(+0.73%)
15,494.92
(100.07%)
📈 view plot
🚷 view threshold
90.00
(+10.54%)
90.23
(99.75%)
📈 view plot
🚷 view threshold
336.00
(+0.29%)
341.25
(98.46%)
client_sv2_open_channel📈 view plot
🚷 view threshold
4,345.00
(-1.17%)
4,611.81
(94.21%)
📈 view plot
🚷 view threshold
1,461.00
(-0.01%)
1,476.74
(98.93%)
📈 view plot
🚷 view threshold
2,160.00
(+0.02%)
2,185.43
(98.84%)
📈 view plot
🚷 view threshold
10.00
(+11.21%)
17.75
(56.35%)
📈 view plot
🚷 view threshold
61.00
(-2.61%)
68.39
(89.20%)
client_sv2_open_channel_serialize📈 view plot
🚷 view threshold
14,012.00
(-0.35%)
14,448.78
(96.98%)
📈 view plot
🚷 view threshold
5,064.00
(-0.00%)
5,079.74
(99.69%)
📈 view plot
🚷 view threshold
7,327.00
(+0.02%)
7,353.18
(99.64%)
📈 view plot
🚷 view threshold
35.00
(-0.40%)
43.37
(80.71%)
📈 view plot
🚷 view threshold
186.00
(-0.75%)
198.59
(93.66%)
client_sv2_open_channel_serialize_deserialize📈 view plot
🚷 view threshold
22,782.00
(+0.53%)
22,902.78
(99.47%)
📈 view plot
🚷 view threshold
8,040.00
(+0.25%)
8,074.89
(99.57%)
📈 view plot
🚷 view threshold
11,692.00
(+0.22%)
11,755.39
(99.46%)
📈 view plot
🚷 view threshold
83.00
(+11.57%)
85.27
(97.34%)
📈 view plot
🚷 view threshold
305.00
(+0.48%)
311.74
(97.84%)
client_sv2_setup_connection📈 view plot
🚷 view threshold
4,685.00
(+0.02%)
4,771.43
(98.19%)
📈 view plot
🚷 view threshold
1,502.00
(-0.01%)
1,517.74
(98.96%)
📈 view plot
🚷 view threshold
2,275.00
(-0.15%)
2,299.52
(98.93%)
📈 view plot
🚷 view threshold
13.00
(+39.01%)
15.86
(81.95%)
📈 view plot
🚷 view threshold
67.00
(-0.58%)
69.80
(95.99%)
client_sv2_setup_connection_serialize📈 view plot
🚷 view threshold
16,114.00
(-0.36%)
16,466.07
(97.86%)
📈 view plot
🚷 view threshold
5,963.00
(-0.00%)
5,978.74
(99.74%)
📈 view plot
🚷 view threshold
8,664.00
(+0.01%)
8,692.76
(99.67%)
📈 view plot
🚷 view threshold
41.00
(+2.52%)
53.53
(76.59%)
📈 view plot
🚷 view threshold
207.00
(-0.88%)
216.49
(95.62%)
client_sv2_setup_connection_serialize_deserialize📈 view plot
🚷 view threshold
35,700.00
(+0.42%)
35,747.07
(99.87%)
📈 view plot
🚷 view threshold
14,888.00
(+0.27%)
14,906.81
(99.87%)
📈 view plot
🚷 view threshold
21,880.00
(+0.31%)
21,918.48
(99.82%)
📈 view plot
🚷 view threshold
97.00
(+4.41%)
114.37
(84.81%)
📈 view plot
🚷 view threshold
381.00
(+0.46%)
384.65
(99.05%)
🐰 View full continuous benchmarking report in Bencher

Copy link

codecov bot commented Nov 13, 2024

Codecov Report

Attention: Patch coverage is 8.77193% with 52 lines in your changes missing coverage. Please review.

Project coverage is 14.24%. Comparing base (b900d0a) to head (5e2f02e).

Files with missing lines Patch % Lines
...les-logic-sv2/src/channel_logic/channel_factory.rs 0.00% 26 Missing ⚠️
protocols/v2/roles-logic-sv2/src/utils.rs 0.00% 10 Missing ⚠️
roles/pool/src/lib/mining_pool/mod.rs 0.00% 6 Missing ⚠️
roles/translator/src/lib/proxy/bridge.rs 0.00% 4 Missing ⚠️
...tocols/v2/roles-logic-sv2/src/channel_logic/mod.rs 0.00% 2 Missing ⚠️
protocols/v2/roles-logic-sv2/src/job_dispatcher.rs 0.00% 1 Missing ⚠️
protocols/v2/subprotocols/mining/src/lib.rs 83.33% 1 Missing ⚠️
roles/jd-client/src/lib/upstream_sv2/upstream.rs 0.00% 1 Missing ⚠️
...les/translator/src/lib/proxy/next_mining_notify.rs 0.00% 1 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (b900d0a) and HEAD (5e2f02e). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (b900d0a) HEAD (5e2f02e)
roles_logic_sv2-coverage 1 0
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1248      +/-   ##
==========================================
- Coverage   19.30%   14.24%   -5.06%     
==========================================
  Files         164      160       -4     
  Lines       10849    10205     -644     
==========================================
- Hits         2094     1454     -640     
+ Misses       8755     8751       -4     
Flag Coverage Δ
binary_codec_sv2-coverage 0.00% <0.00%> (ø)
binary_serde_sv2-coverage 3.62% <0.00%> (-0.03%) ⬇️
binary_sv2-coverage 5.42% <0.00%> (-0.04%) ⬇️
bip32_derivation-coverage 0.00% <ø> (ø)
buffer_sv2-coverage 25.02% <ø> (ø)
codec_sv2-coverage 0.01% <0.00%> (-0.01%) ⬇️
common_messages_sv2-coverage 0.13% <0.00%> (-0.01%) ⬇️
const_sv2-coverage 0.00% <0.00%> (ø)
error_handling-coverage 0.00% <ø> (ø)
framing_sv2-coverage 0.29% <0.00%> (-0.01%) ⬇️
jd_client-coverage 0.00% <0.00%> (ø)
jd_server-coverage 7.79% <ø> (ø)
job_declaration_sv2-coverage 0.00% <0.00%> (ø)
key-utils-coverage 2.39% <ø> (ø)
mining-coverage 2.54% <11.11%> (+0.03%) ⬆️
mining_device-coverage 0.00% <ø> (ø)
mining_proxy_sv2-coverage 0.70% <ø> (ø)
noise_sv2-coverage 4.33% <0.00%> (-0.03%) ⬇️
pool_sv2-coverage 1.38% <0.00%> (-0.01%) ⬇️
protocols 16.46% <11.11%> (-8.27%) ⬇️
roles 6.54% <0.00%> (-0.02%) ⬇️
roles_logic_sv2-coverage ?
sv1-mining-device-coverage 0.00% <ø> (ø)
sv2_ffi-coverage 0.00% <0.00%> (ø)
template_distribution_sv2-coverage 0.00% <0.00%> (ø)
translator_sv2-coverage 9.57% <0.00%> (-0.03%) ⬇️
utils 25.13% <ø> (ø)
v1-coverage 2.45% <0.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@GitGab19
Copy link
Collaborator

add a method that the pool can use in order to change coinbase_script_additional_data of an already opened channel and send downstream the new extranonce_prefix

SInce we're going to use the extranonce_prefix for this addictional data, I think we should use the SetExtranoncePrefix message to achieve your third point here.

@Fi3
Copy link
Collaborator Author

Fi3 commented Nov 14, 2024

add a method that the pool can use in order to change coinbase_script_additional_data of an already opened channel and send downstream the new extranonce_prefix

SInce we're going to use the extranonce_prefix for this addictional data, I think we should use the SetExtranoncePrefix message to achieve your third point here.

thats the plan

@Fi3
Copy link
Collaborator Author

Fi3 commented Nov 14, 2024

add a method that the pool can use in order to change coinbase_script_additional_data of an already opened channel and send downstream the new extranonce_prefix

SInce we're going to use the extranonce_prefix for this addictional data, I think we should use the SetExtranoncePrefix message to achieve your third point here.

I'm implementing it, and we need to support at least 2 extranonce if we want to be able to change it while the miner is mining. That cause there will be short time frames where we have job for the new extranonce and job for the old extranonce. I realized that this is true also for the target. We do not support 2 target at the same time, and this is very likley what cause the very rare invalid shares that we observe during tests. I will do another PR to fix it.

@GitGab19
Copy link
Collaborator

GitGab19 commented Nov 14, 2024

I guess it would be better to wait you to push the SetExtranoncePrefix changes before doing a proper review, right? For now I ACK the appproach 👍

fi3 added 7 commits November 16, 2024 10:27
Coinbase signature is not part of the Sv2 protocol, some pool maybe want
to use it other not. The first part of the extranonce could also be
reserved for things that are not a pool signature. This pr rename the
pool_signature field of the channel factory into additional_coinbase_script_data
and change the type from Strgin to Vec<u8>, since can be anything.
The coinbase input script additional data should be sent as part of the
extranonce_prefix and not as part of the coinbase_prefix. So that a JDC
can see what the pool want as coinbase input script additional data
without the need to observ the coinbase prefix in job constructed by the
pool.
Update the pool to use an extranonce of 16 bytes rather then 32 so that
there is enaugh space to add the additional coinbase input script data.
Right now the channel factory only support one active job at time. That
means that if we receive a share for a job right after we sent downstream
a new job that share will be invalid. Now the channel factory keep track
of the last 3 jobs, so we give time to the dowstream to receive the job
and propagate it down before stop accepting shares for older job. This
is useful, and the system can be more responsive: as soon as we
change the coinbase additional input script data we can send a new job
dowsntream without worrying of invalidating miner's shares. When the
pool receive a prev hash it immidiatly invalidate all the previous jobs,
we still want to refuse shares for stale jobs. The client can easly handle
this situation: when a pool refuse a share it should start a timer and if do
not receive a new prev hash (or already have) within n seconds it change
pool.
This commit fix 2 miner things:

When we calculate the coinbase_prefix (what we need to put in the
extended job) we need to account also for the coinbase input script
additional data that is part of the extranonce.

When we create pool channel facotry we pass an extranonce creator and an
pool signature. If the signature + extranonce are bigger then 32 bytes
we have to return an error. That cause in sv2 the extranonce can not be
longer than 32 bytes.
The translator normalize the coinbase and remove the segwit data
from the coinbase prefix and suffix. In order to do that it need to know
the extranonce len, we used a default value of 322 bytes, but the pool
could use also smalle extranonces.
 Add a method that the pool can use in order to change
 coinbase_script_additional_data of an already opened
 channel and send downstream the new extranonce_prefix
@Fi3 Fi3 changed the title [WIP] Improve coinbase Improve coinbase Nov 16, 2024
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.

2 participants