From 74e825a3f049411da2f9de5a400b0445b0af5494 Mon Sep 17 00:00:00 2001 From: Jimmy Chen Date: Mon, 5 Feb 2024 11:39:28 +1100 Subject: [PATCH 1/7] Lint fixes --- beacon_node/beacon_chain/src/eth1_chain.rs | 2 +- beacon_node/http_api/src/lib.rs | 6 ++---- beacon_node/network/src/subnet_service/tests/mod.rs | 6 ++---- beacon_node/store/src/hot_cold_store.rs | 3 +-- consensus/cached_tree_hash/src/impls.rs | 4 ++-- consensus/types/src/beacon_state.rs | 6 +++--- consensus/types/src/historical_summary.rs | 2 +- consensus/types/src/participation_list.rs | 2 +- database_manager/src/lib.rs | 1 + 9 files changed, 14 insertions(+), 18 deletions(-) diff --git a/beacon_node/beacon_chain/src/eth1_chain.rs b/beacon_node/beacon_chain/src/eth1_chain.rs index 8b6c6b37409..563c2965981 100644 --- a/beacon_node/beacon_chain/src/eth1_chain.rs +++ b/beacon_node/beacon_chain/src/eth1_chain.rs @@ -967,7 +967,7 @@ mod test { let spec = &E::default_spec(); let state: BeaconState = BeaconState::new(0, get_eth1_data(0), spec); - let blocks = vec![]; + let blocks = []; assert_eq!( get_votes_to_consider( diff --git a/beacon_node/http_api/src/lib.rs b/beacon_node/http_api/src/lib.rs index fe01f3c524f..1d04dd7295e 100644 --- a/beacon_node/http_api/src/lib.rs +++ b/beacon_node/http_api/src/lib.rs @@ -1018,8 +1018,7 @@ pub fn serve( let epoch = query.epoch.unwrap_or(current_epoch); Ok(( state - .get_built_sync_committee(epoch, &chain.spec) - .map(|committee| committee.clone()) + .get_built_sync_committee(epoch, &chain.spec).cloned() .map_err(|e| match e { BeaconStateError::SyncCommitteeNotKnown { .. } => { warp_utils::reject::custom_bad_request(format!( @@ -2857,8 +2856,7 @@ pub fn serve( "0x{}", hex::encode( meta_data - .syncnets() - .map(|x| x.clone()) + .syncnets().cloned() .unwrap_or_default() .into_bytes() ) diff --git a/beacon_node/network/src/subnet_service/tests/mod.rs b/beacon_node/network/src/subnet_service/tests/mod.rs index 769775a62c8..51e8753fc05 100644 --- a/beacon_node/network/src/subnet_service/tests/mod.rs +++ b/beacon_node/network/src/subnet_service/tests/mod.rs @@ -253,10 +253,8 @@ mod attestation_service { &attestation_service.beacon_chain.spec, ) .unwrap(); - let expected = vec![ - SubnetServiceMessage::Subscribe(Subnet::Attestation(subnet_id)), - SubnetServiceMessage::Unsubscribe(Subnet::Attestation(subnet_id)), - ]; + let expected = [SubnetServiceMessage::Subscribe(Subnet::Attestation(subnet_id)), + SubnetServiceMessage::Unsubscribe(Subnet::Attestation(subnet_id))]; // Wait for 1 slot duration to get the unsubscription event let events = get_events( diff --git a/beacon_node/store/src/hot_cold_store.rs b/beacon_node/store/src/hot_cold_store.rs index 63cd8e67d5a..7f017e66e2d 100644 --- a/beacon_node/store/src/hot_cold_store.rs +++ b/beacon_node/store/src/hot_cold_store.rs @@ -1343,8 +1343,7 @@ impl, Cold: ItemStore> HotColdDB ) -> Result { high_restore_point .get_block_root(slot) - .or_else(|_| high_restore_point.get_oldest_block_root()) - .map(|x| *x) + .or_else(|_| high_restore_point.get_oldest_block_root()).copied() .map_err(HotColdDBError::RestorePointBlockHashError) } diff --git a/consensus/cached_tree_hash/src/impls.rs b/consensus/cached_tree_hash/src/impls.rs index 0624bd20145..024e3c3fdc6 100644 --- a/consensus/cached_tree_hash/src/impls.rs +++ b/consensus/cached_tree_hash/src/impls.rs @@ -26,13 +26,13 @@ pub fn u64_leaf_count(len: usize) -> usize { pub fn hash256_iter( values: &[Hash256], -) -> impl Iterator + ExactSizeIterator + '_ { +) -> impl ExactSizeIterator + '_ { values.iter().copied().map(Hash256::to_fixed_bytes) } pub fn u64_iter( values: &[u64], -) -> impl Iterator + ExactSizeIterator + '_ { +) -> impl ExactSizeIterator + '_ { let type_size = size_of::(); let vals_per_chunk = BYTES_PER_CHUNK / type_size; values.chunks(vals_per_chunk).map(move |xs| { diff --git a/consensus/types/src/beacon_state.rs b/consensus/types/src/beacon_state.rs index bdc3be9ece4..4c0ee1bfa20 100644 --- a/consensus/types/src/beacon_state.rs +++ b/consensus/types/src/beacon_state.rs @@ -641,7 +641,7 @@ impl BeaconState { if self.slot() <= decision_slot { Ok(block_root) } else { - self.get_block_root(decision_slot).map(|root| *root) + self.get_block_root(decision_slot).copied() } } @@ -657,7 +657,7 @@ impl BeaconState { if self.slot() == decision_slot { Ok(block_root) } else { - self.get_block_root(decision_slot).map(|root| *root) + self.get_block_root(decision_slot).copied() } } @@ -683,7 +683,7 @@ impl BeaconState { if self.slot() == decision_slot { Ok(block_root) } else { - self.get_block_root(decision_slot).map(|root| *root) + self.get_block_root(decision_slot).copied() } } diff --git a/consensus/types/src/historical_summary.rs b/consensus/types/src/historical_summary.rs index dcc387d3d6f..d212f8a5ece 100644 --- a/consensus/types/src/historical_summary.rs +++ b/consensus/types/src/historical_summary.rs @@ -81,7 +81,7 @@ impl<'a, N: Unsigned> CachedTreeHash for HistoricalSummaryCache<' pub fn leaf_iter( values: &[HistoricalSummary], -) -> impl Iterator + ExactSizeIterator + '_ { +) -> impl ExactSizeIterator + '_ { values .iter() .map(|value| value.tree_hash_root()) diff --git a/consensus/types/src/participation_list.rs b/consensus/types/src/participation_list.rs index be119fbef26..6e3d916dee5 100644 --- a/consensus/types/src/participation_list.rs +++ b/consensus/types/src/participation_list.rs @@ -43,7 +43,7 @@ pub fn leaf_count(len: usize) -> usize { pub fn leaf_iter( values: &[ParticipationFlags], -) -> impl Iterator + ExactSizeIterator + '_ { +) -> impl ExactSizeIterator + '_ { values.chunks(BYTES_PER_CHUNK).map(|xs| { // Zero-pad chunks on the right. let mut chunk = [0u8; BYTES_PER_CHUNK]; diff --git a/database_manager/src/lib.rs b/database_manager/src/lib.rs index 95af4d63821..87a1a8bd149 100644 --- a/database_manager/src/lib.rs +++ b/database_manager/src/lib.rs @@ -356,6 +356,7 @@ pub fn inspect_db( let write_result = fs::OpenOptions::new() .create(true) + .truncate(true) .write(true) .open(&file_path) .map_err(|e| format!("Failed to open file: {:?}", e)) From c3f4b6b8238fb6c63b68d630efa01f92f8091ebd Mon Sep 17 00:00:00 2001 From: Jimmy Chen Date: Mon, 5 Feb 2024 12:35:00 +1100 Subject: [PATCH 2/7] More fixes for beta compiler. --- .../src/attestation_verification.rs | 16 ++++++++---- .../beacon_chain/src/state_advance_timer.rs | 2 ++ .../src/test_utils/mock_builder.rs | 2 ++ .../execution_layer/src/test_utils/mod.rs | 4 ++- .../http_api/src/attestation_performance.rs | 2 ++ .../http_api/src/block_packing_efficiency.rs | 2 ++ .../src/gossipsub/behaviour/tests.rs | 26 +++++++++---------- .../lighthouse_network/tests/common.rs | 19 +++++++++----- common/validator_dir/src/builder.rs | 2 ++ lighthouse/environment/src/lib.rs | 6 +++-- 10 files changed, 53 insertions(+), 28 deletions(-) diff --git a/beacon_node/beacon_chain/src/attestation_verification.rs b/beacon_node/beacon_chain/src/attestation_verification.rs index d7a8bca4d0f..019e87309fd 100644 --- a/beacon_node/beacon_chain/src/attestation_verification.rs +++ b/beacon_node/beacon_chain/src/attestation_verification.rs @@ -539,8 +539,8 @@ impl<'a, T: BeaconChainTypes> IndexedAggregatedAttestation<'a, T> { Err(e) => return Err(SignatureNotChecked(&signed_aggregate.message.aggregate, e)), }; - let indexed_attestation = - match map_attestation_committee(chain, attestation, |(committee, _)| { + let get_indexed_attestation_with_committee = + |(committee, _): (BeaconCommittee, CommitteesPerSlot)| { // Note: this clones the signature which is known to be a relatively slow operation. // // Future optimizations should remove this clone. @@ -561,11 +561,17 @@ impl<'a, T: BeaconChainTypes> IndexedAggregatedAttestation<'a, T> { get_indexed_attestation(committee.committee, attestation) .map_err(|e| BeaconChainError::from(e).into()) - }) { - Ok(indexed_attestation) => indexed_attestation, - Err(e) => return Err(SignatureNotChecked(&signed_aggregate.message.aggregate, e)), }; + let indexed_attestation = match map_attestation_committee( + chain, + attestation, + get_indexed_attestation_with_committee, + ) { + Ok(indexed_attestation) => indexed_attestation, + Err(e) => return Err(SignatureNotChecked(&signed_aggregate.message.aggregate, e)), + }; + Ok(IndexedAggregatedAttestation { signed_aggregate, indexed_attestation, diff --git a/beacon_node/beacon_chain/src/state_advance_timer.rs b/beacon_node/beacon_chain/src/state_advance_timer.rs index c04815ebc13..8bd3c2b683f 100644 --- a/beacon_node/beacon_chain/src/state_advance_timer.rs +++ b/beacon_node/beacon_chain/src/state_advance_timer.rs @@ -51,6 +51,8 @@ const MAX_BLOCK_PRODUCTION_CACHE_DISTANCE: u64 = 4; #[derive(Debug)] enum Error { BeaconChain(BeaconChainError), + // We don't use the inner value directly, but it's used in the Debug impl. + #[allow(dead_code)] HeadMissingFromSnapshotCache(Hash256), MaxDistanceExceeded { current_slot: Slot, diff --git a/beacon_node/execution_layer/src/test_utils/mock_builder.rs b/beacon_node/execution_layer/src/test_utils/mock_builder.rs index 3d4ea51f4bd..2c2f29e2f52 100644 --- a/beacon_node/execution_layer/src/test_utils/mock_builder.rs +++ b/beacon_node/execution_layer/src/test_utils/mock_builder.rs @@ -54,6 +54,8 @@ impl Operation { } #[derive(Debug)] +#[allow(dead_code)] +// We don't use the string value directly, but it's used in the Debug impl which is required by `warp::reject::Reject`. struct Custom(String); impl warp::reject::Reject for Custom {} diff --git a/beacon_node/execution_layer/src/test_utils/mod.rs b/beacon_node/execution_layer/src/test_utils/mod.rs index f0be5111472..a9ea6c6db68 100644 --- a/beacon_node/execution_layer/src/test_utils/mod.rs +++ b/beacon_node/execution_layer/src/test_utils/mod.rs @@ -487,6 +487,8 @@ pub struct StaticNewPayloadResponse { should_import: bool, } #[derive(Debug)] +#[allow(dead_code)] +// We don't use the string value directly, but it's used in the Debug impl which is required by `warp::reject::Reject`. struct AuthError(String); impl warp::reject::Reject for AuthError {} @@ -600,7 +602,7 @@ async fn handle_rejection(err: Rejection) -> Result() { - message = format!("Authorization error: {:?}", e); + message = format!("Authorization error: {}", e.0); code = StatusCode::UNAUTHORIZED; } else { message = "BAD_REQUEST".to_string(); diff --git a/beacon_node/http_api/src/attestation_performance.rs b/beacon_node/http_api/src/attestation_performance.rs index 3e7d8d5e316..2957b2d34b7 100644 --- a/beacon_node/http_api/src/attestation_performance.rs +++ b/beacon_node/http_api/src/attestation_performance.rs @@ -14,6 +14,8 @@ const MAX_REQUEST_RANGE_EPOCHS: usize = 100; const BLOCK_ROOT_CHUNK_SIZE: usize = 100; #[derive(Debug)] +// We don't use the inner values directly, but they're used in the Debug impl. +#[allow(dead_code)] enum AttestationPerformanceError { BlockReplay(BlockReplayError), BeaconState(BeaconStateError), diff --git a/beacon_node/http_api/src/block_packing_efficiency.rs b/beacon_node/http_api/src/block_packing_efficiency.rs index e099e130a8b..16328796084 100644 --- a/beacon_node/http_api/src/block_packing_efficiency.rs +++ b/beacon_node/http_api/src/block_packing_efficiency.rs @@ -19,6 +19,8 @@ use warp_utils::reject::{beacon_chain_error, custom_bad_request, custom_server_e const BLOCK_ROOT_CHUNK_SIZE: usize = 100; #[derive(Debug)] +// We don't use the inner values directly, but they're used in the Debug impl. +#[allow(dead_code)] enum PackingEfficiencyError { BlockReplay(BlockReplayError), BeaconState(BeaconStateError), diff --git a/beacon_node/lighthouse_network/src/gossipsub/behaviour/tests.rs b/beacon_node/lighthouse_network/src/gossipsub/behaviour/tests.rs index 4e02e4016fa..9d8a10bcc85 100644 --- a/beacon_node/lighthouse_network/src/gossipsub/behaviour/tests.rs +++ b/beacon_node/lighthouse_network/src/gossipsub/behaviour/tests.rs @@ -174,7 +174,7 @@ fn inject_nodes1() -> InjectNodes fn add_peer( gs: &mut Behaviour, - topic_hashes: &Vec, + topic_hashes: &[TopicHash], outbound: bool, explicit: bool, ) -> (PeerId, RpcReceiver) @@ -187,7 +187,7 @@ where fn add_peer_with_addr( gs: &mut Behaviour, - topic_hashes: &Vec, + topic_hashes: &[TopicHash], outbound: bool, explicit: bool, address: Multiaddr, @@ -208,7 +208,7 @@ where fn add_peer_with_addr_and_kind( gs: &mut Behaviour, - topic_hashes: &Vec, + topic_hashes: &[TopicHash], outbound: bool, explicit: bool, address: Multiaddr, @@ -3218,7 +3218,7 @@ fn test_scoring_p1() { ); } -fn random_message(seq: &mut u64, topics: &Vec) -> RawMessage { +fn random_message(seq: &mut u64, topics: &[TopicHash]) -> RawMessage { let mut rng = rand::thread_rng(); *seq += 1; RawMessage { @@ -4080,20 +4080,20 @@ fn test_scoring_p6() { //create 5 peers with the same ip let addr = Multiaddr::from(Ipv4Addr::new(10, 1, 2, 3)); let peers = vec![ - add_peer_with_addr(&mut gs, &vec![], false, false, addr.clone()).0, - add_peer_with_addr(&mut gs, &vec![], false, false, addr.clone()).0, - add_peer_with_addr(&mut gs, &vec![], true, false, addr.clone()).0, - add_peer_with_addr(&mut gs, &vec![], true, false, addr.clone()).0, - add_peer_with_addr(&mut gs, &vec![], true, true, addr.clone()).0, + add_peer_with_addr(&mut gs, &[], false, false, addr.clone()).0, + add_peer_with_addr(&mut gs, &[], false, false, addr.clone()).0, + add_peer_with_addr(&mut gs, &[], true, false, addr.clone()).0, + add_peer_with_addr(&mut gs, &[], true, false, addr.clone()).0, + add_peer_with_addr(&mut gs, &[], true, true, addr.clone()).0, ]; //create 4 other peers with other ip let addr2 = Multiaddr::from(Ipv4Addr::new(10, 1, 2, 4)); let others = vec![ - add_peer_with_addr(&mut gs, &vec![], false, false, addr2.clone()).0, - add_peer_with_addr(&mut gs, &vec![], false, false, addr2.clone()).0, - add_peer_with_addr(&mut gs, &vec![], true, false, addr2.clone()).0, - add_peer_with_addr(&mut gs, &vec![], true, false, addr2.clone()).0, + add_peer_with_addr(&mut gs, &[], false, false, addr2.clone()).0, + add_peer_with_addr(&mut gs, &[], false, false, addr2.clone()).0, + add_peer_with_addr(&mut gs, &[], true, false, addr2.clone()).0, + add_peer_with_addr(&mut gs, &[], true, false, addr2.clone()).0, ]; //no penalties yet diff --git a/beacon_node/lighthouse_network/tests/common.rs b/beacon_node/lighthouse_network/tests/common.rs index ea0318ca9d1..c8b34deef4a 100644 --- a/beacon_node/lighthouse_network/tests/common.rs +++ b/beacon_node/lighthouse_network/tests/common.rs @@ -42,18 +42,23 @@ pub fn fork_context(fork_name: ForkName) -> ForkContext { ForkContext::new::(current_slot, Hash256::zero(), &chain_spec) } -pub struct Libp2pInstance(LibP2PService, exit_future::Signal); +pub struct Libp2pInstance { + service: LibP2PService, + #[allow(dead_code)] + /// This field is managed for lifetime purposes may not be used directly, hence the `#[allow(dead_code)]` attribute. + exit_signal: exit_future::Signal, +} impl std::ops::Deref for Libp2pInstance { type Target = LibP2PService; fn deref(&self) -> &Self::Target { - &self.0 + &self.service } } impl std::ops::DerefMut for Libp2pInstance { fn deref_mut(&mut self) -> &mut Self::Target { - &mut self.0 + &mut self.service } } @@ -115,13 +120,13 @@ pub async fn build_libp2p_instance( chain_spec: spec, libp2p_registry: None, }; - Libp2pInstance( - LibP2PService::new(executor, libp2p_context, &log) + Libp2pInstance { + service: LibP2PService::new(executor, libp2p_context, &log) .await .expect("should build libp2p instance") .0, - signal, - ) + exit_signal: signal, + } } #[allow(dead_code)] diff --git a/common/validator_dir/src/builder.rs b/common/validator_dir/src/builder.rs index bccf9086acc..3d5d1496082 100644 --- a/common/validator_dir/src/builder.rs +++ b/common/validator_dir/src/builder.rs @@ -214,6 +214,7 @@ impl<'a> Builder<'a> { .write(true) .read(true) .create(true) + .truncate(true) .open(path) .map_err(Error::UnableToSaveDepositData)? .write_all(hex.as_bytes()) @@ -231,6 +232,7 @@ impl<'a> Builder<'a> { .write(true) .read(true) .create(true) + .truncate(true) .open(path) .map_err(Error::UnableToSaveDepositAmount)? .write_all(format!("{}", amount).as_bytes()) diff --git a/lighthouse/environment/src/lib.rs b/lighthouse/environment/src/lib.rs index a1f6b26a95e..40001f1e1d4 100644 --- a/lighthouse/environment/src/lib.rs +++ b/lighthouse/environment/src/lib.rs @@ -434,7 +434,7 @@ impl Environment { async move { rx.next().await.ok_or("Internal shutdown channel exhausted") }; futures::pin_mut!(inner_shutdown); - match self.runtime().block_on(async { + let register_handlers = async { let mut handles = vec![]; // setup for handling SIGTERM @@ -465,7 +465,9 @@ impl Environment { } future::select(inner_shutdown, future::select_all(handles.into_iter())).await - }) { + }; + + match self.runtime().block_on(register_handlers) { future::Either::Left((Ok(reason), _)) => { info!(self.log, "Internal shutdown received"; "reason" => reason.message()); Ok(reason) From 42db70aab5158fb6448bccda476524e92f70e4da Mon Sep 17 00:00:00 2001 From: Jimmy Chen Date: Mon, 5 Feb 2024 12:36:18 +1100 Subject: [PATCH 3/7] Format fixes --- beacon_node/http_api/src/lib.rs | 6 ++++-- beacon_node/network/src/subnet_service/tests/mod.rs | 6 ++++-- beacon_node/store/src/hot_cold_store.rs | 3 ++- consensus/cached_tree_hash/src/impls.rs | 4 +--- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/beacon_node/http_api/src/lib.rs b/beacon_node/http_api/src/lib.rs index 1d04dd7295e..f89bc3c29fb 100644 --- a/beacon_node/http_api/src/lib.rs +++ b/beacon_node/http_api/src/lib.rs @@ -1018,7 +1018,8 @@ pub fn serve( let epoch = query.epoch.unwrap_or(current_epoch); Ok(( state - .get_built_sync_committee(epoch, &chain.spec).cloned() + .get_built_sync_committee(epoch, &chain.spec) + .cloned() .map_err(|e| match e { BeaconStateError::SyncCommitteeNotKnown { .. } => { warp_utils::reject::custom_bad_request(format!( @@ -2856,7 +2857,8 @@ pub fn serve( "0x{}", hex::encode( meta_data - .syncnets().cloned() + .syncnets() + .cloned() .unwrap_or_default() .into_bytes() ) diff --git a/beacon_node/network/src/subnet_service/tests/mod.rs b/beacon_node/network/src/subnet_service/tests/mod.rs index 51e8753fc05..658c851ba21 100644 --- a/beacon_node/network/src/subnet_service/tests/mod.rs +++ b/beacon_node/network/src/subnet_service/tests/mod.rs @@ -253,8 +253,10 @@ mod attestation_service { &attestation_service.beacon_chain.spec, ) .unwrap(); - let expected = [SubnetServiceMessage::Subscribe(Subnet::Attestation(subnet_id)), - SubnetServiceMessage::Unsubscribe(Subnet::Attestation(subnet_id))]; + let expected = [ + SubnetServiceMessage::Subscribe(Subnet::Attestation(subnet_id)), + SubnetServiceMessage::Unsubscribe(Subnet::Attestation(subnet_id)), + ]; // Wait for 1 slot duration to get the unsubscription event let events = get_events( diff --git a/beacon_node/store/src/hot_cold_store.rs b/beacon_node/store/src/hot_cold_store.rs index 7f017e66e2d..49bc75393c1 100644 --- a/beacon_node/store/src/hot_cold_store.rs +++ b/beacon_node/store/src/hot_cold_store.rs @@ -1343,7 +1343,8 @@ impl, Cold: ItemStore> HotColdDB ) -> Result { high_restore_point .get_block_root(slot) - .or_else(|_| high_restore_point.get_oldest_block_root()).copied() + .or_else(|_| high_restore_point.get_oldest_block_root()) + .copied() .map_err(HotColdDBError::RestorePointBlockHashError) } diff --git a/consensus/cached_tree_hash/src/impls.rs b/consensus/cached_tree_hash/src/impls.rs index 024e3c3fdc6..efdba32b59d 100644 --- a/consensus/cached_tree_hash/src/impls.rs +++ b/consensus/cached_tree_hash/src/impls.rs @@ -30,9 +30,7 @@ pub fn hash256_iter( values.iter().copied().map(Hash256::to_fixed_bytes) } -pub fn u64_iter( - values: &[u64], -) -> impl ExactSizeIterator + '_ { +pub fn u64_iter(values: &[u64]) -> impl ExactSizeIterator + '_ { let type_size = size_of::(); let vals_per_chunk = BYTES_PER_CHUNK / type_size; values.chunks(vals_per_chunk).map(move |xs| { From 774e0fc5c65bde90c0bcf16cded05daf8eb7661f Mon Sep 17 00:00:00 2001 From: Jimmy Chen Date: Mon, 5 Feb 2024 15:13:20 +1100 Subject: [PATCH 4/7] Move `#[allow(dead_code)]` to field level. --- .../beacon_chain/src/state_advance_timer.rs | 3 +-- .../src/test_utils/mock_builder.rs | 3 +-- .../execution_layer/src/test_utils/mod.rs | 1 - .../http_api/src/attestation_performance.rs | 9 ++++---- .../http_api/src/block_packing_efficiency.rs | 7 +++--- .../lighthouse_network/tests/common.rs | 22 +++++++++---------- 6 files changed, 20 insertions(+), 25 deletions(-) diff --git a/beacon_node/beacon_chain/src/state_advance_timer.rs b/beacon_node/beacon_chain/src/state_advance_timer.rs index 8bd3c2b683f..39d35f81113 100644 --- a/beacon_node/beacon_chain/src/state_advance_timer.rs +++ b/beacon_node/beacon_chain/src/state_advance_timer.rs @@ -52,8 +52,7 @@ const MAX_BLOCK_PRODUCTION_CACHE_DISTANCE: u64 = 4; enum Error { BeaconChain(BeaconChainError), // We don't use the inner value directly, but it's used in the Debug impl. - #[allow(dead_code)] - HeadMissingFromSnapshotCache(Hash256), + HeadMissingFromSnapshotCache(#[allow(dead_code)] Hash256), MaxDistanceExceeded { current_slot: Slot, head_slot: Slot, diff --git a/beacon_node/execution_layer/src/test_utils/mock_builder.rs b/beacon_node/execution_layer/src/test_utils/mock_builder.rs index 2c2f29e2f52..2c5bde55ea3 100644 --- a/beacon_node/execution_layer/src/test_utils/mock_builder.rs +++ b/beacon_node/execution_layer/src/test_utils/mock_builder.rs @@ -54,9 +54,8 @@ impl Operation { } #[derive(Debug)] -#[allow(dead_code)] // We don't use the string value directly, but it's used in the Debug impl which is required by `warp::reject::Reject`. -struct Custom(String); +struct Custom(#[allow(dead_code)] String); impl warp::reject::Reject for Custom {} diff --git a/beacon_node/execution_layer/src/test_utils/mod.rs b/beacon_node/execution_layer/src/test_utils/mod.rs index a9ea6c6db68..ce3c1042084 100644 --- a/beacon_node/execution_layer/src/test_utils/mod.rs +++ b/beacon_node/execution_layer/src/test_utils/mod.rs @@ -487,7 +487,6 @@ pub struct StaticNewPayloadResponse { should_import: bool, } #[derive(Debug)] -#[allow(dead_code)] // We don't use the string value directly, but it's used in the Debug impl which is required by `warp::reject::Reject`. struct AuthError(String); diff --git a/beacon_node/http_api/src/attestation_performance.rs b/beacon_node/http_api/src/attestation_performance.rs index 2957b2d34b7..6e3ebcccec5 100644 --- a/beacon_node/http_api/src/attestation_performance.rs +++ b/beacon_node/http_api/src/attestation_performance.rs @@ -15,12 +15,11 @@ const BLOCK_ROOT_CHUNK_SIZE: usize = 100; #[derive(Debug)] // We don't use the inner values directly, but they're used in the Debug impl. -#[allow(dead_code)] enum AttestationPerformanceError { - BlockReplay(BlockReplayError), - BeaconState(BeaconStateError), - ParticipationCache(ParticipationCacheError), - UnableToFindValidator(usize), + BlockReplay(#[allow(dead_code)] BlockReplayError), + BeaconState(#[allow(dead_code)] BeaconStateError), + ParticipationCache(#[allow(dead_code)] ParticipationCacheError), + UnableToFindValidator(#[allow(dead_code)] usize), } impl From for AttestationPerformanceError { diff --git a/beacon_node/http_api/src/block_packing_efficiency.rs b/beacon_node/http_api/src/block_packing_efficiency.rs index 16328796084..c73dcb7e02a 100644 --- a/beacon_node/http_api/src/block_packing_efficiency.rs +++ b/beacon_node/http_api/src/block_packing_efficiency.rs @@ -20,11 +20,10 @@ const BLOCK_ROOT_CHUNK_SIZE: usize = 100; #[derive(Debug)] // We don't use the inner values directly, but they're used in the Debug impl. -#[allow(dead_code)] enum PackingEfficiencyError { - BlockReplay(BlockReplayError), - BeaconState(BeaconStateError), - CommitteeStoreError(Slot), + BlockReplay(#[allow(dead_code)] BlockReplayError), + BeaconState(#[allow(dead_code)] BeaconStateError), + CommitteeStoreError(#[allow(dead_code)] Slot), InvalidAttestationError, } diff --git a/beacon_node/lighthouse_network/tests/common.rs b/beacon_node/lighthouse_network/tests/common.rs index c8b34deef4a..af48244678d 100644 --- a/beacon_node/lighthouse_network/tests/common.rs +++ b/beacon_node/lighthouse_network/tests/common.rs @@ -42,23 +42,23 @@ pub fn fork_context(fork_name: ForkName) -> ForkContext { ForkContext::new::(current_slot, Hash256::zero(), &chain_spec) } -pub struct Libp2pInstance { - service: LibP2PService, +pub struct Libp2pInstance( + LibP2PService, #[allow(dead_code)] - /// This field is managed for lifetime purposes may not be used directly, hence the `#[allow(dead_code)]` attribute. - exit_signal: exit_future::Signal, -} + // This field is managed for lifetime purposes may not be used directly, hence the `#[allow(dead_code)]` attribute. + exit_future::Signal, +); impl std::ops::Deref for Libp2pInstance { type Target = LibP2PService; fn deref(&self) -> &Self::Target { - &self.service + &self.0 } } impl std::ops::DerefMut for Libp2pInstance { fn deref_mut(&mut self) -> &mut Self::Target { - &mut self.service + &mut self.0 } } @@ -120,13 +120,13 @@ pub async fn build_libp2p_instance( chain_spec: spec, libp2p_registry: None, }; - Libp2pInstance { - service: LibP2PService::new(executor, libp2p_context, &log) + Libp2pInstance( + LibP2PService::new(executor, libp2p_context, &log) .await .expect("should build libp2p instance") .0, - exit_signal: signal, - } + signal, + ) } #[allow(dead_code)] From 3b1da953e9d61d674348e30fd3838e4ffc9d19bf Mon Sep 17 00:00:00 2001 From: Jimmy Chen Date: Mon, 5 Feb 2024 17:14:53 +1100 Subject: [PATCH 5/7] Remove old comment. --- beacon_node/execution_layer/src/test_utils/mod.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/beacon_node/execution_layer/src/test_utils/mod.rs b/beacon_node/execution_layer/src/test_utils/mod.rs index ce3c1042084..d2849b55747 100644 --- a/beacon_node/execution_layer/src/test_utils/mod.rs +++ b/beacon_node/execution_layer/src/test_utils/mod.rs @@ -487,7 +487,6 @@ pub struct StaticNewPayloadResponse { should_import: bool, } #[derive(Debug)] -// We don't use the string value directly, but it's used in the Debug impl which is required by `warp::reject::Reject`. struct AuthError(String); impl warp::reject::Reject for AuthError {} From bd5da48d32ad15b587ff5a467d5a454a45dc7b88 Mon Sep 17 00:00:00 2001 From: realbigsean Date: Mon, 5 Feb 2024 11:54:59 -0500 Subject: [PATCH 6/7] Update beacon_node/execution_layer/src/test_utils/mod.rs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: João Oliveira --- beacon_node/execution_layer/src/test_utils/mod.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/beacon_node/execution_layer/src/test_utils/mod.rs b/beacon_node/execution_layer/src/test_utils/mod.rs index d2849b55747..efe51429f70 100644 --- a/beacon_node/execution_layer/src/test_utils/mod.rs +++ b/beacon_node/execution_layer/src/test_utils/mod.rs @@ -599,7 +599,8 @@ async fn handle_rejection(err: Rejection) -> Result() { + if let Some(AuthError(e)) = err.find::() { + message = format!("Authorization error: {}", e); message = format!("Authorization error: {}", e.0); code = StatusCode::UNAUTHORIZED; } else { From 80c4b638c99f26f4363fad6b9ec5248aabe8e748 Mon Sep 17 00:00:00 2001 From: realbigsean Date: Mon, 5 Feb 2024 12:14:31 -0500 Subject: [PATCH 7/7] remove duplicate line --- beacon_node/execution_layer/src/test_utils/mod.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/beacon_node/execution_layer/src/test_utils/mod.rs b/beacon_node/execution_layer/src/test_utils/mod.rs index efe51429f70..b509494703b 100644 --- a/beacon_node/execution_layer/src/test_utils/mod.rs +++ b/beacon_node/execution_layer/src/test_utils/mod.rs @@ -601,7 +601,6 @@ async fn handle_rejection(err: Rejection) -> Result() { message = format!("Authorization error: {}", e); - message = format!("Authorization error: {}", e.0); code = StatusCode::UNAUTHORIZED; } else { message = "BAD_REQUEST".to_string();