mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-07 00:42:42 +00:00
Merge remote-tracking branch 'origin/unstable' into tree-states
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.
|
||||
///
|
||||
|
||||
@@ -5,8 +5,6 @@ use diesel::pg::{Pg, PgValue};
|
||||
use diesel::serialize::{self, Output, ToSql};
|
||||
use diesel::sql_types::{Binary, Integer};
|
||||
|
||||
use std::convert::TryFrom;
|
||||
|
||||
macro_rules! impl_to_from_sql_int {
|
||||
($type:ty) => {
|
||||
impl ToSql<Integer, Pg> for $type
|
||||
|
||||
@@ -13,7 +13,6 @@ use self::schema::{
|
||||
};
|
||||
|
||||
use diesel::dsl::max;
|
||||
use diesel::pg::PgConnection;
|
||||
use diesel::prelude::*;
|
||||
use diesel::r2d2::{Builder, ConnectionManager, Pool, PooledConnection};
|
||||
use diesel::upsert::excluded;
|
||||
@@ -128,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};
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#![allow(dead_code)]
|
||||
use crate::database::config::Config;
|
||||
use diesel::pg::PgConnection;
|
||||
use diesel::prelude::*;
|
||||
use diesel_migrations::{FileBasedMigrations, MigrationHarness};
|
||||
|
||||
|
||||
@@ -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.
|
||||
///
|
||||
|
||||
@@ -9,7 +9,6 @@ use eth2::{
|
||||
};
|
||||
use log::{debug, error, info, warn};
|
||||
use std::collections::HashSet;
|
||||
use std::iter::FromIterator;
|
||||
use types::{BeaconBlockHeader, EthSpec, Hash256, SignedBeaconBlock, Slot};
|
||||
|
||||
use crate::updater::{get_beacon_block, get_header, get_validators};
|
||||
@@ -17,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)?;
|
||||
@@ -42,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)?;
|
||||
@@ -100,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