mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-16 11:22:56 +00:00
Server sent events (#1920)
## Issue Addressed Resolves #1434 (this is the last major feature in the standard spec. There are only a couple of places we may be off-spec due to recent spec changes or ongoing discussion) Partly addresses #1669 ## Proposed Changes - remove the websocket server - remove the `TeeEventHandler` and `NullEventHandler` - add server sent events according to the eth2 API spec ## Additional Info This is according to the currently unmerged PR here: https://github.com/ethereum/eth2.0-APIs/pull/117 Co-authored-by: realbigsean <seananderson33@gmail.com>
This commit is contained in:
@@ -232,29 +232,6 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
|
||||
address of this server (e.g., http://localhost:5054).")
|
||||
.takes_value(true),
|
||||
)
|
||||
/* Websocket related arguments */
|
||||
.arg(
|
||||
Arg::with_name("ws")
|
||||
.long("ws")
|
||||
.help("Enable the websocket server. Disabled by default.")
|
||||
.takes_value(false),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("ws-address")
|
||||
.long("ws-address")
|
||||
.value_name("ADDRESS")
|
||||
.help("Set the listen address for the websocket server.")
|
||||
.default_value("127.0.0.1")
|
||||
.takes_value(true),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("ws-port")
|
||||
.long("ws-port")
|
||||
.value_name("PORT")
|
||||
.help("Set the listen TCP port for the websocket server.")
|
||||
.default_value("5053")
|
||||
.takes_value(true),
|
||||
)
|
||||
|
||||
/*
|
||||
* Standard staking flags
|
||||
|
||||
@@ -150,26 +150,6 @@ pub fn get_config<E: EthSpec>(
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
* Websocket server
|
||||
*/
|
||||
|
||||
if cli_args.is_present("ws") {
|
||||
client_config.websocket_server.enabled = true;
|
||||
}
|
||||
|
||||
if let Some(address) = cli_args.value_of("ws-address") {
|
||||
client_config.websocket_server.listen_address = address
|
||||
.parse::<Ipv4Addr>()
|
||||
.map_err(|_| "ws-address is not a valid IPv4 address.")?;
|
||||
}
|
||||
|
||||
if let Some(port) = cli_args.value_of("ws-port") {
|
||||
client_config.websocket_server.port = port
|
||||
.parse::<u16>()
|
||||
.map_err(|_| "ws-port is not a valid u16.")?;
|
||||
}
|
||||
|
||||
/*
|
||||
* Eth1
|
||||
*/
|
||||
@@ -250,7 +230,6 @@ pub fn get_config<E: EthSpec>(
|
||||
unused_port("udp").map_err(|e| format!("Failed to get port for discovery: {}", e))?;
|
||||
client_config.http_api.listen_port = 0;
|
||||
client_config.http_metrics.listen_port = 0;
|
||||
client_config.websocket_server.port = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -5,18 +5,16 @@ mod cli;
|
||||
mod config;
|
||||
|
||||
pub use beacon_chain;
|
||||
pub use cli::cli_app;
|
||||
pub use client::{Client, ClientBuilder, ClientConfig, ClientGenesis};
|
||||
pub use config::{get_config, get_data_dir, get_eth2_testnet_config, set_network_config};
|
||||
pub use eth2_config::Eth2Config;
|
||||
|
||||
use beacon_chain::events::TeeEventHandler;
|
||||
use beacon_chain::store::LevelDB;
|
||||
use beacon_chain::{
|
||||
builder::Witness, eth1_chain::CachingEth1Backend, slot_clock::SystemTimeSlotClock,
|
||||
};
|
||||
use clap::ArgMatches;
|
||||
pub use cli::cli_app;
|
||||
pub use client::{Client, ClientBuilder, ClientConfig, ClientGenesis};
|
||||
pub use config::{get_config, get_data_dir, get_eth2_testnet_config, set_network_config};
|
||||
use environment::RuntimeContext;
|
||||
pub use eth2_config::Eth2Config;
|
||||
use slasher::Slasher;
|
||||
use slog::{info, warn};
|
||||
use std::ops::{Deref, DerefMut};
|
||||
@@ -24,16 +22,8 @@ use std::sync::Arc;
|
||||
use types::EthSpec;
|
||||
|
||||
/// A type-alias to the tighten the definition of a production-intended `Client`.
|
||||
pub type ProductionClient<E> = Client<
|
||||
Witness<
|
||||
SystemTimeSlotClock,
|
||||
CachingEth1Backend<E>,
|
||||
E,
|
||||
TeeEventHandler<E>,
|
||||
LevelDB<E>,
|
||||
LevelDB<E>,
|
||||
>,
|
||||
>;
|
||||
pub type ProductionClient<E> =
|
||||
Client<Witness<SystemTimeSlotClock, CachingEth1Backend<E>, E, LevelDB<E>, LevelDB<E>>>;
|
||||
|
||||
/// The beacon node `Client` that will be used in production.
|
||||
///
|
||||
@@ -121,9 +111,7 @@ impl<E: EthSpec> ProductionBeaconNode<E> {
|
||||
builder.no_eth1_backend()?
|
||||
};
|
||||
|
||||
let (builder, _events) = builder
|
||||
.system_time_slot_clock()?
|
||||
.tee_event_handler(client_config.websocket_server.clone())?;
|
||||
let builder = builder.system_time_slot_clock()?;
|
||||
|
||||
// Inject the executor into the discv5 network config.
|
||||
let discv5_executor = Discv5Executor(executor);
|
||||
|
||||
Reference in New Issue
Block a user