mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-03 00:31:50 +00:00
Implement EIP-7892 BPO hardforks (#7521)
[EIP-7892: Blob Parameter Only Hardforks](https://eips.ethereum.org/EIPS/eip-7892) #7467
This commit is contained in:
@@ -28,7 +28,7 @@ use std::{
|
||||
use tokio::time::{sleep, Sleep};
|
||||
use tokio_util::time::{delay_queue, DelayQueue};
|
||||
use tracing::{debug, trace};
|
||||
use types::{EthSpec, ForkContext};
|
||||
use types::{EthSpec, ForkContext, Slot};
|
||||
|
||||
/// The number of times to retry an outbound upgrade in the case of IO errors.
|
||||
const IO_ERROR_RETRIES: u8 = 3;
|
||||
@@ -932,9 +932,8 @@ where
|
||||
}
|
||||
}
|
||||
RequestType::BlobsByRange(request) => {
|
||||
let max_requested_blobs = request
|
||||
.count
|
||||
.saturating_mul(spec.max_blobs_per_block_by_fork(current_fork));
|
||||
let epoch = Slot::new(request.start_slot).epoch(E::slots_per_epoch());
|
||||
let max_requested_blobs = request.max_blobs_requested(epoch, spec);
|
||||
let max_allowed = spec.max_request_blob_sidecars(current_fork) as u64;
|
||||
if max_requested_blobs > max_allowed {
|
||||
self.events_out.push(HandlerEvent::Err(HandlerErr::Inbound {
|
||||
|
||||
@@ -16,11 +16,10 @@ use types::blob_sidecar::BlobIdentifier;
|
||||
use types::light_client_update::MAX_REQUEST_LIGHT_CLIENT_UPDATES;
|
||||
use types::{
|
||||
blob_sidecar::BlobSidecar, ChainSpec, ColumnIndex, DataColumnSidecar,
|
||||
DataColumnsByRootIdentifier, Epoch, EthSpec, Hash256, LightClientBootstrap,
|
||||
DataColumnsByRootIdentifier, Epoch, EthSpec, ForkContext, Hash256, LightClientBootstrap,
|
||||
LightClientFinalityUpdate, LightClientOptimisticUpdate, LightClientUpdate, RuntimeVariableList,
|
||||
SignedBeaconBlock, Slot,
|
||||
};
|
||||
use types::{ForkContext, ForkName};
|
||||
|
||||
/// Maximum length of error message.
|
||||
pub type MaxErrorLen = U256;
|
||||
@@ -328,8 +327,8 @@ pub struct BlobsByRangeRequest {
|
||||
}
|
||||
|
||||
impl BlobsByRangeRequest {
|
||||
pub fn max_blobs_requested(&self, current_fork: ForkName, spec: &ChainSpec) -> u64 {
|
||||
let max_blobs_per_block = spec.max_blobs_per_block_by_fork(current_fork);
|
||||
pub fn max_blobs_requested(&self, epoch: Epoch, spec: &ChainSpec) -> u64 {
|
||||
let max_blobs_per_block = spec.max_blobs_per_block(epoch);
|
||||
self.count.saturating_mul(max_blobs_per_block)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ use types::{
|
||||
EmptyBlock, EthSpec, EthSpecId, ForkContext, ForkName, LightClientBootstrap,
|
||||
LightClientBootstrapAltair, LightClientFinalityUpdate, LightClientFinalityUpdateAltair,
|
||||
LightClientOptimisticUpdate, LightClientOptimisticUpdateAltair, LightClientUpdate,
|
||||
MainnetEthSpec, MinimalEthSpec, Signature, SignedBeaconBlock,
|
||||
MainnetEthSpec, MinimalEthSpec, Signature, SignedBeaconBlock, Slot,
|
||||
};
|
||||
|
||||
// Note: Hardcoding the `EthSpec` type for `SignedBeaconBlock` as min/max values is
|
||||
@@ -633,7 +633,8 @@ pub fn rpc_blob_limits<E: EthSpec>() -> RpcLimits {
|
||||
pub fn rpc_data_column_limits<E: EthSpec>(fork_name: ForkName, spec: &ChainSpec) -> RpcLimits {
|
||||
RpcLimits::new(
|
||||
DataColumnSidecar::<E>::min_size(),
|
||||
DataColumnSidecar::<E>::max_size(spec.max_blobs_per_block_by_fork(fork_name) as usize),
|
||||
// TODO(EIP-7892): fix this once we change fork-version on BPO forks
|
||||
DataColumnSidecar::<E>::max_size(spec.max_blobs_per_block_within_fork(fork_name) as usize),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -732,13 +733,16 @@ 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, current_fork: ForkName, spec: &ChainSpec) -> u64 {
|
||||
/// TODO(EIP-7892): refactor this to remove `_current_fork`
|
||||
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(current_fork, spec),
|
||||
RequestType::BlobsByRange(req) => {
|
||||
req.max_blobs_requested(Slot::new(req.start_slot).epoch(E::slots_per_epoch()), spec)
|
||||
}
|
||||
RequestType::BlobsByRoot(req) => req.blob_ids.len() as u64,
|
||||
RequestType::DataColumnsByRoot(req) => req.max_requested() as u64,
|
||||
RequestType::DataColumnsByRange(req) => req.max_requested::<E>(),
|
||||
|
||||
Reference in New Issue
Block a user