Gloas serve envelope rpc (#8896)

Serves envelope by range and by root requests. Added PayloadEnvelopeStreamer so that we dont need to alter upstream code when we introduce blinded payload envelopes.


  


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

Co-Authored-By: Eitan Seri-Levi <eserilev@ucsc.edu>

Co-Authored-By: dapplion <35266934+dapplion@users.noreply.github.com>
This commit is contained in:
Eitan Seri-Levi
2026-03-25 15:45:24 +09:00
committed by GitHub
parent 7ffc637eef
commit c7055b604f
26 changed files with 1778 additions and 13 deletions

View File

@@ -22,7 +22,7 @@ use types::{
LightClientBootstrap, LightClientBootstrapAltair, LightClientFinalityUpdate,
LightClientFinalityUpdateAltair, LightClientOptimisticUpdate,
LightClientOptimisticUpdateAltair, LightClientUpdate, MainnetEthSpec, MinimalEthSpec,
SignedBeaconBlock,
SignedBeaconBlock, SignedExecutionPayloadEnvelope,
};
// Note: Hardcoding the `EthSpec` type for `SignedBeaconBlock` as min/max values is
@@ -65,6 +65,12 @@ pub static SIGNED_BEACON_BLOCK_BELLATRIX_MAX: LazyLock<usize> =
+ types::ExecutionPayload::<MainnetEthSpec>::max_execution_payload_bellatrix_size() // adding max size of execution payload (~16gb)
+ ssz::BYTES_PER_LENGTH_OFFSET); // Adding the additional ssz offset for the `ExecutionPayload` field
pub static SIGNED_EXECUTION_PAYLOAD_ENVELOPE_MIN: LazyLock<usize> =
LazyLock::new(SignedExecutionPayloadEnvelope::<MainnetEthSpec>::min_size);
pub static SIGNED_EXECUTION_PAYLOAD_ENVELOPE_MAX: LazyLock<usize> =
LazyLock::new(SignedExecutionPayloadEnvelope::<MainnetEthSpec>::max_size);
pub static BLOB_SIDECAR_SIZE: LazyLock<usize> =
LazyLock::new(BlobSidecar::<MainnetEthSpec>::max_size);
@@ -140,13 +146,30 @@ pub fn rpc_block_limits_by_fork(current_fork: ForkName) -> RpcLimits {
),
// After the merge the max SSZ size of a block is absurdly big. The size is actually
// bound by other constants, so here we default to the bellatrix's max value
_ => RpcLimits::new(
*SIGNED_BEACON_BLOCK_BASE_MIN, // Base block is smaller than altair and bellatrix blocks
*SIGNED_BEACON_BLOCK_BELLATRIX_MAX, // Bellatrix block is larger than base and altair blocks
// After the merge the max SSZ size includes the execution payload.
// Gloas blocks no longer contain the execution payload, but we must
// still accept pre-Gloas blocks during historical sync, so we keep the
// Bellatrix max as the upper bound.
ForkName::Bellatrix
| ForkName::Capella
| ForkName::Deneb
| ForkName::Electra
| ForkName::Fulu
| ForkName::Gloas => RpcLimits::new(
*SIGNED_BEACON_BLOCK_BASE_MIN,
*SIGNED_BEACON_BLOCK_BELLATRIX_MAX,
),
}
}
/// Returns the rpc limits for payload_envelope_by_range and payload_envelope_by_root responses.
pub fn rpc_payload_limits() -> RpcLimits {
RpcLimits::new(
*SIGNED_EXECUTION_PAYLOAD_ENVELOPE_MIN,
*SIGNED_EXECUTION_PAYLOAD_ENVELOPE_MAX,
)
}
fn rpc_light_client_updates_by_range_limits_by_fork(current_fork: ForkName) -> RpcLimits {
let altair_fixed_len = LightClientFinalityUpdateAltair::<MainnetEthSpec>::ssz_fixed_len();
@@ -242,6 +265,12 @@ pub enum Protocol {
/// The `BlobsByRange` protocol name.
#[strum(serialize = "blob_sidecars_by_range")]
BlobsByRange,
/// The `ExecutionPayloadEnvelopesByRoot` protocol name.
#[strum(serialize = "execution_payload_envelopes_by_root")]
PayloadEnvelopesByRoot,
/// The `ExecutionPayloadEnvelopesByRange` protocol name.
#[strum(serialize = "execution_payload_envelopes_by_range")]
PayloadEnvelopesByRange,
/// The `BlobsByRoot` protocol name.
#[strum(serialize = "blob_sidecars_by_root")]
BlobsByRoot,
@@ -277,6 +306,8 @@ impl Protocol {
Protocol::Goodbye => None,
Protocol::BlocksByRange => Some(ResponseTermination::BlocksByRange),
Protocol::BlocksByRoot => Some(ResponseTermination::BlocksByRoot),
Protocol::PayloadEnvelopesByRange => Some(ResponseTermination::PayloadEnvelopesByRange),
Protocol::PayloadEnvelopesByRoot => Some(ResponseTermination::PayloadEnvelopesByRoot),
Protocol::BlobsByRange => Some(ResponseTermination::BlobsByRange),
Protocol::BlobsByRoot => Some(ResponseTermination::BlobsByRoot),
Protocol::DataColumnsByRoot => Some(ResponseTermination::DataColumnsByRoot),
@@ -307,6 +338,8 @@ pub enum SupportedProtocol {
BlocksByRangeV2,
BlocksByRootV1,
BlocksByRootV2,
PayloadEnvelopesByRangeV1,
PayloadEnvelopesByRootV1,
BlobsByRangeV1,
BlobsByRootV1,
DataColumnsByRootV1,
@@ -329,6 +362,8 @@ impl SupportedProtocol {
SupportedProtocol::GoodbyeV1 => "1",
SupportedProtocol::BlocksByRangeV1 => "1",
SupportedProtocol::BlocksByRangeV2 => "2",
SupportedProtocol::PayloadEnvelopesByRangeV1 => "1",
SupportedProtocol::PayloadEnvelopesByRootV1 => "1",
SupportedProtocol::BlocksByRootV1 => "1",
SupportedProtocol::BlocksByRootV2 => "2",
SupportedProtocol::BlobsByRangeV1 => "1",
@@ -355,6 +390,8 @@ impl SupportedProtocol {
SupportedProtocol::BlocksByRangeV2 => Protocol::BlocksByRange,
SupportedProtocol::BlocksByRootV1 => Protocol::BlocksByRoot,
SupportedProtocol::BlocksByRootV2 => Protocol::BlocksByRoot,
SupportedProtocol::PayloadEnvelopesByRangeV1 => Protocol::PayloadEnvelopesByRange,
SupportedProtocol::PayloadEnvelopesByRootV1 => Protocol::PayloadEnvelopesByRoot,
SupportedProtocol::BlobsByRangeV1 => Protocol::BlobsByRange,
SupportedProtocol::BlobsByRootV1 => Protocol::BlobsByRoot,
SupportedProtocol::DataColumnsByRootV1 => Protocol::DataColumnsByRoot,
@@ -409,6 +446,18 @@ impl SupportedProtocol {
ProtocolId::new(SupportedProtocol::DataColumnsByRangeV1, Encoding::SSZSnappy),
]);
}
if fork_context.fork_exists(ForkName::Gloas) {
supported.extend_from_slice(&[
ProtocolId::new(
SupportedProtocol::PayloadEnvelopesByRangeV1,
Encoding::SSZSnappy,
),
ProtocolId::new(
SupportedProtocol::PayloadEnvelopesByRootV1,
Encoding::SSZSnappy,
),
]);
}
supported
}
}
@@ -511,6 +560,13 @@ impl ProtocolId {
<OldBlocksByRangeRequestV2 as Encode>::ssz_fixed_len(),
),
Protocol::BlocksByRoot => RpcLimits::new(0, spec.max_blocks_by_root_request),
Protocol::PayloadEnvelopesByRange => RpcLimits::new(
<PayloadEnvelopesByRangeRequest as Encode>::ssz_fixed_len(),
<PayloadEnvelopesByRangeRequest as Encode>::ssz_fixed_len(),
),
Protocol::PayloadEnvelopesByRoot => {
RpcLimits::new(0, spec.max_payload_envelopes_by_root_request)
}
Protocol::BlobsByRange => RpcLimits::new(
<BlobsByRangeRequest as Encode>::ssz_fixed_len(),
<BlobsByRangeRequest as Encode>::ssz_fixed_len(),
@@ -549,6 +605,8 @@ impl ProtocolId {
Protocol::Goodbye => RpcLimits::new(0, 0), // Goodbye request has no response
Protocol::BlocksByRange => rpc_block_limits_by_fork(fork_context.current_fork_name()),
Protocol::BlocksByRoot => rpc_block_limits_by_fork(fork_context.current_fork_name()),
Protocol::PayloadEnvelopesByRange => rpc_payload_limits(),
Protocol::PayloadEnvelopesByRoot => rpc_payload_limits(),
Protocol::BlobsByRange => rpc_blob_limits::<E>(),
Protocol::BlobsByRoot => rpc_blob_limits::<E>(),
Protocol::DataColumnsByRoot => {
@@ -586,6 +644,8 @@ impl ProtocolId {
match self.versioned_protocol {
SupportedProtocol::BlocksByRangeV2
| SupportedProtocol::BlocksByRootV2
| SupportedProtocol::PayloadEnvelopesByRangeV1
| SupportedProtocol::PayloadEnvelopesByRootV1
| SupportedProtocol::BlobsByRangeV1
| SupportedProtocol::BlobsByRootV1
| SupportedProtocol::DataColumnsByRootV1
@@ -737,6 +797,8 @@ pub enum RequestType<E: EthSpec> {
Goodbye(GoodbyeReason),
BlocksByRange(OldBlocksByRangeRequest),
BlocksByRoot(BlocksByRootRequest),
PayloadEnvelopesByRange(PayloadEnvelopesByRangeRequest),
PayloadEnvelopesByRoot(PayloadEnvelopesByRootRequest),
BlobsByRange(BlobsByRangeRequest),
BlobsByRoot(BlobsByRootRequest),
DataColumnsByRoot(DataColumnsByRootRequest<E>),
@@ -760,6 +822,8 @@ impl<E: EthSpec> RequestType<E> {
RequestType::Goodbye(_) => 0,
RequestType::BlocksByRange(req) => *req.count(),
RequestType::BlocksByRoot(req) => req.block_roots().len() as u64,
RequestType::PayloadEnvelopesByRange(req) => req.count,
RequestType::PayloadEnvelopesByRoot(req) => req.beacon_block_roots.len() as u64,
RequestType::BlobsByRange(req) => req.max_blobs_requested(digest_epoch, spec),
RequestType::BlobsByRoot(req) => req.blob_ids.len() as u64,
RequestType::DataColumnsByRoot(req) => req.max_requested() as u64,
@@ -789,6 +853,8 @@ impl<E: EthSpec> RequestType<E> {
BlocksByRootRequest::V1(_) => SupportedProtocol::BlocksByRootV1,
BlocksByRootRequest::V2(_) => SupportedProtocol::BlocksByRootV2,
},
RequestType::PayloadEnvelopesByRange(_) => SupportedProtocol::PayloadEnvelopesByRangeV1,
RequestType::PayloadEnvelopesByRoot(_) => SupportedProtocol::PayloadEnvelopesByRootV1,
RequestType::BlobsByRange(_) => SupportedProtocol::BlobsByRangeV1,
RequestType::BlobsByRoot(_) => SupportedProtocol::BlobsByRootV1,
RequestType::DataColumnsByRoot(_) => SupportedProtocol::DataColumnsByRootV1,
@@ -820,6 +886,8 @@ impl<E: EthSpec> RequestType<E> {
// variants that have `multiple_responses()` can have values.
RequestType::BlocksByRange(_) => ResponseTermination::BlocksByRange,
RequestType::BlocksByRoot(_) => ResponseTermination::BlocksByRoot,
RequestType::PayloadEnvelopesByRange(_) => ResponseTermination::PayloadEnvelopesByRange,
RequestType::PayloadEnvelopesByRoot(_) => ResponseTermination::PayloadEnvelopesByRoot,
RequestType::BlobsByRange(_) => ResponseTermination::BlobsByRange,
RequestType::BlobsByRoot(_) => ResponseTermination::BlobsByRoot,
RequestType::DataColumnsByRoot(_) => ResponseTermination::DataColumnsByRoot,
@@ -854,6 +922,14 @@ impl<E: EthSpec> RequestType<E> {
ProtocolId::new(SupportedProtocol::BlocksByRootV2, Encoding::SSZSnappy),
ProtocolId::new(SupportedProtocol::BlocksByRootV1, Encoding::SSZSnappy),
],
RequestType::PayloadEnvelopesByRange(_) => vec![ProtocolId::new(
SupportedProtocol::PayloadEnvelopesByRangeV1,
Encoding::SSZSnappy,
)],
RequestType::PayloadEnvelopesByRoot(_) => vec![ProtocolId::new(
SupportedProtocol::PayloadEnvelopesByRootV1,
Encoding::SSZSnappy,
)],
RequestType::BlobsByRange(_) => vec![ProtocolId::new(
SupportedProtocol::BlobsByRangeV1,
Encoding::SSZSnappy,
@@ -905,6 +981,8 @@ impl<E: EthSpec> RequestType<E> {
RequestType::BlocksByRange(_) => false,
RequestType::BlocksByRoot(_) => false,
RequestType::BlobsByRange(_) => false,
RequestType::PayloadEnvelopesByRange(_) => false,
RequestType::PayloadEnvelopesByRoot(_) => false,
RequestType::BlobsByRoot(_) => false,
RequestType::DataColumnsByRoot(_) => false,
RequestType::DataColumnsByRange(_) => false,
@@ -1015,6 +1093,12 @@ impl<E: EthSpec> std::fmt::Display for RequestType<E> {
RequestType::Goodbye(reason) => write!(f, "Goodbye: {}", reason),
RequestType::BlocksByRange(req) => write!(f, "Blocks by range: {}", req),
RequestType::BlocksByRoot(req) => write!(f, "Blocks by root: {:?}", req),
RequestType::PayloadEnvelopesByRange(req) => {
write!(f, "Payload envelopes by range: {:?}", req)
}
RequestType::PayloadEnvelopesByRoot(req) => {
write!(f, "Payload envelopes by root: {:?}", req)
}
RequestType::BlobsByRange(req) => write!(f, "Blobs by range: {:?}", req),
RequestType::BlobsByRoot(req) => write!(f, "Blobs by root: {:?}", req),
RequestType::DataColumnsByRoot(req) => write!(f, "Data columns by root: {:?}", req),