Skip to content

Commit abf9a97

Browse files
committed
Merge branch 'gloas-containers' into gloas-envelope-processing
2 parents 80f77d8 + 794fcb3 commit abf9a97

File tree

8 files changed

+66
-227
lines changed

8 files changed

+66
-227
lines changed

beacon_node/beacon_chain/src/envelope_verification.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -216,9 +216,9 @@ impl<T: BeaconChainTypes> GossipVerifiedEnvelope<T> {
216216
signed_envelope: Arc<SignedExecutionPayloadEnvelope<T::EthSpec>>,
217217
chain: &BeaconChain<T>,
218218
) -> Result<Self, EnvelopeError> {
219-
let envelope = signed_envelope.message();
220-
let payload = envelope.payload();
221-
let beacon_block_root = envelope.beacon_block_root();
219+
let envelope = &signed_envelope.message;
220+
let payload = &envelope.payload;
221+
let beacon_block_root = envelope.beacon_block_root;
222222

223223
// check that we've seen the parent block of this envelope and that it passes validation
224224
// TODO(EIP-7732): this check would fail if the block didn't pass validation right?
@@ -255,26 +255,26 @@ impl<T: BeaconChainTypes> GossipVerifiedEnvelope<T> {
255255
// should these kinds of checks be included for envelopes as well?
256256

257257
// check that the slot of the envelope matches the slot of the parent block
258-
if envelope.slot() != parent_block.slot() {
258+
if envelope.slot != parent_block.slot() {
259259
return Err(EnvelopeError::SlotMismatch {
260260
parent_block: parent_block.slot(),
261-
envelope: envelope.slot(),
261+
envelope: envelope.slot,
262262
});
263263
}
264264

265265
// builder index matches committed bid
266-
if envelope.builder_index() != execution_bid.builder_index {
266+
if envelope.builder_index != execution_bid.builder_index {
267267
return Err(EnvelopeError::BuilderIndexMismatch {
268268
committed_bid: execution_bid.builder_index,
269-
envelope: envelope.builder_index(),
269+
envelope: envelope.builder_index,
270270
});
271271
}
272272

273273
// the block hash should match the block hash of the execution bid
274-
if payload.block_hash() != execution_bid.block_hash {
274+
if payload.block_hash != execution_bid.block_hash {
275275
return Err(EnvelopeError::BlockHashMismatch {
276276
committed_bid: execution_bid.block_hash,
277-
envelope: payload.block_hash(),
277+
envelope: payload.block_hash,
278278
});
279279
}
280280

@@ -283,7 +283,7 @@ impl<T: BeaconChainTypes> GossipVerifiedEnvelope<T> {
283283
// and so on.
284284

285285
// get the fork from the cache so we can verify the signature
286-
let block_slot = envelope.slot();
286+
let block_slot = envelope.slot;
287287
let block_epoch = block_slot.epoch(T::EthSpec::slots_per_epoch());
288288
let proposer_shuffling_decision_block =
289289
parent_proto_block.proposer_shuffling_root_for_child_block(block_epoch, &chain.spec);
@@ -311,9 +311,9 @@ impl<T: BeaconChainTypes> GossipVerifiedEnvelope<T> {
311311
let signature_is_valid = {
312312
let pubkey_cache = chain.validator_pubkey_cache.read();
313313
let builder_pubkey = pubkey_cache
314-
.get(envelope.builder_index() as usize)
314+
.get(envelope.builder_index as usize)
315315
.ok_or_else(|| EnvelopeError::UnknownValidator {
316-
builder_index: envelope.builder_index(),
316+
builder_index: envelope.builder_index,
317317
})?;
318318
signed_envelope.verify_signature(
319319
builder_pubkey,
@@ -360,13 +360,13 @@ impl<T: BeaconChainTypes> IntoExecutionPendingEnvelope<T> for GossipVerifiedEnve
360360
notify_execution_layer: NotifyExecutionLayer,
361361
) -> Result<ExecutionPendingEnvelope<T>, EnvelopeError> {
362362
let signed_envelope = self.signed_envelope;
363-
let envelope = signed_envelope.message();
364-
let payload = &envelope.payload();
363+
let envelope = &signed_envelope.message;
364+
let payload = &envelope.payload;
365365

366366
// Verify the execution payload is valid
367367
let payload_notifier =
368368
PayloadNotifier::from_envelope(chain.clone(), envelope, notify_execution_layer)?;
369-
let block_root = envelope.beacon_block_root();
369+
let block_root = envelope.beacon_block_root;
370370
let slot = self.parent_block.slot();
371371

372372
let payload_verification_future = async move {
@@ -417,7 +417,7 @@ impl<T: BeaconChainTypes> IntoExecutionPendingEnvelope<T> for GossipVerifiedEnve
417417

418418
Ok(ExecutionPendingEnvelope {
419419
signed_envelope: MaybeAvailableEnvelope::AvailabilityPending {
420-
block_hash: payload.block_hash(),
420+
block_hash: payload.block_hash,
421421
envelope: signed_envelope,
422422
},
423423
import_data: EnvelopeImportData {

beacon_node/beacon_chain/src/execution_payload.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ impl<T: BeaconChainTypes> PayloadNotifier<T> {
110110

111111
pub fn from_envelope(
112112
_chain: Arc<BeaconChain<T>>,
113-
_envelope: ExecutionPayloadEnvelopeRef<T::EthSpec>,
113+
_envelope: &ExecutionPayloadEnvelope<T::EthSpec>,
114114
_notify_execution_layer: NotifyExecutionLayer,
115115
) -> Result<Self, EnvelopeError> {
116116
todo!(

beacon_node/execution_layer/src/engine_api/new_payload_request.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ impl<'block, E: EthSpec> NewPayloadRequest<'block, E> {
172172
}
173173
}
174174

175-
//TODO(EIP7732): Consider implmenting these as methods on the NewPayloadRequest struct
175+
//TODO(EIP7732): Consider implementing these as methods on the NewPayloadRequest struct
176176
impl<'a, E: EthSpec> TryFrom<BeaconBlockRef<'a, E>> for NewPayloadRequest<'a, E> {
177177
type Error = BeaconStateError;
178178

consensus/state_processing/src/envelope_processing.rs

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,9 @@ pub fn envelope_processing<E: EthSpec>(
124124
}
125125
}
126126

127-
let envelope = signed_envelope.message();
128-
let payload = envelope.payload();
129-
let execution_requests = envelope.execution_requests();
127+
let envelope = &signed_envelope.message;
128+
let payload = &envelope.payload;
129+
let execution_requests = &envelope.execution_requests;
130130

131131
// Cache latest block header state root
132132
if state.latest_block_header().state_root == Hash256::default() {
@@ -138,92 +138,92 @@ pub fn envelope_processing<E: EthSpec>(
138138

139139
// Verify consistency with the beacon block
140140
envelope_verify!(
141-
envelope.beacon_block_root() == state.latest_block_header().tree_hash_root(),
141+
envelope.beacon_block_root == state.latest_block_header().tree_hash_root(),
142142
EnvelopeProcessingError::LatestBlockHeaderMismatch {
143-
envelope_root: envelope.beacon_block_root(),
143+
envelope_root: envelope.beacon_block_root,
144144
block_header_root: state.latest_block_header().tree_hash_root(),
145145
}
146146
);
147147
envelope_verify!(
148-
envelope.slot() == state.slot(),
148+
envelope.slot == state.slot(),
149149
EnvelopeProcessingError::SlotMismatch {
150-
envelope_slot: envelope.slot(),
150+
envelope_slot: envelope.slot,
151151
parent_state_slot: state.slot(),
152152
}
153153
);
154154

155155
// Verify consistency with the committed bid
156156
let committed_bid = state.latest_execution_payload_bid()?;
157157
// builder index match already verified
158-
if committed_bid.blob_kzg_commitments_root != envelope.blob_kzg_commitments().tree_hash_root() {
158+
if committed_bid.blob_kzg_commitments_root != envelope.blob_kzg_commitments.tree_hash_root() {
159159
return Err(EnvelopeProcessingError::BlobKzgCommitmentsRootMismatch {
160160
committed_bid: committed_bid.blob_kzg_commitments_root,
161-
envelope: envelope.blob_kzg_commitments().tree_hash_root(),
161+
envelope: envelope.blob_kzg_commitments.tree_hash_root(),
162162
});
163163
};
164164

165165
// Verify the withdrawals root
166166
envelope_verify!(
167-
payload.withdrawals()?.tree_hash_root() == *state.latest_withdrawals_root()?,
167+
payload.withdrawals.tree_hash_root() == *state.latest_withdrawals_root()?,
168168
EnvelopeProcessingError::WithdrawalsRootMismatch {
169169
state: *state.latest_withdrawals_root()?,
170-
envelope: payload.withdrawals()?.tree_hash_root(),
170+
envelope: payload.withdrawals.tree_hash_root(),
171171
}
172172
);
173173

174174
// Verify the gas limit
175175
envelope_verify!(
176-
payload.gas_limit() == committed_bid.gas_limit,
176+
payload.gas_limit == committed_bid.gas_limit,
177177
EnvelopeProcessingError::GasLimitMismatch {
178178
committed_bid: committed_bid.gas_limit,
179-
envelope: payload.gas_limit(),
179+
envelope: payload.gas_limit,
180180
}
181181
);
182182

183183
// Verify the block hash
184184
envelope_verify!(
185-
committed_bid.block_hash == payload.block_hash(),
185+
committed_bid.block_hash == payload.block_hash,
186186
EnvelopeProcessingError::BlockHashMismatch {
187187
committed_bid: committed_bid.block_hash,
188-
envelope: payload.block_hash(),
188+
envelope: payload.block_hash,
189189
}
190190
);
191191

192192
// Verify consistency of the parent hash with respect to the previous execution payload
193193
envelope_verify!(
194-
payload.parent_hash() == *state.latest_block_hash()?,
194+
payload.parent_hash == *state.latest_block_hash()?,
195195
EnvelopeProcessingError::ParentHashMismatch {
196196
state: *state.latest_block_hash()?,
197-
envelope: payload.parent_hash(),
197+
envelope: payload.parent_hash,
198198
}
199199
);
200200

201201
// Verify prev_randao
202202
envelope_verify!(
203-
payload.prev_randao() == *state.get_randao_mix(state.current_epoch())?,
203+
payload.prev_randao == *state.get_randao_mix(state.current_epoch())?,
204204
EnvelopeProcessingError::PrevRandaoMismatch {
205205
state: *state.get_randao_mix(state.current_epoch())?,
206-
envelope: payload.prev_randao(),
206+
envelope: payload.prev_randao,
207207
}
208208
);
209209

210210
// Verify the timestamp
211211
let state_timestamp = compute_timestamp_at_slot(state, state.slot(), spec)?;
212212
envelope_verify!(
213-
payload.timestamp() == state_timestamp,
213+
payload.timestamp == state_timestamp,
214214
EnvelopeProcessingError::TimestampMismatch {
215215
state: state_timestamp,
216-
envelope: payload.timestamp(),
216+
envelope: payload.timestamp,
217217
}
218218
);
219219

220220
// Verify the commitments are under limit
221221
let max_blobs = spec.max_blobs_per_block(state.current_epoch()) as usize;
222222
envelope_verify!(
223-
envelope.blob_kzg_commitments().len() <= max_blobs,
223+
envelope.blob_kzg_commitments.len() <= max_blobs,
224224
EnvelopeProcessingError::BlobLimitExceeded {
225225
max: max_blobs,
226-
envelope: envelope.blob_kzg_commitments().len(),
226+
envelope: envelope.blob_kzg_commitments.len(),
227227
}
228228
);
229229

@@ -269,14 +269,14 @@ pub fn envelope_processing<E: EthSpec>(
269269
.execution_payload_availability_mut()?
270270
.set(availability_index, true)
271271
.map_err(EnvelopeProcessingError::BitFieldError)?;
272-
*state.latest_block_hash_mut()? = payload.block_hash();
272+
*state.latest_block_hash_mut()? = payload.block_hash;
273273

274274
// verify the state root
275275
envelope_verify!(
276-
envelope.state_root() == state.canonical_root()?,
276+
envelope.state_root == state.canonical_root()?,
277277
EnvelopeProcessingError::InvalidStateRoot {
278278
state: state.canonical_root()?,
279-
envelope: envelope.state_root(),
279+
envelope: envelope.state_root,
280280
}
281281
);
282282

consensus/state_processing/src/per_block_processing/signature_sets.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -378,13 +378,13 @@ where
378378
&state.fork(),
379379
state.genesis_validators_root(),
380380
);
381-
let message = signed_envelope.message().signing_root(domain);
382-
let pubkey = get_pubkey(signed_envelope.message().builder_index() as usize).ok_or(
383-
Error::ValidatorUnknown(signed_envelope.message().builder_index()),
381+
let message = signed_envelope.message.signing_root(domain);
382+
let pubkey = get_pubkey(signed_envelope.message.builder_index as usize).ok_or(
383+
Error::ValidatorUnknown(signed_envelope.message.builder_index),
384384
)?;
385385

386386
Ok(SignatureSet::single_pubkey(
387-
signed_envelope.signature(),
387+
&signed_envelope.signature,
388388
pubkey,
389389
message,
390390
))

consensus/types/src/execution_payload_envelope.rs

Lines changed: 4 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -2,107 +2,33 @@ use crate::test_utils::TestRandom;
22
use crate::*;
33
use beacon_block_body::KzgCommitments;
44
use educe::Educe;
5-
use serde::de::{Deserializer, Error as _};
65
use serde::{Deserialize, Serialize};
76
use ssz_derive::{Decode, Encode};
8-
use superstruct::superstruct;
97
use test_random_derive::TestRandom;
108
use tree_hash_derive::TreeHash;
119

12-
// in all likelihood, this will be superstructed so might as well start early eh?
13-
#[superstruct(
14-
variants(Gloas, NextFork),
15-
variant_attributes(
16-
derive(
17-
Debug,
18-
Clone,
19-
Serialize,
20-
Deserialize,
21-
Encode,
22-
Decode,
23-
TreeHash,
24-
TestRandom,
25-
Educe
26-
),
27-
cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary)),
28-
educe(PartialEq, Hash(bound(E: EthSpec))),
29-
serde(bound = "E: EthSpec", deny_unknown_fields),
30-
cfg_attr(feature = "arbitrary", arbitrary(bound = "E: EthSpec"))
31-
),
32-
ref_attributes(
33-
derive(Debug, PartialEq, TreeHash),
34-
tree_hash(enum_behaviour = "transparent")
35-
),
36-
cast_error(ty = "Error", expr = "BeaconStateError::IncorrectStateVariant"),
37-
partial_getter_error(ty = "Error", expr = "BeaconStateError::IncorrectStateVariant")
38-
)]
39-
#[derive(Debug, Clone, Serialize, Encode, Deserialize, TreeHash, Educe)]
10+
#[derive(Debug, Clone, Serialize, Encode, Decode, Deserialize, TestRandom, TreeHash, Educe)]
4011
#[educe(PartialEq, Hash(bound(E: EthSpec)))]
41-
#[serde(bound = "E: EthSpec", untagged)]
42-
#[ssz(enum_behaviour = "transparent")]
43-
#[tree_hash(enum_behaviour = "transparent")]
12+
#[context_deserialize(ForkName)]
13+
#[serde(bound = "E: EthSpec")]
4414
pub struct ExecutionPayloadEnvelope<E: EthSpec> {
45-
#[superstruct(only(Gloas), partial_getter(rename = "payload_gloas"))]
46-
pub payload: ExecutionPayloadGloas<E>,
47-
#[superstruct(only(NextFork), partial_getter(rename = "payload_next_fork"))]
4815
pub payload: ExecutionPayloadGloas<E>,
4916
pub execution_requests: ExecutionRequests<E>,
5017
#[serde(with = "serde_utils::quoted_u64")]
51-
#[superstruct(getter(copy))]
5218
pub builder_index: u64,
53-
#[superstruct(getter(copy))]
5419
pub beacon_block_root: Hash256,
55-
#[superstruct(getter(copy))]
5620
pub slot: Slot,
5721
pub blob_kzg_commitments: KzgCommitments<E>,
58-
#[superstruct(getter(copy))]
5922
pub state_root: Hash256,
6023
}
6124

6225
impl<E: EthSpec> SignedRoot for ExecutionPayloadEnvelope<E> {}
63-
impl<'a, E: EthSpec> SignedRoot for ExecutionPayloadEnvelopeRef<'a, E> {}
64-
65-
impl<'a, E: EthSpec> ExecutionPayloadEnvelopeRef<'a, E> {
66-
pub fn payload(&self) -> ExecutionPayloadRef<'a, E> {
67-
match self {
68-
Self::Gloas(envelope) => ExecutionPayloadRef::Gloas(&envelope.payload),
69-
Self::NextFork(envelope) => ExecutionPayloadRef::Gloas(&envelope.payload),
70-
}
71-
}
72-
73-
pub fn block_hash(&self) -> ExecutionBlockHash {
74-
self.payload().block_hash()
75-
}
76-
}
7726

78-
impl<'de, E: EthSpec> ContextDeserialize<'de, ForkName> for ExecutionPayloadEnvelope<E> {
79-
fn context_deserialize<D>(deserializer: D, context: ForkName) -> Result<Self, D::Error>
80-
where
81-
D: Deserializer<'de>,
82-
{
83-
let value: Self = serde::Deserialize::deserialize(deserializer)?;
84-
85-
match (context, &value) {
86-
(ForkName::Gloas, Self::Gloas { .. }) => Ok(value),
87-
_ => Err(D::Error::custom(format!(
88-
"ExecutionPayloadEnvelope does not support fork {context:?}"
89-
))),
90-
}
91-
}
92-
}
9327

9428
#[cfg(test)]
9529
mod tests {
9630
use super::*;
9731
use crate::MainnetEthSpec;
9832

99-
mod gloas {
100-
use super::*;
101-
ssz_and_tree_hash_tests!(ExecutionPayloadEnvelopeGloas<MainnetEthSpec>);
102-
}
103-
104-
mod next_fork {
105-
use super::*;
106-
ssz_and_tree_hash_tests!(ExecutionPayloadEnvelopeNextFork<MainnetEthSpec>);
107-
}
33+
ssz_and_tree_hash_tests!(ExecutionPayloadEnvelope<MainnetEthSpec>);
10834
}

consensus/types/src/lib.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,7 @@ pub use crate::execution_payload::{
187187
Transaction, Transactions, Withdrawals,
188188
};
189189
pub use crate::execution_payload_bid::ExecutionPayloadBid;
190-
pub use crate::execution_payload_envelope::{
191-
ExecutionPayloadEnvelope, ExecutionPayloadEnvelopeGloas, ExecutionPayloadEnvelopeNextFork,
192-
ExecutionPayloadEnvelopeRef,
193-
};
190+
pub use crate::execution_payload_envelope::ExecutionPayloadEnvelope;
194191
pub use crate::execution_payload_header::{
195192
ExecutionPayloadHeader, ExecutionPayloadHeaderBellatrix, ExecutionPayloadHeaderCapella,
196193
ExecutionPayloadHeaderDeneb, ExecutionPayloadHeaderElectra, ExecutionPayloadHeaderFulu,

0 commit comments

Comments
 (0)