diff --git a/beacon_node/beacon_chain/src/block_production/gloas.rs b/beacon_node/beacon_chain/src/block_production/gloas.rs index 34571df7a9..d52f5c5177 100644 --- a/beacon_node/beacon_chain/src/block_production/gloas.rs +++ b/beacon_node/beacon_chain/src/block_production/gloas.rs @@ -31,11 +31,10 @@ use types::{ Address, Attestation, AttestationElectra, AttesterSlashing, AttesterSlashingElectra, BeaconBlock, BeaconBlockBodyGloas, BeaconBlockGloas, BeaconState, BeaconStateError, BuilderIndex, ChainSpec, Deposit, Eth1Data, EthSpec, ExecutionBlockHash, ExecutionPayloadBid, - ExecutionPayloadEnvelope, ExecutionPayloadGloas, ExecutionRequests, ExecutionRequestsGloas, - FullPayload, Graffiti, Hash256, PayloadAttestation, ProposerSlashing, RelativeEpoch, - SignedBeaconBlock, SignedBlsToExecutionChange, SignedExecutionPayloadBid, - SignedExecutionPayloadEnvelope, SignedVoluntaryExit, Slot, SyncAggregate, Withdrawal, - Withdrawals, + ExecutionPayloadEnvelope, ExecutionPayloadGloas, ExecutionRequestsGloas, FullPayload, Graffiti, + Hash256, PayloadAttestation, ProposerSlashing, RelativeEpoch, SignedBeaconBlock, + SignedBlsToExecutionChange, SignedExecutionPayloadBid, SignedExecutionPayloadEnvelope, + SignedVoluntaryExit, Slot, SyncAggregate, Withdrawal, Withdrawals, }; use crate::pending_payload_envelopes::PendingEnvelopeData; @@ -810,11 +809,6 @@ impl BeaconChain { should_override_builder, } = block_proposal_contents; - // The EL get_payload response carries the standard (Electra-shaped) requests; lift them - // into the Gloas variant carried by the envelope and committed to by the bid. - // TODO(gloas): plumb builder deposit/exit requests from the EL. - let execution_requests = to_gloas_execution_requests(execution_requests); - // TODO(gloas) since we are defaulting to local building, execution payment is 0 // execution payment should only be set to > 0 for trusted building. let bid = ExecutionPayloadBid:: { @@ -1106,33 +1100,6 @@ where Ok(block_contents) } -/// Drop voluntary exits whose target validators will be exited by the parent envelope's -/// execution requests. -/// -/// In Gloas the parent execution payload is processed before voluntary exits during block -/// processing. EL-triggered withdrawal-full-exit requests (EIP-7002) and cross-pubkey -/// consolidation requests (EIP-7251) call `initiate_validator_exit`, setting the target's -/// `exit_epoch`. A voluntary exit for the same validator would then fail with `AlreadyExited`. -/// Lift a fork-agnostic `ExecutionRequests` (as received from the EL) into the Gloas variant. -/// -/// The standard request types are carried over; the Gloas-only builder deposit/exit lists are -/// left empty. -/// TODO(gloas): plumb builder deposit/exit requests from the EL. -fn to_gloas_execution_requests( - requests: ExecutionRequests, -) -> ExecutionRequestsGloas { - match requests { - ExecutionRequests::Gloas(requests) => requests, - other => ExecutionRequestsGloas { - deposits: other.deposits().clone(), - withdrawals: other.withdrawals().clone(), - consolidations: other.consolidations().clone(), - builder_deposits: <_>::default(), - builder_exits: <_>::default(), - }, - } -} - fn filter_voluntary_exits_for_parent_execution_requests( voluntary_exits: &mut Vec, parent_execution_requests: &ExecutionRequestsGloas, diff --git a/beacon_node/execution_layer/src/engine_api.rs b/beacon_node/execution_layer/src/engine_api.rs index 079a82ff98..9f32bfdfeb 100644 --- a/beacon_node/execution_layer/src/engine_api.rs +++ b/beacon_node/execution_layer/src/engine_api.rs @@ -341,8 +341,13 @@ pub struct GetPayloadResponse { pub blobs_bundle: BlobsBundle, #[superstruct(only(Deneb, Electra, Fulu, Gloas), partial_getter(copy))] pub should_override_builder: bool, - #[superstruct(only(Electra, Fulu, Gloas))] - pub requests: ExecutionRequests, + #[superstruct( + only(Electra, Fulu), + partial_getter(rename = "execution_requests_electra") + )] + pub requests: types::ExecutionRequestsElectra, + #[superstruct(only(Gloas), partial_getter(rename = "execution_requests_gloas"))] + pub requests: types::ExecutionRequestsGloas, } impl GetPayloadResponse { @@ -407,19 +412,19 @@ impl From> ExecutionPayload::Electra(inner.execution_payload), inner.block_value, Some(inner.blobs_bundle), - Some(inner.requests), + Some(ExecutionRequests::Electra(inner.requests)), ), GetPayloadResponse::Fulu(inner) => ( ExecutionPayload::Fulu(inner.execution_payload), inner.block_value, Some(inner.blobs_bundle), - Some(inner.requests), + Some(ExecutionRequests::Electra(inner.requests)), ), GetPayloadResponse::Gloas(inner) => ( ExecutionPayload::Gloas(inner.execution_payload), inner.block_value, Some(inner.blobs_bundle), - Some(inner.requests), + Some(ExecutionRequests::Gloas(inner.requests)), ), } } diff --git a/beacon_node/execution_layer/src/engine_api/json_structures.rs b/beacon_node/execution_layer/src/engine_api/json_structures.rs index 453e4d11be..4071245166 100644 --- a/beacon_node/execution_layer/src/engine_api/json_structures.rs +++ b/beacon_node/execution_layer/src/engine_api/json_structures.rs @@ -474,6 +474,7 @@ pub enum RequestsError { InvalidOrdering, InvalidPrefix(u8), DecodeError(String), + VariantMismatch, } /// Format of `ExecutionRequests` received over the engine api. @@ -606,6 +607,28 @@ impl TryFrom for ExecutionRequests { } } +impl TryFrom for ExecutionRequestsElectra { + type Error = RequestsError; + + fn try_from(value: JsonExecutionRequests) -> Result { + match ExecutionRequests::::try_from(value)? { + ExecutionRequests::Electra(requests) => Ok(requests), + ExecutionRequests::Gloas(_) => Err(RequestsError::VariantMismatch), + } + } +} + +impl TryFrom for ExecutionRequestsGloas { + type Error = RequestsError; + + fn try_from(value: JsonExecutionRequests) -> Result { + match ExecutionRequests::::try_from(value)? { + ExecutionRequests::Gloas(requests) => Ok(requests), + ExecutionRequests::Electra(_) => Err(RequestsError::VariantMismatch), + } + } +} + #[superstruct( variants(Bellatrix, Capella, Deneb, Electra, Fulu, Gloas), variant_attributes( diff --git a/beacon_node/execution_layer/src/lib.rs b/beacon_node/execution_layer/src/lib.rs index a392d21e2e..b255e1b75d 100644 --- a/beacon_node/execution_layer/src/lib.rs +++ b/beacon_node/execution_layer/src/lib.rs @@ -43,7 +43,6 @@ use tokio::{ use tokio_stream::wrappers::WatchStream; use tracing::{Instrument, debug, debug_span, error, info, instrument, warn}; use tree_hash::TreeHash; -use types::ExecutionPayloadGloas; use types::builder::BuilderBid; use types::execution::BlockProductionVersion; use types::kzg_ext::KzgCommitments; @@ -56,6 +55,7 @@ use types::{ ExecutionPayloadCapella, ExecutionPayloadElectra, ExecutionPayloadFulu, FullPayload, ProposerPreparationData, Slot, }; +use types::{ExecutionPayloadGloas, ExecutionRequestsGloas}; mod block_hash; mod engine_api; @@ -206,7 +206,7 @@ pub struct BlockProposalContentsGloas { pub payload_value: Uint256, pub blob_kzg_commitments: KzgCommitments, pub blobs_and_proofs: (BlobsList, KzgProofs), - pub execution_requests: ExecutionRequests, + pub execution_requests: ExecutionRequestsGloas, pub should_override_builder: bool, }