Gloas fork choice redux (#9025)

Co-Authored-By: hopinheimer <knmanas6@gmail.com>

Co-Authored-By: Michael Sproul <michael@sigmaprime.io>

Co-Authored-By: hopinheimer <48147533+hopinheimer@users.noreply.github.com>

Co-Authored-By: Eitan Seri- Levi <eserilev@gmail.com>

Co-Authored-By: dapplion <35266934+dapplion@users.noreply.github.com>

Co-Authored-By: Michael Sproul <michaelsproul@users.noreply.github.com>

Co-Authored-By: Jimmy Chen <jchen.tc@gmail.com>

Co-Authored-By: Daniel Knopik <107140945+dknopik@users.noreply.github.com>
This commit is contained in:
Michael Sproul
2026-04-03 19:35:02 +11:00
committed by GitHub
parent 99f5a92b98
commit 65c2e01612
40 changed files with 4061 additions and 834 deletions

View File

@@ -168,6 +168,16 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
.map_err(BeaconChainError::TokioJoin)?
.ok_or(BeaconChainError::RuntimeShutdown)??;
// TODO(gloas): optimistic sync is not supported for Gloas, maybe we could re-add it
if payload_verification_outcome
.payload_verification_status
.is_optimistic()
{
return Err(EnvelopeError::OptimisticSyncNotSupported {
block_root: import_data.block_root,
});
}
Ok(ExecutedEnvelope::new(
signed_envelope,
import_data,
@@ -236,16 +246,15 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
// Note that a duplicate cache/payload status table should prevent this from happening
// but it doesnt hurt to be defensive.
// TODO(gloas) when the code below is implemented we can delete this drop
drop(fork_choice_reader);
// 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);
// 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)?;
// Update the block's payload to received in fork choice, which creates the `Full` virtual
// node which can be eligible for head.
fork_choice
.on_valid_payload_envelope_received(block_root)
.map_err(|e| EnvelopeError::InternalError(format!("{e:?}")))?;
// TODO(gloas) emit SSE event if the payload became the new head payload
@@ -299,10 +308,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.

View File

@@ -182,6 +182,8 @@ pub enum EnvelopeError {
payload_slot: Slot,
latest_finalized_slot: Slot,
},
/// Optimistic sync is not supported for Gloas payload envelopes.
OptimisticSyncNotSupported { block_root: Hash256 },
/// Some Beacon Chain Error
BeaconChainError(Arc<BeaconChainError>),
/// Some Beacon State error