mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-09 11:41:51 +00:00
Final changes for fusaka-devnet-2 (#7655)
Closes #7467. This PR primarily addresses [the P2P changes](https://github.com/ethereum/EIPs/pull/9840) in [fusaka-devnet-2](https://fusaka-devnet-2.ethpandaops.io/). Specifically: * [the new `nfd` parameter added to the `ENR`](https://github.com/ethereum/EIPs/pull/9840) * [the modified `compute_fork_digest()` changes for every BPO fork](https://github.com/ethereum/EIPs/pull/9840) 90% of this PR was absolutely hacked together as fast as possible during the Berlinterop as fast as I could while running between Glamsterdam debates. Luckily, it seems to work. But I was unable to be as careful in avoiding bugs as I usually am. I've cleaned up the things *I remember* wanting to come back and have a closer look at. But still working on this. Progress: * [x] get it working on `fusaka-devnet-2` * [ ] [*optional* disconnect from peers with incorrect `nfd` at the fork boundary](https://github.com/ethereum/consensus-specs/pull/4407) - Can be addressed in a future PR if necessary * [x] first pass clean-up * [x] fix up all the broken tests * [x] final self-review * [x] more thorough review from people more familiar with affected code
This commit is contained in:
@@ -11,7 +11,7 @@ use tracing::{debug, error, info_span, Instrument};
|
||||
use tracing_subscriber::EnvFilter;
|
||||
use types::{
|
||||
ChainSpec, EnrForkId, Epoch, EthSpec, FixedBytesExtended, ForkContext, ForkName, Hash256,
|
||||
MinimalEthSpec, Slot,
|
||||
MinimalEthSpec,
|
||||
};
|
||||
|
||||
type E = MinimalEthSpec;
|
||||
@@ -19,33 +19,36 @@ type E = MinimalEthSpec;
|
||||
use lighthouse_network::rpc::config::InboundRateLimiterConfig;
|
||||
use tempfile::Builder as TempBuilder;
|
||||
|
||||
/// Returns a dummy fork context
|
||||
pub fn fork_context(fork_name: ForkName) -> ForkContext {
|
||||
/// Returns a chain spec with all forks enabled.
|
||||
pub fn spec_with_all_forks_enabled() -> ChainSpec {
|
||||
let mut chain_spec = E::default_spec();
|
||||
let altair_fork_epoch = Epoch::new(1);
|
||||
let bellatrix_fork_epoch = Epoch::new(2);
|
||||
let capella_fork_epoch = Epoch::new(3);
|
||||
let deneb_fork_epoch = Epoch::new(4);
|
||||
let electra_fork_epoch = Epoch::new(5);
|
||||
let fulu_fork_epoch = Epoch::new(6);
|
||||
chain_spec.altair_fork_epoch = Some(Epoch::new(1));
|
||||
chain_spec.bellatrix_fork_epoch = Some(Epoch::new(2));
|
||||
chain_spec.capella_fork_epoch = Some(Epoch::new(3));
|
||||
chain_spec.deneb_fork_epoch = Some(Epoch::new(4));
|
||||
chain_spec.electra_fork_epoch = Some(Epoch::new(5));
|
||||
chain_spec.fulu_fork_epoch = Some(Epoch::new(6));
|
||||
|
||||
chain_spec.altair_fork_epoch = Some(altair_fork_epoch);
|
||||
chain_spec.bellatrix_fork_epoch = Some(bellatrix_fork_epoch);
|
||||
chain_spec.capella_fork_epoch = Some(capella_fork_epoch);
|
||||
chain_spec.deneb_fork_epoch = Some(deneb_fork_epoch);
|
||||
chain_spec.electra_fork_epoch = Some(electra_fork_epoch);
|
||||
chain_spec.fulu_fork_epoch = Some(fulu_fork_epoch);
|
||||
// check that we have all forks covered
|
||||
assert!(chain_spec.fork_epoch(ForkName::latest()).is_some());
|
||||
chain_spec
|
||||
}
|
||||
|
||||
let current_slot = match fork_name {
|
||||
ForkName::Base => Slot::new(0),
|
||||
ForkName::Altair => altair_fork_epoch.start_slot(E::slots_per_epoch()),
|
||||
ForkName::Bellatrix => bellatrix_fork_epoch.start_slot(E::slots_per_epoch()),
|
||||
ForkName::Capella => capella_fork_epoch.start_slot(E::slots_per_epoch()),
|
||||
ForkName::Deneb => deneb_fork_epoch.start_slot(E::slots_per_epoch()),
|
||||
ForkName::Electra => electra_fork_epoch.start_slot(E::slots_per_epoch()),
|
||||
ForkName::Fulu => fulu_fork_epoch.start_slot(E::slots_per_epoch()),
|
||||
/// Returns a dummy fork context
|
||||
pub fn fork_context(fork_name: ForkName, spec: &ChainSpec) -> ForkContext {
|
||||
let current_epoch = match fork_name {
|
||||
ForkName::Base => Some(Epoch::new(0)),
|
||||
ForkName::Altair => spec.altair_fork_epoch,
|
||||
ForkName::Bellatrix => spec.bellatrix_fork_epoch,
|
||||
ForkName::Capella => spec.capella_fork_epoch,
|
||||
ForkName::Deneb => spec.deneb_fork_epoch,
|
||||
ForkName::Electra => spec.electra_fork_epoch,
|
||||
ForkName::Fulu => spec.fulu_fork_epoch,
|
||||
};
|
||||
ForkContext::new::<E>(current_slot, Hash256::zero(), &chain_spec)
|
||||
let current_slot = current_epoch
|
||||
.unwrap_or_else(|| panic!("expect fork {fork_name} to be scheduled"))
|
||||
.start_slot(E::slots_per_epoch());
|
||||
ForkContext::new::<E>(current_slot, Hash256::zero(), spec)
|
||||
}
|
||||
|
||||
pub struct Libp2pInstance(
|
||||
@@ -122,7 +125,7 @@ pub async fn build_libp2p_instance(
|
||||
let libp2p_context = lighthouse_network::Context {
|
||||
config,
|
||||
enr_fork_id: EnrForkId::default(),
|
||||
fork_context: Arc::new(fork_context(fork_name)),
|
||||
fork_context: Arc::new(fork_context(fork_name, &chain_spec)),
|
||||
chain_spec,
|
||||
libp2p_registry: None,
|
||||
};
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
mod common;
|
||||
|
||||
use crate::common::spec_with_all_forks_enabled;
|
||||
use common::{build_tracing_subscriber, Protocol};
|
||||
use lighthouse_network::rpc::{methods::*, RequestType};
|
||||
use lighthouse_network::service::api_types::AppRequestId;
|
||||
@@ -60,7 +61,7 @@ fn test_tcp_status_rpc() {
|
||||
|
||||
let rt = Arc::new(Runtime::new().unwrap());
|
||||
|
||||
let spec = Arc::new(E::default_spec());
|
||||
let spec = Arc::new(spec_with_all_forks_enabled());
|
||||
|
||||
rt.block_on(async {
|
||||
// get sender/receiver
|
||||
@@ -168,7 +169,7 @@ fn test_tcp_blocks_by_range_chunked_rpc() {
|
||||
|
||||
let rt = Arc::new(Runtime::new().unwrap());
|
||||
|
||||
let spec = Arc::new(E::default_spec());
|
||||
let spec = Arc::new(spec_with_all_forks_enabled());
|
||||
|
||||
rt.block_on(async {
|
||||
// get sender/receiver
|
||||
@@ -318,7 +319,7 @@ fn test_blobs_by_range_chunked_rpc() {
|
||||
|
||||
rt.block_on(async {
|
||||
// get sender/receiver
|
||||
let spec = Arc::new(E::default_spec());
|
||||
let spec = Arc::new(spec_with_all_forks_enabled());
|
||||
let (mut sender, mut receiver) = common::build_node_pair(
|
||||
Arc::downgrade(&rt),
|
||||
ForkName::Deneb,
|
||||
@@ -330,13 +331,18 @@ fn test_blobs_by_range_chunked_rpc() {
|
||||
.await;
|
||||
|
||||
// BlobsByRange Request
|
||||
let deneb_slot = spec
|
||||
.deneb_fork_epoch
|
||||
.expect("deneb must be scheduled")
|
||||
.start_slot(E::slots_per_epoch());
|
||||
let rpc_request = RequestType::BlobsByRange(BlobsByRangeRequest {
|
||||
start_slot: 0,
|
||||
start_slot: deneb_slot.as_u64(),
|
||||
count: slot_count,
|
||||
});
|
||||
|
||||
// BlocksByRange Response
|
||||
let blob = BlobSidecar::<E>::empty();
|
||||
// BlobsByRange Response
|
||||
let mut blob = BlobSidecar::<E>::empty();
|
||||
blob.signed_block_header.message.slot = deneb_slot;
|
||||
|
||||
let rpc_response = Response::BlobsByRange(Some(Arc::new(blob)));
|
||||
|
||||
@@ -438,7 +444,7 @@ fn test_tcp_blocks_by_range_over_limit() {
|
||||
|
||||
let rt = Arc::new(Runtime::new().unwrap());
|
||||
|
||||
let spec = Arc::new(E::default_spec());
|
||||
let spec = Arc::new(spec_with_all_forks_enabled());
|
||||
|
||||
rt.block_on(async {
|
||||
// get sender/receiver
|
||||
@@ -545,7 +551,7 @@ fn test_tcp_blocks_by_range_chunked_rpc_terminates_correctly() {
|
||||
|
||||
let rt = Arc::new(Runtime::new().unwrap());
|
||||
|
||||
let spec = Arc::new(E::default_spec());
|
||||
let spec = Arc::new(spec_with_all_forks_enabled());
|
||||
|
||||
rt.block_on(async {
|
||||
// get sender/receiver
|
||||
@@ -681,7 +687,7 @@ fn test_tcp_blocks_by_range_single_empty_rpc() {
|
||||
|
||||
let rt = Arc::new(Runtime::new().unwrap());
|
||||
|
||||
let spec = Arc::new(E::default_spec());
|
||||
let spec = Arc::new(spec_with_all_forks_enabled());
|
||||
|
||||
rt.block_on(async {
|
||||
// get sender/receiver
|
||||
@@ -804,14 +810,15 @@ fn test_tcp_blocks_by_root_chunked_rpc() {
|
||||
|
||||
let messages_to_send = 6;
|
||||
|
||||
let spec = Arc::new(E::default_spec());
|
||||
let spec = Arc::new(spec_with_all_forks_enabled());
|
||||
let current_fork_name = ForkName::Bellatrix;
|
||||
|
||||
let rt = Arc::new(Runtime::new().unwrap());
|
||||
// get sender/receiver
|
||||
rt.block_on(async {
|
||||
let (mut sender, mut receiver) = common::build_node_pair(
|
||||
Arc::downgrade(&rt),
|
||||
ForkName::Bellatrix,
|
||||
current_fork_name,
|
||||
spec.clone(),
|
||||
Protocol::Tcp,
|
||||
false,
|
||||
@@ -831,7 +838,7 @@ fn test_tcp_blocks_by_root_chunked_rpc() {
|
||||
Hash256::zero(),
|
||||
Hash256::zero(),
|
||||
],
|
||||
spec.max_request_blocks_upper_bound(),
|
||||
spec.max_request_blocks(current_fork_name),
|
||||
),
|
||||
}));
|
||||
|
||||
@@ -934,7 +941,7 @@ fn test_tcp_blocks_by_root_chunked_rpc() {
|
||||
tokio::select! {
|
||||
_ = sender_future => {}
|
||||
_ = receiver_future => {}
|
||||
_ = sleep(Duration::from_secs(30)) => {
|
||||
_ = sleep(Duration::from_secs(300)) => {
|
||||
panic!("Future timed out");
|
||||
}
|
||||
}
|
||||
@@ -952,14 +959,15 @@ fn test_tcp_blocks_by_root_chunked_rpc_terminates_correctly() {
|
||||
let messages_to_send: u64 = 10;
|
||||
let extra_messages_to_send: u64 = 10;
|
||||
|
||||
let spec = Arc::new(E::default_spec());
|
||||
let spec = Arc::new(spec_with_all_forks_enabled());
|
||||
let current_fork = ForkName::Base;
|
||||
|
||||
let rt = Arc::new(Runtime::new().unwrap());
|
||||
// get sender/receiver
|
||||
rt.block_on(async {
|
||||
let (mut sender, mut receiver) = common::build_node_pair(
|
||||
Arc::downgrade(&rt),
|
||||
ForkName::Base,
|
||||
current_fork,
|
||||
spec.clone(),
|
||||
Protocol::Tcp,
|
||||
false,
|
||||
@@ -983,7 +991,7 @@ fn test_tcp_blocks_by_root_chunked_rpc_terminates_correctly() {
|
||||
Hash256::zero(),
|
||||
Hash256::zero(),
|
||||
],
|
||||
spec.max_request_blocks_upper_bound(),
|
||||
spec.max_request_blocks(current_fork),
|
||||
),
|
||||
}));
|
||||
|
||||
@@ -1098,7 +1106,7 @@ fn goodbye_test(log_level: &str, enable_logging: bool, protocol: Protocol) {
|
||||
|
||||
let rt = Arc::new(Runtime::new().unwrap());
|
||||
|
||||
let spec = Arc::new(E::default_spec());
|
||||
let spec = Arc::new(spec_with_all_forks_enabled());
|
||||
|
||||
// get sender/receiver
|
||||
rt.block_on(async {
|
||||
@@ -1180,7 +1188,7 @@ fn test_delayed_rpc_response() {
|
||||
// Set up the logging.
|
||||
build_tracing_subscriber("debug", true);
|
||||
let rt = Arc::new(Runtime::new().unwrap());
|
||||
let spec = Arc::new(E::default_spec());
|
||||
let spec = Arc::new(spec_with_all_forks_enabled());
|
||||
|
||||
// Allow 1 token to be use used every 3 seconds.
|
||||
const QUOTA_SEC: u64 = 3;
|
||||
@@ -1314,7 +1322,7 @@ fn test_active_requests() {
|
||||
// Set up the logging.
|
||||
build_tracing_subscriber("debug", true);
|
||||
let rt = Arc::new(Runtime::new().unwrap());
|
||||
let spec = Arc::new(E::default_spec());
|
||||
let spec = Arc::new(spec_with_all_forks_enabled());
|
||||
|
||||
rt.block_on(async {
|
||||
// Get sender/receiver.
|
||||
|
||||
Reference in New Issue
Block a user