From 7f2f7e0514a19d4ebf43ae693c2a18961fd22bae Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Mon, 7 Oct 2024 12:21:36 -0500 Subject: [PATCH 1/3] Reschedule enqueue_sync_block --- plugins/net_plugin/net_plugin.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/plugins/net_plugin/net_plugin.cpp b/plugins/net_plugin/net_plugin.cpp index b400c9a1fa..798d7bb543 100644 --- a/plugins/net_plugin/net_plugin.cpp +++ b/plugins/net_plugin/net_plugin.cpp @@ -1766,6 +1766,12 @@ namespace eosio { if( current_rate_sec >= block_sync_rate_limit ) { block_sync_throttling = true; peer_dlog( this, "throttling block sync to peer ${host}:${port}", ("host", log_remote_endpoint_ip)("port", log_remote_endpoint_port)); + std::shared_ptr throttle_timer = std::make_shared(strand); + throttle_timer->expires_from_now(std::chrono::milliseconds(100)); + throttle_timer->async_wait([this, throttle_timer](const boost::system::error_code& ec) { + if (!ec) + enqueue_sync_block(); + }); return false; } } From dbc9f5f0952c6c20cbe0c088c328b8f8b25de5f7 Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Mon, 7 Oct 2024 13:08:24 -0500 Subject: [PATCH 2/3] GH-882 release branch not updated to use use new strand, use bind_executor instead --- plugins/net_plugin/net_plugin.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/net_plugin/net_plugin.cpp b/plugins/net_plugin/net_plugin.cpp index 798d7bb543..5cefd0022d 100644 --- a/plugins/net_plugin/net_plugin.cpp +++ b/plugins/net_plugin/net_plugin.cpp @@ -1766,12 +1766,12 @@ namespace eosio { if( current_rate_sec >= block_sync_rate_limit ) { block_sync_throttling = true; peer_dlog( this, "throttling block sync to peer ${host}:${port}", ("host", log_remote_endpoint_ip)("port", log_remote_endpoint_port)); - std::shared_ptr throttle_timer = std::make_shared(strand); + std::shared_ptr throttle_timer = std::make_shared(my_impl->thread_pool.get_executor()); throttle_timer->expires_from_now(std::chrono::milliseconds(100)); - throttle_timer->async_wait([this, throttle_timer](const boost::system::error_code& ec) { + throttle_timer->async_wait(boost::asio::bind_executor(strand, [this, throttle_timer](const boost::system::error_code& ec) { if (!ec) enqueue_sync_block(); - }); + })); return false; } } From 54d46a8cbcf32ca75fcee7a1b5b1f2353ceb7d35 Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Mon, 7 Oct 2024 13:15:03 -0500 Subject: [PATCH 3/3] GH-882 Use connection_ptr instead of this --- plugins/net_plugin/net_plugin.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/net_plugin/net_plugin.cpp b/plugins/net_plugin/net_plugin.cpp index 5cefd0022d..0d3eeab6cc 100644 --- a/plugins/net_plugin/net_plugin.cpp +++ b/plugins/net_plugin/net_plugin.cpp @@ -1768,9 +1768,9 @@ namespace eosio { peer_dlog( this, "throttling block sync to peer ${host}:${port}", ("host", log_remote_endpoint_ip)("port", log_remote_endpoint_port)); std::shared_ptr throttle_timer = std::make_shared(my_impl->thread_pool.get_executor()); throttle_timer->expires_from_now(std::chrono::milliseconds(100)); - throttle_timer->async_wait(boost::asio::bind_executor(strand, [this, throttle_timer](const boost::system::error_code& ec) { + throttle_timer->async_wait(boost::asio::bind_executor(strand, [c=shared_from_this(), throttle_timer](const boost::system::error_code& ec) { if (!ec) - enqueue_sync_block(); + c->enqueue_sync_block(); })); return false; }