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

Use 2-chain for finality #384

Closed
arhag opened this issue Jul 19, 2024 · 0 comments · Fixed by #389
Closed

Use 2-chain for finality #384

arhag opened this issue Jul 19, 2024 · 0 comments · Fixed by #389
Assignees
Labels
consensus-protocol Change to the consensus protocol. Impacts light client validation. 👍 lgtm

Comments

@arhag
Copy link
Member

arhag commented Jul 19, 2024

Other than adapting the tests to work with 2-chain, the only change that should be necessary is to the get_new_block_numbers function in finality_core.cpp.

Switching to 2-chain makes final_on_strong_qc_block_num unnecessary. But for this issue we will keep it for now even though it should always be the same block number as the latest_qc_claim().block_num. So get_new_block_number should always return most_recent_ancestor_with_qc.block_num as the third item in the returned tuple.

The get_new_block_number function likely is simplified to the following (note that the comments have been removed below for brevity but should be adapted in the actual code):

std::tuple<block_num_type, block_num_type, block_num_type> get_new_block_numbers(const finality_core& c, const qc_claim_t& most_recent_ancestor_with_qc)
{
   assert(most_recent_ancestor_with_qc.block_num <= c.current_block_num()); // Satisfied by the precondition.

   assert(c.links.front().source_block_num <= most_recent_ancestor_with_qc.block_num); // Satisfied by invariant 2 of core and the precondition.

   // No changes to last_final_block_num on new claim of weak QC.
   if (!most_recent_ancestor_with_qc.is_strong_qc) {
      return {c.last_final_block_num(), c.links.front().source_block_num, most_recent_ancestor_with_qc.block_num};
   }

   const auto& link1 = c.get_qc_link_from(most_recent_ancestor_with_qc.block_num);

   return {link1.target_block_num, link1.source_block_num, most_recent_ancestor_with_qc.block_num}; 
}

Note that this should also automatically resolve #304 since final_on_strong_qc_block_num cannot go backwards.

@arhag arhag added this to the Savanna: Production-Ready milestone Jul 19, 2024
@enf-ci-bot enf-ci-bot moved this to Todo in Team Backlog Jul 19, 2024
@arhag arhag added consensus-protocol Change to the consensus protocol. Impacts light client validation. 👍 lgtm and removed triage labels Jul 19, 2024
@linh2931 linh2931 moved this from Todo to In Progress in Team Backlog Jul 19, 2024
@linh2931 linh2931 moved this from In Progress to Awaiting Review in Team Backlog Jul 23, 2024
@github-project-automation github-project-automation bot moved this from Awaiting Review to Done in Team Backlog Jul 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
consensus-protocol Change to the consensus protocol. Impacts light client validation. 👍 lgtm
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants