Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
e61bb06
Update EF tests to v1.7.0-beta.5
eserilev Nov 28, 2026
18c4d40
Round slot component durations to the nearest millisecond (consensus-…
eserilev Nov 28, 2026
cb3be3f
Compute committee weight precisely in FCR (consensus-specs#5670)
eserilev Nov 28, 2026
37c6881
Assert support_discount <= maximum_support in FCR (consensus-specs#5788)
eserilev Nov 28, 2026
c7db74f
Add pending parent node support to the FCR discount (consensus-specs#…
eserilev Nov 28, 2026
3c7b609
Skip seen bitsets of a different length in subset checks (consensus-s…
eserilev Nov 28, 2026
8501ba0
Ignore voluntary exits with pending partial withdrawals (consensus-sp…
eserilev Nov 28, 2026
9db401e
Unset fork slot payload availability in upgrade_to_gloas (consensus-s…
eserilev Nov 28, 2026
e9d031c
Add payload consistency checks to envelope gossip validation (consens…
eserilev Nov 28, 2026
9ad955f
Bound envelope transaction count by the parent payload's gas limit (c…
eserilev Nov 28, 2026
bc89d5d
Verify the payload's block hash in envelope gossip validation (consen…
eserilev Nov 28, 2026
3b4c0c3
Separate builder and validator deposits at the Gloas fork (consensus-…
eserilev Nov 29, 2026
fb2359c
Use millisecond precision for the fork choice block delay
eserilev Nov 29, 2026
cab6cd4
Update execution payload bid gossip validation (consensus-specs#5803,…
eserilev Nov 29, 2026
a148a73
Merge branch 'unstable' into spec-v1.7.0-beta.5
eserilev Nov 29, 2026
b1bfe06
Fix Gloas re-org cutoff test and skip new FCR sync period vectors
eserilev Nov 29, 2026
6d49c87
Check the envelope payload block hash before loading the state
eserilev Nov 29, 2026
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
2 changes: 1 addition & 1 deletion beacon_node/beacon_chain/src/beacon_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4547,7 +4547,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
{
let block_delay = self
.slot_clock
.seconds_from_current_slot_start()
.millis_from_current_slot_start()
.ok_or(Error::UnableToComputeTimeAtSlot)?;

fork_choice
Expand Down
2 changes: 1 addition & 1 deletion beacon_node/beacon_chain/src/block_production/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
}

// Read the clock at millisecond precision, as the re-org cutoff need not fall on a whole
// second (it is 833ms for 5s slots).
// second (it is 834ms for 5s slots).
let slot_delay = self
.slot_clock
.millis_from_current_slot_start()
Expand Down
14 changes: 1 addition & 13 deletions beacon_node/beacon_chain/src/block_verification_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use crate::data_availability_checker::AvailabilityCheckError;
pub use crate::data_availability_checker::{
AvailableBlock, AvailableBlockData, MaybeAvailableBlock,
};
use crate::payload_envelope_verification::AvailableEnvelope;
use crate::payload_envelope_verification::gossip_verified_envelope::verify_envelope_consistency;
use crate::payload_envelope_verification::{AvailableEnvelope, EnvelopeError};
use crate::{BeaconChainTypes, CustodyContext, PayloadVerificationOutcome};
use state_processing::ConsensusContext;
use std::fmt::{Debug, Formatter};
Expand Down Expand Up @@ -165,18 +165,6 @@ impl<E: EthSpec> RangeSyncBlock<E> {
latest_finalized_slot,
)
.map_err(|e| format!("Inconsistent envelope: {e:?}"))?;
// Sync-only check, deliberately not part of gossip validation: needed before
// recomputing the execution block hash, which takes this root as input.
let parent_beacon_block_root = envelope.message().parent_beacon_block_root;
if parent_beacon_block_root != block.message().parent_root() {
return Err(format!(
"Inconsistent envelope: {:?}",
EnvelopeError::ParentBeaconBlockRootMismatch {
block: block.message().parent_root(),
envelope: parent_beacon_block_root,
}
));
}
}

Ok(Self::Gloas {
Expand Down
17 changes: 12 additions & 5 deletions beacon_node/beacon_chain/src/observed_aggregates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ pub trait SubsetItem {
/// The item that is stored for later comparison with new incoming aggregate items.
type Item;

/// Returns `true` if `self` is a non-strict subset of `other` and `false` otherwise.
/// Returns `true` if `self` is a non-strict subset of `other` and `false` otherwise. Items of
/// different lengths are never subsets of each other.
fn is_subset(&self, other: &Self::Item) -> bool;

/// Returns `true` if `self` is a non-strict superset of `other` and `false` otherwise.
Expand Down Expand Up @@ -132,12 +133,15 @@ impl<E: EthSpec> SubsetItem for AttestationRef<'_, E> {
}
false
}
Self::Electra(att) => att.aggregation_bits.is_subset(other),
Self::Electra(att) => {
att.aggregation_bits.len() == other.len() && att.aggregation_bits.is_subset(other)
}
Self::Gloas(att) => {
if let Ok(aggregation_bits) =
progressive_bits_to_bitlist::<E>(&att.aggregation_bits)
{
return aggregation_bits.is_subset(other);
return aggregation_bits.len() == other.len()
&& aggregation_bits.is_subset(other);
}
false
}
Expand All @@ -152,12 +156,15 @@ impl<E: EthSpec> SubsetItem for AttestationRef<'_, E> {
}
false
}
Self::Electra(att) => other.is_subset(&att.aggregation_bits),
Self::Electra(att) => {
att.aggregation_bits.len() == other.len() && other.is_subset(&att.aggregation_bits)
}
Self::Gloas(att) => {
if let Ok(aggregation_bits) =
progressive_bits_to_bitlist::<E>(&att.aggregation_bits)
{
return other.is_subset(&aggregation_bits);
return aggregation_bits.len() == other.len()
&& other.is_subset(&aggregation_bits);
}
false
}
Expand Down
13 changes: 13 additions & 0 deletions beacon_node/beacon_chain/src/observed_execution_payloads.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use hashlink::lru_cache::LruCache;
use parking_lot::RwLock;
use std::sync::OnceLock;
use types::{ExecPayload, ExecutionBlockHash};

use crate::{BeaconChain, BeaconChainError, BeaconChainTypes};
Expand All @@ -10,12 +11,16 @@ const PAYLOAD_GAS_LIMIT_CACHE_CAPACITY: usize = 1_024;
/// Gas limits from execution payloads observed during gossip validation, import, or startup.
pub struct ObservedExecutionPayloads {
gas_limits: RwLock<LruCache<ExecutionBlockHash, u64>>,
/// The parent hash of a Gloas genesis block. Its gas limit comes from the genesis bid, not
/// from an observed payload.
gloas_genesis_parent_hash: OnceLock<ExecutionBlockHash>,
}

impl Default for ObservedExecutionPayloads {
fn default() -> Self {
Self {
gas_limits: RwLock::new(LruCache::new(PAYLOAD_GAS_LIMIT_CACHE_CAPACITY)),
gloas_genesis_parent_hash: OnceLock::new(),
}
}
}
Expand All @@ -25,6 +30,10 @@ impl ObservedExecutionPayloads {
self.gas_limits.read().peek(&block_hash).copied()
}

pub fn is_gloas_genesis_parent(&self, block_hash: ExecutionBlockHash) -> bool {
self.gloas_genesis_parent_hash.get() == Some(&block_hash)
}

pub(crate) fn insert(&self, block_hash: ExecutionBlockHash, gas_limit: u64) {
let mut gas_limits = self.gas_limits.write();
if !gas_limits.contains_key(&block_hash) {
Expand Down Expand Up @@ -63,6 +72,10 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
.message();
self.observed_execution_payloads
.insert(bid.parent_block_hash(), bid.gas_limit());
let _ = self
.observed_execution_payloads
.gloas_genesis_parent_hash
.set(bid.parent_block_hash());
} else if let Some(envelope) = head.snapshot.execution_envelope.as_ref() {
let payload_header = &envelope.payload_header;
self.observed_execution_payloads
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,41 @@ fn verify_bid_slot_range<S: SlotClock>(
Ok(())
}

/// Spec: the bid is received after the payload attestation deadline of the previous slot.
fn verify_bid_after_payload_attestation_due<S: SlotClock>(
slot_clock: &S,
bid_slot: Slot,
spec: &ChainSpec,
) -> Result<(), PayloadBidError> {
let current_time = slot_clock
.now_duration()
.ok_or(PayloadBidError::UnableToReadSlot)?;
let payload_attestation_due_time = slot_clock
.start_of(bid_slot.saturating_sub(1u64))
.ok_or(PayloadBidError::UnableToReadSlot)?
.saturating_add(spec.get_payload_attestation_due());

if current_time < payload_attestation_due_time {
return Err(PayloadBidError::BeforePayloadAttestationDue { bid_slot });
}

Ok(())
}

/// Spec: `get_builder_bid_limit`.
fn get_builder_bid_limit<E: EthSpec>(
state: &BeaconState<E>,
builder_index: u64,
) -> Result<u64, PayloadBidError> {
let balance = state
.get_builder(builder_index)
.map_err(|_| PayloadBidError::InvalidBuilder { builder_index })?
.balance;
let pending_withdrawals_amount =
state.get_pending_balance_to_withdraw_for_builder(builder_index)?;
Ok(balance.saturating_sub(pending_withdrawals_amount) / 1_000_000_000)
}

fn verify_bid_payment_and_blobs<E: EthSpec>(
bid: ExecutionPayloadBidRef<E>,
spec: &ChainSpec,
Expand Down Expand Up @@ -255,7 +290,33 @@ pub(crate) fn is_bid_compatible_with_head<T: BeaconChainTypes>(
};

if builds_on_parent_block && builds_on_parent_payload {
return Ok(true);
// A proposer only builds on the head's parent to re-org the head.
if head_block.slot.saturating_add(1u64) != bid.slot() {
return Ok(false);
}
let proto_array = fork_choice_read.proto_array().core_proto_array();
let Some(head_node) = proto_array
.indices
.get(&head_block_root)
.and_then(|index| proto_array.nodes.get(*index))
else {
return Ok(false);
};
let Ok(proposer_index) = head_node.proposer_index() else {
return Ok(true);
};
let head_late = !head_node
.block_timeliness_attestation_threshold()
.unwrap_or(true);
let proposer_equivocation = proto_array
.nodes
.iter()
.filter(|node| {
node.slot() == head_block.slot && node.proposer_index() == Ok(proposer_index)
})
.nth(1)
.is_some();
return Ok(head_late || proposer_equivocation);
}

if bid.parent_block_root() != head_block.root {
Expand Down Expand Up @@ -320,20 +381,7 @@ impl<E: EthSpec> GossipVerifiedPayloadBid<E> {
let bid_parent_block_root = signed_bid.message().parent_block_root();
let bid_value = signed_bid.message().value();
verify_bid_slot_range(ctx.slot_clock, bid_slot, ctx.spec)?;

if ctx
.gossip_verified_payload_bid_cache
.seen_builder_bid_for_parent(
&bid_slot,
bid_parent,
signed_bid.message().builder_index(),
)
{
return Err(PayloadBidError::BuilderAlreadySeen {
builder_index: signed_bid.message().builder_index(),
slot: bid_slot,
});
}
verify_bid_after_payload_attestation_due(ctx.slot_clock, bid_slot, ctx.spec)?;

// TODO(gloas): Extract into `bid_value_over_threshold` on the bid cache and potentially
// make this more sophisticated than just a <= check.
Expand Down Expand Up @@ -468,6 +516,21 @@ impl<E: EthSpec> GossipVerifiedPayloadBid<E> {

verify_bid_state_conditions(signed_bid.message(), head_state, ctx.spec)?;

let builder_index = signed_bid.message().builder_index();
let bid_limit = get_builder_bid_limit(head_state, builder_index)?;
if ctx.gossip_verified_payload_bid_cache.builder_bid_count(
&bid_slot,
bid_parent,
builder_index,
) >= bid_limit
{
return Err(PayloadBidError::BuilderBidLimitReached {
builder_index,
slot: bid_slot,
limit: bid_limit,
});
}

if parent_payload_exits_builder::<T>(
signed_bid.message(),
&parent_block,
Expand Down
10 changes: 8 additions & 2 deletions beacon_node/beacon_chain/src/payload_bid_verification/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,14 @@ pub enum PayloadBidError {
InvalidParentBlockRoot { bid: Hash256, expected: Hash256 },
/// The signature is invalid.
BadSignature,
/// A bid for this builder at this slot has already been seen.
BuilderAlreadySeen { builder_index: u64, slot: Slot },
/// The builder has reached its bid limit for this slot and parent.
BuilderBidLimitReached {
builder_index: u64,
slot: Slot,
limit: u64,
},
/// The bid arrived before the payload attestation deadline of the previous slot.
BeforePayloadAttestationDue { bid_slot: Slot },
/// Builder is not valid/active for the given epoch
InvalidBuilder { builder_index: u64 },
/// The bid was signed by a builder not in the requesting entry's `builder_pubkeys` (the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use educe::Educe;
use parking_lot::RwLock;
use std::{
collections::hash_map,
collections::{BTreeMap, HashMap, HashSet},
collections::{BTreeMap, HashMap},
sync::Arc,
};
use types::{
Expand Down Expand Up @@ -39,19 +39,17 @@ type HighestBidMap<E> = BTreeMap<Slot, HashMap<BidParent, GossipVerifiedPayloadB
pub struct GossipBidCacheInner<E: EthSpec> {
/// The current best bid for each `(slot, BidParent)`.
highest_bid: HighestBidMap<E>,
/// The `(BidParent, BuilderIndex)` pairs for which we have already accepted a gossip-verified
/// bid, per slot.
/// The number of gossip-verified bids accepted for each `(BidParent, BuilderIndex)`, per slot.
///
/// Used to enforce one bid per builder per parent per slot: a builder may bid once for each
/// parent view compatible with the head.
seen_builder_bids: BTreeMap<Slot, HashSet<(BidParent, BuilderIndex)>>,
/// Used to enforce the builder bid limit for each parent and slot.
seen_builder_bids: BTreeMap<Slot, HashMap<(BidParent, BuilderIndex), u64>>,
}

/// A cache of gossip-verified payload bids.
///
/// Tracks, per slot, the highest-value bid observed for each parent a bid may build on and the
/// set of `(parent, builder)` pairs that have already bid, so that duplicate and lower-value
/// gossip bids can be rejected. Stale entries are removed via [`prune`](Self::prune) as the chain
/// number of bids from each `(parent, builder)` pair, so that lower-value gossip bids and bids
/// past the builder bid limit can be rejected. Stale entries are removed via [`prune`](Self::prune) as the chain
/// advances.
#[derive(Educe)]
#[educe(Default(bound = "E: EthSpec"))]
Expand Down Expand Up @@ -82,8 +80,8 @@ impl<E: EthSpec> GossipVerifiedPayloadBidCache<E> {

/// Record a gossip-verified `bid` in the cache.
///
/// This always marks the bid's `(parent, builder)` pair as seen for the bid's slot (see
/// [`seen_builder_bid_for_parent`](Self::seen_builder_bid_for_parent)). Additionally, if the
/// This always counts the bid for its `(parent, builder)` pair and slot (see
/// [`builder_bid_count`](Self::builder_bid_count)). Additionally, if the
/// bid has a strictly higher value than the currently cached bid for its `(slot, BidParent)`
/// (or no bid is cached yet), it replaces the cached bid.
///
Expand All @@ -93,11 +91,13 @@ impl<E: EthSpec> GossipVerifiedPayloadBidCache<E> {
let slot = bid.signed_bid.message().slot();
let key = BidParent::from_bid(bid.signed_bid.message());
let mut inner = self.inner.write();
inner
let count = inner
.seen_builder_bids
.entry(slot)
.or_default()
.insert((key, bid.signed_bid.message().builder_index()));
.entry((key, bid.signed_bid.message().builder_index()))
.or_default();
*count = count.saturating_add(1);

match inner.highest_bid.entry(slot).or_default().entry(key) {
hash_map::Entry::Vacant(entry) => {
Expand All @@ -114,19 +114,31 @@ impl<E: EthSpec> GossipVerifiedPayloadBidCache<E> {
}
}

/// Returns `true` if a gossip-verified bid from `builder_index` has already been seen for
/// `(slot, bid_parent)`.
pub fn seen_builder_bid_for_parent(
/// Returns the number of gossip-verified bids from `builder_index` for `(slot, bid_parent)`.
pub fn builder_bid_count(
&self,
slot: &Slot,
bid_parent: BidParent,
builder_index: BuilderIndex,
) -> bool {
) -> u64 {
self.inner
.read()
.seen_builder_bids
.get(slot)
.is_some_and(|seen_builders| seen_builders.contains(&(bid_parent, builder_index)))
.and_then(|seen_builders| seen_builders.get(&(bid_parent, builder_index)))
.copied()
.unwrap_or(0)
}

/// Returns `true` if a gossip-verified bid from `builder_index` has already been seen for
/// `(slot, bid_parent)`.
pub fn seen_builder_bid_for_parent(
&self,
slot: &Slot,
bid_parent: BidParent,
builder_index: BuilderIndex,
) -> bool {
self.builder_bid_count(slot, bid_parent, builder_index) > 0
}

/// Removes all cached bids and seen-builder records for slots older than `current_slot`.
Expand Down Expand Up @@ -205,6 +217,18 @@ mod tests {
assert!(!cache.seen_builder_bid_for_parent(&slot, parent_b, 0));
assert!(!cache.seen_builder_bid_for_parent(&slot, parent_a, 1));
assert!(!cache.seen_builder_bid_for_parent(&Slot::new(2), parent_a, 0));

// Each observed bid adds to the count for its (slot, parent tuple, builder).
assert_eq!(cache.builder_bid_count(&slot, parent_a, 0), 1);
cache.observe_bid(make_gossip_verified(
slot,
0,
parent_a.parent_block_hash,
parent_a.parent_block_root,
200,
));
assert_eq!(cache.builder_bid_count(&slot, parent_a, 0), 2);
assert_eq!(cache.builder_bid_count(&slot, parent_b, 0), 0);
}

#[test]
Expand Down
Loading
Loading