From 5ce14c8dcebeca2699cffd03cdf3456f1cf4cf6a Mon Sep 17 00:00:00 2001 From: Michael Sproul Date: Tue, 17 Jan 2023 15:57:34 +1100 Subject: [PATCH] Fix ups and Clippy --- Cargo.lock | 59 +++++++++---------- Cargo.toml | 3 - beacon_node/beacon_chain/src/beacon_chain.rs | 7 ++- .../src/beacon_fork_choice_store.rs | 4 -- .../beacon_chain/src/block_verification.rs | 11 ++-- beacon_node/store/Cargo.toml | 3 +- beacon_node/store/src/hot_cold_store.rs | 3 + beacon_node/store/src/impls/beacon_state.rs | 2 +- beacon_node/store/src/state_cache.rs | 2 +- .../store/src/validator_pubkey_cache.rs | 20 +++---- .../proto_array/src/justified_balances.rs | 4 +- .../altair/participation_cache.rs | 2 +- consensus/types/src/beacon_state.rs | 3 +- consensus/types/src/beacon_state/tests.rs | 5 +- consensus/types/src/chain_spec.rs | 2 +- .../types/src/light_client_finality_update.rs | 1 + consensus/types/src/light_client_update.rs | 7 +++ consensus/types/src/validator.rs | 9 +++ lcli/src/transition_blocks.rs | 3 +- .../ef_tests/src/cases/epoch_processing.rs | 4 +- testing/ef_tests/src/cases/operations.rs | 6 +- testing/state_transition_vectors/src/exit.rs | 11 ++-- 22 files changed, 92 insertions(+), 79 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9ab961a7bf..04cf3d0fea 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -614,7 +614,7 @@ dependencies = [ "task_executor", "tempfile", "tokio", - "tree_hash 0.4.1", + "tree_hash", "types", "unused_port", ] @@ -761,6 +761,7 @@ version = "0.2.0" dependencies = [ "arbitrary", "blst", + "criterion", "ethereum-types 0.14.1", "ethereum_hashing", "ethereum_serde_utils", @@ -770,7 +771,7 @@ dependencies = [ "rand 0.8.5", "serde", "serde_derive", - "tree_hash 0.4.1", + "tree_hash", "zeroize", ] @@ -1632,7 +1633,7 @@ dependencies = [ "reqwest", "serde_json", "sha2 0.10.6", - "tree_hash 0.4.1", + "tree_hash", "types", ] @@ -1925,7 +1926,7 @@ dependencies = [ "state_processing", "store", "swap_or_not_shuffle", - "tree_hash 0.4.1", + "tree_hash", "tree_hash_derive", "types", ] @@ -2081,7 +2082,7 @@ dependencies = [ "superstruct", "task_executor", "tokio", - "tree_hash 0.4.1", + "tree_hash", "types", "web3", ] @@ -2360,9 +2361,9 @@ dependencies = [ [[package]] name = "ethereum_ssz" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29d6b56a74d435691764a6e8b635dab1cca4fcf15d7ec8f265c73d3b98cdd889" +checksum = "8012d097c5b4f4915c84c672a397a2ca4124e1900737f1393b3ba0c87d8fa489" dependencies = [ "ethereum-types 0.14.1", "itertools", @@ -2371,9 +2372,9 @@ dependencies = [ [[package]] name = "ethereum_ssz_derive" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44f51ce7a63b03c9ee2ea8e0e7078e948846dc227331e50fa2124c0fa872b1fc" +checksum = "9f421142049c25d52d7c38124af054e235f4898355282069ef37e4d031565fb8" dependencies = [ "darling 0.13.4", "proc-macro2", @@ -2514,7 +2515,7 @@ dependencies = [ "tempfile", "tokio", "tokio-stream", - "tree_hash 0.4.1", + "tree_hash", "tree_hash_derive", "triehash", "types", @@ -2864,7 +2865,7 @@ dependencies = [ "slog", "state_processing", "tokio", - "tree_hash 0.4.1", + "tree_hash", "types", ] @@ -3230,7 +3231,7 @@ dependencies = [ "task_executor", "tokio", "tokio-stream", - "tree_hash 0.4.1", + "tree_hash", "types", "unused_port", "warp", @@ -3739,7 +3740,7 @@ dependencies = [ "snap", "state_processing", "store", - "tree_hash 0.4.1", + "tree_hash", "types", "validator_dir", "web3", @@ -4701,7 +4702,7 @@ dependencies = [ "rayon", "serde", "smallvec", - "tree_hash 0.5.0", + "tree_hash", "triomphe", "typenum", "vec_map", @@ -7078,7 +7079,7 @@ dependencies = [ "sloggers", "strum", "tempfile", - "tree_hash 0.4.1", + "tree_hash", "tree_hash_derive", "types", ] @@ -7341,6 +7342,12 @@ dependencies = [ "typenum", ] +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + [[package]] name = "state_processing" version = "0.2.0" @@ -7365,7 +7372,7 @@ dependencies = [ "smallvec", "ssz_types", "tokio", - "tree_hash 0.4.1", + "tree_hash", "types", "vec_map", ] @@ -7402,6 +7409,7 @@ dependencies = [ "lazy_static", "leveldb", "lighthouse_metrics", + "logging", "lru 0.7.8", "parking_lot 0.12.1", "safe_arith", @@ -7414,7 +7422,7 @@ dependencies = [ "strum", "take-until", "tempfile", - "tree_hash 0.4.1", + "tree_hash", "types", "zstd", ] @@ -8138,17 +8146,6 @@ dependencies = [ "smallvec", ] -[[package]] -name = "tree_hash" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87bb13ce6641dabdb9983d3cadd77d9320eb81102abeb15220eb98db12d58eb6" -dependencies = [ - "ethereum-types 0.14.1", - "ethereum_hashing", - "smallvec", -] - [[package]] name = "tree_hash_derive" version = "0.5.0" @@ -8355,7 +8352,7 @@ dependencies = [ "tempfile", "test_random_derive", "tokio", - "tree_hash 0.4.1", + "tree_hash", "tree_hash_derive", ] @@ -8549,7 +8546,7 @@ dependencies = [ "task_executor", "tempfile", "tokio", - "tree_hash 0.4.1", + "tree_hash", "types", "url", "validator_dir", @@ -8570,7 +8567,7 @@ dependencies = [ "lockfile", "rand 0.8.5", "tempfile", - "tree_hash 0.4.1", + "tree_hash", "types", ] diff --git a/Cargo.toml b/Cargo.toml index 3f43dda680..0e1b8e70d7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -87,9 +87,6 @@ members = [ fixed-hash = { git = "https://github.com/paritytech/parity-common", rev="df638ab0885293d21d656dc300d39236b69ce57d" } warp = { git = "https://github.com/macladson/warp", rev="7e75acc368229a46a236a8c991bf251fe7fe50ef" } -[patch."https://github.com/sigp/milhouse"] -milhouse = { path = "../milhouse" } - [profile.maxperf] inherits = "release" lto = "fat" diff --git a/beacon_node/beacon_chain/src/beacon_chain.rs b/beacon_node/beacon_chain/src/beacon_chain.rs index de0b235471..8ed0c4563d 100644 --- a/beacon_node/beacon_chain/src/beacon_chain.rs +++ b/beacon_node/beacon_chain/src/beacon_chain.rs @@ -3456,7 +3456,8 @@ impl BeaconChain { }; let (state, state_root_opt) = if head_slot < slot { // Attempt an aggressive re-org if configured and the conditions are right. - if let Some(re_org_state) = self.get_state_for_re_org(slot, head_slot, head_block_root) + if let Some((re_org_state, re_org_state_root)) = + self.get_state_for_re_org(slot, head_slot, head_block_root) { info!( self.log, @@ -3464,7 +3465,7 @@ impl BeaconChain { "slot" => slot, "head_to_reorg" => %head_block_root, ); - (re_org_state.pre_state, re_org_state.state_root) + (re_org_state, Some(re_org_state_root)) } else { // Fetch the head state advanced through to `slot`, which should be present in the // state cache thanks to the state advance timer. @@ -3594,7 +3595,7 @@ impl BeaconChain { "Error loading block production state"; "error" => ?e, ); - ) + }) .ok()??; info!( diff --git a/beacon_node/beacon_chain/src/beacon_fork_choice_store.rs b/beacon_node/beacon_chain/src/beacon_fork_choice_store.rs index 90ce70617e..b76a4dca68 100644 --- a/beacon_node/beacon_chain/src/beacon_fork_choice_store.rs +++ b/beacon_node/beacon_chain/src/beacon_fork_choice_store.rs @@ -192,11 +192,7 @@ where balances_cache: <_>::default(), time: anchor_state.slot(), justified_checkpoint, -<<<<<<< HEAD - justified_balances: anchor_state.balances().to_vec(), -======= justified_balances, ->>>>>>> origin/unstable finalized_checkpoint, best_justified_checkpoint: justified_checkpoint, unrealized_justified_checkpoint: justified_checkpoint, diff --git a/beacon_node/beacon_chain/src/block_verification.rs b/beacon_node/beacon_chain/src/block_verification.rs index 902f0f7af6..623b025bc1 100644 --- a/beacon_node/beacon_chain/src/block_verification.rs +++ b/beacon_node/beacon_chain/src/block_verification.rs @@ -530,7 +530,7 @@ pub fn signature_verify_chain_segment( } let (first_root, first_block) = chain_segment.remove(0); - let (mut parent, first_block) = load_parent(first_root, first_block, chain)?; + let (mut parent, first_block) = load_parent(first_block, chain)?; let slot = first_block.slot(); chain_segment.insert(0, (first_root, first_block)); @@ -795,7 +795,7 @@ impl GossipVerifiedBlock { } else { // The proposer index was *not* cached and we must load the parent in order to determine // the proposer index. - let (mut parent, block) = load_parent(block_root, block, chain)?; + let (mut parent, block) = load_parent(block, chain)?; debug!( chain.log, @@ -933,7 +933,7 @@ impl SignatureVerifiedBlock { // Check the anchor slot before loading the parent, to avoid spurious lookups. check_block_against_anchor_slot(block.message(), chain)?; - let (mut parent, block) = load_parent(block_root, block, chain)?; + let (mut parent, block) = load_parent(block, chain)?; // Reject any block that exceeds our limit on skipped slots. check_block_skip_slots(chain, parent.beacon_block.slot(), block.message())?; @@ -986,7 +986,7 @@ impl SignatureVerifiedBlock { let (mut parent, block) = if let Some(parent) = from.parent { (parent, from.block) } else { - load_parent(from.block_root, from.block, chain)? + load_parent(from.block, chain)? }; let state = cheap_state_advance_to_obtain_committees( @@ -1046,7 +1046,7 @@ impl IntoExecutionPendingBlock for SignatureVerifiedBloc let (parent, block) = if let Some(parent) = self.parent { (parent, self.block) } else { - load_parent(self.block_root, self.block, chain) + load_parent(self.block, chain) .map_err(|e| BlockSlashInfo::SignatureValid(header.clone(), e))? }; @@ -1655,7 +1655,6 @@ fn verify_parent_block_is_known( /// whilst attempting the operation. #[allow(clippy::type_complexity)] fn load_parent( - block_root: Hash256, block: Arc>, chain: &BeaconChain, ) -> Result< diff --git a/beacon_node/store/Cargo.toml b/beacon_node/store/Cargo.toml index 8ca84513a0..9cccaf64b6 100644 --- a/beacon_node/store/Cargo.toml +++ b/beacon_node/store/Cargo.toml @@ -7,6 +7,7 @@ edition = "2021" [dev-dependencies] tempfile = "3.1.0" beacon_chain = {path = "../beacon_chain"} +logging = { path = "../../common/logging" } [dependencies] db-key = "0.0.5" @@ -26,7 +27,7 @@ lighthouse_metrics = { path = "../../common/lighthouse_metrics" } lru = "0.7.1" sloggers = { version = "2.1.1", features = ["json"] } directory = { path = "../../common/directory" } -tree_hash = "0.4.0" +tree_hash = "0.5.0" take-until = "0.1.0" zstd = "0.11.0" strum = { version = "0.24.0", features = ["derive"] } diff --git a/beacon_node/store/src/hot_cold_store.rs b/beacon_node/store/src/hot_cold_store.rs index 797135fd0f..f06e3747d0 100644 --- a/beacon_node/store/src/hot_cold_store.rs +++ b/beacon_node/store/src/hot_cold_store.rs @@ -1729,6 +1729,7 @@ impl, Cold: ItemStore> HotColdDB } /// Load the state root of a restore point. + #[allow(unused)] fn load_restore_point_hash(&self, restore_point_index: u64) -> Result { let key = Self::restore_point_key(restore_point_index); self.cold_db @@ -1738,6 +1739,7 @@ impl, Cold: ItemStore> HotColdDB } /// Store the state root of a restore point. + #[allow(unused)] fn store_restore_point_hash( &self, restore_point_index: u64, @@ -1751,6 +1753,7 @@ impl, Cold: ItemStore> HotColdDB } /// Convert a `restore_point_index` into a database key. + #[allow(unused)] fn restore_point_key(restore_point_index: u64) -> Hash256 { Hash256::from_low_u64_be(restore_point_index) } diff --git a/beacon_node/store/src/impls/beacon_state.rs b/beacon_node/store/src/impls/beacon_state.rs index 5ebb0dbd18..7f0eb05d7c 100644 --- a/beacon_node/store/src/impls/beacon_state.rs +++ b/beacon_node/store/src/impls/beacon_state.rs @@ -1,5 +1,5 @@ use crate::*; -use ssz::{DecodeError, Encode}; +use ssz::Encode; use ssz_derive::Encode; use std::io::{Read, Write}; use std::sync::Arc; diff --git a/beacon_node/store/src/state_cache.rs b/beacon_node/store/src/state_cache.rs index 7ebbc4dd52..babb19224e 100644 --- a/beacon_node/store/src/state_cache.rs +++ b/beacon_node/store/src/state_cache.rs @@ -146,7 +146,7 @@ impl StateCache { .iter() .rev() .find_map(|(ancestor_slot, state_root)| { - (*ancestor_slot <= slot).then(|| *state_root) + (*ancestor_slot <= slot).then_some(*state_root) })?; let state = self.get_by_state_root(state_root)?; diff --git a/beacon_node/store/src/validator_pubkey_cache.rs b/beacon_node/store/src/validator_pubkey_cache.rs index 663ca02c2d..daf6ea78c4 100644 --- a/beacon_node/store/src/validator_pubkey_cache.rs +++ b/beacon_node/store/src/validator_pubkey_cache.rs @@ -218,6 +218,7 @@ impl DatabaseValidator { } } + #[allow(clippy::wrong_self_convention)] fn into_immutable_validator(&self) -> Result<(PublicKey, ValidatorImmutable), Error> { let pubkey = PublicKey::deserialize_uncompressed(&self.pubkey) .map_err(Error::InvalidValidatorPubkeyBytes)?; @@ -236,14 +237,14 @@ impl DatabaseValidator { #[cfg(test)] mod test { use super::*; - use crate::test_utils::{BeaconChainHarness, EphemeralHarnessType}; + use crate::{HotColdDB, KeyValueStore, MemoryStore}; + use beacon_chain::test_utils::BeaconChainHarness; use logging::test_logger; use std::sync::Arc; - use store::HotColdDB; use types::{BeaconState, EthSpec, Keypair, MainnetEthSpec}; type E = MainnetEthSpec; - type T = EphemeralHarnessType; + type Store = MemoryStore; fn get_state(validator_count: usize) -> (BeaconState, Vec) { let harness = BeaconChainHarness::builder(MainnetEthSpec) @@ -257,14 +258,14 @@ mod test { (harness.get_current_state(), harness.validator_keypairs) } - fn get_store() -> BeaconStore { + fn get_store() -> Arc> { Arc::new( HotColdDB::open_ephemeral(<_>::default(), E::default_spec(), test_logger()).unwrap(), ) } #[allow(clippy::needless_range_loop)] - fn check_cache_get(cache: &ValidatorPubkeyCache, keypairs: &[Keypair]) { + fn check_cache_get(cache: &ValidatorPubkeyCache, keypairs: &[Keypair]) { let validator_count = keypairs.len(); for i in 0..validator_count + 1 { @@ -297,7 +298,7 @@ mod test { let store = get_store(); - let mut cache = ValidatorPubkeyCache::new(&state, store).expect("should create cache"); + let mut cache = ValidatorPubkeyCache::new(&state, &store).expect("should create cache"); check_cache_get(&cache, &keypairs[..]); @@ -330,13 +331,12 @@ mod test { let store = get_store(); // Create a new cache. - let cache = ValidatorPubkeyCache::new(&state, store.clone()).expect("should create cache"); + let cache = ValidatorPubkeyCache::new(&state, &store).expect("should create cache"); check_cache_get(&cache, &keypairs[..]); drop(cache); // Re-init the cache from the store. - let mut cache = - ValidatorPubkeyCache::load_from_store(store.clone()).expect("should open cache"); + let mut cache = ValidatorPubkeyCache::load_from_store(&store).expect("should open cache"); check_cache_get(&cache, &keypairs[..]); // Add some more keypairs. @@ -349,7 +349,7 @@ mod test { drop(cache); // Re-init the cache from the store. - let cache = ValidatorPubkeyCache::load_from_store(store).expect("should open cache"); + let cache = ValidatorPubkeyCache::load_from_store(&store).expect("should open cache"); check_cache_get(&cache, &keypairs[..]); } } diff --git a/consensus/proto_array/src/justified_balances.rs b/consensus/proto_array/src/justified_balances.rs index 75f6c2f7c8..a1211f0f7d 100644 --- a/consensus/proto_array/src/justified_balances.rs +++ b/consensus/proto_array/src/justified_balances.rs @@ -25,10 +25,10 @@ impl JustifiedBalances { .iter() .map(|validator| { if validator.is_active_at(current_epoch) { - total_effective_balance.safe_add_assign(validator.effective_balance)?; + total_effective_balance.safe_add_assign(validator.effective_balance())?; num_active_validators.safe_add_assign(1)?; - Ok(validator.effective_balance) + Ok(validator.effective_balance()) } else { Ok(0) } diff --git a/consensus/state_processing/src/per_epoch_processing/altair/participation_cache.rs b/consensus/state_processing/src/per_epoch_processing/altair/participation_cache.rs index 32f16961c1..31dfd09525 100644 --- a/consensus/state_processing/src/per_epoch_processing/altair/participation_cache.rs +++ b/consensus/state_processing/src/per_epoch_processing/altair/participation_cache.rs @@ -355,7 +355,7 @@ impl ParticipationCache { eligible_indices, process_slashings_indices, inactivity_score_updates: definitely_not_in_inactivity_leak - .then(|| inactivity_score_updates), + .then_some(inactivity_score_updates), }) } diff --git a/consensus/types/src/beacon_state.rs b/consensus/types/src/beacon_state.rs index 108f070515..5122ada9e5 100644 --- a/consensus/types/src/beacon_state.rs +++ b/consensus/types/src/beacon_state.rs @@ -5,7 +5,6 @@ use crate::validator::ValidatorTrait; use crate::*; use compare_fields::CompareFields; use compare_fields_derive::CompareFields; -use derivative::Derivative; use ethereum_hashing::hash; use int_to_bytes::{int_to_bytes4, int_to_bytes8}; use metastruct::{metastruct, NumFields}; @@ -1711,6 +1710,7 @@ impl BeaconState Result<(), Error> { match self { Self::Base(inner) => { @@ -1754,6 +1754,7 @@ impl BeaconState { map_beacon_state_base_fields!(state, |_, field| { diff --git a/consensus/types/src/beacon_state/tests.rs b/consensus/types/src/beacon_state/tests.rs index 2ee917df0b..954c6b733c 100644 --- a/consensus/types/src/beacon_state/tests.rs +++ b/consensus/types/src/beacon_state/tests.rs @@ -6,12 +6,9 @@ use beacon_chain::types::{ BeaconStateMerge, ChainSpec, Domain, Epoch, EthSpec, FixedVector, Hash256, Keypair, MainnetEthSpec, MinimalEthSpec, RelativeEpoch, Slot, }; -use safe_arith::SafeArith; -use ssz::{Decode, Encode}; -use state_processing::per_slot_processing; +use ssz::Encode; use std::ops::Mul; use swap_or_not_shuffle::compute_shuffled_index; -use tree_hash::TreeHash; pub const MAX_VALIDATOR_COUNT: usize = 129; pub const SLOT_OFFSET: Slot = Slot::new(1); diff --git a/consensus/types/src/chain_spec.rs b/consensus/types/src/chain_spec.rs index 0ef181028a..b161984860 100644 --- a/consensus/types/src/chain_spec.rs +++ b/consensus/types/src/chain_spec.rs @@ -246,7 +246,7 @@ impl ChainSpec { pub fn fork_activated_at_slot(&self, slot: Slot) -> Option { let prev_slot_fork = self.fork_name_at_slot::(slot - 1); let slot_fork = self.fork_name_at_slot::(slot); - (slot_fork != prev_slot_fork).then(|| slot_fork) + (slot_fork != prev_slot_fork).then_some(slot_fork) } /// Returns the fork version for a named fork. diff --git a/consensus/types/src/light_client_finality_update.rs b/consensus/types/src/light_client_finality_update.rs index cae6266f9e..6cf8a8a85a 100644 --- a/consensus/types/src/light_client_finality_update.rs +++ b/consensus/types/src/light_client_finality_update.rs @@ -19,6 +19,7 @@ pub struct LightClientFinalityUpdate { /// The last `BeaconBlockHeader` from the last attested finalized block (end of epoch). pub finalized_header: BeaconBlockHeader, /// Merkle proof attesting finalized header. + #[test_random(default)] pub finality_branch: FixedVector, /// current sync aggreggate pub sync_aggregate: SyncAggregate, diff --git a/consensus/types/src/light_client_update.rs b/consensus/types/src/light_client_update.rs index 9c1cf89d2d..8805084edd 100644 --- a/consensus/types/src/light_client_update.rs +++ b/consensus/types/src/light_client_update.rs @@ -26,6 +26,7 @@ pub const NEXT_SYNC_COMMITTEE_PROOF_LEN: usize = 5; #[derive(Debug, PartialEq, Clone)] pub enum Error { SszTypesError(ssz_types::Error), + MilhouseError(milhouse::Error), BeaconStateError(beacon_state::Error), ArithError(ArithError), AltairForkNotActive, @@ -52,6 +53,12 @@ impl From for Error { } } +impl From for Error { + fn from(e: milhouse::Error) -> Error { + Error::MilhouseError(e) + } +} + /// A LightClientUpdate is the update we request solely to either complete the bootstraping process, /// or to sync up to the last committee period, we need to have one ready for each ALTAIR period /// we go over, note: there is no need to keep all of the updates from [ALTAIR_PERIOD, CURRENT_PERIOD]. diff --git a/consensus/types/src/validator.rs b/consensus/types/src/validator.rs index 7f81bbce28..2d16af1c2c 100644 --- a/consensus/types/src/validator.rs +++ b/consensus/types/src/validator.rs @@ -98,11 +98,20 @@ impl Validator { self.mutable.activation_epoch } + #[inline] + pub fn activation_epoch_mut(&mut self) -> &mut Epoch { + &mut self.mutable.activation_epoch + } + #[inline] pub fn exit_epoch(&self) -> Epoch { self.mutable.exit_epoch } + pub fn exit_epoch_mut(&mut self) -> &mut Epoch { + &mut self.mutable.exit_epoch + } + #[inline] pub fn withdrawable_epoch(&self) -> Epoch { self.mutable.withdrawable_epoch diff --git a/lcli/src/transition_blocks.rs b/lcli/src/transition_blocks.rs index 18d57782fd..72108ab213 100644 --- a/lcli/src/transition_blocks.rs +++ b/lcli/src/transition_blocks.rs @@ -198,7 +198,7 @@ pub fn run(env: Environment, matches: &ArgMatches) -> Result<(), let validator_pubkey_cache = store.immutable_validators.clone(); validator_pubkey_cache .write() - .import_new_pubkeys(&pre_state, &store) + .import_new_pubkeys(&pre_state) .map_err(|e| format!("Failed to create pubkey cache: {:?}", e))?; /* @@ -298,6 +298,7 @@ pub fn run(env: Environment, matches: &ArgMatches) -> Result<(), Ok(()) } +#[allow(clippy::too_many_arguments)] fn do_transition( mut pre_state: BeaconState, block_root: Hash256, diff --git a/testing/ef_tests/src/cases/epoch_processing.rs b/testing/ef_tests/src/cases/epoch_processing.rs index 9fbc6b7dc6..fb561bb0ad 100644 --- a/testing/ef_tests/src/cases/epoch_processing.rs +++ b/testing/ef_tests/src/cases/epoch_processing.rs @@ -294,9 +294,9 @@ impl> Case for EpochProcessing { let mut state = pre_state.clone(); let mut expected = self.post.clone(); - expected.as_mut().map(|post_state| { + if let Some(post_state) = expected.as_mut() { post_state.build_all_committee_caches(spec).unwrap(); - }); + } let mut result = T::run(&mut state, spec).map(|_| state); diff --git a/testing/ef_tests/src/cases/operations.rs b/testing/ef_tests/src/cases/operations.rs index eb1494ad28..7b53ae514b 100644 --- a/testing/ef_tests/src/cases/operations.rs +++ b/testing/ef_tests/src/cases/operations.rs @@ -386,9 +386,9 @@ impl> Case for Operations { let mut state = pre_state.clone(); let mut expected = self.post.clone(); - expected - .as_mut() - .map(|post_state| post_state.build_all_committee_caches(spec).unwrap()); + if let Some(post_state) = expected.as_mut() { + post_state.build_all_committee_caches(spec).unwrap(); + } let mut result = self .operation diff --git a/testing/state_transition_vectors/src/exit.rs b/testing/state_transition_vectors/src/exit.rs index d581eba965..caf365babb 100644 --- a/testing/state_transition_vectors/src/exit.rs +++ b/testing/state_transition_vectors/src/exit.rs @@ -170,7 +170,7 @@ vectors_and_tests!( invalid_exit_already_initiated, ExitTest { state_modifier: Box::new(|state| { - state.validators_mut().get_mut(0).unwrap().exit_epoch = STATE_EPOCH + 1; + *state.validators_mut().get_mut(0).unwrap().exit_epoch_mut() = STATE_EPOCH + 1; }), expected: Err(BlockProcessingError::ExitInvalid { index: 0, @@ -189,8 +189,11 @@ vectors_and_tests!( invalid_not_active_before_activation_epoch, ExitTest { state_modifier: Box::new(|state| { - state.validators_mut().get_mut(0).unwrap().activation_epoch = - E::default_spec().far_future_epoch; + *state + .validators_mut() + .get_mut(0) + .unwrap() + .activation_epoch_mut() = E::default_spec().far_future_epoch; }), expected: Err(BlockProcessingError::ExitInvalid { index: 0, @@ -209,7 +212,7 @@ vectors_and_tests!( invalid_not_active_after_exit_epoch, ExitTest { state_modifier: Box::new(|state| { - state.validators_mut().get_mut(0).unwrap().exit_epoch = STATE_EPOCH; + *state.validators_mut().get_mut(0).unwrap().exit_epoch_mut() = STATE_EPOCH; }), expected: Err(BlockProcessingError::ExitInvalid { index: 0,