Skip to content

Commit

Permalink
polkadot: disable block authoring backoff on production networks (#2510)
Browse files Browse the repository at this point in the history
Currently the polkadot node will backoff from block authoring if
finality starts lagging. This PR disables this mechanism on production
networks (polkadot and kusama) and adds a flags to optionally force
enabling it.
  • Loading branch information
andresilva authored Nov 28, 2023
1 parent 0f7ffc6 commit 58a1f9c
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 4 deletions.
1 change: 1 addition & 0 deletions cumulus/client/relay-chain-inprocess-interface/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ fn build_polkadot_full_node(
grandpa_pause: None,
// Disable BEEFY. It should not be required by the internal relay chain node.
enable_beefy: false,
force_authoring_backoff: false,
jaeger_agent: None,
telemetry_worker_handle,

Expand Down
4 changes: 4 additions & 0 deletions polkadot/cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ pub struct RunCmd {
#[arg(long)]
pub no_beefy: bool,

/// Enable the block authoring backoff that is triggered when finality is lagging.
#[arg(long)]
pub force_authoring_backoff: bool,

/// Add the destination address to the 'Jaeger' agent.
///
/// Must be valid socket address, of format `IP:Port` (commonly `127.0.0.1:6831`).
Expand Down
1 change: 1 addition & 0 deletions polkadot/cli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ where
is_parachain_node: service::IsParachainNode::No,
grandpa_pause,
enable_beefy,
force_authoring_backoff: cli.run.force_authoring_backoff,
jaeger_agent,
telemetry_worker_handle: None,
node_version,
Expand Down
18 changes: 14 additions & 4 deletions polkadot/node/service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,9 @@ pub struct NewFullParams<OverseerGenerator: OverseerGen> {
pub is_parachain_node: IsParachainNode,
pub grandpa_pause: Option<(u32, u32)>,
pub enable_beefy: bool,
/// Whether to enable the block authoring backoff on production networks
/// where it isn't enabled by default.
pub force_authoring_backoff: bool,
pub jaeger_agent: Option<std::net::SocketAddr>,
pub telemetry_worker_handle: Option<TelemetryWorkerHandle>,
/// The version of the node. TESTING ONLY: `None` can be passed to skip the node/worker version
Expand Down Expand Up @@ -716,6 +719,7 @@ pub fn new_full<OverseerGenerator: OverseerGen>(
is_parachain_node,
grandpa_pause,
enable_beefy,
force_authoring_backoff,
jaeger_agent,
telemetry_worker_handle,
node_version,
Expand All @@ -733,15 +737,21 @@ pub fn new_full<OverseerGenerator: OverseerGen>(
let is_offchain_indexing_enabled = config.offchain_worker.indexing_enabled;
let role = config.role.clone();
let force_authoring = config.force_authoring;
let backoff_authoring_blocks = {
let backoff_authoring_blocks = if !force_authoring_backoff &&
(config.chain_spec.is_polkadot() || config.chain_spec.is_kusama())
{
// the block authoring backoff is disabled by default on production networks
None
} else {
let mut backoff = sc_consensus_slots::BackoffAuthoringOnFinalizedHeadLagging::default();

if config.chain_spec.is_rococo() ||
config.chain_spec.is_wococo() ||
config.chain_spec.is_versi()
config.chain_spec.is_versi() ||
config.chain_spec.is_dev()
{
// it's a testnet that's in flux, finality has stalled sometimes due
// to operational issues and it's annoying to slow down block
// on testnets that are in flux (like rococo or versi), finality has stalled
// sometimes due to operational issues and it's annoying to slow down block
// production to 1 block per hour.
backoff.max_interval = 10;
}
Expand Down
1 change: 1 addition & 0 deletions polkadot/node/test/service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ pub fn new_full(
is_parachain_node,
grandpa_pause: None,
enable_beefy: true,
force_authoring_backoff: false,
jaeger_agent: None,
telemetry_worker_handle: None,
node_version: None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ fn main() -> Result<()> {
),
grandpa_pause: None,
enable_beefy: false,
force_authoring_backoff: false,
jaeger_agent: None,
telemetry_worker_handle: None,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ fn main() -> Result<()> {
),
grandpa_pause: None,
enable_beefy: false,
force_authoring_backoff: false,
jaeger_agent: None,
telemetry_worker_handle: None,

Expand Down

0 comments on commit 58a1f9c

Please sign in to comment.