Atomically update blob info with pruned blobs

This commit is contained in:
Emilia Hane 2023-01-24 10:27:30 +01:00
parent 5d2480c762
commit 6dff69bde9
No known key found for this signature in database
GPG Key ID: E73394F9C09206FA
2 changed files with 16 additions and 8 deletions

View File

@ -827,6 +827,10 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
get_key_for_col(DBColumn::BeaconBlobOrphan.into(), block_root.as_bytes());
key_value_batch.push(KeyValueStoreOp::PutKeyValue(db_key, [].into()));
}
StoreOp::PutRawKVStoreOp(kv_store_op) => {
key_value_batch.push(kv_store_op);
}
}
}
Ok(key_value_batch)
@ -869,6 +873,8 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
StoreOp::DeleteExecutionPayload(_) => (),
StoreOp::PutOrphanedBlobsKey(_) => (),
StoreOp::PutRawKVStoreOp(_) => (),
}
}
@ -1865,8 +1871,16 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
break;
}
}
let blobs_sidecars_pruned = ops.len();
let update_blob_info = self.compare_and_set_blob_info(
Some(blob_info),
Some(BlobInfo {
oldest_blob_slot: end_slot + 1,
}),
)?;
ops.push(StoreOp::PutRawKVStoreOp(update_blob_info));
self.do_atomically(ops)?;
info!(
self.log,
@ -1874,13 +1888,6 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
"blobs_sidecars_pruned" => blobs_sidecars_pruned,
);
self.compare_and_set_blob_info_with_write(
Some(blob_info),
Some(BlobInfo {
oldest_blob_slot: end_slot + 1,
}),
)?;
Ok(())
}
}

View File

@ -166,6 +166,7 @@ pub enum StoreOp<'a, E: EthSpec> {
DeleteBlobs(Hash256),
DeleteState(Hash256, Option<Slot>),
DeleteExecutionPayload(Hash256),
PutRawKVStoreOp(KeyValueStoreOp),
}
/// A unique column identifier.