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

IF: Add hs_irreversible_blocknum to block_header_state #1612

Closed
wants to merge 6 commits into from

Conversation

heifner
Copy link
Member

@heifner heifner commented Sep 8, 2023

  • Add hs_irreversible_blocknum to block_header_state to track hotstuff irreversible block number.
  • Update fork_database to use either hs_irreversible_blocknum or dpos_irreversible_blocknum for LIB.
  • Add mark_irreversible to fork_database to be used by chain_pacemaker to advance LIB which will then be used by controller log_irreversible to advance LIB.
  • Added copyable_atomic type for use by block_header_state hs_irreversible_blocknum since it will be modified after the block_state is signaled and potentially accessed from other threads.
  • Added fc::atomic_shared_ptr and copyable_atomic_shared_ptr these may not actually be needed. But could be used if we wish to store active finalizer_set in block_state.

Need to add tests for the fork_database::mark_irreversible but getting this PR up so it can be used by #1586

@heifner heifner requested review from greg7mdp and linh2931 September 8, 2023 19:50
@heifner
Copy link
Member Author

heifner commented Sep 8, 2023

Closing. Going to explore not storing in block_header_state.

@heifner heifner closed this Sep 8, 2023
@@ -88,6 +88,9 @@ namespace eosio { namespace chain {

void mark_valid( const block_state_ptr& h );

// Called by hotstuff to mark a fork branch irreversible
void mark_irreversible( const block_id_type& id );
Copy link
Member

Choose a reason for hiding this comment

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

Should this be named as `hs_mark_irreversible"?

"block state ${id} not in fork database; cannot mark as irreversible", ("id", id));
const bool at_root = (id == root->id);
by_id_idx.modify(itr, [&id, lib](block_state_ptr& bsp) {
bsp->hs_irreversible_blocknum.store(lib);
Copy link
Member

Choose a reason for hiding this comment

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

This method only updates s_irreversible_blocknum. Should it be named as hs_mark_irreversible_impl?

@@ -329,6 +331,25 @@ namespace eosio { namespace chain {
root = new_root;
}

void fork_database_impl::mark_irreversible_impl( block_id_type id ) {
Copy link
Member

Choose a reason for hiding this comment

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

You can pass the parameter as const block_id_type&

const bool at_root = (id == root->id);
by_id_idx.modify(itr, [&id, lib](block_state_ptr& bsp) {
bsp->hs_irreversible_blocknum.store(lib);
id = bsp->header.previous;
Copy link
Member

Choose a reason for hiding this comment

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

Don't reuse (reset) input parameter.

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