fuel_relayer/
config.rs

1use ethers_contract::EthEvent;
2use ethers_core::types::{
3    H160,
4    H256,
5};
6use fuel_core_interfaces::model::DaBlockHeight;
7use once_cell::sync::Lazy;
8use std::{
9    str::FromStr,
10    time::Duration,
11};
12
13pub(crate) static ETH_LOG_MESSAGE: Lazy<H256> =
14    Lazy::new(crate::abi::bridge::message::SentMessageFilter::signature);
15
16// TODO: Move settlement fields into `ChainConfig` because it is part of the consensus.
17#[derive(Clone, Debug)]
18/// Configuration settings for the Relayer.
19pub struct Config {
20    /// The da block to which the contract was deployed.
21    pub da_deploy_height: DaBlockHeight,
22    /// Number of da blocks after which messages/stakes/validators become finalized.
23    pub da_finalization: DaBlockHeight,
24    /// Uri address to ethereum client.
25    pub eth_client: Option<url::Url>,
26    // TODO: Create `EthAddress` into `fuel_types`.
27    /// Ethereum contract address.
28    pub eth_v2_listening_contracts: Vec<H160>,
29    /// Number of pages or blocks containing logs that
30    /// should be downloaded in a single call to the da layer
31    pub log_page_size: u64,
32    /// This throttles the background relayer loop to
33    /// at least this duration to prevent spamming the DA node.
34    pub sync_minimum_duration: Duration,
35    /// How often calls are made to the DA node when the DA node
36    /// is in the process of syncing.
37    pub syncing_call_frequency: Duration,
38    /// How often progress logs are printed when the DA node is
39    /// syncing.
40    pub syncing_log_frequency: Duration,
41
42    /// Enables metrics on this fuel service
43    pub metrics: bool,
44}
45
46#[allow(missing_docs)]
47impl Config {
48    pub const DEFAULT_LOG_PAGE_SIZE: u64 = 5;
49    pub const DEFAULT_DA_FINALIZATION: u64 = 100;
50    pub const DEFAULT_DA_DEPLOY_HEIGHT: u64 = 0;
51    pub const DEFAULT_SYNC_MINIMUM_DURATION: Duration = Duration::from_secs(5);
52    pub const DEFAULT_SYNCING_CALL_FREQ: Duration = Duration::from_secs(5);
53    pub const DEFAULT_SYNCING_LOG_FREQ: Duration = Duration::from_secs(60);
54}
55
56impl Default for Config {
57    fn default() -> Self {
58        Self {
59            da_deploy_height: DaBlockHeight::from(Self::DEFAULT_DA_DEPLOY_HEIGHT),
60            da_finalization: DaBlockHeight::from(Self::DEFAULT_DA_FINALIZATION),
61            eth_client: None,
62            eth_v2_listening_contracts: vec![H160::from_str(
63                "0x03E4538018285e1c03CCce2F92C9538c87606911",
64            )
65            .unwrap()],
66            log_page_size: Self::DEFAULT_LOG_PAGE_SIZE,
67            sync_minimum_duration: Self::DEFAULT_SYNC_MINIMUM_DURATION,
68            syncing_call_frequency: Self::DEFAULT_SYNCING_CALL_FREQ,
69            syncing_log_frequency: Self::DEFAULT_SYNCING_LOG_FREQ,
70            metrics: false,
71        }
72    }
73}