Merge conlficts

This commit is contained in:
Eitan Seri- Levi
2026-03-26 21:50:30 -07:00
158 changed files with 4877 additions and 3908 deletions

View File

@@ -562,7 +562,7 @@ fn handle_rpc_request<E: EthSpec>(
RequestType::PayloadEnvelopesByRoot(PayloadEnvelopesByRootRequest {
beacon_block_roots: RuntimeVariableList::from_ssz_bytes(
decoded_buffer,
spec.max_request_blocks(current_fork),
spec.max_request_payloads(),
)?,
}),
)),

View File

@@ -954,6 +954,35 @@ where
return;
}
}
RequestType::PayloadEnvelopesByRange(request) => {
let max_allowed = spec.max_request_payloads;
if request.count > max_allowed {
self.events_out.push(HandlerEvent::Err(HandlerErr::Inbound {
id: self.current_inbound_substream_id,
proto: Protocol::PayloadEnvelopesByRange,
error: RPCError::InvalidData(format!(
"requested exceeded limit. allowed: {}, requested: {}",
max_allowed, request.count
)),
}));
return;
}
}
RequestType::DataColumnsByRange(request) => {
let max_requested = request.max_requested::<E>();
let max_allowed = spec.max_request_data_column_sidecars;
if max_requested > max_allowed {
self.events_out.push(HandlerEvent::Err(HandlerErr::Inbound {
id: self.current_inbound_substream_id,
proto: Protocol::DataColumnsByRange,
error: RPCError::InvalidData(format!(
"requested exceeded limit. allowed: {}, requested: {}",
max_allowed, max_requested
)),
}));
return;
}
}
_ => {}
};

View File

@@ -17,10 +17,10 @@ use tokio_util::{
compat::{Compat, FuturesAsyncReadCompatExt},
};
use types::{
BeaconBlock, BeaconBlockAltair, BeaconBlockBase, BeaconBlockGloas, BlobSidecar, ChainSpec,
DataColumnSidecarFulu, DataColumnSidecarGloas, EmptyBlock, Epoch, EthSpec, EthSpecId,
ForkContext, ForkName, LightClientBootstrap, LightClientBootstrapAltair,
LightClientFinalityUpdate, LightClientFinalityUpdateAltair, LightClientOptimisticUpdate,
BeaconBlock, BeaconBlockAltair, BeaconBlockBase, BlobSidecar, ChainSpec, DataColumnSidecarFulu,
DataColumnSidecarGloas, EmptyBlock, Epoch, EthSpec, EthSpecId, ForkContext, ForkName,
LightClientBootstrap, LightClientBootstrapAltair, LightClientFinalityUpdate,
LightClientFinalityUpdateAltair, LightClientOptimisticUpdate,
LightClientOptimisticUpdateAltair, LightClientUpdate, MainnetEthSpec, MinimalEthSpec,
SignedBeaconBlock, SignedExecutionPayloadEnvelope,
};
@@ -65,17 +65,6 @@ 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
/// Gloas blocks no longer contain an execution payload (it's in the envelope),
/// so they are significantly smaller than Bellatrix+ blocks.
pub static SIGNED_BEACON_BLOCK_GLOAS_MAX: LazyLock<usize> = LazyLock::new(|| {
SignedBeaconBlock::<MainnetEthSpec>::from_block(
BeaconBlock::Gloas(BeaconBlockGloas::full(&MainnetEthSpec::default_spec())),
Signature::empty(),
)
.as_ssz_bytes()
.len()
});
pub static SIGNED_EXECUTION_PAYLOAD_ENVELOPE_MIN: LazyLock<usize> =
LazyLock::new(SignedExecutionPayloadEnvelope::<MainnetEthSpec>::min_size);
@@ -157,18 +146,18 @@ 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
// 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 => 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
),
// Gloas blocks no longer contain the execution payload, so they are much smaller
ForkName::Gloas => RpcLimits::new(
| ForkName::Fulu
| ForkName::Gloas => RpcLimits::new(
*SIGNED_BEACON_BLOCK_BASE_MIN,
*SIGNED_BEACON_BLOCK_GLOAS_MAX,
*SIGNED_BEACON_BLOCK_BELLATRIX_MAX,
),
}
}

View File

@@ -110,9 +110,9 @@ pub struct RPCRateLimiter {
/// BlobsByRoot rate limiter.
blbroot_rl: Limiter<PeerId>,
/// PayloadEnvelopesByRange rate limiter.
perange_rl: Limiter<PeerId>,
envrange_rl: Limiter<PeerId>,
/// PayloadEnvelopesByRoot rate limiter.
peroots_rl: Limiter<PeerId>,
envroots_rl: Limiter<PeerId>,
/// DataColumnsByRoot rate limiter.
dcbroot_rl: Limiter<PeerId>,
/// DataColumnsByRange rate limiter.
@@ -252,8 +252,8 @@ impl RPCRateLimiterBuilder {
let goodbye_rl = Limiter::from_quota(goodbye_quota)?;
let bbroots_rl = Limiter::from_quota(bbroots_quota)?;
let bbrange_rl = Limiter::from_quota(bbrange_quota)?;
let perange_rl = Limiter::from_quota(perange_quota)?;
let peroots_rl = Limiter::from_quota(peroots_quota)?;
let envrange_rl = Limiter::from_quota(perange_quota)?;
let envroots_rl = Limiter::from_quota(peroots_quota)?;
let blbrange_rl = Limiter::from_quota(blbrange_quota)?;
let blbroot_rl = Limiter::from_quota(blbroots_quota)?;
let dcbroot_rl = Limiter::from_quota(dcbroot_quota)?;
@@ -277,8 +277,8 @@ impl RPCRateLimiterBuilder {
goodbye_rl,
bbroots_rl,
bbrange_rl,
perange_rl,
peroots_rl,
envrange_rl,
envroots_rl,
blbrange_rl,
blbroot_rl,
dcbroot_rl,
@@ -406,8 +406,8 @@ impl RPCRateLimiter {
Protocol::Goodbye => &mut self.goodbye_rl,
Protocol::BlocksByRange => &mut self.bbrange_rl,
Protocol::BlocksByRoot => &mut self.bbroots_rl,
Protocol::PayloadEnvelopesByRange => &mut self.perange_rl,
Protocol::PayloadEnvelopesByRoot => &mut self.peroots_rl,
Protocol::PayloadEnvelopesByRange => &mut self.envrange_rl,
Protocol::PayloadEnvelopesByRoot => &mut self.envroots_rl,
Protocol::BlobsByRange => &mut self.blbrange_rl,
Protocol::BlobsByRoot => &mut self.blbroot_rl,
Protocol::DataColumnsByRoot => &mut self.dcbroot_rl,
@@ -432,8 +432,8 @@ impl RPCRateLimiter {
status_rl,
bbrange_rl,
bbroots_rl,
perange_rl,
peroots_rl,
envrange_rl,
envroots_rl,
blbrange_rl,
blbroot_rl,
dcbroot_rl,
@@ -451,8 +451,8 @@ impl RPCRateLimiter {
status_rl.prune(time_since_start);
bbrange_rl.prune(time_since_start);
bbroots_rl.prune(time_since_start);
perange_rl.prune(time_since_start);
peroots_rl.prune(time_since_start);
envrange_rl.prune(time_since_start);
envroots_rl.prune(time_since_start);
blbrange_rl.prune(time_since_start);
blbroot_rl.prune(time_since_start);
dcbrange_rl.prune(time_since_start);

View File

@@ -187,10 +187,9 @@ impl<E: EthSpec> Network<E> {
// set up a collection of variables accessible outside of the network crate
// Create an ENR or load from disk if appropriate
let next_fork_digest = ctx
.fork_context
.next_fork_digest()
.unwrap_or_else(|| ctx.fork_context.current_fork_digest());
// Per [spec](https://github.com/ethereum/consensus-specs/blob/1baa05e71148b0975e28918ac6022d2256b56f4a/specs/fulu/p2p-interface.md?plain=1#L636-L637)
// `nfd` must be zero-valued when no next fork is scheduled.
let next_fork_digest = ctx.fork_context.next_fork_digest().unwrap_or_default();
let advertised_cgc = config
.advertise_false_custody_group_count