mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-07 00:42:42 +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:
@@ -8,7 +8,7 @@ use log::{debug, error, warn};
|
||||
|
||||
const MAX_SIZE_SINGLE_REQUEST_BLOCK_PACKING: u64 = 50;
|
||||
|
||||
impl<T: EthSpec> UpdateHandler<T> {
|
||||
impl<E: EthSpec> UpdateHandler<E> {
|
||||
/// Forward fills the `block_packing` table starting from the entry with the
|
||||
/// highest slot.
|
||||
///
|
||||
|
||||
@@ -8,7 +8,7 @@ use log::{debug, error, warn};
|
||||
|
||||
const MAX_SIZE_SINGLE_REQUEST_BLOCK_REWARDS: u64 = 1600;
|
||||
|
||||
impl<T: EthSpec> UpdateHandler<T> {
|
||||
impl<E: EthSpec> UpdateHandler<E> {
|
||||
/// Forward fills the `block_rewards` table starting from the entry with the
|
||||
/// highest slot.
|
||||
///
|
||||
|
||||
@@ -6,7 +6,7 @@ use log::{debug, error, warn};
|
||||
|
||||
const MAX_SIZE_SINGLE_REQUEST_BLOCKPRINT: u64 = 1600;
|
||||
|
||||
impl<T: EthSpec> UpdateHandler<T> {
|
||||
impl<E: EthSpec> UpdateHandler<E> {
|
||||
/// Forward fills the `blockprint` table starting from the entry with the
|
||||
/// highest slot.
|
||||
///
|
||||
|
||||
@@ -127,9 +127,9 @@ pub fn insert_canonical_slot(conn: &mut PgConn, new_slot: WatchCanonicalSlot) ->
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn insert_beacon_block<T: EthSpec>(
|
||||
pub fn insert_beacon_block<E: EthSpec>(
|
||||
conn: &mut PgConn,
|
||||
block: SignedBeaconBlock<T>,
|
||||
block: SignedBeaconBlock<E>,
|
||||
root: WatchHash,
|
||||
) -> Result<(), Error> {
|
||||
use self::canonical_slots::dsl::{beacon_block, slot as canonical_slot};
|
||||
|
||||
@@ -8,7 +8,7 @@ use log::{debug, error, warn};
|
||||
|
||||
const MAX_SIZE_SINGLE_REQUEST_ATTESTATIONS: u64 = 50;
|
||||
|
||||
impl<T: EthSpec> UpdateHandler<T> {
|
||||
impl<E: EthSpec> UpdateHandler<E> {
|
||||
/// Forward fills the `suboptimal_attestations` table starting from the entry with the highest
|
||||
/// slot.
|
||||
///
|
||||
|
||||
@@ -16,8 +16,8 @@ use crate::updater::{get_beacon_block, get_header, get_validators};
|
||||
const MAX_EXPECTED_REORG_LENGTH: u64 = 32;
|
||||
|
||||
/// Ensure the existing database is valid for this run.
|
||||
pub async fn ensure_valid_database<T: EthSpec>(
|
||||
spec: &WatchSpec<T>,
|
||||
pub async fn ensure_valid_database<E: EthSpec>(
|
||||
spec: &WatchSpec<E>,
|
||||
pool: &mut PgPool,
|
||||
) -> Result<(), Error> {
|
||||
let mut conn = database::get_connection(pool)?;
|
||||
@@ -41,21 +41,21 @@ pub async fn ensure_valid_database<T: EthSpec>(
|
||||
}
|
||||
}
|
||||
|
||||
pub struct UpdateHandler<T: EthSpec> {
|
||||
pub struct UpdateHandler<E: EthSpec> {
|
||||
pub pool: PgPool,
|
||||
pub bn: BeaconNodeHttpClient,
|
||||
pub blockprint: Option<WatchBlockprintClient>,
|
||||
pub config: Config,
|
||||
pub slots_per_epoch: u64,
|
||||
pub spec: WatchSpec<T>,
|
||||
pub spec: WatchSpec<E>,
|
||||
}
|
||||
|
||||
impl<T: EthSpec> UpdateHandler<T> {
|
||||
impl<E: EthSpec> UpdateHandler<E> {
|
||||
pub async fn new(
|
||||
bn: BeaconNodeHttpClient,
|
||||
spec: WatchSpec<T>,
|
||||
spec: WatchSpec<E>,
|
||||
config: FullConfig,
|
||||
) -> Result<UpdateHandler<T>, Error> {
|
||||
) -> Result<UpdateHandler<E>, Error> {
|
||||
let blockprint = if config.blockprint.enabled {
|
||||
if let Some(server) = config.blockprint.url {
|
||||
let blockprint_url = SensitiveUrl::parse(&server).map_err(Error::SensitiveUrl)?;
|
||||
@@ -99,7 +99,7 @@ impl<T: EthSpec> UpdateHandler<T> {
|
||||
let mut conn = database::get_connection(&self.pool)?;
|
||||
let roots = database::get_unknown_canonical_blocks(&mut conn)?;
|
||||
for root in roots {
|
||||
let block_opt: Option<SignedBeaconBlock<T>> =
|
||||
let block_opt: Option<SignedBeaconBlock<E>> =
|
||||
get_beacon_block(&self.bn, BlockId::Root(root.as_hash())).await?;
|
||||
if let Some(block) = block_opt {
|
||||
database::insert_beacon_block(&mut conn, block, root)?;
|
||||
|
||||
@@ -24,14 +24,14 @@ const DEFAULT_TIMEOUT: Duration = Duration::from_secs(5);
|
||||
const MAINNET: &str = "mainnet";
|
||||
const GNOSIS: &str = "gnosis";
|
||||
|
||||
pub struct WatchSpec<T: EthSpec> {
|
||||
pub struct WatchSpec<E: EthSpec> {
|
||||
network: String,
|
||||
spec: PhantomData<T>,
|
||||
spec: PhantomData<E>,
|
||||
}
|
||||
|
||||
impl<T: EthSpec> WatchSpec<T> {
|
||||
impl<E: EthSpec> WatchSpec<E> {
|
||||
fn slots_per_epoch(&self) -> u64 {
|
||||
T::slots_per_epoch()
|
||||
E::slots_per_epoch()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,9 +87,9 @@ pub async fn run_updater(config: FullConfig) -> Result<(), Error> {
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn run_once<T: EthSpec>(
|
||||
pub async fn run_once<E: EthSpec>(
|
||||
bn: BeaconNodeHttpClient,
|
||||
spec: WatchSpec<T>,
|
||||
spec: WatchSpec<E>,
|
||||
config: FullConfig,
|
||||
) -> Result<(), Error> {
|
||||
let mut watch = UpdateHandler::new(bn, spec, config.clone()).await?;
|
||||
@@ -190,10 +190,10 @@ pub async fn get_header(
|
||||
Ok(None)
|
||||
}
|
||||
|
||||
pub async fn get_beacon_block<T: EthSpec>(
|
||||
pub async fn get_beacon_block<E: EthSpec>(
|
||||
bn: &BeaconNodeHttpClient,
|
||||
block_id: BlockId,
|
||||
) -> Result<Option<SignedBeaconBlock<T>>, Error> {
|
||||
) -> Result<Option<SignedBeaconBlock<E>>, Error> {
|
||||
let block = bn.get_beacon_blocks(block_id).await?.map(|resp| resp.data);
|
||||
|
||||
Ok(block)
|
||||
|
||||
Reference in New Issue
Block a user