mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-11 18:04:18 +00:00
Fixes after rebasing eip4844
This commit is contained in:
@@ -958,9 +958,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
block_root: &Hash256,
|
||||
) -> Result<Option<SignedBeaconBlockAndBlobsSidecar<T::EthSpec>>, Error> {
|
||||
// If there is no data availability boundary, the Eip4844 fork is disabled.
|
||||
if let Some(finalized_data_availability_boundary) =
|
||||
self.finalized_data_availability_boundary()
|
||||
{
|
||||
if self.finalized_data_availability_boundary().is_some() {
|
||||
// Only use the attester cache if we can find both the block and blob
|
||||
if let (Some(block), Some(blobs)) = (
|
||||
self.early_attester_cache.get_block(*block_root),
|
||||
@@ -972,9 +970,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
}))
|
||||
// Attempt to get the block and blobs from the database
|
||||
} else if let Some(block) = self.get_block(block_root).await?.map(Arc::new) {
|
||||
let blobs = self
|
||||
.get_blobs(block_root, finalized_data_availability_boundary)?
|
||||
.map(Arc::new);
|
||||
let blobs = self.get_blobs(block_root)?.map(Arc::new);
|
||||
Ok(blobs.map(|blobs| SignedBeaconBlockAndBlobsSidecar {
|
||||
beacon_block: block,
|
||||
blobs_sidecar: blobs,
|
||||
@@ -1070,7 +1066,6 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
pub fn get_blobs(
|
||||
&self,
|
||||
block_root: &Hash256,
|
||||
data_availability_boundary: Epoch,
|
||||
) -> Result<Option<BlobsSidecar<T::EthSpec>>, Error> {
|
||||
match self.store.get_blobs(block_root)? {
|
||||
Some(blobs) => Ok(Some(blobs)),
|
||||
|
||||
@@ -292,12 +292,12 @@ impl<E: EthSpec> AvailableBlock<E> {
|
||||
let blobs_sidecar = beacon_block
|
||||
.reconstruct_empty_blobs(Some(block_root))
|
||||
.map(Arc::new)?;
|
||||
return Ok(AvailableBlock(AvailableBlockInner::BlockAndBlob(
|
||||
Ok(AvailableBlock(AvailableBlockInner::BlockAndBlob(
|
||||
SignedBeaconBlockAndBlobsSidecar {
|
||||
beacon_block,
|
||||
blobs_sidecar,
|
||||
},
|
||||
)));
|
||||
)))
|
||||
}
|
||||
DataAvailabilityCheckRequired::No => {
|
||||
Ok(AvailableBlock(AvailableBlockInner::Block(beacon_block)))
|
||||
@@ -391,6 +391,7 @@ pub trait AsBlock<E: EthSpec> {
|
||||
fn message(&self) -> BeaconBlockRef<E>;
|
||||
fn as_block(&self) -> &SignedBeaconBlock<E>;
|
||||
fn block_cloned(&self) -> Arc<SignedBeaconBlock<E>>;
|
||||
fn canonical_root(&self) -> Hash256;
|
||||
}
|
||||
|
||||
impl<E: EthSpec> AsBlock<E> for BlockWrapper<E> {
|
||||
@@ -432,8 +433,8 @@ impl<E: EthSpec> AsBlock<E> for BlockWrapper<E> {
|
||||
}
|
||||
fn as_block(&self) -> &SignedBeaconBlock<E> {
|
||||
match &self {
|
||||
BlockWrapper::Block(block) => &block,
|
||||
BlockWrapper::BlockAndBlob(block, _) => &block,
|
||||
BlockWrapper::Block(block) => block,
|
||||
BlockWrapper::BlockAndBlob(block, _) => block,
|
||||
}
|
||||
}
|
||||
fn block_cloned(&self) -> Arc<SignedBeaconBlock<E>> {
|
||||
@@ -442,6 +443,12 @@ impl<E: EthSpec> AsBlock<E> for BlockWrapper<E> {
|
||||
BlockWrapper::BlockAndBlob(block, _) => block.clone(),
|
||||
}
|
||||
}
|
||||
fn canonical_root(&self) -> Hash256 {
|
||||
match &self {
|
||||
BlockWrapper::Block(block) => block.canonical_root(),
|
||||
BlockWrapper::BlockAndBlob(block, _) => block.canonical_root(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<E: EthSpec> AsBlock<E> for &BlockWrapper<E> {
|
||||
@@ -483,8 +490,8 @@ impl<E: EthSpec> AsBlock<E> for &BlockWrapper<E> {
|
||||
}
|
||||
fn as_block(&self) -> &SignedBeaconBlock<E> {
|
||||
match &self {
|
||||
BlockWrapper::Block(block) => &block,
|
||||
BlockWrapper::BlockAndBlob(block, _) => &block,
|
||||
BlockWrapper::Block(block) => block,
|
||||
BlockWrapper::BlockAndBlob(block, _) => block,
|
||||
}
|
||||
}
|
||||
fn block_cloned(&self) -> Arc<SignedBeaconBlock<E>> {
|
||||
@@ -493,6 +500,12 @@ impl<E: EthSpec> AsBlock<E> for &BlockWrapper<E> {
|
||||
BlockWrapper::BlockAndBlob(block, _) => block.clone(),
|
||||
}
|
||||
}
|
||||
fn canonical_root(&self) -> Hash256 {
|
||||
match &self {
|
||||
BlockWrapper::Block(block) => block.canonical_root(),
|
||||
BlockWrapper::BlockAndBlob(block, _) => block.canonical_root(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<E: EthSpec> AsBlock<E> for AvailableBlock<E> {
|
||||
@@ -546,7 +559,7 @@ impl<E: EthSpec> AsBlock<E> for AvailableBlock<E> {
|
||||
}
|
||||
fn as_block(&self) -> &SignedBeaconBlock<E> {
|
||||
match &self.0 {
|
||||
AvailableBlockInner::Block(block) => &block,
|
||||
AvailableBlockInner::Block(block) => block,
|
||||
AvailableBlockInner::BlockAndBlob(block_sidecar_pair) => {
|
||||
&block_sidecar_pair.beacon_block
|
||||
}
|
||||
@@ -560,4 +573,12 @@ impl<E: EthSpec> AsBlock<E> for AvailableBlock<E> {
|
||||
}
|
||||
}
|
||||
}
|
||||
fn canonical_root(&self) -> Hash256 {
|
||||
match &self.0 {
|
||||
AvailableBlockInner::Block(block) => block.canonical_root(),
|
||||
AvailableBlockInner::BlockAndBlob(block_sidecar_pair) => {
|
||||
block_sidecar_pair.beacon_block.canonical_root()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1120,7 +1120,7 @@ impl<T: BeaconChainTypes> IntoExecutionPendingBlock<T> for SignatureVerifiedBloc
|
||||
}
|
||||
|
||||
fn block(&self) -> &SignedBeaconBlock<T::EthSpec> {
|
||||
&self.block.as_block()
|
||||
self.block.as_block()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user