Check data availability boundary in rpc request

This commit is contained in:
Emilia Hane
2023-01-17 09:53:37 +01:00
parent e046657b4f
commit 9445ac70d8
4 changed files with 99 additions and 25 deletions

View File

@@ -195,7 +195,7 @@ impl<E: EthSpec, Payload: AbstractExecPayload<E>> SignedBeaconBlock<E, Payload>
}
let domain = spec.get_domain(
self.slot().epoch(E::slots_per_epoch()),
self.epoch(),
Domain::BeaconProposer,
fork,
genesis_validators_root,
@@ -227,6 +227,11 @@ impl<E: EthSpec, Payload: AbstractExecPayload<E>> SignedBeaconBlock<E, Payload>
self.message().slot()
}
/// Convenience accessor for the block's epoch.
pub fn epoch(&self) -> Epoch {
self.message().slot().epoch(E::slots_per_epoch())
}
/// Convenience accessor for the block's parent root.
pub fn parent_root(&self) -> Hash256 {
self.message().parent_root()

View File

@@ -1,5 +1,7 @@
use crate::signed_beacon_block::BlobReconstructionError;
use crate::{BlobsSidecar, EthSpec, Hash256, SignedBeaconBlock, SignedBeaconBlockEip4844, Slot};
use crate::{
BlobsSidecar, Epoch, EthSpec, Hash256, SignedBeaconBlock, SignedBeaconBlockEip4844, Slot,
};
use derivative::Derivative;
use serde_derive::{Deserialize, Serialize};
use ssz::{Decode, DecodeError};
@@ -74,6 +76,14 @@ impl<T: EthSpec> BlockWrapper<T> {
}
}
}
pub fn epoch(&self) -> Epoch {
match &self.0 {
BlockWrapperInner::Block(block) => block.epoch(),
BlockWrapperInner::BlockAndBlob(block_sidecar_pair) => {
block_sidecar_pair.beacon_block.epoch()
}
}
}
pub fn block(&self) -> &SignedBeaconBlock<T> {
match &self.0 {
BlockWrapperInner::Block(block) => &block,