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

Hotstuff integration #1536

Closed
wants to merge 1,597 commits into from
Closed

Hotstuff integration #1536

wants to merge 1,597 commits into from

Conversation

heifner
Copy link
Member

@heifner heifner commented Aug 19, 2023

Merge of hotstuff consensus integration branch to main.

Suggested process for this PR:

Resolves #1508

Copy link
Member Author

@heifner heifner left a comment

Choose a reason for hiding this comment

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

First quick pass complete. Detailed review next.

libraries/chain/controller.cpp Outdated Show resolved Hide resolved
libraries/chain/include/eosio/chain/hotstuff.hpp Outdated Show resolved Hide resolved
libraries/chain/controller.cpp Outdated Show resolved Hide resolved
libraries/chain/controller.cpp Outdated Show resolved Hide resolved
libraries/chain/include/eosio/chain/controller.hpp Outdated Show resolved Hide resolved
plugins/producer_plugin/producer_plugin.cpp Outdated Show resolved Hide resolved
plugins/producer_plugin/qc_chain.cpp.bkp Outdated Show resolved Hide resolved
plugins/producer_plugin/qc_chain.old.cpp Outdated Show resolved Hide resolved
plugins/producer_plugin/qc_chain.old2.cpp Outdated Show resolved Hide resolved
plugins/net_plugin/net_plugin.cpp Outdated Show resolved Hide resolved
@heifner heifner marked this pull request as draft August 21, 2023 17:30
@greg7mdp greg7mdp self-requested a review August 21, 2023 21:13
libraries/chain/include/eosio/chain/hotstuff.hpp Outdated Show resolved Hide resolved
fc::variant("bc726a24928ea2d71ba294b70c5c9efc515c1542139bcf9e42f8bc174f2e72ff").as<digest_type>(),
// SHA256 hash of the raw message below within the comment delimiters (do not modify message below).
/*
Builtin protocol feature: INSTANT_FINALITY
Copy link
Member

Choose a reason for hiding this comment

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

Add some explanation about instant_finality like other protocol features do.


add_library( hotstuff
chain_pacemaker.cpp
qc_chain.cpp
Copy link
Member

Choose a reason for hiding this comment

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

I am a little puzzled by chain being a part of those two file names, and one having chain in the front and the other in the end: chain_pacemake.cpp and qc_chain.cpp. Can the names be changed?

#include <iostream>

// comment this out to remove the core profiler
#define HS_CORE_PROFILER
Copy link
Member

Choose a reason for hiding this comment

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

Move HS_CORE_PROFILER to CmakeList.txt to let cmake to control whether to profile or not.

if (! enabled())
return;

csc prof("beat");
Copy link
Member

Choose a reason for hiding this comment

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

For all those profiling statements, maybe each of them should be enclosed with ifdef. Even though csc is a dummy struct when HS_CORE_PROFILER is false, compiler will still generate some code. When read first, it appears profiling is always on. The downside of ifdefs is the cluttering.

Copy link
Member

Choose a reason for hiding this comment

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

Created #1542


namespace fc { namespace crypto { namespace blslib {

/* struct recovery_visitor : fc::visitor<bls_public_key::storage_type> {
Copy link
Member

Choose a reason for hiding this comment

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

should be removed?

namespace fc { namespace crypto { namespace blslib {

struct hash_visitor : public fc::visitor<size_t> {
/* template<typename SigType>
Copy link
Member

Choose a reason for hiding this comment

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

remove?

results.current_qc = fs.current_qc;
results.schedule = fs.schedule;
for (auto proposal: fs.proposals) {
chain::hs_proposal_message & p = proposal.second;
Copy link
Member

Choose a reason for hiding this comment

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

remove the space before &.

@@ -147,6 +147,9 @@ enum return_codes {

int main(int argc, char** argv)
{

ilog("nodeos started");
Copy link
Member

Choose a reason for hiding this comment

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

why this log? if we do, probably should be "nodeos starting".

Copy link
Member

Choose a reason for hiding this comment

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

Can be safely removed

@@ -200,6 +203,7 @@ int main(int argc, char** argv)
} catch( const node_management_success& e ) {
return NODE_MANAGEMENT_SUCCESS;
} catch( const fc::exception& e ) {

Copy link
Member

Choose a reason for hiding this comment

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

why new empty line?

libraries/hotstuff/include/eosio/hotstuff/qc_chain.hpp Outdated Show resolved Hide resolved
libraries/hotstuff/include/eosio/hotstuff/qc_chain.hpp Outdated Show resolved Hide resolved
libraries/hotstuff/qc_chain.cpp Outdated Show resolved Hide resolved
libraries/hotstuff/qc_chain.cpp Outdated Show resolved Hide resolved
libraries/hotstuff/qc_chain.cpp Outdated Show resolved Hide resolved
libraries/hotstuff/qc_chain.cpp Outdated Show resolved Hide resolved
libraries/hotstuff/chain_pacemaker.cpp Outdated Show resolved Hide resolved
libraries/hotstuff/qc_chain.cpp Outdated Show resolved Hide resolved
libraries/hotstuff/qc_chain.cpp Outdated Show resolved Hide resolved

struct extended_schedule {
producer_authority_schedule producer_schedule;
std::map<name, fc::crypto::blslib::bls_public_key> bls_pub_keys;
Copy link
Contributor

Choose a reason for hiding this comment

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

Should the bls_pub_keys be added in the producer_authority_schedule instead of on the side like here?

Copy link
Member

Choose a reason for hiding this comment

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

Extended schedule was a placeholder until we reached a decision on the final format of the finalizers set structure. I think we agreed to only keep the bls public key, as well as the threshold for finalizers (as far as the hotstuff algorithm is concerned). The name would be present in the structure as well, but serves only to identify the finalizer on-chain, and is not required by Hotstuff.

block_id_type block_id = NULL_BLOCK_ID;
fc::sha256 parent_id = NULL_PROPOSAL_ID; //new proposal
fc::sha256 final_on_qc = NULL_PROPOSAL_ID;
quorum_certificate justify; //justification
Copy link
Contributor

Choose a reason for hiding this comment

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

All these = NULL_PROPOSAL_ID are unneeded since the default construction of sha256 already initializes to all zeroes.

libraries/hotstuff/chain_pacemaker.cpp Outdated Show resolved Hide resolved
//
mutable std::mutex _state_mutex;

#ifdef QC_CHAIN_SIMPLE_PROPOSAL_STORE
Copy link
Contributor

Choose a reason for hiding this comment

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

Have we decided on a proposal store? Right now QC_CHAIN_SIMPLE_PROPOSAL_STORE is not defined.

Copy link
Member Author

Choose a reason for hiding this comment

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

The QC_CHAIN_SIMPLE_PROPOSAL_STORE and associated code will be removed. Maybe can be done during #1541 or #1520

libraries/hotstuff/qc_chain.cpp Outdated Show resolved Hide resolved
libraries/hotstuff/qc_chain.cpp Outdated Show resolved Hide resolved
libraries/hotstuff/qc_chain.cpp Outdated Show resolved Hide resolved
libraries/hotstuff/qc_chain.cpp Outdated Show resolved Hide resolved
libraries/hotstuff/qc_chain.cpp Outdated Show resolved Hide resolved
libraries/hotstuff/chain_pacemaker.cpp Outdated Show resolved Hide resolved
libraries/hotstuff/qc_chain.cpp Outdated Show resolved Hide resolved
uint32_t _v_height = 0;
eosio::chain::extended_schedule _schedule;
base_pacemaker* _pacemaker = nullptr;
std::set<name> _my_producers;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this a std::set and not a std::vector. As far as I can tell we never use any of the std::set capabilities.

Copy link

Choose a reason for hiding this comment

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

Agree; there's no reason to sort or uniquify producer account names.

@ericpassmore
Copy link
Contributor

Note:start
group: IF
category: CHORE
summary: Integration of new faster finality into main branch, continued support for legacy DPOS.
Note:end

@ericpassmore
Copy link
Contributor

Note:start
group: IF
category: CHORE
summary: Merge main branch into Faster Finality working branch.
Note: end

heifner and others added 28 commits April 4, 2024 12:22
…ion_block

IF: SHiP -- Provide finality_data for Transition blocks
… to terminate at a block don't put any blocks above that in the fork database.
IF: switch variant index of new `get_blocks_request_v1`
Increment `finalizer_policy`'s `generation` when `set_finalizers` is executed.
IF: Populated fork db ASAP; Vote processing off the main thread
@arhag arhag closed this Aug 20, 2024
@arhag arhag deleted the hotstuff_integration branch August 20, 2024 17:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

IF Prototype Stage 1A Implementation in Leap
8 participants