From 018e66ed28d1d5368cef371ea8116dd942a2b026 Mon Sep 17 00:00:00 2001 From: tesol2y090 Date: Sun, 18 Feb 2024 23:47:42 +0700 Subject: [PATCH 1/6] add dynamic timeout on rpc call --- src/meta.rs | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/meta.rs b/src/meta.rs index d773762..9f75cf9 100644 --- a/src/meta.rs +++ b/src/meta.rs @@ -6,6 +6,15 @@ use crate::{ use eth2::types::EthSpec; use std::time::Duration; +const STANDARD_TIMEOUT_MILLIS: u64 = 15_000; + +/// Timeout when doing a eth_blockNumber call. +const BLOCK_NUMBER_TIMEOUT_MILLIS: u64 = STANDARD_TIMEOUT_MILLIS; +/// Timeout when doing an eth_getBlockByNumber call. +const GET_BLOCK_TIMEOUT_MILLIS: u64 = STANDARD_TIMEOUT_MILLIS; +/// Timeout when doing an eth_getLogs to read the deposit contract logs. +const GET_DEPOSIT_LOG_TIMEOUT_MILLIS: u64 = 60_000; + impl Multiplexer { pub async fn handle_syncing(&self, request: Request) -> Result { // TODO: actually check EL status, maybe with a cache @@ -16,8 +25,7 @@ impl Multiplexer { pub async fn handle_chain_id(&self, request: Request) -> Result { let (id, _) = request.parse_as::>()?; - // TODO: dynamic timeout - let timeout = Duration::from_secs(1); + let timeout = Duration::from_millis(STANDARD_TIMEOUT_MILLIS); let chain_id = self .engine .api @@ -48,8 +56,12 @@ impl Multiplexer { pub async fn proxy_directly(&self, request: Request) -> Result { let id = request.id; - // TODO: adjust timeout - let timeout = Duration::from_secs(12); + let timeout = match request.method.as_str() { + "eth_getBlockByNumber" => Duration::from_millis(GET_BLOCK_TIMEOUT_MILLIS), + "eth_blockNumber" => Duration::from_millis(BLOCK_NUMBER_TIMEOUT_MILLIS), + "eth_getLogs" => Duration::from_millis(GET_DEPOSIT_LOG_TIMEOUT_MILLIS), + _ => Duration::from_millis(STANDARD_TIMEOUT_MILLIS), + }; let result: JsonValue = self .engine From 9931185cd7286a3d2570e7072df813bf3b712968 Mon Sep 17 00:00:00 2001 From: tesol2y090 Date: Tue, 20 Feb 2024 22:47:30 +0700 Subject: [PATCH 2/6] add ee timeout in config --- src/config.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/config.rs b/src/config.rs index 8c33863..b886a45 100644 --- a/src/config.rs +++ b/src/config.rs @@ -79,6 +79,9 @@ pub struct Config { /// Maximum size of JSON-RPC message to accept from any connected consensus node. #[arg(long, value_name = "MEGABYTES", default_value = "128")] pub body_limit_mb: usize, + /// Maximum timeout that need to wait for a response from the execution + #[arg(long, value_name = "MILLIS", default_value = "15000")] + pub ee_timeout_millis: u64, } #[derive(Deserialize, Serialize)] From d4835198329e84d907214f54340f90149c4661cb Mon Sep 17 00:00:00 2001 From: tesol2y090 Date: Tue, 20 Feb 2024 22:48:28 +0700 Subject: [PATCH 3/6] use ee timeout in ee request --- src/meta.rs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/meta.rs b/src/meta.rs index 9f75cf9..74d1c8b 100644 --- a/src/meta.rs +++ b/src/meta.rs @@ -25,7 +25,7 @@ impl Multiplexer { pub async fn handle_chain_id(&self, request: Request) -> Result { let (id, _) = request.parse_as::>()?; - let timeout = Duration::from_millis(STANDARD_TIMEOUT_MILLIS); + let timeout = Duration::from_millis(self.config.ee_timeout_millis); let chain_id = self .engine .api @@ -55,13 +55,7 @@ impl Multiplexer { pub async fn proxy_directly(&self, request: Request) -> Result { let id = request.id; - - let timeout = match request.method.as_str() { - "eth_getBlockByNumber" => Duration::from_millis(GET_BLOCK_TIMEOUT_MILLIS), - "eth_blockNumber" => Duration::from_millis(BLOCK_NUMBER_TIMEOUT_MILLIS), - "eth_getLogs" => Duration::from_millis(GET_DEPOSIT_LOG_TIMEOUT_MILLIS), - _ => Duration::from_millis(STANDARD_TIMEOUT_MILLIS), - }; + let timeout = Duration::from_millis(self.config.ee_timeout_millis); let result: JsonValue = self .engine From 23f242aaf50a796c1731032ee53e6010043743ab Mon Sep 17 00:00:00 2001 From: tesol2y090 Date: Tue, 20 Feb 2024 22:51:49 +0700 Subject: [PATCH 4/6] update docs --- docs/cli-reference.md | 43 ++++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/docs/cli-reference.md b/docs/cli-reference.md index bfba2ec..500a49f 100644 --- a/docs/cli-reference.md +++ b/docs/cli-reference.md @@ -6,17 +6,17 @@ Usage: eleel [OPTIONS] --ee-jwt-secret --controller-jwt-secret --c Options: --listen-address Listening address for the HTTP server - + [default: 127.0.0.1] --listen-port Listening port for the HTTP server - + [default: 8552] --ee-url Primary execution engine to be shared by connected consensus nodes - + [default: http://localhost:8551] --ee-jwt-secret @@ -27,42 +27,42 @@ Options: --client-jwt-secrets Path to TOML file of JWT secrets for the non-controlling consensus clients. - + See docs for TOML file format. --new-payload-cache-size Number of recent newPayload messages to cache in memory - + [default: 64] --fcu-cache-size Number of recent forkchoiceUpdated messages to cache in memory - + [default: 64] --payload-builder-cache-size Number of payload attributes and past payloads to cache in memory - + [default: 8] --payload-builder-extra-data Extra data to include in produced blocks - + [default: Eleel] --justified-block-cache-size Number of justified block hashes to cache in memory - + [default: 4] --finalized-block-cache-size Number of finalized block hashes to cache in memory - + [default: 4] --fcu-matching Choose the type of matching to use before returning a VALID fcU message to a client - + [default: loose] Possible values: @@ -72,35 +72,40 @@ Options: --network Network that the consensus and execution nodes are operating on - + [default: mainnet] --new-payload-wait-millis Maximum time that a consensus node should wait for a newPayload response from the cache. - + We expect that the controlling consensus node and primary execution node will take some time to process requests, and that requests from consensus nodes could arrive while this processing is on-going. Using a timeout of 0 will often result in a SYNCING response, which will put the consensus node into optimistic sync. Using a longer timeout will allow the definitive (VALID) response from the execution engine to be returned, more closely matching the behaviour of a full execution engine. - + [default: 2000] --new-payload-wait-cutoff Maximum age of a payload that will trigger a wait on `newPayload` - + Payloads older than this age receive an instant SYNCING response. See docs for `--new-payload-wait-millis` for the purpose of this wait. - + [default: 64] --fcu-wait-millis Maximum time that a consensus node should wait for a forkchoiceUpdated response from the cache. - + See the docs for `--new-payload-wait-millis` for the purpose of this timeout. - + [default: 1000] --body-limit-mb Maximum size of JSON-RPC message to accept from any connected consensus node - + [default: 128] + --ee_timeout_millis + Maximum timeout that need to wait for a response from the execution + + [default: 15000] + -h, --help Print help (see a summary with '-h') ``` From 8a90e839d7b942159fcf1387bc07ad51831de704 Mon Sep 17 00:00:00 2001 From: tesol2y090 Date: Tue, 20 Feb 2024 22:54:13 +0700 Subject: [PATCH 5/6] delete unused variable --- src/meta.rs | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/meta.rs b/src/meta.rs index 74d1c8b..1f9d264 100644 --- a/src/meta.rs +++ b/src/meta.rs @@ -6,15 +6,6 @@ use crate::{ use eth2::types::EthSpec; use std::time::Duration; -const STANDARD_TIMEOUT_MILLIS: u64 = 15_000; - -/// Timeout when doing a eth_blockNumber call. -const BLOCK_NUMBER_TIMEOUT_MILLIS: u64 = STANDARD_TIMEOUT_MILLIS; -/// Timeout when doing an eth_getBlockByNumber call. -const GET_BLOCK_TIMEOUT_MILLIS: u64 = STANDARD_TIMEOUT_MILLIS; -/// Timeout when doing an eth_getLogs to read the deposit contract logs. -const GET_DEPOSIT_LOG_TIMEOUT_MILLIS: u64 = 60_000; - impl Multiplexer { pub async fn handle_syncing(&self, request: Request) -> Result { // TODO: actually check EL status, maybe with a cache From a238a8efe478859605480516e9a5bb7ed7591fd7 Mon Sep 17 00:00:00 2001 From: tesol2y090 Date: Wed, 21 Feb 2024 21:58:21 +0700 Subject: [PATCH 6/6] fix docs --- docs/cli-reference.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/cli-reference.md b/docs/cli-reference.md index 500a49f..b29cdb3 100644 --- a/docs/cli-reference.md +++ b/docs/cli-reference.md @@ -101,7 +101,7 @@ Options: [default: 128] - --ee_timeout_millis + --ee-timeout-millis Maximum timeout that need to wait for a response from the execution [default: 15000]