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

Add support for data types defined by sv2 extensions #1113

Merged
merged 1 commit into from
Aug 19, 2024

Conversation

Fi3
Copy link
Collaborator

@Fi3 Fi3 commented Aug 19, 2024

In no-serde-sv2 an sv2 sequence is generic over T. If we want this sequence to be Deserialize we need T to be Fixed and GerMarker. This 2 traits were private since all the sv2 types are already defined in no-serde-sv2. But if we want to use sv2 types defined in an sv2 extensions we need to make these traits public.

The Encodable dervive macro in derive_codec implement GetSize for the passed struct. But GetSize is also a blanket implementation for every type that implement Fixed. So if we implement Fixed for our new sv2 type and then we derive Encodable (commonly renamed Serialize) we get an error. This commit add an attribute to Encodable called already_sized if the struct that we want derive Encodable is market as already_sized the macro will not implement GetSize for it.

This commit also bump minor version of derive_codec and no-serde-sv2 consequentially also of binary-sv2 since it reexport the above libs.

This PR is the minimum needed in order to use binary-sv2 with externally defined sv2 types. An improvement would be to automatically derive Fixed and GetMarker. This can be done in a successive PR to keep thing simple

Copy link
Contributor

github-actions bot commented Aug 19, 2024

🐰Bencher

ReportMon, August 19, 2024 at 15:18:48 UTC
ProjectStratum v2 (SRI)
BranchAddSupportForExtensionTypes
Testbedsv2

🚨 9 ALERTS: Threshold Boundary Limits exceeded!
BenchmarkMeasure (units)ViewValueLower BoundaryUpper Boundary
client_sv2_handle_message_commonEstimated Cycles (estimated cycles)🚨 (view plot | view alert)2,179.00 (+5.93%)2,150.14 (101.34%)
client_sv2_handle_message_commonRAM Accesses (accesses)🚨 (view plot | view alert)40.00 (+8.61%)39.14 (102.19%)
client_sv2_mining_message_submit_standard_serialize_deserializeInstructions (instructions)🚨 (view plot | view alert)10,591.00 (+0.42%)10,581.61 (100.09%)
client_sv2_mining_message_submit_standard_serialize_deserializeL1 Accesses (accesses)🚨 (view plot | view alert)15,402.00 (+0.37%)15,391.49 (100.07%)
client_sv2_open_channel_serialize_deserializeInstructions (instructions)🚨 (view plot | view alert)8,027.00 (+0.49%)8,020.59 (100.08%)
client_sv2_open_channel_serialize_deserializeL1 Accesses (accesses)🚨 (view plot | view alert)11,666.00 (+0.41%)11,660.97 (100.04%)
client_sv2_setup_connection_serializeL2 Accesses (accesses)🚨 (view plot | view alert)51.00 (+12.90%)50.79 (100.41%)
client_sv2_setup_connection_serialize_deserializeInstructions (instructions)🚨 (view plot | view alert)14,855.00 (+0.27%)14,848.24 (100.05%)
client_sv2_setup_connection_serialize_deserializeL1 Accesses (accesses)🚨 (view plot | view alert)21,809.00 (+0.24%)21,800.90 (100.04%)

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 | view alert)2,179.00 (+5.93%)2,150.14 (101.34%)✅ (view plot)473.00 (+0.45%)486.03 (97.32%)✅ (view plot)729.00 (-0.41%)754.26 (96.65%)✅ (view plot)10.00 (+38.76%)11.28 (88.67%)🚨 (view plot | view alert)40.00 (+8.61%)39.14 (102.19%)
client_sv2_handle_message_mining✅ (view plot)8,221.00 (+0.27%)8,333.82 (98.65%)✅ (view plot)2,143.00 (+0.68%)2,171.87 (98.67%)✅ (view plot)3,166.00 (+0.63%)3,216.15 (98.44%)✅ (view plot)38.00 (-1.25%)43.38 (87.60%)✅ (view plot)139.00 (+0.10%)141.87 (97.98%)
client_sv2_mining_message_submit_standard✅ (view plot)6,378.00 (+1.55%)6,397.27 (99.70%)✅ (view plot)1,756.00 (+0.34%)1,763.78 (99.56%)✅ (view plot)2,553.00 (-0.03%)2,575.18 (99.14%)✅ (view plot)23.00 (+28.02%)23.87 (96.35%)✅ (view plot)106.00 (+2.01%)106.99 (99.07%)
client_sv2_mining_message_submit_standard_serialize✅ (view plot)14,877.00 (+0.66%)15,030.09 (98.98%)✅ (view plot)4,700.00 (+0.13%)4,707.78 (99.83%)✅ (view plot)6,757.00 (+0.03%)6,775.08 (99.73%)✅ (view plot)49.00 (+3.31%)52.24 (93.79%)✅ (view plot)225.00 (+1.13%)229.81 (97.91%)
client_sv2_mining_message_submit_standard_serialize_deserialize✅ (view plot)27,697.00 (+0.75%)27,857.64 (99.42%)🚨 (view plot | view alert)10,591.00 (+0.42%)10,581.61 (100.09%)🚨 (view plot | view alert)15,402.00 (+0.37%)15,391.49 (100.07%)✅ (view plot)86.00 (+2.42%)89.65 (95.93%)✅ (view plot)339.00 (+1.18%)345.26 (98.19%)
client_sv2_open_channel✅ (view plot)4,421.00 (-1.37%)4,616.13 (95.77%)✅ (view plot)1,461.00 (+0.05%)1,473.99 (99.12%)✅ (view plot)2,156.00 (+0.14%)2,172.75 (99.23%)✅ (view plot)12.00 (+0.14%)15.12 (79.38%)✅ (view plot)63.00 (-2.84%)68.42 (92.08%)
client_sv2_open_channel_serialize✅ (view plot)14,160.00 (-0.34%)14,451.79 (97.98%)✅ (view plot)5,064.00 (+0.01%)5,076.99 (99.74%)✅ (view plot)7,320.00 (+0.03%)7,338.88 (99.74%)✅ (view plot)38.00 (+1.80%)41.90 (90.69%)✅ (view plot)190.00 (-0.81%)198.63 (95.65%)
client_sv2_open_channel_serialize_deserialize✅ (view plot)22,791.00 (+0.63%)23,022.37 (99.00%)🚨 (view plot | view alert)8,027.00 (+0.49%)8,020.59 (100.08%)🚨 (view plot | view alert)11,666.00 (+0.41%)11,660.97 (100.04%)✅ (view plot)83.00 (+11.95%)84.16 (98.62%)✅ (view plot)306.00 (+0.48%)314.61 (97.26%)
client_sv2_setup_connection✅ (view plot)4,761.00 (+1.29%)4,768.72 (99.84%)✅ (view plot)1,502.00 (+0.05%)1,514.99 (99.14%)✅ (view plot)2,271.00 (-0.24%)2,298.67 (98.80%)✅ (view plot)15.00 (+56.47%)15.13 (99.12%)✅ (view plot)69.00 (+1.65%)69.67 (99.04%)
client_sv2_setup_connection_serialize✅ (view plot)16,256.00 (-0.03%)16,482.29 (98.63%)✅ (view plot)5,963.00 (+0.01%)5,975.99 (99.78%)✅ (view plot)8,651.00 (-0.04%)8,676.59 (99.71%)🚨 (view plot | view alert)51.00 (+12.90%)50.79 (100.41%)✅ (view plot)210.00 (-0.41%)217.28 (96.65%)
client_sv2_setup_connection_serialize_deserialize✅ (view plot)35,664.00 (+0.35%)35,750.51 (99.76%)🚨 (view plot | view alert)14,855.00 (+0.27%)14,848.24 (100.05%)🚨 (view plot | view alert)21,809.00 (+0.24%)21,800.90 (100.04%)✅ (view plot)104.00 (+4.00%)112.85 (92.16%)✅ (view plot)381.00 (+0.38%)384.43 (99.11%)

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

Copy link
Contributor

github-actions bot commented Aug 19, 2024

🐰Bencher

ReportMon, August 19, 2024 at 15:18:49 UTC
ProjectStratum v2 (SRI)
Branch1113/merge
Testbedsv1

🚨 1 ALERT: Threshold Boundary Limit exceeded!
BenchmarkMeasure (units)ViewValueLower BoundaryUpper Boundary
client-sv1-subscribe-serialize/client-sv1-subscribe-serializeLatency (nanoseconds (ns))🚨 (view plot | view alert)228.77 (+10.61%)221.79 (103.15%)

Click to view all benchmark results
BenchmarkLatencyLatency Results
nanoseconds (ns) | (Δ%)
Latency Upper Boundary
nanoseconds (ns) | (%)
client-submit-serialize✅ (view plot)6,497.10 (-5.59%)7,381.34 (88.02%)
client-submit-serialize-deserialize✅ (view plot)7,195.60 (-7.74%)8,358.22 (86.09%)
client-submit-serialize-deserialize-handle/client-submit-serialize-deserialize-handle✅ (view plot)7,867.60 (-5.94%)8,885.38 (88.55%)
client-sv1-authorize-serialize-deserialize-handle/client-sv1-authorize-serialize-deserialize-handle✅ (view plot)908.51 (+1.14%)926.49 (98.06%)
client-sv1-authorize-serialize-deserialize/client-sv1-authorize-serialize-deserialize✅ (view plot)713.20 (+2.32%)717.76 (99.36%)
client-sv1-authorize-serialize/client-sv1-authorize-serialize✅ (view plot)252.29 (+1.65%)255.11 (98.90%)
client-sv1-get-authorize/client-sv1-get-authorize✅ (view plot)156.85 (-0.20%)162.19 (96.71%)
client-sv1-get-submit✅ (view plot)6,309.20 (-5.16%)7,152.13 (88.21%)
client-sv1-get-subscribe/client-sv1-get-subscribe✅ (view plot)281.23 (+0.94%)290.62 (96.77%)
client-sv1-subscribe-serialize-deserialize-handle/client-sv1-subscribe-serialize-deserialize-handle✅ (view plot)763.92 (+2.06%)777.51 (98.25%)
client-sv1-subscribe-serialize-deserialize/client-sv1-subscribe-serialize-deserialize✅ (view plot)629.27 (+2.21%)639.17 (98.45%)
client-sv1-subscribe-serialize/client-sv1-subscribe-serialize🚨 (view plot | view alert)228.77 (+10.61%)221.79 (103.15%)

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

Copy link
Contributor

github-actions bot commented Aug 19, 2024

🐰Bencher

ReportMon, August 19, 2024 at 15:18:48 UTC
ProjectStratum v2 (SRI)
BranchAddSupportForExtensionTypes
Testbedsv1

🚨 1 ALERT: Threshold Boundary Limit exceeded!
BenchmarkMeasure (units)ViewValueLower BoundaryUpper Boundary
serialize_subscribeRAM Accesses (accesses)🚨 (view plot | view alert)161.00 (+3.43%)160.96 (100.03%)

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,541.00 (+1.18%)8,724.73 (97.89%)✅ (view plot)3,772.00 (+0.77%)3,855.65 (97.83%)✅ (view plot)5,296.00 (+0.89%)5,403.78 (98.01%)✅ (view plot)5.00 (-35.16%)10.63 (47.02%)✅ (view plot)92.00 (+2.11%)94.04 (97.83%)
get_submit✅ (view plot)95,688.00 (+0.13%)96,136.02 (99.53%)✅ (view plot)59,522.00 (+0.08%)59,774.77 (99.58%)✅ (view plot)85,498.00 (+0.10%)85,834.36 (99.61%)✅ (view plot)50.00 (-8.73%)62.42 (80.10%)✅ (view plot)284.00 (+0.64%)287.69 (98.72%)
get_subscribe✅ (view plot)8,102.00 (+1.46%)8,275.97 (97.90%)✅ (view plot)2,848.00 (+0.59%)2,937.98 (96.94%)✅ (view plot)3,982.00 (+0.66%)4,097.80 (97.17%)✅ (view plot)12.00 (-24.44%)20.08 (59.75%)✅ (view plot)116.00 (+2.78%)117.33 (98.86%)
serialize_authorize✅ (view plot)12,392.00 (+1.42%)12,521.18 (98.97%)✅ (view plot)5,343.00 (+0.55%)5,426.65 (98.46%)✅ (view plot)7,457.00 (+0.61%)7,566.75 (98.55%)✅ (view plot)7.00 (-33.28%)13.83 (50.62%)✅ (view plot)140.00 (+3.06%)140.87 (99.38%)
serialize_deserialize_authorize✅ (view plot)24,614.00 (+0.55%)24,719.57 (99.57%)✅ (view plot)9,950.00 (+0.46%)10,029.82 (99.20%)✅ (view plot)14,049.00 (+0.54%)14,158.75 (99.22%)✅ (view plot)34.00 (-6.65%)41.43 (82.07%)✅ (view plot)297.00 (+0.70%)297.87 (99.71%)
serialize_deserialize_handle_authorize✅ (view plot)30,214.00 (+0.22%)30,338.14 (99.59%)✅ (view plot)12,127.00 (+0.24%)12,210.65 (99.31%)✅ (view plot)17,164.00 (+0.25%)17,281.06 (99.32%)✅ (view plot)62.00 (+4.93%)65.18 (95.12%)✅ (view plot)364.00 (+0.07%)366.84 (99.23%)
serialize_deserialize_handle_submit✅ (view plot)126,443.00 (+0.02%)127,015.80 (99.55%)✅ (view plot)73,307.00 (+0.07%)73,614.84 (99.58%)✅ (view plot)105,098.00 (+0.09%)105,508.56 (99.61%)✅ (view plot)111.00 (-7.28%)131.52 (84.40%)✅ (view plot)594.00 (-0.13%)599.03 (99.16%)
serialize_deserialize_handle_subscribe✅ (view plot)27,516.00 (+0.21%)27,605.28 (99.68%)✅ (view plot)9,650.00 (+0.17%)9,739.98 (99.08%)✅ (view plot)13,651.00 (+0.19%)13,773.29 (99.11%)✅ (view plot)64.00 (-2.83%)73.49 (87.09%)✅ (view plot)387.00 (+0.30%)388.63 (99.58%)
serialize_deserialize_submit✅ (view plot)115,239.00 (+0.12%)115,656.30 (99.64%)✅ (view plot)68,167.00 (+0.15%)68,407.46 (99.65%)✅ (view plot)97,844.00 (+0.18%)98,164.70 (99.67%)✅ (view plot)63.00 (-8.65%)75.68 (83.25%)✅ (view plot)488.00 (-0.02%)492.20 (99.15%)
serialize_deserialize_subscribe✅ (view plot)23,020.00 (+0.59%)23,124.63 (99.55%)✅ (view plot)8,209.00 (+0.26%)8,296.45 (98.95%)✅ (view plot)11,565.00 (+0.28%)11,682.10 (99.00%)✅ (view plot)37.00 (-5.74%)43.91 (84.27%)✅ (view plot)322.00 (+1.02%)322.09 (99.97%)
serialize_submit✅ (view plot)100,099.00 (+0.19%)100,476.92 (99.62%)✅ (view plot)61,566.00 (+0.08%)61,823.91 (99.58%)✅ (view plot)88,344.00 (+0.09%)88,687.52 (99.61%)✅ (view plot)48.00 (-13.00%)62.78 (76.46%)✅ (view plot)329.00 (+1.24%)329.85 (99.74%)
serialize_subscribe✅ (view plot)11,541.00 (+1.75%)11,635.62 (99.19%)✅ (view plot)4,195.00 (+0.40%)4,284.98 (97.90%)✅ (view plot)5,836.00 (+0.38%)5,956.38 (97.98%)✅ (view plot)14.00 (-13.51%)19.04 (73.52%)🚨 (view plot | view alert)161.00 (+3.43%)160.96 (100.03%)

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

Copy link
Contributor

github-actions bot commented Aug 19, 2024

🐰Bencher

ReportMon, August 19, 2024 at 15:18:48 UTC
ProjectStratum v2 (SRI)
BranchAddSupportForExtensionTypes
Testbedsv2
Click to view all benchmark results
BenchmarkLatencyLatency Results
nanoseconds (ns) | (Δ%)
Latency Upper Boundary
nanoseconds (ns) | (%)
client_sv2_handle_message_common✅ (view plot)44.85 (+0.56%)45.37 (98.84%)
client_sv2_handle_message_mining✅ (view plot)74.48 (+2.08%)80.32 (92.73%)
client_sv2_mining_message_submit_standard✅ (view plot)14.63 (-0.12%)14.69 (99.59%)
client_sv2_mining_message_submit_standard_serialize✅ (view plot)266.46 (+0.63%)283.92 (93.85%)
client_sv2_mining_message_submit_standard_serialize_deserialize✅ (view plot)605.66 (+1.83%)627.39 (96.54%)
client_sv2_open_channel✅ (view plot)167.20 (+0.60%)174.28 (95.94%)
client_sv2_open_channel_serialize✅ (view plot)270.16 (-4.20%)294.51 (91.73%)
client_sv2_open_channel_serialize_deserialize✅ (view plot)370.08 (-2.04%)421.98 (87.70%)
client_sv2_setup_connection✅ (view plot)161.74 (-1.25%)174.72 (92.57%)
client_sv2_setup_connection_serialize✅ (view plot)450.67 (-4.62%)506.20 (89.03%)
client_sv2_setup_connection_serialize_deserialize✅ (view plot)990.82 (+2.09%)1,041.61 (95.12%)

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

@Fi3 Fi3 force-pushed the AddSupportForExtensionTypes branch 2 times, most recently from 32db718 to 7daaf56 Compare August 19, 2024 09:54
@Fi3 Fi3 force-pushed the AddSupportForExtensionTypes branch from 7daaf56 to e179222 Compare August 19, 2024 14:45
In no-serde-sv2 an sv2 sequence is generic over T. If we want this
sequence to be Deserialize we need T to be Fixed and GerMarker. This 2
traits were private since all the sv2 types are already defined in
no-serde-sv2. But if we want to use sv2 types defined in an sv2
extensions we need to make these traits public.

The Encodable dervive macro in derive_codec implement GetSize for the
passed struct. But GetSize is also a blanket implementation for every
type that implement Fixed. So if we implement Fixed for our new sv2 type
and then we derive Encodable (commonly renamed Serialize) we get an
error. This commit add an attribute to Encodable called already_sized if the
struct that we want derive Encodable is market as already_sized the
macro will not implement GetSize for it.

This commit also bump minor version of derive_codec and no-serde-sv2
consequentially also of binary-sv2 since it reexport the above libs.
@Fi3 Fi3 force-pushed the AddSupportForExtensionTypes branch from e179222 to 8e50099 Compare August 19, 2024 15:11
@Fi3 Fi3 merged commit 98be997 into stratum-mining:dev Aug 19, 2024
33 checks passed
@plebhash plebhash mentioned this pull request Aug 19, 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