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

[3.2] Use block_num for interrupt of start_block #893

Merged
merged 1 commit into from
Mar 27, 2023

Conversation

heifner
Copy link
Member

@heifner heifner commented Mar 24, 2023

Signal received block with the block number so that start_block can be interrupted even if the block is received before the start of start_block. This is particularly important for #867, but also useful as mitigation against race condition of receiving block right before start of the block in current implementation. See #648.

Resolves #891

…eceiving block before beginning of start_block
@heifner heifner added the OCI Work exclusive to OCI team label Mar 24, 2023
@@ -1798,7 +1799,7 @@ producer_plugin_impl::start_block_result producer_plugin_impl::start_block() {
if( !remove_expired_blacklisted_trxs( preprocess_deadline ) )
return start_block_result::exhausted;
if( !_subjective_billing.remove_expired( _log, chain.pending_block_time(), fc::time_point::now(),
[&](){ return should_interrupt_start_block( preprocess_deadline ); } ) ) {
[&](){ return should_interrupt_start_block( preprocess_deadline, pending_block_num ); } ) ) {
Copy link
Contributor

@greg7mdp greg7mdp Mar 24, 2023

Choose a reason for hiding this comment

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

Here we are using pending_block_num defined as pending_block_num = hbs->block_num + 1;.

Is it the same as chain.pending_block_num();?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes. Head is what we are building on and pending is what we are building. Therefore, pending is always head+1.

Copy link
Contributor

Choose a reason for hiding this comment

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

Head is what we are building on and pending is what we are building

Hum, that would mean head = pending. What is head really? The last block we know about?

Copy link
Member Author

Choose a reason for hiding this comment

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

Let me try that again. [block#3][block#4 head][pending... block#4 is a complete block. It is the head of the chain. pending is an incomplete block we are currently building.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, thanks, got you, I missed the on in building on in my first reading.

Copy link
Member

@linh2931 linh2931 left a comment

Choose a reason for hiding this comment

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

Somehow I cannot add comments directly into producer_plugin::received_block(). Do you want to reset my->_received_block to 0 or some small number so the previous value will not trigger should_interrupt_start_block by accident?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OCI Work exclusive to OCI team
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

3 participants