mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-14 18:32:42 +00:00
First pass
This commit is contained in:
@@ -24,6 +24,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>);
|
||||
@@ -326,8 +333,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 as u64)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -92,7 +92,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.
|
||||
//
|
||||
@@ -100,7 +100,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.
|
||||
|
||||
@@ -636,7 +636,7 @@ pub fn rpc_blob_limits<E: EthSpec>() -> RpcLimits {
|
||||
pub fn rpc_data_column_limits<E: EthSpec>() -> RpcLimits {
|
||||
RpcLimits::new(
|
||||
DataColumnSidecar::<E>::empty().as_ssz_bytes().len(),
|
||||
DataColumnSidecar::<E>::max_size(),
|
||||
DataColumnSidecar::<E>::max_size(MAX_BLOBS_PER_BLOCK_CEILING as usize),
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user