Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge queue: embarking unstable (f35213e) and [#6958 + #6808] together #6963

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions beacon_node/lighthouse_network/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ hex = { workspace = true }
itertools = { workspace = true }
libp2p-mplex = "0.43"
lighthouse_version = { workspace = true }
local-ip-address = "0.6"
lru = { workspace = true }
lru_cache = { workspace = true }
metrics = { workspace = true }
Expand Down
13 changes: 13 additions & 0 deletions beacon_node/lighthouse_network/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use directory::{
DEFAULT_BEACON_NODE_DIR, DEFAULT_HARDCODED_NETWORK, DEFAULT_NETWORK_DIR, DEFAULT_ROOT_DIR,
};
use libp2p::Multiaddr;
use local_ip_address::local_ipv6;
use serde::{Deserialize, Serialize};
use sha2::{Digest, Sha256};
use std::net::{Ipv4Addr, Ipv6Addr};
Expand Down Expand Up @@ -266,6 +267,18 @@ impl Config {
}
}

/// A helper function to check if the local host has a globally routeable IPv6 address. If so,
/// returns true.
pub fn is_ipv6_supported() -> bool {
// If IPv6 is supported
let Ok(std::net::IpAddr::V6(local_ip)) = local_ipv6() else {
return false;
};

// If its globally routable, return true
is_global_ipv6(&local_ip)
}

pub fn listen_addrs(&self) -> &ListenAddress {
&self.listen_addresses
}
Expand Down
6 changes: 3 additions & 3 deletions beacon_node/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,16 +147,16 @@ pub fn cli_app() -> Command {
.long("listen-address")
.value_name("ADDRESS")
.help("The address lighthouse will listen for UDP and TCP connections. To listen \
over IpV4 and IpV6 set this flag twice with the different values.\n\
over IPv4 and IPv6 set this flag twice with the different values.\n\
Examples:\n\
- --listen-address '0.0.0.0' will listen over IPv4.\n\
- --listen-address '::' will listen over IPv6.\n\
- --listen-address '0.0.0.0' --listen-address '::' will listen over both \
IPv4 and IPv6. The order of the given addresses is not relevant. However, \
multiple IPv4, or multiple IPv6 addresses will not be accepted.")
multiple IPv4, or multiple IPv6 addresses will not be accepted. \
If omitted, Lighthouse will listen on all interfaces, for both IPv4 and IPv6.")
.action(ArgAction::Append)
.num_args(0..=2)
.default_value("0.0.0.0")
.display_order(0)
)
.arg(
Expand Down
26 changes: 19 additions & 7 deletions beacon_node/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -905,12 +905,13 @@ pub fn parse_listening_addresses(
) -> Result<ListenAddress, String> {
let listen_addresses_str = cli_args
.get_many::<String>("listen-address")
.expect("--listen_addresses has a default value");
.unwrap_or_default();
let use_zero_ports = parse_flag(cli_args, "zero-ports");

// parse the possible ips
let mut maybe_ipv4 = None;
let mut maybe_ipv6 = None;

for addr_str in listen_addresses_str {
let addr = addr_str.parse::<IpAddr>().map_err(|parse_error| {
format!("Failed to parse listen-address ({addr_str}) as an Ip address: {parse_error}")
Expand All @@ -920,17 +921,17 @@ pub fn parse_listening_addresses(
IpAddr::V4(v4_addr) => match &maybe_ipv4 {
Some(first_ipv4_addr) => {
return Err(format!(
"When setting the --listen-address option twice, use an IpV4 address and an Ipv6 address. \
Got two IpV4 addresses {first_ipv4_addr} and {v4_addr}"
"When setting the --listen-address option twice, use an IPv4 address and an IPv6 address. \
Got two IPv4 addresses {first_ipv4_addr} and {v4_addr}"
));
}
None => maybe_ipv4 = Some(v4_addr),
},
IpAddr::V6(v6_addr) => match &maybe_ipv6 {
Some(first_ipv6_addr) => {
return Err(format!(
"When setting the --listen-address option twice, use an IpV4 address and an Ipv6 address. \
Got two IpV6 addresses {first_ipv6_addr} and {v6_addr}"
"When setting the --listen-address option twice, use an IPv4 address and an IPv6 address. \
Got two IPv6 addresses {first_ipv6_addr} and {v6_addr}"
));
}
None => maybe_ipv6 = Some(v6_addr),
Expand Down Expand Up @@ -984,11 +985,22 @@ pub fn parse_listening_addresses(
format!("Failed to parse --quic6-port as an integer: {parse_error}")
})?;

// Here we specify the default listening addresses for Lighthouse.
// By default, we listen on 0.0.0.0.
//
// IF the host supports a globally routable IPv6 address, we also listen on ::.
if matches!((maybe_ipv4, maybe_ipv6), (None, None)) {
maybe_ipv4 = Some(Ipv4Addr::UNSPECIFIED);

if NetworkConfig::is_ipv6_supported() {
maybe_ipv6 = Some(Ipv6Addr::UNSPECIFIED);
}
}

// Now put everything together
let listening_addresses = match (maybe_ipv4, maybe_ipv6) {
(None, None) => {
// This should never happen unless clap is broken
return Err("No listening addresses provided".into());
unreachable!("This path is handled above this match statement");
}
(None, Some(ipv6)) => {
// A single ipv6 address was provided. Set the ports
Expand Down
5 changes: 3 additions & 2 deletions book/src/help_bn.md
Original file line number Diff line number Diff line change
Expand Up @@ -230,15 +230,16 @@ Options:
peer without an ENR.
--listen-address [<ADDRESS>...]
The address lighthouse will listen for UDP and TCP connections. To
listen over IpV4 and IpV6 set this flag twice with the different
listen over IPv4 and IPv6 set this flag twice with the different
values.
Examples:
- --listen-address '0.0.0.0' will listen over IPv4.
- --listen-address '::' will listen over IPv6.
- --listen-address '0.0.0.0' --listen-address '::' will listen over
both IPv4 and IPv6. The order of the given addresses is not relevant.
However, multiple IPv4, or multiple IPv6 addresses will not be
accepted. [default: 0.0.0.0]
accepted. If omitted, Lighthouse will listen on all interfaces, for
both IPv4 and IPv6.
--log-format <FORMAT>
Specifies the log format used when emitting logs to the terminal.
[possible values: JSON]
Expand Down
2 changes: 1 addition & 1 deletion testing/ef_tests/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
TESTS_TAG := v1.5.0-beta.1
TESTS_TAG := v1.5.0-beta.2
TESTS = general minimal mainnet
TARBALLS = $(patsubst %,%-$(TESTS_TAG).tar.gz,$(TESTS))

Expand Down
5 changes: 2 additions & 3 deletions testing/ef_tests/check_all_files_accessed.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,8 @@
"bls12-381-tests/hash_to_G2",
"tests/.*/eip6110",
"tests/.*/whisk",
# TODO(electra): SingleAttestation tests are waiting on Eitan's PR
"tests/.*/electra/ssz_static/SingleAttestation",
"tests/.*/fulu/ssz_static/SingleAttestation",
# TODO(das): Fulu tests are ignored for now
"tests/.*/fulu",
"tests/.*/fulu/ssz_static/MatrixEntry",
]

Expand Down
5 changes: 5 additions & 0 deletions testing/ef_tests/src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,11 @@ impl<E: EthSpec + TypeName> Handler for ForkChoiceHandler<E> {
return false;
}

// Deposit tests exist only after Electra.
if self.handler_name == "deposit_with_reorg" && !fork_name.electra_enabled() {
return false;
}

// These tests check block validity (which may include signatures) and there is no need to
// run them with fake crypto.
cfg!(not(feature = "fake_crypto"))
Expand Down
1 change: 1 addition & 0 deletions testing/ef_tests/src/type_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ type_name!(SignedBeaconBlockHeader);
type_name_generic!(SignedContributionAndProof);
type_name!(SignedVoluntaryExit);
type_name!(SigningData);
type_name!(SingleAttestation);
type_name_generic!(SyncCommitteeContribution);
type_name!(SyncCommitteeMessage);
type_name!(SyncAggregatorSelectionData);
Expand Down
12 changes: 12 additions & 0 deletions testing/ef_tests/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,12 @@ mod ssz_static {
.run();
}

#[test]
fn single_attestation() {
SszStaticHandler::<SingleAttestation, MinimalEthSpec>::electra_and_later().run();
SszStaticHandler::<SingleAttestation, MainnetEthSpec>::electra_and_later().run();
}

#[test]
fn attester_slashing() {
SszStaticHandler::<AttesterSlashingBase<MinimalEthSpec>, MinimalEthSpec>::pre_electra()
Expand Down Expand Up @@ -880,6 +886,12 @@ fn fork_choice_get_proposer_head() {
ForkChoiceHandler::<MainnetEthSpec>::new("get_proposer_head").run();
}

#[test]
fn fork_choice_deposit_with_reorg() {
ForkChoiceHandler::<MinimalEthSpec>::new("deposit_with_reorg").run();
// There is no mainnet variant for this test.
}

#[test]
fn optimistic_sync() {
OptimisticSyncHandler::<MinimalEthSpec>::default().run();
Expand Down