Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions beacon_node/beacon_chain/src/beacon_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -614,10 +614,10 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
// but absent in the DB. This inconsistency halts pruning and dramastically increases disk
// size. Ref: https://github.com/sigp/lighthouse/issues/4773
let head_tracker = self.head_tracker.0.read();
batch.push(self.persist_head_in_batch(&head_tracker)?);
batch.push(self.persist_head_in_batch(&head_tracker));

let _fork_choice_timer = metrics::start_timer(&metrics::PERSIST_FORK_CHOICE);
batch.push(self.persist_fork_choice_in_batch()?);
batch.push(self.persist_fork_choice_in_batch());

self.store.hot_db.do_atomically(batch)?;
drop(head_tracker);
Expand All @@ -641,14 +641,14 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
pub fn persist_head_in_batch(
&self,
head_tracker_reader: &HeadTrackerReader,
) -> Result<KeyValueStoreOp, DBError> {
) -> KeyValueStoreOp {
Self::persist_head_in_batch_standalone(self.genesis_block_root, head_tracker_reader)
}

pub fn persist_head_in_batch_standalone(
genesis_block_root: Hash256,
head_tracker_reader: &HeadTrackerReader,
) -> Result<KeyValueStoreOp, DBError> {
) -> KeyValueStoreOp {
Self::make_persisted_head(genesis_block_root, head_tracker_reader)
.as_kv_store_op(BEACON_CHAIN_DB_KEY)
}
Expand Down
21 changes: 7 additions & 14 deletions beacon_node/beacon_chain/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -578,11 +578,7 @@ where
// This prevents the database from restarting in an inconsistent state if the anchor
// info or split point is written before the `PersistedBeaconChain`.
let retain_historic_states = self.chain_config.reconstruct_historic_states;
self.pending_io_batch.push(
store
.store_split_in_batch()
.map_err(|e| format!("Failed to store split: {:?}", e))?,
);
self.pending_io_batch.push(store.store_split_in_batch());
self.pending_io_batch.push(
store
.init_anchor_info(weak_subj_block.message(), retain_historic_states)
Expand Down Expand Up @@ -875,19 +871,16 @@ where
// This *must* be stored before constructing the `BeaconChain`, so that its `Drop` instance
// doesn't write a `PersistedBeaconChain` without the rest of the batch.
let head_tracker_reader = head_tracker.0.read();
self.pending_io_batch
.push(BeaconChain::<
Witness<TSlotClock, TEth1Backend, TEthSpec, THotStore, TColdStore>,
>::persist_head_in_batch_standalone(
genesis_block_root,
&head_tracker_reader,
)
.map_err(|e| format!("{e:?}"))?);
self.pending_io_batch.push(BeaconChain::<
Witness<TSlotClock, TEth1Backend, TEthSpec, THotStore, TColdStore>,
>::persist_head_in_batch_standalone(
genesis_block_root, &head_tracker_reader
));
self.pending_io_batch.push(BeaconChain::<
Witness<TSlotClock, TEth1Backend, TEthSpec, THotStore, TColdStore>,
>::persist_fork_choice_in_batch_standalone(
&fork_choice
).map_err(|e| format!("{e:?}"))?);
));
store
.hot_db
.do_atomically(self.pending_io_batch)
Expand Down
4 changes: 2 additions & 2 deletions beacon_node/beacon_chain/src/canonical_head.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1016,14 +1016,14 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
}

/// Return a database operation for writing fork choice to disk.
pub fn persist_fork_choice_in_batch(&self) -> Result<KeyValueStoreOp, store::Error> {
pub fn persist_fork_choice_in_batch(&self) -> KeyValueStoreOp {
Self::persist_fork_choice_in_batch_standalone(&self.canonical_head.fork_choice_read_lock())
}

/// Return a database operation for writing fork choice to disk.
pub fn persist_fork_choice_in_batch_standalone(
fork_choice: &BeaconForkChoice<T>,
) -> Result<KeyValueStoreOp, store::Error> {
) -> KeyValueStoreOp {
let persisted_fork_choice = PersistedForkChoice {
fork_choice: fork_choice.to_persisted(),
fork_choice_store: fork_choice.fc_store().to_persisted(),
Expand Down
4 changes: 2 additions & 2 deletions beacon_node/beacon_chain/src/eth1_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ impl StoreItem for SszEth1 {
DBColumn::Eth1Cache
}

fn as_store_bytes(&self) -> Result<Vec<u8>, StoreError> {
Ok(self.as_ssz_bytes())
fn as_store_bytes(&self) -> Vec<u8> {
self.as_ssz_bytes()
}

fn from_store_bytes(bytes: &[u8]) -> Result<Self, StoreError> {
Expand Down
2 changes: 1 addition & 1 deletion beacon_node/beacon_chain/src/migrate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,7 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> BackgroundMigrator<E, Ho
};
drop(head_tracker_lock);
batch.push(StoreOp::KeyValueOp(
persisted_head.as_kv_store_op(BEACON_CHAIN_DB_KEY)?,
persisted_head.as_kv_store_op(BEACON_CHAIN_DB_KEY),
));

store.do_atomically_with_block_and_blobs_cache(batch)?;
Expand Down
4 changes: 2 additions & 2 deletions beacon_node/beacon_chain/src/otb_verification_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ impl StoreItem for OptimisticTransitionBlock {
OTBColumn
}

fn as_store_bytes(&self) -> Result<Vec<u8>, StoreError> {
Ok(self.as_ssz_bytes())
fn as_store_bytes(&self) -> Vec<u8> {
self.as_ssz_bytes()
}

fn from_store_bytes(bytes: &[u8]) -> Result<Self, StoreError> {
Expand Down
4 changes: 2 additions & 2 deletions beacon_node/beacon_chain/src/persisted_beacon_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ impl StoreItem for PersistedBeaconChain {
DBColumn::BeaconChain
}

fn as_store_bytes(&self) -> Result<Vec<u8>, StoreError> {
Ok(self.as_ssz_bytes())
fn as_store_bytes(&self) -> Vec<u8> {
self.as_ssz_bytes()
}

fn from_store_bytes(bytes: &[u8]) -> Result<Self, StoreError> {
Expand Down
4 changes: 2 additions & 2 deletions beacon_node/beacon_chain/src/persisted_fork_choice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ macro_rules! impl_store_item {
DBColumn::ForkChoice
}

fn as_store_bytes(&self) -> Result<Vec<u8>, Error> {
Ok(self.as_ssz_bytes())
fn as_store_bytes(&self) -> Vec<u8> {
self.as_ssz_bytes()
}

fn from_store_bytes(bytes: &[u8]) -> Result<Self, Error> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ pub fn upgrade_to_v17<T: BeaconChainTypes>(
"Removing unused best_justified_checkpoint from fork choice store."
);

Ok(vec![v17.as_kv_store_op(FORK_CHOICE_DB_KEY)?])
Ok(vec![v17.as_kv_store_op(FORK_CHOICE_DB_KEY)])
}

pub fn downgrade_from_v17<T: BeaconChainTypes>(
Expand All @@ -84,5 +84,5 @@ pub fn downgrade_from_v17<T: BeaconChainTypes>(
"Adding junk best_justified_checkpoint to fork choice store."
);

Ok(vec![v11.as_kv_store_op(FORK_CHOICE_DB_KEY)?])
Ok(vec![v11.as_kv_store_op(FORK_CHOICE_DB_KEY)])
}
4 changes: 2 additions & 2 deletions beacon_node/network/src/persisted_dht.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ impl StoreItem for PersistedDht {
DBColumn::DhtEnrs
}

fn as_store_bytes(&self) -> Result<Vec<u8>, StoreError> {
Ok(rlp::encode_list(&self.enrs).to_vec())
fn as_store_bytes(&self) -> Vec<u8> {
rlp::encode_list(&self.enrs).to_vec()
}

fn from_store_bytes(bytes: &[u8]) -> Result<Self, StoreError> {
Expand Down
20 changes: 10 additions & 10 deletions beacon_node/operation_pool/src/persistence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@ impl<T: EthSpec> StoreItem for PersistedOperationPoolV5<T> {
DBColumn::OpPool
}

fn as_store_bytes(&self) -> Result<Vec<u8>, StoreError> {
Ok(self.as_ssz_bytes())
fn as_store_bytes(&self) -> Vec<u8> {
self.as_ssz_bytes()
}

fn from_store_bytes(bytes: &[u8]) -> Result<Self, StoreError> {
Expand All @@ -219,8 +219,8 @@ impl<T: EthSpec> StoreItem for PersistedOperationPoolV12<T> {
DBColumn::OpPool
}

fn as_store_bytes(&self) -> Result<Vec<u8>, StoreError> {
Ok(self.as_ssz_bytes())
fn as_store_bytes(&self) -> Vec<u8> {
self.as_ssz_bytes()
}

fn from_store_bytes(bytes: &[u8]) -> Result<Self, StoreError> {
Expand All @@ -233,8 +233,8 @@ impl<T: EthSpec> StoreItem for PersistedOperationPoolV14<T> {
DBColumn::OpPool
}

fn as_store_bytes(&self) -> Result<Vec<u8>, StoreError> {
Ok(self.as_ssz_bytes())
fn as_store_bytes(&self) -> Vec<u8> {
self.as_ssz_bytes()
}

fn from_store_bytes(bytes: &[u8]) -> Result<Self, StoreError> {
Expand All @@ -247,8 +247,8 @@ impl<T: EthSpec> StoreItem for PersistedOperationPoolV15<T> {
DBColumn::OpPool
}

fn as_store_bytes(&self) -> Result<Vec<u8>, StoreError> {
Ok(self.as_ssz_bytes())
fn as_store_bytes(&self) -> Vec<u8> {
self.as_ssz_bytes()
}

fn from_store_bytes(bytes: &[u8]) -> Result<Self, StoreError> {
Expand All @@ -262,8 +262,8 @@ impl<T: EthSpec> StoreItem for PersistedOperationPool<T> {
DBColumn::OpPool
}

fn as_store_bytes(&self) -> Result<Vec<u8>, StoreError> {
Ok(self.as_ssz_bytes())
fn as_store_bytes(&self) -> Vec<u8> {
self.as_ssz_bytes()
}

fn from_store_bytes(bytes: &[u8]) -> Result<Self, StoreError> {
Expand Down
4 changes: 2 additions & 2 deletions beacon_node/store/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,8 @@ impl StoreItem for OnDiskStoreConfig {
DBColumn::BeaconMeta
}

fn as_store_bytes(&self) -> Result<Vec<u8>, Error> {
Ok(self.as_ssz_bytes())
fn as_store_bytes(&self) -> Vec<u8> {
self.as_ssz_bytes()
}

fn from_store_bytes(bytes: &[u8]) -> Result<Self, Error> {
Expand Down
4 changes: 2 additions & 2 deletions beacon_node/store/src/hdiff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ impl StoreItem for HDiff {
DBColumn::BeaconStateDiff
}

fn as_store_bytes(&self) -> Result<Vec<u8>, crate::Error> {
Ok(self.as_ssz_bytes())
fn as_store_bytes(&self) -> Vec<u8> {
self.as_ssz_bytes()
}

fn from_store_bytes(bytes: &[u8]) -> Result<Self, crate::Error> {
Expand Down
Loading