add --mandatory-headers-only cli option to complex relay (#1129)

This commit is contained in:
Svyatoslav Nikolsky
2021-09-13 09:26:36 +03:00
committed by Bastian Köcher
parent 7e98cc8f37
commit 77969c567f
2 changed files with 9 additions and 1 deletions
@@ -57,6 +57,9 @@ pub struct HeadersAndMessagesSharedParams {
lane: Vec<HexLaneId>, lane: Vec<HexLaneId>,
#[structopt(long, possible_values = RelayerMode::VARIANTS, case_insensitive = true, default_value = "rational")] #[structopt(long, possible_values = RelayerMode::VARIANTS, case_insensitive = true, default_value = "rational")]
relayer_mode: RelayerMode, relayer_mode: RelayerMode,
/// If passed, only mandatory headers (headers that are changing the GRANDPA authorities set) are relayed.
#[structopt(long)]
only_mandatory_headers: bool,
#[structopt(flatten)] #[structopt(flatten)]
prometheus_params: PrometheusParams, prometheus_params: PrometheusParams,
} }
@@ -278,6 +281,7 @@ impl RelayHeadersAndMessages {
right_transactions_mortality, right_transactions_mortality,
LeftToRightFinality::new(right_client.clone(), right_sign.clone()), LeftToRightFinality::new(right_client.clone(), right_sign.clone()),
MAX_MISSING_LEFT_HEADERS_AT_RIGHT, MAX_MISSING_LEFT_HEADERS_AT_RIGHT,
params.shared.only_mandatory_headers,
); );
let right_to_left_on_demand_headers = OnDemandHeadersRelay::new( let right_to_left_on_demand_headers = OnDemandHeadersRelay::new(
right_client.clone(), right_client.clone(),
@@ -285,6 +289,7 @@ impl RelayHeadersAndMessages {
left_transactions_mortality, left_transactions_mortality,
RightToLeftFinality::new(left_client.clone(), left_sign.clone()), RightToLeftFinality::new(left_client.clone(), left_sign.clone()),
MAX_MISSING_RIGHT_HEADERS_AT_LEFT, MAX_MISSING_RIGHT_HEADERS_AT_LEFT,
params.shared.only_mandatory_headers,
); );
// Need 2x capacity since we consider both directions for each lane // Need 2x capacity since we consider both directions for each lane
@@ -59,6 +59,7 @@ impl<SourceChain: Chain> OnDemandHeadersRelay<SourceChain> {
target_transactions_mortality: Option<u32>, target_transactions_mortality: Option<u32>,
pipeline: P, pipeline: P,
maximal_headers_difference: SourceChain::BlockNumber, maximal_headers_difference: SourceChain::BlockNumber,
only_mandatory_headers: bool,
) -> Self ) -> Self
where where
SourceChain: Chain + Debug, SourceChain: Chain + Debug,
@@ -83,6 +84,7 @@ impl<SourceChain: Chain> OnDemandHeadersRelay<SourceChain> {
target_transactions_mortality, target_transactions_mortality,
pipeline, pipeline,
maximal_headers_difference, maximal_headers_difference,
only_mandatory_headers,
required_header_number, required_header_number,
) )
.await; .await;
@@ -115,6 +117,7 @@ async fn background_task<SourceChain, TargetChain, TargetSign, P>(
target_transactions_mortality: Option<u32>, target_transactions_mortality: Option<u32>,
pipeline: P, pipeline: P,
maximal_headers_difference: SourceChain::BlockNumber, maximal_headers_difference: SourceChain::BlockNumber,
only_mandatory_headers: bool,
required_header_number: RequiredHeaderNumberRef<SourceChain>, required_header_number: RequiredHeaderNumberRef<SourceChain>,
) where ) where
SourceChain: Chain + Debug, SourceChain: Chain + Debug,
@@ -230,7 +233,7 @@ async fn background_task<SourceChain, TargetChain, TargetSign, P>(
tick: std::cmp::max(SourceChain::AVERAGE_BLOCK_INTERVAL, TargetChain::AVERAGE_BLOCK_INTERVAL), tick: std::cmp::max(SourceChain::AVERAGE_BLOCK_INTERVAL, TargetChain::AVERAGE_BLOCK_INTERVAL),
recent_finality_proofs_limit: RECENT_FINALITY_PROOFS_LIMIT, recent_finality_proofs_limit: RECENT_FINALITY_PROOFS_LIMIT,
stall_timeout: STALL_TIMEOUT, stall_timeout: STALL_TIMEOUT,
only_mandatory_headers: false, only_mandatory_headers,
}, },
MetricsParams::disabled(), MetricsParams::disabled(),
futures::future::pending(), futures::future::pending(),