mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-19 13:58:28 +00:00
start fixing some compile errors
This commit is contained in:
@@ -468,7 +468,7 @@ pub struct BeaconChain<T: BeaconChainTypes> {
|
||||
/// Provides monitoring of a set of explicitly defined validators.
|
||||
pub validator_monitor: RwLock<ValidatorMonitor<T::EthSpec>>,
|
||||
pub proposal_blob_cache: BlobCache<T::EthSpec>,
|
||||
pub data_availability_checker: DataAvailabilityChecker<T::EthSpec, T::SlotClock>,
|
||||
pub data_availability_checker: Arc<DataAvailabilityChecker<T::EthSpec, T::SlotClock>>,
|
||||
pub kzg: Option<Arc<Kzg>>,
|
||||
}
|
||||
|
||||
@@ -2775,8 +2775,8 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
block_root: Hash256,
|
||||
unverified_block: B,
|
||||
count_unrealized: CountUnrealized,
|
||||
notify_execution_layer: notifyexecutionlayer,
|
||||
) -> result<availabilityprocessingStatus, BlockError<T::EthSpec>> {
|
||||
notify_execution_layer: NotifyExecutionLayer,
|
||||
) -> Result<AvailabilityProcessingStatus, BlockError<T::EthSpec>> {
|
||||
// Start the Prometheus timer.
|
||||
let _full_timer = metrics::start_timer(&metrics::BLOCK_PROCESSING_TIMES);
|
||||
|
||||
@@ -2915,12 +2915,9 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
Availability::Available(block) => {
|
||||
self.import_available_block(block, count_unrealized).await
|
||||
}
|
||||
Availability::PendingBlock(block_root) => {
|
||||
Ok(AvailabilityProcessingStatus::PendingBlock(block_root))
|
||||
Availability::MissingParts(block_root) => {
|
||||
Ok(AvailabilityProcessingStatus::MissingParts(block_root))
|
||||
}
|
||||
Availability::PendingBlobs(block_root, blob_ids) => Ok(
|
||||
AvailabilityProcessingStatus::PendingBlobs(block_root, blob_ids),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -372,17 +372,6 @@ pub enum MaybeAvailableBlock<E: EthSpec> {
|
||||
AvailabilityPending(AvailabilityPendingBlock<E>),
|
||||
}
|
||||
|
||||
impl<E: EthSpec> MaybeAvailableBlock<E> {
|
||||
pub fn get_missing_blob_ids(&self) -> Option<&Vec<BlobIdentifier>> {
|
||||
match self {
|
||||
MaybeAvailableBlock::Available(_) => None,
|
||||
MaybeAvailableBlock::AvailabilityPending(pending_block) => {
|
||||
Some(pending_block.get_missing_blob_ids())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Trait for common block operations.
|
||||
pub trait AsBlock<E: EthSpec> {
|
||||
fn slot(&self) -> Slot;
|
||||
|
||||
@@ -146,7 +146,7 @@ pub enum BlockError<T: EthSpec> {
|
||||
///
|
||||
/// It's unclear if this block is valid, but it cannot be processed without already knowing
|
||||
/// its parent.
|
||||
ParentUnknown(MaybeAvailableBlock<T>),
|
||||
ParentUnknown(BlockWrapper<T>),
|
||||
/// The block skips too many slots and is a DoS risk.
|
||||
TooManySkippedSlots {
|
||||
parent_slot: Slot,
|
||||
@@ -311,6 +311,7 @@ pub enum BlockError<T: EthSpec> {
|
||||
parent_root: Hash256,
|
||||
},
|
||||
BlobValidation(BlobError),
|
||||
AvailabilityCheck(AvailabilityCheckError),
|
||||
}
|
||||
|
||||
impl<T: EthSpec> From<BlobError> for BlockError<T> {
|
||||
@@ -1331,7 +1332,7 @@ impl<T: BeaconChainTypes> ExecutionPendingBlock<T> {
|
||||
// because it will revert finalization. Note that the finalized block is stored in fork
|
||||
// choice, so we will not reject any child of the finalized block (this is relevant during
|
||||
// genesis).
|
||||
return Err(BlockError::ParentUnknown(block));
|
||||
return Err(BlockError::ParentUnknown(block.into_block_wrapper()));
|
||||
}
|
||||
|
||||
// Reject any block that exceeds our limit on skipped slots.
|
||||
@@ -1795,7 +1796,7 @@ pub fn check_block_is_finalized_checkpoint_or_descendant<
|
||||
block_parent_root: block.parent_root(),
|
||||
})
|
||||
} else {
|
||||
Err(BlockError::ParentUnknown(block))
|
||||
Err(BlockError::ParentUnknown(block.into_block_wrapper()))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1876,7 +1877,7 @@ fn verify_parent_block_is_known<T: BeaconChainTypes>(
|
||||
{
|
||||
Ok((proto_block, block))
|
||||
} else {
|
||||
Err(BlockError::ParentUnknown(block))
|
||||
Err(BlockError::ParentUnknown(block.into_block_wrapper()))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1907,7 +1908,7 @@ fn load_parent<T: BeaconChainTypes, B: AsBlock<T::EthSpec>>(
|
||||
.fork_choice_read_lock()
|
||||
.contains_block(&block.parent_root())
|
||||
{
|
||||
return Err(BlockError::ParentUnknown(block));
|
||||
return Err(BlockError::ParentUnknown(block.into_block_wrapper()));
|
||||
}
|
||||
|
||||
let block_delay = chain
|
||||
|
||||
@@ -850,11 +850,11 @@ where
|
||||
slasher: self.slasher.clone(),
|
||||
validator_monitor: RwLock::new(validator_monitor),
|
||||
//TODO(sean) should we move kzg solely to the da checker?
|
||||
data_availability_checker: DataAvailabilityChecker::new(
|
||||
data_availability_checker: Arc::new(DataAvailabilityChecker::new(
|
||||
slot_clock,
|
||||
kzg.clone(),
|
||||
self.spec,
|
||||
),
|
||||
)),
|
||||
proposal_blob_cache: BlobCache::default(),
|
||||
kzg,
|
||||
};
|
||||
|
||||
@@ -122,23 +122,10 @@ impl<T: EthSpec> ReceivedComponents<T> {
|
||||
/// Indicates if the block is fully `Available` or if we need blobs or blocks
|
||||
/// to "complete" the requirements for an `AvailableBlock`.
|
||||
pub enum Availability<T: EthSpec> {
|
||||
PendingBlobs(Hash256, Vec<BlobIdentifier>),
|
||||
PendingBlock(Hash256),
|
||||
MissingParts(Hash256),
|
||||
Available(Box<AvailableExecutedBlock<T>>),
|
||||
}
|
||||
|
||||
impl<T: EthSpec> Availability<T> {
|
||||
/// Returns all the blob identifiers associated with an `AvailableBlock`.
|
||||
/// Returns `None` if avaiability hasn't been fully satisfied yet.
|
||||
pub fn get_available_blob_ids(&self) -> Option<Vec<BlobIdentifier>> {
|
||||
if let Self::Available(block) = self {
|
||||
Some(block.get_all_blob_ids())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: EthSpec, S: SlotClock> DataAvailabilityChecker<T, S> {
|
||||
pub fn new(slot_clock: S, kzg: Option<Arc<Kzg>>, spec: ChainSpec) -> Self {
|
||||
Self {
|
||||
@@ -161,7 +148,6 @@ impl<T: EthSpec, S: SlotClock> DataAvailabilityChecker<T, S> {
|
||||
BlobRequirements::PreDeneb => BlockWrapper::Block(block),
|
||||
BlobRequirements::Required => {
|
||||
let expected_num_blobs = block
|
||||
.block()
|
||||
.message()
|
||||
.body()
|
||||
.blob_kzg_commitments()
|
||||
@@ -175,7 +161,7 @@ impl<T: EthSpec, S: SlotClock> DataAvailabilityChecker<T, S> {
|
||||
num_blobs: blobs.len(),
|
||||
});
|
||||
}
|
||||
for blob in blobs {
|
||||
for blob in blobs.iter() {
|
||||
if blob.block_root != block_root {
|
||||
return Err(AvailabilityCheckError::BlockBlobRootMismatch {
|
||||
block_root,
|
||||
@@ -278,12 +264,12 @@ impl<T: EthSpec, S: SlotClock> DataAvailabilityChecker<T, S> {
|
||||
if let Some(executed_block) = received_components.executed_block.take() {
|
||||
self.check_block_availability_maybe_cache(occupied_entry, executed_block)?
|
||||
} else {
|
||||
Availability::PendingBlock(block_root)
|
||||
Availability::MissingParts(block_root)
|
||||
}
|
||||
}
|
||||
Entry::Vacant(vacant_entry) => {
|
||||
vacant_entry.insert(ReceivedComponents::new_from_blobs(kzg_verified_blobs));
|
||||
Availability::PendingBlock(block_root)
|
||||
Availability::MissingParts(block_root)
|
||||
}
|
||||
};
|
||||
|
||||
@@ -305,10 +291,9 @@ impl<T: EthSpec, S: SlotClock> DataAvailabilityChecker<T, S> {
|
||||
self.check_block_availability_maybe_cache(occupied_entry, executed_block)?
|
||||
}
|
||||
Entry::Vacant(vacant_entry) => {
|
||||
let all_blob_ids = executed_block.get_all_blob_ids();
|
||||
let block_root = executed_block.import_data.block_root;
|
||||
vacant_entry.insert(ReceivedComponents::new_from_block(executed_block));
|
||||
Availability::PendingBlobs(block_root, all_blob_ids)
|
||||
Availability::MissingParts(block_root)
|
||||
}
|
||||
};
|
||||
|
||||
@@ -357,19 +342,11 @@ impl<T: EthSpec, S: SlotClock> DataAvailabilityChecker<T, S> {
|
||||
} else {
|
||||
let received_components = occupied_entry.get_mut();
|
||||
|
||||
let missing_blob_ids = executed_block.get_filtered_blob_ids(|index, _| {
|
||||
received_components
|
||||
.verified_blobs
|
||||
.get(index as usize)
|
||||
.map(|maybe_blob| maybe_blob.is_none())
|
||||
.unwrap_or(true)
|
||||
});
|
||||
|
||||
let block_root = executed_block.import_data.block_root;
|
||||
|
||||
let _ = received_components.executed_block.insert(executed_block);
|
||||
|
||||
Ok(Availability::PendingBlobs(block_root, missing_blob_ids))
|
||||
Ok(Availability::MissingParts(block_root))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user