diff --git a/Cargo.lock b/Cargo.lock index 90a5373dbb5..19ffb85d3d3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2669,6 +2669,15 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6999dc1837253364c2ebb0704ba97994bd874e8f195d665c50b7548f6ea92764" +[[package]] +name = "fdlimit" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c4c9e43643f5a3be4ca5b67d26b98031ff9db6806c3440ae32e02e3ceac3f1b" +dependencies = [ + "libc", +] + [[package]] name = "ff" version = "0.12.1" @@ -8485,6 +8494,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 46f523c9905..d5dc93487c0 100644 --- a/validator_client/Cargo.toml +++ b/validator_client/Cargo.toml @@ -62,3 +62,4 @@ malloc_utils = { workspace = true } sysinfo = { workspace = true } system_health = { path = "../common/system_health" } logging = { workspace = true } +fdlimit = "0.2.1" diff --git a/validator_client/src/lib.rs b/validator_client/src/lib.rs index 6925e285fc5..13e821c47f1 100644 --- a/validator_client/src/lib.rs +++ b/validator_client/src/lib.rs @@ -46,7 +46,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; @@ -120,6 +120,18 @@ 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 + if let Some(limit) = fdlimit::raise_fd_limit() { + debug!( + log, + "Raised soft open file descriptor resource limit"; + "new_limit" => limit + ); + } + info!( log, "Starting validator client";