Skip to content
Draft
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions integration-tests/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ fn load_config_from_path(config_path: &Path) -> Config {
Config {
genesis_config,
l1_sender_config: config_repo.single().unwrap().parse().unwrap(),
provider_config: Default::default(),
general_config: config_repo.single().unwrap().parse().unwrap(),
network_config: Default::default(),
rpc_config: Default::default(),
Expand Down
1 change: 1 addition & 0 deletions integration-tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ impl Tester {
tx_validator_config: Default::default(),
sequencer_config,
l1_sender_config: default_config.l1_sender_config.clone(),
provider_config: Default::default(),
l1_watcher_config: Default::default(),
batcher_config: Default::default(),
prover_input_generator_config: ProverInputGeneratorConfig {
Expand Down
16 changes: 16 additions & 0 deletions node/bin/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ pub struct Config {
pub tx_validator_config: MempoolTxValidatorConfig,
pub sequencer_config: SequencerConfig,
pub l1_sender_config: L1SenderConfig,
pub provider_config: ProviderConfig,
pub l1_watcher_config: L1WatcherConfig,
pub batcher_config: BatcherConfig,
pub prover_input_generator_config: ProverInputGeneratorConfig,
Expand Down Expand Up @@ -84,6 +85,9 @@ impl Config {
schema
.insert(&L1SenderConfig::DESCRIPTION, "l1_sender")
.expect("Failed to insert l1_sender config");
schema
.insert(&ProviderConfig::DESCRIPTION, "provider")
.expect("Failed to insert provider config");
schema
.insert(&L1WatcherConfig::DESCRIPTION, "l1_watcher")
.expect("Failed to insert l1_watcher config");
Expand Down Expand Up @@ -549,6 +553,18 @@ pub struct L1SenderConfig {
pub pubdata_mode: Option<PubdataMode>,
}

#[derive(Clone, Debug, DescribeConfig, DeserializeConfig)]
#[config(derive(Default))]
pub struct ProviderConfig {
/// Number of retries for L1/SL RPC calls, excluding the initial attempt.
#[config(default_t = 2)]
pub max_retries: u32,

/// Constant backoff duration between L1/SL RPC retries.
#[config(default_t = 200 * TimeUnit::Millis)]
pub retry_backoff: Duration,
}

#[derive(Clone, Debug, DescribeConfig, DeserializeConfig)]
#[config(derive(Default))]
pub struct L1WatcherConfig {
Expand Down
5 changes: 3 additions & 2 deletions node/bin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,10 @@ pub async fn run<State: ReadStateHistory + WriteState + StateInitializer + Clone

// This is the only place where we initialize L1 provider, every component shares the same
// cloned provider.
let l1_provider = build_node_provider(&config.general_config.l1_rpc_url).await;
let l1_provider =
build_node_provider(&config.general_config.l1_rpc_url, &config.provider_config).await;
let sl_provider = match &config.general_config.gateway_rpc_url {
Some(url) => build_node_provider(url).await,
Some(url) => build_node_provider(url, &config.provider_config).await,
None => l1_provider.clone(),
};
let gateway_provider = config
Expand Down
11 changes: 9 additions & 2 deletions node/bin/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ use zksync_os_server::config::{
ExternalPriceApiClientConfig, FeeConfig, GasAdjusterConfig, GeneralConfig, GenesisConfig,
InteropFeeUpdaterConfig, L1SenderConfig, L1WatcherConfig, MempoolConfig,
MempoolTxValidatorConfig, NetworkConfig, ObservabilityConfig, ProofStorageConfig,
ProverApiConfig, ProverInputGeneratorConfig, RebuildBlocksConfig, RpcConfig, SequencerConfig,
StateBackendConfig, StatusServerConfig,
ProverApiConfig, ProverInputGeneratorConfig, ProviderConfig, RebuildBlocksConfig, RpcConfig,
SequencerConfig, StateBackendConfig, StatusServerConfig,
};
use zksync_os_server::default_protocol_version::{DEFAULT_ROCKS_DB_PATH, PROTOCOL_VERSION};
use zksync_os_server::{INTERNAL_CONFIG_FILE_NAME, run};
Expand Down Expand Up @@ -294,6 +294,12 @@ async fn build_external_config(repo: ConfigRepository<'_>) -> Config {
l1_sender_config.pubdata_mode = None;
}

let provider_config = repo
.single::<ProviderConfig>()
.expect("Failed to load provider config")
.parse()
.expect("Failed to parse provider config");

let l1_watcher_config = repo
.single::<L1WatcherConfig>()
.expect("Failed to load L1 watcher config")
Expand Down Expand Up @@ -409,6 +415,7 @@ async fn build_external_config(repo: ConfigRepository<'_>) -> Config {
tx_validator_config,
sequencer_config,
l1_sender_config,
provider_config,
l1_watcher_config,
batcher_config,
prover_input_generator_config,
Expand Down
6 changes: 4 additions & 2 deletions node/bin/src/provider.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::config::ProviderConfig;
use alloy::network::{Ethereum, EthereumWallet};
use alloy::providers::fillers::{FillProvider, TxFiller};
use alloy::providers::{Provider, ProviderBuilder, WalletProvider};
Expand Down Expand Up @@ -42,13 +43,14 @@ impl RetryPolicy for OptimisticRetryPolicy {

pub async fn build_node_provider(
rpc_url: &str,
provider_config: &ProviderConfig,
) -> FillProvider<
impl TxFiller<Ethereum> + WalletProvider<Wallet = EthereumWallet> + 'static,
impl Provider<Ethereum> + Clone + 'static,
> {
let retry_layer = RetryBackoffLayer::new_with_policy(
2, // max retries, excluding the initial attempt
200, // backoff in ms,
provider_config.max_retries,
provider_config.retry_backoff.as_millis() as u64,
u64::MAX, // compute units per second, considering it unlimited for now
OptimisticRetryPolicy::default(),
);
Expand Down
Loading