mirror of
https://github.com/sigp/lighthouse.git
synced 2026-07-04 21:34:36 +00:00
BeaconBlockBody updates per eip-7732
This commit is contained in:
@@ -5727,15 +5727,12 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
BeaconState::Gloas(_) => {
|
BeaconState::Gloas(_) => {
|
||||||
let (
|
// Gloas blocks contain execution bids, not execution payloads
|
||||||
payload,
|
let block_proposal_contents =
|
||||||
kzg_commitments,
|
block_contents.ok_or(BlockProductionError::MissingExecutionBid)?;
|
||||||
maybe_blobs_and_proofs,
|
let (signed_execution_bid, payload_attestations) = block_proposal_contents
|
||||||
maybe_requests,
|
.into_execution_bid()
|
||||||
execution_payload_value,
|
.map_err(|_| BlockProductionError::InvalidPayloadFork)?;
|
||||||
) = block_contents
|
|
||||||
.ok_or(BlockProductionError::MissingExecutionPayload)?
|
|
||||||
.deconstruct();
|
|
||||||
|
|
||||||
(
|
(
|
||||||
BeaconBlock::Gloas(BeaconBlockGloas {
|
BeaconBlock::Gloas(BeaconBlockGloas {
|
||||||
@@ -5754,18 +5751,15 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
|||||||
voluntary_exits: voluntary_exits.into(),
|
voluntary_exits: voluntary_exits.into(),
|
||||||
sync_aggregate: sync_aggregate
|
sync_aggregate: sync_aggregate
|
||||||
.ok_or(BlockProductionError::MissingSyncAggregate)?,
|
.ok_or(BlockProductionError::MissingSyncAggregate)?,
|
||||||
execution_payload: payload
|
|
||||||
.try_into()
|
|
||||||
.map_err(|_| BlockProductionError::InvalidPayloadFork)?,
|
|
||||||
bls_to_execution_changes: bls_to_execution_changes.into(),
|
bls_to_execution_changes: bls_to_execution_changes.into(),
|
||||||
blob_kzg_commitments: kzg_commitments
|
// EIP-7732: Use actual execution bid data
|
||||||
.ok_or(BlockProductionError::InvalidPayloadFork)?,
|
signed_execution_payload_header: signed_execution_bid.clone(),
|
||||||
execution_requests: maybe_requests
|
payload_attestations,
|
||||||
.ok_or(BlockProductionError::MissingExecutionRequests)?,
|
_phantom: PhantomData,
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
maybe_blobs_and_proofs,
|
None, // blob commitments moved to `ExecutionPayloadEnvelope`
|
||||||
execution_payload_value,
|
Uint256::ZERO, // No execution payload value for Gloas blocks, just bids value
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -292,6 +292,7 @@ pub enum BlockProductionError {
|
|||||||
MissingBlobs,
|
MissingBlobs,
|
||||||
MissingSyncAggregate,
|
MissingSyncAggregate,
|
||||||
MissingExecutionPayload,
|
MissingExecutionPayload,
|
||||||
|
MissingExecutionBid,
|
||||||
MissingKzgCommitment(String),
|
MissingKzgCommitment(String),
|
||||||
TokioJoin(JoinError),
|
TokioJoin(JoinError),
|
||||||
BeaconChain(Box<BeaconChainError>),
|
BeaconChain(Box<BeaconChainError>),
|
||||||
|
|||||||
@@ -3252,25 +3252,6 @@ pub fn generate_rand_block_and_blobs<E: EthSpec>(
|
|||||||
message.body.blob_kzg_commitments = bundle.commitments.clone();
|
message.body.blob_kzg_commitments = bundle.commitments.clone();
|
||||||
bundle
|
bundle
|
||||||
}
|
}
|
||||||
SignedBeaconBlock::Gloas(SignedBeaconBlockGloas {
|
|
||||||
ref mut message, ..
|
|
||||||
}) => {
|
|
||||||
// Get either zero blobs or a random number of blobs between 1 and Max Blobs.
|
|
||||||
let payload: &mut FullPayloadGloas<E> = &mut message.body.execution_payload;
|
|
||||||
let num_blobs = match num_blobs {
|
|
||||||
NumBlobs::Random => rng.random_range(1..=max_blobs),
|
|
||||||
NumBlobs::Number(n) => n,
|
|
||||||
NumBlobs::None => 0,
|
|
||||||
};
|
|
||||||
let (bundle, transactions) =
|
|
||||||
execution_layer::test_utils::generate_blobs::<E>(num_blobs, fork_name).unwrap();
|
|
||||||
payload.execution_payload.transactions = <_>::default();
|
|
||||||
for tx in Vec::from(transactions) {
|
|
||||||
payload.execution_payload.transactions.push(tx).unwrap();
|
|
||||||
}
|
|
||||||
message.body.blob_kzg_commitments = bundle.commitments.clone();
|
|
||||||
bundle
|
|
||||||
}
|
|
||||||
_ => return (block, blob_sidecars),
|
_ => return (block, blob_sidecars),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -177,7 +177,7 @@ impl<'a, E: EthSpec> TryFrom<BeaconBlockRef<'a, E>> for NewPayloadRequest<'a, E>
|
|||||||
|
|
||||||
fn try_from(block: BeaconBlockRef<'a, E>) -> Result<Self, Self::Error> {
|
fn try_from(block: BeaconBlockRef<'a, E>) -> Result<Self, Self::Error> {
|
||||||
match block {
|
match block {
|
||||||
BeaconBlockRef::Base(_) | BeaconBlockRef::Altair(_) => {
|
BeaconBlockRef::Base(_) | BeaconBlockRef::Altair(_) | BeaconBlockRef::Gloas(_) => {
|
||||||
Err(Self::Error::IncorrectStateVariant)
|
Err(Self::Error::IncorrectStateVariant)
|
||||||
}
|
}
|
||||||
BeaconBlockRef::Bellatrix(block_ref) => {
|
BeaconBlockRef::Bellatrix(block_ref) => {
|
||||||
@@ -220,17 +220,6 @@ impl<'a, E: EthSpec> TryFrom<BeaconBlockRef<'a, E>> for NewPayloadRequest<'a, E>
|
|||||||
parent_beacon_block_root: block_ref.parent_root,
|
parent_beacon_block_root: block_ref.parent_root,
|
||||||
execution_requests: &block_ref.body.execution_requests,
|
execution_requests: &block_ref.body.execution_requests,
|
||||||
})),
|
})),
|
||||||
BeaconBlockRef::Gloas(block_ref) => Ok(Self::Gloas(NewPayloadRequestGloas {
|
|
||||||
execution_payload: &block_ref.body.execution_payload.execution_payload,
|
|
||||||
versioned_hashes: block_ref
|
|
||||||
.body
|
|
||||||
.blob_kzg_commitments
|
|
||||||
.iter()
|
|
||||||
.map(kzg_commitment_to_versioned_hash)
|
|
||||||
.collect(),
|
|
||||||
parent_beacon_block_root: block_ref.parent_root,
|
|
||||||
execution_requests: &block_ref.body.execution_requests,
|
|
||||||
})),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ use types::non_zero_usize::new_non_zero_usize;
|
|||||||
use types::payload::BlockProductionVersion;
|
use types::payload::BlockProductionVersion;
|
||||||
use types::{
|
use types::{
|
||||||
AbstractExecPayload, BlobsList, ExecutionPayloadDeneb, ExecutionRequests, KzgProofs,
|
AbstractExecPayload, BlobsList, ExecutionPayloadDeneb, ExecutionRequests, KzgProofs,
|
||||||
SignedBlindedBeaconBlock,
|
PayloadAttestation, SignedBlindedBeaconBlock, SignedExecutionBid,
|
||||||
};
|
};
|
||||||
use types::{
|
use types::{
|
||||||
BeaconStateError, BlindedPayload, ChainSpec, Epoch, ExecPayload, ExecutionPayloadBellatrix,
|
BeaconStateError, BlindedPayload, ChainSpec, Epoch, ExecPayload, ExecutionPayloadBellatrix,
|
||||||
@@ -219,6 +219,11 @@ pub enum BlockProposalContents<E: EthSpec, Payload: AbstractExecPayload<E>> {
|
|||||||
// See: https://github.com/sigp/lighthouse/issues/6981
|
// See: https://github.com/sigp/lighthouse/issues/6981
|
||||||
requests: Option<ExecutionRequests<E>>,
|
requests: Option<ExecutionRequests<E>>,
|
||||||
},
|
},
|
||||||
|
/// EIP-7732: Execution bid and payload attestations for Gloas fork
|
||||||
|
BidAndPayloadAttestations {
|
||||||
|
signed_execution_bid: SignedExecutionBid,
|
||||||
|
payload_attestations: VariableList<PayloadAttestation<E>, E::MaxPayloadAttestations>,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<E: EthSpec> From<BlockProposalContents<E, FullPayload<E>>>
|
impl<E: EthSpec> From<BlockProposalContents<E, FullPayload<E>>>
|
||||||
@@ -246,6 +251,13 @@ impl<E: EthSpec> From<BlockProposalContents<E, FullPayload<E>>>
|
|||||||
blobs_and_proofs: None,
|
blobs_and_proofs: None,
|
||||||
requests,
|
requests,
|
||||||
},
|
},
|
||||||
|
BlockProposalContents::BidAndPayloadAttestations {
|
||||||
|
signed_execution_bid,
|
||||||
|
payload_attestations,
|
||||||
|
} => BlockProposalContents::BidAndPayloadAttestations {
|
||||||
|
signed_execution_bid,
|
||||||
|
payload_attestations,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -313,6 +325,28 @@ impl<E: EthSpec, Payload: AbstractExecPayload<E>> BlockProposalContents<E, Paylo
|
|||||||
requests,
|
requests,
|
||||||
block_value,
|
block_value,
|
||||||
),
|
),
|
||||||
|
Self::BidAndPayloadAttestations { .. } => {
|
||||||
|
panic!("Cannot deconstruct BidAndPayloadAttestations variant into execution payload components")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Extract execution bid data for EIP-7732 Gloas blocks
|
||||||
|
pub fn into_execution_bid(
|
||||||
|
self,
|
||||||
|
) -> Result<
|
||||||
|
(
|
||||||
|
SignedExecutionBid,
|
||||||
|
VariableList<PayloadAttestation<E>, E::MaxPayloadAttestations>,
|
||||||
|
),
|
||||||
|
&'static str,
|
||||||
|
> {
|
||||||
|
match self {
|
||||||
|
Self::BidAndPayloadAttestations {
|
||||||
|
signed_execution_bid,
|
||||||
|
payload_attestations,
|
||||||
|
} => Ok((signed_execution_bid, payload_attestations)),
|
||||||
|
_ => Err("Cannot extract execution bid from non-BidAndPayloadAttestations variant"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -320,18 +354,27 @@ impl<E: EthSpec, Payload: AbstractExecPayload<E>> BlockProposalContents<E, Paylo
|
|||||||
match self {
|
match self {
|
||||||
Self::Payload { payload, .. } => payload,
|
Self::Payload { payload, .. } => payload,
|
||||||
Self::PayloadAndBlobs { payload, .. } => payload,
|
Self::PayloadAndBlobs { payload, .. } => payload,
|
||||||
|
Self::BidAndPayloadAttestations { .. } => {
|
||||||
|
panic!("BidAndPayloadAttestations variant does not contain execution payload")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn to_payload(self) -> Payload {
|
pub fn to_payload(self) -> Payload {
|
||||||
match self {
|
match self {
|
||||||
Self::Payload { payload, .. } => payload,
|
Self::Payload { payload, .. } => payload,
|
||||||
Self::PayloadAndBlobs { payload, .. } => payload,
|
Self::PayloadAndBlobs { payload, .. } => payload,
|
||||||
|
Self::BidAndPayloadAttestations { .. } => {
|
||||||
|
panic!("BidAndPayloadAttestations variant does not contain execution payload")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn block_value(&self) -> &Uint256 {
|
pub fn block_value(&self) -> &Uint256 {
|
||||||
match self {
|
match self {
|
||||||
Self::Payload { block_value, .. } => block_value,
|
Self::Payload { block_value, .. } => block_value,
|
||||||
Self::PayloadAndBlobs { block_value, .. } => block_value,
|
Self::PayloadAndBlobs { block_value, .. } => block_value,
|
||||||
|
Self::BidAndPayloadAttestations { .. } => {
|
||||||
|
panic!("BidAndPayloadAttestations variant does not have block_value")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -464,7 +464,9 @@ impl<E: EthSpec> MockBuilder<E> {
|
|||||||
block: SignedBlindedBeaconBlock<E>,
|
block: SignedBlindedBeaconBlock<E>,
|
||||||
) -> Result<FullPayloadContents<E>, String> {
|
) -> Result<FullPayloadContents<E>, String> {
|
||||||
let root = match &block {
|
let root = match &block {
|
||||||
SignedBlindedBeaconBlock::Base(_) | types::SignedBeaconBlock::Altair(_) => {
|
SignedBlindedBeaconBlock::Base(_)
|
||||||
|
| SignedBlindedBeaconBlock::Altair(_)
|
||||||
|
| SignedBlindedBeaconBlock::Gloas(_) => {
|
||||||
return Err("invalid fork".to_string());
|
return Err("invalid fork".to_string());
|
||||||
}
|
}
|
||||||
SignedBlindedBeaconBlock::Bellatrix(block) => {
|
SignedBlindedBeaconBlock::Bellatrix(block) => {
|
||||||
@@ -482,9 +484,6 @@ impl<E: EthSpec> MockBuilder<E> {
|
|||||||
SignedBlindedBeaconBlock::Fulu(block) => {
|
SignedBlindedBeaconBlock::Fulu(block) => {
|
||||||
block.message.body.execution_payload.tree_hash_root()
|
block.message.body.execution_payload.tree_hash_root()
|
||||||
}
|
}
|
||||||
SignedBlindedBeaconBlock::Gloas(block) => {
|
|
||||||
block.message.body.execution_payload.tree_hash_root()
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
info!(
|
info!(
|
||||||
block_hash = %root,
|
block_hash = %root,
|
||||||
|
|||||||
@@ -672,10 +672,10 @@ impl<E: EthSpec, Payload: AbstractExecPayload<E>> EmptyBlock for BeaconBlockGloa
|
|||||||
deposits: VariableList::empty(),
|
deposits: VariableList::empty(),
|
||||||
voluntary_exits: VariableList::empty(),
|
voluntary_exits: VariableList::empty(),
|
||||||
sync_aggregate: SyncAggregate::empty(),
|
sync_aggregate: SyncAggregate::empty(),
|
||||||
execution_payload: Payload::Gloas::default(),
|
|
||||||
bls_to_execution_changes: VariableList::empty(),
|
bls_to_execution_changes: VariableList::empty(),
|
||||||
blob_kzg_commitments: VariableList::empty(),
|
signed_execution_payload_header: SignedExecutionBid::empty(),
|
||||||
execution_requests: ExecutionRequests::default(),
|
payload_attestations: VariableList::empty(),
|
||||||
|
_phantom: PhantomData,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,7 +61,11 @@ pub const BLOB_KZG_COMMITMENTS_INDEX: usize = 11;
|
|||||||
Deneb(metastruct(mappings(beacon_block_body_deneb_fields(groups(fields))))),
|
Deneb(metastruct(mappings(beacon_block_body_deneb_fields(groups(fields))))),
|
||||||
Electra(metastruct(mappings(beacon_block_body_electra_fields(groups(fields))))),
|
Electra(metastruct(mappings(beacon_block_body_electra_fields(groups(fields))))),
|
||||||
Fulu(metastruct(mappings(beacon_block_body_fulu_fields(groups(fields))))),
|
Fulu(metastruct(mappings(beacon_block_body_fulu_fields(groups(fields))))),
|
||||||
Gloas(metastruct(mappings(beacon_block_body_gloas_fields(groups(fields))))),
|
// we relax the trait bounds for gloas since it doesn't contain a Payload
|
||||||
|
Gloas(
|
||||||
|
derivative(PartialEq, Hash(bound = "E: EthSpec")),
|
||||||
|
metastruct(mappings(beacon_block_body_gloas_fields(groups(fields))))
|
||||||
|
),
|
||||||
),
|
),
|
||||||
cast_error(ty = "Error", expr = "Error::IncorrectStateVariant"),
|
cast_error(ty = "Error", expr = "Error::IncorrectStateVariant"),
|
||||||
partial_getter_error(ty = "Error", expr = "Error::IncorrectStateVariant")
|
partial_getter_error(ty = "Error", expr = "Error::IncorrectStateVariant")
|
||||||
@@ -127,17 +131,21 @@ pub struct BeaconBlockBody<E: EthSpec, Payload: AbstractExecPayload<E> = FullPay
|
|||||||
#[superstruct(only(Fulu), partial_getter(rename = "execution_payload_fulu"))]
|
#[superstruct(only(Fulu), partial_getter(rename = "execution_payload_fulu"))]
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
pub execution_payload: Payload::Fulu,
|
pub execution_payload: Payload::Fulu,
|
||||||
#[superstruct(only(Gloas), partial_getter(rename = "execution_payload_gloas"))]
|
// execution_payload removed from Gloas, replaced with signed_execution_payload_header below
|
||||||
#[serde(flatten)]
|
|
||||||
pub execution_payload: Payload::Gloas,
|
|
||||||
#[superstruct(only(Capella, Deneb, Electra, Fulu, Gloas))]
|
#[superstruct(only(Capella, Deneb, Electra, Fulu, Gloas))]
|
||||||
pub bls_to_execution_changes:
|
pub bls_to_execution_changes:
|
||||||
VariableList<SignedBlsToExecutionChange, E::MaxBlsToExecutionChanges>,
|
VariableList<SignedBlsToExecutionChange, E::MaxBlsToExecutionChanges>,
|
||||||
#[superstruct(only(Deneb, Electra, Fulu, Gloas))]
|
// blob_kzg_commitments removed from Gloas, moved to `ExecutionPayloadEnvelope`
|
||||||
|
#[superstruct(only(Deneb, Electra, Fulu))]
|
||||||
pub blob_kzg_commitments: KzgCommitments<E>,
|
pub blob_kzg_commitments: KzgCommitments<E>,
|
||||||
#[superstruct(only(Electra, Fulu, Gloas))]
|
// execution_requests removed from Gloas, moved to `ExecutionPayloadEnvelope`
|
||||||
|
#[superstruct(only(Electra, Fulu))]
|
||||||
pub execution_requests: ExecutionRequests<E>,
|
pub execution_requests: ExecutionRequests<E>,
|
||||||
#[superstruct(only(Base, Altair))]
|
#[superstruct(only(Gloas))]
|
||||||
|
pub signed_execution_payload_header: SignedExecutionBid,
|
||||||
|
#[superstruct(only(Gloas))]
|
||||||
|
pub payload_attestations: VariableList<PayloadAttestation<E>, E::MaxPayloadAttestations>,
|
||||||
|
#[superstruct(only(Base, Altair, Gloas))]
|
||||||
#[metastruct(exclude_from(fields))]
|
#[metastruct(exclude_from(fields))]
|
||||||
#[ssz(skip_serializing, skip_deserializing)]
|
#[ssz(skip_serializing, skip_deserializing)]
|
||||||
#[tree_hash(skip_hashing)]
|
#[tree_hash(skip_hashing)]
|
||||||
@@ -160,13 +168,12 @@ impl<E: EthSpec, Payload: AbstractExecPayload<E>> BeaconBlockBody<E, Payload> {
|
|||||||
impl<'a, E: EthSpec, Payload: AbstractExecPayload<E>> BeaconBlockBodyRef<'a, E, Payload> {
|
impl<'a, E: EthSpec, Payload: AbstractExecPayload<E>> BeaconBlockBodyRef<'a, E, Payload> {
|
||||||
pub fn execution_payload(&self) -> Result<Payload::Ref<'a>, Error> {
|
pub fn execution_payload(&self) -> Result<Payload::Ref<'a>, Error> {
|
||||||
match self {
|
match self {
|
||||||
Self::Base(_) | Self::Altair(_) => Err(Error::IncorrectStateVariant),
|
Self::Base(_) | Self::Altair(_) | Self::Gloas(_) => Err(Error::IncorrectStateVariant),
|
||||||
Self::Bellatrix(body) => Ok(Payload::Ref::from(&body.execution_payload)),
|
Self::Bellatrix(body) => Ok(Payload::Ref::from(&body.execution_payload)),
|
||||||
Self::Capella(body) => Ok(Payload::Ref::from(&body.execution_payload)),
|
Self::Capella(body) => Ok(Payload::Ref::from(&body.execution_payload)),
|
||||||
Self::Deneb(body) => Ok(Payload::Ref::from(&body.execution_payload)),
|
Self::Deneb(body) => Ok(Payload::Ref::from(&body.execution_payload)),
|
||||||
Self::Electra(body) => Ok(Payload::Ref::from(&body.execution_payload)),
|
Self::Electra(body) => Ok(Payload::Ref::from(&body.execution_payload)),
|
||||||
Self::Fulu(body) => Ok(Payload::Ref::from(&body.execution_payload)),
|
Self::Fulu(body) => Ok(Payload::Ref::from(&body.execution_payload)),
|
||||||
Self::Gloas(body) => Ok(Payload::Ref::from(&body.execution_payload)),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -230,10 +237,12 @@ impl<'a, E: EthSpec, Payload: AbstractExecPayload<E>> BeaconBlockBodyRef<'a, E,
|
|||||||
kzg_commitments_proof: &[Hash256],
|
kzg_commitments_proof: &[Hash256],
|
||||||
) -> Result<FixedVector<Hash256, E::KzgCommitmentInclusionProofDepth>, Error> {
|
) -> Result<FixedVector<Hash256, E::KzgCommitmentInclusionProofDepth>, Error> {
|
||||||
match self {
|
match self {
|
||||||
Self::Base(_) | Self::Altair(_) | Self::Bellatrix(_) | Self::Capella(_) => {
|
Self::Base(_)
|
||||||
Err(Error::IncorrectStateVariant)
|
| Self::Altair(_)
|
||||||
}
|
| Self::Bellatrix(_)
|
||||||
Self::Deneb(_) | Self::Electra(_) | Self::Fulu(_) | Self::Gloas(_) => {
|
| Self::Capella(_)
|
||||||
|
| Self::Gloas(_) => Err(Error::IncorrectStateVariant),
|
||||||
|
Self::Deneb(_) | Self::Electra(_) | Self::Fulu(_) => {
|
||||||
// We compute the branches by generating 2 merkle trees:
|
// We compute the branches by generating 2 merkle trees:
|
||||||
// 1. Merkle tree for the `blob_kzg_commitments` List object
|
// 1. Merkle tree for the `blob_kzg_commitments` List object
|
||||||
// 2. Merkle tree for the `BeaconBlockBody` container
|
// 2. Merkle tree for the `BeaconBlockBody` container
|
||||||
@@ -512,6 +521,45 @@ impl<E: EthSpec> From<BeaconBlockBodyAltair<E, BlindedPayload<E>>>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Post-Fulu block bodies without payloads can be converted into block bodies with payloads
|
||||||
|
impl<E: EthSpec> From<BeaconBlockBodyGloas<E, BlindedPayload<E>>>
|
||||||
|
for BeaconBlockBodyGloas<E, FullPayload<E>>
|
||||||
|
{
|
||||||
|
fn from(body: BeaconBlockBodyGloas<E, BlindedPayload<E>>) -> Self {
|
||||||
|
let BeaconBlockBodyGloas {
|
||||||
|
randao_reveal,
|
||||||
|
eth1_data,
|
||||||
|
graffiti,
|
||||||
|
proposer_slashings,
|
||||||
|
attester_slashings,
|
||||||
|
attestations,
|
||||||
|
deposits,
|
||||||
|
voluntary_exits,
|
||||||
|
sync_aggregate,
|
||||||
|
bls_to_execution_changes,
|
||||||
|
signed_execution_payload_header,
|
||||||
|
payload_attestations,
|
||||||
|
_phantom,
|
||||||
|
} = body;
|
||||||
|
|
||||||
|
BeaconBlockBodyGloas {
|
||||||
|
randao_reveal,
|
||||||
|
eth1_data,
|
||||||
|
graffiti,
|
||||||
|
proposer_slashings,
|
||||||
|
attester_slashings,
|
||||||
|
attestations,
|
||||||
|
deposits,
|
||||||
|
voluntary_exits,
|
||||||
|
sync_aggregate,
|
||||||
|
bls_to_execution_changes,
|
||||||
|
signed_execution_payload_header,
|
||||||
|
payload_attestations,
|
||||||
|
_phantom: PhantomData,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Likewise bodies with payloads can be transformed into bodies without.
|
// Likewise bodies with payloads can be transformed into bodies without.
|
||||||
impl<E: EthSpec> From<BeaconBlockBodyBase<E, FullPayload<E>>>
|
impl<E: EthSpec> From<BeaconBlockBodyBase<E, FullPayload<E>>>
|
||||||
for (
|
for (
|
||||||
@@ -822,10 +870,10 @@ impl<E: EthSpec> From<BeaconBlockBodyGloas<E, FullPayload<E>>>
|
|||||||
deposits,
|
deposits,
|
||||||
voluntary_exits,
|
voluntary_exits,
|
||||||
sync_aggregate,
|
sync_aggregate,
|
||||||
execution_payload: FullPayloadGloas { execution_payload },
|
|
||||||
bls_to_execution_changes,
|
bls_to_execution_changes,
|
||||||
blob_kzg_commitments,
|
signed_execution_payload_header,
|
||||||
execution_requests,
|
payload_attestations,
|
||||||
|
_phantom,
|
||||||
} = body;
|
} = body;
|
||||||
|
|
||||||
(
|
(
|
||||||
@@ -839,14 +887,12 @@ impl<E: EthSpec> From<BeaconBlockBodyGloas<E, FullPayload<E>>>
|
|||||||
deposits,
|
deposits,
|
||||||
voluntary_exits,
|
voluntary_exits,
|
||||||
sync_aggregate,
|
sync_aggregate,
|
||||||
execution_payload: BlindedPayloadGloas {
|
|
||||||
execution_payload_header: From::from(&execution_payload),
|
|
||||||
},
|
|
||||||
bls_to_execution_changes,
|
bls_to_execution_changes,
|
||||||
blob_kzg_commitments: blob_kzg_commitments.clone(),
|
signed_execution_payload_header,
|
||||||
execution_requests,
|
payload_attestations,
|
||||||
|
_phantom: PhantomData,
|
||||||
},
|
},
|
||||||
Some(execution_payload),
|
None,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1046,39 +1092,8 @@ impl<E: EthSpec> BeaconBlockBodyFulu<E, FullPayload<E>> {
|
|||||||
|
|
||||||
impl<E: EthSpec> BeaconBlockBodyGloas<E, FullPayload<E>> {
|
impl<E: EthSpec> BeaconBlockBodyGloas<E, FullPayload<E>> {
|
||||||
pub fn clone_as_blinded(&self) -> BeaconBlockBodyGloas<E, BlindedPayload<E>> {
|
pub fn clone_as_blinded(&self) -> BeaconBlockBodyGloas<E, BlindedPayload<E>> {
|
||||||
let BeaconBlockBodyGloas {
|
let (block_body, _payload) = self.clone().into();
|
||||||
randao_reveal,
|
block_body
|
||||||
eth1_data,
|
|
||||||
graffiti,
|
|
||||||
proposer_slashings,
|
|
||||||
attester_slashings,
|
|
||||||
attestations,
|
|
||||||
deposits,
|
|
||||||
voluntary_exits,
|
|
||||||
sync_aggregate,
|
|
||||||
execution_payload: FullPayloadGloas { execution_payload },
|
|
||||||
bls_to_execution_changes,
|
|
||||||
blob_kzg_commitments,
|
|
||||||
execution_requests,
|
|
||||||
} = self;
|
|
||||||
|
|
||||||
BeaconBlockBodyGloas {
|
|
||||||
randao_reveal: randao_reveal.clone(),
|
|
||||||
eth1_data: eth1_data.clone(),
|
|
||||||
graffiti: *graffiti,
|
|
||||||
proposer_slashings: proposer_slashings.clone(),
|
|
||||||
attester_slashings: attester_slashings.clone(),
|
|
||||||
attestations: attestations.clone(),
|
|
||||||
deposits: deposits.clone(),
|
|
||||||
voluntary_exits: voluntary_exits.clone(),
|
|
||||||
sync_aggregate: sync_aggregate.clone(),
|
|
||||||
execution_payload: BlindedPayloadGloas {
|
|
||||||
execution_payload_header: execution_payload.into(),
|
|
||||||
},
|
|
||||||
bls_to_execution_changes: bls_to_execution_changes.clone(),
|
|
||||||
blob_kzg_commitments: blob_kzg_commitments.clone(),
|
|
||||||
execution_requests: execution_requests.clone(),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ use merkle_proof::MerkleTree;
|
|||||||
use serde::{Deserialize, Deserializer, Serialize};
|
use serde::{Deserialize, Deserializer, Serialize};
|
||||||
use ssz_derive::{Decode, Encode};
|
use ssz_derive::{Decode, Encode};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
use std::marker::PhantomData;
|
||||||
use superstruct::superstruct;
|
use superstruct::superstruct;
|
||||||
use test_random_derive::TestRandom;
|
use test_random_derive::TestRandom;
|
||||||
use tree_hash::TreeHash;
|
use tree_hash::TreeHash;
|
||||||
@@ -648,10 +649,11 @@ impl<E: EthSpec> SignedBeaconBlockFulu<E, BlindedPayload<E>> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Gloas doesn't support BlindedPayload, but we keep this impl for compatibility purposes of the SignedBeaconBlock type
|
||||||
impl<E: EthSpec> SignedBeaconBlockGloas<E, BlindedPayload<E>> {
|
impl<E: EthSpec> SignedBeaconBlockGloas<E, BlindedPayload<E>> {
|
||||||
pub fn into_full_block(
|
pub fn into_full_block(
|
||||||
self,
|
self,
|
||||||
execution_payload: ExecutionPayloadGloas<E>,
|
_execution_payload: ExecutionPayloadGloas<E>,
|
||||||
) -> SignedBeaconBlockGloas<E, FullPayload<E>> {
|
) -> SignedBeaconBlockGloas<E, FullPayload<E>> {
|
||||||
let SignedBeaconBlockGloas {
|
let SignedBeaconBlockGloas {
|
||||||
message:
|
message:
|
||||||
@@ -671,10 +673,10 @@ impl<E: EthSpec> SignedBeaconBlockGloas<E, BlindedPayload<E>> {
|
|||||||
deposits,
|
deposits,
|
||||||
voluntary_exits,
|
voluntary_exits,
|
||||||
sync_aggregate,
|
sync_aggregate,
|
||||||
execution_payload: BlindedPayloadGloas { .. },
|
|
||||||
bls_to_execution_changes,
|
bls_to_execution_changes,
|
||||||
blob_kzg_commitments,
|
signed_execution_payload_header,
|
||||||
execution_requests,
|
payload_attestations,
|
||||||
|
..
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
signature,
|
signature,
|
||||||
@@ -695,10 +697,10 @@ impl<E: EthSpec> SignedBeaconBlockGloas<E, BlindedPayload<E>> {
|
|||||||
deposits,
|
deposits,
|
||||||
voluntary_exits,
|
voluntary_exits,
|
||||||
sync_aggregate,
|
sync_aggregate,
|
||||||
execution_payload: FullPayloadGloas { execution_payload },
|
|
||||||
bls_to_execution_changes,
|
bls_to_execution_changes,
|
||||||
blob_kzg_commitments,
|
signed_execution_payload_header,
|
||||||
execution_requests,
|
payload_attestations,
|
||||||
|
_phantom: PhantomData,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
signature,
|
signature,
|
||||||
|
|||||||
Reference in New Issue
Block a user