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 Jun 28, 2024
1 parent 2eab4b5 commit 4d26ef8
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 24 deletions.
8 changes: 4 additions & 4 deletions consensus/types/src/attestation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ pub enum Error {
#[derivative(PartialEq, Hash(bound = "E: EthSpec"))]
#[serde(bound = "E: EthSpec")]
#[arbitrary(bound = "E: EthSpec")]
#[tree_hash(struct_behaviour = "profile", max_fields = "typenum::U8")]
//#[tree_hash(struct_behaviour = "profile", max_fields = "typenum::U8")]
pub struct Attestation<E: EthSpec> {
#[tree_hash(stable_index = 0)]
//#[tree_hash(stable_index = 0)]
pub aggregation_bits: BitList<E::MaxValidatorsPerCommittee>,
#[tree_hash(stable_index = 1)]
//#[tree_hash(stable_index = 1)]
pub data: AttestationData,
#[tree_hash(stable_index = 2)]
//#[tree_hash(stable_index = 2)]
pub signature: AggregateSignature,
}

Expand Down
6 changes: 3 additions & 3 deletions consensus/types/src/attester_slashing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ use tree_hash_derive::TreeHash;
#[derivative(PartialEq, Eq, Hash(bound = "E: EthSpec"))]
#[serde(bound = "E: EthSpec")]
#[arbitrary(bound = "E: EthSpec")]
#[tree_hash(struct_behaviour = "profile", max_fields = "typenum::U8")]
//#[tree_hash(struct_behaviour = "profile", max_fields = "typenum::U8")]
pub struct AttesterSlashing<E: EthSpec> {
#[tree_hash(stable_index = 0)]
//#[tree_hash(stable_index = 0)]
pub attestation_1: IndexedAttestation<E>,
#[tree_hash(stable_index = 1)]
//#[tree_hash(stable_index = 1)]
pub attestation_2: IndexedAttestation<E>,
}

Expand Down
5 changes: 4 additions & 1 deletion consensus/types/src/beacon_block_body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,11 @@ pub const BLOB_KZG_COMMITMENTS_INDEX: usize = 11;
deny_unknown_fields
),
arbitrary(bound = "E: EthSpec, Payload: AbstractExecPayload<E>"),
tree_hash(struct_behaviour = "profile", max_fields = "typenum::U64"),
),
specific_variant_attributes(tree_hash(
struct_behaviour = "profile",
max_fields = "typenum::U64"
)),
cast_error(ty = "Error", expr = "Error::IncorrectStateVariant"),
partial_getter_error(ty = "Error", expr = "Error::IncorrectStateVariant")
)]
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 @@ -224,7 +224,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 @@ -297,20 +296,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 @@ -33,8 +33,11 @@ pub type Withdrawals<E> = VariableList<Withdrawal, <E as EthSpec>::MaxWithdrawal
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 4d26ef8

Please sign in to comment.