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

feat: cache new block template #6222

Merged

Conversation

hansieodendaal
Copy link
Contributor

@hansieodendaal hansieodendaal commented Mar 18, 2024

Description

In the merge mining proxy for the block template protocol:

  • Cached a new block template and used it in case it is asked repetitively for the same best block.
  • Added an exit clause to the potential endless loop.

Motivation and Context

Under certain conditions, a merge mining proxy request for a new block template from the base node would be repeated many times for the same best block height, without the final request for a block template that includes the coinbase transaction. This wastes many resources, especially within the mempool where the template must be constructed.

2024-03-15 16:49:43.873749100 [minotari_mm_proxy::proxy::block_template_protocol] DEBUG Requested new block template at height: #1675
2024-03-15 16:56:35.702267000 [minotari_mm_proxy::proxy::block_template_protocol] DEBUG Requested new block template at height: #1676
2024-03-15 16:56:57.709323100 [minotari_mm_proxy::proxy::block_template_protocol] DEBUG Requested new block template at height: #1677
2024-03-15 16:59:04.747989700 [minotari_mm_proxy::proxy::block_template_protocol] DEBUG Requested new block template at height: #1678
2024-03-15 16:59:04.840957100 [minotari_mm_proxy::proxy::block_template_protocol] DEBUG Requested new block template at height: #1678
2024-03-15 16:59:04.849282000 [minotari_mm_proxy::proxy::block_template_protocol] DEBUG Requested new block template at height: #1678
2024-03-15 16:59:04.852855000 [minotari_mm_proxy::proxy::block_template_protocol] DEBUG Requested new block template at height: #1678
2024-03-15 16:59:04.953873500 [minotari_mm_proxy::proxy::block_template_protocol] DEBUG Requested new block template at height: #1678
2024-03-15 16:59:04.954461600 [minotari_mm_proxy::proxy::block_template_protocol] DEBUG Requested new block template at height: #1678
2024-03-15 16:59:04.958619200 [minotari_mm_proxy::proxy::block_template_protocol] DEBUG Requested new block template at height: #1678
2024-03-15 16:59:05.054517300 [minotari_mm_proxy::proxy::block_template_protocol] DEBUG Requested new block template at height: #1678
2024-03-15 16:59:05.056071600 [minotari_mm_proxy::proxy::block_template_protocol] DEBUG Requested new block template at height: #1678
2024-03-15 16:59:05.057842800 [minotari_mm_proxy::proxy::block_template_protocol] DEBUG Requested new block template at height: #1678
2024-03-15 16:59:05.058706200 [minotari_mm_proxy::proxy::block_template_protocol] DEBUG Requested new block template at height: #1678
2024-03-15 16:59:05.184297100 [minotari_mm_proxy::proxy::block_template_protocol] DEBUG Requested new block template at height: #1678
2024-03-15 16:59:05.184568300 [minotari_mm_proxy::proxy::block_template_protocol] DEBUG Requested new block template at height: #1678
2024-03-15 16:59:05.186171600 [minotari_mm_proxy::proxy::block_template_protocol] DEBUG Requested new block template at height: #1678
2024-03-15 16:59:05.308025900 [minotari_mm_proxy::proxy::block_template_protocol] DEBUG Requested new block template at height: #1678
2024-03-15 16:59:05.308188600 [minotari_mm_proxy::proxy::block_template_protocol] DEBUG Requested new block template at height: #1678
2024-03-15 16:59:05.411993800 [minotari_mm_proxy::proxy::block_template_protocol] DEBUG Requested new block template at height: #1678
2024-03-15 16:59:05.413148500 [minotari_mm_proxy::proxy::block_template_protocol] DEBUG Requested new block template at height: #1678
2024-03-15 16:59:05.436028800 [minotari_mm_proxy::proxy::block_template_protocol] DEBUG Requested new block template at height: #1678
2024-03-15 16:59:05.457553200 [minotari_mm_proxy::proxy::block_template_protocol] DEBUG Requested new block template at height: #1678
2024-03-15 16:59:05.569510200 [minotari_mm_proxy::proxy::block_template_protocol] DEBUG Requested new block template at height: #1678
2024-03-15 16:59:05.573500600 [minotari_mm_proxy::proxy::block_template_protocol] DEBUG Requested new block template at height: #1678
2024-03-15 16:59:05.658578700 [minotari_mm_proxy::proxy::block_template_protocol] DEBUG Requested new block template at height: #1678
2024-03-15 16:59:05.659258900 [minotari_mm_proxy::proxy::block_template_protocol] DEBUG Requested new block template at height: #1678
2024-03-15 16:59:05.693116700 [minotari_mm_proxy::proxy::block_template_protocol] DEBUG Requested new block template at height: #1678
2024-03-15 16:59:05.695350400 [minotari_mm_proxy::proxy::block_template_protocol] DEBUG Requested new block template at height: #1678
2024-03-15 16:59:05.713246600 [minotari_mm_proxy::proxy::block_template_protocol] DEBUG Requested new block template at height: #1678
2024-03-15 16:59:05.724627700 [minotari_mm_proxy::proxy::block_template_protocol] DEBUG Requested new block template at height: #1678
2024-03-15 16:59:05.734541000 [minotari_mm_proxy::proxy::block_template_protocol] DEBUG Requested new block template at height: #1678
2024-03-15 16:59:05.904546600 [minotari_mm_proxy::proxy::block_template_protocol] DEBUG Requested new block template at height: #1678
2024-03-15 16:59:05.909569300 [minotari_mm_proxy::proxy::block_template_protocol] DEBUG Requested new block template at height: #1678
2024-03-15 16:59:05.913773800 [minotari_mm_proxy::proxy::block_template_protocol] DEBUG Requested new block template at height: #1678
2024-03-15 16:59:05.914761900 [minotari_mm_proxy::proxy::block_template_protocol] DEBUG Requested new block template at height: #1678
2024-03-15 16:59:05.918061100 [minotari_mm_proxy::proxy::block_template_protocol] DEBUG Requested new block template at height: #1678
2024-03-15 16:59:05.928847000 [minotari_mm_proxy::proxy::block_template_protocol] DEBUG Requested new block template at height: #1678
2024-03-15 16:59:06.125242100 [minotari_mm_proxy::proxy::block_template_protocol] DEBUG Requested new block template at height: #1678
2024-03-15 16:59:06.125427400 [minotari_mm_proxy::proxy::block_template_protocol] DEBUG Requested new block template at height: #1678
2024-03-15 16:59:06.130678700 [minotari_mm_proxy::proxy::block_template_protocol] DEBUG Requested new block template at height: #1678
2024-03-15 16:59:06.367898700 [minotari_mm_proxy::proxy::block_template_protocol] DEBUG Requested new block template at height: #1678
2024-03-15 16:59:06.385011900 [minotari_mm_proxy::proxy::block_template_protocol] DEBUG Requested new block template at height: #1678
2024-03-15 16:59:06.386722300 [minotari_mm_proxy::proxy::block_template_protocol] DEBUG Requested new block template at height: #1678
2024-03-15 16:59:06.388034000 [minotari_mm_proxy::proxy::block_template_protocol] DEBUG Requested new block template at height: #1678
2024-03-15 16:59:06.406540100 [minotari_mm_proxy::proxy::block_template_protocol] DEBUG Requested new block template at height: #1678
2024-03-15 16:59:06.645604600 [minotari_mm_proxy::proxy::block_template_protocol] DEBUG Requested new block template at height: #1678
2024-03-15 16:59:06.654252400 [minotari_mm_proxy::proxy::block_template_protocol] DEBUG Requested new block template at height: #1678
2024-03-15 16:59:06.659640400 [minotari_mm_proxy::proxy::block_template_protocol] DEBUG Requested new block template at height: #1678
2024-03-15 16:59:06.661591500 [minotari_mm_proxy::proxy::block_template_protocol] DEBUG Requested new block template at height: #1678
2024-03-15 16:59:06.829952300 [minotari_mm_proxy::proxy::block_template_protocol] DEBUG Requested new block template at height: #1678
2024-03-15 16:59:06.838337400 [minotari_mm_proxy::proxy::block_template_protocol] DEBUG Requested new block template at height: #1678
2024-03-15 16:59:06.843845500 [minotari_mm_proxy::proxy::block_template_protocol] DEBUG Requested new block template at height: #1678
2024-03-15 16:59:06.847976400 [minotari_mm_proxy::proxy::block_template_protocol] DEBUG Requested new block template at height: #1678
2024-03-15 16:59:07.036353600 [minotari_mm_proxy::proxy::block_template_protocol] DEBUG Requested new block template at height: #1678
2024-03-15 16:59:07.038593100 [minotari_mm_proxy::proxy::block_template_protocol] DEBUG Requested new block template at height: #1678
2024-03-15 16:59:07.042252500 [minotari_mm_proxy::proxy::block_template_protocol] DEBUG Requested new block template at height: #1678
2024-03-15 16:59:07.070333200 [minotari_mm_proxy::proxy::block_template_protocol] DEBUG Requested new block template at height: #1678
2024-03-15 16:59:07.204174900 [minotari_mm_proxy::proxy::block_template_protocol] DEBUG Requested new block template at height: #1678
2024-03-15 16:59:07.207776400 [minotari_mm_proxy::proxy::block_template_protocol] DEBUG Requested new block template at height: #1678
2024-03-15 16:59:07.208302900 [minotari_mm_proxy::proxy::block_template_protocol] DEBUG Requested new block template at height: #1678
2024-03-15 16:59:07.211634900 [minotari_mm_proxy::proxy::block_template_protocol] DEBUG Requested new block template at height: #1678
2024-03-15 16:59:07.218055300 [minotari_mm_proxy::proxy::block_template_protocol] DEBUG Requested new block template at height: #1678
2024-03-15 16:59:07.367296100 [minotari_mm_proxy::proxy::block_template_protocol] DEBUG Requested new block template at height: #1678
2024-03-15 16:59:07.367378600 [minotari_mm_proxy::proxy::block_template_protocol] DEBUG Requested new block template at height: #1678
2024-03-15 16:59:07.369022900 [minotari_mm_proxy::proxy::block_template_protocol] DEBUG Requested new block template at height: #1678
2024-03-15 16:59:07.372211400 [minotari_mm_proxy::proxy::block_template_protocol] DEBUG Requested new block template at height: #1678
2024-03-15 16:59:07.504687000 [minotari_mm_proxy::proxy::block_template_protocol] DEBUG Requested new block template at height: #1678
2024-03-15 16:59:07.505760400 [minotari_mm_proxy::proxy::block_template_protocol] DEBUG Requested new block template at height: #1678
2024-03-15 16:59:07.505823500 [minotari_mm_proxy::proxy::block_template_protocol] DEBUG Requested new block template at height: #1678
2024-03-15 16:59:09.578821600 [minotari_mm_proxy::proxy::block_template_protocol] DEBUG Requested new block template at height: #1678
2024-03-15 16:59:09.829455600 [minotari_mm_proxy::proxy::block_template_protocol] DEBUG Requested new block template at height: #1678
2024-03-15 17:00:11.282291600 [minotari_mm_proxy::proxy::block_template_protocol] DEBUG Requested new block template at height: #1679
2024-03-15 17:01:13.476999400 [minotari_mm_proxy::proxy::block_template_protocol] DEBUG Requested new block template at height: #1680

How Has This Been Tested?

System-level testing

What process can a PR reviewer use to test or verify this change?

  • Review code changes
  • System-level testing:
    • These log entries should not be repeated for the same best block height:
    2024-03-18 15:12:50.362269600 [minotari_mm_proxy::proxy::block_template_protocol] DEBUG Requested new block template at height: #1832 (try 4)
    
    • Look for these log entries instead:
    2024-03-18 15:13:46.016447400 [minotari_mm_proxy::proxy::block_template_protocol] DEBUG Used existing new block template at height: #1836 (try 1)
    

Breaking Changes

  • None
  • Requires data directory on base node to be deleted
  • Requires hard fork
  • Other - Please specify

@ghpbot-tari-project ghpbot-tari-project added P-acks_required Process - Requires more ACKs or utACKs P-reviews_required Process - Requires a review from a lead maintainer to be merged labels Mar 18, 2024
Copy link

github-actions bot commented Mar 18, 2024

Test Results (CI)

    3 files    120 suites   44m 20s ⏱️
1 269 tests 1 269 ✅ 0 💤 0 ❌
3 799 runs  3 799 ✅ 0 💤 0 ❌

Results for commit 61e99d0.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Mar 18, 2024

Test Results (Integration tests)

 2 files  + 2  11 suites  +11   40m 31s ⏱️ + 40m 31s
32 tests +32  31 ✅ +31  0 💤 ±0  1 ❌ +1 
34 runs  +34  31 ✅ +31  0 💤 ±0  3 ❌ +3 

For more details on these failures, see this check.

Results for commit 61e99d0. ± Comparison against base commit 1452535.

♻️ This comment has been updated with latest results.

For the block template protocol:
- Cached new block template and use it in case it is asked for the same best block
repetitively.
- Added an exit clause to the potential endless loop.
@hansieodendaal hansieodendaal force-pushed the ho_proxy_cache_template branch from 7e98a43 to dd488a0 Compare March 19, 2024 16:10
@ghpbot-tari-project ghpbot-tari-project removed P-reviews_required Process - Requires a review from a lead maintainer to be merged labels Mar 20, 2024
@ghpbot-tari-project ghpbot-tari-project added the P-reviews_required Process - Requires a review from a lead maintainer to be merged label Mar 20, 2024
@SWvheerden SWvheerden merged commit e0ad342 into tari-project:development Mar 20, 2024
14 of 16 checks passed
@hansieodendaal hansieodendaal deleted the ho_proxy_cache_template branch March 25, 2024 06:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P-acks_required Process - Requires more ACKs or utACKs P-reviews_required Process - Requires a review from a lead maintainer to be merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants