mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-09 19:51:47 +00:00
Use E for EthSpec globally (#5264)
* Use `E` for `EthSpec` globally * Fix tests * Merge branch 'unstable' into e-ethspec * Merge branch 'unstable' into e-ethspec # Conflicts: # beacon_node/execution_layer/src/engine_api.rs # beacon_node/execution_layer/src/engine_api/http.rs # beacon_node/execution_layer/src/engine_api/json_structures.rs # beacon_node/execution_layer/src/test_utils/handle_rpc.rs # beacon_node/store/src/partial_beacon_state.rs # consensus/types/src/beacon_block.rs # consensus/types/src/beacon_block_body.rs # consensus/types/src/beacon_state.rs # consensus/types/src/config_and_preset.rs # consensus/types/src/execution_payload.rs # consensus/types/src/execution_payload_header.rs # consensus/types/src/light_client_optimistic_update.rs # consensus/types/src/payload.rs # lcli/src/parse_ssz.rs
This commit is contained in:
@@ -92,19 +92,19 @@ pub struct ClientBuilder<T: BeaconChainTypes> {
|
||||
eth_spec_instance: T::EthSpec,
|
||||
}
|
||||
|
||||
impl<TSlotClock, TEth1Backend, TEthSpec, THotStore, TColdStore>
|
||||
ClientBuilder<Witness<TSlotClock, TEth1Backend, TEthSpec, THotStore, TColdStore>>
|
||||
impl<TSlotClock, TEth1Backend, E, THotStore, TColdStore>
|
||||
ClientBuilder<Witness<TSlotClock, TEth1Backend, E, THotStore, TColdStore>>
|
||||
where
|
||||
TSlotClock: SlotClock + Clone + 'static,
|
||||
TEth1Backend: Eth1ChainBackend<TEthSpec> + 'static,
|
||||
TEthSpec: EthSpec + 'static,
|
||||
THotStore: ItemStore<TEthSpec> + 'static,
|
||||
TColdStore: ItemStore<TEthSpec> + 'static,
|
||||
TEth1Backend: Eth1ChainBackend<E> + 'static,
|
||||
E: EthSpec + 'static,
|
||||
THotStore: ItemStore<E> + 'static,
|
||||
TColdStore: ItemStore<E> + 'static,
|
||||
{
|
||||
/// Instantiates a new, empty builder.
|
||||
///
|
||||
/// The `eth_spec_instance` parameter is used to concretize `TEthSpec`.
|
||||
pub fn new(eth_spec_instance: TEthSpec) -> Self {
|
||||
/// The `eth_spec_instance` parameter is used to concretize `E`.
|
||||
pub fn new(eth_spec_instance: E) -> Self {
|
||||
Self {
|
||||
slot_clock: None,
|
||||
store: None,
|
||||
@@ -129,7 +129,7 @@ where
|
||||
}
|
||||
|
||||
/// Specifies the runtime context (tokio executor, logger, etc) for client services.
|
||||
pub fn runtime_context(mut self, context: RuntimeContext<TEthSpec>) -> Self {
|
||||
pub fn runtime_context(mut self, context: RuntimeContext<E>) -> Self {
|
||||
self.runtime_context = Some(context);
|
||||
self
|
||||
}
|
||||
@@ -146,7 +146,7 @@ where
|
||||
self
|
||||
}
|
||||
|
||||
pub fn slasher(mut self, slasher: Arc<Slasher<TEthSpec>>) -> Self {
|
||||
pub fn slasher(mut self, slasher: Arc<Slasher<E>>) -> Self {
|
||||
self.slasher = Some(slasher);
|
||||
self
|
||||
}
|
||||
@@ -214,7 +214,7 @@ where
|
||||
};
|
||||
|
||||
let builder = if config.network.enable_light_client_server {
|
||||
let (tx, rv) = futures::channel::mpsc::channel::<LightClientProducerEvent<TEthSpec>>(
|
||||
let (tx, rv) = futures::channel::mpsc::channel::<LightClientProducerEvent<E>>(
|
||||
LIGHT_CLIENT_SERVER_CHANNEL_CAPACITY,
|
||||
);
|
||||
self.light_client_server_rv = Some(rv);
|
||||
@@ -299,7 +299,7 @@ where
|
||||
.min_epochs_for_blob_sidecars_requests
|
||||
.saturating_sub(BLOB_AVAILABILITY_REDUCTION_EPOCHS);
|
||||
let blob_availability_window = reduced_p2p_availability_epochs
|
||||
* TEthSpec::slots_per_epoch()
|
||||
* E::slots_per_epoch()
|
||||
* spec.seconds_per_slot;
|
||||
|
||||
if now > deneb_time + blob_availability_window {
|
||||
@@ -424,7 +424,7 @@ where
|
||||
"Downloading finalized state";
|
||||
);
|
||||
let state = remote
|
||||
.get_debug_beacon_states_ssz::<TEthSpec>(StateId::Finalized, &spec)
|
||||
.get_debug_beacon_states_ssz::<E>(StateId::Finalized, &spec)
|
||||
.await
|
||||
.map_err(|e| format!("Error loading checkpoint state from remote: {:?}", e))?
|
||||
.ok_or_else(|| "Checkpoint state missing from remote".to_string())?;
|
||||
@@ -435,7 +435,7 @@ where
|
||||
|
||||
debug!(context.log(), "Downloading finalized block"; "block_slot" => ?finalized_block_slot);
|
||||
let block = remote
|
||||
.get_beacon_blocks_ssz::<TEthSpec>(BlockId::Slot(finalized_block_slot), &spec)
|
||||
.get_beacon_blocks_ssz::<E>(BlockId::Slot(finalized_block_slot), &spec)
|
||||
.await
|
||||
.map_err(|e| match e {
|
||||
ApiError::InvalidSsz(e) => format!(
|
||||
@@ -453,7 +453,7 @@ where
|
||||
let blobs = if block.message().body().has_blobs() {
|
||||
debug!(context.log(), "Downloading finalized blobs");
|
||||
if let Some(response) = remote
|
||||
.get_blobs::<TEthSpec>(BlockId::Root(block_root), None)
|
||||
.get_blobs::<E>(BlockId::Root(block_root), None)
|
||||
.await
|
||||
.map_err(|e| format!("Error fetching finalized blobs from remote: {e:?}"))?
|
||||
{
|
||||
@@ -537,7 +537,7 @@ where
|
||||
#[allow(clippy::type_complexity)]
|
||||
let ctx: Arc<
|
||||
http_api::Context<
|
||||
Witness<TSlotClock, TEth1Backend, TEthSpec, THotStore, TColdStore>,
|
||||
Witness<TSlotClock, TEth1Backend, E, THotStore, TColdStore>,
|
||||
>,
|
||||
> = Arc::new(http_api::Context {
|
||||
config: self.http_api_config.clone(),
|
||||
@@ -764,8 +764,7 @@ where
|
||||
#[allow(clippy::type_complexity)]
|
||||
pub fn build(
|
||||
mut self,
|
||||
) -> Result<Client<Witness<TSlotClock, TEth1Backend, TEthSpec, THotStore, TColdStore>>, String>
|
||||
{
|
||||
) -> Result<Client<Witness<TSlotClock, TEth1Backend, E, THotStore, TColdStore>>, String> {
|
||||
let runtime_context = self
|
||||
.runtime_context
|
||||
.as_ref()
|
||||
@@ -962,14 +961,14 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<TSlotClock, TEth1Backend, TEthSpec, THotStore, TColdStore>
|
||||
ClientBuilder<Witness<TSlotClock, TEth1Backend, TEthSpec, THotStore, TColdStore>>
|
||||
impl<TSlotClock, TEth1Backend, E, THotStore, TColdStore>
|
||||
ClientBuilder<Witness<TSlotClock, TEth1Backend, E, THotStore, TColdStore>>
|
||||
where
|
||||
TSlotClock: SlotClock + Clone + 'static,
|
||||
TEth1Backend: Eth1ChainBackend<TEthSpec> + 'static,
|
||||
TEthSpec: EthSpec + 'static,
|
||||
THotStore: ItemStore<TEthSpec> + 'static,
|
||||
TColdStore: ItemStore<TEthSpec> + 'static,
|
||||
TEth1Backend: Eth1ChainBackend<E> + 'static,
|
||||
E: EthSpec + 'static,
|
||||
THotStore: ItemStore<E> + 'static,
|
||||
TColdStore: ItemStore<E> + 'static,
|
||||
{
|
||||
/// Consumes the internal `BeaconChainBuilder`, attaching the resulting `BeaconChain` to self.
|
||||
pub fn build_beacon_chain(mut self) -> Result<Self, String> {
|
||||
@@ -999,12 +998,12 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<TSlotClock, TEth1Backend, TEthSpec>
|
||||
ClientBuilder<Witness<TSlotClock, TEth1Backend, TEthSpec, LevelDB<TEthSpec>, LevelDB<TEthSpec>>>
|
||||
impl<TSlotClock, TEth1Backend, E>
|
||||
ClientBuilder<Witness<TSlotClock, TEth1Backend, E, LevelDB<E>, LevelDB<E>>>
|
||||
where
|
||||
TSlotClock: SlotClock + 'static,
|
||||
TEth1Backend: Eth1ChainBackend<TEthSpec> + 'static,
|
||||
TEthSpec: EthSpec + 'static,
|
||||
TEth1Backend: Eth1ChainBackend<E> + 'static,
|
||||
E: EthSpec + 'static,
|
||||
{
|
||||
/// Specifies that the `Client` should use a `HotColdDB` database.
|
||||
pub fn disk_store(
|
||||
@@ -1061,15 +1060,13 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<TSlotClock, TEthSpec, THotStore, TColdStore>
|
||||
ClientBuilder<
|
||||
Witness<TSlotClock, CachingEth1Backend<TEthSpec>, TEthSpec, THotStore, TColdStore>,
|
||||
>
|
||||
impl<TSlotClock, E, THotStore, TColdStore>
|
||||
ClientBuilder<Witness<TSlotClock, CachingEth1Backend<E>, E, THotStore, TColdStore>>
|
||||
where
|
||||
TSlotClock: SlotClock + 'static,
|
||||
TEthSpec: EthSpec + 'static,
|
||||
THotStore: ItemStore<TEthSpec> + 'static,
|
||||
TColdStore: ItemStore<TEthSpec> + 'static,
|
||||
E: EthSpec + 'static,
|
||||
THotStore: ItemStore<E> + 'static,
|
||||
TColdStore: ItemStore<E> + 'static,
|
||||
{
|
||||
/// Specifies that the `BeaconChain` should cache eth1 blocks/logs from a remote eth1 node
|
||||
/// (e.g., Parity/Geth) and refer to that cache when collecting deposits or eth1 votes during
|
||||
@@ -1162,13 +1159,13 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<TEth1Backend, TEthSpec, THotStore, TColdStore>
|
||||
ClientBuilder<Witness<SystemTimeSlotClock, TEth1Backend, TEthSpec, THotStore, TColdStore>>
|
||||
impl<TEth1Backend, E, THotStore, TColdStore>
|
||||
ClientBuilder<Witness<SystemTimeSlotClock, TEth1Backend, E, THotStore, TColdStore>>
|
||||
where
|
||||
TEth1Backend: Eth1ChainBackend<TEthSpec> + 'static,
|
||||
TEthSpec: EthSpec + 'static,
|
||||
THotStore: ItemStore<TEthSpec> + 'static,
|
||||
TColdStore: ItemStore<TEthSpec> + 'static,
|
||||
TEth1Backend: Eth1ChainBackend<E> + 'static,
|
||||
E: EthSpec + 'static,
|
||||
THotStore: ItemStore<E> + 'static,
|
||||
TColdStore: ItemStore<E> + 'static,
|
||||
{
|
||||
/// Specifies that the slot clock should read the time from the computers system clock.
|
||||
pub fn system_time_slot_clock(mut self) -> Result<Self, String> {
|
||||
@@ -1198,17 +1195,17 @@ where
|
||||
}
|
||||
|
||||
/// Obtain the genesis state from the `eth2_network_config` in `context`.
|
||||
async fn genesis_state<T: EthSpec>(
|
||||
context: &RuntimeContext<T>,
|
||||
async fn genesis_state<E: EthSpec>(
|
||||
context: &RuntimeContext<E>,
|
||||
config: &ClientConfig,
|
||||
log: &Logger,
|
||||
) -> Result<BeaconState<T>, String> {
|
||||
) -> Result<BeaconState<E>, String> {
|
||||
let eth2_network_config = context
|
||||
.eth2_network_config
|
||||
.as_ref()
|
||||
.ok_or("An eth2_network_config is required to obtain the genesis state")?;
|
||||
eth2_network_config
|
||||
.genesis_state::<T>(
|
||||
.genesis_state::<E>(
|
||||
config.genesis_state_url.as_deref(),
|
||||
config.genesis_state_url_timeout,
|
||||
log,
|
||||
|
||||
Reference in New Issue
Block a user