Fork aware max values in rpc (#6847)

N/A


  In https://github.com/sigp/lighthouse/pull/6329 we changed `max_blobs_per_block` from a preset to a config value.
We weren't using the right value based on fork in that PR. This is a follow up PR to use the fork dependent values.

In the proces, I also updated other places where we weren't using fork dependent values from the ChainSpec.

Note to reviewer: easier to go through by commit
This commit is contained in:
Pawan Dhananjay
2025-01-29 11:42:13 -08:00
committed by GitHub
parent e7ea69647a
commit 4a07c08c4f
16 changed files with 203 additions and 114 deletions

View File

@@ -43,8 +43,8 @@ use std::time::Duration;
use tokio::sync::mpsc;
use types::blob_sidecar::FixedBlobSidecarList;
use types::{
BlobSidecar, ColumnIndex, DataColumnSidecar, DataColumnSidecarList, EthSpec, Hash256,
SignedBeaconBlock, Slot,
BlobSidecar, ColumnIndex, DataColumnSidecar, DataColumnSidecarList, EthSpec, ForkContext,
Hash256, SignedBeaconBlock, Slot,
};
pub mod custody;
@@ -216,6 +216,8 @@ pub struct SyncNetworkContext<T: BeaconChainTypes> {
pub chain: Arc<BeaconChain<T>>,
fork_context: Arc<ForkContext>,
/// Logger for the `SyncNetworkContext`.
pub log: slog::Logger,
}
@@ -244,6 +246,7 @@ impl<T: BeaconChainTypes> SyncNetworkContext<T> {
network_send: mpsc::UnboundedSender<NetworkMessage<T::EthSpec>>,
network_beacon_processor: Arc<NetworkBeaconProcessor<T>>,
chain: Arc<BeaconChain<T>>,
fork_context: Arc<ForkContext>,
log: slog::Logger,
) -> Self {
SyncNetworkContext {
@@ -257,6 +260,7 @@ impl<T: BeaconChainTypes> SyncNetworkContext<T> {
range_block_components_requests: FnvHashMap::default(),
network_beacon_processor,
chain,
fork_context,
log,
}
}
@@ -455,7 +459,6 @@ impl<T: BeaconChainTypes> SyncNetworkContext<T> {
(None, None)
};
// TODO(pawan): this would break if a batch contains multiple epochs
let max_blobs_len = self.chain.spec.max_blobs_per_block(epoch);
let info = RangeBlockComponentsRequest::new(
expected_blobs,
@@ -624,7 +627,7 @@ impl<T: BeaconChainTypes> SyncNetworkContext<T> {
self.network_send
.send(NetworkMessage::SendRequest {
peer_id,
request: RequestType::BlocksByRoot(request.into_request(&self.chain.spec)),
request: RequestType::BlocksByRoot(request.into_request(&self.fork_context)),
request_id: AppRequestId::Sync(SyncRequestId::SingleBlock { id }),
})
.map_err(|_| RpcRequestSendError::NetworkSendError)?;
@@ -706,7 +709,7 @@ impl<T: BeaconChainTypes> SyncNetworkContext<T> {
self.network_send
.send(NetworkMessage::SendRequest {
peer_id,
request: RequestType::BlobsByRoot(request.clone().into_request(&self.chain.spec)),
request: RequestType::BlobsByRoot(request.clone().into_request(&self.fork_context)),
request_id: AppRequestId::Sync(SyncRequestId::SingleBlob { id }),
})
.map_err(|_| RpcRequestSendError::NetworkSendError)?;