Skip to content

Commit

Permalink
Lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmygchen committed Feb 5, 2024
1 parent 8fb6989 commit 74e825a
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 18 deletions.
2 changes: 1 addition & 1 deletion beacon_node/beacon_chain/src/eth1_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -967,7 +967,7 @@ mod test {
let spec = &E::default_spec();
let state: BeaconState<E> = BeaconState::new(0, get_eth1_data(0), spec);

let blocks = vec![];
let blocks = [];

assert_eq!(
get_votes_to_consider(
Expand Down
6 changes: 2 additions & 4 deletions beacon_node/http_api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1018,8 +1018,7 @@ pub fn serve<T: BeaconChainTypes>(
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!(
Expand Down Expand Up @@ -2857,8 +2856,7 @@ pub fn serve<T: BeaconChainTypes>(
"0x{}",
hex::encode(
meta_data
.syncnets()
.map(|x| x.clone())
.syncnets().cloned()
.unwrap_or_default()
.into_bytes()
)
Expand Down
6 changes: 2 additions & 4 deletions beacon_node/network/src/subnet_service/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
3 changes: 1 addition & 2 deletions beacon_node/store/src/hot_cold_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1343,8 +1343,7 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
) -> Result<Hash256, HotColdDBError> {
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)
}

Expand Down
4 changes: 2 additions & 2 deletions consensus/cached_tree_hash/src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ pub fn u64_leaf_count(len: usize) -> usize {

pub fn hash256_iter(
values: &[Hash256],
) -> impl Iterator<Item = [u8; BYTES_PER_CHUNK]> + ExactSizeIterator + '_ {
) -> impl ExactSizeIterator<Item = [u8; BYTES_PER_CHUNK]> + '_ {
values.iter().copied().map(Hash256::to_fixed_bytes)
}

pub fn u64_iter(
values: &[u64],
) -> impl Iterator<Item = [u8; BYTES_PER_CHUNK]> + ExactSizeIterator + '_ {
) -> impl ExactSizeIterator<Item = [u8; BYTES_PER_CHUNK]> + '_ {
let type_size = size_of::<u64>();
let vals_per_chunk = BYTES_PER_CHUNK / type_size;
values.chunks(vals_per_chunk).map(move |xs| {
Expand Down
6 changes: 3 additions & 3 deletions consensus/types/src/beacon_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ impl<T: EthSpec> BeaconState<T> {
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()
}
}

Expand All @@ -657,7 +657,7 @@ impl<T: EthSpec> BeaconState<T> {
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()
}
}

Expand All @@ -683,7 +683,7 @@ impl<T: EthSpec> BeaconState<T> {
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()
}
}

Expand Down
2 changes: 1 addition & 1 deletion consensus/types/src/historical_summary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ impl<'a, N: Unsigned> CachedTreeHash<TreeHashCache> for HistoricalSummaryCache<'

pub fn leaf_iter(
values: &[HistoricalSummary],
) -> impl Iterator<Item = [u8; BYTES_PER_CHUNK]> + ExactSizeIterator + '_ {
) -> impl ExactSizeIterator<Item = [u8; BYTES_PER_CHUNK]> + '_ {
values
.iter()
.map(|value| value.tree_hash_root())
Expand Down
2 changes: 1 addition & 1 deletion consensus/types/src/participation_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pub fn leaf_count(len: usize) -> usize {

pub fn leaf_iter(
values: &[ParticipationFlags],
) -> impl Iterator<Item = [u8; BYTES_PER_CHUNK]> + ExactSizeIterator + '_ {
) -> impl ExactSizeIterator<Item = [u8; BYTES_PER_CHUNK]> + '_ {
values.chunks(BYTES_PER_CHUNK).map(|xs| {
// Zero-pad chunks on the right.
let mut chunk = [0u8; BYTES_PER_CHUNK];
Expand Down
1 change: 1 addition & 0 deletions database_manager/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ pub fn inspect_db<E: EthSpec>(

let write_result = fs::OpenOptions::new()
.create(true)
.truncate(true)
.write(true)
.open(&file_path)
.map_err(|e| format!("Failed to open file: {:?}", e))
Expand Down

0 comments on commit 74e825a

Please sign in to comment.