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(optimistic_block): produce #12761

Draft
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

VanBarbascu
Copy link
Contributor

@VanBarbascu VanBarbascu commented Jan 20, 2025

We continue the implementation of Optimistic block #10584, by adding the logic to produce the block as soon as the previous block is done.

If available, the optimistic block will be used in the production of the block to use the same timestamp.

@VanBarbascu VanBarbascu requested a review from a team as a code owner January 20, 2025 14:09
@VanBarbascu VanBarbascu changed the title DOptimistic block/create feat(optimistic_block): produce Jan 20, 2025
@VanBarbascu VanBarbascu requested review from Longarithm and removed request for saketh-are January 20, 2025 14:10
@VanBarbascu VanBarbascu marked this pull request as draft January 20, 2025 14:10
Copy link
Member

@Longarithm Longarithm left a comment

Choose a reason for hiding this comment

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

Very nice! I think it can be merged after merging with master. Leaving mostly nits.

We can start thinking if something can already be unit-tested here. Maybe just run produce_optimistic, then produce and check that timestamps match. But it can be done later, and if setup is too hard, we'd have to make it simple first.

chain/client/src/client.rs Outdated Show resolved Hide resolved
chain/client/src/client.rs Outdated Show resolved Hide resolved
chain/client/src/client.rs Show resolved Hide resolved
chain/client/src/client.rs Outdated Show resolved Hide resolved
for height in
latest_known.height + 1..=self.client.doomslug.get_largest_height_crossing_threshold()
{
let next_block_producer_account =
self.client.epoch_manager.get_block_producer(&epoch_id, height)?;

if me == next_block_producer_account {
if let Err(err) = self.produce_optimistic_block(height) {
Copy link
Member

Choose a reason for hiding this comment

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

I think we can call this only if

                self.client.doomslug.ready_to_produce_block(
                    height,
                    true,
                    log_block_production_info,
                )

Could you double check?

Also the order should be the opposite - if we can produce normal block, we can skip producing optimistic block in order to optimise processing flow.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree that we should only produce the optimistic block if we cannot produce the actual block. I am not yet sure why do we need to wait for approvals for the previous block. Will look deeper into doomslug

core/primitives/src/block.rs Outdated Show resolved Hide resolved
chain/client/src/client_actor.rs Outdated Show resolved Hide resolved
chain/client/src/client.rs Outdated Show resolved Hide resolved
@VanBarbascu VanBarbascu force-pushed the optimistic_block/create branch from 492e6e3 to 66b73c5 Compare January 20, 2025 16:02
Copy link

codecov bot commented Jan 20, 2025

Codecov Report

Attention: Patch coverage is 81.86047% with 39 lines in your changes missing coverage. Please review.

Project coverage is 70.76%. Comparing base (9b626a7) to head (80b83fa).

Files with missing lines Patch % Lines
chain/client/src/client.rs 74.01% 22 Missing and 11 partials ⚠️
chain/client/src/client_actor.rs 85.71% 2 Missing and 4 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #12761      +/-   ##
==========================================
+ Coverage   70.73%   70.76%   +0.03%     
==========================================
  Files         850      850              
  Lines      174864   175009     +145     
  Branches   174864   175009     +145     
==========================================
+ Hits       123683   123851     +168     
+ Misses      46000    45970      -30     
- Partials     5181     5188       +7     
Flag Coverage Δ
backward-compatibility 0.16% <0.00%> (-0.01%) ⬇️
db-migration 0.16% <0.00%> (-0.01%) ⬇️
genesis-check 1.34% <0.00%> (-0.01%) ⬇️
linux 69.15% <81.60%> (+0.03%) ⬆️
linux-nightly 70.36% <82.62%> (+0.03%) ⬆️
pytests 1.64% <0.00%> (-0.01%) ⬇️
sanity-checks 1.45% <0.00%> (-0.01%) ⬇️
unittests 70.60% <81.86%> (+0.03%) ⬆️
upgradability 0.20% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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