From 47671b246d8e53f88bbaf090b5b060e2f93c499b Mon Sep 17 00:00:00 2001 From: Roman Krasiuk Date: Fri, 19 Jan 2024 12:31:28 +0100 Subject: [PATCH 1/2] fix(validator_client): raise soft fd limit --- Cargo.lock | 13 ++++++++++++- validator_client/Cargo.toml | 1 + validator_client/src/lib.rs | 23 ++++++++++++++++++++++- 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7874e1ec3dd..22d022826be 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2659,6 +2659,16 @@ version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" +[[package]] +name = "fdlimit" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e182f7dbc2ef73d9ef67351c5fbbea084729c48362d3ce9dd44c28e32e277fe5" +dependencies = [ + "libc", + "thiserror", +] + [[package]] name = "ff" version = "0.12.1" @@ -3506,7 +3516,7 @@ dependencies = [ "httpdate", "itoa", "pin-project-lite", - "socket2 0.4.10", + "socket2 0.5.5", "tokio", "tower-service", "tracing", @@ -8575,6 +8585,7 @@ dependencies = [ "eth2_keystore", "ethereum_serde_utils", "exit-future", + "fdlimit", "filesystem", "futures", "hex", diff --git a/validator_client/Cargo.toml b/validator_client/Cargo.toml index 90a82b7e3b2..7e5f09cf408 100644 --- a/validator_client/Cargo.toml +++ b/validator_client/Cargo.toml @@ -62,3 +62,4 @@ sysinfo = { workspace = true } system_health = { path = "../common/system_health" } logging = { workspace = true } strum = { workspace = true } +fdlimit = "0.3.0" diff --git a/validator_client/src/lib.rs b/validator_client/src/lib.rs index 89fc0376215..3f9fafcfdd7 100644 --- a/validator_client/src/lib.rs +++ b/validator_client/src/lib.rs @@ -47,7 +47,7 @@ use notifier::spawn_notifier; use parking_lot::RwLock; use preparation_service::{PreparationService, PreparationServiceBuilder}; use reqwest::Certificate; -use slog::{error, info, warn, Logger}; +use slog::{debug, error, info, warn, Logger}; use slot_clock::SlotClock; use slot_clock::SystemTimeSlotClock; use std::fs::File; @@ -121,6 +121,27 @@ impl ProductionValidatorClient { pub async fn new(context: RuntimeContext, config: Config) -> Result { let log = context.log().clone(); + // Attempt to raise soft fd limit. The behavior is OS specific: + // `linux` - raise soft fd limit to hard + // `macos` - raise soft fd limit to `min(kernel limit, hard fd limit)` + // `windows` & rest - noop + match fdlimit::raise_fd_limit().map_err(|e| format!("Unable to raise fd limit: {}", e))? { + fdlimit::Outcome::LimitRaised { from, to } => { + debug!( + log, + "Raised soft open file descriptor resource limit"; + "old_limit" => from, + "new_limit" => to + ); + } + fdlimit::Outcome::Unsupported => { + debug!( + log, + "Raising soft open file descriptor resource limit is not supported" + ); + } + }; + info!( log, "Starting validator client"; From 60add2a4c1a0ed62710f3fd88229a87318dafb64 Mon Sep 17 00:00:00 2001 From: realbigsean Date: Mon, 29 Apr 2024 15:10:29 -0400 Subject: [PATCH 2/2] cargo lock --- Cargo.lock | 1 + 1 file changed, 1 insertion(+) diff --git a/Cargo.lock b/Cargo.lock index 49d95abe72f..85c89528d0c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8998,6 +8998,7 @@ dependencies = [ "eth2", "eth2_keystore", "ethereum_serde_utils", + "fdlimit", "filesystem", "futures", "hex",