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

Rust Docs framing_sv2 #848

Merged
merged 10 commits into from
May 10, 2024
Merged

Conversation

plebhash
Copy link
Collaborator

@plebhash plebhash commented Apr 13, 2024

adds Rust Docs for framing_sv2, as described in #845

also renames NoiseFrame into HandShakeFrame

the documentation effort was guided by discussion with @Fi3 on #858

/// - Returns a negative value if the byte slice is smaller than a Noise Frame header; this value
/// represents how many bytes are missing.
/// - Returns a positive value if the byte slice is longer than expected; this value
/// indicates the surplus of bytes beyond the expected size.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Note for the future, it could make sense to return a type that encode the above infos: enum Ok, Bigger, Smaller. This would be an API change so for now I would live it like it is

/// deserialized (`self.serialized` is `None`, `self.payload` is `Some()`).
/// This function is only intended as a fast way to get a reference to an
/// already serialized payload. If the frame has not yet been
/// serialized, this function should never be used (it will panic).
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we add a warning here that is printed when compiled? So you have to explicitly opt out from it when you want to use this function?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

sorry @Fi3 I don't fully understand the suggestion

I did some research but couldn't find an easy way to print a warning during compilation.
I only found this pre-RFC which proposes a compile_warning! macro but it will probably take a long time before this is available.

Do you have some examples on how to achieve this?

Copy link
Collaborator

Choose a reason for hiding this comment

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

No I was just supposing that it was already doable on stable, maybe we can leave a comment for our future self.

Copy link
Collaborator Author

@plebhash plebhash May 9, 2024

Choose a reason for hiding this comment

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

well, as we already discussed briefly, I believe the framing_sv2 crate should be refactored in the future.

the Frame trait is forcing Sv2Frame and HandShakeFrame to share APIs while they don't really share a lot of common features, and as a consequence we end up with APIs that are inuntuitive and dirty (e.g.: panic on undersired scenarios)

so if we're taking a note for the future, I think we should simply refactor this crate (removing the Frame trait and re-writing the APIs) so that we don't need to be emitting compilation warnings to avoid footguns

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I wrote a summary of all things to be refactored on framing_sv2 in the future here:
#903

@pavlenex pavlenex mentioned this pull request May 1, 2024
@pavlenex pavlenex added this to the 1.0.1 milestone May 1, 2024
@Fi3 Fi3 deleted the branch stratum-mining:dev May 3, 2024 09:37
@Fi3 Fi3 closed this May 3, 2024
@Fi3 Fi3 reopened this May 3, 2024
@Fi3

This comment was marked as resolved.

@plebhash plebhash force-pushed the docs-framing-sv2 branch 2 times, most recently from cb01f3f to 0842773 Compare May 4, 2024 19:49
@plebhash plebhash force-pushed the docs-framing-sv2 branch 2 times, most recently from 73d477a to 087edfd Compare May 9, 2024 16:38
Copy link
Contributor

🐰Bencher

ReportFri, May 10, 2024 at 14:30:24 UTC
ProjectStratum v2 (SRI)
Branchdocs-framing-sv2
Testbedsv2
Click to view all benchmark results
BenchmarkLatencyLatency Results
nanoseconds (ns) | (Δ%)
Latency Upper Boundary
nanoseconds (ns) | (%)
client_sv2_handle_message_common✅ (view plot)44.41 (-0.29%)45.22 (98.22%)
client_sv2_handle_message_mining✅ (view plot)74.72 (+2.04%)82.46 (90.61%)
client_sv2_mining_message_submit_standard✅ (view plot)14.64 (-0.07%)14.69 (99.70%)
client_sv2_mining_message_submit_standard_serialize✅ (view plot)264.02 (-0.29%)284.43 (92.83%)
client_sv2_mining_message_submit_standard_serialize_deserialize✅ (view plot)619.45 (+4.31%)626.21 (98.92%)
client_sv2_open_channel✅ (view plot)166.15 (+0.39%)171.15 (97.08%)
client_sv2_open_channel_serialize✅ (view plot)279.50 (-1.78%)296.18 (94.37%)
client_sv2_open_channel_serialize_deserialize✅ (view plot)370.57 (-1.52%)402.59 (92.05%)
client_sv2_setup_connection✅ (view plot)156.73 (-4.34%)174.96 (89.58%)
client_sv2_setup_connection_serialize✅ (view plot)475.43 (+0.44%)498.51 (95.37%)
client_sv2_setup_connection_serialize_deserialize✅ (view plot)944.57 (-2.47%)1,041.77 (90.67%)

Bencher - Continuous Benchmarking
View Public Perf Page
Docs | Repo | Chat | Help

Copy link
Contributor

🐰Bencher

ReportFri, May 10, 2024 at 14:30:25 UTC
ProjectStratum v2 (SRI)
Branchdocs-framing-sv2
Testbedsv1
Click to view all benchmark results
BenchmarkEstimated CyclesEstimated Cycles Results
estimated cycles | (Δ%)
Estimated Cycles Upper Boundary
estimated cycles | (%)
InstructionsInstructions Results
instructions | (Δ%)
Instructions Upper Boundary
instructions | (%)
L1 AccessesL1 Accesses Results
accesses | (Δ%)
L1 Accesses Upper Boundary
accesses | (%)
L2 AccessesL2 Accesses Results
accesses | (Δ%)
L2 Accesses Upper Boundary
accesses | (%)
RAM AccessesRAM Accesses Results
accesses | (Δ%)
RAM Accesses Upper Boundary
accesses | (%)
get_authorize✅ (view plot)8,440.00 (+0.25%)8,711.33 (96.89%)✅ (view plot)3,746.00 (+0.27%)3,853.71 (97.20%)✅ (view plot)5,250.00 (+0.24%)5,396.62 (97.28%)✅ (view plot)8.00 (-1.23%)10.50 (76.22%)✅ (view plot)90.00 (+0.29%)93.69 (96.06%)
get_submit✅ (view plot)95,549.00 (+0.01%)96,158.89 (99.37%)✅ (view plot)59,439.00 (-0.04%)59,782.26 (99.43%)✅ (view plot)85,349.00 (-0.05%)85,836.20 (99.43%)✅ (view plot)59.00 (+6.61%)62.80 (93.95%)✅ (view plot)283.00 (+0.26%)288.07 (98.24%)
get_subscribe✅ (view plot)8,007.00 (+0.46%)8,275.04 (96.76%)✅ (view plot)2,841.00 (+0.47%)2,942.69 (96.54%)✅ (view plot)3,967.00 (+0.42%)4,102.57 (96.70%)✅ (view plot)17.00 (+4.94%)19.60 (86.73%)✅ (view plot)113.00 (+0.41%)116.97 (96.61%)
serialize_authorize✅ (view plot)12,163.00 (-0.13%)12,464.14 (97.58%)✅ (view plot)5,317.00 (+0.19%)5,424.71 (98.01%)✅ (view plot)7,413.00 (+0.17%)7,560.54 (98.05%)✅ (view plot)12.00 (+8.30%)13.68 (87.75%)✅ (view plot)134.00 (-0.71%)139.16 (96.29%)
serialize_deserialize_authorize✅ (view plot)24,472.00 (+0.10%)24,677.69 (99.17%)✅ (view plot)9,898.00 (+0.06%)10,017.23 (98.81%)✅ (view plot)13,957.00 (+0.03%)14,132.50 (98.76%)✅ (view plot)38.00 (+2.59%)41.83 (90.84%)✅ (view plot)295.00 (+0.15%)297.23 (99.25%)
serialize_deserialize_handle_authorize✅ (view plot)30,199.00 (+0.21%)30,327.56 (99.58%)✅ (view plot)12,101.00 (+0.08%)12,208.71 (99.12%)✅ (view plot)17,119.00 (+0.05%)17,276.50 (99.09%)✅ (view plot)61.00 (+4.67%)63.62 (95.88%)✅ (view plot)365.00 (+0.32%)366.65 (99.55%)
serialize_deserialize_handle_submit✅ (view plot)126,468.00 (+0.05%)127,051.67 (99.54%)✅ (view plot)73,224.00 (-0.02%)73,626.66 (99.45%)✅ (view plot)104,938.00 (-0.03%)105,515.67 (99.45%)✅ (view plot)127.00 (+5.32%)132.25 (96.03%)✅ (view plot)597.00 (+0.33%)599.37 (99.60%)
serialize_deserialize_handle_subscribe✅ (view plot)27,523.00 (+0.25%)27,606.07 (99.70%)✅ (view plot)9,643.00 (+0.14%)9,744.69 (98.96%)✅ (view plot)13,633.00 (+0.10%)13,779.77 (98.93%)✅ (view plot)69.00 (+5.99%)70.69 (97.61%)✅ (view plot)387.00 (+0.26%)388.46 (99.62%)
serialize_deserialize_submit✅ (view plot)115,069.00 (+0.02%)115,628.15 (99.52%)✅ (view plot)68,001.00 (-0.05%)68,387.61 (99.43%)✅ (view plot)97,549.00 (-0.07%)98,116.43 (99.42%)✅ (view plot)74.00 (+6.94%)74.54 (99.28%)✅ (view plot)490.00 (+0.38%)492.55 (99.48%)
serialize_deserialize_subscribe✅ (view plot)22,904.00 (+0.18%)23,100.18 (99.15%)✅ (view plot)8,195.00 (+0.15%)8,298.86 (98.75%)✅ (view plot)11,539.00 (+0.13%)11,683.47 (98.76%)✅ (view plot)40.00 (+1.68%)43.80 (91.33%)✅ (view plot)319.00 (+0.22%)321.20 (99.31%)
serialize_submit✅ (view plot)99,840.00 (-0.03%)100,467.62 (99.38%)✅ (view plot)61,483.00 (-0.04%)61,832.10 (99.44%)✅ (view plot)88,195.00 (-0.05%)88,691.20 (99.44%)✅ (view plot)61.00 (+9.16%)62.00 (98.38%)✅ (view plot)324.00 (-0.17%)329.19 (98.42%)
serialize_subscribe✅ (view plot)11,302.00 (-0.07%)11,586.48 (97.54%)✅ (view plot)4,188.00 (+0.32%)4,289.69 (97.63%)✅ (view plot)5,827.00 (+0.31%)5,962.41 (97.73%)✅ (view plot)17.00 (+3.91%)18.92 (89.86%)✅ (view plot)154.00 (-0.53%)159.08 (96.81%)

Bencher - Continuous Benchmarking
View Public Perf Page
Docs | Repo | Chat | Help

Copy link
Contributor

🐰Bencher

ReportFri, May 10, 2024 at 14:30:26 UTC
ProjectStratum v2 (SRI)
Branch848/merge
Testbedsv1
Click to view all benchmark results
BenchmarkLatencyLatency Results
nanoseconds (ns) | (Δ%)
Latency Upper Boundary
nanoseconds (ns) | (%)
client-submit-serialize✅ (view plot)6,902.60 (-0.34%)7,280.41 (94.81%)
client-submit-serialize-deserialize✅ (view plot)7,679.40 (-2.05%)8,269.02 (92.87%)
client-submit-serialize-deserialize-handle/client-submit-serialize-deserialize-handle✅ (view plot)8,362.90 (-0.68%)8,824.19 (94.77%)
client-sv1-authorize-serialize-deserialize-handle/client-sv1-authorize-serialize-deserialize-handle✅ (view plot)894.70 (-0.41%)926.95 (96.52%)
client-sv1-authorize-serialize-deserialize/client-sv1-authorize-serialize-deserialize✅ (view plot)700.27 (+0.47%)718.23 (97.50%)
client-sv1-authorize-serialize/client-sv1-authorize-serialize✅ (view plot)253.39 (+2.16%)254.79 (99.45%)
client-sv1-get-authorize/client-sv1-get-authorize✅ (view plot)157.90 (+0.67%)160.17 (98.59%)
client-sv1-get-submit✅ (view plot)6,722.90 (+0.54%)7,038.98 (95.51%)
client-sv1-get-subscribe/client-sv1-get-subscribe✅ (view plot)273.22 (-1.92%)291.47 (93.74%)
client-sv1-subscribe-serialize-deserialize-handle/client-sv1-subscribe-serialize-deserialize-handle✅ (view plot)736.08 (-1.44%)776.47 (94.80%)
client-sv1-subscribe-serialize-deserialize/client-sv1-subscribe-serialize-deserialize✅ (view plot)609.44 (-0.83%)637.85 (95.55%)
client-sv1-subscribe-serialize/client-sv1-subscribe-serialize✅ (view plot)203.03 (-1.73%)220.17 (92.22%)

Bencher - Continuous Benchmarking
View Public Perf Page
Docs | Repo | Chat | Help

Copy link
Contributor

🐰Bencher

ReportFri, May 10, 2024 at 14:30:28 UTC
ProjectStratum v2 (SRI)
Branchdocs-framing-sv2
Testbedsv2
Click to view all benchmark results
BenchmarkEstimated CyclesEstimated Cycles Results
estimated cycles | (Δ%)
Estimated Cycles Upper Boundary
estimated cycles | (%)
InstructionsInstructions Results
instructions | (Δ%)
Instructions Upper Boundary
instructions | (%)
L1 AccessesL1 Accesses Results
accesses | (Δ%)
L1 Accesses Upper Boundary
accesses | (%)
L2 AccessesL2 Accesses Results
accesses | (Δ%)
L2 Accesses Upper Boundary
accesses | (%)
RAM AccessesRAM Accesses Results
accesses | (Δ%)
RAM Accesses Upper Boundary
accesses | (%)
client_sv2_handle_message_common✅ (view plot)2,111.00 (+2.77%)2,140.03 (98.64%)✅ (view plot)473.00 (+0.51%)486.87 (97.15%)✅ (view plot)731.00 (-0.06%)755.20 (96.80%)✅ (view plot)10.00 (+33.69%)12.03 (83.13%)✅ (view plot)38.00 (+3.49%)38.79 (97.97%)
client_sv2_handle_message_mining✅ (view plot)8,211.00 (+0.12%)8,351.44 (98.32%)✅ (view plot)2,137.00 (+0.49%)2,172.01 (98.39%)✅ (view plot)3,161.00 (+0.58%)3,215.75 (98.30%)✅ (view plot)37.00 (-5.61%)43.33 (85.38%)✅ (view plot)139.00 (+0.04%)142.27 (97.70%)
client_sv2_mining_message_submit_standard✅ (view plot)6,246.00 (-0.59%)6,395.00 (97.67%)✅ (view plot)1,750.00 (+0.03%)1,763.75 (99.22%)✅ (view plot)2,556.00 (+0.10%)2,576.26 (99.21%)✅ (view plot)17.00 (-4.39%)22.88 (74.29%)✅ (view plot)103.00 (-0.98%)107.05 (96.22%)
client_sv2_mining_message_submit_standard_serialize✅ (view plot)14,901.00 (+0.76%)15,068.70 (98.89%)✅ (view plot)4,694.00 (+0.01%)4,707.75 (99.71%)✅ (view plot)6,751.00 (-0.04%)6,775.63 (99.64%)✅ (view plot)48.00 (+0.38%)53.05 (90.48%)✅ (view plot)226.00 (+1.45%)230.79 (97.92%)
client_sv2_mining_message_submit_standard_serialize_deserialize✅ (view plot)27,666.00 (+0.62%)27,900.98 (99.16%)✅ (view plot)10,545.00 (+0.03%)10,558.99 (99.87%)✅ (view plot)15,336.00 (-0.01%)15,360.46 (99.84%)✅ (view plot)86.00 (+2.14%)90.60 (94.92%)✅ (view plot)340.00 (+1.38%)346.79 (98.04%)
client_sv2_open_channel✅ (view plot)4,527.00 (+0.73%)4,615.89 (98.07%)✅ (view plot)1,461.00 (+0.06%)1,475.02 (99.05%)✅ (view plot)2,152.00 (-0.03%)2,173.62 (99.01%)✅ (view plot)13.00 (+8.15%)15.49 (83.94%)✅ (view plot)66.00 (+1.26%)68.27 (96.67%)
client_sv2_open_channel_serialize✅ (view plot)14,330.00 (+0.68%)14,493.74 (98.87%)✅ (view plot)5,064.00 (+0.02%)5,078.02 (99.72%)✅ (view plot)7,315.00 (-0.03%)7,339.86 (99.66%)✅ (view plot)38.00 (+1.93%)41.86 (90.77%)✅ (view plot)195.00 (+1.43%)199.72 (97.64%)
client_sv2_open_channel_serialize_deserialize✅ (view plot)22,806.00 (+0.63%)23,090.50 (98.77%)✅ (view plot)7,987.00 (+0.05%)8,001.55 (99.82%)✅ (view plot)11,611.00 (-0.01%)11,636.88 (99.78%)✅ (view plot)76.00 (+3.77%)81.93 (92.76%)✅ (view plot)309.00 (+1.21%)316.70 (97.57%)
client_sv2_setup_connection✅ (view plot)4,699.00 (-0.05%)4,768.13 (98.55%)✅ (view plot)1,502.00 (+0.05%)1,516.02 (99.08%)✅ (view plot)2,279.00 (+0.10%)2,300.42 (99.07%)✅ (view plot)8.00 (-12.85%)13.44 (59.54%)✅ (view plot)68.00 (+0.06%)69.65 (97.64%)
client_sv2_setup_connection_serialize✅ (view plot)16,330.00 (+0.41%)16,467.82 (99.16%)✅ (view plot)5,963.00 (+0.01%)5,977.02 (99.77%)✅ (view plot)8,655.00 (-0.00%)8,678.43 (99.73%)✅ (view plot)44.00 (-1.35%)49.24 (89.36%)✅ (view plot)213.00 (+0.94%)216.72 (98.28%)
client_sv2_setup_connection_serialize_deserialize✅ (view plot)35,616.00 (+0.20%)35,773.71 (99.56%)✅ (view plot)14,814.00 (+0.03%)14,828.55 (99.90%)✅ (view plot)21,746.00 (-0.01%)21,772.69 (99.88%)✅ (view plot)107.00 (+6.85%)114.96 (93.07%)✅ (view plot)381.00 (+0.31%)384.79 (99.02%)

Bencher - Continuous Benchmarking
View Public Perf Page
Docs | Repo | Chat | Help

@plebhash plebhash merged commit a803f1a into stratum-mining:dev May 10, 2024
13 checks passed
@plebhash plebhash deleted the docs-framing-sv2 branch May 10, 2024 14:48
Fi3 pushed a commit that referenced this pull request May 28, 2024
@plebhash plebhash mentioned this pull request May 28, 2024
@plebhash plebhash changed the title docs framing_sv2 Rust Docs framing_sv2 Jul 20, 2024
@plebhash plebhash mentioned this pull request Aug 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done ✅
Development

Successfully merging this pull request may close these issues.

3 participants