Skip to content

Commit 794fcb3

Browse files
committed
Address First Round Comments
1 parent fd50ba6 commit 794fcb3

File tree

4 files changed

+10
-170
lines changed

4 files changed

+10
-170
lines changed

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/types/src/execution_payload_envelope.rs

Lines changed: 4 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -2,103 +2,32 @@ 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-
74-
impl<'de, E: EthSpec> ContextDeserialize<'de, ForkName> for ExecutionPayloadEnvelope<E> {
75-
fn context_deserialize<D>(deserializer: D, context: ForkName) -> Result<Self, D::Error>
76-
where
77-
D: Deserializer<'de>,
78-
{
79-
let value: Self = serde::Deserialize::deserialize(deserializer)?;
80-
81-
match (context, &value) {
82-
(ForkName::Gloas, Self::Gloas { .. }) => Ok(value),
83-
_ => Err(D::Error::custom(format!(
84-
"ExecutionPayloadEnvelope does not support fork {context:?}"
85-
))),
86-
}
87-
}
88-
}
8926

9027
#[cfg(test)]
9128
mod tests {
9229
use super::*;
9330
use crate::MainnetEthSpec;
9431

95-
mod gloas {
96-
use super::*;
97-
ssz_and_tree_hash_tests!(ExecutionPayloadEnvelopeGloas<MainnetEthSpec>);
98-
}
99-
100-
mod next_fork {
101-
use super::*;
102-
ssz_and_tree_hash_tests!(ExecutionPayloadEnvelopeNextFork<MainnetEthSpec>);
103-
}
32+
ssz_and_tree_hash_tests!(ExecutionPayloadEnvelope<MainnetEthSpec>);
10433
}

consensus/types/src/lib.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,10 +186,7 @@ pub use crate::execution_payload::{
186186
Transaction, Transactions, Withdrawals,
187187
};
188188
pub use crate::execution_payload_bid::ExecutionPayloadBid;
189-
pub use crate::execution_payload_envelope::{
190-
ExecutionPayloadEnvelope, ExecutionPayloadEnvelopeGloas, ExecutionPayloadEnvelopeNextFork,
191-
ExecutionPayloadEnvelopeRef,
192-
};
189+
pub use crate::execution_payload_envelope::ExecutionPayloadEnvelope;
193190
pub use crate::execution_payload_header::{
194191
ExecutionPayloadHeader, ExecutionPayloadHeaderBellatrix, ExecutionPayloadHeaderCapella,
195192
ExecutionPayloadHeaderDeneb, ExecutionPayloadHeaderElectra, ExecutionPayloadHeaderFulu,
Lines changed: 4 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -1,109 +1,23 @@
11
use crate::test_utils::TestRandom;
22
use crate::*;
33
use educe::Educe;
4-
use serde::de::{Deserializer, Error as _};
54
use serde::{Deserialize, Serialize};
65
use ssz_derive::{Decode, Encode};
7-
use superstruct::superstruct;
86
use test_random_derive::TestRandom;
97
use tree_hash_derive::TreeHash;
108

11-
#[superstruct(
12-
variants(Gloas, NextFork),
13-
variant_attributes(
14-
derive(
15-
Debug,
16-
Clone,
17-
Serialize,
18-
Deserialize,
19-
Encode,
20-
Decode,
21-
TreeHash,
22-
TestRandom,
23-
Educe
24-
),
25-
cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary)),
26-
educe(PartialEq, Hash(bound(E: EthSpec))),
27-
serde(bound = "E: EthSpec", deny_unknown_fields),
28-
cfg_attr(feature = "arbitrary", arbitrary(bound = "E: EthSpec"))
29-
),
30-
ref_attributes(
31-
derive(Debug, PartialEq, TreeHash),
32-
tree_hash(enum_behaviour = "transparent")
33-
),
34-
cast_error(ty = "Error", expr = "BeaconStateError::IncorrectStateVariant"),
35-
partial_getter_error(ty = "Error", expr = "BeaconStateError::IncorrectStateVariant")
36-
)]
37-
#[derive(Debug, Clone, Serialize, Encode, Deserialize, TreeHash, Educe)]
9+
#[derive(Debug, Clone, Serialize, Encode, Decode, Deserialize, TestRandom, TreeHash, Educe)]
3810
#[educe(PartialEq, Hash(bound(E: EthSpec)))]
39-
#[serde(bound = "E: EthSpec", untagged)]
40-
#[ssz(enum_behaviour = "transparent")]
41-
#[tree_hash(enum_behaviour = "transparent")]
11+
#[serde(bound = "E: EthSpec")]
4212
pub struct SignedExecutionPayloadEnvelope<E: EthSpec> {
43-
#[superstruct(only(Gloas), partial_getter(rename = "message_gloas"))]
44-
pub message: ExecutionPayloadEnvelopeGloas<E>,
45-
#[superstruct(only(NextFork), partial_getter(rename = "message_next_fork"))]
46-
pub message: crate::execution_payload_envelope::ExecutionPayloadEnvelopeNextFork<E>,
13+
pub message: ExecutionPayloadEnvelope<E>,
4714
pub signature: Signature,
4815
}
4916

50-
impl<E: EthSpec> SignedExecutionPayloadEnvelope<E> {
51-
/// Create a new `SignedExecutionPayloadEnvelope` from an `ExecutionPayloadEnvelope` and `Signature`.
52-
pub fn from_envelope(envelope: ExecutionPayloadEnvelope<E>, signature: Signature) -> Self {
53-
match envelope {
54-
ExecutionPayloadEnvelope::Gloas(message) => SignedExecutionPayloadEnvelope::Gloas(
55-
signed_execution_payload_envelope::SignedExecutionPayloadEnvelopeGloas {
56-
message,
57-
signature,
58-
},
59-
),
60-
ExecutionPayloadEnvelope::NextFork(message) => {
61-
SignedExecutionPayloadEnvelope::NextFork(
62-
signed_execution_payload_envelope::SignedExecutionPayloadEnvelopeNextFork {
63-
message,
64-
signature,
65-
},
66-
)
67-
}
68-
}
69-
}
70-
71-
pub fn message(&self) -> ExecutionPayloadEnvelopeRef<'_, E> {
72-
match self {
73-
Self::Gloas(signed) => ExecutionPayloadEnvelopeRef::Gloas(&signed.message),
74-
Self::NextFork(signed) => ExecutionPayloadEnvelopeRef::NextFork(&signed.message),
75-
}
76-
}
77-
}
78-
79-
impl<'de, E: EthSpec> ContextDeserialize<'de, ForkName> for SignedExecutionPayloadEnvelope<E> {
80-
fn context_deserialize<D>(deserializer: D, context: ForkName) -> Result<Self, D::Error>
81-
where
82-
D: Deserializer<'de>,
83-
{
84-
let value: Self = Deserialize::deserialize(deserializer)?;
85-
86-
match (context, &value) {
87-
(ForkName::Gloas, Self::Gloas { .. }) => Ok(value),
88-
_ => Err(D::Error::custom(format!(
89-
"SignedExecutionPayloadEnvelope does not support fork {context:?}"
90-
))),
91-
}
92-
}
93-
}
94-
9517
#[cfg(test)]
9618
mod tests {
9719
use super::*;
9820
use crate::MainnetEthSpec;
9921

100-
mod gloas {
101-
use super::*;
102-
ssz_and_tree_hash_tests!(SignedExecutionPayloadEnvelopeGloas<MainnetEthSpec>);
103-
}
104-
105-
mod next_fork {
106-
use super::*;
107-
ssz_and_tree_hash_tests!(SignedExecutionPayloadEnvelopeNextFork<MainnetEthSpec>);
108-
}
22+
ssz_and_tree_hash_tests!(SignedExecutionPayloadEnvelope<MainnetEthSpec>);
10923
}

0 commit comments

Comments
 (0)