Fix timestamp bug - min_ntime becomes always the one sent by TP#1325
Conversation
f22291c to
eeee677
Compare
eeee677 to
4c97af4
Compare
|
| Branch | fix-timestamp-bug |
| Testbed | sv2 |
Click to view all benchmark results
| Benchmark | Latency | Benchmark Result nanoseconds (ns) (Result Δ%) | Upper Boundary nanoseconds (ns) (Limit %) |
|---|---|---|---|
| client_sv2_handle_message_common | 📈 view plot 🚷 view threshold | 44.34 (-2.00%) | 60.47 (73.32%) |
| client_sv2_handle_message_mining | 📈 view plot 🚷 view threshold | 92.52 (+18.05%) | 111.82 (82.75%) |
| client_sv2_mining_message_submit_standard | 📈 view plot 🚷 view threshold | 14.67 (+0.00%) | 14.72 (99.60%) |
| client_sv2_mining_message_submit_standard_serialize | 📈 view plot 🚷 view threshold | 252.42 (-4.64%) | 290.74 (86.82%) |
| client_sv2_mining_message_submit_standard_serialize_deserialize | 📈 view plot 🚷 view threshold | 609.28 (-1.02%) | 657.60 (92.65%) |
| client_sv2_open_channel | 📈 view plot 🚷 view threshold | 161.81 (-2.57%) | 180.11 (89.84%) |
| client_sv2_open_channel_serialize | 📈 view plot 🚷 view threshold | 283.02 (-0.90%) | 311.22 (90.94%) |
| client_sv2_open_channel_serialize_deserialize | 📈 view plot 🚷 view threshold | 382.25 (+0.06%) | 400.26 (95.50%) |
| client_sv2_setup_connection | 📈 view plot 🚷 view threshold | 158.65 (-0.80%) | 171.26 (92.64%) |
| client_sv2_setup_connection_serialize | 📈 view plot 🚷 view threshold | 471.25 (+0.16%) | 557.86 (84.47%) |
| client_sv2_setup_connection_serialize_deserialize | 📈 view plot 🚷 view threshold | 1,017.20 (+1.48%) | 1,203.28 (84.54%) |
|
| Branch | fix-timestamp-bug |
| Testbed | sv1 |
Click to view all benchmark results
| Benchmark | Estimated Cycles | Benchmark Result 1e3 x estimated cycles (Result Δ%) | Upper Boundary 1e3 x estimated cycles (Limit %) | Instructions | Benchmark Result 1e3 x instructions (Result Δ%) | Upper Boundary 1e3 x instructions (Limit %) | L1 Accesses | Benchmark Result 1e3 x accesses (Result Δ%) | Upper Boundary 1e3 x accesses (Limit %) | L2 Accesses | Benchmark Result accesses (Result Δ%) | Upper Boundary accesses (Limit %) | RAM Accesses | Benchmark Result accesses (Result Δ%) | Upper Boundary accesses (Limit %) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| get_authorize | 📈 view plot 🚷 view threshold | 8.45 (-0.07%) | 8.67 (97.43%) | 📈 view plot 🚷 view threshold | 3.66 (-1.68%) | 3.86 (94.87%) | 📈 view plot 🚷 view threshold | 5.11 (-2.05%) | 5.45 (93.79%) | 📈 view plot 🚷 view threshold | 10.00 (+18.85%) | 16.17 (61.85%) | 📈 view plot 🚷 view threshold | 94.00 (+2.93%) | 96.64 (97.27%) |
| get_submit | 📈 view plot 🚷 view threshold | 95.31 (-0.05%) | 95.61 (99.69%) | 📈 view plot 🚷 view threshold | 59.26 (-0.24%) | 59.71 (99.26%) | 📈 view plot 🚷 view threshold | 85.08 (-0.28%) | 85.82 (99.14%) | 📈 view plot 🚷 view threshold | 45.00 (+0.88%) | 60.05 (74.94%) | 📈 view plot 🚷 view threshold | 286.00 (+1.91%) | 291.53 (98.10%) |
| get_subscribe | 📈 view plot 🚷 view threshold | 7.92 (-0.95%) | 8.23 (96.21%) | 📈 view plot 🚷 view threshold | 2.76 (-1.96%) | 2.94 (93.72%) | 📈 view plot 🚷 view threshold | 3.83 (-2.31%) | 4.14 (92.55%) | 📈 view plot 🚷 view threshold | 12.00 (-3.70%) | 20.59 (58.28%) | 📈 view plot 🚷 view threshold | 115.00 (+0.42%) | 117.87 (97.57%) |
| serialize_authorize | 📈 view plot 🚷 view threshold | 12.26 (+0.04%) | 12.50 (98.09%) | 📈 view plot 🚷 view threshold | 5.24 (-1.11%) | 5.43 (96.58%) | 📈 view plot 🚷 view threshold | 7.28 (-1.38%) | 7.60 (95.75%) | 📈 view plot 🚷 view threshold | 10.00 (-1.54%) | 18.74 (53.36%) | 📈 view plot 🚷 view threshold | 141.00 (+2.24%) | 143.04 (98.57%) |
| serialize_deserialize_authorize | 📈 view plot 🚷 view threshold | 24.73 (+0.05%) | 25.18 (98.18%) | 📈 view plot 🚷 view threshold | 9.79 (-0.73%) | 10.01 (97.77%) | 📈 view plot 🚷 view threshold | 13.79 (-0.89%) | 14.17 (97.27%) | 📈 view plot 🚷 view threshold | 32.00 (-10.92%) | 45.95 (69.64%) | 📈 view plot 🚷 view threshold | 308.00 (+1.47%) | 313.38 (98.28%) |
| serialize_deserialize_handle_authorize | 📈 view plot 🚷 view threshold | 30.36 (+0.13%) | 30.73 (98.82%) | 📈 view plot 🚷 view threshold | 11.99 (-0.51%) | 12.19 (98.39%) | 📈 view plot 🚷 view threshold | 16.95 (-0.66%) | 17.29 (98.00%) | 📈 view plot 🚷 view threshold | 58.00 (+3.80%) | 67.61 (85.79%) | 📈 view plot 🚷 view threshold | 375.00 (+1.08%) | 379.28 (98.87%) |
| serialize_deserialize_handle_submit | 📈 view plot 🚷 view threshold | 126.55 (+0.08%) | 126.78 (99.82%) | 📈 view plot 🚷 view threshold | 73.12 (-0.18%) | 73.53 (99.43%) | 📈 view plot 🚷 view threshold | 104.76 (-0.23%) | 105.51 (99.29%) | 📈 view plot 🚷 view threshold | 109.00 (+2.26%) | 125.65 (86.75%) | 📈 view plot 🚷 view threshold | 607.00 (+1.56%) | 610.12 (99.49%) |
| serialize_deserialize_handle_subscribe | 📈 view plot 🚷 view threshold | 27.96 (+0.19%) | 28.39 (98.51%) | 📈 view plot 🚷 view threshold | 9.58 (-0.57%) | 9.76 (98.13%) | 📈 view plot 🚷 view threshold | 13.52 (-0.74%) | 13.84 (97.67%) | 📈 view plot 🚷 view threshold | 69.00 (+6.81%) | 78.12 (88.33%) | 📈 view plot 🚷 view threshold | 403.00 (+0.94%) | 409.70 (98.37%) |
| serialize_deserialize_submit | 📈 view plot 🚷 view threshold | 115.31 (+0.05%) | 115.71 (99.65%) | 📈 view plot 🚷 view threshold | 67.89 (-0.24%) | 68.42 (99.23%) | 📈 view plot 🚷 view threshold | 97.36 (-0.30%) | 98.29 (99.05%) | 📈 view plot 🚷 view threshold | 69.00 (+5.67%) | 87.14 (79.19%) | 📈 view plot 🚷 view threshold | 503.00 (+1.97%) | 504.55 (99.69%) |
| serialize_deserialize_subscribe | 📈 view plot 🚷 view threshold | 23.34 (+0.05%) | 23.82 (97.98%) | 📈 view plot 🚷 view threshold | 8.13 (-0.70%) | 8.32 (97.75%) | 📈 view plot 🚷 view threshold | 11.42 (-0.87%) | 11.75 (97.25%) | 📈 view plot 🚷 view threshold | 38.00 (-2.35%) | 50.87 (74.70%) | 📈 view plot 🚷 view threshold | 335.00 (+1.01%) | 342.32 (97.86%) |
| serialize_submit | 📈 view plot 🚷 view threshold | 99.80 (+0.02%) | 100.09 (99.71%) | 📈 view plot 🚷 view threshold | 61.33 (-0.21%) | 61.73 (99.34%) | 📈 view plot 🚷 view threshold | 87.93 (-0.26%) | 88.65 (99.20%) | 📈 view plot 🚷 view threshold | 50.00 (+4.17%) | 66.61 (75.06%) | 📈 view plot 🚷 view threshold | 332.00 (+2.05%) | 337.18 (98.46%) |
| serialize_subscribe | 📈 view plot 🚷 view threshold | 11.44 (+0.36%) | 11.60 (98.66%) | 📈 view plot 🚷 view threshold | 4.11 (-1.24%) | 4.28 (95.98%) | 📈 view plot 🚷 view threshold | 5.69 (-1.60%) | 6.00 (94.88%) | 📈 view plot 🚷 view threshold | 16.00 (+15.58%) | 23.92 (66.89%) | 📈 view plot 🚷 view threshold | 162.00 (+2.21%) | 164.36 (98.57%) |
|
| Branch | fix-timestamp-bug |
| Testbed | sv2 |
Click to view all benchmark results
| Benchmark | Estimated Cycles | Benchmark Result 1e3 x estimated cycles (Result Δ%) | Upper Boundary 1e3 x estimated cycles (Limit %) | Instructions | Benchmark Result instructions (Result Δ%) | Upper Boundary instructions (Limit %) | L1 Accesses | Benchmark Result accesses (Result Δ%) | Upper Boundary accesses (Limit %) | L2 Accesses | Benchmark Result accesses (Result Δ%) | Upper Boundary accesses (Limit %) | RAM Accesses | Benchmark Result accesses (Result Δ%) | Upper Boundary accesses (Limit %) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| client_sv2_handle_message_common | 📈 view plot 🚷 view threshold | 2.14 (+1.15%) | 2.24 (95.61%) | 📈 view plot 🚷 view threshold | 473.00 (-0.12%) | 490.70 (96.39%) | 📈 view plot 🚷 view threshold | 732.00 (-0.53%) | 759.35 (96.40%) | 📈 view plot 🚷 view threshold | 8.00 (+56.81%) | 11.89 (67.30%) | 📈 view plot 🚷 view threshold | 39.00 (+1.01%) | 41.67 (93.59%) |
| client_sv2_handle_message_mining | 📈 view plot 🚷 view threshold | 8.28 (+0.66%) | 8.40 (98.60%) | 📈 view plot 🚷 view threshold | 2,137.00 | 📈 view plot 🚷 view threshold | 3,155.00 (-0.12%) | 3,167.53 (99.60%) | 📈 view plot 🚷 view threshold | 38.00 (+6.67%) | 41.82 (90.86%) | 📈 view plot 🚷 view threshold | 141.00 (+0.95%) | 144.49 (97.59%) | |
| client_sv2_mining_message_submit_standard | 📈 view plot 🚷 view threshold | 6.32 (+0.35%) | 6.45 (98.07%) | 📈 view plot 🚷 view threshold | 1,750.00 (-0.03%) | 1,767.70 (99.00%) | 📈 view plot 🚷 view threshold | 2,548.00 (-0.15%) | 2,575.89 (98.92%) | 📈 view plot 🚷 view threshold | 20.00 (+15.89%) | 24.62 (81.24%) | 📈 view plot 🚷 view threshold | 105.00 (+0.34%) | 108.72 (96.58%) |
| client_sv2_mining_message_submit_standard_serialize | 📈 view plot 🚷 view threshold | 14.79 (+0.45%) | 14.93 (99.03%) | 📈 view plot 🚷 view threshold | 4,694.00 (-0.01%) | 4,711.70 (99.62%) | 📈 view plot 🚷 view threshold | 6,745.00 (-0.16%) | 6,786.79 (99.38%) | 📈 view plot 🚷 view threshold | 55.00 (+20.59%) | 62.79 (87.60%) | 📈 view plot 🚷 view threshold | 222.00 (+0.38%) | 226.12 (98.18%) |
| client_sv2_mining_message_submit_standard_serialize_deserialize | 📈 view plot 🚷 view threshold | 27.79 (+0.70%) | 28.05 (99.07%) | 📈 view plot 🚷 view threshold | 10,645.00 (+0.37%) | 10,696.90 (99.51%) | 📈 view plot 🚷 view threshold | 15,502.00 (+0.41%) | 15,591.18 (99.43%) | 📈 view plot 🚷 view threshold | 92.00 (+9.94%) | 98.92 (93.00%) | 📈 view plot 🚷 view threshold | 338.00 (+0.75%) | 343.09 (98.52%) |
| client_sv2_open_channel | 📈 view plot 🚷 view threshold | 4.49 (+2.02%) | 4.57 (98.12%) | 📈 view plot 🚷 view threshold | 1,461.00 (-0.04%) | 1,478.70 (98.80%) | 📈 view plot 🚷 view threshold | 2,154.00 (-0.31%) | 2,184.92 (98.58%) | 📈 view plot 🚷 view threshold | 12.00 (+46.43%) | 14.03 (85.51%) | 📈 view plot 🚷 view threshold | 65.00 (+3.47%) | 67.54 (96.23%) |
| client_sv2_open_channel_serialize | 📈 view plot 🚷 view threshold | 14.09 (+0.48%) | 14.20 (99.22%) | 📈 view plot 🚷 view threshold | 5,064.00 (-0.01%) | 5,081.70 (99.65%) | 📈 view plot 🚷 view threshold | 7,316.00 (-0.14%) | 7,352.91 (99.50%) | 📈 view plot 🚷 view threshold | 45.00 (+23.10%) | 48.29 (93.19%) | 📈 view plot 🚷 view threshold | 187.00 (+0.55%) | 190.78 (98.02%) |
| client_sv2_open_channel_serialize_deserialize | 📈 view plot 🚷 view threshold | 22.97 (+1.17%) | 23.06 (99.62%) | 📈 view plot 🚷 view threshold | 8,040.00 (+0.10%) | 8,057.34 (99.78%) | 📈 view plot 🚷 view threshold | 11,683.00 (-0.01%) | 11,714.06 (99.73%) | 📈 view plot 🚷 view threshold | 87.00 (+14.84%) | 89.83 (96.85%) | 📈 view plot 🚷 view threshold | 310.00 (+1.97%) | 312.43 (99.22%) |
| client_sv2_setup_connection | 📈 view plot 🚷 view threshold | 4.71 (+0.53%) | 4.79 (98.44%) | 📈 view plot 🚷 view threshold | 1,502.00 (-0.04%) | 1,519.70 (98.84%) | 📈 view plot 🚷 view threshold | 2,275.00 (-0.16%) | 2,301.24 (98.86%) | 📈 view plot 🚷 view threshold | 12.00 (+26.94%) | 15.42 (77.82%) | 📈 view plot 🚷 view threshold | 68.00 (+0.67%) | 70.07 (97.05%) |
| client_sv2_setup_connection_serialize | 📈 view plot 🚷 view threshold | 16.23 (+0.47%) | 16.32 (99.43%) | 📈 view plot 🚷 view threshold | 5,963.00 (-0.01%) | 5,980.70 (99.70%) | 📈 view plot 🚷 view threshold | 8,650.00 (-0.16%) | 8,692.77 (99.51%) | 📈 view plot 🚷 view threshold | 53.00 (+30.64%) | 56.13 (94.43%) | 📈 view plot 🚷 view threshold | 209.00 (+0.38%) | 212.05 (98.56%) |
| client_sv2_setup_connection_serialize_deserialize | 📈 view plot 🚷 view threshold | 35.76 (+0.44%) | 35.95 (99.46%) | 📈 view plot 🚷 view threshold | 14,888.00 (+0.14%) | 14,918.45 (99.80%) | 📈 view plot 🚷 view threshold | 21,866.00 (+0.11%) | 21,917.87 (99.76%) | 📈 view plot 🚷 view threshold | 111.00 (+17.74%) | 119.12 (93.18%) | 📈 view plot 🚷 view threshold | 381.00 (+0.37%) | 385.70 (98.78%) |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1325 +/- ##
==========================================
+ Coverage 18.61% 19.30% +0.68%
==========================================
Files 144 164 +20
Lines 9718 10853 +1135
==========================================
+ Hits 1809 2095 +286
- Misses 7909 8758 +849
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
IMO more tests are always desirable 🙈 the real question is how complex it is to write a comprehensive test for this bug if it is too complex and we decide it's not worth spending our time on it now, we could always take note of this on #1077 and come back to it later
yes, see: stratum/roles/tests-integration/tests/common/sniffer.rs Lines 465 to 470 in a58246a or a more concrete example: stratum/roles/tests-integration/tests/pool_integration.rs Lines 40 to 51 in a58246a
are we doing a patch release for this bugfix? if yes, then we should bump and release right away if not, then we should take note of this change and then bump before v1.3.0 (maybe there will be a MAJOR or MINOR bump that would overwrite this) |
|
You should the |
I'm not following you here, weren't we saying that we should always use the timestamp communicated by the TP? |
|
Maybe I'm just confused by the name. The |
|
What I'm using in this PR is the Regarding the naming, do you think something could be improved in the specs? |
|
Yes, it's indeed The spec is clear:
Some part of the SRI codebase is calling it |
I think that's because on the mining protocol specs is specified as Don't you think we should enhance that part of the specs? I can push changes on this PR, but I think that if we agree on it, we should also clarify specs. |
|
Yes it makes sense to improve the spec there.
There's currently no way to know this, unless we add a new field to the NewTemplate and/or SetNewPrevHash message. |
|
@Sjors took note of this on both: |
23b6e17 to
e4e5e61
Compare
Shourya742
left a comment
There was a problem hiding this comment.
tack 4c97af4.
A major version bump will be required due to the change in the JobCreator struct:
@@ -27,6 +27,7 @@ pub struct JobsCreators {
templte_to_job_id: HashMap<u64, u32, BuildNoHashHasher<u64>>,
ids: Id,
last_target: mining_sv2::Target,
+ last_ntime: Option<u32>,
extranonce_len: u8,
}However, the rest of the changes do not affect any public APIs.
jbesraa
left a comment
There was a problem hiding this comment.
It is really great to see you using the integration tests!
Added a few nits mainly in that regard.
e4e5e61 to
d5fa199
Compare
2416330 to
b53152c
Compare
|
Thanks everyone for reviewing it 🙏 , I addressed almost every comment. The last thing which needs to be done in this PR is to bump the crate version in its I'm diving into it, will post updates here asap. |
|
I did some local manual testing for the semver issue:
(the no errors were reported it's very good that @Shourya742 had the eagle eyes to detect this potential versioning issue, but we should definitely investigate deeper to know if:
|
|
for future reference: after some investigation, it was confirmed that the semver issue was a false alarm although the |
b53152c to
f117ccf
Compare
f117ccf to
aab26f2
Compare
aab26f2 to
e4cfe3b
Compare
This PR introduces a new
last_ntimefield intoJobsCreatorsstruct to save the lastnTimevalue sent by TP.In this way, the correct value is always used when creating new jobs (future and not), instead of using the current system time.
Closes #1324