Skip to content

Commit 466b4e1

Browse files
michaelsproulWoodpile37
authored andcommitted
Add parent_block_number to payload SSE (sigp#4053)
In sigp#4027 I forgot to add the `parent_block_number` to the payload attributes SSE. Compute the parent block number while computing the pre-payload attributes. Pass it on to the SSE stream. Not essential for v3.5.1 as I suspect most builders don't need the `parent_block_root`. I would like to use it for my dummy no-op builder however.
1 parent e524612 commit 466b4e1

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

beacon_node/beacon_chain/src/canonical_head.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,17 @@ impl<E: EthSpec> CachedHead<E> {
167167
.map(|payload| payload.prev_randao())
168168
}
169169

170+
/// Returns the execution block number of the block at the head of the chain.
171+
///
172+
/// Returns an error if the chain is prior to Bellatrix.
173+
pub fn head_block_number(&self) -> Result<u64, BeaconStateError> {
174+
self.snapshot
175+
.beacon_block
176+
.message()
177+
.execution_payload()
178+
.map(|payload| payload.block_number())
179+
}
180+
170181
/// Returns the active validator count for the current epoch of the head state.
171182
///
172183
/// Should only return `None` if the caches have not been built on the head state (this should

beacon_node/execution_layer/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ use types::{ExecutionPayload, ExecutionPayloadCapella, ExecutionPayloadMerge};
4444

4545
mod block_hash;
4646
mod engine_api;
47-
mod engines;
47+
pub mod engines;
4848
mod keccak;
4949
mod metrics;
5050
pub mod payload_cache;

common/eth2/src/types.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -921,6 +921,8 @@ pub struct SseExtendedPayloadAttributesGeneric<T> {
921921
#[serde(with = "eth2_serde_utils::quoted_u64")]
922922
pub proposer_index: u64,
923923
pub parent_block_root: Hash256,
924+
#[serde(with = "eth2_serde_utils::quoted_u64")]
925+
pub parent_block_number: u64,
924926
pub parent_block_hash: ExecutionBlockHash,
925927
pub payload_attributes: T,
926928
}
@@ -958,6 +960,7 @@ impl ForkVersionDeserialize for SseExtendedPayloadAttributes {
958960
proposal_slot: helper.proposal_slot,
959961
proposer_index: helper.proposer_index,
960962
parent_block_root: helper.parent_block_root,
963+
parent_block_number: helper.parent_block_number,
961964
parent_block_hash: helper.parent_block_hash,
962965
payload_attributes: SsePayloadAttributes::deserialize_by_fork::<D>(
963966
helper.payload_attributes,

0 commit comments

Comments
 (0)