mirror of
https://github.com/sigp/lighthouse.git
synced 2026-06-18 22:49:34 +00:00
cargo fmt
This commit is contained in:
@@ -1161,12 +1161,8 @@ impl<T: BeaconChainTypes> IntoExecutionPendingBlock<T> for Arc<SignedBeaconBlock
|
||||
BlockError::AvailabilityCheck(e),
|
||||
)
|
||||
})?;
|
||||
SignatureVerifiedBlock::check_slashable(
|
||||
maybe_available,
|
||||
block_root,
|
||||
chain,
|
||||
)?
|
||||
.into_execution_pending_block_slashable(block_root, chain, notify_execution_layer)
|
||||
SignatureVerifiedBlock::check_slashable(maybe_available, block_root, chain)?
|
||||
.into_execution_pending_block_slashable(block_root, chain, notify_execution_layer)
|
||||
}
|
||||
|
||||
fn block(&self) -> &SignedBeaconBlock<T::EthSpec> {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
use crate::blob_verification::GossipVerifiedBlobList;
|
||||
use crate::data_availability_checker::AvailabilityCheckError;
|
||||
pub use crate::data_availability_checker::{AvailableBlock, MaybeAvailableBlock};
|
||||
use crate::eth1_finalization_cache::Eth1FinalizationData;
|
||||
use crate::{data_availability_checker, GossipVerifiedBlock, PayloadVerificationOutcome};
|
||||
use derivative::Derivative;
|
||||
use ssz_derive::{Decode, Encode};
|
||||
@@ -14,7 +15,6 @@ use types::{
|
||||
BeaconBlockRef, BeaconState, BlindedPayload, BlobSidecarList, Epoch, EthSpec, Hash256,
|
||||
SignedBeaconBlock, SignedBeaconBlockHeader, Slot,
|
||||
};
|
||||
use crate::eth1_finalization_cache::Eth1FinalizationData;
|
||||
|
||||
#[derive(Debug, Clone, Derivative)]
|
||||
#[derivative(Hash(bound = "E: EthSpec"))]
|
||||
@@ -44,7 +44,7 @@ impl<E: EthSpec> RpcBlock<E> {
|
||||
blobs: Option<BlobSidecarList<E>>,
|
||||
) -> Result<Self, AvailabilityCheckError> {
|
||||
if let Some(blobs) = blobs.as_ref() {
|
||||
data_availability_checker::consistency_checks( &block, blobs)?;
|
||||
data_availability_checker::consistency_checks(&block, blobs)?;
|
||||
}
|
||||
let inner = match blobs {
|
||||
Some(blobs) => RpcBlockInner::BlockAndBlobs(block, blobs),
|
||||
@@ -401,4 +401,4 @@ impl<E: EthSpec> AsBlock<E> for RpcBlock<E> {
|
||||
fn into_rpc_block(self) -> RpcBlock<E> {
|
||||
self
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -317,7 +317,7 @@ pub fn make_available<T: EthSpec>(
|
||||
) -> Result<AvailableBlock<T>, AvailabilityCheckError> {
|
||||
let blobs = VariableList::new(blobs.into_iter().map(|blob| blob.to_blob()).collect())?;
|
||||
|
||||
consistency_checks( &block, &blobs)?;
|
||||
consistency_checks(&block, &blobs)?;
|
||||
|
||||
Ok(AvailableBlock {
|
||||
block,
|
||||
@@ -347,7 +347,10 @@ pub fn consistency_checks<T: EthSpec>(
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let block_root = blobs.first().map(|blob|blob.block_root).unwrap_or(block.canonical_root());
|
||||
let block_root = blobs
|
||||
.first()
|
||||
.map(|blob| blob.block_root)
|
||||
.unwrap_or(block.canonical_root());
|
||||
for (index, (block_commitment, blob)) in
|
||||
block_kzg_commitments.iter().zip(blobs.iter()).enumerate()
|
||||
{
|
||||
|
||||
@@ -540,8 +540,7 @@ impl<T: BeaconChainTypes> OverflowLRUCache<T> {
|
||||
import_data,
|
||||
payload_verification_outcome,
|
||||
} = executed_block;
|
||||
let available_block =
|
||||
make_available(block, vec![])?;
|
||||
let available_block = make_available(block, vec![])?;
|
||||
return Ok(Availability::Available(Box::new(
|
||||
AvailableExecutedBlock::new(
|
||||
available_block,
|
||||
@@ -591,8 +590,7 @@ impl<T: BeaconChainTypes> OverflowLRUCache<T> {
|
||||
return Ok(Availability::MissingComponents(import_data.block_root))
|
||||
};
|
||||
|
||||
let available_block =
|
||||
make_available(block, verified_blobs)?;
|
||||
let available_block = make_available(block, verified_blobs)?;
|
||||
Ok(Availability::Available(Box::new(
|
||||
AvailableExecutedBlock::new(
|
||||
available_block,
|
||||
|
||||
@@ -700,7 +700,7 @@ where
|
||||
let block = self.chain.get_blinded_block(block_root).unwrap().unwrap();
|
||||
let full_block = self.chain.store.make_full_block(block_root, block).unwrap();
|
||||
let blobs = self.chain.get_blobs(block_root).unwrap();
|
||||
RpcBlock::new( Arc::new(full_block), blobs).unwrap()
|
||||
RpcBlock::new(Arc::new(full_block), blobs).unwrap()
|
||||
}
|
||||
|
||||
pub fn get_all_validators(&self) -> Vec<usize> {
|
||||
@@ -1985,11 +1985,7 @@ where
|
||||
.process_block(
|
||||
slot,
|
||||
block.canonical_root(),
|
||||
RpcBlock::new(
|
||||
Arc::new(block.clone()),
|
||||
blobs_without_signatures.clone(),
|
||||
)
|
||||
.unwrap(),
|
||||
RpcBlock::new(Arc::new(block.clone()), blobs_without_signatures.clone()).unwrap(),
|
||||
)
|
||||
.await?;
|
||||
Ok((block_hash, (block, blobs), new_state))
|
||||
|
||||
@@ -133,7 +133,8 @@ async fn produces_attestations() {
|
||||
assert_eq!(data.target.epoch, state.current_epoch(), "bad target epoch");
|
||||
assert_eq!(data.target.root, target_root, "bad target root");
|
||||
|
||||
let rpc_block = RpcBlock::<MainnetEthSpec>::new(Arc::new(block.clone()), blobs.clone()).unwrap();
|
||||
let rpc_block =
|
||||
RpcBlock::<MainnetEthSpec>::new(Arc::new(block.clone()), blobs.clone()).unwrap();
|
||||
let beacon_chain::data_availability_checker::MaybeAvailableBlock::Available(available_block) = chain
|
||||
.data_availability_checker
|
||||
.check_rpc_block_availability(rpc_block)
|
||||
|
||||
@@ -158,7 +158,9 @@ fn chain_segment_blocks(
|
||||
chain_segment
|
||||
.iter()
|
||||
.zip(blobs.into_iter())
|
||||
.map(|(snapshot, blobs)| RpcBlock::new(snapshot.beacon_block.clone(), blobs.clone()).unwrap())
|
||||
.map(|(snapshot, blobs)| {
|
||||
RpcBlock::new(snapshot.beacon_block.clone(), blobs.clone()).unwrap()
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
@@ -408,7 +410,9 @@ async fn assert_invalid_signature(
|
||||
let blocks: Vec<RpcBlock<E>> = snapshots
|
||||
.iter()
|
||||
.zip(chain_segment_blobs.iter())
|
||||
.map(|(snapshot, blobs)| RpcBlock::new(snapshot.beacon_block.clone(), blobs.clone()).unwrap())
|
||||
.map(|(snapshot, blobs)| {
|
||||
RpcBlock::new(snapshot.beacon_block.clone(), blobs.clone()).unwrap()
|
||||
})
|
||||
.collect();
|
||||
|
||||
// Ensure the block will be rejected if imported in a chain segment.
|
||||
@@ -433,7 +437,9 @@ async fn assert_invalid_signature(
|
||||
.iter()
|
||||
.take(block_index)
|
||||
.zip(chain_segment_blobs.iter())
|
||||
.map(|(snapshot, blobs)| RpcBlock::new(snapshot.beacon_block.clone(), blobs.clone()).unwrap())
|
||||
.map(|(snapshot, blobs)| {
|
||||
RpcBlock::new(snapshot.beacon_block.clone(), blobs.clone()).unwrap()
|
||||
})
|
||||
.collect();
|
||||
// We don't care if this fails, we just call this to ensure that all prior blocks have been
|
||||
// imported prior to this test.
|
||||
@@ -450,7 +456,8 @@ async fn assert_invalid_signature(
|
||||
RpcBlock::new(
|
||||
snapshots[block_index].beacon_block.clone(),
|
||||
chain_segment_blobs[block_index].clone(),
|
||||
).unwrap(),
|
||||
)
|
||||
.unwrap(),
|
||||
NotifyExecutionLayer::Yes,
|
||||
|| Ok(()),
|
||||
)
|
||||
@@ -501,7 +508,9 @@ async fn invalid_signature_gossip_block() {
|
||||
.iter()
|
||||
.take(block_index)
|
||||
.zip(chain_segment_blobs.iter())
|
||||
.map(|(snapshot, blobs)| RpcBlock::new(snapshot.beacon_block.clone(), blobs.clone()).unwrap())
|
||||
.map(|(snapshot, blobs)| {
|
||||
RpcBlock::new(snapshot.beacon_block.clone(), blobs.clone()).unwrap()
|
||||
})
|
||||
.collect();
|
||||
harness
|
||||
.chain
|
||||
@@ -546,7 +555,9 @@ async fn invalid_signature_block_proposal() {
|
||||
let blocks: Vec<RpcBlock<E>> = snapshots
|
||||
.iter()
|
||||
.zip(chain_segment_blobs.iter())
|
||||
.map(|(snapshot, blobs)| RpcBlock::new(snapshot.beacon_block.clone(), blobs.clone()).unwrap())
|
||||
.map(|(snapshot, blobs)| {
|
||||
RpcBlock::new(snapshot.beacon_block.clone(), blobs.clone()).unwrap()
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
// Ensure the block will be rejected if imported in a chain segment.
|
||||
assert!(
|
||||
@@ -757,7 +768,9 @@ async fn invalid_signature_deposit() {
|
||||
let blocks: Vec<RpcBlock<E>> = snapshots
|
||||
.iter()
|
||||
.zip(chain_segment_blobs.iter())
|
||||
.map(|(snapshot, blobs)| RpcBlock::new(snapshot.beacon_block.clone(), blobs.clone()).unwrap())
|
||||
.map(|(snapshot, blobs)| {
|
||||
RpcBlock::new(snapshot.beacon_block.clone(), blobs.clone()).unwrap()
|
||||
})
|
||||
.collect();
|
||||
assert!(
|
||||
!matches!(
|
||||
|
||||
Reference in New Issue
Block a user