mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-14 02:12:33 +00:00
Make max_blobs_per_block a config parameter (#6329)
* First pass
* Add restrictions to RuntimeVariableList api
* Use empty_uninitialized and fix warnings
* Fix some todos
* Merge branch 'unstable' into max-blobs-preset
* Fix take impl on RuntimeFixedList
* cleanup
* Fix test compilations
* Fix some more tests
* Fix test from unstable
* Merge branch 'unstable' into max-blobs-preset
* Merge remote-tracking branch 'origin/unstable' into max-blobs-preset
* Remove footgun function
* Minor simplifications
* Move from preset to config
* Fix typo
* Revert "Remove footgun function"
This reverts commit de01f923c7.
* Try fixing tests
* Thread through ChainSpec
* Fix release tests
* Move RuntimeFixedVector into module and rename
* Add test
* Remove empty RuntimeVarList awefullness
* Fix tests
* Simplify BlobSidecarListFromRoot
* Merge remote-tracking branch 'origin/unstable' into max-blobs-preset
* Bump quota to account for new target (6)
* Remove clone
* Fix issue from review
* Try to remove ugliness
* Merge branch 'unstable' into max-blobs-preset
* Fix max value
* Fix doctest
* Fix formatting
* Fix max check
* Delete hardcoded max_blobs_per_block in RPC limits
* Merge remote-tracking branch 'origin/unstable' into max-blobs-preset
This commit is contained in:
@@ -86,6 +86,10 @@ pub static SIGNED_BEACON_BLOCK_FULU_MAX_WITHOUT_PAYLOAD: LazyLock<usize> = LazyL
|
||||
/// We calculate the value from its fields instead of constructing the block and checking the length.
|
||||
/// Note: This is only the theoretical upper bound. We further bound the max size we receive over the network
|
||||
/// with `max_chunk_size`.
|
||||
///
|
||||
/// FIXME: Given that these limits are useless we should probably delete them. See:
|
||||
///
|
||||
/// https://github.com/sigp/lighthouse/issues/6790
|
||||
pub static SIGNED_BEACON_BLOCK_BELLATRIX_MAX: LazyLock<usize> =
|
||||
LazyLock::new(|| // Size of a full altair block
|
||||
*SIGNED_BEACON_BLOCK_ALTAIR_MAX
|
||||
@@ -102,7 +106,6 @@ 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())
|
||||
+ ssz::BYTES_PER_LENGTH_OFFSET
|
||||
}); // Length offset for the blob commitments field.
|
||||
//
|
||||
@@ -110,7 +113,6 @@ 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())
|
||||
+ ssz::BYTES_PER_LENGTH_OFFSET
|
||||
}); // Length offset for the blob commitments field.
|
||||
|
||||
@@ -118,8 +120,6 @@ pub static SIGNED_BEACON_BLOCK_FULU_MAX: LazyLock<usize> = LazyLock::new(|| {
|
||||
*SIGNED_BEACON_BLOCK_FULU_MAX_WITHOUT_PAYLOAD
|
||||
+ types::ExecutionPayload::<MainnetEthSpec>::max_execution_payload_fulu_size()
|
||||
+ ssz::BYTES_PER_LENGTH_OFFSET
|
||||
+ (<types::KzgCommitment as Encode>::ssz_fixed_len()
|
||||
* <MainnetEthSpec>::max_blobs_per_block())
|
||||
+ ssz::BYTES_PER_LENGTH_OFFSET
|
||||
});
|
||||
|
||||
@@ -129,14 +129,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()
|
||||
@@ -635,8 +627,10 @@ 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>(fork_context.current_fork()),
|
||||
Protocol::DataColumnsByRange => {
|
||||
rpc_data_column_limits::<E>(fork_context.current_fork())
|
||||
}
|
||||
Protocol::Ping => RpcLimits::new(
|
||||
<Ping as Encode>::ssz_fixed_len(),
|
||||
<Ping as Encode>::ssz_fixed_len(),
|
||||
@@ -716,8 +710,14 @@ 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)
|
||||
// TODO(peerdas): fix hardcoded max here
|
||||
pub fn rpc_data_column_limits<E: EthSpec>(fork_name: ForkName) -> RpcLimits {
|
||||
RpcLimits::new(
|
||||
DataColumnSidecar::<E>::empty().as_ssz_bytes().len(),
|
||||
DataColumnSidecar::<E>::max_size(
|
||||
E::default_spec().max_blobs_per_block_by_fork(fork_name) as usize
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
/* Inbound upgrade */
|
||||
@@ -815,13 +815,13 @@ impl<E: EthSpec> RequestType<E> {
|
||||
/* These functions are used in the handler for stream management */
|
||||
|
||||
/// Maximum number of responses expected for this request.
|
||||
pub fn max_responses(&self) -> u64 {
|
||||
pub fn max_responses(&self, current_fork: ForkName, spec: &ChainSpec) -> u64 {
|
||||
match self {
|
||||
RequestType::Status(_) => 1,
|
||||
RequestType::Goodbye(_) => 0,
|
||||
RequestType::BlocksByRange(req) => *req.count(),
|
||||
RequestType::BlocksByRoot(req) => req.block_roots().len() as u64,
|
||||
RequestType::BlobsByRange(req) => req.max_blobs_requested::<E>(),
|
||||
RequestType::BlobsByRange(req) => req.max_blobs_requested(current_fork, spec),
|
||||
RequestType::BlobsByRoot(req) => req.blob_ids.len() as u64,
|
||||
RequestType::DataColumnsByRoot(req) => req.data_column_ids.len() as u64,
|
||||
RequestType::DataColumnsByRange(req) => req.max_requested::<E>(),
|
||||
|
||||
Reference in New Issue
Block a user