mirror of
https://gitlab.com/pulsechaincom/lighthouse-pulse.git
synced 2024-12-22 11:41:28 +00:00
Merge commit 'c5383e393acee152e92641ce4699d05913953e70' into eip4844
This commit is contained in:
commit
9558c18dc5
5
Cargo.lock
generated
5
Cargo.lock
generated
@ -8582,6 +8582,11 @@ checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a"
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "unused_port"
|
name = "unused_port"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"lazy_static",
|
||||||
|
"lru_cache",
|
||||||
|
"parking_lot 0.12.1",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "url"
|
name = "url"
|
||||||
|
@ -28,6 +28,7 @@ validator client or the slasher**.
|
|||||||
| v3.3.0 | Nov 2022 | v13 | yes |
|
| v3.3.0 | Nov 2022 | v13 | yes |
|
||||||
| v3.4.0 | Jan 2023 | v13 | yes |
|
| v3.4.0 | Jan 2023 | v13 | yes |
|
||||||
| v3.5.0 | Feb 2023 | v15 | yes before Capella |
|
| 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
|
> **Note**: All point releases (e.g. v2.3.1) are schema-compatible with the prior minor release
|
||||||
> (e.g. v2.3.0).
|
> (e.g. v2.3.0).
|
||||||
|
@ -6,3 +6,6 @@ edition = "2021"
|
|||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
lru_cache = { path = "../lru_cache" }
|
||||||
|
lazy_static = "1.4.0"
|
||||||
|
parking_lot = "0.12.0"
|
||||||
|
@ -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)]
|
#[derive(Copy, Clone)]
|
||||||
pub enum Transport {
|
pub enum Transport {
|
||||||
@ -12,6 +16,13 @@ pub enum IpVersion {
|
|||||||
Ipv6,
|
Ipv6,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub const CACHED_PORTS_TTL: Duration = Duration::from_secs(300);
|
||||||
|
|
||||||
|
lazy_static! {
|
||||||
|
static ref FOUND_PORTS_CACHE: Mutex<LRUTimeCache<u16>> =
|
||||||
|
Mutex::new(LRUTimeCache::new(CACHED_PORTS_TTL));
|
||||||
|
}
|
||||||
|
|
||||||
/// A convenience wrapper over [`zero_port`].
|
/// A convenience wrapper over [`zero_port`].
|
||||||
pub fn unused_tcp4_port() -> Result<u16, String> {
|
pub fn unused_tcp4_port() -> Result<u16, String> {
|
||||||
zero_port(Transport::Tcp, IpVersion::Ipv4)
|
zero_port(Transport::Tcp, IpVersion::Ipv4)
|
||||||
@ -48,6 +59,20 @@ pub fn zero_port(transport: Transport, ipv: IpVersion) -> Result<u16, String> {
|
|||||||
IpVersion::Ipv6 => std::net::Ipv6Addr::LOCALHOST.into(),
|
IpVersion::Ipv6 => std::net::Ipv6Addr::LOCALHOST.into(),
|
||||||
};
|
};
|
||||||
let socket_addr = std::net::SocketAddr::new(localhost, 0);
|
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<u16, String> {
|
||||||
let local_addr = match transport {
|
let local_addr = match transport {
|
||||||
Transport::Tcp => {
|
Transport::Tcp => {
|
||||||
let listener = TcpListener::bind(socket_addr).map_err(|e| {
|
let listener = TcpListener::bind(socket_addr).map_err(|e| {
|
||||||
|
@ -20,7 +20,7 @@ Modify `vars.env` as desired.
|
|||||||
Start a local eth1 ganache server plus boot node along with `BN_COUNT`
|
Start a local eth1 ganache server plus boot node along with `BN_COUNT`
|
||||||
number of beacon nodes and `VC_COUNT` validator clients.
|
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.
|
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`
|
- VC_COUNT: the number of validator clients to create, default: `BN_COUNT`
|
||||||
- DEBUG_LEVEL: one of { error, warn, info, debug, trace }, default: `info`
|
- DEBUG_LEVEL: one of { error, warn, info, debug, trace }, default: `info`
|
||||||
|
@ -28,7 +28,7 @@ while getopts "v:d:ph" flag; do
|
|||||||
echo "Options:"
|
echo "Options:"
|
||||||
echo " -v: VC_COUNT default: $VC_COUNT"
|
echo " -v: VC_COUNT default: $VC_COUNT"
|
||||||
echo " -d: DEBUG_LEVEL default: info"
|
echo " -d: DEBUG_LEVEL default: info"
|
||||||
echo " -p: enable private tx proposals"
|
echo " -p: enable builder proposals"
|
||||||
echo " -h: this help"
|
echo " -h: this help"
|
||||||
exit
|
exit
|
||||||
;;
|
;;
|
||||||
|
Loading…
Reference in New Issue
Block a user