mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-30 22:27:56 +00:00
client/authority-discovery: Publish and query on exponential interval (#7545)
* client/authority-discovery: Publish and query on exponential interval When a node starts up publishing and querying might fail due to various reasons, for example due to being not yet fully bootstrapped on the DHT. Thus one should retry rather sooner than later. On the other hand, a long running node is likely well connected and thus timely retries are not needed. For this reasoning use an exponentially increasing interval for `publish_interval`, `query_interval` and `priority_group_set_interval` instead of a constant interval. * client/authority-discovery/src/interval.rs: Add license header * .maintain/gitlab: Ensure adder collator tests are run on CI
This commit is contained in:
@@ -38,50 +38,41 @@ use sp_runtime::traits::Block as BlockT;
|
||||
use sp_api::ProvideRuntimeApi;
|
||||
|
||||
mod error;
|
||||
mod interval;
|
||||
mod service;
|
||||
mod worker;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
mod worker;
|
||||
|
||||
/// Configuration of [`Worker`].
|
||||
pub struct WorkerConfig {
|
||||
/// The interval in which the node will publish its own address on the DHT.
|
||||
/// The maximum interval in which the node will publish its own address on the DHT.
|
||||
///
|
||||
/// By default this is set to 12 hours.
|
||||
pub publish_interval: Duration,
|
||||
/// The interval in which the node will query the DHT for new entries.
|
||||
/// By default this is set to 1 hour.
|
||||
pub max_publish_interval: Duration,
|
||||
/// The maximum interval in which the node will query the DHT for new entries.
|
||||
///
|
||||
/// By default this is set to 10 minutes.
|
||||
pub query_interval: Duration,
|
||||
/// The time the node will wait before triggering the first DHT query or publish.
|
||||
///
|
||||
/// By default this is set to 30 seconds.
|
||||
///
|
||||
/// This default is based on the rough boostrap time required by libp2p Kademlia.
|
||||
pub query_start_delay: Duration,
|
||||
/// The interval in which the worker will instruct the peerset to connect to a random subset
|
||||
/// of discovered validators.
|
||||
///
|
||||
/// By default this is set to 10 minutes.
|
||||
pub priority_group_set_interval: Duration,
|
||||
/// The time the worker will wait after each query interval tick to pass a subset of
|
||||
/// the cached authority addresses down to the peerset.
|
||||
///
|
||||
/// Be aware that the actual delay will be computed by [`Self::query_start_delay`] +
|
||||
/// [`Self::priority_group_set_start_delay`]
|
||||
///
|
||||
/// By default this is set to 5 minutes.
|
||||
pub priority_group_set_offset: Duration,
|
||||
pub max_query_interval: Duration,
|
||||
}
|
||||
|
||||
impl Default for WorkerConfig {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
publish_interval: Duration::from_secs(12 * 60 * 60),
|
||||
query_interval: Duration::from_secs(10 * 60),
|
||||
query_start_delay: Duration::from_secs(30),
|
||||
priority_group_set_interval: Duration::from_secs(10 * 60),
|
||||
priority_group_set_offset: Duration::from_secs(5 * 60),
|
||||
// Kademlia's default time-to-live for Dht records is 36h, republishing records every
|
||||
// 24h through libp2p-kad. Given that a node could restart at any point in time, one can
|
||||
// not depend on the republishing process, thus publishing own external addresses should
|
||||
// happen on an interval < 36h.
|
||||
max_publish_interval: Duration::from_secs(1 * 60 * 60),
|
||||
// External addresses of remote authorities can change at any given point in time. The
|
||||
// interval on which to trigger new queries for the current and next authorities is a trade
|
||||
// off between efficiency and performance.
|
||||
//
|
||||
// Querying 700 [`AuthorityId`]s takes ~8m on the Kusama DHT (16th Nov 2020) when
|
||||
// comparing `authority_discovery_authority_addresses_requested_total` and
|
||||
// `authority_discovery_dht_event_received`.
|
||||
max_query_interval: Duration::from_secs(10 * 60),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user