Satisfy Clippy, remove non-tree-states code

This commit is contained in:
Michael Sproul
2022-03-28 11:42:55 +11:00
parent 705cba6443
commit c5212d0f98
45 changed files with 129 additions and 1153 deletions

View File

@@ -217,15 +217,11 @@ where
pre_block_hook(&mut self.state, block)?;
}
let verify_block_root = self.verify_block_root.unwrap_or_else(|| {
// If no explicit policy is set, verify only the first 1 or 2 block roots if using
// accurate state roots. Inaccurate state roots require block root verification to
// be off.
if i <= 1 {
VerifyBlockRoot::True
} else {
VerifyBlockRoot::False
}
// If no explicit policy is set, verify only the first 1 or 2 block roots.
let verify_block_root = self.verify_block_root.unwrap_or(if i <= 1 {
VerifyBlockRoot::True
} else {
VerifyBlockRoot::False
});
let mut ctxt = ConsensusContext::new(block.slot());
per_block_processing(

View File

@@ -72,7 +72,6 @@ pub enum BlockProcessingError {
},
ExecutionInvalid,
ConsensusContext(ContextError),
#[cfg(feature = "milhouse")]
MilhouseError(milhouse::Error),
}
@@ -112,7 +111,6 @@ impl From<ContextError> for BlockProcessingError {
}
}
#[cfg(feature = "milhouse")]
impl From<milhouse::Error> for BlockProcessingError {
fn from(e: milhouse::Error) -> Self {
Self::MilhouseError(e)

View File

@@ -7,8 +7,8 @@ use crate::per_block_processing::errors::{
ProposerSlashingInvalid,
};
use crate::{
per_block_processing::process_operations, BlockSignatureStrategy, VerifyBlockRoot,
VerifySignatures,
per_block_processing::process_operations, BlockSignatureStrategy, ConsensusContext,
VerifyBlockRoot, VerifySignatures,
};
use beacon_chain::test_utils::{BeaconChainHarness, EphemeralHarnessType};
use lazy_static::lazy_static;
@@ -63,12 +63,13 @@ fn valid_block_ok() {
let slot = state.slot();
let (block, mut state) = harness.make_block_return_pre_state(state, slot + Slot::new(1));
let mut ctxt = ConsensusContext::new(block.slot());
let result = per_block_processing(
&mut state,
&block,
None,
BlockSignatureStrategy::VerifyIndividual,
VerifyBlockRoot::True,
&mut ctxt,
&spec,
);
@@ -87,12 +88,13 @@ fn invalid_block_header_state_slot() {
let (mut block, signature) = signed_block.deconstruct();
*block.slot_mut() = slot + Slot::new(1);
let mut ctxt = ConsensusContext::new(block.slot());
let result = per_block_processing(
&mut state,
&SignedBeaconBlock::from_block(block, signature),
None,
BlockSignatureStrategy::VerifyIndividual,
VerifyBlockRoot::True,
&mut ctxt,
&spec,
);
@@ -116,12 +118,13 @@ fn invalid_parent_block_root() {
let (mut block, signature) = signed_block.deconstruct();
*block.parent_root_mut() = Hash256::from([0xAA; 32]);
let mut ctxt = ConsensusContext::new(block.slot());
let result = per_block_processing(
&mut state,
&SignedBeaconBlock::from_block(block, signature),
None,
BlockSignatureStrategy::VerifyIndividual,
VerifyBlockRoot::True,
&mut ctxt,
&spec,
);
@@ -146,12 +149,13 @@ fn invalid_block_signature() {
let (signed_block, mut state) = harness.make_block_return_pre_state(state, slot + Slot::new(1));
let (block, _) = signed_block.deconstruct();
let mut ctxt = ConsensusContext::new(block.slot());
let result = per_block_processing(
&mut state,
&SignedBeaconBlock::from_block(block, Signature::empty()),
None,
BlockSignatureStrategy::VerifyIndividual,
VerifyBlockRoot::True,
&mut ctxt,
&spec,
);
@@ -176,12 +180,13 @@ fn invalid_randao_reveal_signature() {
*block.body_mut().randao_reveal_mut() = Signature::empty();
});
let mut ctxt = ConsensusContext::new(signed_block.slot());
let result = per_block_processing(
&mut state,
&signed_block,
None,
BlockSignatureStrategy::VerifyIndividual,
VerifyBlockRoot::True,
&mut ctxt,
&spec,
);

View File

@@ -1,8 +1,5 @@
use crate::per_epoch_processing::altair::participation_cache::Error as ParticipationCacheError;
use types::{BeaconStateError, InconsistentFork};
#[cfg(feature = "milhouse")]
use types::milhouse;
use types::{milhouse, BeaconStateError, InconsistentFork};
#[derive(Debug, PartialEq)]
pub enum EpochProcessingError {
@@ -28,7 +25,6 @@ pub enum EpochProcessingError {
InvalidJustificationBit(ssz_types::Error),
InvalidFlagIndex(usize),
ParticipationCache(ParticipationCacheError),
#[cfg(feature = "milhouse")]
MilhouseError(milhouse::Error),
}
@@ -62,7 +58,6 @@ impl From<ParticipationCacheError> for EpochProcessingError {
}
}
#[cfg(feature = "milhouse")]
impl From<milhouse::Error> for EpochProcessingError {
fn from(e: milhouse::Error) -> Self {
Self::MilhouseError(e)

View File

@@ -104,8 +104,6 @@ pub fn upgrade_to_altair<E: EthSpec>(
committee_caches: mem::take(&mut pre.committee_caches),
pubkey_cache: mem::take(&mut pre.pubkey_cache),
exit_cache: mem::take(&mut pre.exit_cache),
#[cfg(not(feature = "milhouse"))]
tree_hash_cache: mem::take(&mut pre.tree_hash_cache),
});
// Fill in previous epoch participation from the pre state's pending attestations.

View File

@@ -63,8 +63,6 @@ pub fn upgrade_to_bellatrix<E: EthSpec>(
committee_caches: mem::take(&mut pre.committee_caches),
pubkey_cache: mem::take(&mut pre.pubkey_cache),
exit_cache: mem::take(&mut pre.exit_cache),
#[cfg(not(feature = "milhouse"))]
tree_hash_cache: mem::take(&mut pre.tree_hash_cache),
});
*pre_state = post;