range block or block+blob requests
This commit is contained in:
parent
a0d4aecf30
commit
5a42f6b067
@ -5422,21 +5422,25 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
|||||||
/// The epoch at which we require a data availability check in block processing.
|
/// The epoch at which we require a data availability check in block processing.
|
||||||
/// `None` if the `Eip4844` fork is disabled.
|
/// `None` if the `Eip4844` fork is disabled.
|
||||||
pub fn data_availability_boundary(&self) -> Option<Epoch> {
|
pub fn data_availability_boundary(&self) -> Option<Epoch> {
|
||||||
self.spec.eip4844_fork_epoch.map(|fork_epoch| {
|
self.spec
|
||||||
|
.eip4844_fork_epoch
|
||||||
|
.map(|fork_epoch| {
|
||||||
self.epoch().ok().map(|current_epoch| {
|
self.epoch().ok().map(|current_epoch| {
|
||||||
std::cmp::max(
|
std::cmp::max(
|
||||||
fork_epoch,
|
fork_epoch,
|
||||||
current_epoch - *MIN_EPOCHS_FOR_BLOBS_SIDECARS_REQUESTS,
|
current_epoch - *MIN_EPOCHS_FOR_BLOBS_SIDECARS_REQUESTS,
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
}).flatten()
|
})
|
||||||
|
.flatten()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns `true` if we are at or past the `Eip4844` fork. This will always return `false` if
|
/// Returns `true` if we are at or past the `Eip4844` fork. This will always return `false` if
|
||||||
/// the `Eip4844` fork is disabled.
|
/// the `Eip4844` fork is disabled.
|
||||||
pub fn is_data_availability_check_required(&self) -> Result<bool, Error> {
|
pub fn is_data_availability_check_required(&self) -> Result<bool, Error> {
|
||||||
let current_epoch = self.epoch()?;
|
let current_epoch = self.epoch()?;
|
||||||
Ok(self.spec
|
Ok(self
|
||||||
|
.spec
|
||||||
.eip4844_fork_epoch
|
.eip4844_fork_epoch
|
||||||
.map(|fork_epoch| fork_epoch <= current_epoch)
|
.map(|fork_epoch| fork_epoch <= current_epoch)
|
||||||
.unwrap_or(false))
|
.unwrap_or(false))
|
||||||
|
@ -466,7 +466,11 @@ impl<T: BeaconChainTypes> SyncNetworkContext<T> {
|
|||||||
peer_id: PeerId,
|
peer_id: PeerId,
|
||||||
request: BlocksByRootRequest,
|
request: BlocksByRootRequest,
|
||||||
) -> Result<Id, &'static str> {
|
) -> Result<Id, &'static str> {
|
||||||
let request = if self.chain.is_data_availability_check_required().map_err(|_|"Unable to read slot clock")? {
|
let request = if self
|
||||||
|
.chain
|
||||||
|
.is_data_availability_check_required()
|
||||||
|
.map_err(|_| "Unable to read slot clock")?
|
||||||
|
{
|
||||||
trace!(
|
trace!(
|
||||||
self.log,
|
self.log,
|
||||||
"Sending BlobsByRoot Request";
|
"Sending BlobsByRoot Request";
|
||||||
@ -501,7 +505,11 @@ impl<T: BeaconChainTypes> SyncNetworkContext<T> {
|
|||||||
peer_id: PeerId,
|
peer_id: PeerId,
|
||||||
request: BlocksByRootRequest,
|
request: BlocksByRootRequest,
|
||||||
) -> Result<Id, &'static str> {
|
) -> Result<Id, &'static str> {
|
||||||
let request = if self.chain.is_data_availability_check_required().map_err(|_|"Unable to read slot clock")? {
|
let request = if self
|
||||||
|
.chain
|
||||||
|
.is_data_availability_check_required()
|
||||||
|
.map_err(|_| "Unable to read slot clock")?
|
||||||
|
{
|
||||||
trace!(
|
trace!(
|
||||||
self.log,
|
self.log,
|
||||||
"Sending BlobsByRoot Request";
|
"Sending BlobsByRoot Request";
|
||||||
@ -613,15 +621,21 @@ impl<T: BeaconChainTypes> SyncNetworkContext<T> {
|
|||||||
EPOCHS_PER_BATCH, 1,
|
EPOCHS_PER_BATCH, 1,
|
||||||
"If this is not one, everything will fail horribly"
|
"If this is not one, everything will fail horribly"
|
||||||
);
|
);
|
||||||
warn!(
|
|
||||||
self.log,
|
|
||||||
"Missing fork boundary and prunning boundary comparison to decide request type. EVERYTHING IS A BLOB, BOB."
|
|
||||||
);
|
|
||||||
// Here we need access to the beacon chain, check the fork boundary, the current epoch, the
|
// Here we need access to the beacon chain, check the fork boundary, the current epoch, the
|
||||||
// blob period to serve and check with that if the batch is a blob batch or not.
|
// blob period to serve and check with that if the batch is a blob batch or not.
|
||||||
// NOTE: This would carelessly assume batch sizes are always 1 epoch, to avoid needing to
|
// NOTE: This would carelessly assume batch sizes are always 1 epoch, to avoid needing to
|
||||||
// align with the batch boundary.
|
// align with the batch boundary.
|
||||||
|
|
||||||
|
if let Some(data_availability_boundary) = self.chain.data_availability_boundary() {
|
||||||
|
if epoch >= data_availability_boundary {
|
||||||
ExpectedBatchTy::OnlyBlockBlobs
|
ExpectedBatchTy::OnlyBlockBlobs
|
||||||
|
} else {
|
||||||
|
ExpectedBatchTy::OnlyBlock
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ExpectedBatchTy::OnlyBlock
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user