@@ -687,6 +687,7 @@ class producer_plugin_impl : public std::enable_shared_from_this<producer_plugin
687
687
std::map<chain::public_key_type, signature_provider_type> _signature_providers;
688
688
chain::bls_pub_priv_key_map_t _finalizer_keys; // public, private
689
689
std::set<chain::account_name> _producers;
690
+ chain::db_read_mode _db_read_mode = db_read_mode::HEAD;
690
691
boost::asio::deadline_timer _timer;
691
692
block_timing_util::producer_watermarks _producer_watermarks;
692
693
pending_block_mode _pending_block_mode = pending_block_mode::speculating;
@@ -833,6 +834,10 @@ class producer_plugin_impl : public std::enable_shared_from_this<producer_plugin
833
834
return !_producers.empty();
834
835
}
835
836
837
+ bool irreversible_mode() const {
838
+ return _db_read_mode == db_read_mode::IRREVERSIBLE;
839
+ }
840
+
836
841
void on_accepted_block(const signed_block_ptr& block, const block_id_type& id) {
837
842
auto& chain = chain_plug->chain();
838
843
auto before = _unapplied_transactions.size();
@@ -1532,10 +1537,12 @@ void producer_plugin_impl::plugin_startup() {
1532
1537
dlog("producer plugin: plugin_startup() begin");
1533
1538
1534
1539
chain::controller& chain = chain_plug->chain();
1535
- EOS_ASSERT(!is_configured_producer() || chain.get_read_mode() != chain::db_read_mode::IRREVERSIBLE, plugin_config_exception,
1540
+ _db_read_mode = chain.get_read_mode();
1541
+
1542
+ EOS_ASSERT(!is_configured_producer() || !irreversible_mode(), plugin_config_exception,
1536
1543
"node cannot have any producer-name configured because block production is impossible when read_mode is \"irreversible\"");
1537
1544
1538
- EOS_ASSERT(_finalizer_keys.empty() || chain.get_read_mode() != chain::db_read_mode::IRREVERSIBLE , plugin_config_exception,
1545
+ EOS_ASSERT(_finalizer_keys.empty() || !irreversible_mode() , plugin_config_exception,
1539
1546
"node cannot have any finalizers configured because finalization is impossible when read_mode is \"irreversible\"");
1540
1547
1541
1548
EOS_ASSERT(!is_configured_producer() || chain.get_validation_mode() == chain::validation_mode::FULL, plugin_config_exception,
@@ -1587,6 +1594,10 @@ void producer_plugin_impl::plugin_startup() {
1587
1594
_irreversible_block_time = fc::time_point::maximum();
1588
1595
}
1589
1596
1597
+ if (!_is_savanna_active && irreversible_mode() && chain_plug->accept_transactions()) {
1598
+ wlog("Legacy consensus active. Accepting speculative transaction execution not recommended in read-mode=irreversible");
1599
+ }
1600
+
1590
1601
if (is_configured_producer()) {
1591
1602
ilog("Launching block production for ${n} producers at ${time}.", ("n", _producers.size())("time", fc::time_point::now()));
1592
1603
@@ -1978,8 +1989,11 @@ bool producer_plugin_impl::should_interrupt_start_block(const fc::time_point& de
1978
1989
if (in_producing_mode()) {
1979
1990
return deadline <= fc::time_point::now();
1980
1991
}
1981
- // if we can produce then honor deadline so production starts on time
1982
- return (is_configured_producer() && deadline <= fc::time_point::now()) || (_received_block >= pending_block_num);
1992
+ // if we can produce then honor deadline so production starts on time.
1993
+ // if in irreversible mode then a received block should not interrupt since the incoming block is not processed until
1994
+ // it becomes irreversible. We could check if LIB changed, but doesn't seem like the extra complexity is worth it.
1995
+ return (is_configured_producer() && deadline <= fc::time_point::now())
1996
+ || (!irreversible_mode() && _received_block >= pending_block_num);
1983
1997
}
1984
1998
1985
1999
producer_plugin_impl::start_block_result producer_plugin_impl::start_block() {
@@ -2081,7 +2095,7 @@ producer_plugin_impl::start_block_result producer_plugin_impl::start_block() {
2081
2095
// Determine if we are syncing: if we have recently started an old block then assume we are syncing
2082
2096
if (last_start_block_time < now + fc::microseconds(config::block_interval_us)) {
2083
2097
auto head_block_age = now - chain.head().block_time();
2084
- if (head_block_age > fc::seconds (5))
2098
+ if (head_block_age > fc::minutes (5))
2085
2099
return start_block_result::waiting_for_block; // if syncing no need to create a block just to immediately abort it
2086
2100
}
2087
2101
last_start_block_time = now;
0 commit comments