Skip to content

Commit c110da4

Browse files
committed
Use specific_variant_attributes
1 parent d8a4831 commit c110da4

File tree

4 files changed

+31
-18
lines changed

4 files changed

+31
-18
lines changed

consensus/types/src/attestation.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,11 @@ pub struct Attestation<E: EthSpec> {
7878
pub aggregation_bits: BitList<E::MaxValidatorsPerSlot>,
7979
#[tree_hash(stable_index = 1)]
8080
pub data: AttestationData,
81-
#[superstruct(only(Electra))]
8281
#[tree_hash(stable_index = 2)]
83-
pub committee_bits: BitVector<E::MaxCommitteesPerSlot>,
8482
pub signature: AggregateSignature,
83+
#[superstruct(only(Electra))]
84+
#[tree_hash(stable_index = 3)]
85+
pub committee_bits: BitVector<E::MaxCommitteesPerSlot>,
8586
}
8687

8788
impl<E: EthSpec> Hash for Attestation<E> {

consensus/types/src/beacon_state.rs

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,6 @@ impl From<BeaconStateHash> for Hash256 {
234234
serde(bound = "E: EthSpec", deny_unknown_fields),
235235
arbitrary(bound = "E: EthSpec"),
236236
derivative(Clone),
237-
tree_hash(struct_behaviour = "profile", max_fields = "typenum::U128"),
238237
),
239238
specific_variant_attributes(
240239
Base(metastruct(
@@ -307,20 +306,27 @@ impl From<BeaconStateHash> for Hash256 {
307306
)),
308307
num_fields(all()),
309308
)),
310-
Electra(metastruct(
311-
mappings(
312-
map_beacon_state_electra_fields(),
313-
map_beacon_state_electra_tree_list_fields(mutable, fallible, groups(tree_lists)),
314-
map_beacon_state_electra_tree_list_fields_immutable(groups(tree_lists)),
309+
Electra(
310+
metastruct(
311+
mappings(
312+
map_beacon_state_electra_fields(),
313+
map_beacon_state_electra_tree_list_fields(
314+
mutable,
315+
fallible,
316+
groups(tree_lists)
317+
),
318+
map_beacon_state_electra_tree_list_fields_immutable(groups(tree_lists)),
319+
),
320+
bimappings(bimap_beacon_state_electra_tree_list_fields(
321+
other_type = "BeaconStateElectra",
322+
self_mutable,
323+
fallible,
324+
groups(tree_lists)
325+
)),
326+
num_fields(all()),
315327
),
316-
bimappings(bimap_beacon_state_electra_tree_list_fields(
317-
other_type = "BeaconStateElectra",
318-
self_mutable,
319-
fallible,
320-
groups(tree_lists)
321-
)),
322-
num_fields(all()),
323-
))
328+
tree_hash(struct_behaviour = "profile", max_fields = "typenum::U128")
329+
),
324330
),
325331
cast_error(ty = "Error", expr = "Error::IncorrectStateVariant"),
326332
partial_getter_error(ty = "Error", expr = "Error::IncorrectStateVariant"),

consensus/types/src/execution_payload.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,11 @@ pub type Withdrawals<E> = VariableList<Withdrawal, <E as EthSpec>::MaxWithdrawal
3333
derivative(PartialEq, Hash(bound = "E: EthSpec")),
3434
serde(bound = "E: EthSpec", deny_unknown_fields),
3535
arbitrary(bound = "E: EthSpec"),
36-
tree_hash(max_fields = "typenum::U64")
3736
),
37+
specific_variant_attributes(Electra(tree_hash(
38+
struct_behaviour = "profile",
39+
max_fields = "typenum::U64"
40+
))),
3841
cast_error(ty = "Error", expr = "BeaconStateError::IncorrectStateVariant"),
3942
partial_getter_error(ty = "Error", expr = "BeaconStateError::IncorrectStateVariant"),
4043
map_into(FullPayload, BlindedPayload),

consensus/types/src/execution_payload_header.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,11 @@ use tree_hash_derive::TreeHash;
2626
derivative(PartialEq, Hash(bound = "E: EthSpec")),
2727
serde(bound = "E: EthSpec", deny_unknown_fields),
2828
arbitrary(bound = "E: EthSpec"),
29-
tree_hash(max_fields = "typenum::U64")
3029
),
30+
specific_variant_attributes(Electra(tree_hash(
31+
struct_behaviour = "profile",
32+
max_fields = "typenum::U64"
33+
))),
3134
ref_attributes(
3235
derive(PartialEq, TreeHash, Debug),
3336
tree_hash(enum_behaviour = "transparent")

0 commit comments

Comments
 (0)