mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-18 13:28:33 +00:00
Merge remote-tracking branch 'origin/unstable' into tree-states
This commit is contained in:
@@ -139,14 +139,14 @@ const WRITE_BLOCK_PROCESSING_SSZ: bool = cfg!(feature = "write_ssz_files");
|
||||
/// - The block is malformed/invalid (indicated by all results other than `BeaconChainError`.
|
||||
/// - We encountered an error whilst trying to verify the block (a `BeaconChainError`).
|
||||
#[derive(Debug)]
|
||||
pub enum BlockError<T: EthSpec> {
|
||||
pub enum BlockError<E: EthSpec> {
|
||||
/// The parent block was unknown.
|
||||
///
|
||||
/// ## Peer scoring
|
||||
///
|
||||
/// It's unclear if this block is valid, but it cannot be processed without already knowing
|
||||
/// its parent.
|
||||
ParentUnknown(RpcBlock<T>),
|
||||
ParentUnknown(RpcBlock<E>),
|
||||
/// The block slot is greater than the present slot.
|
||||
///
|
||||
/// ## Peer scoring
|
||||
@@ -186,7 +186,7 @@ pub enum BlockError<T: EthSpec> {
|
||||
/// ## Peer scoring
|
||||
///
|
||||
/// The block is valid and we have already imported a block with this hash.
|
||||
BlockIsAlreadyKnown,
|
||||
BlockIsAlreadyKnown(Hash256),
|
||||
/// The block slot exceeds the MAXIMUM_BLOCK_SLOT_NUMBER.
|
||||
///
|
||||
/// ## Peer scoring
|
||||
@@ -306,7 +306,7 @@ pub enum BlockError<T: EthSpec> {
|
||||
AvailabilityCheck(AvailabilityCheckError),
|
||||
}
|
||||
|
||||
impl<T: EthSpec> From<AvailabilityCheckError> for BlockError<T> {
|
||||
impl<E: EthSpec> From<AvailabilityCheckError> for BlockError<E> {
|
||||
fn from(e: AvailabilityCheckError) -> Self {
|
||||
Self::AvailabilityCheck(e)
|
||||
}
|
||||
@@ -414,19 +414,19 @@ impl From<execution_layer::Error> for ExecutionPayloadError {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: EthSpec> From<ExecutionPayloadError> for BlockError<T> {
|
||||
impl<E: EthSpec> From<ExecutionPayloadError> for BlockError<E> {
|
||||
fn from(e: ExecutionPayloadError) -> Self {
|
||||
BlockError::ExecutionPayloadError(e)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: EthSpec> From<InconsistentFork> for BlockError<T> {
|
||||
impl<E: EthSpec> From<InconsistentFork> for BlockError<E> {
|
||||
fn from(e: InconsistentFork) -> Self {
|
||||
BlockError::InconsistentFork(e)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: EthSpec> std::fmt::Display for BlockError<T> {
|
||||
impl<E: EthSpec> std::fmt::Display for BlockError<E> {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
BlockError::ParentUnknown(block) => {
|
||||
@@ -437,7 +437,7 @@ impl<T: EthSpec> std::fmt::Display for BlockError<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: EthSpec> From<BlockSignatureVerifierError> for BlockError<T> {
|
||||
impl<E: EthSpec> From<BlockSignatureVerifierError> for BlockError<E> {
|
||||
fn from(e: BlockSignatureVerifierError) -> Self {
|
||||
match e {
|
||||
// Make a special distinction for `IncorrectBlockProposer` since it indicates an
|
||||
@@ -454,31 +454,31 @@ impl<T: EthSpec> From<BlockSignatureVerifierError> for BlockError<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: EthSpec> From<BeaconChainError> for BlockError<T> {
|
||||
impl<E: EthSpec> From<BeaconChainError> for BlockError<E> {
|
||||
fn from(e: BeaconChainError) -> Self {
|
||||
BlockError::BeaconChainError(e)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: EthSpec> From<BeaconStateError> for BlockError<T> {
|
||||
impl<E: EthSpec> From<BeaconStateError> for BlockError<E> {
|
||||
fn from(e: BeaconStateError) -> Self {
|
||||
BlockError::BeaconChainError(BeaconChainError::BeaconStateError(e))
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: EthSpec> From<SlotProcessingError> for BlockError<T> {
|
||||
impl<E: EthSpec> From<SlotProcessingError> for BlockError<E> {
|
||||
fn from(e: SlotProcessingError) -> Self {
|
||||
BlockError::BeaconChainError(BeaconChainError::SlotProcessingError(e))
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: EthSpec> From<DBError> for BlockError<T> {
|
||||
impl<E: EthSpec> From<DBError> for BlockError<E> {
|
||||
fn from(e: DBError) -> Self {
|
||||
BlockError::BeaconChainError(BeaconChainError::DBError(e))
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: EthSpec> From<ArithError> for BlockError<T> {
|
||||
impl<E: EthSpec> From<ArithError> for BlockError<E> {
|
||||
fn from(e: ArithError) -> Self {
|
||||
BlockError::BeaconChainError(BeaconChainError::ArithError(e))
|
||||
}
|
||||
@@ -828,7 +828,7 @@ impl<T: BeaconChainTypes> GossipVerifiedBlock<T> {
|
||||
// already know this block.
|
||||
let fork_choice_read_lock = chain.canonical_head.fork_choice_read_lock();
|
||||
if fork_choice_read_lock.contains_block(&block_root) {
|
||||
return Err(BlockError::BlockIsAlreadyKnown);
|
||||
return Err(BlockError::BlockIsAlreadyKnown(block_root));
|
||||
}
|
||||
|
||||
// Do not process a block that doesn't descend from the finalized root.
|
||||
@@ -962,7 +962,7 @@ impl<T: BeaconChainTypes> GossipVerifiedBlock<T> {
|
||||
SeenBlock::Slashable => {
|
||||
return Err(BlockError::Slashable);
|
||||
}
|
||||
SeenBlock::Duplicate => return Err(BlockError::BlockIsAlreadyKnown),
|
||||
SeenBlock::Duplicate => return Err(BlockError::BlockIsAlreadyKnown(block_root)),
|
||||
SeenBlock::UniqueNonSlashable => {}
|
||||
};
|
||||
|
||||
@@ -1760,7 +1760,7 @@ pub fn check_block_relevancy<T: BeaconChainTypes>(
|
||||
.fork_choice_read_lock()
|
||||
.contains_block(&block_root)
|
||||
{
|
||||
return Err(BlockError::BlockIsAlreadyKnown);
|
||||
return Err(BlockError::BlockIsAlreadyKnown(block_root));
|
||||
}
|
||||
|
||||
Ok(block_root)
|
||||
@@ -2076,7 +2076,7 @@ pub fn verify_header_signature<T: BeaconChainTypes, Err: BlockBlobError>(
|
||||
}
|
||||
}
|
||||
|
||||
fn write_state<T: EthSpec>(prefix: &str, state: &BeaconState<T>, log: &Logger) {
|
||||
fn write_state<E: EthSpec>(prefix: &str, state: &BeaconState<E>, log: &Logger) {
|
||||
if WRITE_BLOCK_PROCESSING_SSZ {
|
||||
let root = state.tree_hash_root();
|
||||
let filename = format!("{}_slot_{}_root_{}.ssz", prefix, state.slot(), root);
|
||||
@@ -2098,7 +2098,7 @@ fn write_state<T: EthSpec>(prefix: &str, state: &BeaconState<T>, log: &Logger) {
|
||||
}
|
||||
}
|
||||
|
||||
fn write_block<T: EthSpec>(block: &SignedBeaconBlock<T>, root: Hash256, log: &Logger) {
|
||||
fn write_block<E: EthSpec>(block: &SignedBeaconBlock<E>, root: Hash256, log: &Logger) {
|
||||
if WRITE_BLOCK_PROCESSING_SSZ {
|
||||
let filename = format!("block_slot_{}_root{}.ssz", block.slot(), root);
|
||||
let mut path = std::env::temp_dir().join("lighthouse");
|
||||
|
||||
Reference in New Issue
Block a user