Skip to content

Commit

Permalink
Use specific_variant_attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
macladson committed Jul 1, 2024
1 parent cbdcfeb commit 6113de7
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 18 deletions.
5 changes: 3 additions & 2 deletions consensus/types/src/attestation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,11 @@ pub struct Attestation<E: EthSpec> {
pub aggregation_bits: BitList<E::MaxValidatorsPerSlot>,
#[tree_hash(stable_index = 1)]
pub data: AttestationData,
#[superstruct(only(Electra))]
#[tree_hash(stable_index = 2)]
pub committee_bits: BitVector<E::MaxCommitteesPerSlot>,
pub signature: AggregateSignature,
#[superstruct(only(Electra))]
#[tree_hash(stable_index = 3)]
pub committee_bits: BitVector<E::MaxCommitteesPerSlot>,
}

impl<E: EthSpec> Hash for Attestation<E> {
Expand Down
34 changes: 20 additions & 14 deletions consensus/types/src/beacon_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,6 @@ impl From<BeaconStateHash> for Hash256 {
serde(bound = "E: EthSpec", deny_unknown_fields),
arbitrary(bound = "E: EthSpec"),
derivative(Clone),
tree_hash(struct_behaviour = "profile", max_fields = "typenum::U128"),
),
specific_variant_attributes(
Base(metastruct(
Expand Down Expand Up @@ -307,20 +306,27 @@ impl From<BeaconStateHash> for Hash256 {
)),
num_fields(all()),
)),
Electra(metastruct(
mappings(
map_beacon_state_electra_fields(),
map_beacon_state_electra_tree_list_fields(mutable, fallible, groups(tree_lists)),
map_beacon_state_electra_tree_list_fields_immutable(groups(tree_lists)),
Electra(
metastruct(
mappings(
map_beacon_state_electra_fields(),
map_beacon_state_electra_tree_list_fields(
mutable,
fallible,
groups(tree_lists)
),
map_beacon_state_electra_tree_list_fields_immutable(groups(tree_lists)),
),
bimappings(bimap_beacon_state_electra_tree_list_fields(
other_type = "BeaconStateElectra",
self_mutable,
fallible,
groups(tree_lists)
)),
num_fields(all()),
),
bimappings(bimap_beacon_state_electra_tree_list_fields(
other_type = "BeaconStateElectra",
self_mutable,
fallible,
groups(tree_lists)
)),
num_fields(all()),
))
tree_hash(struct_behaviour = "profile", max_fields = "typenum::U128")
),
),
cast_error(ty = "Error", expr = "Error::IncorrectStateVariant"),
partial_getter_error(ty = "Error", expr = "Error::IncorrectStateVariant"),
Expand Down
5 changes: 4 additions & 1 deletion consensus/types/src/execution_payload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@ pub type WithdrawalRequests<E> =
derivative(PartialEq, Hash(bound = "E: EthSpec")),
serde(bound = "E: EthSpec", deny_unknown_fields),
arbitrary(bound = "E: EthSpec"),
tree_hash(max_fields = "typenum::U64")
),
specific_variant_attributes(Electra(tree_hash(
struct_behaviour = "profile",
max_fields = "typenum::U64"
))),
cast_error(ty = "Error", expr = "BeaconStateError::IncorrectStateVariant"),
partial_getter_error(ty = "Error", expr = "BeaconStateError::IncorrectStateVariant"),
map_into(FullPayload, BlindedPayload),
Expand Down
5 changes: 4 additions & 1 deletion consensus/types/src/execution_payload_header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,11 @@ use tree_hash_derive::TreeHash;
derivative(PartialEq, Hash(bound = "E: EthSpec")),
serde(bound = "E: EthSpec", deny_unknown_fields),
arbitrary(bound = "E: EthSpec"),
tree_hash(max_fields = "typenum::U64")
),
specific_variant_attributes(Electra(tree_hash(
struct_behaviour = "profile",
max_fields = "typenum::U64"
))),
ref_attributes(
derive(PartialEq, TreeHash, Debug),
tree_hash(enum_behaviour = "transparent")
Expand Down

0 comments on commit 6113de7

Please sign in to comment.