mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-18 12:22:51 +00:00
Implement ConsensusContext
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
use super::signature_sets::Error as SignatureSetError;
|
||||
use crate::ContextError;
|
||||
use merkle_proof::MerkleTreeError;
|
||||
use safe_arith::ArithError;
|
||||
use types::*;
|
||||
@@ -70,6 +71,7 @@ pub enum BlockProcessingError {
|
||||
found: u64,
|
||||
},
|
||||
ExecutionInvalid,
|
||||
ConsensusContext(ContextError),
|
||||
#[cfg(feature = "milhouse")]
|
||||
MilhouseError(milhouse::Error),
|
||||
}
|
||||
@@ -104,6 +106,12 @@ impl From<SyncAggregateInvalid> for BlockProcessingError {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<ContextError> for BlockProcessingError {
|
||||
fn from(e: ContextError) -> Self {
|
||||
BlockProcessingError::ConsensusContext(e)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "milhouse")]
|
||||
impl From<milhouse::Error> for BlockProcessingError {
|
||||
fn from(e: milhouse::Error) -> Self {
|
||||
@@ -118,6 +126,7 @@ impl From<BlockOperationError<HeaderInvalid>> for BlockProcessingError {
|
||||
BlockOperationError::BeaconStateError(e) => BlockProcessingError::BeaconStateError(e),
|
||||
BlockOperationError::SignatureSetError(e) => BlockProcessingError::SignatureSetError(e),
|
||||
BlockOperationError::SszTypesError(e) => BlockProcessingError::SszTypesError(e),
|
||||
BlockOperationError::ConsensusContext(e) => BlockProcessingError::ConsensusContext(e),
|
||||
BlockOperationError::ArithError(e) => BlockProcessingError::ArithError(e),
|
||||
}
|
||||
}
|
||||
@@ -145,6 +154,7 @@ macro_rules! impl_into_block_processing_error_with_index {
|
||||
BlockOperationError::BeaconStateError(e) => BlockProcessingError::BeaconStateError(e),
|
||||
BlockOperationError::SignatureSetError(e) => BlockProcessingError::SignatureSetError(e),
|
||||
BlockOperationError::SszTypesError(e) => BlockProcessingError::SszTypesError(e),
|
||||
BlockOperationError::ConsensusContext(e) => BlockProcessingError::ConsensusContext(e),
|
||||
BlockOperationError::ArithError(e) => BlockProcessingError::ArithError(e),
|
||||
}
|
||||
}
|
||||
@@ -176,6 +186,7 @@ pub enum BlockOperationError<T> {
|
||||
BeaconStateError(BeaconStateError),
|
||||
SignatureSetError(SignatureSetError),
|
||||
SszTypesError(ssz_types::Error),
|
||||
ConsensusContext(ContextError),
|
||||
ArithError(ArithError),
|
||||
}
|
||||
|
||||
@@ -208,6 +219,12 @@ impl<T> From<ArithError> for BlockOperationError<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> From<ContextError> for BlockOperationError<T> {
|
||||
fn from(e: ContextError) -> Self {
|
||||
BlockOperationError::ConsensusContext(e)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Clone)]
|
||||
pub enum HeaderInvalid {
|
||||
ProposalSignatureInvalid,
|
||||
@@ -217,14 +234,14 @@ pub enum HeaderInvalid {
|
||||
block_slot: Slot,
|
||||
},
|
||||
ProposerIndexMismatch {
|
||||
block_proposer_index: usize,
|
||||
state_proposer_index: usize,
|
||||
block_proposer_index: u64,
|
||||
state_proposer_index: u64,
|
||||
},
|
||||
ParentBlockRootMismatch {
|
||||
state: Hash256,
|
||||
block: Hash256,
|
||||
},
|
||||
ProposerSlashed(usize),
|
||||
ProposerSlashed(u64),
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Clone)]
|
||||
@@ -319,6 +336,7 @@ impl From<BlockOperationError<IndexedAttestationInvalid>>
|
||||
BlockOperationError::BeaconStateError(e) => BlockOperationError::BeaconStateError(e),
|
||||
BlockOperationError::SignatureSetError(e) => BlockOperationError::SignatureSetError(e),
|
||||
BlockOperationError::SszTypesError(e) => BlockOperationError::SszTypesError(e),
|
||||
BlockOperationError::ConsensusContext(e) => BlockOperationError::ConsensusContext(e),
|
||||
BlockOperationError::ArithError(e) => BlockOperationError::ArithError(e),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user