mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-09 03:31:45 +00:00
Add PeerDAS RPC import boilerplate (#6238)
* Add PeerDAS RPC import boilerplate * revert refactor * Remove allow
This commit is contained in:
@@ -476,6 +476,30 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
|
||||
})
|
||||
}
|
||||
|
||||
/// Create a new `Work` event for some custody columns. `process_rpc_custody_columns` reports
|
||||
/// the result back to sync.
|
||||
pub fn send_rpc_custody_columns(
|
||||
self: &Arc<Self>,
|
||||
block_root: Hash256,
|
||||
custody_columns: DataColumnSidecarList<T::EthSpec>,
|
||||
seen_timestamp: Duration,
|
||||
process_type: BlockProcessType,
|
||||
) -> Result<(), Error<T::EthSpec>> {
|
||||
let s = self.clone();
|
||||
self.try_send(BeaconWorkEvent {
|
||||
drop_during_sync: false,
|
||||
work: Work::RpcCustodyColumn(Box::pin(async move {
|
||||
s.process_rpc_custody_columns(
|
||||
block_root,
|
||||
custody_columns,
|
||||
seen_timestamp,
|
||||
process_type,
|
||||
)
|
||||
.await;
|
||||
})),
|
||||
})
|
||||
}
|
||||
|
||||
/// Create a new work event to import `blocks` as a beacon chain segment.
|
||||
pub fn send_chain_segment(
|
||||
self: &Arc<Self>,
|
||||
|
||||
@@ -24,7 +24,7 @@ use store::KzgCommitment;
|
||||
use tokio::sync::mpsc;
|
||||
use types::beacon_block_body::format_kzg_commitments;
|
||||
use types::blob_sidecar::FixedBlobSidecarList;
|
||||
use types::BlockImportSource;
|
||||
use types::{BlockImportSource, DataColumnSidecarList};
|
||||
use types::{Epoch, Hash256};
|
||||
|
||||
/// Id associated to a batch processing request, either a sync batch or a parent lookup.
|
||||
@@ -307,6 +307,60 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
|
||||
});
|
||||
}
|
||||
|
||||
pub async fn process_rpc_custody_columns(
|
||||
self: Arc<NetworkBeaconProcessor<T>>,
|
||||
block_root: Hash256,
|
||||
custody_columns: DataColumnSidecarList<T::EthSpec>,
|
||||
_seen_timestamp: Duration,
|
||||
process_type: BlockProcessType,
|
||||
) {
|
||||
let result = self
|
||||
.chain
|
||||
.process_rpc_custody_columns(custody_columns)
|
||||
.await;
|
||||
|
||||
match &result {
|
||||
Ok(availability) => match availability {
|
||||
AvailabilityProcessingStatus::Imported(hash) => {
|
||||
debug!(
|
||||
self.log,
|
||||
"Block components retrieved";
|
||||
"result" => "imported block and custody columns",
|
||||
"block_hash" => %hash,
|
||||
);
|
||||
self.chain.recompute_head_at_current_slot().await;
|
||||
}
|
||||
AvailabilityProcessingStatus::MissingComponents(_, _) => {
|
||||
debug!(
|
||||
self.log,
|
||||
"Missing components over rpc";
|
||||
"block_hash" => %block_root,
|
||||
);
|
||||
}
|
||||
},
|
||||
Err(BlockError::BlockIsAlreadyKnown(_)) => {
|
||||
debug!(
|
||||
self.log,
|
||||
"Custody columns have already been imported";
|
||||
"block_hash" => %block_root,
|
||||
);
|
||||
}
|
||||
Err(e) => {
|
||||
warn!(
|
||||
self.log,
|
||||
"Error when importing rpc custody columns";
|
||||
"error" => ?e,
|
||||
"block_hash" => %block_root,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
self.send_sync_message(SyncMessage::BlockComponentProcessed {
|
||||
process_type,
|
||||
result: result.into(),
|
||||
});
|
||||
}
|
||||
|
||||
/// Attempt to import the chain segment (`blocks`) to the beacon chain, informing the sync
|
||||
/// thread if more blocks are needed to process it.
|
||||
pub async fn process_chain_segment(
|
||||
|
||||
Reference in New Issue
Block a user