@@ -329,7 +329,7 @@ pub trait VerifiedAttestation<T: BeaconChainTypes>: Sized {
329
329
// Inefficient default implementation. This is overridden for gossip verified attestations.
330
330
fn into_attestation_and_indices ( self ) -> ( Attestation < T :: EthSpec > , Vec < u64 > ) {
331
331
let attestation = self . attestation ( ) . clone ( ) ;
332
- let attesting_indices = self . indexed_attestation ( ) . attesting_indices . clone ( ) . into ( ) ;
332
+ let attesting_indices = self . indexed_attestation ( ) . attesting_indices_to_vec ( ) ;
333
333
( attestation, attesting_indices)
334
334
}
335
335
}
@@ -455,17 +455,17 @@ impl<'a, T: BeaconChainTypes> IndexedAggregatedAttestation<'a, T> {
455
455
verify_propagation_slot_range ( & chain. slot_clock , attestation, & chain. spec ) ?;
456
456
457
457
// Check the attestation's epoch matches its target.
458
- if attestation. data . slot . epoch ( T :: EthSpec :: slots_per_epoch ( ) )
459
- != attestation. data . target . epoch
458
+ if attestation. data ( ) . slot . epoch ( T :: EthSpec :: slots_per_epoch ( ) )
459
+ != attestation. data ( ) . target . epoch
460
460
{
461
461
return Err ( Error :: InvalidTargetEpoch {
462
- slot : attestation. data . slot ,
463
- epoch : attestation. data . target . epoch ,
462
+ slot : attestation. data ( ) . slot ,
463
+ epoch : attestation. data ( ) . target . epoch ,
464
464
} ) ;
465
465
}
466
466
467
467
// Ensure the valid aggregated attestation has not already been seen locally.
468
- let attestation_data = & attestation. data ;
468
+ let attestation_data = attestation. data ( ) ;
469
469
let attestation_data_root = attestation_data. tree_hash_root ( ) ;
470
470
471
471
if chain
@@ -486,7 +486,7 @@ impl<'a, T: BeaconChainTypes> IndexedAggregatedAttestation<'a, T> {
486
486
match chain
487
487
. observed_aggregators
488
488
. read ( )
489
- . validator_has_been_observed ( attestation. data . target . epoch , aggregator_index as usize )
489
+ . validator_has_been_observed ( attestation. data ( ) . target . epoch , aggregator_index as usize )
490
490
{
491
491
Ok ( true ) => Err ( Error :: AggregatorAlreadyKnown ( aggregator_index) ) ,
492
492
Ok ( false ) => Ok ( ( ) ) ,
@@ -518,7 +518,7 @@ impl<'a, T: BeaconChainTypes> IndexedAggregatedAttestation<'a, T> {
518
518
verify_attestation_target_root :: < T :: EthSpec > ( & head_block, attestation) ?;
519
519
520
520
// Ensure that the attestation has participants.
521
- if attestation. aggregation_bits . is_zero ( ) {
521
+ if attestation. is_aggregation_bits_zero ( ) {
522
522
Err ( Error :: EmptyAggregationBitfield )
523
523
} else {
524
524
Ok ( attestation_data_root)
@@ -611,12 +611,12 @@ impl<'a, T: BeaconChainTypes> VerifiedAggregatedAttestation<'a, T> {
611
611
if chain
612
612
. observed_aggregators
613
613
. write ( )
614
- . observe_validator ( attestation. data . target . epoch , aggregator_index as usize )
614
+ . observe_validator ( attestation. data ( ) . target . epoch , aggregator_index as usize )
615
615
. map_err ( BeaconChainError :: from) ?
616
616
{
617
617
return Err ( Error :: PriorAttestationKnown {
618
618
validator_index : aggregator_index,
619
- epoch : attestation. data . target . epoch ,
619
+ epoch : attestation. data ( ) . target . epoch ,
620
620
} ) ;
621
621
}
622
622
@@ -712,13 +712,13 @@ impl<'a, T: BeaconChainTypes> IndexedUnaggregatedAttestation<'a, T> {
712
712
attestation : & Attestation < T :: EthSpec > ,
713
713
chain : & BeaconChain < T > ,
714
714
) -> Result < ( ) , Error > {
715
- let attestation_epoch = attestation. data . slot . epoch ( T :: EthSpec :: slots_per_epoch ( ) ) ;
715
+ let attestation_epoch = attestation. data ( ) . slot . epoch ( T :: EthSpec :: slots_per_epoch ( ) ) ;
716
716
717
717
// Check the attestation's epoch matches its target.
718
- if attestation_epoch != attestation. data . target . epoch {
718
+ if attestation_epoch != attestation. data ( ) . target . epoch {
719
719
return Err ( Error :: InvalidTargetEpoch {
720
- slot : attestation. data . slot ,
721
- epoch : attestation. data . target . epoch ,
720
+ slot : attestation. data ( ) . slot ,
721
+ epoch : attestation. data ( ) . target . epoch ,
722
722
} ) ;
723
723
}
724
724
@@ -730,7 +730,7 @@ impl<'a, T: BeaconChainTypes> IndexedUnaggregatedAttestation<'a, T> {
730
730
731
731
// Check to ensure that the attestation is "unaggregated". I.e., it has exactly one
732
732
// aggregation bit set.
733
- let num_aggregation_bits = attestation. aggregation_bits . num_set_bits ( ) ;
733
+ let num_aggregation_bits = attestation. num_set_aggregation_bits ( ) ;
734
734
if num_aggregation_bits != 1 {
735
735
return Err ( Error :: NotExactlyOneAggregationBitSet ( num_aggregation_bits) ) ;
736
736
}
@@ -757,7 +757,7 @@ impl<'a, T: BeaconChainTypes> IndexedUnaggregatedAttestation<'a, T> {
757
757
chain : & BeaconChain < T > ,
758
758
) -> Result < ( u64 , SubnetId ) , Error > {
759
759
let expected_subnet_id = SubnetId :: compute_subnet_for_attestation_data :: < T :: EthSpec > (
760
- & indexed_attestation. data ,
760
+ indexed_attestation. data ( ) ,
761
761
committees_per_slot,
762
762
& chain. spec ,
763
763
)
@@ -774,8 +774,7 @@ impl<'a, T: BeaconChainTypes> IndexedUnaggregatedAttestation<'a, T> {
774
774
} ;
775
775
776
776
let validator_index = * indexed_attestation
777
- . attesting_indices
778
- . first ( )
777
+ . attesting_indices_first ( )
779
778
. ok_or ( Error :: NotExactlyOneAggregationBitSet ( 0 ) ) ?;
780
779
781
780
/*
@@ -785,12 +784,12 @@ impl<'a, T: BeaconChainTypes> IndexedUnaggregatedAttestation<'a, T> {
785
784
if chain
786
785
. observed_gossip_attesters
787
786
. read ( )
788
- . validator_has_been_observed ( attestation. data . target . epoch , validator_index as usize )
787
+ . validator_has_been_observed ( attestation. data ( ) . target . epoch , validator_index as usize )
789
788
. map_err ( BeaconChainError :: from) ?
790
789
{
791
790
return Err ( Error :: PriorAttestationKnown {
792
791
validator_index,
793
- epoch : attestation. data . target . epoch ,
792
+ epoch : attestation. data ( ) . target . epoch ,
794
793
} ) ;
795
794
}
796
795
@@ -881,12 +880,12 @@ impl<'a, T: BeaconChainTypes> VerifiedUnaggregatedAttestation<'a, T> {
881
880
if chain
882
881
. observed_gossip_attesters
883
882
. write ( )
884
- . observe_validator ( attestation. data . target . epoch , validator_index as usize )
883
+ . observe_validator ( attestation. data ( ) . target . epoch , validator_index as usize )
885
884
. map_err ( BeaconChainError :: from) ?
886
885
{
887
886
return Err ( Error :: PriorAttestationKnown {
888
887
validator_index,
889
- epoch : attestation. data . target . epoch ,
888
+ epoch : attestation. data ( ) . target . epoch ,
890
889
} ) ;
891
890
}
892
891
Ok ( ( ) )
@@ -998,28 +997,28 @@ fn verify_head_block_is_known<T: BeaconChainTypes>(
998
997
let block_opt = chain
999
998
. canonical_head
1000
999
. fork_choice_read_lock ( )
1001
- . get_block ( & attestation. data . beacon_block_root )
1000
+ . get_block ( & attestation. data ( ) . beacon_block_root )
1002
1001
. or_else ( || {
1003
1002
chain
1004
1003
. early_attester_cache
1005
- . get_proto_block ( attestation. data . beacon_block_root )
1004
+ . get_proto_block ( attestation. data ( ) . beacon_block_root )
1006
1005
} ) ;
1007
1006
1008
1007
if let Some ( block) = block_opt {
1009
1008
// Reject any block that exceeds our limit on skipped slots.
1010
1009
if let Some ( max_skip_slots) = max_skip_slots {
1011
- if attestation. data . slot > block. slot + max_skip_slots {
1010
+ if attestation. data ( ) . slot > block. slot + max_skip_slots {
1012
1011
return Err ( Error :: TooManySkippedSlots {
1013
1012
head_block_slot : block. slot ,
1014
- attestation_slot : attestation. data . slot ,
1013
+ attestation_slot : attestation. data ( ) . slot ,
1015
1014
} ) ;
1016
1015
}
1017
1016
}
1018
1017
1019
1018
Ok ( block)
1020
- } else if chain. is_pre_finalization_block ( attestation. data . beacon_block_root ) ? {
1019
+ } else if chain. is_pre_finalization_block ( attestation. data ( ) . beacon_block_root ) ? {
1021
1020
Err ( Error :: HeadBlockFinalized {
1022
- beacon_block_root : attestation. data . beacon_block_root ,
1021
+ beacon_block_root : attestation. data ( ) . beacon_block_root ,
1023
1022
} )
1024
1023
} else {
1025
1024
// The block is either:
@@ -1029,7 +1028,7 @@ fn verify_head_block_is_known<T: BeaconChainTypes>(
1029
1028
// 2) A post-finalization block that we don't know about yet. We'll queue
1030
1029
// the attestation until the block becomes available (or we time out).
1031
1030
Err ( Error :: UnknownHeadBlock {
1032
- beacon_block_root : attestation. data . beacon_block_root ,
1031
+ beacon_block_root : attestation. data ( ) . beacon_block_root ,
1033
1032
} )
1034
1033
}
1035
1034
}
@@ -1043,7 +1042,7 @@ pub fn verify_propagation_slot_range<S: SlotClock, E: EthSpec>(
1043
1042
attestation : & Attestation < E > ,
1044
1043
spec : & ChainSpec ,
1045
1044
) -> Result < ( ) , Error > {
1046
- let attestation_slot = attestation. data . slot ;
1045
+ let attestation_slot = attestation. data ( ) . slot ;
1047
1046
let latest_permissible_slot = slot_clock
1048
1047
. now_with_future_tolerance ( spec. maximum_gossip_clock_disparity ( ) )
1049
1048
. ok_or ( BeaconChainError :: UnableToReadSlot ) ?;
@@ -1095,11 +1094,11 @@ pub fn verify_attestation_signature<T: BeaconChainTypes>(
1095
1094
1096
1095
let fork = chain
1097
1096
. spec
1098
- . fork_at_epoch ( indexed_attestation. data . target . epoch ) ;
1097
+ . fork_at_epoch ( indexed_attestation. data ( ) . target . epoch ) ;
1099
1098
1100
1099
let signature_set = indexed_attestation_signature_set_from_pubkeys (
1101
1100
|validator_index| pubkey_cache. get ( validator_index) . map ( Cow :: Borrowed ) ,
1102
- & indexed_attestation. signature ,
1101
+ indexed_attestation. signature ( ) ,
1103
1102
indexed_attestation,
1104
1103
& fork,
1105
1104
chain. genesis_validators_root ,
@@ -1127,7 +1126,7 @@ pub fn verify_attestation_target_root<E: EthSpec>(
1127
1126
) -> Result < ( ) , Error > {
1128
1127
// Check the attestation target root.
1129
1128
let head_block_epoch = head_block. slot . epoch ( E :: slots_per_epoch ( ) ) ;
1130
- let attestation_epoch = attestation. data . slot . epoch ( E :: slots_per_epoch ( ) ) ;
1129
+ let attestation_epoch = attestation. data ( ) . slot . epoch ( E :: slots_per_epoch ( ) ) ;
1131
1130
if head_block_epoch > attestation_epoch {
1132
1131
// The epoch references an invalid head block from a future epoch.
1133
1132
//
@@ -1140,7 +1139,7 @@ pub fn verify_attestation_target_root<E: EthSpec>(
1140
1139
// Reference:
1141
1140
// https://github.com/ethereum/eth2.0-specs/pull/2001#issuecomment-699246659
1142
1141
return Err ( Error :: InvalidTargetRoot {
1143
- attestation : attestation. data . target . root ,
1142
+ attestation : attestation. data ( ) . target . root ,
1144
1143
// It is not clear what root we should expect in this case, since the attestation is
1145
1144
// fundamentally invalid.
1146
1145
expected : None ,
@@ -1159,9 +1158,9 @@ pub fn verify_attestation_target_root<E: EthSpec>(
1159
1158
} ;
1160
1159
1161
1160
// Reject any attestation with an invalid target root.
1162
- if target_root != attestation. data . target . root {
1161
+ if target_root != attestation. data ( ) . target . root {
1163
1162
return Err ( Error :: InvalidTargetRoot {
1164
- attestation : attestation. data . target . root ,
1163
+ attestation : attestation. data ( ) . target . root ,
1165
1164
expected : Some ( target_root) ,
1166
1165
} ) ;
1167
1166
}
@@ -1199,7 +1198,7 @@ pub fn verify_signed_aggregate_signatures<T: BeaconChainTypes>(
1199
1198
1200
1199
let fork = chain
1201
1200
. spec
1202
- . fork_at_epoch ( indexed_attestation. data . target . epoch ) ;
1201
+ . fork_at_epoch ( indexed_attestation. data ( ) . target . epoch ) ;
1203
1202
1204
1203
let signature_sets = vec ! [
1205
1204
signed_aggregate_selection_proof_signature_set(
@@ -1220,7 +1219,7 @@ pub fn verify_signed_aggregate_signatures<T: BeaconChainTypes>(
1220
1219
. map_err( BeaconChainError :: SignatureSetError ) ?,
1221
1220
indexed_attestation_signature_set_from_pubkeys(
1222
1221
|validator_index| pubkey_cache. get( validator_index) . map( Cow :: Borrowed ) ,
1223
- & indexed_attestation. signature,
1222
+ indexed_attestation. signature( ) ,
1224
1223
indexed_attestation,
1225
1224
& fork,
1226
1225
chain. genesis_validators_root,
@@ -1266,8 +1265,8 @@ where
1266
1265
T : BeaconChainTypes ,
1267
1266
F : Fn ( ( BeaconCommittee , CommitteesPerSlot ) ) -> Result < R , Error > ,
1268
1267
{
1269
- let attestation_epoch = attestation. data . slot . epoch ( T :: EthSpec :: slots_per_epoch ( ) ) ;
1270
- let target = & attestation. data . target ;
1268
+ let attestation_epoch = attestation. data ( ) . slot . epoch ( T :: EthSpec :: slots_per_epoch ( ) ) ;
1269
+ let target = & attestation. data ( ) . target ;
1271
1270
1272
1271
// Attestation target must be for a known block.
1273
1272
//
@@ -1290,12 +1289,12 @@ where
1290
1289
let committees_per_slot = committee_cache. committees_per_slot ( ) ;
1291
1290
1292
1291
Ok ( committee_cache
1293
- . get_beacon_committee ( attestation. data . slot , attestation. data . index )
1292
+ . get_beacon_committee ( attestation. data ( ) . slot , attestation. data ( ) . index )
1294
1293
. map ( |committee| map_fn ( ( committee, committees_per_slot) ) )
1295
1294
. unwrap_or_else ( || {
1296
1295
Err ( Error :: NoCommitteeForSlotAndIndex {
1297
- slot : attestation. data . slot ,
1298
- index : attestation. data . index ,
1296
+ slot : attestation. data ( ) . slot ,
1297
+ index : attestation. data ( ) . index ,
1299
1298
} )
1300
1299
} ) )
1301
1300
} )
0 commit comments