From d351cc8d8d138a93c6c0b28b1bc128325ce9c662 Mon Sep 17 00:00:00 2001 From: Jimmy Chen Date: Thu, 30 Mar 2023 06:08:38 +0000 Subject: [PATCH 1/3] Test failing CI tests due to port conflicts (#4134) ## Issue Addressed #4127. PR to test port conflicts in CI tests . ## Proposed Changes See issue for more details, potential solution could be adding a cache bound by time to the `unused_port` function. --- Cargo.lock | 5 +++++ common/unused_port/Cargo.toml | 3 +++ common/unused_port/src/lib.rs | 27 ++++++++++++++++++++++++++- 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index c7cdf212b..214f3baa3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8546,6 +8546,11 @@ checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" [[package]] name = "unused_port" version = "0.1.0" +dependencies = [ + "lazy_static", + "lru_cache", + "parking_lot 0.12.1", +] [[package]] name = "url" diff --git a/common/unused_port/Cargo.toml b/common/unused_port/Cargo.toml index 06c1ca8f5..2dd041ff0 100644 --- a/common/unused_port/Cargo.toml +++ b/common/unused_port/Cargo.toml @@ -6,3 +6,6 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +lru_cache = { path = "../lru_cache" } +lazy_static = "1.4.0" +parking_lot = "0.12.0" diff --git a/common/unused_port/src/lib.rs b/common/unused_port/src/lib.rs index a5d081721..386f08a73 100644 --- a/common/unused_port/src/lib.rs +++ b/common/unused_port/src/lib.rs @@ -1,4 +1,8 @@ -use std::net::{TcpListener, UdpSocket}; +use lazy_static::lazy_static; +use lru_cache::LRUTimeCache; +use parking_lot::Mutex; +use std::net::{SocketAddr, TcpListener, UdpSocket}; +use std::time::Duration; #[derive(Copy, Clone)] pub enum Transport { @@ -12,6 +16,13 @@ pub enum IpVersion { Ipv6, } +pub const CACHED_PORTS_TTL: Duration = Duration::from_secs(300); + +lazy_static! { + static ref FOUND_PORTS_CACHE: Mutex> = + Mutex::new(LRUTimeCache::new(CACHED_PORTS_TTL)); +} + /// A convenience wrapper over [`zero_port`]. pub fn unused_tcp4_port() -> Result { zero_port(Transport::Tcp, IpVersion::Ipv4) @@ -48,6 +59,20 @@ pub fn zero_port(transport: Transport, ipv: IpVersion) -> Result { IpVersion::Ipv6 => std::net::Ipv6Addr::LOCALHOST.into(), }; let socket_addr = std::net::SocketAddr::new(localhost, 0); + let mut unused_port: u16; + loop { + unused_port = find_unused_port(transport, socket_addr)?; + let mut cache_lock = FOUND_PORTS_CACHE.lock(); + if !cache_lock.contains(&unused_port) { + cache_lock.insert(unused_port); + break; + } + } + + Ok(unused_port) +} + +fn find_unused_port(transport: Transport, socket_addr: SocketAddr) -> Result { let local_addr = match transport { Transport::Tcp => { let listener = TcpListener::bind(socket_addr).map_err(|e| { From 56911231538da05248d3672bef5d772ab987fc8b Mon Sep 17 00:00:00 2001 From: int88 Date: Thu, 30 Mar 2023 10:14:07 +0000 Subject: [PATCH 2/3] update README of local_testnet (#4114) ## Issue Addressed NA ## Proposed Changes update the descriptions of README in `scripts/local_testnet`. ## Additional Info NA --- scripts/local_testnet/README.md | 2 +- scripts/local_testnet/start_local_testnet.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/local_testnet/README.md b/scripts/local_testnet/README.md index c9fb38768..c4050ac93 100644 --- a/scripts/local_testnet/README.md +++ b/scripts/local_testnet/README.md @@ -20,7 +20,7 @@ Modify `vars.env` as desired. Start a local eth1 ganache server plus boot node along with `BN_COUNT` number of beacon nodes and `VC_COUNT` validator clients. -The `start_local_testnet.sh` script takes three options `-v VC_COUNT`, `-d DEBUG_LEVEL` and `-h` for help. +The `start_local_testnet.sh` script takes four options `-v VC_COUNT`, `-d DEBUG_LEVEL`, `-p` to enable builder proposals and `-h` for help. The options may be in any order or absent in which case they take the default value specified. - VC_COUNT: the number of validator clients to create, default: `BN_COUNT` - DEBUG_LEVEL: one of { error, warn, info, debug, trace }, default: `info` diff --git a/scripts/local_testnet/start_local_testnet.sh b/scripts/local_testnet/start_local_testnet.sh index dcc0a5382..e3aba5c3a 100755 --- a/scripts/local_testnet/start_local_testnet.sh +++ b/scripts/local_testnet/start_local_testnet.sh @@ -28,7 +28,7 @@ while getopts "v:d:ph" flag; do echo "Options:" echo " -v: VC_COUNT default: $VC_COUNT" echo " -d: DEBUG_LEVEL default: info" - echo " -p: enable private tx proposals" + echo " -p: enable builder proposals" echo " -h: this help" exit ;; From c5383e393acee152e92641ce4699d05913953e70 Mon Sep 17 00:00:00 2001 From: chonghe Date: Fri, 31 Mar 2023 05:00:50 +0000 Subject: [PATCH 3/3] Update database-migrations.md (#4149) ## Issue Addressed Update the database-migrations to include v4.0.1 for database version v16: ## Proposed Changes Update the table by adding a row ## Additional Info Please provide any additional information. For example, future considerations or information useful for reviewers. --- book/src/database-migrations.md | 1 + 1 file changed, 1 insertion(+) diff --git a/book/src/database-migrations.md b/book/src/database-migrations.md index ef7e95cc7..d2b7b518d 100644 --- a/book/src/database-migrations.md +++ b/book/src/database-migrations.md @@ -28,6 +28,7 @@ validator client or the slasher**. | v3.3.0 | Nov 2022 | v13 | yes | | v3.4.0 | Jan 2023 | v13 | yes | | v3.5.0 | Feb 2023 | v15 | yes before Capella | +| v4.0.1 | Mar 2023 | v16 | yes before Capella | > **Note**: All point releases (e.g. v2.3.1) are schema-compatible with the prior minor release > (e.g. v2.3.0).