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 block extension which contains latest HotStuff commitment known to proposer #1607

Closed
wants to merge 21 commits into from

Conversation

greg7mdp
Copy link
Contributor

@greg7mdp greg7mdp commented Sep 7, 2023

Resolves #1586.

Proposer takes the latest irreversible HotStuff commitment proof (the latest block proposal with the final_on_qc pointing to an irreversible block along with QC for it) known to it and includes it in a new block extension for the block that it constructs. This is the irreversible HotStuff proofs which means they always are relevant for advancing LIB on the irreversible blockchain.

@greg7mdp greg7mdp changed the base branch from main to hotstuff_integration September 7, 2023 19:26
@greg7mdp greg7mdp marked this pull request as draft September 7, 2023 19:27
@greg7mdp greg7mdp linked an issue Sep 7, 2023 that may be closed by this pull request
@greg7mdp greg7mdp changed the title IF: Add block extension to include latest commit QC known to proposer IF: Add block extension to include latest HotStuff commitment known to proposer Sep 7, 2023
@greg7mdp greg7mdp changed the title IF: Add block extension to include latest HotStuff commitment known to proposer IF: Add block extension which contains latest HotStuff commitment known to proposer Sep 7, 2023
@greg7mdp greg7mdp linked an issue Sep 8, 2023 that may be closed by this pull request
@greg7mdp greg7mdp requested a review from heifner September 15, 2023 15:15
@greg7mdp greg7mdp marked this pull request as ready for review September 15, 2023 20:07
libraries/chain/fork_database.cpp Outdated Show resolved Hide resolved
}
}
signed_block_ptr sb = blk->block;
std::optional<block_extension> ext = sb->extract_extension(hs_commitment_extension::extension_id());
Copy link
Member

Choose a reason for hiding this comment

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

If block_num is less than active commitment(s) block number this can be skipped. It is only used for syncing so we should see if it is relevant before processing.

Copy link
Contributor Author

@greg7mdp greg7mdp Sep 19, 2023

Choose a reason for hiding this comment

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

I'm not sure that it is not needed, since we need to track the finalizer_set with a delay (when a commitment seen in accepted blocks made it irreversible), which is different from the active finalizer_set of hotstuff. Also, the optimization is not significant because most blocks will not have commitments.

void qc_chain::send_hs_new_block_msg(const hs_new_block_message & msg){
fc_tlog(_logger, " === broadcast_hs_new_block ===");
_pacemaker->send_hs_new_block_msg(msg, _id);
std::optional<hs_commitment> qc_chain::send_hs_msg(const hs_message& msg) {
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 should avoid unneeded copies of hs_message. 4 similar methods to avoid copies I think is worth it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Where is it copied?

Copy link
Contributor Author

@greg7mdp greg7mdp Sep 19, 2023

Choose a reason for hiding this comment

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

But yes the variant is larger for some messages than otherwise.I still think this is much cleaner and the cost is insignificant compared to the rest of what we do.

Copy link
Member

Choose a reason for hiding this comment

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

When you create a variant from a type it is copied unless you move into the construction. Might want to take by value and move into it to avoid the copy. Although, most of the data in the messages is likely not movable.

libraries/hotstuff/chain_pacemaker.cpp Outdated Show resolved Hide resolved
// issue #1522: HotStuff finality should drive LIB in controller
// no need to do anything here. `qc_chain::update()` will return the `hs_commitment` where b.block_id is final
// and chain_pacemaker will notify the controller. The controller will notify `fork_database` so that
// this block and its ancestors are marked irreversible and moved out of `fork_database`.
Copy link
Member

Choose a reason for hiding this comment

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

We can comment out this for loop then.

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 doubt commenting an empty loop changes anything in the generated code.

Copy link
Member

Choose a reason for hiding this comment

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

True, more for documentation than efficiency.

@@ -123,6 +123,7 @@ add_library( eosio_chain

Copy link
Member

Choose a reason for hiding this comment

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

There are conflicts with branch that need to be resolved.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I was waiting for gnome's PR to be merged so I don't resolve conflicts twice.

libraries/chain/controller.cpp Show resolved Hide resolved
@arhag
Copy link
Member

arhag commented Dec 20, 2023

Overcome by events

@arhag arhag closed this Dec 20, 2023
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.

IF: Add block extension to include latest commit QC known to proposer
3 participants