Merge pull request #3848 from emhane/empty_blobs_db
Don't write empty blobs to db
This commit is contained in:
commit
33ff84743d
728
Cargo.lock
generated
728
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -972,7 +972,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
|||||||
}
|
}
|
||||||
Ok((
|
Ok((
|
||||||
self.get_block(block_root).await?.map(Arc::new),
|
self.get_block(block_root).await?.map(Arc::new),
|
||||||
self.get_blobs(block_root).await?.map(Arc::new),
|
self.get_blobs(block_root).ok().flatten().map(Arc::new),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1048,11 +1048,32 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
|||||||
/// ## Errors
|
/// ## Errors
|
||||||
///
|
///
|
||||||
/// May return a database error.
|
/// May return a database error.
|
||||||
pub async fn get_blobs(
|
pub fn get_blobs(
|
||||||
&self,
|
&self,
|
||||||
block_root: &Hash256,
|
block_root: &Hash256,
|
||||||
) -> Result<Option<BlobsSidecar<T::EthSpec>>, Error> {
|
) -> Result<Option<BlobsSidecar<T::EthSpec>>, Error> {
|
||||||
Ok(self.store.get_blobs(block_root)?)
|
match self.store.get_blobs(block_root)? {
|
||||||
|
Some(blobs) => Ok(Some(blobs)),
|
||||||
|
None => {
|
||||||
|
if let Ok(Some(block)) = self.get_blinded_block(block_root) {
|
||||||
|
let expected_kzg_commitments = block.message().body().blob_kzg_commitments()?;
|
||||||
|
|
||||||
|
if expected_kzg_commitments.len() > 0 {
|
||||||
|
Err(Error::DBInconsistent(format!(
|
||||||
|
"Expected kzg commitments but no blobs stored for block root {}",
|
||||||
|
block_root
|
||||||
|
)))
|
||||||
|
} else {
|
||||||
|
Ok(Some(BlobsSidecar::empty_from_parts(
|
||||||
|
*block_root,
|
||||||
|
block.slot(),
|
||||||
|
)))
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Ok(None)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_blinded_block(
|
pub fn get_blinded_block(
|
||||||
@ -2945,9 +2966,11 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
|||||||
ops.push(StoreOp::PutState(block.state_root(), &state));
|
ops.push(StoreOp::PutState(block.state_root(), &state));
|
||||||
|
|
||||||
if let Some(blobs) = blobs? {
|
if let Some(blobs) = blobs? {
|
||||||
//FIXME(sean) using this for debugging for now
|
if blobs.blobs.len() > 0 {
|
||||||
info!(self.log, "Writing blobs to store"; "block_root" => ?block_root);
|
//FIXME(sean) using this for debugging for now
|
||||||
ops.push(StoreOp::PutBlobs(block_root, blobs));
|
info!(self.log, "Writing blobs to store"; "block_root" => ?block_root);
|
||||||
|
ops.push(StoreOp::PutBlobs(block_root, blobs));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
let txn_lock = self.store.hot_db.begin_rw_transaction();
|
let txn_lock = self.store.hot_db.begin_rw_transaction();
|
||||||
|
|
||||||
|
@ -658,20 +658,20 @@ impl<T: BeaconChainTypes> Worker<T> {
|
|||||||
let send_response = true;
|
let send_response = true;
|
||||||
|
|
||||||
for root in block_roots {
|
for root in block_roots {
|
||||||
match self.chain.store.get_blobs(&root) {
|
match self.chain.get_blobs(&root) {
|
||||||
Ok(Some(blob)) => {
|
Ok(Some(blobs)) => {
|
||||||
blobs_sent += 1;
|
blobs_sent += 1;
|
||||||
self.send_network_message(NetworkMessage::SendResponse {
|
self.send_network_message(NetworkMessage::SendResponse {
|
||||||
peer_id,
|
peer_id,
|
||||||
response: Response::BlobsByRange(Some(Arc::new(blob))),
|
response: Response::BlobsByRange(Some(Arc::new(blobs))),
|
||||||
id: request_id,
|
id: request_id,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
Ok(None) => {
|
Ok(None) => {
|
||||||
error!(
|
error!(
|
||||||
self.log,
|
self.log,
|
||||||
"Blob in the chain is not in the store";
|
"No blobs or block in the store for block root";
|
||||||
"request_root" => ?root
|
"block_root" => ?root
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user