resolve merge conflicts

This commit is contained in:
Eitan Seri-Levi
2025-01-07 13:57:22 +07:00
49 changed files with 545 additions and 261 deletions

View File

@@ -25,6 +25,13 @@ use types::{
pub type MaxErrorLen = U256;
pub const MAX_ERROR_LEN: u64 = 256;
/// The max number of blobs we expect in the configs to set for compile time params.
/// Note: This value is an estimate that we should use only for rate limiting,
/// bounds checking and other non-consensus critical operations.
///
/// For exact value, we should always check the chainspec.
pub const MAX_BLOBS_PER_BLOCK_CEILING: u64 = 16;
/// Wrapper over SSZ List to represent error message in rpc responses.
#[derive(Debug, Clone)]
pub struct ErrorType(pub VariableList<u8, MaxErrorLen>);
@@ -327,8 +334,13 @@ pub struct BlobsByRangeRequest {
}
impl BlobsByRangeRequest {
/// This function provides an upper bound on number of blobs expected in
/// a certain slot range.
///
/// Note: **must not** use for anything consensus critical, only for
/// bounds checking and rate limiting.
pub fn max_blobs_requested<E: EthSpec>(&self) -> u64 {
self.count.saturating_mul(E::max_blobs_per_block() as u64)
self.count.saturating_mul(MAX_BLOBS_PER_BLOCK_CEILING)
}
}
@@ -851,3 +863,16 @@ impl slog::KV for StatusMessage {
slog::Result::Ok(())
}
}
#[cfg(test)]
mod test {
use super::*;
use types::{ForkName, MainnetEthSpec};
#[test]
fn max_blobs_per_block_ceiling() {
let spec = MainnetEthSpec::default_spec();
let latest_fork = ForkName::latest();
assert!(spec.max_blobs_per_block_by_fork(latest_fork) <= MAX_BLOBS_PER_BLOCK_CEILING);
}
}

View File

@@ -93,7 +93,7 @@ pub static SIGNED_BEACON_BLOCK_DENEB_MAX: LazyLock<usize> = LazyLock::new(|| {
*SIGNED_BEACON_BLOCK_CAPELLA_MAX_WITHOUT_PAYLOAD
+ types::ExecutionPayload::<MainnetEthSpec>::max_execution_payload_deneb_size() // adding max size of execution payload (~16gb)
+ ssz::BYTES_PER_LENGTH_OFFSET // Adding the additional offsets for the `ExecutionPayload`
+ (<types::KzgCommitment as Encode>::ssz_fixed_len() * <MainnetEthSpec>::max_blobs_per_block())
+ (<types::KzgCommitment as Encode>::ssz_fixed_len() * MAX_BLOBS_PER_BLOCK_CEILING as usize)
+ ssz::BYTES_PER_LENGTH_OFFSET
}); // Length offset for the blob commitments field.
//
@@ -101,7 +101,7 @@ pub static SIGNED_BEACON_BLOCK_ELECTRA_MAX: LazyLock<usize> = LazyLock::new(|| {
*SIGNED_BEACON_BLOCK_ELECTRA_MAX_WITHOUT_PAYLOAD
+ types::ExecutionPayload::<MainnetEthSpec>::max_execution_payload_electra_size() // adding max size of execution payload (~16gb)
+ ssz::BYTES_PER_LENGTH_OFFSET // Adding the additional ssz offset for the `ExecutionPayload` field
+ (<types::KzgCommitment as Encode>::ssz_fixed_len() * <MainnetEthSpec>::max_blobs_per_block())
+ (<types::KzgCommitment as Encode>::ssz_fixed_len() * MAX_BLOBS_PER_BLOCK_CEILING as usize)
+ ssz::BYTES_PER_LENGTH_OFFSET
}); // Length offset for the blob commitments field.
@@ -111,14 +111,6 @@ pub static BLOB_SIDECAR_SIZE: LazyLock<usize> =
pub static BLOB_SIDECAR_SIZE_MINIMAL: LazyLock<usize> =
LazyLock::new(BlobSidecar::<MinimalEthSpec>::max_size);
pub static DATA_COLUMNS_SIDECAR_MIN: LazyLock<usize> = LazyLock::new(|| {
DataColumnSidecar::<MainnetEthSpec>::empty()
.as_ssz_bytes()
.len()
});
pub static DATA_COLUMNS_SIDECAR_MAX: LazyLock<usize> =
LazyLock::new(DataColumnSidecar::<MainnetEthSpec>::max_size);
pub static ERROR_TYPE_MIN: LazyLock<usize> = LazyLock::new(|| {
VariableList::<u8, MaxErrorLen>::from(Vec::<u8>::new())
.as_ssz_bytes()
@@ -611,8 +603,8 @@ impl ProtocolId {
Protocol::BlocksByRoot => rpc_block_limits_by_fork(fork_context.current_fork()),
Protocol::BlobsByRange => rpc_blob_limits::<E>(),
Protocol::BlobsByRoot => rpc_blob_limits::<E>(),
Protocol::DataColumnsByRoot => rpc_data_column_limits(),
Protocol::DataColumnsByRange => rpc_data_column_limits(),
Protocol::DataColumnsByRoot => rpc_data_column_limits::<E>(),
Protocol::DataColumnsByRange => rpc_data_column_limits::<E>(),
Protocol::Ping => RpcLimits::new(
<Ping as Encode>::ssz_fixed_len(),
<Ping as Encode>::ssz_fixed_len(),
@@ -692,8 +684,11 @@ pub fn rpc_blob_limits<E: EthSpec>() -> RpcLimits {
}
}
pub fn rpc_data_column_limits() -> RpcLimits {
RpcLimits::new(*DATA_COLUMNS_SIDECAR_MIN, *DATA_COLUMNS_SIDECAR_MAX)
pub fn rpc_data_column_limits<E: EthSpec>() -> RpcLimits {
RpcLimits::new(
DataColumnSidecar::<E>::empty().as_ssz_bytes().len(),
DataColumnSidecar::<E>::max_size(MAX_BLOBS_PER_BLOCK_CEILING as usize),
)
}
/* Inbound upgrade */