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

Docs for Template Distribution Messages #1257

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

Conversation

jbesraa
Copy link
Contributor

@jbesraa jbesraa commented Nov 17, 2024

resolves #1206

Copy link

codecov bot commented Nov 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 19.30%. Comparing base (e650561) to head (1c25a28).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1257   +/-   ##
=======================================
  Coverage   19.30%   19.30%           
=======================================
  Files         164      164           
  Lines       10849    10849           
=======================================
  Hits         2094     2094           
  Misses       8755     8755           
Flag Coverage Δ
binary_codec_sv2-coverage 0.00% <ø> (ø)
binary_serde_sv2-coverage 3.65% <ø> (ø)
binary_sv2-coverage 5.46% <ø> (ø)
bip32_derivation-coverage 0.00% <ø> (ø)
buffer_sv2-coverage 25.02% <ø> (ø)
codec_sv2-coverage 0.01% <ø> (ø)
common_messages_sv2-coverage 0.13% <ø> (ø)
const_sv2-coverage 0.00% <ø> (ø)
error_handling-coverage 0.00% <ø> (ø)
framing_sv2-coverage 0.29% <ø> (ø)
jd_client-coverage 0.00% <ø> (ø)
jd_server-coverage 7.79% <ø> (ø)
job_declaration_sv2-coverage 0.00% <ø> (ø)
key-utils-coverage 2.39% <ø> (ø)
mining-coverage 2.51% <ø> (ø)
mining_device-coverage 0.00% <ø> (ø)
mining_proxy_sv2-coverage 0.70% <ø> (ø)
noise_sv2-coverage 4.35% <ø> (ø)
pool_sv2-coverage 1.38% <ø> (ø)
protocols 24.72% <ø> (ø)
roles 6.55% <ø> (ø)
roles_logic_sv2-coverage 8.06% <ø> (ø)
sv2_ffi-coverage 0.00% <ø> (ø)
template_distribution_sv2-coverage 0.00% <ø> (ø)
translator_sv2-coverage 9.60% <ø> (ø)
utils 25.13% <ø> (ø)
v1-coverage 2.47% <ø> (ø)

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.


🚨 Try these New Features:

Copy link
Contributor

github-actions bot commented Nov 17, 2024

🐰 Bencher Report

Branch2024-11-08-template-distribution-msgs-docs
Testbedsv2
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,091.00
(-0.17%)
2,207.65
(94.72%)
📈 view plot
🚷 view threshold
473.00
(-0.07%)
488.51
(96.82%)
📈 view plot
🚷 view threshold
736.00
(+0.00%)
757.27
(97.19%)
📈 view plot
🚷 view threshold
5.00
(-6.57%)
13.81
(36.21%)
📈 view plot
🚷 view threshold
38.00
(-0.14%)
41.19
(92.25%)
client_sv2_handle_message_mining📈 view plot
🚷 view threshold
8,204.00
(+0.01%)
8,282.32
(99.05%)
📈 view plot
🚷 view threshold
2,137.00
(-0.03%)
2,143.08
(99.72%)
📈 view plot
🚷 view threshold
3,159.00
(-0.06%)
3,170.57
(99.63%)
📈 view plot
🚷 view threshold
36.00
(+1.41%)
41.95
(85.83%)
📈 view plot
🚷 view threshold
139.00
(+0.01%)
140.82
(98.71%)
client_sv2_mining_message_submit_standard📈 view plot
🚷 view threshold
6,311.00
(+0.49%)
6,394.42
(98.70%)
📈 view plot
🚷 view threshold
1,750.00
(-0.05%)
1,766.87
(99.05%)
📈 view plot
🚷 view threshold
2,551.00
(-0.11%)
2,575.60
(99.04%)
📈 view plot
🚷 view threshold
17.00
(+0.74%)
24.25
(70.09%)
📈 view plot
🚷 view threshold
105.00
(+0.91%)
107.22
(97.93%)
client_sv2_mining_message_submit_standard_serialize📈 view plot
🚷 view threshold
14,674.00
(-0.36%)
14,953.43
(98.13%)
📈 view plot
🚷 view threshold
4,694.00
(-0.02%)
4,710.87
(99.64%)
📈 view plot
🚷 view threshold
6,759.00
(+0.00%)
6,781.81
(99.66%)
📈 view plot
🚷 view threshold
43.00
(-0.90%)
52.87
(81.34%)
📈 view plot
🚷 view threshold
220.00
(-0.67%)
227.44
(96.73%)
client_sv2_mining_message_submit_standard_serialize_deserialize📈 view plot
🚷 view threshold
27,768.00
(+0.84%)
27,816.76
(99.82%)
📈 view plot
🚷 view threshold
10,645.00
(+0.58%)
10,654.37
(99.91%)
📈 view plot
🚷 view threshold
15,508.00
(+0.69%)
15,515.74
(99.95%)
📈 view plot
🚷 view threshold
86.00
(+5.75%)
89.58
(96.00%)
📈 view plot
🚷 view threshold
338.00
(+0.87%)
341.75
(98.90%)
client_sv2_open_channel📈 view plot
🚷 view threshold
4,413.00
(+0.44%)
4,594.83
(96.04%)
📈 view plot
🚷 view threshold
1,461.00
(-0.02%)
1,476.51
(98.95%)
📈 view plot
🚷 view threshold
2,158.00
(-0.09%)
2,184.18
(98.80%)
📈 view plot
🚷 view threshold
10.00
(+13.37%)
17.07
(58.58%)
📈 view plot
🚷 view threshold
63.00
(+0.70%)
67.95
(92.71%)
client_sv2_open_channel_serialize📈 view plot
🚷 view threshold
14,020.00
(-0.22%)
14,401.30
(97.35%)
📈 view plot
🚷 view threshold
5,064.00
(-0.01%)
5,079.51
(99.69%)
📈 view plot
🚷 view threshold
7,325.00
(-0.02%)
7,351.62
(99.64%)
📈 view plot
🚷 view threshold
37.00
(+5.62%)
43.08
(85.89%)
📈 view plot
🚷 view threshold
186.00
(-0.60%)
197.23
(94.31%)
client_sv2_open_channel_serialize_deserialize📈 view plot
🚷 view threshold
22,846.00
(+0.80%)
22,912.87
(99.71%)
📈 view plot
🚷 view threshold
8,040.00
(+0.23%)
8,073.25
(99.59%)
📈 view plot
🚷 view threshold
11,691.00
(+0.18%)
11,750.88
(99.49%)
📈 view plot
🚷 view threshold
82.00
(+10.24%)
85.25
(96.19%)
📈 view plot
🚷 view threshold
307.00
(+1.16%)
311.24
(98.64%)
client_sv2_setup_connection📈 view plot
🚷 view threshold
4,693.00
(+0.18%)
4,774.34
(98.30%)
📈 view plot
🚷 view threshold
1,502.00
(-0.02%)
1,517.51
(98.98%)
📈 view plot
🚷 view threshold
2,273.00
(-0.24%)
2,299.21
(98.86%)
📈 view plot
🚷 view threshold
15.00
(+56.99%)
16.66
(90.02%)
📈 view plot
🚷 view threshold
67.00
(-0.57%)
69.79
(96.01%)
client_sv2_setup_connection_serialize📈 view plot
🚷 view threshold
16,148.00
(-0.12%)
16,443.08
(98.21%)
📈 view plot
🚷 view threshold
5,963.00
(-0.01%)
5,978.51
(99.74%)
📈 view plot
🚷 view threshold
8,663.00
(-0.01%)
8,691.38
(99.67%)
📈 view plot
🚷 view threshold
41.00
(+3.04%)
52.79
(77.66%)
📈 view plot
🚷 view threshold
208.00
(-0.34%)
215.89
(96.34%)
client_sv2_setup_connection_serialize_deserialize📈 view plot
🚷 view threshold
35,714.00
(+0.45%)
35,763.75
(99.86%)
📈 view plot
🚷 view threshold
14,888.00
(+0.25%)
14,909.61
(99.86%)
📈 view plot
🚷 view threshold
21,884.00
(+0.30%)
21,923.16
(99.82%)
📈 view plot
🚷 view threshold
92.00
(-0.22%)
111.47
(82.53%)
📈 view plot
🚷 view threshold
382.00
(+0.72%)
384.69
(99.30%)
🐰 View full continuous benchmarking report in Bencher

Copy link
Contributor

github-actions bot commented Nov 17, 2024

🐰 Bencher Report

Branch2024-11-08-template-distribution-msgs-docs
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.93
(+0.72%)
46.85
(95.90%)
client_sv2_handle_message_mining📈 view plot
🚷 view threshold
72.55
(-3.22%)
83.69
(86.68%)
client_sv2_mining_message_submit_standard📈 view plot
🚷 view threshold
14.65
(-0.08%)
14.81
(98.97%)
client_sv2_mining_message_submit_standard_serialize📈 view plot
🚷 view threshold
272.98
(+2.64%)
316.77
(86.18%)
client_sv2_mining_message_submit_standard_serialize_deserialize📈 view plot
🚷 view threshold
601.69
(-0.55%)
720.48
(83.51%)
client_sv2_open_channel📈 view plot
🚷 view threshold
164.93
(+8.88%)
189.88
(86.86%)
client_sv2_open_channel_serialize📈 view plot
🚷 view threshold
291.68
(+2.33%)
312.44
(93.35%)
client_sv2_open_channel_serialize_deserialize📈 view plot
🚷 view threshold
385.22
(+1.91%)
404.42
(95.25%)
client_sv2_setup_connection📈 view plot
🚷 view threshold
164.71
(+2.28%)
174.49
(94.39%)
client_sv2_setup_connection_serialize📈 view plot
🚷 view threshold
443.79
(-4.21%)
544.09
(81.57%)
client_sv2_setup_connection_serialize_deserialize📈 view plot
🚷 view threshold
1,008.90
(+3.26%)
1,063.64
(94.85%)
🐰 View full continuous benchmarking report in Bencher

Copy link
Contributor

github-actions bot commented Nov 17, 2024

🐰 Bencher Report

Branch2024-11-08-template-distribution-msgs-docs
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,861.70
(+1.75%)
7,167.13
(95.74%)
client-submit-serialize-deserialize📈 view plot
🚷 view threshold
7,659.00
(+0.07%)
7,930.70
(96.57%)
client-submit-serialize-deserialize-handle/client-submit-serialize-deserialize-handle📈 view plot
🚷 view threshold
8,253.90
(+0.55%)
8,537.24
(96.68%)
client-sv1-authorize-serialize-deserialize-handle/client-sv1-authorize-serialize-deserialize-handle📈 view plot
🚷 view threshold
884.55
(+1.19%)
935.21
(94.58%)
client-sv1-authorize-serialize-deserialize/client-sv1-authorize-serialize-deserialize📈 view plot
🚷 view threshold
671.92
(+0.01%)
709.46
(94.71%)
client-sv1-authorize-serialize/client-sv1-authorize-serialize📈 view plot
🚷 view threshold
254.52
(+2.17%)
263.90
(96.44%)
client-sv1-get-authorize/client-sv1-get-authorize📈 view plot
🚷 view threshold
156.85
(-0.33%)
163.16
(96.13%)
client-sv1-get-submit📈 view plot
🚷 view threshold
6,645.70
(+1.66%)
7,194.37
(92.37%)
client-sv1-get-subscribe/client-sv1-get-subscribe📈 view plot
🚷 view threshold
289.36
(+3.12%)
311.00
(93.04%)
client-sv1-subscribe-serialize-deserialize-handle/client-sv1-subscribe-serialize-deserialize-handle📈 view plot
🚷 view threshold
724.43
(-1.53%)
801.32
(90.40%)
client-sv1-subscribe-serialize-deserialize/client-sv1-subscribe-serialize-deserialize📈 view plot
🚷 view threshold
592.07
(-0.86%)
643.09
(92.07%)
client-sv1-subscribe-serialize/client-sv1-subscribe-serialize📈 view plot
🚷 view threshold
205.57
(-0.37%)
221.41
(92.84%)
🐰 View full continuous benchmarking report in Bencher

Copy link
Contributor

github-actions bot commented Nov 17, 2024

🐰 Bencher Report

Branch2024-11-08-template-distribution-msgs-docs
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,402.00
(-0.76%)
8,729.32
(96.25%)
📈 view plot
🚷 view threshold
3,663.00
(-2.31%)
3,855.28
(95.01%)
📈 view plot
🚷 view threshold
5,112.00
(-2.77%)
5,422.72
(94.27%)
📈 view plot
🚷 view threshold
7.00
(-2.82%)
13.03
(53.71%)
📈 view plot
🚷 view threshold
93.00
(+2.59%)
95.21
(97.68%)
get_submit📈 view plot
🚷 view threshold
95,292.00
(-0.15%)
95,891.09
(99.38%)
📈 view plot
🚷 view threshold
59,263.00
(-0.33%)
59,679.74
(99.30%)
📈 view plot
🚷 view threshold
85,082.00
(-0.38%)
85,753.53
(99.22%)
📈 view plot
🚷 view threshold
40.00
(-10.75%)
63.63
(62.86%)
📈 view plot
🚷 view threshold
286.00
(+2.08%)
289.37
(98.84%)
get_subscribe📈 view plot
🚷 view threshold
7,957.00
(-0.83%)
8,272.59
(96.19%)
📈 view plot
🚷 view threshold
2,758.00
(-2.73%)
2,936.15
(93.93%)
📈 view plot
🚷 view threshold
3,832.00
(-3.29%)
4,117.46
(93.07%)
📈 view plot
🚷 view threshold
13.00
(+8.62%)
20.68
(62.86%)
📈 view plot
🚷 view threshold
116.00
(+1.46%)
118.56
(97.84%)
serialize_authorize📈 view plot
🚷 view threshold
12,141.00
(-1.16%)
12,562.99
(96.64%)
📈 view plot
🚷 view threshold
5,240.00
(-1.53%)
5,422.91
(96.63%)
📈 view plot
🚷 view threshold
7,286.00
(-1.81%)
7,581.07
(96.11%)
📈 view plot
🚷 view threshold
5.00
(-45.11%)
16.36
(30.56%)
📈 view plot
🚷 view threshold
138.00
(+0.26%)
142.61
(96.77%)
serialize_deserialize_authorize📈 view plot
🚷 view threshold
24,586.00
(-0.43%)
25,228.37
(97.45%)
📈 view plot
🚷 view threshold
9,786.00
(-1.07%)
10,031.49
(97.55%)
📈 view plot
🚷 view threshold
13,791.00
(-1.25%)
14,181.77
(97.24%)
📈 view plot
🚷 view threshold
31.00
(-10.43%)
43.60
(71.10%)
📈 view plot
🚷 view threshold
304.00
(+0.82%)
315.22
(96.44%)
serialize_deserialize_handle_authorize📈 view plot
🚷 view threshold
30,351.00
(+0.09%)
30,753.29
(98.69%)
📈 view plot
🚷 view threshold
11,989.00
(-0.77%)
12,201.09
(98.26%)
📈 view plot
🚷 view threshold
16,951.00
(-0.93%)
17,288.69
(98.05%)
📈 view plot
🚷 view threshold
55.00
(-0.94%)
67.32
(81.70%)
📈 view plot
🚷 view threshold
375.00
(+1.45%)
381.76
(98.23%)
serialize_deserialize_handle_submit📈 view plot
🚷 view threshold
126,298.00
(-0.14%)
126,895.90
(99.53%)
📈 view plot
🚷 view threshold
73,117.00
(-0.23%)
73,507.35
(99.47%)
📈 view plot
🚷 view threshold
104,763.00
(-0.29%)
105,431.07
(99.37%)
📈 view plot
🚷 view threshold
114.00
(+6.52%)
133.01
(85.71%)
📈 view plot
🚷 view threshold
599.00
(+0.44%)
605.14
(98.99%)
serialize_deserialize_handle_subscribe📈 view plot
🚷 view threshold
27,911.00
(+0.25%)
28,606.21
(97.57%)
📈 view plot
🚷 view threshold
9,577.00
(-0.75%)
9,750.15
(98.22%)
📈 view plot
🚷 view threshold
13,521.00
(-0.93%)
13,803.34
(97.95%)
📈 view plot
🚷 view threshold
64.00
(+0.86%)
75.92
(84.30%)
📈 view plot
🚷 view threshold
402.00
(+1.41%)
416.92
(96.42%)
serialize_deserialize_submit📈 view plot
🚷 view threshold
114,899.00
(-0.30%)
115,802.60
(99.22%)
📈 view plot
🚷 view threshold
67,894.00
(-0.31%)
68,392.66
(99.27%)
📈 view plot
🚷 view threshold
97,374.00
(-0.37%)
98,218.13
(99.14%)
📈 view plot
🚷 view threshold
61.00
(-2.70%)
78.21
(77.99%)
📈 view plot
🚷 view threshold
492.00
(+0.15%)
498.40
(98.71%)
serialize_deserialize_subscribe📈 view plot
🚷 view threshold
23,190.00
(-0.30%)
23,992.33
(96.66%)
📈 view plot
🚷 view threshold
8,129.00
(-0.93%)
8,305.68
(97.87%)
📈 view plot
🚷 view threshold
11,430.00
(-1.10%)
11,709.18
(97.62%)
📈 view plot
🚷 view threshold
35.00
(-5.96%)
44.41
(78.82%)
📈 view plot
🚷 view threshold
331.00
(+0.59%)
347.89
(95.15%)
serialize_submit📈 view plot
🚷 view threshold
99,639.00
(-0.21%)
100,297.09
(99.34%)
📈 view plot
🚷 view threshold
61,325.00
(-0.29%)
61,713.45
(99.37%)
📈 view plot
🚷 view threshold
87,944.00
(-0.34%)
88,587.78
(99.27%)
📈 view plot
🚷 view threshold
43.00
(-8.01%)
64.45
(66.72%)
📈 view plot
🚷 view threshold
328.00
(+1.00%)
333.78
(98.27%)
serialize_subscribe📈 view plot
🚷 view threshold
11,326.00
(-0.69%)
11,674.79
(97.01%)
📈 view plot
🚷 view threshold
4,111.00
(-1.72%)
4,279.52
(96.06%)
📈 view plot
🚷 view threshold
5,696.00
(-2.13%)
5,970.40
(95.40%)
📈 view plot
🚷 view threshold
13.00
(+1.03%)
20.80
(62.50%)
📈 view plot
🚷 view threshold
159.00
(+0.80%)
163.21
(97.42%)
🐰 View full continuous benchmarking report in Bencher

@jbesraa jbesraa force-pushed the 2024-11-08-template-distribution-msgs-docs branch 3 times, most recently from a877fed to 31e33f6 Compare November 19, 2024 14:38
@jbesraa jbesraa marked this pull request as ready for review November 19, 2024 14:39
@jbesraa
Copy link
Contributor Author

jbesraa commented Nov 19, 2024

@GitGab19 this is ready for initial review

@GitGab19 GitGab19 self-requested a review November 20, 2024 09:33
Copy link
Collaborator

@GitGab19 GitGab19 left a comment

Choose a reason for hiding this comment

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

Overall LGTM, I left some minor comments.

[![docs.rs](https://docs.rs/common_messages_sv2/badge.svg)](https://docs.rs/common_messages_sv2)
[![rustc+](https://img.shields.io/badge/rustc-1.75.0%2B-lightgrey.svg)](https://blog.rust-lang.org/2023/12/28/Rust-1.75.0.html)
[![license](https://img.shields.io/badge/license-MIT%2FApache--2.0-blue.svg)](https://github.com/stratum-mining/stratum/blob/main/LICENSE.md)
[![codecov](https://codecov.io/gh/stratum-mining/stratum/branch/main/graph/badge.svg)](https://app.codecov.io/gh/stratum-mining/stratum/tree/main/protocols%2Fv2%2Fcommon_messages_sv2)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
[![codecov](https://codecov.io/gh/stratum-mining/stratum/branch/main/graph/badge.svg)](https://app.codecov.io/gh/stratum-mining/stratum/tree/main/protocols%2Fv2%2Fcommon_messages_sv2)
[![codecov](https://codecov.io/gh/stratum-mining/stratum/branch/main/graph/badge.svg)](https://app.codecov.io/gh/stratum-mining/stratum/tree/main/protocols%2Fv2%2Ftemplate_distribution_sv2)

[![license](https://img.shields.io/badge/license-MIT%2FApache--2.0-blue.svg)](https://github.com/stratum-mining/stratum/blob/main/LICENSE.md)
[![codecov](https://codecov.io/gh/stratum-mining/stratum/branch/main/graph/badge.svg)](https://app.codecov.io/gh/stratum-mining/stratum/tree/main/protocols%2Fv2%2Fcommon_messages_sv2)

`template_distribution_sv2` is a Rust crate that implements the set of messages used by multiple Stratum V2 roles.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Isn't this a bit too much generic? It's the same of common_messages_sv2, but maybe you still need to work on the README. In any case, I think here the description should contain some reference to template distribution protocol at least.

/// will be added by the pools it intends to use this work. It then **must** communicate the sum of
/// such size to the Template Provider via this message.
///
/// The Template Provider **must not** provide `NewMiningJob` or `NewExtendedMiningJob` messages
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
/// The Template Provider **must not** provide `NewMiningJob` or `NewExtendedMiningJob` messages
/// The Template Provider **must not** provide `NewTemplate` messages

@@ -1,23 +1,14 @@
#![cfg_attr(feature = "no_std", no_std)]

//! # Template Distribution Protocol
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
//! # Template Distribution Protocol
//! # Stratum V2 Template Distribution Protocol Messages Crate

/// current UNIX time may be used in place of an ID.
/// Upstream’s identification of the template.
///
/// Strictly increasing, the current UNIX time may be used in place of an ID.
Copy link
Collaborator

Choose a reason for hiding this comment

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

the current UNIX time may be used in place of an ID.

I don't know if I would leave this tbh

Comment on lines +38 to +39
/// Up to 8 bytes (not including the length byte) which are to be placed at the beginning of
/// the coinbase field in the coinbase transaction.
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is wrong (cc @plebhash), since they are the bip34 bytes, we should put a proper description for it.

pub template_id: u64,
}

/// ## RequestTransactionData.Success (Server->Client)
/// Message used by an upstream to respond successfuly to a [`RequestTransactionData`] message.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
/// Message used by an upstream to respond successfuly to a [`RequestTransactionData`] message.
/// Message used by an upstream to respond successfully to a [`RequestTransactionData`] message.

@@ -58,6 +66,38 @@ pub struct RequestTransactionDataSuccess<'decoder> {
pub transaction_list: Seq064K<'decoder, B016M<'decoder>>,
}

/// Message used by an upstream to respond successfuly to a [`RequestTransactionData`] message.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
/// Message used by an upstream to respond successfuly to a [`RequestTransactionData`] message.
/// Message used by an upstream to respond successfully to a [`RequestTransactionData`] message.

///
/// If a `NewMiningJob` or `NewExtendedMiningJob` message has previously been sent with the
/// Future Job flag set, the [`SetNewPrevHash::template_id`] field **should** be set to the
/// `job_id` present in that message.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
/// `job_id` present in that message.
/// `template_id` present in that message.

I think this should be the right description, I just asked on discord to be 100% sure

///
/// If a `NewMiningJob` or `NewExtendedMiningJob` message has previously been sent with the
/// Future Job flag set, the [`SetNewPrevHash::template_id`] field **should** be set to the
/// `job_id` present in that message.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
/// `job_id` present in that message.
/// `template_id` present in that message.

I think this should be the right description, I just asked on discord to be 100% sure

@jbesraa jbesraa force-pushed the 2024-11-08-template-distribution-msgs-docs branch from 31e33f6 to 97b62d7 Compare November 21, 2024 12:51
@jbesraa jbesraa force-pushed the 2024-11-08-template-distribution-msgs-docs branch from 97b62d7 to 1c25a28 Compare November 21, 2024 12:55
Copy link
Contributor

@Shourya742 Shourya742 left a comment

Choose a reason for hiding this comment

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

I have a few general questions about structs with C memory layout, along with some minor nit. The description in the messaging is really detailed.

/// coinbase transaction outputs.
///
/// As the pool is responsible for adding coinbase transaction outputs for payouts and other uses,
/// the Template Provider will need to consider this additional block size when selecting
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// the Template Provider will need to consider this additional block size when selecting
/// the Template Provider will need to consider this reserved space when selecting

/// additional bytes required in the output count variable-length integer in the coinbase
/// transaction when complying with the size limits.
///
/// [`NewTemplate`]: crate::NewTemplate
#[derive(Serialize, Deserialize, Copy, Clone, Debug, PartialEq, Eq)]
#[repr(C)]
Copy link
Contributor

Choose a reason for hiding this comment

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

A C-compatible memory layout (#[repr(C)]) seems unnecessary in this case, as the struct contains only a single field, which will always occupy 4 bytes without any padding.

/// additional bytes required in the output count variable-length integer in the coinbase
/// transaction when complying with the size limits.
///
/// [`NewTemplate`]: crate::NewTemplate
#[derive(Serialize, Deserialize, Copy, Clone, Debug, PartialEq, Eq)]
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
#[derive(Serialize, Deserialize, Copy, Clone, Debug, PartialEq, Eq)]
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]

pub coinbase_tx_locktime: u32,
/// Merkle path hashes ordered from deepest.
#[cfg_attr(feature = "with_serde", serde(borrow))]
pub merkle_path: Seq0255<'decoder, U256<'decoder>>,
}

/// Message used by an upstream to provide a new template for downstream to mine on.
#[repr(C)]
#[cfg(not(feature = "with_serde"))]
pub struct CNewTemplate {
Copy link
Contributor

Choose a reason for hiding this comment

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

Not related to doc this struct should be like this, to have more efficient memory layout, and not waste space in padding.

#[repr(C)]
#[cfg(not(feature = "with_serde"))]
pub struct CNewTemplate {
    future_template: bool,                  
    coinbase_tx_locktime: u32,               
    version: u32,                             
    coinbase_tx_input_sequence: u32,            
    coinbase_tx_outputs_count: u32,        
    template_id: u64,                  
    coinbase_tx_value_remaining: u64,         
    coinbase_prefix: CVec,                    
    coinbase_tx_outputs: CVec,                  
    merkle_path: CVec2,                         
}

/// ensure backward compatibility, the transaction data **may** be encoded in a way that is
/// different from the consensus serialization of Bitcoin transactions.
///
/// The [`RequestTransactionDataSuccess`] sender **must** ensure that provided data is forward and
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// The [`RequestTransactionDataSuccess`] sender **must** ensure that provided data is forward and
/// The [`CRequestTransactionDataSuccess`] sender **must** ensure that provided data is forward and

/// ignored by versions which do not understand it.
///
/// To work around the limitation of not being able to negotiate e.g. a transaction compression
/// scheme, the format of the opaque data in [`RequestTransactionDataSuccess`] messages **may** be
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// scheme, the format of the opaque data in [`RequestTransactionDataSuccess`] messages **may** be
/// scheme, the format of the opaque data in [`CRequestTransactionDataSuccess`] messages **may** be

/// scheme, the format of the opaque data in [`RequestTransactionDataSuccess`] messages **may** be
/// changed in a non-compatible way at the time of fork activation, given sufficient time from
/// code-release to activation and there being in protocol(Template Declaration) signaling of
/// support for the new fork (e.g. for soft-forks activated using [BIP 9]).
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we just remove this description, and just add C version of RequestTransactionDataSuccess..

///
/// Upon validating a new best block, the server **must** immediately send this message.
///
/// If a `NewMiningJob` or `NewExtendedMiningJob` message has previously been sent with the
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// If a `NewMiningJob` or `NewExtendedMiningJob` message has previously been sent with the
/// If a `NewTemplate` message has previously been sent with the

Comment on lines 23 to 24
/// TODO: Define how many previous works the client has to track (2? 3?), and require that the
/// server reference one of those in SetNewPrevHash.
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we have this as a doc comment.?

Comment on lines +45 to +51
/// Message used by a downstream to submit a successful solution to a previously provided template.
///
/// Upon finding a Coinbase transaction and nonce pair which double-SHA256 hashes at or below
/// [`crate::SetNewPrevHash::target`], the downstream **must** immediately send this message.
///
/// Upon receiving this message, upstream **must** immediately construct the corresponding full
/// block and attempt to propagate it to the Bitcoin network.
Copy link
Contributor

Choose a reason for hiding this comment

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

Can be removed, and can be detailed as c implementation for SubmitSolution

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.

Need Rust docs on protocols::v2::subprotocols::template-distribution
3 participants