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
30 changes: 24 additions & 6 deletions fork_choice_store/src/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2336,17 +2336,35 @@ impl<P: Preset, S: Storage<P>> Store<P, S> {
};

// > the `bid.parent_block_hash` is the block hash of a known execution payload in fork choice
if !self
.execution_payload_locations
.contains_key(&bid.parent_block_hash)
{
let Some(parent_payload_chain_link) =
self.unfinalized_chain_link_by_execution_block_hash(bid.parent_block_hash)
else {
return Ok(ExecutionPayloadBidAction::Ignore(
"the `bid.parent_block_hash` is the block hash of a known execution payload in fork choice",
));
}
};

// > Check `is_gas_limit_target_compatible(parent_gas_limit, bid.gas_limit, target_gas_limit)` is True.
let parent_gas_limit = post_gloas_state.latest_execution_payload_bid().gas_limit;
//
// `parent_gas_limit` is the `gas_limit` of the execution payload identified by
// `bid.parent_block_hash`, which is committed to by the bid of the block that carries it
// (envelopes must match their bid's `gas_limit`). This is not necessarily the payload of
// `bid.parent_block_root`: a bid may build on the parent's parent payload when the parent
// block's payload was withheld. Pre-Gloas blocks carry the payload itself.
let parent_payload_block_body = parent_payload_chain_link.block.message().body();
let Some(parent_gas_limit) = parent_payload_block_body
.with_payload_bid()
.map(|body| body.signed_execution_payload_bid().message.gas_limit)
.or_else(|| {
parent_payload_block_body
.with_execution_payload()
.map(|body| body.execution_payload().gas_limit())
})
else {
return Ok(ExecutionPayloadBidAction::Ignore(
"the `bid.parent_block_hash` is the block hash of a known execution payload in fork choice",
));
};
if !predicates::is_gas_limit_target_compatible(
parent_gas_limit,
bid.gas_limit,
Expand Down
30 changes: 30 additions & 0 deletions types/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ use crate::{
ExecutionPayload as BellatrixExecutionPayload,
ExecutionPayloadHeader as BellatrixExecutionPayloadHeader,
},
primitives::Gas,
},
cache::Cache,
capella::{
Expand Down Expand Up @@ -1816,6 +1817,7 @@ pub trait ExecutionPayload<P: Preset>: SszHash<PackingFactor = U1> {
fn block_hash(&self) -> ExecutionBlockHash;
fn block_number(&self) -> Option<ExecutionBlockNumber>;
fn parent_hash(&self) -> ExecutionBlockHash;
fn gas_limit(&self) -> Gas;

fn is_default_payload(&self) -> bool;
fn to_header(&self) -> CombinedExecutionPayloadHeader<P>;
Expand All @@ -1834,6 +1836,10 @@ impl<P: Preset> ExecutionPayload<P> for BellatrixExecutionPayload<P> {
self.parent_hash
}

fn gas_limit(&self) -> Gas {
self.gas_limit
}

fn is_default_payload(&self) -> bool {
self.is_default()
}
Expand All @@ -1856,6 +1862,10 @@ impl<P: Preset> ExecutionPayload<P> for BellatrixExecutionPayloadHeader<P> {
self.parent_hash
}

fn gas_limit(&self) -> Gas {
self.gas_limit
}

fn is_default_payload(&self) -> bool {
self.is_default()
}
Expand All @@ -1878,6 +1888,10 @@ impl<P: Preset> ExecutionPayload<P> for CapellaExecutionPayload<P> {
self.parent_hash
}

fn gas_limit(&self) -> Gas {
self.gas_limit
}

fn is_default_payload(&self) -> bool {
self.is_default()
}
Expand All @@ -1900,6 +1914,10 @@ impl<P: Preset> ExecutionPayload<P> for CapellaExecutionPayloadHeader<P> {
self.parent_hash
}

fn gas_limit(&self) -> Gas {
self.gas_limit
}

fn is_default_payload(&self) -> bool {
self.is_default()
}
Expand All @@ -1922,6 +1940,10 @@ impl<P: Preset> ExecutionPayload<P> for DenebExecutionPayload<P> {
self.parent_hash
}

fn gas_limit(&self) -> Gas {
self.gas_limit
}

fn is_default_payload(&self) -> bool {
self.is_default()
}
Expand All @@ -1944,6 +1966,10 @@ impl<P: Preset> ExecutionPayload<P> for DenebExecutionPayloadHeader<P> {
self.parent_hash
}

fn gas_limit(&self) -> Gas {
self.gas_limit
}

fn is_default_payload(&self) -> bool {
self.is_default()
}
Expand All @@ -1966,6 +1992,10 @@ impl<P: Preset> ExecutionPayload<P> for ExecutionPayloadBid<P> {
self.parent_block_hash
}

fn gas_limit(&self) -> Gas {
self.gas_limit
}

fn is_default_payload(&self) -> bool {
self.is_default()
}
Expand Down
Loading