-
Notifications
You must be signed in to change notification settings - Fork 69
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: Hotstuff message propagation/gossip #1583
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -292,65 +292,66 @@ namespace eosio { namespace hotstuff { | |
prof.core_out(); | ||
} | ||
|
||
void chain_pacemaker::send_hs_proposal_msg(const hs_proposal_message& msg, name id) { | ||
bcast_hs_message(msg); | ||
void chain_pacemaker::send_hs_proposal_msg(const hs_proposal_message& msg, name id, const std::optional<uint32_t>& connection_id) { | ||
bcast_hs_message( { connection_id, msg } ); | ||
} | ||
|
||
void chain_pacemaker::send_hs_vote_msg(const hs_vote_message& msg, name id) { | ||
bcast_hs_message(msg); | ||
void chain_pacemaker::send_hs_vote_msg(const hs_vote_message& msg, name id, const std::optional<uint32_t>& connection_id) { | ||
bcast_hs_message( { connection_id, msg } ); | ||
} | ||
|
||
void chain_pacemaker::send_hs_new_block_msg(const hs_new_block_message& msg, name id) { | ||
bcast_hs_message(msg); | ||
void chain_pacemaker::send_hs_new_block_msg(const hs_new_block_message& msg, name id, const std::optional<uint32_t>& connection_id) { | ||
bcast_hs_message( { connection_id, msg } ); | ||
} | ||
|
||
void chain_pacemaker::send_hs_new_view_msg(const hs_new_view_message& msg, name id) { | ||
bcast_hs_message(msg); | ||
void chain_pacemaker::send_hs_new_view_msg(const hs_new_view_message& msg, name id, const std::optional<uint32_t>& connection_id) { | ||
bcast_hs_message( { connection_id, msg } ); | ||
} | ||
|
||
// called from net threads | ||
void chain_pacemaker::on_hs_msg(const eosio::chain::hs_message &msg) { | ||
uint32_t connection_id = msg.connection_id.value(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This would throw an exception if the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will change/fix. |
||
std::visit(overloaded{ | ||
[this](const hs_vote_message& m) { on_hs_vote_msg(m); }, | ||
[this](const hs_proposal_message& m) { on_hs_proposal_msg(m); }, | ||
[this](const hs_new_block_message& m) { on_hs_new_block_msg(m); }, | ||
[this](const hs_new_view_message& m) { on_hs_new_view_msg(m); }, | ||
}, msg); | ||
[this, connection_id](const hs_vote_message& m) { on_hs_vote_msg(connection_id, m); }, | ||
[this, connection_id](const hs_proposal_message& m) { on_hs_proposal_msg(connection_id, m); }, | ||
[this, connection_id](const hs_new_block_message& m) { on_hs_new_block_msg(connection_id, m); }, | ||
[this, connection_id](const hs_new_view_message& m) { on_hs_new_view_msg(connection_id, m); }, | ||
Comment on lines
+315
to
+318
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we just call There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will try to refactor this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This can be removed when we decide to delete the "core profiling" code. |
||
}, msg.message); | ||
} | ||
|
||
// called from net threads | ||
void chain_pacemaker::on_hs_proposal_msg(const hs_proposal_message& msg) { | ||
void chain_pacemaker::on_hs_proposal_msg(const uint32_t connection_id, const hs_proposal_message& msg) { | ||
csc prof("prop"); | ||
std::lock_guard g( _hotstuff_global_mutex ); | ||
prof.core_in(); | ||
_qc_chain.on_hs_proposal_msg(msg); | ||
_qc_chain.on_hs_proposal_msg(msg, std::make_optional<uint32_t>(connection_id)); | ||
prof.core_out(); | ||
} | ||
|
||
// called from net threads | ||
void chain_pacemaker::on_hs_vote_msg(const hs_vote_message& msg) { | ||
void chain_pacemaker::on_hs_vote_msg(const uint32_t connection_id, const hs_vote_message& msg) { | ||
csc prof("vote"); | ||
std::lock_guard g( _hotstuff_global_mutex ); | ||
prof.core_in(); | ||
_qc_chain.on_hs_vote_msg(msg); | ||
_qc_chain.on_hs_vote_msg(msg, std::make_optional<uint32_t>(connection_id)); | ||
prof.core_out(); | ||
} | ||
|
||
// called from net threads | ||
void chain_pacemaker::on_hs_new_block_msg(const hs_new_block_message& msg) { | ||
void chain_pacemaker::on_hs_new_block_msg(const uint32_t connection_id, const hs_new_block_message& msg) { | ||
csc prof("nblk"); | ||
std::lock_guard g( _hotstuff_global_mutex ); | ||
prof.core_in(); | ||
_qc_chain.on_hs_new_block_msg(msg); | ||
_qc_chain.on_hs_new_block_msg(msg, std::make_optional<uint32_t>(connection_id)); | ||
prof.core_out(); | ||
} | ||
|
||
// called from net threads | ||
void chain_pacemaker::on_hs_new_view_msg(const hs_new_view_message& msg) { | ||
void chain_pacemaker::on_hs_new_view_msg(const uint32_t connection_id, const hs_new_view_message& msg) { | ||
csc prof("view"); | ||
std::lock_guard g( _hotstuff_global_mutex ); | ||
prof.core_in(); | ||
_qc_chain.on_hs_new_view_msg(msg); | ||
_qc_chain.on_hs_new_view_msg(msg, std::make_optional<uint32_t>(connection_id)); | ||
prof.core_out(); | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this should be added to the message. This requires the
hs_message_inner
to be copied. Better to pass it along as extra params.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, will do that.