mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-30 20:57:10 +00:00
Resolve merge conflicts
This commit is contained in:
@@ -93,7 +93,6 @@ struct BlockCache<E: EthSpec> {
|
||||
block_cache: LruCache<Hash256, SignedBeaconBlock<E>>,
|
||||
blob_cache: LruCache<Hash256, BlobSidecarList<E>>,
|
||||
data_column_cache: LruCache<Hash256, HashMap<ColumnIndex, Arc<DataColumnSidecar<E>>>>,
|
||||
payload_envelope_cache: LruCache<Hash256, SignedExecutionPayloadEnvelope<E>>,
|
||||
data_column_custody_info_cache: Option<DataColumnCustodyInfo>,
|
||||
}
|
||||
|
||||
@@ -103,7 +102,6 @@ impl<E: EthSpec> BlockCache<E> {
|
||||
block_cache: LruCache::new(size),
|
||||
blob_cache: LruCache::new(size),
|
||||
data_column_cache: LruCache::new(size),
|
||||
payload_envelope_cache: LruCache::new(size),
|
||||
data_column_custody_info_cache: None,
|
||||
}
|
||||
}
|
||||
@@ -118,14 +116,6 @@ impl<E: EthSpec> BlockCache<E> {
|
||||
.get_or_insert_mut(block_root, Default::default)
|
||||
.insert(*data_column.index(), data_column);
|
||||
}
|
||||
pub fn put_payload_envelope(
|
||||
&mut self,
|
||||
block_root: Hash256,
|
||||
payload_envelope: SignedExecutionPayloadEnvelope<E>,
|
||||
) {
|
||||
self.payload_envelope_cache
|
||||
.put(block_root, payload_envelope);
|
||||
}
|
||||
pub fn put_data_column_custody_info(
|
||||
&mut self,
|
||||
data_column_custody_info: Option<DataColumnCustodyInfo>,
|
||||
@@ -149,12 +139,6 @@ impl<E: EthSpec> BlockCache<E> {
|
||||
.get(block_root)
|
||||
.and_then(|map| map.get(column_index).cloned())
|
||||
}
|
||||
pub fn get_payload_envelope<'a>(
|
||||
&'a mut self,
|
||||
block_root: &Hash256,
|
||||
) -> Option<&'a SignedExecutionPayloadEnvelope<E>> {
|
||||
self.payload_envelope_cache.get(block_root)
|
||||
}
|
||||
pub fn get_data_column_custody_info(&self) -> Option<DataColumnCustodyInfo> {
|
||||
self.data_column_custody_info_cache.clone()
|
||||
}
|
||||
@@ -167,14 +151,10 @@ impl<E: EthSpec> BlockCache<E> {
|
||||
pub fn delete_data_columns(&mut self, block_root: &Hash256) {
|
||||
let _ = self.data_column_cache.pop(block_root);
|
||||
}
|
||||
pub fn delete_payload_envelope(&mut self, block_root: &Hash256) {
|
||||
let _ = self.payload_envelope_cache.pop(block_root);
|
||||
}
|
||||
pub fn delete(&mut self, block_root: &Hash256) {
|
||||
self.delete_block(block_root);
|
||||
self.delete_blobs(block_root);
|
||||
self.delete_data_columns(block_root);
|
||||
self.delete_payload_envelope(block_root);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -528,10 +508,6 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
|
||||
&metrics::STORE_BEACON_BLOB_CACHE_SIZE,
|
||||
cache.blob_cache.len() as i64,
|
||||
);
|
||||
metrics::set_gauge(
|
||||
&metrics::STORE_BEACON_PAYLOAD_ENVELOPE_CACHE_SIZE,
|
||||
cache.payload_envelope_cache.len() as i64,
|
||||
);
|
||||
}
|
||||
let state_cache = self.state_cache.lock();
|
||||
metrics::set_gauge(
|
||||
@@ -773,16 +749,6 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
|
||||
&self,
|
||||
block_root: &Hash256,
|
||||
) -> Result<Option<SignedExecutionPayloadEnvelope<E>>, Error> {
|
||||
// Check the cache.
|
||||
if let Some(envelope) = self
|
||||
.block_cache
|
||||
.as_ref()
|
||||
.and_then(|cache| cache.lock().get_payload_envelope(block_root).cloned())
|
||||
{
|
||||
metrics::inc_counter(&metrics::BEACON_PAYLOAD_ENVELOPE_CACHE_HIT_COUNT);
|
||||
return Ok(Some(envelope));
|
||||
}
|
||||
|
||||
let key = block_root.as_slice();
|
||||
|
||||
match self
|
||||
@@ -791,29 +757,14 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
|
||||
{
|
||||
Some(bytes) => {
|
||||
let envelope = SignedExecutionPayloadEnvelope::from_ssz_bytes(&bytes)?;
|
||||
self.block_cache.as_ref().inspect(|cache| {
|
||||
cache
|
||||
.lock()
|
||||
.put_payload_envelope(*block_root, envelope.clone())
|
||||
});
|
||||
Ok(Some(envelope))
|
||||
}
|
||||
None => Ok(None),
|
||||
}
|
||||
}
|
||||
|
||||
/// Check if the payload envelope for a block exists on disk or in cache.
|
||||
/// Check if the payload envelope for a block exists on disk.
|
||||
pub fn payload_envelope_exists(&self, block_root: &Hash256) -> Result<bool, Error> {
|
||||
// Check the cache first.
|
||||
if self
|
||||
.block_cache
|
||||
.as_ref()
|
||||
.and_then(|cache| cache.lock().get_payload_envelope(block_root).cloned())
|
||||
.is_some()
|
||||
{
|
||||
return Ok(true);
|
||||
}
|
||||
|
||||
self.hot_db.key_exists(
|
||||
SignedExecutionPayloadEnvelope::<E>::db_column(),
|
||||
block_root.as_slice(),
|
||||
@@ -1126,13 +1077,7 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
|
||||
SignedExecutionPayloadEnvelope::<E>::db_column(),
|
||||
block_root.as_slice(),
|
||||
&payload_envelope.as_ssz_bytes(),
|
||||
)?;
|
||||
self.block_cache.as_ref().inspect(|cache| {
|
||||
cache
|
||||
.lock()
|
||||
.put_payload_envelope(*block_root, payload_envelope)
|
||||
});
|
||||
Ok(())
|
||||
)
|
||||
}
|
||||
|
||||
/// Store a state in the store.
|
||||
@@ -1651,9 +1596,7 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
|
||||
|
||||
StoreOp::PutDataColumns(_, _) => (),
|
||||
|
||||
StoreOp::PutPayloadEnvelope(block_root, payload_envelope) => {
|
||||
guard.put_payload_envelope(block_root, (*payload_envelope).clone());
|
||||
}
|
||||
StoreOp::PutPayloadEnvelope(_, _) => (),
|
||||
|
||||
StoreOp::PutState(_, _) => (),
|
||||
|
||||
@@ -1663,9 +1606,7 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
|
||||
guard.delete_block(&block_root);
|
||||
}
|
||||
|
||||
StoreOp::DeletePayloadEnvelope(block_root) => {
|
||||
guard.delete_payload_envelope(&block_root);
|
||||
}
|
||||
StoreOp::DeletePayloadEnvelope(_) => (),
|
||||
|
||||
StoreOp::DeleteState(_, _) => (),
|
||||
|
||||
|
||||
@@ -270,13 +270,6 @@ pub static STORE_BEACON_BLOB_CACHE_SIZE: LazyLock<Result<IntGauge>> = LazyLock::
|
||||
"Current count of items in beacon store blob cache",
|
||||
)
|
||||
});
|
||||
pub static STORE_BEACON_PAYLOAD_ENVELOPE_CACHE_SIZE: LazyLock<Result<IntGauge>> =
|
||||
LazyLock::new(|| {
|
||||
try_create_int_gauge(
|
||||
"store_beacon_payload_envelope_cache_size",
|
||||
"Current count of items in beacon store payload envelope cache",
|
||||
)
|
||||
});
|
||||
pub static STORE_BEACON_STATE_CACHE_SIZE: LazyLock<Result<IntGauge>> = LazyLock::new(|| {
|
||||
try_create_int_gauge(
|
||||
"store_beacon_state_cache_size",
|
||||
|
||||
Reference in New Issue
Block a user