Hacky fork choice changes

This commit is contained in:
Eitan Seri- Levi
2026-02-12 23:58:42 -08:00
parent 7d0d438fd4
commit dc143d9709
5 changed files with 95 additions and 5 deletions

View File

@@ -233,10 +233,14 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
return Err(EnvelopeError::BlockRootUnknown { block_root });
}
// TODO(gloas) no fork choice logic yet
// Take an exclusive write-lock on fork choice. It's very important to prevent deadlocks by
// avoiding taking other locks whilst holding this lock.
// let fork_choice = parking_lot::RwLockUpgradableReadGuard::upgrade(fork_choice_reader);
let mut fork_choice = parking_lot::RwLockUpgradableReadGuard::upgrade(fork_choice_reader);
// Update the node's payload_status from PENDING to FULL in fork choice.
fork_choice
.on_execution_payload(block_root)
.map_err(|e| EnvelopeError::InternalError(format!("{e:?}")))?;
// TODO(gloas) Do we need this check? Do not import a block that doesn't descend from the finalized root.
// let signed_block = check_block_is_finalized_checkpoint_or_descendant(self, &fork_choice, signed_block)?;
@@ -311,10 +315,9 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
drop(db_span);
// TODO(gloas) drop fork choice lock
// The fork choice write-lock is dropped *after* the on-disk database has been updated.
// This prevents inconsistency between the two at the expense of concurrency.
// drop(fork_choice);
drop(fork_choice);
// We're declaring the envelope "imported" at this point, since fork choice and the DB know
// about it.