Skip to content

Commit

Permalink
Drop reconstructed for processing
Browse files Browse the repository at this point in the history
  • Loading branch information
dapplion committed Apr 22, 2024
1 parent e0b862b commit 4c8143f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 39 deletions.
37 changes: 6 additions & 31 deletions beacon_node/network/src/sync/block_lookups/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@ pub trait RequestState<T: BeaconChainTypes> {
/// The type created after validation.
type VerifiedResponseType: Clone;

/// We convert a `VerifiedResponseType` to this type prior to sending it to the beacon processor.
type ReconstructedResponseType;

/* Request building methods */

/// Construct a new request.
Expand Down Expand Up @@ -141,18 +138,12 @@ pub trait RequestState<T: BeaconChainTypes> {
components: &mut ChildComponents<T::EthSpec>,
);

/// Convert a verified response to the type we send to the beacon processor.
fn verified_to_reconstructed(
block_root: Hash256,
verified: Self::VerifiedResponseType,
) -> Self::ReconstructedResponseType;

/// Send the response to the beacon processor.
fn send_reconstructed_for_processing(
fn send_for_processing(
id: Id,
bl: &BlockLookups<T>,
block_root: Hash256,
verified: Self::ReconstructedResponseType,
verified: Self::VerifiedResponseType,
duration: Duration,
cx: &SyncNetworkContext<T>,
) -> Result<(), LookupRequestError>;
Expand Down Expand Up @@ -180,7 +171,6 @@ pub trait RequestState<T: BeaconChainTypes> {
impl<T: BeaconChainTypes> RequestState<T> for BlockRequestState {
type RequestType = BlocksByRootSingleRequest;
type VerifiedResponseType = Arc<SignedBeaconBlock<T::EthSpec>>;
type ReconstructedResponseType = RpcBlock<T::EthSpec>;

fn new_request(&self) -> Self::RequestType {
BlocksByRootSingleRequest(self.requested_block_root)
Expand All @@ -207,24 +197,17 @@ impl<T: BeaconChainTypes> RequestState<T> for BlockRequestState {
components.merge_block(verified_response);
}

fn verified_to_reconstructed(
block_root: Hash256,
block: Arc<SignedBeaconBlock<T::EthSpec>>,
) -> RpcBlock<T::EthSpec> {
RpcBlock::new_without_blobs(Some(block_root), block)
}

fn send_reconstructed_for_processing(
fn send_for_processing(
id: Id,
bl: &BlockLookups<T>,
block_root: Hash256,
constructed: RpcBlock<T::EthSpec>,
block: Arc<SignedBeaconBlock<T::EthSpec>>,
duration: Duration,
cx: &SyncNetworkContext<T>,
) -> Result<(), LookupRequestError> {
bl.send_block_for_processing(
block_root,
constructed,
RpcBlock::new_without_blobs(Some(block_root), block),
duration,
BlockProcessType::SingleBlock { id },
cx,
Expand All @@ -248,7 +231,6 @@ impl<T: BeaconChainTypes> RequestState<T> for BlockRequestState {
impl<T: BeaconChainTypes> RequestState<T> for BlobRequestState<T::EthSpec> {
type RequestType = BlobsByRootSingleBlockRequest;
type VerifiedResponseType = FixedBlobSidecarList<T::EthSpec>;
type ReconstructedResponseType = FixedBlobSidecarList<T::EthSpec>;

fn new_request(&self) -> Self::RequestType {
BlobsByRootSingleBlockRequest {
Expand Down Expand Up @@ -282,14 +264,7 @@ impl<T: BeaconChainTypes> RequestState<T> for BlobRequestState<T::EthSpec> {
components.merge_blobs(verified_response);
}

fn verified_to_reconstructed(
_block_root: Hash256,
blobs: FixedBlobSidecarList<T::EthSpec>,
) -> FixedBlobSidecarList<T::EthSpec> {
blobs
}

fn send_reconstructed_for_processing(
fn send_for_processing(
id: Id,
bl: &BlockLookups<T>,
block_root: Hash256,
Expand Down
9 changes: 1 addition & 8 deletions beacon_node/network/src/sync/block_lookups/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -427,14 +427,7 @@ impl<T: BeaconChainTypes> BlockLookups<T> {
.on_download_success()
.map_err(LookupRequestError::BadState)?;

R::send_reconstructed_for_processing(
id,
self,
block_root,
R::verified_to_reconstructed(block_root, verified_response),
seen_timestamp,
cx,
)?
R::send_for_processing(id, self, block_root, verified_response, seen_timestamp, cx)?
}
CachedChild::Err(e) => {
warn!(self.log, "Consistency error in cached block";
Expand Down

0 comments on commit 4c8143f

Please sign in to comment.