forgor something
This commit is contained in:
parent
eab1fce0e5
commit
750c594f5f
@ -376,7 +376,7 @@ pub struct BeaconChain<T: BeaconChainTypes> {
|
||||
/// continue they can request that everything shuts down.
|
||||
pub shutdown_sender: Sender<ShutdownReason>,
|
||||
pub block_waiting_for_sidecar: Mutex<Option<GossipVerifiedBlock<T>>>,
|
||||
pub sidecar_waiting_for_block: Mutex<Option<SignedBlobsSidecar<T::EthSpec>>>,
|
||||
pub sidecar_waiting_for_block: Mutex<Option<Arc<SignedBlobsSidecar<T::EthSpec>>>>,
|
||||
/// Logging to CLI, etc.
|
||||
pub(crate) log: Logger,
|
||||
/// Arbitrary bytes included in the blocks.
|
||||
@ -2431,7 +2431,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
pub async fn process_block<B: IntoExecutionPendingBlock<T>>(
|
||||
self: &Arc<Self>,
|
||||
unverified_block: B,
|
||||
sidecar: Option<SignedBlobsSidecar<T::EthSpec>>,
|
||||
sidecar: Option<Arc<SignedBlobsSidecar<T::EthSpec>>>,
|
||||
count_unrealized: CountUnrealized,
|
||||
) -> Result<Hash256, BlockError<T::EthSpec>> {
|
||||
// Start the Prometheus timer.
|
||||
@ -2506,7 +2506,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
async fn import_execution_pending_block(
|
||||
self: Arc<Self>,
|
||||
execution_pending_block: ExecutionPendingBlock<T>,
|
||||
sidecar: Option<SignedBlobsSidecar<T::EthSpec>>,
|
||||
sidecar: Option<Arc<SignedBlobsSidecar<T::EthSpec>>>,
|
||||
count_unrealized: CountUnrealized,
|
||||
) -> Result<Hash256, BlockError<T::EthSpec>> {
|
||||
let ExecutionPendingBlock {
|
||||
@ -2585,7 +2585,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
fn import_block(
|
||||
&self,
|
||||
signed_block: Arc<SignedBeaconBlock<T::EthSpec>>,
|
||||
sidecar: Option<SignedBlobsSidecar<T::EthSpec>>,
|
||||
sidecar: Option<Arc<SignedBlobsSidecar<T::EthSpec>>>,
|
||||
block_root: Hash256,
|
||||
mut state: BeaconState<T::EthSpec>,
|
||||
confirmed_state_roots: Vec<Hash256>,
|
||||
|
@ -16,7 +16,7 @@ pub const DEFAULT_SNAPSHOT_CACHE_SIZE: usize = 4;
|
||||
const MINIMUM_BLOCK_DELAY_FOR_CLONE: Duration = Duration::from_secs(6);
|
||||
|
||||
/// This snapshot is to be used for verifying a child of `self.beacon_block`.
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct PreProcessingSnapshot<T: EthSpec> {
|
||||
/// This state is equivalent to the `self.beacon_block.state_root()` state that has been
|
||||
/// advanced forward one slot using `per_slot_processing`. This state is "primed and ready" for
|
||||
|
@ -935,6 +935,7 @@ impl<T: BeaconChainTypes> Worker<T> {
|
||||
return
|
||||
}
|
||||
} else {
|
||||
*self.chain.block_waiting_for_sidecar.lock() = Some(verified_block);
|
||||
// we need the sidecar but dont have it yet
|
||||
return
|
||||
};
|
||||
@ -1017,7 +1018,80 @@ impl<T: BeaconChainTypes> Worker<T> {
|
||||
duplicate_cache: DuplicateCache,
|
||||
seen_duration: Duration,
|
||||
) {
|
||||
let verified_block = self.chain.block_waiting_for_sidecar.lock().take();
|
||||
if let Some(verified_block) = verified_block {
|
||||
let block = verified_block.block.clone();
|
||||
if verified_block.block_root() == blobs.message.beacon_block_root {
|
||||
match self
|
||||
.chain
|
||||
.process_block(verified_block, Some(blobs), CountUnrealized::True)
|
||||
.await
|
||||
{
|
||||
Ok(block_root) => {
|
||||
metrics::inc_counter(&metrics::BEACON_PROCESSOR_GOSSIP_BLOCK_IMPORTED_TOTAL);
|
||||
|
||||
if reprocess_tx
|
||||
.try_send(ReprocessQueueMessage::BlockImported(block_root))
|
||||
.is_err()
|
||||
{
|
||||
error!(
|
||||
self.log,
|
||||
"Failed to inform block import";
|
||||
"source" => "gossip",
|
||||
"block_root" => ?block_root,
|
||||
)
|
||||
};
|
||||
|
||||
debug!(
|
||||
self.log,
|
||||
"Gossipsub block processed";
|
||||
"block" => ?block_root,
|
||||
"peer_id" => %peer_id
|
||||
);
|
||||
|
||||
self.chain.recompute_head_at_current_slot().await;
|
||||
}
|
||||
Err(BlockError::ParentUnknown { .. }) => {
|
||||
// Inform the sync manager to find parents for this block
|
||||
// This should not occur. It should be checked by `should_forward_block`
|
||||
error!(
|
||||
self.log,
|
||||
"Block with unknown parent attempted to be processed";
|
||||
"peer_id" => %peer_id
|
||||
);
|
||||
self.send_sync_message(SyncMessage::UnknownBlock(peer_id, block));
|
||||
}
|
||||
Err(ref e @ BlockError::ExecutionPayloadError(ref epe)) if !epe.penalize_peer() => {
|
||||
debug!(
|
||||
self.log,
|
||||
"Failed to verify execution payload";
|
||||
"error" => %e
|
||||
);
|
||||
}
|
||||
other => {
|
||||
debug!(
|
||||
self.log,
|
||||
"Invalid gossip beacon block";
|
||||
"outcome" => ?other,
|
||||
"block root" => ?block.canonical_root(),
|
||||
"block slot" => block.slot()
|
||||
);
|
||||
self.gossip_penalize_peer(
|
||||
peer_id,
|
||||
PeerAction::MidToleranceError,
|
||||
"bad_gossip_block_ssz",
|
||||
);
|
||||
trace!(
|
||||
self.log,
|
||||
"Invalid gossip beacon block ssz";
|
||||
"ssz" => format_args!("0x{}", hex::encode(block.as_ssz_bytes())),
|
||||
);
|
||||
}
|
||||
};
|
||||
}
|
||||
} else {
|
||||
*self.chain.sidecar_waiting_for_block.lock() = Some(blobs);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn process_gossip_voluntary_exit(
|
||||
|
@ -784,7 +784,7 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
|
||||
}
|
||||
|
||||
StoreOp::PutBlobs(block_root, blobs) => {
|
||||
guard_blob.put(*block_root, blobs.clone());
|
||||
guard_blob.put(*block_root, (**blobs).clone());
|
||||
}
|
||||
|
||||
StoreOp::PutState(_, _) => (),
|
||||
|
@ -156,7 +156,7 @@ pub trait ItemStore<E: EthSpec>: KeyValueStore<E> + Sync + Send + Sized + 'stati
|
||||
pub enum StoreOp<'a, E: EthSpec> {
|
||||
PutBlock(Hash256, Arc<SignedBeaconBlock<E>>),
|
||||
PutState(Hash256, &'a BeaconState<E>),
|
||||
PutBlobs(Hash256, SignedBlobsSidecar<E>),
|
||||
PutBlobs(Hash256, Arc<SignedBlobsSidecar<E>>),
|
||||
PutStateSummary(Hash256, HotStateSummary),
|
||||
PutStateTemporaryFlag(Hash256),
|
||||
DeleteStateTemporaryFlag(Hash256),
|
||||
|
Loading…
Reference in New Issue
Block a user