mirror of
https://github.com/sigp/lighthouse.git
synced 2026-07-01 11:54:40 +00:00
Fix rebase conflicts
This commit is contained in:
@@ -1075,27 +1075,23 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
match self.store.get_blobs(block_root)? {
|
||||
Some(blobs) => Ok(Some(blobs)),
|
||||
None => {
|
||||
// Check for the corresponding block to understand whether we *should* have blobs.
|
||||
self.get_blinded_block(block_root)?
|
||||
.map(|block| {
|
||||
// If there are no KZG commitments in the block, we know the sidecar should
|
||||
// be empty.
|
||||
let expected_kzg_commitments =
|
||||
match block.message().body().blob_kzg_commitments() {
|
||||
Ok(kzg_commitments) => kzg_commitments,
|
||||
Err(_) => return Err(Error::NoKzgCommitmentsFieldOnBlock),
|
||||
};
|
||||
if expected_kzg_commitments.is_empty() {
|
||||
Ok(BlobsSidecar::empty_from_parts(*block_root, block.slot()))
|
||||
} else if data_availability_boundary <= block.epoch() {
|
||||
// We should have blobs for all blocks younger than the boundary.
|
||||
Err(Error::BlobsUnavailable)
|
||||
} else {
|
||||
// We shouldn't have blobs for blocks older than the boundary.
|
||||
Err(Error::BlobsOlderThanDataAvailabilityBoundary(block.epoch()))
|
||||
}
|
||||
})
|
||||
.transpose()
|
||||
if let Ok(Some(block)) = self.get_blinded_block(block_root) {
|
||||
let expected_kzg_commitments = block.message().body().blob_kzg_commitments()?;
|
||||
|
||||
if !expected_kzg_commitments.is_empty() {
|
||||
Err(Error::DBInconsistent(format!(
|
||||
"Expected kzg commitments but no blobs stored for block root {}",
|
||||
block_root
|
||||
)))
|
||||
} else {
|
||||
Ok(Some(BlobsSidecar::empty_from_parts(
|
||||
*block_root,
|
||||
block.slot(),
|
||||
)))
|
||||
}
|
||||
} else {
|
||||
Ok(None)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3031,7 +3027,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
// margin, or younger (of higher epoch number).
|
||||
if block_epoch >= import_boundary {
|
||||
if let Some(blobs) = blobs {
|
||||
if blobs.blobs.len() > 0 {
|
||||
if !blobs.blobs.is_empty() {
|
||||
//FIXME(sean) using this for debugging for now
|
||||
info!(
|
||||
self.log, "Writing blobs to store";
|
||||
@@ -4548,7 +4544,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
None,
|
||||
),
|
||||
BeaconState::Merge(_) => {
|
||||
let (payload, _, _) = block_contents
|
||||
let block_contents = block_contents
|
||||
.ok_or(BlockProductionError::MissingExecutionPayload)?
|
||||
.deconstruct();
|
||||
(
|
||||
@@ -4568,7 +4564,8 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
voluntary_exits: voluntary_exits.into(),
|
||||
sync_aggregate: sync_aggregate
|
||||
.ok_or(BlockProductionError::MissingSyncAggregate)?,
|
||||
execution_payload: payload
|
||||
execution_payload: block_contents
|
||||
.payload
|
||||
.try_into()
|
||||
.map_err(|_| BlockProductionError::InvalidPayloadFork)?,
|
||||
},
|
||||
@@ -4577,7 +4574,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
)
|
||||
}
|
||||
BeaconState::Capella(_) => {
|
||||
let (payload, _, _) = block_contents
|
||||
let block_contents = block_contents
|
||||
.ok_or(BlockProductionError::MissingExecutionPayload)?
|
||||
.deconstruct();
|
||||
|
||||
@@ -4598,7 +4595,8 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
voluntary_exits: voluntary_exits.into(),
|
||||
sync_aggregate: sync_aggregate
|
||||
.ok_or(BlockProductionError::MissingSyncAggregate)?,
|
||||
execution_payload: payload
|
||||
execution_payload: block_contents
|
||||
.payload
|
||||
.try_into()
|
||||
.map_err(|_| BlockProductionError::InvalidPayloadFork)?,
|
||||
bls_to_execution_changes: bls_to_execution_changes.into(),
|
||||
@@ -4608,10 +4606,22 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
)
|
||||
}
|
||||
BeaconState::Eip4844(_) => {
|
||||
let (payload, kzg_commitments, blobs) = block_contents
|
||||
let block_contents_unpacked = block_contents
|
||||
.ok_or(BlockProductionError::MissingExecutionPayload)?
|
||||
.deconstruct();
|
||||
|
||||
let (blob_kzg_commitments, blobs) = match block_contents_unpacked.blobs_content {
|
||||
Some(blobs_content) => {
|
||||
let kzg_commitments: KzgCommitments<T::EthSpec> =
|
||||
blobs_content.kzg_commitments;
|
||||
let blobs: Blobs<T::EthSpec> = blobs_content.blobs;
|
||||
(kzg_commitments, blobs)
|
||||
}
|
||||
None => {
|
||||
return Err(BlockProductionError::InvalidPayloadFork);
|
||||
}
|
||||
};
|
||||
|
||||
(
|
||||
BeaconBlock::Eip4844(BeaconBlockEip4844 {
|
||||
slot,
|
||||
@@ -4629,15 +4639,15 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
voluntary_exits: voluntary_exits.into(),
|
||||
sync_aggregate: sync_aggregate
|
||||
.ok_or(BlockProductionError::MissingSyncAggregate)?,
|
||||
execution_payload: payload
|
||||
execution_payload: block_contents_unpacked
|
||||
.payload
|
||||
.try_into()
|
||||
.map_err(|_| BlockProductionError::InvalidPayloadFork)?,
|
||||
bls_to_execution_changes: bls_to_execution_changes.into(),
|
||||
blob_kzg_commitments: kzg_commitments
|
||||
.ok_or(BlockProductionError::InvalidPayloadFork)?,
|
||||
blob_kzg_commitments,
|
||||
},
|
||||
}),
|
||||
blobs,
|
||||
Some(blobs),
|
||||
)
|
||||
}
|
||||
};
|
||||
@@ -4652,7 +4662,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
debug!(
|
||||
self.log,
|
||||
"Produced block on state";
|
||||
"block_size" => block_size,
|
||||
"block_size" => %block_size,
|
||||
);
|
||||
|
||||
metrics::observe(&metrics::BLOCK_SIZE, block_size as f64);
|
||||
@@ -4695,8 +4705,8 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
.as_ref()
|
||||
.ok_or(BlockProductionError::TrustedSetupNotInitialized)?;
|
||||
let kzg_aggregated_proof =
|
||||
kzg_utils::compute_aggregate_kzg_proof::<T::EthSpec>(&kzg, &blobs)
|
||||
.map_err(|e| BlockProductionError::KzgError(e))?;
|
||||
kzg_utils::compute_aggregate_kzg_proof::<T::EthSpec>(kzg, &blobs)
|
||||
.map_err(BlockProductionError::KzgError)?;
|
||||
let beacon_block_root = block.canonical_root();
|
||||
let expected_kzg_commitments = block.body().blob_kzg_commitments().map_err(|_| {
|
||||
BlockProductionError::InvalidBlockVariant(
|
||||
@@ -4710,7 +4720,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
kzg_aggregated_proof,
|
||||
};
|
||||
kzg_utils::validate_blobs_sidecar(
|
||||
&kzg,
|
||||
kzg,
|
||||
slot,
|
||||
beacon_block_root,
|
||||
expected_kzg_commitments,
|
||||
@@ -5942,17 +5952,14 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
/// The epoch at which we require a data availability check in block processing.
|
||||
/// `None` if the `Eip4844` fork is disabled.
|
||||
pub fn data_availability_boundary(&self) -> Option<Epoch> {
|
||||
self.spec
|
||||
.eip4844_fork_epoch
|
||||
.map(|fork_epoch| {
|
||||
self.epoch().ok().map(|current_epoch| {
|
||||
std::cmp::max(
|
||||
fork_epoch,
|
||||
current_epoch.saturating_sub(*MIN_EPOCHS_FOR_BLOBS_SIDECARS_REQUESTS),
|
||||
)
|
||||
})
|
||||
self.spec.eip4844_fork_epoch.and_then(|fork_epoch| {
|
||||
self.epoch().ok().map(|current_epoch| {
|
||||
std::cmp::max(
|
||||
fork_epoch,
|
||||
current_epoch.saturating_sub(*MIN_EPOCHS_FOR_BLOBS_SIDECARS_REQUESTS),
|
||||
)
|
||||
})
|
||||
.flatten()
|
||||
})
|
||||
}
|
||||
|
||||
/// The epoch that is a data availability boundary, or the latest finalized epoch.
|
||||
|
||||
Reference in New Issue
Block a user