Skip to content

Commit ea49ea7

Browse files
committed
clippy
1 parent aff99ac commit ea49ea7

File tree

13 files changed

+36
-60
lines changed

13 files changed

+36
-60
lines changed

beacon_node/beacon_chain/src/beacon_chain.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3671,7 +3671,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
36713671
let availability = self
36723672
.data_availability_checker
36733673
.put_verified_execution_proofs(block_root, std::iter::once(proof))
3674-
.map_err(|e| BlockError::AvailabilityCheck(e))?;
3674+
.map_err(BlockError::AvailabilityCheck)?;
36753675

36763676
self.process_availability(slot, availability, publish_fn)
36773677
.await

beacon_node/beacon_chain/src/data_availability_checker.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ impl<E: EthSpec> Debug for Availability<E> {
121121
}
122122

123123
impl<T: BeaconChainTypes> DataAvailabilityChecker<T> {
124+
#[allow(clippy::too_many_arguments)]
124125
pub fn new(
125126
complete_blob_backfill: bool,
126127
slot_clock: T::SlotClock,
@@ -464,7 +465,7 @@ impl<T: BeaconChainTypes> DataAvailabilityChecker<T> {
464465
"Proof verification failed: proof is invalid"
465466
);
466467
return Err(AvailabilityCheckError::InvalidProof {
467-
proof_id: proof_id,
468+
proof_id,
468469
reason: "Proof verification returns false".to_string(),
469470
});
470471
}

beacon_node/beacon_chain/src/observed_execution_proofs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ impl ObservedExecutionProofs {
8585
}
8686

8787
let key = ProofKey::new(slot, block_root);
88-
let proof_ids = self.items.entry(key).or_insert_with(HashSet::new);
88+
let proof_ids = self.items.entry(key).or_default();
8989

9090
let was_duplicate = !proof_ids.insert(proof_id);
9191

beacon_node/lighthouse_network/tests/rpc_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1894,7 +1894,7 @@ fn test_tcp_execution_proofs_by_root_chunked() {
18941894

18951895
let block_root = Hash256::random();
18961896
let block_hash = ExecutionBlockHash::from_root(Hash256::random());
1897-
let proof_ids = vec![
1897+
let proof_ids = [
18981898
ExecutionProofId::new(0).unwrap(),
18991899
ExecutionProofId::new(1).unwrap(),
19001900
ExecutionProofId::new(2).unwrap(),

beacon_node/network/src/network_beacon_processor/rpc_methods.rs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -437,21 +437,18 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
437437
let count_needed = request.count_needed as usize;
438438

439439
// Get all execution proofs we have for this block from the DA checker
440-
let available_proofs = match self
440+
let Some(available_proofs) = self
441441
.chain
442442
.data_availability_checker
443443
.get_execution_proofs(&block_root)
444-
{
445-
Some(proofs) => proofs,
446-
None => {
447-
// No proofs available for this block
448-
debug!(
449-
%peer_id,
450-
%block_root,
451-
"No execution proofs available for peer"
452-
);
453-
return Ok(());
454-
}
444+
else {
445+
// No proofs available for this block
446+
debug!(
447+
%peer_id,
448+
%block_root,
449+
"No execution proofs available for peer"
450+
);
451+
return Ok(());
455452
};
456453

457454
// Filter out proofs the peer already has and send up to count_needed

beacon_node/network/src/network_beacon_processor/sync_methods.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1006,7 +1006,7 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
10061006
self: Arc<NetworkBeaconProcessor<T>>,
10071007
block_root: Hash256,
10081008
proofs: Vec<Arc<types::ExecutionProof>>,
1009-
seen_timestamp: Duration,
1009+
_seen_timestamp: Duration,
10101010
process_type: BlockProcessType,
10111011
) {
10121012
// Get slot directly from the first proof. All proofs should be for the same block.

beacon_node/network/src/sync/block_lookups/single_block_lookup.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -262,10 +262,8 @@ impl<T: BeaconChainTypes> SingleBlockLookup<T> {
262262
}
263263

264264
if cx.chain.should_fetch_execution_proofs(block_epoch) {
265-
if let Some(min_proofs) = cx.chain.min_execution_proofs_required() {
266-
self.proof_request =
267-
Some(ProofRequestState::new(self.block_root, min_proofs));
268-
}
265+
self.proof_request = cx.chain.min_execution_proofs_required()
266+
.map(|min_proofs| ProofRequestState::new(self.block_root, min_proofs));
269267
}
270268
} else {
271269
// Wait to download the block before downloading blobs. Then we can be sure that the

beacon_node/network/src/sync/tests/lookups.rs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -577,19 +577,10 @@ impl TestRig {
577577
pub(super) fn expect_proof_lookup_request(&mut self, block_root: Hash256) -> SingleLookupReqId {
578578
self.pop_received_network_event(|ev| match ev {
579579
NetworkMessage::SendRequest {
580-
request,
580+
request: RequestType::ExecutionProofsByRoot(req),
581581
app_request_id: AppRequestId::Sync(SyncRequestId::SingleExecutionProof { id }),
582582
..
583-
} => match request {
584-
RequestType::ExecutionProofsByRoot(req) => {
585-
if req.block_root == block_root {
586-
Some(*id)
587-
} else {
588-
None
589-
}
590-
}
591-
_ => None,
592-
},
583+
} if req.block_root == block_root => Some(*id),
593584
_ => None,
594585
})
595586
.unwrap_or_else(|_| panic!("Expected proof request for {block_root}"))

beacon_node/proof_generation_service/src/lib.rs

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -162,16 +162,13 @@ impl<T: BeaconChainTypes> ProofGenerationService<T> {
162162
let chain = self.chain.clone();
163163

164164
// Get the generator for this proof type
165-
let generator = match registry.get_generator(proof_id) {
166-
Some(gen) => gen,
167-
None => {
168-
debug!(
169-
slot = ?slot,
170-
proof_id = ?proof_id,
171-
"No generator found for proof type"
172-
);
173-
return;
174-
}
165+
let Some(generator) = registry.get_generator(proof_id) else {
166+
debug!(
167+
slot = ?slot,
168+
proof_id = ?proof_id,
169+
"No generator found for proof type"
170+
);
171+
return;
175172
};
176173

177174
// Spawn the generation task (async because generator.generate() is async)
@@ -293,12 +290,11 @@ mod tests {
293290

294291
/// Create a test harness with minimal setup
295292
fn build_test_harness(validator_count: usize) -> TestHarness {
296-
let harness = BeaconChainHarness::builder(E::default())
293+
BeaconChainHarness::builder(E)
297294
.default_spec()
298295
.deterministic_keypairs(validator_count)
299296
.fresh_ephemeral_store()
300-
.build();
301-
harness
297+
.build()
302298
}
303299

304300
#[tokio::test]
@@ -316,9 +312,8 @@ mod tests {
316312
let proof_id = ExecutionProofId::new(0).unwrap();
317313

318314
// Should return false for a proof that hasn't been observed
319-
assert_eq!(
320-
service.check_if_proof_exists(slot, block_root, proof_id),
321-
false
315+
assert!(
316+
!service.check_if_proof_exists(slot, block_root, proof_id)
322317
);
323318
}
324319

@@ -344,9 +339,8 @@ mod tests {
344339
.unwrap();
345340

346341
// Should return true for an observed proof
347-
assert_eq!(
348-
service.check_if_proof_exists(slot, block_root, proof_id),
349-
true
342+
assert!(
343+
service.check_if_proof_exists(slot, block_root, proof_id)
350344
);
351345
}
352346

beacon_node/src/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ pub fn get_config<E: EthSpec>(
354354
)
355355
})?
356356
.into_iter()
357-
.map(|id| ExecutionProofId::new(id))
357+
.map(ExecutionProofId::new)
358358
.collect::<Result<HashSet<_>, _>>()
359359
.map_err(|e| format!("Invalid subnet ID: {}", e))?
360360
} else {

0 commit comments

Comments
 (0)