From bb05b166103c4863cbda23dc0f517159f95d1081 Mon Sep 17 00:00:00 2001 From: Stanislav Bezkorovainyi Date: Thu, 25 Mar 2021 08:03:56 +0200 Subject: [PATCH] Custom polling interval for forced exit requests --- core/bin/zksync_forced_exit_requests/src/eth_watch.rs | 2 +- core/lib/config/src/configs/forced_exit_requests.rs | 9 +++++++++ etc/env/base/forced_exit_requests.toml | 3 +++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/core/bin/zksync_forced_exit_requests/src/eth_watch.rs b/core/bin/zksync_forced_exit_requests/src/eth_watch.rs index 4cbc192e25..fd8259ff48 100644 --- a/core/bin/zksync_forced_exit_requests/src/eth_watch.rs +++ b/core/bin/zksync_forced_exit_requests/src/eth_watch.rs @@ -370,7 +370,7 @@ where .await .expect("Failed to restore state for ForcedExit eth_watcher"); - let mut timer = time::interval(Duration::from_secs(1)); + let mut timer = time::interval(self.config.forced_exit_requests.poll_interval()); loop { timer.tick().await; diff --git a/core/lib/config/src/configs/forced_exit_requests.rs b/core/lib/config/src/configs/forced_exit_requests.rs index 8a772c3ac9..92c5051354 100644 --- a/core/lib/config/src/configs/forced_exit_requests.rs +++ b/core/lib/config/src/configs/forced_exit_requests.rs @@ -1,3 +1,5 @@ +use std::time::Duration; + use crate::envy_load; /// External uses use serde::Deserialize; @@ -24,6 +26,7 @@ struct ForcedExitRequestsInternalConfig { pub sender_eth_private_key: H256, pub sender_account_address: Address, pub expiration_period: u64, + pub eth_node_poll_interval: u64, } #[derive(Debug, Deserialize, Clone, PartialEq)] @@ -39,6 +42,7 @@ pub struct ForcedExitRequestsConfig { pub sender_eth_private_key: H256, pub sender_account_address: Address, pub expiration_period: u64, + pub eth_node_poll_interval: u64, } // Checks that in no way the price will overlap with the requests id space @@ -79,6 +83,11 @@ impl ForcedExitRequestsConfig { sender_eth_private_key: config.sender_eth_private_key, sender_account_address: config.sender_account_address, expiration_period: config.expiration_period, + eth_node_poll_interval: config.eth_node_poll_interval, } } + + pub fn poll_interval(&self) -> Duration { + Duration::from_millis(self.eth_node_poll_interval) + } } diff --git a/etc/env/base/forced_exit_requests.toml b/etc/env/base/forced_exit_requests.toml index c0c6689955..e0494ef16c 100644 --- a/etc/env/base/forced_exit_requests.toml +++ b/etc/env/base/forced_exit_requests.toml @@ -36,3 +36,6 @@ withdrawal_threshold=1000000000000000000 # Here it is set for some random account for the purpose of testing, but usually it is preferred # to set the same account as the one that sends the txs for retrieving the fees from the smart contract fee_receiver="0x1963917ba0b44A879cf6248387C1d51A0F11669d" + +# How often we want to poll the Ethereum node (in milliseconds). +eth_node_poll_interval=300