Skip to content

Commit ca5d42a

Browse files
authored
Merge of #7521
2 parents 0ddf9a9 + 36147d4 commit ca5d42a

File tree

6 files changed

+262
-36
lines changed

6 files changed

+262
-36
lines changed

beacon_node/execution_layer/src/test_utils/execution_block_generator.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,9 @@ impl<E: EthSpec> ExecutionBlockGenerator<E> {
702702
if fork_name.deneb_enabled() {
703703
// get random number between 0 and Max Blobs
704704
let mut rng = self.rng.lock();
705-
let max_blobs = self.spec.max_blobs_per_block_by_fork(fork_name) as usize;
705+
// TODO(EIP-7892): see FIXME below
706+
// FIXME: this will break with BPO forks. This function needs to calculate the epoch based on block timestamp..
707+
let max_blobs = self.spec.max_blobs_per_block_within_fork(fork_name) as usize;
706708
let num_blobs = rng.gen::<usize>() % (max_blobs + 1);
707709
let (bundle, transactions) = generate_blobs(num_blobs, fork_name)?;
708710
for tx in Vec::from(transactions) {

beacon_node/lighthouse_network/src/rpc/handler.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use std::{
2828
use tokio::time::{sleep, Sleep};
2929
use tokio_util::time::{delay_queue, DelayQueue};
3030
use tracing::{debug, trace};
31-
use types::{EthSpec, ForkContext};
31+
use types::{EthSpec, ForkContext, Slot};
3232

3333
/// The number of times to retry an outbound upgrade in the case of IO errors.
3434
const IO_ERROR_RETRIES: u8 = 3;
@@ -932,9 +932,8 @@ where
932932
}
933933
}
934934
RequestType::BlobsByRange(request) => {
935-
let max_requested_blobs = request
936-
.count
937-
.saturating_mul(spec.max_blobs_per_block_by_fork(current_fork));
935+
let epoch = Slot::new(request.start_slot).epoch(E::slots_per_epoch());
936+
let max_requested_blobs = request.max_blobs_requested(epoch, spec);
938937
let max_allowed = spec.max_request_blob_sidecars(current_fork) as u64;
939938
if max_requested_blobs > max_allowed {
940939
self.events_out.push(HandlerEvent::Err(HandlerErr::Inbound {

beacon_node/lighthouse_network/src/rpc/methods.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,10 @@ use types::blob_sidecar::BlobIdentifier;
1616
use types::light_client_update::MAX_REQUEST_LIGHT_CLIENT_UPDATES;
1717
use types::{
1818
blob_sidecar::BlobSidecar, ChainSpec, ColumnIndex, DataColumnSidecar,
19-
DataColumnsByRootIdentifier, Epoch, EthSpec, Hash256, LightClientBootstrap,
19+
DataColumnsByRootIdentifier, Epoch, EthSpec, ForkContext, Hash256, LightClientBootstrap,
2020
LightClientFinalityUpdate, LightClientOptimisticUpdate, LightClientUpdate, RuntimeVariableList,
2121
SignedBeaconBlock, Slot,
2222
};
23-
use types::{ForkContext, ForkName};
2423

2524
/// Maximum length of error message.
2625
pub type MaxErrorLen = U256;
@@ -328,8 +327,8 @@ pub struct BlobsByRangeRequest {
328327
}
329328

330329
impl BlobsByRangeRequest {
331-
pub fn max_blobs_requested(&self, current_fork: ForkName, spec: &ChainSpec) -> u64 {
332-
let max_blobs_per_block = spec.max_blobs_per_block_by_fork(current_fork);
330+
pub fn max_blobs_requested(&self, epoch: Epoch, spec: &ChainSpec) -> u64 {
331+
let max_blobs_per_block = spec.max_blobs_per_block(epoch);
333332
self.count.saturating_mul(max_blobs_per_block)
334333
}
335334
}

beacon_node/lighthouse_network/src/rpc/protocol.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use types::{
2121
EmptyBlock, EthSpec, EthSpecId, ForkContext, ForkName, LightClientBootstrap,
2222
LightClientBootstrapAltair, LightClientFinalityUpdate, LightClientFinalityUpdateAltair,
2323
LightClientOptimisticUpdate, LightClientOptimisticUpdateAltair, LightClientUpdate,
24-
MainnetEthSpec, MinimalEthSpec, Signature, SignedBeaconBlock,
24+
MainnetEthSpec, MinimalEthSpec, Signature, SignedBeaconBlock, Slot,
2525
};
2626

2727
// Note: Hardcoding the `EthSpec` type for `SignedBeaconBlock` as min/max values is
@@ -633,7 +633,8 @@ pub fn rpc_blob_limits<E: EthSpec>() -> RpcLimits {
633633
pub fn rpc_data_column_limits<E: EthSpec>(fork_name: ForkName, spec: &ChainSpec) -> RpcLimits {
634634
RpcLimits::new(
635635
DataColumnSidecar::<E>::min_size(),
636-
DataColumnSidecar::<E>::max_size(spec.max_blobs_per_block_by_fork(fork_name) as usize),
636+
// TODO(EIP-7892): fix this once we change fork-version on BPO forks
637+
DataColumnSidecar::<E>::max_size(spec.max_blobs_per_block_within_fork(fork_name) as usize),
637638
)
638639
}
639640

@@ -732,13 +733,16 @@ impl<E: EthSpec> RequestType<E> {
732733
/* These functions are used in the handler for stream management */
733734

734735
/// Maximum number of responses expected for this request.
735-
pub fn max_responses(&self, current_fork: ForkName, spec: &ChainSpec) -> u64 {
736+
/// TODO(EIP-7892): refactor this to remove `_current_fork`
737+
pub fn max_responses(&self, _current_fork: ForkName, spec: &ChainSpec) -> u64 {
736738
match self {
737739
RequestType::Status(_) => 1,
738740
RequestType::Goodbye(_) => 0,
739741
RequestType::BlocksByRange(req) => *req.count(),
740742
RequestType::BlocksByRoot(req) => req.block_roots().len() as u64,
741-
RequestType::BlobsByRange(req) => req.max_blobs_requested(current_fork, spec),
743+
RequestType::BlobsByRange(req) => {
744+
req.max_blobs_requested(Slot::new(req.start_slot).epoch(E::slots_per_epoch()), spec)
745+
}
742746
RequestType::BlobsByRoot(req) => req.blob_ids.len() as u64,
743747
RequestType::DataColumnsByRoot(req) => req.max_requested() as u64,
744748
RequestType::DataColumnsByRange(req) => req.max_requested::<E>(),

common/eth2/src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1296,7 +1296,9 @@ impl BeaconNodeHttpClient {
12961296
}
12971297

12981298
self.get_fork_contextual(path, |fork| {
1299-
(fork, spec.max_blobs_per_block_by_fork(fork) as usize)
1299+
// TODO(EIP-7892): this will overestimate the max number of blobs
1300+
// It would be better if we could get an epoch passed into this function
1301+
(fork, spec.max_blobs_per_block_within_fork(fork) as usize)
13001302
})
13011303
.await
13021304
.map(|opt| opt.map(BeaconResponse::ForkVersioned))

0 commit comments

Comments
 (0)