don't expect context bytes for blob messages

This commit is contained in:
realbigsean
2022-12-20 19:32:54 -05:00
parent 9c46a1cb21
commit a67fa516c7
4 changed files with 39 additions and 33 deletions

View File

@@ -570,38 +570,42 @@ fn handle_v1_response<T: EthSpec>(
SignedBeaconBlock::Base(SignedBeaconBlockBase::from_ssz_bytes(decoded_buffer)?),
)))),
Protocol::BlobsByRange => {
let fork_name = fork_name.take().ok_or_else(|| {
RPCError::ErrorResponse(
RPCResponseErrorCode::InvalidRequest,
format!("No context bytes provided for {} response", protocol),
)
})?;
match fork_name {
ForkName::Eip4844 => Ok(Some(RPCResponse::BlobsByRange(Arc::new(
BlobsSidecar::from_ssz_bytes(decoded_buffer)?,
)))),
_ => Err(RPCError::ErrorResponse(
RPCResponseErrorCode::InvalidRequest,
"Invalid forkname for blobsbyrange".to_string(),
)),
}
Ok(Some(RPCResponse::BlobsByRange(Arc::new(
BlobsSidecar::from_ssz_bytes(decoded_buffer)?,
))))
//FIXME(sean) do we need context bytes?
// let fork_name = fork_name.take().ok_or_else(|| {
// RPCError::ErrorResponse(
// RPCResponseErrorCode::InvalidRequest,
// format!("No context bytes provided for {} response", protocol),
// )
// })?;
// match fork_name {
// ForkName::Eip4844 => ,
// _ => Err(RPCError::ErrorResponse(
// RPCResponseErrorCode::InvalidRequest,
// "Invalid forkname for blobsbyrange".to_string(),
// )),
// }
}
Protocol::BlobsByRoot => {
let fork_name = fork_name.take().ok_or_else(|| {
RPCError::ErrorResponse(
RPCResponseErrorCode::InvalidRequest,
format!("No context bytes provided for {} response", protocol),
)
})?;
match fork_name {
ForkName::Eip4844 => Ok(Some(RPCResponse::BlobsByRoot(Arc::new(
SignedBeaconBlockAndBlobsSidecar::from_ssz_bytes(decoded_buffer)?,
)))),
_ => Err(RPCError::ErrorResponse(
RPCResponseErrorCode::InvalidRequest,
"Invalid forkname for blobsbyroot".to_string(),
)),
}
Ok(Some(RPCResponse::BlobsByRoot(Arc::new(
SignedBeaconBlockAndBlobsSidecar::from_ssz_bytes(decoded_buffer)?,
))))
//FIXME(sean) do we need context bytes?
// let fork_name = fork_name.take().ok_or_else(|| {
// RPCError::ErrorResponse(
// RPCResponseErrorCode::InvalidRequest,
// format!("No context bytes provided for {} response", protocol),
// )
// })?;
// match fork_name {
// ForkName::Eip4844 =>
// _ => Err(RPCError::ErrorResponse(
// RPCResponseErrorCode::InvalidRequest,
// "Invalid forkname for blobsbyroot".to_string(),
// )),
// }
}
Protocol::Ping => Ok(Some(RPCResponse::Pong(Ping {
data: u64::from_ssz_bytes(decoded_buffer)?,

View File

@@ -503,6 +503,8 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
}
pub fn get_blobs(&self, block_root: &Hash256) -> Result<Option<BlobsSidecar<E>>, Error> {
// FIXME(sean) I was attempting to use a blob cache here but was getting deadlocks,
// may want to attempt to use one again
if let Some(bytes) = self
.hot_db
.get_bytes(DBColumn::BeaconBlob.into(), block_root.as_bytes())?