Skip to content

Commit

Permalink
Merge pull request eqlabs#2162 from eqlabs/krisztian/fix-l1-polling-i…
Browse files Browse the repository at this point in the history
…nterval

feat(pathfinder): add CLI option for setting L1 poll interval
  • Loading branch information
kkovaacs authored Aug 12, 2024
2 parents e42e6d1 + 0c9e670 commit 412267f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added

- Pathfinder JSON-RPC extension methods are now also exposed on the `/rpc/pathfinder/v0_1` endpoint.
- `--sync.l1-poll-interval` CLI option has been added to set the poll interval for L1 state. Defaults to 30s.

## [0.14.1] - 2024-07-29

Expand Down
10 changes: 10 additions & 0 deletions crates/pathfinder/src/bin/pathfinder/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,14 @@ Examples:
)]
poll_interval: std::num::NonZeroU64,

#[arg(
long = "sync.l1-poll-interval",
long_help = "L1 state poll interval in seconds",
default_value = "30",
env = "PATHFINDER_L1_POLL_INTERVAL_SECONDS"
)]
l1_poll_interval: std::num::NonZeroU64,

#[arg(
long = "color",
long_help = "This flag controls when to use colors in the output logs.",
Expand Down Expand Up @@ -669,6 +677,7 @@ pub struct Config {
pub sqlite_wal: JournalMode,
pub max_rpc_connections: std::num::NonZeroUsize,
pub poll_interval: std::time::Duration,
pub l1_poll_interval: std::time::Duration,
pub color: Color,
pub p2p: P2PConfig,
pub debug: DebugConfig,
Expand Down Expand Up @@ -953,6 +962,7 @@ impl Config {
},
max_rpc_connections: cli.max_rpc_connections,
poll_interval: Duration::from_secs(cli.poll_interval.get()),
l1_poll_interval: Duration::from_secs(cli.l1_poll_interval.get()),
color: cli.color,
p2p: P2PConfig::parse_or_exit(cli.p2p),
debug: DebugConfig::parse(cli.debug),
Expand Down
2 changes: 2 additions & 0 deletions crates/pathfinder/src/bin/pathfinder/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,7 @@ fn start_sync(
gossiper: state::Gossiper,
gateway_public_key: pathfinder_common::PublicKey,
_p2p_client: Option<p2p::client::peer_agnostic::Client>,
_verify_tree_hashes: bool,
) -> tokio::task::JoinHandle<anyhow::Result<()>> {
start_feeder_gateway_sync(
storage,
Expand Down Expand Up @@ -573,6 +574,7 @@ fn start_feeder_gateway_sync(
sequencer: pathfinder_context.gateway,
state: sync_state.clone(),
head_poll_interval: config.poll_interval,
l1_poll_interval: config.l1_poll_interval,
pending_data: tx_pending,
block_validation_mode: state::l2::BlockValidationMode::Strict,
websocket_txs,
Expand Down
4 changes: 3 additions & 1 deletion crates/pathfinder/src/state/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ pub struct SyncContext<G, E> {
pub sequencer: G,
pub state: Arc<SyncState>,
pub head_poll_interval: Duration,
pub l1_poll_interval: Duration,
pub pending_data: WatchSender<PendingData>,
pub block_validation_mode: l2::BlockValidationMode,
pub websocket_txs: Option<TopicBroadcasters>,
Expand All @@ -97,7 +98,7 @@ where
ethereum: value.ethereum.clone(),
chain: value.chain,
core_address: value.core_address,
poll_interval: value.head_poll_interval,
poll_interval: value.l1_poll_interval,
}
}
}
Expand Down Expand Up @@ -183,6 +184,7 @@ where
sequencer,
state,
head_poll_interval,
l1_poll_interval: _,
pending_data,
block_validation_mode: _,
websocket_txs,
Expand Down

0 comments on commit 412267f

Please sign in to comment.