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

[5.0] Normalize speculative & producer block intervals #1840

Merged
merged 1 commit into from
Oct 28, 2023
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
13 changes: 2 additions & 11 deletions plugins/producer_plugin/producer_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ class producer_plugin_impl : public std::enable_shared_from_this<producer_plugin
account_name first_auth,
int64_t sub_bill,
uint32_t prev_billed_cpu_time_us);

void log_trx_results(const transaction_metadata_ptr& trx, const transaction_trace_ptr& trace, const fc::time_point& start);
void log_trx_results(const transaction_metadata_ptr& trx, const fc::exception_ptr& except_ptr);
void log_trx_results(const packed_transaction_ptr& trx,
Expand Down Expand Up @@ -1830,7 +1830,7 @@ producer_plugin_impl::start_block_result producer_plugin_impl::start_block() {
}

// create speculative blocks at regular intervals, so we create blocks with "current" block time
_pending_block_deadline = now + fc::microseconds(config::block_interval_us);
_pending_block_deadline = block_timing_util::calculate_producing_block_deadline(_produce_block_cpu_effort, block_time);
greg7mdp marked this conversation as resolved.
Show resolved Hide resolved
if (in_producing_mode()) {
uint32_t production_round_index = block_timestamp_type(block_time).slot % chain::config::producer_repetitions;
if (production_round_index == 0) {
Expand All @@ -1842,15 +1842,6 @@ producer_plugin_impl::start_block_result producer_plugin_impl::start_block() {
return start_block_result::waiting_for_production;
}
}

_pending_block_deadline = block_timing_util::calculate_producing_block_deadline(_produce_block_cpu_effort, block_time);
} else if (!_producers.empty()) {
// cpu effort percent doesn't matter for the first block of the round, use max (block_interval_us) for cpu effort
auto wake_time = block_timing_util::calculate_producer_wake_up_time(fc::microseconds(config::block_interval_us), chain.head_block_num(), chain.head_block_time(),
_producers, chain.head_block_state()->active_schedule.producers,
_producer_watermarks);
if (wake_time)
_pending_block_deadline = std::min(*wake_time, _pending_block_deadline);
}

const auto& preprocess_deadline = _pending_block_deadline;
Expand Down