cargo fmt

This commit is contained in:
realbigsean 2023-08-24 14:35:06 -04:00
parent f90b190d9a
commit 42b34dbbe4
No known key found for this signature in database
GPG Key ID: BE1B3DB104F6C788
10 changed files with 55 additions and 49 deletions

View File

@ -241,7 +241,8 @@ pub fn validate_blob_sidecar_for_gossip<T: BeaconChainTypes>(
let Some(parent_block) = chain
.canonical_head
.fork_choice_read_lock()
.get_block(&block_parent_root) else {
.get_block(&block_parent_root)
else {
return Err(GossipBlobError::BlobParentUnknown(
signed_blob_sidecar.message,
));

View File

@ -349,11 +349,8 @@ pub fn consistency_checks<T: EthSpec>(
block: &SignedBeaconBlock<T>,
blobs: &[Arc<BlobSidecar<T>>],
) -> Result<(), AvailabilityCheckError> {
let Ok(block_kzg_commitments) = block
.message()
.body()
.blob_kzg_commitments() else {
return Ok(())
let Ok(block_kzg_commitments) = block.message().body().blob_kzg_commitments() else {
return Ok(());
};
if blobs.len() != block_kzg_commitments.len() {

View File

@ -586,8 +586,9 @@ impl<T: BeaconChainTypes> OverflowLRUCache<T> {
let Some(verified_blobs) = Vec::from(pending_components.verified_blobs)
.into_iter()
.take(num_blobs_expected)
.collect::<Option<Vec<_>>>() else {
return Ok(Availability::MissingComponents(import_data.block_root))
.collect::<Option<Vec<_>>>()
else {
return Ok(Availability::MissingComponents(import_data.block_root));
};
let available_block = make_available(block, verified_blobs)?;

View File

@ -136,13 +136,15 @@ async fn produces_attestations() {
let rpc_block =
RpcBlock::<MainnetEthSpec>::new(Arc::new(block.clone()), Some(blobs.clone()))
.unwrap();
let beacon_chain::data_availability_checker::MaybeAvailableBlock::Available(available_block) = chain
let beacon_chain::data_availability_checker::MaybeAvailableBlock::Available(
available_block,
) = chain
.data_availability_checker
.check_rpc_block_availability(rpc_block)
.unwrap()
else {
panic!("block should be available")
};
else {
panic!("block should be available")
};
let early_attestation = {
let proto_block = chain
@ -212,13 +214,15 @@ async fn early_attester_cache_old_request() {
let rpc_block =
RpcBlock::<MainnetEthSpec>::new(head.beacon_block.clone(), Some(head_blobs)).unwrap();
let beacon_chain::data_availability_checker::MaybeAvailableBlock::Available(available_block) = harness.chain
.data_availability_checker
.check_rpc_block_availability(rpc_block)
.unwrap()
else {
panic!("block should be available")
};
let beacon_chain::data_availability_checker::MaybeAvailableBlock::Available(available_block) =
harness
.chain
.data_availability_checker
.check_rpc_block_availability(rpc_block)
.unwrap()
else {
panic!("block should be available")
};
harness
.chain

View File

@ -279,9 +279,10 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
_seen_timestamp: Duration,
process_type: BlockProcessType,
) {
let Some(slot) = blobs.iter().find_map(|blob|{
blob.as_ref().map(|blob| blob.slot)
}) else {
let Some(slot) = blobs
.iter()
.find_map(|blob| blob.as_ref().map(|blob| blob.slot))
else {
return;
};

View File

@ -149,12 +149,14 @@ pub trait RequestState<L: Lookup, T: BeaconChainTypes> {
.copied()
.map(PeerShouldHave::BlockAndBlobs);
let Some(peer_id) = available_peer_opt.or_else(||request_state
.potential_peers
.iter()
.choose(&mut rand::thread_rng())
.copied()
.map(PeerShouldHave::Neither)) else {
let Some(peer_id) = available_peer_opt.or_else(|| {
request_state
.potential_peers
.iter()
.choose(&mut rand::thread_rng())
.copied()
.map(PeerShouldHave::Neither)
}) else {
return Err(LookupRequestError::NoPeers);
};
request_state.used_peers.insert(peer_id.to_peer_id());

View File

@ -597,7 +597,7 @@ impl<T: BeaconChainTypes> BlockLookups<T> {
if response.is_some() {
debug!(self.log, "Response for a parent lookup request that was not found"; "peer_id" => %peer_id);
}
return
return;
};
match self.parent_lookup_response_inner::<R>(
@ -781,7 +781,7 @@ impl<T: BeaconChainTypes> BlockLookups<T> {
"peer_id" => %peer_id,
"error" => msg
);
return
return;
};
R::request_state_mut(&mut parent_lookup.current_parent_request)
.register_failure_downloading();
@ -845,14 +845,14 @@ impl<T: BeaconChainTypes> BlockLookups<T> {
cx: &mut SyncNetworkContext<T>,
) {
let Some(mut lookup) = self.single_block_lookups.remove(&target_id) else {
return;
};
return;
};
let root = lookup.block_root();
let request_state = R::request_state_mut(&mut lookup);
let Ok(peer_id) = request_state.get_state().processing_peer() else {
return
let Ok(peer_id) = request_state.get_state().processing_peer() else {
return;
};
debug!(
self.log,
@ -1044,7 +1044,7 @@ impl<T: BeaconChainTypes> BlockLookups<T> {
.find(|(_, lookup)| lookup.chain_hash() == chain_hash)
.map(|(index, _)| index);
let Some(mut parent_lookup) = index.map(|index|self.parent_lookups.remove(index)) else {
let Some(mut parent_lookup) = index.map(|index| self.parent_lookups.remove(index)) else {
return debug!(self.log, "Process response for a parent lookup request that was not found"; "chain_hash" => %chain_hash);
};
@ -1187,7 +1187,7 @@ impl<T: BeaconChainTypes> BlockLookups<T> {
.iter()
.find_map(|(id, lookup)| (lookup.block_root() == chain_hash).then_some(*id))
{
let Some(child_lookup) = self.single_block_lookups.get_mut(&child_lookup_id) else {
let Some(child_lookup) = self.single_block_lookups.get_mut(&child_lookup_id) else {
debug!(self.log, "Missing child for parent lookup request"; "child_root" => ?chain_hash);
return blocks;
};
@ -1233,9 +1233,8 @@ impl<T: BeaconChainTypes> BlockLookups<T> {
mut parent_lookup: ParentLookup<T>,
) {
// We should always have a block peer.
let Ok(block_peer_id) =
parent_lookup.block_processing_peer() else {
return
let Ok(block_peer_id) = parent_lookup.block_processing_peer() else {
return;
};
let block_peer_id = block_peer_id.to_peer_id();
@ -1301,15 +1300,13 @@ impl<T: BeaconChainTypes> BlockLookups<T> {
let Some(id) = self
.single_block_lookups
.iter()
.find_map(|(id, req)|
(req.block_root() == chain_hash).then_some(*id)) else {
.find_map(|(id, req)| (req.block_root() == chain_hash).then_some(*id))
else {
warn!(self.log, "No id found for single block lookup"; "chain_hash" => %chain_hash);
return;
};
let Some(lookup) = self
.single_block_lookups
.get_mut(&id) else {
let Some(lookup) = self.single_block_lookups.get_mut(&id) else {
warn!(self.log, "No id found for single block lookup"; "chain_hash" => %chain_hash);
return;
};

View File

@ -135,8 +135,8 @@ impl<L: Lookup, T: BeaconChainTypes> SingleBlockLookup<L, T> {
/// 4. `Err`: The child is required, but has failed consistency checks.
pub fn get_cached_child_block(&self) -> CachedChild<T::EthSpec> {
if let Some(components) = self.cached_child_components.as_ref() {
let Some(block) = components.downloaded_block.as_ref()else {
return CachedChild::DownloadIncomplete
let Some(block) = components.downloaded_block.as_ref() else {
return CachedChild::DownloadIncomplete;
};
if !self.missing_blob_ids().is_empty() {

View File

@ -57,8 +57,8 @@ impl<T: EthSpec> BlocksAndBlobsRequestInfo<T> {
for blob in blob_list {
let blob_index = blob.index as usize;
let Some(blob_opt) = blobs_buffer.get_mut(blob_index) else {
return Err("Invalid blob index");
};
return Err("Invalid blob index");
};
if blob_opt.is_some() {
return Err("Repeat blob index");
} else {

View File

@ -129,7 +129,10 @@ impl<T: EthSpec> BlobSidecar<T> {
// Ensure that the blob is canonical by ensuring that
// each field element contained in the blob is < BLS_MODULUS
for i in 0..T::Kzg::FIELD_ELEMENTS_PER_BLOB {
let Some(byte) = blob_bytes.get_mut(i.checked_mul(T::Kzg::BYTES_PER_FIELD_ELEMENT).ok_or("overflow".to_string())?) else {
let Some(byte) = blob_bytes.get_mut(
i.checked_mul(T::Kzg::BYTES_PER_FIELD_ELEMENT)
.ok_or("overflow".to_string())?,
) else {
return Err(format!("blob byte index out of bounds: {:?}", i));
};
*byte = 0;