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

Fix for issue where JDC stops receiving shares after rapid block succession #1146

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

xyephy
Copy link
Contributor

@xyephy xyephy commented Aug 26, 2024

This PR addresses issue #920, where JDC stops receiving valid shares from the Translator when two new blocks are found within a few seconds. The problem occurs due to a race condition in the handling of SetCustomMiningJob messages, leading to the JDC not registering job IDs properly.

Changes to be Made:

  • Add a check in downstream.rs to ensure SetCustomMiningJobSuccess is received before processing the next NewTemplate.
  • Implement a retry mechanism in upstream.rs for handling missed SetCustomMiningJobSuccess messages.
  • Add unit, integration, and stress tests to verify the correctness and robustness of the solution.
  • Improve logging and error handling in the relevant modules.

Testing:

  • Unit tests cover the new retry logic and job ID management.
  • Integration tests simulate the entire message flow, ensuring correct behavior.
  • Stress tests were conducted by simulating rapid block succession to verify system stability under high load.

This PR addresses issue stratum-mining#920, where JDC  stops receiving valid shares from the Translator when two new blocks are found within a few seconds. The problem occurs due to a race condition in the handling of SetCustomMiningJob messages, leading to the JDC not registering job IDs properly.
@xyephy xyephy marked this pull request as draft August 26, 2024 13:55
Copy link
Contributor

🐰Bencher

ReportMon, August 26, 2024 at 13:59:20 UTC
ProjectStratum v2 (SRI)
Branchfix-jdc-shares-issue-920
Testbedsv2

🚨 10 ALERTS: Threshold Boundary Limits exceeded!
BenchmarkMeasure (units)ViewValueLower BoundaryUpper Boundary
client_sv2_handle_message_commonEstimated Cycles (estimated cycles)🚨 (view plot | view alert)2,153.00 (+4.73%)2,144.45 (100.40%)
client_sv2_handle_message_commonL2 Accesses (accesses)🚨 (view plot | view alert)12.00 (+67.31%)11.61 (103.38%)
client_sv2_handle_message_commonRAM Accesses (accesses)🚨 (view plot | view alert)39.00 (+6.00%)38.96 (100.11%)
client_sv2_mining_message_submit_standard_serialize_deserializeInstructions (instructions)🚨 (view plot | view alert)10,591.00 (+0.44%)10,575.99 (100.14%)
client_sv2_mining_message_submit_standard_serialize_deserializeL1 Accesses (accesses)🚨 (view plot | view alert)15,404.00 (+0.39%)15,384.23 (100.13%)
client_sv2_open_channel_serialize_deserializeInstructions (instructions)🚨 (view plot | view alert)8,027.00 (+0.51%)8,015.26 (100.15%)
client_sv2_open_channel_serialize_deserializeL1 Accesses (accesses)🚨 (view plot | view alert)11,667.00 (+0.43%)11,653.62 (100.11%)
client_sv2_open_channel_serialize_deserializeL2 Accesses (accesses)🚨 (view plot | view alert)85.00 (+15.00%)83.73 (101.52%)
client_sv2_setup_connection_serialize_deserializeInstructions (instructions)🚨 (view plot | view alert)14,855.00 (+0.28%)14,842.76 (100.08%)
client_sv2_setup_connection_serialize_deserializeL1 Accesses (accesses)🚨 (view plot | view alert)21,813.00 (+0.27%)21,794.06 (100.09%)

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,153.00 (+4.73%)2,144.45 (100.40%)✅ (view plot)473.00 (+0.45%)486.03 (97.32%)✅ (view plot)728.00 (-0.56%)754.41 (96.50%)🚨 (view plot | view alert)12.00 (+67.31%)11.61 (103.38%)🚨 (view plot | view alert)39.00 (+6.00%)38.96 (100.11%)
client_sv2_handle_message_mining✅ (view plot)8,251.00 (+0.62%)8,336.49 (98.97%)✅ (view plot)2,143.00 (+0.69%)2,171.65 (98.68%)✅ (view plot)3,166.00 (+0.63%)3,216.14 (98.44%)✅ (view plot)37.00 (-3.46%)43.39 (85.27%)✅ (view plot)140.00 (+0.78%)141.97 (98.61%)
client_sv2_mining_message_submit_standard✅ (view plot)6,378.00 (+1.56%)6,397.77 (99.69%)✅ (view plot)1,756.00 (+0.34%)1,763.58 (99.57%)✅ (view plot)2,553.00 (-0.04%)2,575.29 (99.13%)✅ (view plot)23.00 (+29.89%)23.14 (99.38%)✅ (view plot)106.00 (+1.99%)107.03 (99.04%)
client_sv2_mining_message_submit_standard_serialize✅ (view plot)14,843.00 (+0.40%)15,034.27 (98.73%)✅ (view plot)4,700.00 (+0.13%)4,707.58 (99.84%)✅ (view plot)6,758.00 (+0.05%)6,774.94 (99.75%)✅ (view plot)49.00 (+3.72%)51.66 (94.85%)✅ (view plot)224.00 (+0.60%)229.92 (97.42%)
client_sv2_mining_message_submit_standard_serialize_deserialize✅ (view plot)27,629.00 (+0.51%)27,852.93 (99.20%)🚨 (view plot | view alert)10,591.00 (+0.44%)10,575.99 (100.14%)🚨 (view plot | view alert)15,404.00 (+0.39%)15,384.23 (100.13%)✅ (view plot)86.00 (+2.70%)89.12 (96.50%)✅ (view plot)337.00 (+0.57%)345.25 (97.61%)
client_sv2_open_channel✅ (view plot)4,395.00 (-2.05%)4,618.69 (95.16%)✅ (view plot)1,461.00 (+0.05%)1,473.99 (99.12%)✅ (view plot)2,155.00 (+0.10%)2,172.36 (99.20%)✅ (view plot)14.00 (+15.50%)15.39 (90.98%)✅ (view plot)62.00 (-4.56%)68.52 (90.48%)
client_sv2_open_channel_serialize✅ (view plot)14,114.00 (-0.71%)14,453.28 (97.65%)✅ (view plot)5,064.00 (+0.01%)5,076.99 (99.74%)✅ (view plot)7,324.00 (+0.08%)7,339.06 (99.79%)✅ (view plot)35.00 (-5.54%)41.30 (84.75%)✅ (view plot)189.00 (-1.44%)198.62 (95.16%)
client_sv2_open_channel_serialize_deserialize✅ (view plot)22,697.00 (+0.21%)23,020.46 (98.59%)🚨 (view plot | view alert)8,027.00 (+0.51%)8,015.26 (100.15%)🚨 (view plot | view alert)11,667.00 (+0.43%)11,653.62 (100.11%)🚨 (view plot | view alert)85.00 (+15.00%)83.73 (101.52%)✅ (view plot)303.00 (-0.54%)314.64 (96.30%)
client_sv2_setup_connection✅ (view plot)4,723.00 (+0.49%)4,766.25 (99.09%)✅ (view plot)1,502.00 (+0.05%)1,514.99 (99.14%)✅ (view plot)2,273.00 (-0.16%)2,298.84 (98.88%)✅ (view plot)14.00 (+50.65%)14.20 (98.60%)✅ (view plot)68.00 (+0.13%)69.63 (97.66%)
client_sv2_setup_connection_serialize✅ (view plot)16,214.00 (-0.35%)16,479.66 (98.39%)✅ (view plot)5,963.00 (+0.01%)5,975.99 (99.78%)✅ (view plot)8,654.00 (-0.01%)8,676.42 (99.74%)✅ (view plot)49.00 (+9.01%)49.80 (98.40%)✅ (view plot)209.00 (-1.03%)217.12 (96.26%)
client_sv2_setup_connection_serialize_deserialize✅ (view plot)35,588.00 (+0.13%)35,750.03 (99.55%)🚨 (view plot | view alert)14,855.00 (+0.28%)14,842.76 (100.08%)🚨 (view plot | view alert)21,813.00 (+0.27%)21,794.06 (100.09%)✅ (view plot)102.00 (+2.25%)112.30 (90.83%)✅ (view plot)379.00 (-0.19%)384.29 (98.62%)

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

Copy link
Contributor

🐰Bencher

ReportMon, August 26, 2024 at 13:59:20 UTC
ProjectStratum v2 (SRI)
Branchfix-jdc-shares-issue-920
Testbedsv1

🚨 4 ALERTS: Threshold Boundary Limits exceeded!
BenchmarkMeasure (units)ViewValueLower BoundaryUpper Boundary
serialize_deserialize_authorizeRAM Accesses (accesses)🚨 (view plot | view alert)299.00 (+1.40%)298.02 (100.33%)
serialize_deserialize_handle_subscribeRAM Accesses (accesses)🚨 (view plot | view alert)390.00 (+1.09%)389.20 (100.21%)
serialize_deserialize_subscribeRAM Accesses (accesses)🚨 (view plot | view alert)324.00 (+1.66%)322.43 (100.49%)
serialize_subscribeRAM Accesses (accesses)🚨 (view plot | view alert)161.00 (+3.55%)160.85 (100.09%)

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.31%)8,744.22 (97.68%)✅ (view plot)3,772.00 (+0.87%)3,864.38 (97.61%)✅ (view plot)5,296.00 (+0.97%)5,414.16 (97.82%)✅ (view plot)5.00 (-35.31%)10.59 (47.20%)✅ (view plot)92.00 (+2.32%)94.21 (97.65%)
get_submit✅ (view plot)95,718.00 (+0.17%)96,168.93 (99.53%)✅ (view plot)59,522.00 (+0.09%)59,779.04 (99.57%)✅ (view plot)85,498.00 (+0.10%)85,838.35 (99.60%)✅ (view plot)49.00 (-10.61%)62.64 (78.22%)✅ (view plot)285.00 (+1.09%)288.77 (98.69%)
get_subscribe✅ (view plot)8,102.00 (+1.60%)8,298.48 (97.63%)✅ (view plot)2,848.00 (+0.73%)2,948.57 (96.59%)✅ (view plot)3,982.00 (+0.78%)4,111.38 (96.85%)✅ (view plot)12.00 (-24.68%)20.29 (59.15%)✅ (view plot)116.00 (+2.95%)117.47 (98.75%)
serialize_authorize✅ (view plot)12,392.00 (+1.51%)12,539.00 (98.83%)✅ (view plot)5,343.00 (+0.61%)5,435.38 (98.30%)✅ (view plot)7,457.00 (+0.67%)7,577.13 (98.41%)✅ (view plot)7.00 (-33.60%)13.74 (50.95%)✅ (view plot)140.00 (+3.21%)140.93 (99.34%)
serialize_deserialize_authorize✅ (view plot)24,670.00 (+0.81%)24,733.17 (99.74%)✅ (view plot)9,950.00 (+0.49%)10,036.13 (99.14%)✅ (view plot)14,050.00 (+0.57%)14,165.86 (99.18%)✅ (view plot)31.00 (-14.81%)41.90 (73.98%)🚨 (view plot | view alert)299.00 (+1.40%)298.02 (100.33%)
serialize_deserialize_handle_authorize✅ (view plot)30,308.00 (+0.56%)30,378.75 (99.77%)✅ (view plot)12,127.00 (+0.27%)12,219.38 (99.24%)✅ (view plot)17,163.00 (+0.27%)17,291.41 (99.26%)✅ (view plot)60.00 (+2.08%)64.61 (92.87%)✅ (view plot)367.00 (+0.91%)367.32 (99.91%)
serialize_deserialize_handle_submit✅ (view plot)126,609.00 (+0.16%)127,077.87 (99.63%)✅ (view plot)73,307.00 (+0.08%)73,624.10 (99.57%)✅ (view plot)105,094.00 (+0.10%)105,519.48 (99.60%)✅ (view plot)110.00 (-8.00%)132.08 (83.28%)✅ (view plot)599.00 (+0.72%)600.76 (99.71%)
serialize_deserialize_handle_subscribe✅ (view plot)27,622.00 (+0.62%)27,652.75 (99.89%)✅ (view plot)9,650.00 (+0.21%)9,750.57 (98.97%)✅ (view plot)13,647.00 (+0.20%)13,786.37 (98.99%)✅ (view plot)65.00 (-1.36%)73.50 (88.43%)🚨 (view plot | view alert)390.00 (+1.09%)389.20 (100.21%)
serialize_deserialize_submit✅ (view plot)115,367.00 (+0.24%)115,690.75 (99.72%)✅ (view plot)68,167.00 (+0.15%)68,409.27 (99.65%)✅ (view plot)97,842.00 (+0.18%)98,165.26 (99.67%)✅ (view plot)61.00 (-11.68%)76.22 (80.03%)✅ (view plot)492.00 (+0.81%)493.65 (99.67%)
serialize_deserialize_subscribe✅ (view plot)23,088.00 (+0.92%)23,148.21 (99.74%)✅ (view plot)8,209.00 (+0.30%)8,306.38 (98.83%)✅ (view plot)11,563.00 (+0.31%)11,694.50 (98.88%)✅ (view plot)37.00 (-5.95%)43.97 (84.14%)🚨 (view plot | view alert)324.00 (+1.66%)322.43 (100.49%)
serialize_submit✅ (view plot)100,125.00 (+0.23%)100,506.59 (99.62%)✅ (view plot)61,566.00 (+0.08%)61,828.09 (99.58%)✅ (view plot)88,345.00 (+0.10%)88,691.62 (99.61%)✅ (view plot)46.00 (-16.85%)63.23 (72.76%)✅ (view plot)330.00 (+1.63%)330.99 (99.70%)
serialize_subscribe✅ (view plot)11,541.00 (+1.85%)11,652.06 (99.05%)✅ (view plot)4,195.00 (+0.49%)4,295.57 (97.66%)✅ (view plot)5,836.00 (+0.47%)5,970.19 (97.75%)✅ (view plot)14.00 (-13.60%)19.32 (72.48%)🚨 (view plot | view alert)161.00 (+3.55%)160.85 (100.09%)

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

Copy link
Contributor

🐰Bencher

ReportMon, August 26, 2024 at 13:59:21 UTC
ProjectStratum v2 (SRI)
Branch1146/merge
Testbedsv1
Click to view all benchmark results
BenchmarkLatencyLatency Results
nanoseconds (ns) | (Δ%)
Latency Upper Boundary
nanoseconds (ns) | (%)
client-submit-serialize✅ (view plot)6,439.30 (-7.11%)7,359.38 (87.50%)
client-submit-serialize-deserialize✅ (view plot)7,394.50 (-5.89%)8,351.79 (88.54%)
client-submit-serialize-deserialize-handle/client-submit-serialize-deserialize-handle✅ (view plot)7,996.30 (-5.06%)8,854.01 (90.31%)
client-sv1-authorize-serialize-deserialize-handle/client-sv1-authorize-serialize-deserialize-handle✅ (view plot)903.73 (+0.58%)926.38 (97.55%)
client-sv1-authorize-serialize-deserialize/client-sv1-authorize-serialize-deserialize✅ (view plot)699.41 (+0.34%)717.63 (97.46%)
client-sv1-authorize-serialize/client-sv1-authorize-serialize✅ (view plot)248.53 (+0.20%)255.12 (97.42%)
client-sv1-get-authorize/client-sv1-get-authorize✅ (view plot)155.94 (-0.74%)162.35 (96.05%)
client-sv1-get-submit✅ (view plot)6,181.00 (-7.70%)7,158.30 (86.35%)
client-sv1-get-subscribe/client-sv1-get-subscribe✅ (view plot)279.39 (+0.29%)291.06 (95.99%)
client-sv1-subscribe-serialize-deserialize-handle/client-sv1-subscribe-serialize-deserialize-handle✅ (view plot)762.42 (+2.00%)776.55 (98.18%)
client-sv1-subscribe-serialize-deserialize/client-sv1-subscribe-serialize-deserialize✅ (view plot)621.84 (+1.18%)637.70 (97.51%)
client-sv1-subscribe-serialize/client-sv1-subscribe-serialize✅ (view plot)206.81 (+0.02%)219.87 (94.06%)

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

Copy link
Contributor

🐰Bencher

ReportMon, August 26, 2024 at 13:59:24 UTC
ProjectStratum v2 (SRI)
Branchfix-jdc-shares-issue-920
Testbedsv2
Click to view all benchmark results
BenchmarkLatencyLatency Results
nanoseconds (ns) | (Δ%)
Latency Upper Boundary
nanoseconds (ns) | (%)
client_sv2_handle_message_common✅ (view plot)45.34 (+1.67%)45.37 (99.93%)
client_sv2_handle_message_mining✅ (view plot)72.67 (-0.50%)80.82 (89.92%)
client_sv2_mining_message_submit_standard✅ (view plot)14.63 (-0.10%)14.69 (99.61%)
client_sv2_mining_message_submit_standard_serialize✅ (view plot)269.98 (+1.98%)284.04 (95.05%)
client_sv2_mining_message_submit_standard_serialize_deserialize✅ (view plot)614.31 (+3.43%)627.25 (97.94%)
client_sv2_open_channel✅ (view plot)164.18 (-0.77%)171.45 (95.76%)
client_sv2_open_channel_serialize✅ (view plot)277.03 (-2.05%)293.40 (94.42%)
client_sv2_open_channel_serialize_deserialize✅ (view plot)369.46 (-2.62%)427.17 (86.49%)
client_sv2_setup_connection✅ (view plot)159.83 (-2.49%)174.89 (91.39%)
client_sv2_setup_connection_serialize✅ (view plot)456.94 (-3.48%)504.37 (90.60%)
client_sv2_setup_connection_serialize_deserialize✅ (view plot)975.74 (+0.23%)1,044.92 (93.38%)

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

@plebhash plebhash changed the base branch from dev to main August 28, 2024 20:12
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.

1 participant