Merge remote-tracking branch 'origin/unstable' into tree-states

This commit is contained in:
Michael Sproul
2023-10-19 12:07:35 +11:00
189 changed files with 1475 additions and 951 deletions

View File

@@ -253,7 +253,7 @@ impl BlockId {
}
/// Return the `BlobSidecarList` identified by `self`.
pub async fn blob_sidecar_list<T: BeaconChainTypes>(
pub fn blob_sidecar_list<T: BeaconChainTypes>(
&self,
chain: &BeaconChain<T>,
) -> Result<BlobSidecarList<T::EthSpec>, warp::Rejection> {
@@ -263,12 +263,12 @@ impl BlockId {
.map_err(warp_utils::reject::beacon_chain_error)
}
pub async fn blob_sidecar_list_filtered<T: BeaconChainTypes>(
pub fn blob_sidecar_list_filtered<T: BeaconChainTypes>(
&self,
indices: BlobIndicesQuery,
chain: &BeaconChain<T>,
) -> Result<BlobSidecarList<T::EthSpec>, warp::Rejection> {
let blob_sidecar_list = self.blob_sidecar_list(chain).await?;
let blob_sidecar_list = self.blob_sidecar_list(chain)?;
let blob_sidecar_list_filtered = match indices.indices {
Some(vec) => {
let list = blob_sidecar_list

View File

@@ -1727,16 +1727,18 @@ pub fn serve<T: BeaconChainTypes>(
.and(block_id_or_err)
.and(warp::query::<api_types::BlobIndicesQuery>())
.and(warp::path::end())
.and(task_spawner_filter.clone())
.and(chain_filter.clone())
.and(warp::header::optional::<api_types::Accept>("accept"))
.and_then(
.then(
|block_id: BlockId,
indices: api_types::BlobIndicesQuery,
task_spawner: TaskSpawner<T::EthSpec>,
chain: Arc<BeaconChain<T>>,
accept_header: Option<api_types::Accept>| {
async move {
task_spawner.blocking_response_task(Priority::P1, move || {
let blob_sidecar_list_filtered =
block_id.blob_sidecar_list_filtered(indices, &chain).await?;
block_id.blob_sidecar_list_filtered(indices, &chain)?;
match accept_header {
Some(api_types::Accept::Ssz) => Response::builder()
.status(200)
@@ -1753,7 +1755,7 @@ pub fn serve<T: BeaconChainTypes>(
))
.into_response()),
}
}
})
},
);
@@ -4423,6 +4425,9 @@ pub fn serve<T: BeaconChainTypes>(
let receiver = match topic {
api_types::EventTopic::Head => event_handler.subscribe_head(),
api_types::EventTopic::Block => event_handler.subscribe_block(),
api_types::EventTopic::BlobSidecar => {
event_handler.subscribe_blob_sidecar()
}
api_types::EventTopic::Attestation => {
event_handler.subscribe_attestation()
}

View File

@@ -75,8 +75,7 @@ pub async fn publish_block<T: BeaconChainTypes, B: IntoGossipVerifiedBlockConten
.unwrap_or_else(|| Duration::from_secs(0));
info!(log, "Signed block published to network via HTTP API"; "slot" => block.slot(), "publish_delay" => ?publish_delay);
// Send the block, regardless of whether or not it is valid. The API
// specification is very clear that this is the desired behaviour.
match block.as_ref() {
SignedBeaconBlock::Base(_)
| SignedBeaconBlock::Altair(_)
@@ -199,9 +198,17 @@ pub async fn publish_block<T: BeaconChainTypes, B: IntoGossipVerifiedBlockConten
if let Some(gossip_verified_blobs) = gossip_verified_blobs {
for blob in gossip_verified_blobs {
if let Err(e) = chain.process_gossip_blob(blob).await {
return Err(warp_utils::reject::custom_bad_request(format!(
"Invalid blob: {e}"
)));
let msg = format!("Invalid blob: {e}");
return if let BroadcastValidation::Gossip = validation_level {
Err(warp_utils::reject::broadcast_without_import(msg))
} else {
error!(
log,
"Invalid blob provided to HTTP API";
"reason" => &msg
);
Err(warp_utils::reject::custom_bad_request(msg))
};
}
}
}