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: Fix sigsegv in the use of process_vote_message #2185

Merged
merged 1 commit into from
Feb 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 17 additions & 12 deletions libraries/chain/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2998,6 +2998,21 @@ struct controller_impl {
} FC_CAPTURE_AND_RETHROW();
} /// apply_block

// called from net threads and controller's thread pool
bool process_vote_message( const vote_message& vote ) {
auto do_vote = [&vote](auto& forkdb) -> std::pair<bool, std::optional<uint32_t>> {
auto bsp = forkdb.get_block(vote.proposal_id);
if (bsp)
return bsp->aggregate_vote(vote);
return {false, {}};
};
auto [valid, new_lib] = fork_db.apply_if<std::pair<bool, std::optional<uint32_t>>>(do_vote);
if (new_lib) {
set_if_irreversible_block_num(*new_lib);
}
return valid;
};

void create_and_send_vote_msg(const block_state_ptr& bsp) {
#warning use decide_vote() for strong after it is implementd by https://github.com/AntelopeIO/leap/issues/2070
bool strong = true;
Expand All @@ -3020,7 +3035,7 @@ struct controller_impl {
emit( self.voted_block, vote );

boost::asio::post(thread_pool.get_executor(), [control=this, vote]() {
control->self.process_vote_message(vote);
control->process_vote_message(vote);
});
}
}
Expand Down Expand Up @@ -4388,17 +4403,7 @@ void controller::set_proposed_finalizers( const finalizer_policy& fin_pol ) {

// called from net threads
bool controller::process_vote_message( const vote_message& vote ) {
auto do_vote = [&vote](auto& forkdb) -> std::pair<bool, std::optional<uint32_t>> {
auto bsp = forkdb.get_block(vote.proposal_id);
if (bsp)
return bsp->aggregate_vote(vote);
return {false, {}};
};
auto [valid, new_lib] = my->fork_db.apply_if<std::pair<bool, std::optional<uint32_t>>>(do_vote);
if (new_lib) {
my->set_if_irreversible_block_num(*new_lib);
}
return valid;
return my->process_vote_message( vote );
};

const producer_authority_schedule& controller::active_producers()const {
Expand Down
Loading