Merge pull request #46 from eserilev/fix/record-il-satisfaction-on-envelope-import

fix(focil): record inclusion list satisfaction on envelope import
This commit is contained in:
Eitan Seri-Levi
2026-05-19 00:02:34 -07:00
committed by GitHub
2 changed files with 42 additions and 7 deletions

View File

@@ -266,6 +266,30 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
.on_valid_payload_envelope_received(block_root) .on_valid_payload_envelope_received(block_root)
.map_err(|e| BlockError::InternalError(format!("{e:?}")))?; .map_err(|e| BlockError::InternalError(format!("{e:?}")))?;
// Check if the envelope's payload satisfies the inclusion list for this slot.
// This is used by fork choice's `should_extend_payload` tiebreaker to decide
// whether Full or Empty wins when weights are equal.
let il_slot = signed_envelope.message().slot();
let il_satisfied = {
let il_cache = self.inclusion_list_cache.read();
if let Some(il_transactions) =
il_cache.get_inclusion_list_transactions(il_slot, false)
{
let envelope_message = signed_envelope.message();
let payload = envelope_message.payload();
let payload_transactions = payload.transactions();
let payload_tx_set: std::collections::HashSet<_> =
payload_transactions.iter().collect();
il_transactions.iter().all(|tx| payload_tx_set.contains(tx))
} else {
// No inclusion list for this slot — considered satisfied
true
}
};
fork_choice
.record_payload_inclusion_list_satisfaction(block_root, il_satisfied);
// TODO(gloas) emit SSE event if the payload became the new head payload // TODO(gloas) emit SSE event if the payload became the new head payload
// It is important NOT to return errors here before the database commit, because the envelope // It is important NOT to return errors here before the database commit, because the envelope

View File

@@ -1509,17 +1509,28 @@ impl ProtoArray {
proto_node: &ProtoNode, proto_node: &ProtoNode,
proposer_boost_root: Hash256, proposer_boost_root: Hash256,
) -> Result<bool, Error> { ) -> Result<bool, Error> {
// Per spec: is_payload_inclusion_list_satisfied returns false unless the // Per spec (Gloas): if not is_payload_verified(store, root): return False
// root is in the map AND the value is true. // In our implementation, payload_received == True means the envelope was received.
if !self if !proto_node
.payload_inclusion_list_satisfaction .payload_received()
.get(&fc_node.root) .map_err(|_| Error::InvalidNodeVariant { block_root: fc_node.root })?
.copied()
.unwrap_or(false)
{ {
return Ok(false); return Ok(false);
} }
// Per spec (Heze/FOCIL): is_payload_inclusion_list_satisfied check.
// Only applies when the IL satisfaction map has entries (i.e., heze is active).
// For gloas-only slots where no IL exists, the map won't contain the root,
// but we should NOT gate on this — only check if the root IS in the map.
if let Some(&satisfied) = self
.payload_inclusion_list_satisfaction
.get(&fc_node.root)
{
if !satisfied {
return Ok(false);
}
}
// Per spec: `proposer_root == Root()` is one of the `or` conditions that // Per spec: `proposer_root == Root()` is one of the `or` conditions that
// makes `should_extend_payload` return True. // makes `should_extend_payload` return True.
if proposer_boost_root.is_zero() { if proposer_boost_root.is_zero() {