mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-14 10:22:38 +00:00
Altair networking (#2300)
## Issue Addressed Resolves #2278 ## Proposed Changes Implements the networking components for the Altair hard fork https://github.com/ethereum/eth2.0-specs/blob/dev/specs/altair/p2p-interface.md ## Additional Info This PR acts as the base branch for networking changes and tracks https://github.com/sigp/lighthouse/pull/2279 . Changes to gossip, rpc and discovery can be separate PRs to be merged here for ease of review. Co-authored-by: realbigsean <seananderson33@gmail.com>
This commit is contained in:
@@ -7,14 +7,20 @@ use eth2_libp2p::{Libp2pEvent, NetworkConfig};
|
||||
use libp2p::gossipsub::GossipsubConfigBuilder;
|
||||
use slog::{debug, error, o, Drain};
|
||||
use std::net::{TcpListener, UdpSocket};
|
||||
use std::sync::Arc;
|
||||
use std::sync::Weak;
|
||||
use std::time::Duration;
|
||||
use tokio::runtime::Runtime;
|
||||
use types::{ChainSpec, EnrForkId, MinimalEthSpec};
|
||||
use types::{ChainSpec, EnrForkId, ForkContext, Hash256, MinimalEthSpec};
|
||||
|
||||
type E = MinimalEthSpec;
|
||||
use tempfile::Builder as TempBuilder;
|
||||
|
||||
/// Returns a dummy fork context
|
||||
fn fork_context() -> ForkContext {
|
||||
ForkContext::new::<E>(types::Slot::new(0), Hash256::zero(), &ChainSpec::minimal())
|
||||
}
|
||||
|
||||
pub struct Libp2pInstance(LibP2PService<E>, exit_future::Signal);
|
||||
|
||||
impl std::ops::Deref for Libp2pInstance {
|
||||
@@ -109,12 +115,14 @@ pub async fn build_libp2p_instance(
|
||||
let (signal, exit) = exit_future::signal();
|
||||
let (shutdown_tx, _) = futures::channel::mpsc::channel(1);
|
||||
let executor = task_executor::TaskExecutor::new(rt, exit, log.clone(), shutdown_tx);
|
||||
let fork_context = Arc::new(fork_context());
|
||||
Libp2pInstance(
|
||||
LibP2PService::new(
|
||||
executor,
|
||||
&config,
|
||||
EnrForkId::default(),
|
||||
&log,
|
||||
fork_context,
|
||||
&ChainSpec::minimal(),
|
||||
)
|
||||
.await
|
||||
|
||||
Reference in New Issue
Block a user