Skip to content
10 changes: 5 additions & 5 deletions beacon_node/beacon_chain/src/attestation_verification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,12 +267,12 @@ pub enum Error {
///
/// We were unable to process this attestation due to an internal error. It's unclear if the
/// attestation is valid.
BeaconChainError(Box<BeaconChainError>),
BeaconChainError(BeaconChainError),
}

impl From<BeaconChainError> for Error {
fn from(e: BeaconChainError) -> Self {
Self::BeaconChainError(Box::new(e))
Self::BeaconChainError(e)
}
}

Expand Down Expand Up @@ -533,7 +533,7 @@ impl<'a, T: BeaconChainTypes> IndexedAggregatedAttestation<'a, T> {
.observed_attestations
.write()
.is_known_subset(attestation, observed_attestation_key_root)
.map_err(|e| Error::BeaconChainError(Box::new(e.into())))?
.map_err(|e| Error::BeaconChainError(e.into()))?
{
metrics::inc_counter(&metrics::AGGREGATED_ATTESTATION_SUBSETS);
return Err(Error::AttestationSupersetKnown(
Expand Down Expand Up @@ -636,7 +636,7 @@ impl<'a, T: BeaconChainTypes> IndexedAggregatedAttestation<'a, T> {

if !SelectionProof::from(selection_proof)
.is_aggregator(committee.committee.len(), &chain.spec)
.map_err(|e| Error::BeaconChainError(Box::new(e.into())))?
.map_err(|e| Error::BeaconChainError(e.into()))?
{
return Err(Error::InvalidSelectionProof { aggregator_index });
}
Expand Down Expand Up @@ -706,7 +706,7 @@ impl<'a, T: BeaconChainTypes> VerifiedAggregatedAttestation<'a, T> {
.observed_attestations
.write()
.observe_item(attestation, Some(observed_attestation_key_root))
.map_err(|e| Error::BeaconChainError(Box::new(e.into())))?
.map_err(|e| Error::BeaconChainError(e.into()))?
{
metrics::inc_counter(&metrics::AGGREGATED_ATTESTATION_SUBSETS);
return Err(Error::AttestationSupersetKnown(
Expand Down
35 changes: 18 additions & 17 deletions beacon_node/beacon_chain/src/beacon_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2861,7 +2861,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
Err(error) => {
return ChainSegmentResult::Failed {
imported_blocks,
error: BlockError::BeaconChainError(error.into()),
error: BlockError::BeaconChainError(error),
}
}
};
Expand Down Expand Up @@ -2900,7 +2900,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
Err(error) => {
return ChainSegmentResult::Failed {
imported_blocks,
error: BlockError::BeaconChainError(error.into()),
error: BlockError::BeaconChainError(error),
};
}
};
Expand Down Expand Up @@ -3479,8 +3479,8 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
Ok(status)
}
Err(BlockError::BeaconChainError(e)) => {
match e.as_ref() {
BeaconChainError::TokioJoin(e) => {
match e {
BeaconChainError::TokioJoin(ref e) => {
debug!(
error = ?e,
"Beacon block processing cancelled"
Expand Down Expand Up @@ -3628,7 +3628,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
header.message.proposer_index,
block_root,
)
.map_err(|e| BlockError::BeaconChainError(Box::new(e.into())))?;
.map_err(|e| BlockError::BeaconChainError(e.into()))?;
if let Some(slasher) = self.slasher.as_ref() {
slasher.accept_block_header(header);
}
Expand Down Expand Up @@ -3724,7 +3724,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
header.message.proposer_index,
block_root,
)
.map_err(|e| BlockError::BeaconChainError(Box::new(e.into())))?;
.map_err(|e| BlockError::BeaconChainError(e.into()))?;
if let Some(slasher) = self.slasher.as_ref() {
slasher.accept_block_header(header);
}
Expand Down Expand Up @@ -3904,7 +3904,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
payload_verification_status,
&self.spec,
)
.map_err(|e| BlockError::BeaconChainError(Box::new(e.into())))?;
.map_err(|e| BlockError::BeaconChainError(e.into()))?;
}

// If the block is recent enough and it was not optimistically imported, check to see if it
Expand Down Expand Up @@ -4097,7 +4097,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
warning = "The database is likely corrupt now, consider --purge-db",
"No stored fork choice found to restore from"
);
Err(BlockError::BeaconChainError(Box::new(e)))
Err(BlockError::BeaconChainError(e))
} else {
Ok(())
}
Expand Down Expand Up @@ -4152,9 +4152,9 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
Provided block root is not a checkpoint.",
))
.map_err(|err| {
BlockError::BeaconChainError(Box::new(
BlockError::BeaconChainError(
BeaconChainError::WeakSubjectivtyShutdownError(err),
))
)
})?;
return Err(BlockError::WeakSubjectivityConflict);
}
Expand Down Expand Up @@ -5220,16 +5220,16 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
.validators()
.get(proposer_index as usize)
.map(|v| v.pubkey)
.ok_or(BlockProductionError::BeaconChain(Box::new(
.ok_or(BlockProductionError::BeaconChain(
BeaconChainError::ValidatorIndexUnknown(proposer_index as usize),
)))?;
))?;

let builder_params = BuilderParams {
pubkey,
slot: state.slot(),
chain_health: self
.is_healthy(&parent_root)
.map_err(|e| BlockProductionError::BeaconChain(Box::new(e)))?,
.map_err(BlockProductionError::BeaconChain)?,
};

// If required, start the process of loading an execution payload from the EL early. This
Expand Down Expand Up @@ -6198,11 +6198,12 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
.await
{
// We are a proposer, check for terminal_pow_block_hash
if let Some(terminal_pow_block_hash) = execution_layer
let terminal_pow_block_hash_opt = execution_layer
.get_terminal_pow_block_hash(&self.spec, payload_attributes.timestamp())
.await
.map_err(Error::ForkchoiceUpdate)?
{
.map_err(|e| Error::ForkchoiceUpdate(Box::new(e)))?;

if let Some(terminal_pow_block_hash) = terminal_pow_block_hash_opt {
info!(
slot = %next_slot,
"Prepared POS transition block proposer"
Expand Down Expand Up @@ -6239,7 +6240,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
head_block_root,
)
.await
.map_err(Error::ExecutionForkChoiceUpdateFailed);
.map_err(|e| Error::ExecutionForkChoiceUpdateFailed(Box::new(e)));

// The head has been read and the execution layer has been updated. It is now valid to send
// another fork choice update.
Expand Down
14 changes: 7 additions & 7 deletions beacon_node/beacon_chain/src/blob_verification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub enum GossipBlobError {
///
/// We were unable to process this blob due to an internal error. It's
/// unclear if the blob is valid.
BeaconChainError(Box<BeaconChainError>),
BeaconChainError(BeaconChainError),

/// The `BlobSidecar` was gossiped over an incorrect subnet.
///
Expand Down Expand Up @@ -147,13 +147,13 @@ impl std::fmt::Display for GossipBlobError {

impl From<BeaconChainError> for GossipBlobError {
fn from(e: BeaconChainError) -> Self {
GossipBlobError::BeaconChainError(e.into())
GossipBlobError::BeaconChainError(e)
}
}

impl From<BeaconStateError> for GossipBlobError {
fn from(e: BeaconStateError) -> Self {
GossipBlobError::BeaconChainError(BeaconChainError::BeaconStateError(e).into())
GossipBlobError::BeaconChainError(BeaconChainError::BeaconStateError(e))
}
}

Expand Down Expand Up @@ -444,7 +444,7 @@ pub fn validate_blob_sidecar_for_gossip<T: BeaconChainTypes, O: ObservationStrat
.observed_blob_sidecars
.read()
.proposer_is_known(&blob_sidecar)
.map_err(|e| GossipBlobError::BeaconChainError(Box::new(e.into())))?
.map_err(|e| GossipBlobError::BeaconChainError(e.into()))?
{
return Err(GossipBlobError::RepeatBlob {
proposer: blob_proposer_index,
Expand Down Expand Up @@ -509,7 +509,7 @@ pub fn validate_blob_sidecar_for_gossip<T: BeaconChainTypes, O: ObservationStrat
let (parent_state_root, mut parent_state) = chain
.store
.get_advanced_hot_state(block_parent_root, blob_slot, parent_block.state_root)
.map_err(|e| GossipBlobError::BeaconChainError(Box::new(e.into())))?
.map_err(|e| GossipBlobError::BeaconChainError(e.into()))?
.ok_or_else(|| {
BeaconChainError::DBInconsistent(format!(
"Missing state for parent block {block_parent_root:?}",
Expand Down Expand Up @@ -581,7 +581,7 @@ pub fn validate_blob_sidecar_for_gossip<T: BeaconChainTypes, O: ObservationStrat
blob_sidecar.block_proposer_index(),
block_root,
)
.map_err(|e| GossipBlobError::BeaconChainError(Box::new(e.into())))?;
.map_err(|e| GossipBlobError::BeaconChainError(e.into()))?;

if O::observe() {
observe_gossip_blob(&kzg_verified_blob.blob, chain)?;
Expand Down Expand Up @@ -627,7 +627,7 @@ fn observe_gossip_blob<T: BeaconChainTypes>(
.observed_blob_sidecars
.write()
.observe_sidecar(blob_sidecar)
.map_err(|e| GossipBlobError::BeaconChainError(Box::new(e.into())))?
.map_err(|e| GossipBlobError::BeaconChainError(e.into()))?
{
return Err(GossipBlobError::RepeatBlob {
proposer: blob_sidecar.block_proposer_index(),
Expand Down
30 changes: 14 additions & 16 deletions beacon_node/beacon_chain/src/block_verification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ pub enum BlockError {
///
/// We were unable to process this block due to an internal error. It's unclear if the block is
/// valid.
BeaconChainError(Box<BeaconChainError>),
BeaconChainError(BeaconChainError),
/// There was an error whilst verifying weak subjectivity. This block conflicts with the
/// configured weak subjectivity checkpoint and was not imported.
///
Expand Down Expand Up @@ -484,40 +484,38 @@ impl From<BlockSignatureVerifierError> for BlockError {
block,
local_shuffling,
},
e => BlockError::BeaconChainError(
BeaconChainError::BlockSignatureVerifierError(e).into(),
),
e => BlockError::BeaconChainError(BeaconChainError::BlockSignatureVerifierError(e)),
}
}
}

impl From<BeaconChainError> for BlockError {
fn from(e: BeaconChainError) -> Self {
BlockError::BeaconChainError(e.into())
BlockError::BeaconChainError(e)
}
}

impl From<BeaconStateError> for BlockError {
fn from(e: BeaconStateError) -> Self {
BlockError::BeaconChainError(BeaconChainError::BeaconStateError(e).into())
BlockError::BeaconChainError(BeaconChainError::BeaconStateError(e))
}
}

impl From<SlotProcessingError> for BlockError {
fn from(e: SlotProcessingError) -> Self {
BlockError::BeaconChainError(BeaconChainError::SlotProcessingError(e).into())
BlockError::BeaconChainError(BeaconChainError::SlotProcessingError(e))
}
}

impl From<DBError> for BlockError {
fn from(e: DBError) -> Self {
BlockError::BeaconChainError(BeaconChainError::DBError(e).into())
BlockError::BeaconChainError(BeaconChainError::DBError(e))
}
}

impl From<ArithError> for BlockError {
fn from(e: ArithError) -> Self {
BlockError::BeaconChainError(BeaconChainError::ArithError(e).into())
BlockError::BeaconChainError(BeaconChainError::ArithError(e))
}
}

Expand Down Expand Up @@ -1019,7 +1017,7 @@ impl<T: BeaconChainTypes> GossipVerifiedBlock<T> {
.observed_slashable
.write()
.observe_slashable(block.slot(), block.message().proposer_index(), block_root)
.map_err(|e| BlockError::BeaconChainError(Box::new(e.into())))?;
.map_err(|e| BlockError::BeaconChainError(e.into()))?;
// Now the signature is valid, store the proposal so we don't accept another from this
// validator and slot.
//
Expand All @@ -1029,7 +1027,7 @@ impl<T: BeaconChainTypes> GossipVerifiedBlock<T> {
.observed_block_producers
.write()
.observe_proposal(block_root, block.message())
.map_err(|e| BlockError::BeaconChainError(Box::new(e.into())))?
.map_err(|e| BlockError::BeaconChainError(e.into()))?
{
SeenBlock::Slashable => {
return Err(BlockError::Slashable);
Expand Down Expand Up @@ -1338,13 +1336,13 @@ impl<T: BeaconChainTypes> ExecutionPendingBlock<T> {
.observed_slashable
.write()
.observe_slashable(block.slot(), block.message().proposer_index(), block_root)
.map_err(|e| BlockError::BeaconChainError(Box::new(e.into())))?;
.map_err(|e| BlockError::BeaconChainError(e.into()))?;

chain
.observed_block_producers
.write()
.observe_proposal(block_root, block.message())
.map_err(|e| BlockError::BeaconChainError(Box::new(e.into())))?;
.map_err(|e| BlockError::BeaconChainError(e.into()))?;

if let Some(parent) = chain
.canonical_head
Expand Down Expand Up @@ -1654,7 +1652,7 @@ impl<T: BeaconChainTypes> ExecutionPendingBlock<T> {
// Ignore invalid attestations whilst importing attestations from a block. The
// block might be very old and therefore the attestations useless to fork choice.
Err(ForkChoiceError::InvalidAttestation(_)) => Ok(()),
Err(e) => Err(BlockError::BeaconChainError(Box::new(e.into()))),
Err(e) => Err(BlockError::BeaconChainError(e.into())),
}?;
}
drop(fork_choice);
Expand Down Expand Up @@ -1745,7 +1743,7 @@ pub fn check_block_is_finalized_checkpoint_or_descendant<
if chain
.store
.block_exists(&block.parent_root())
.map_err(|e| BlockError::BeaconChainError(Box::new(e.into())))?
.map_err(|e| BlockError::BeaconChainError(e.into()))?
{
Err(BlockError::NotFinalizedDescendant {
block_parent_root: block.parent_root(),
Expand Down Expand Up @@ -1890,7 +1888,7 @@ fn load_parent<T: BeaconChainTypes, B: AsBlock<T::EthSpec>>(
let root = block.parent_root();
let parent_block = chain
.get_blinded_block(&block.parent_root())
.map_err(|e| BlockError::BeaconChainError(Box::new(e)))?
.map_err(BlockError::BeaconChainError)?
.ok_or_else(|| {
// Return a `MissingBeaconBlock` error instead of a `ParentUnknown` error since
// we've already checked fork choice for this block.
Expand Down
Loading
Loading