fix rebase conflicts
This commit is contained in:
parent
e0b1a0841c
commit
05c51b37b1
5
.vscode/settings.json
vendored
Normal file
5
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"cSpell.words": [
|
||||||
|
"blbo"
|
||||||
|
]
|
||||||
|
}
|
@ -1072,7 +1072,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
|||||||
block_root: &Hash256,
|
block_root: &Hash256,
|
||||||
data_availability_boundary: Epoch,
|
data_availability_boundary: Epoch,
|
||||||
) -> Result<Option<BlobsSidecar<T::EthSpec>>, Error> {
|
) -> Result<Option<BlobsSidecar<T::EthSpec>>, Error> {
|
||||||
match self.store.get_blobs(block_root)? {
|
match self.store.get_blobs(block_root, slot)? {
|
||||||
Some(blobs) => Ok(Some(blobs)),
|
Some(blobs) => Ok(Some(blobs)),
|
||||||
None => {
|
None => {
|
||||||
// Check for the corresponding block to understand whether we *should* have blobs.
|
// Check for the corresponding block to understand whether we *should* have blobs.
|
||||||
|
@ -910,7 +910,7 @@ where
|
|||||||
|
|
||||||
self.db_path = Some(hot_path.into());
|
self.db_path = Some(hot_path.into());
|
||||||
self.freezer_db_path = Some(cold_path.into());
|
self.freezer_db_path = Some(cold_path.into());
|
||||||
self.blobs_freezer_db_path = cold_blobs_path;
|
self.blobs_freezer_db_path = cold_blobs_path.clone();
|
||||||
|
|
||||||
let inner_spec = spec.clone();
|
let inner_spec = spec.clone();
|
||||||
let deposit_contract_deploy_block = context
|
let deposit_contract_deploy_block = context
|
||||||
|
@ -218,7 +218,7 @@ impl BlockId {
|
|||||||
chain: &BeaconChain<T>,
|
chain: &BeaconChain<T>,
|
||||||
) -> Result<Arc<BlobsSidecar<T::EthSpec>>, warp::Rejection> {
|
) -> Result<Arc<BlobsSidecar<T::EthSpec>>, warp::Rejection> {
|
||||||
let root = self.root(chain)?.0;
|
let root = self.root(chain)?.0;
|
||||||
match chain.store.get_blobs(&root) {
|
match chain.get_blobs(&root, None) {
|
||||||
Ok(Some(blob)) => Ok(Arc::new(blob)),
|
Ok(Some(blob)) => Ok(Arc::new(blob)),
|
||||||
Ok(None) => Err(warp_utils::reject::custom_not_found(format!(
|
Ok(None) => Err(warp_utils::reject::custom_not_found(format!(
|
||||||
"Blob with block root {} is not in the store",
|
"Blob with block root {} is not in the store",
|
||||||
|
@ -795,12 +795,14 @@ impl<T: BeaconChainTypes> Worker<T> {
|
|||||||
// remove all skip slots
|
// remove all skip slots
|
||||||
let block_roots = block_roots.into_iter().flatten().collect::<Vec<_>>();
|
let block_roots = block_roots.into_iter().flatten().collect::<Vec<_>>();
|
||||||
|
|
||||||
|
let mut slot_hint: Option<Slot> = None;
|
||||||
let mut blobs_sent = 0;
|
let mut blobs_sent = 0;
|
||||||
let mut send_response = true;
|
let mut send_response = true;
|
||||||
|
|
||||||
for root in block_roots {
|
for root in block_roots {
|
||||||
match self.chain.get_blobs(&root, data_availability_boundary) {
|
match self.chain.get_blobs(&root, data_availability_boundary) {
|
||||||
Ok(Some(blobs)) => {
|
Ok(Some(blobs)) => {
|
||||||
|
slot_hint = Some(blobs.beacon_block_slot + 1);
|
||||||
blobs_sent += 1;
|
blobs_sent += 1;
|
||||||
self.send_network_message(NetworkMessage::SendResponse {
|
self.send_network_message(NetworkMessage::SendResponse {
|
||||||
peer_id,
|
peer_id,
|
||||||
|
@ -533,31 +533,27 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_blobs(&self, block_root: &Hash256) -> Result<Option<BlobsSidecar<E>>, Error> {
|
/// Fetch a blobs sidecar from the store.
|
||||||
// FIXME(sean) I was attempting to use a blob cache here but was getting deadlocks,
|
///
|
||||||
// may want to attempt to use one again
|
/// If `slot` is provided then it will be used as a hint as to which database should
|
||||||
if let Some(bytes) = self
|
/// be checked first.
|
||||||
.hot_db
|
pub fn get_blobs(
|
||||||
.get_bytes(DBColumn::BeaconBlob.into(), block_root.as_bytes())?
|
&self,
|
||||||
{
|
block_root: &Hash256,
|
||||||
let ret = BlobsSidecar::from_ssz_bytes(&bytes)?;
|
slot: Option<Slot>,
|
||||||
self.blob_cache.lock().put(*block_root, ret.clone());
|
) -> Result<Option<BlobsSidecar<E>>, Error> {
|
||||||
Ok(Some(ret))
|
if let Some(slot) = slot {
|
||||||
} else {
|
if slot < self.get_split_slot() {
|
||||||
let blobs_freezer = if let Some(ref cold_blobs_db) = self.cold_blobs_db {
|
return match self.load_cold_blobs(block_root)? {
|
||||||
cold_blobs_db
|
Some(blobs) => Ok(Some(blobs)),
|
||||||
} else {
|
None => self.load_hot_blobs(block_root),
|
||||||
&self.cold_db
|
};
|
||||||
};
|
|
||||||
|
|
||||||
if let Some(ref blobs_bytes) =
|
|
||||||
blobs_freezer.get_bytes(DBColumn::BeaconBlob.into(), block_root.as_bytes())?
|
|
||||||
{
|
|
||||||
Ok(Some(BlobsSidecar::from_ssz_bytes(blobs_bytes)?))
|
|
||||||
} else {
|
|
||||||
Ok(None)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
match self.load_hot_blobs(block_root)? {
|
||||||
|
Some(blobs) => Ok(Some(blobs)),
|
||||||
|
None => self.load_cold_blobs(block_root),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn blobs_as_kv_store_ops(
|
pub fn blobs_as_kv_store_ops(
|
||||||
@ -1236,6 +1232,41 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Load a blobs sidecar from the hot database.
|
||||||
|
pub fn load_hot_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())?
|
||||||
|
{
|
||||||
|
let ret = BlobsSidecar::from_ssz_bytes(&bytes)?;
|
||||||
|
self.blob_cache.lock().put(*block_root, ret.clone());
|
||||||
|
Ok(Some(ret))
|
||||||
|
} else {
|
||||||
|
Ok(None)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Try to load a blobs from the freezer database.
|
||||||
|
///
|
||||||
|
/// Return `None` if no blobs sidecar with `block_root` lies in the freezer.
|
||||||
|
pub fn load_cold_blobs(&self, block_root: &Hash256) -> Result<Option<BlobsSidecar<E>>, Error> {
|
||||||
|
let blobs_freezer = if let Some(ref cold_blobs_db) = self.cold_blobs_db {
|
||||||
|
cold_blobs_db
|
||||||
|
} else {
|
||||||
|
&self.cold_db
|
||||||
|
};
|
||||||
|
|
||||||
|
if let Some(ref blobs_bytes) =
|
||||||
|
blobs_freezer.get_bytes(DBColumn::BeaconBlob.into(), block_root.as_bytes())?
|
||||||
|
{
|
||||||
|
Ok(Some(BlobsSidecar::from_ssz_bytes(blobs_bytes)?))
|
||||||
|
} else {
|
||||||
|
Ok(None)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Get a reference to the `ChainSpec` used by the database.
|
/// Get a reference to the `ChainSpec` used by the database.
|
||||||
pub fn get_chain_spec(&self) -> &ChainSpec {
|
pub fn get_chain_spec(&self) -> &ChainSpec {
|
||||||
&self.spec
|
&self.spec
|
||||||
@ -1994,7 +2025,7 @@ pub fn migrate_database<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Prepare migration of blobs to freezer.
|
// Prepare migration of blobs to freezer.
|
||||||
if let Some(blobs) = store.get_blobs(&block_root)? {
|
if let Some(blobs) = store.get_blobs(&block_root, Some(slot))? {
|
||||||
hot_db_ops.push(StoreOp::DeleteBlobs(block_root));
|
hot_db_ops.push(StoreOp::DeleteBlobs(block_root));
|
||||||
cold_blobs_db_ops.push(StoreOp::PutBlobs(block_root, Arc::new(blobs)));
|
cold_blobs_db_ops.push(StoreOp::PutBlobs(block_root, Arc::new(blobs)));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user