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

P2P: Immediately close on bad block #912

Merged
merged 3 commits into from
Oct 9, 2024
Merged
Changes from 2 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
11 changes: 3 additions & 8 deletions plugins/net_plugin/net_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,6 @@ namespace eosio {
void bcast_transaction(const packed_transaction_ptr& trx);
void rejected_transaction(const packed_transaction_ptr& trx);
void bcast_block( const signed_block_ptr& b, const block_id_type& id );
void rejected_block(const block_id_type& id);

void expire_blocks( uint32_t lib_num );
void recv_notice(const connection_ptr& conn, const notice_message& msg, bool generated);
Expand Down Expand Up @@ -2701,10 +2700,6 @@ namespace eosio {
} );
}

void dispatch_manager::rejected_block(const block_id_type& id) {
fc_dlog( logger, "rejected block ${bn} ${id}", ("bn", block_header::num_from_id(id))("id", id) );
}

// called from any thread
void dispatch_manager::bcast_transaction(const packed_transaction_ptr& trx) {
trx_buffer_factory buff_factory;
Expand Down Expand Up @@ -3723,7 +3718,7 @@ namespace eosio {
bool exception = false;
bool best_head = false;
bool unlinkable = false;
sync_manager::closing_mode close_mode = sync_manager::closing_mode::handshake;
sync_manager::closing_mode close_mode = sync_manager::closing_mode::immediately;
try {
EOS_ASSERT(ptr->timestamp < (fc::time_point::now() + fc::seconds(7)), block_from_the_future,
"received a block from the future, ignoring it: ${id}", ("id", id));
linh2931 marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -3732,9 +3727,9 @@ namespace eosio {
best_head = abh.is_new_best_head;
obh = std::move(abh.block);
unlinkable = !obh;
close_mode = sync_manager::closing_mode::handshake;
} catch( const invalid_qc_claim& ex) {
exception = true;
close_mode = sync_manager::closing_mode::immediately;
fc_wlog( logger, "invalid QC claim exception, connection - ${cid}: #${n} ${id}...: ${m}",
("cid", cid)("n", ptr->block_num())("id", id.str().substr(8,16))("m",ex.to_string()));
} catch( const fc::exception& ex ) {
Expand All @@ -3753,8 +3748,8 @@ namespace eosio {
("bn", ptr->block_num())("id", id)("pn", block_header::num_from_id(ptr->previous))("pid", ptr->previous));
}
boost::asio::post(c->strand, [c, id, blk_num=ptr->block_num(), close_mode]() {
peer_dlog( c, "rejected block ${bn} ${id}", ("bn", blk_num)("id", id) );
my_impl->sync_master->rejected_block( c, blk_num, close_mode );
my_impl->dispatcher.rejected_block( id );
});
return;
}
Expand Down