@@ -948,58 +948,67 @@ func (r *treeGeneratorImpl_v9_v10) checkAttestations(attestations []beacon.Attes
948948 if inclusionSlot - attestation .SlotIndex > r .beaconConfig .SlotsPerEpoch {
949949 continue
950950 }
951- rpCommittee , exists := slotInfo .Committees [attestation .CommitteeIndex ]
952- if ! exists {
953- continue
951+ var committeeIndexes []int
952+ if attestation .CommitteeBits == nil {
953+ committeeIndexes = []int {int (attestation .CommitteeIndex )}
954+ } else {
955+ committeeIndexes = attestation .CommitteeBits .BitIndices ()
954956 }
955- blockTime := r .genesisTime .Add (time .Second * time .Duration (r .networkState .BeaconConfig .SecondsPerSlot * attestation .SlotIndex ))
956957
957- // Check if each RP validator attested successfully
958- for position , validator := range rpCommittee . Positions {
959- if ! attestation . AggregationBits . BitAt ( uint64 ( position )) {
958+ for _ , committeeIndex := range committeeIndexes {
959+ rpCommittee , exists := slotInfo . Committees [ uint64 ( committeeIndex )]
960+ if ! exists {
960961 continue
961962 }
963+ blockTime := r .genesisTime .Add (time .Second * time .Duration (r .networkState .BeaconConfig .SecondsPerSlot * attestation .SlotIndex ))
962964
963- // This was seen, so remove it from the missing attestations and add it to the completed ones
964- delete (rpCommittee .Positions , position )
965- if len (rpCommittee .Positions ) == 0 {
966- delete (slotInfo .Committees , attestation .CommitteeIndex )
967- }
968- if len (slotInfo .Committees ) == 0 {
969- delete (r .intervalDutiesInfo .Slots , attestation .SlotIndex )
970- }
971- delete (validator .MissingAttestationSlots , attestation .SlotIndex )
965+ // Check if each RP validator attested successfully
966+ for position , validator := range rpCommittee .Positions {
967+ if ! attestation .ValidatorAttested (committeeIndex , position , slotInfo .CommitteeSizes ) {
968+ continue
969+ }
972970
973- // Check if this minipool was opted into the SP for this block
974- nodeDetails := r .nodeDetails [validator .NodeIndex ]
975- if blockTime .Before (nodeDetails .OptInTime ) || blockTime .After (nodeDetails .OptOutTime ) {
976- // Not opted in
977- continue
978- }
971+ // This was seen, so remove it from the missing attestations and add it to the completed ones
972+ delete (rpCommittee .Positions , position )
973+ if len (rpCommittee .Positions ) == 0 {
974+ delete (slotInfo .Committees , uint64 (committeeIndex ))
975+ }
976+ if len (slotInfo .Committees ) == 0 {
977+ delete (r .intervalDutiesInfo .Slots , attestation .SlotIndex )
978+ }
979+ delete (validator .MissingAttestationSlots , attestation .SlotIndex )
979980
980- eligibleBorrowedEth := nodeDetails .EligibleBorrowedEth
981- _ , percentOfBorrowedEth := r .networkState .GetStakedRplValueInEthAndPercentOfBorrowedEth (eligibleBorrowedEth , nodeDetails .RplStake )
981+ // Check if this minipool was opted into the SP for this block
982+ nodeDetails := r .nodeDetails [validator .NodeIndex ]
983+ if blockTime .Before (nodeDetails .OptInTime ) || blockTime .After (nodeDetails .OptOutTime ) {
984+ // Not opted in
985+ continue
986+ }
982987
983- // Mark this duty as completed
984- validator . CompletedAttestations [ attestation . SlotIndex ] = true
988+ eligibleBorrowedEth := nodeDetails . EligibleBorrowedEth
989+ _ , percentOfBorrowedEth := r . networkState . GetStakedRplValueInEthAndPercentOfBorrowedEth ( eligibleBorrowedEth , nodeDetails . RplStake )
985990
986- // Get the pseudoscore for this attestation
987- details := r .networkState .MinipoolDetailsByAddress [validator .Address ]
988- bond , fee := details .GetMinipoolBondAndNodeFee (blockTime )
991+ // Mark this duty as completed
992+ validator .CompletedAttestations [attestation .SlotIndex ] = true
989993
990- if r . rewardsFile . RulesetVersion >= 10 {
991- fee = fees . GetMinipoolFeeWithBonus ( bond , fee , percentOfBorrowedEth )
992- }
994+ // Get the pseudoscore for this attestation
995+ details := r . networkState . MinipoolDetailsByAddress [ validator . Address ]
996+ bond , fee := details . GetMinipoolBondAndNodeFee ( blockTime )
993997
994- minipoolScore := big .NewInt (0 ).Sub (oneEth , fee ) // 1 - fee
995- minipoolScore .Mul (minipoolScore , bond ) // Multiply by bond
996- minipoolScore .Div (minipoolScore , thirtyTwoEth ) // Divide by 32 to get the bond as a fraction of a total validator
997- minipoolScore .Add (minipoolScore , fee ) // Total = fee + (bond/32)(1 - fee)
998+ if r .rewardsFile .RulesetVersion >= 10 {
999+ fee = fees .GetMinipoolFeeWithBonus (bond , fee , percentOfBorrowedEth )
1000+ }
9981001
999- // Add it to the minipool's score and the total score
1000- validator .AttestationScore .Add (& validator .AttestationScore .Int , minipoolScore )
1001- r .totalAttestationScore .Add (r .totalAttestationScore , minipoolScore )
1002- r .successfulAttestations ++
1002+ minipoolScore := big .NewInt (0 ).Sub (oneEth , fee ) // 1 - fee
1003+ minipoolScore .Mul (minipoolScore , bond ) // Multiply by bond
1004+ minipoolScore .Div (minipoolScore , thirtyTwoEth ) // Divide by 32 to get the bond as a fraction of a total validator
1005+ minipoolScore .Add (minipoolScore , fee ) // Total = fee + (bond/32)(1 - fee)
1006+
1007+ // Add it to the minipool's score and the total score
1008+ validator .AttestationScore .Add (& validator .AttestationScore .Int , minipoolScore )
1009+ r .totalAttestationScore .Add (r .totalAttestationScore , minipoolScore )
1010+ r .successfulAttestations ++
1011+ }
10031012 }
10041013 }
10051014
@@ -1020,6 +1029,18 @@ func (r *treeGeneratorImpl_v9_v10) getDutiesForEpoch(committees beacon.Committee
10201029 blockTime := r .genesisTime .Add (time .Second * time .Duration (r .beaconConfig .SecondsPerSlot * slotIndex ))
10211030 committeeIndex := committees .Index (idx )
10221031
1032+ // Add the committee size to the list, for calculating offset in post-electra aggregation_bits
1033+ slotInfo , exists := r .intervalDutiesInfo .Slots [slotIndex ]
1034+ if ! exists {
1035+ slotInfo = & SlotInfo {
1036+ Index : slotIndex ,
1037+ Committees : map [uint64 ]* CommitteeInfo {},
1038+ CommitteeSizes : map [uint64 ]int {},
1039+ }
1040+ r .intervalDutiesInfo .Slots [slotIndex ] = slotInfo
1041+ }
1042+ slotInfo .CommitteeSizes [committeeIndex ] = committees .ValidatorCount (idx )
1043+
10231044 // Check if there are any RP validators in this committee
10241045 rpValidators := map [int ]* MinipoolInfo {}
10251046 for position , validator := range committees .Validators (idx ) {
@@ -1052,14 +1073,6 @@ func (r *treeGeneratorImpl_v9_v10) getDutiesForEpoch(committees beacon.Committee
10521073
10531074 // If there are some RP validators, add this committee to the map
10541075 if len (rpValidators ) > 0 {
1055- slotInfo , exists := r .intervalDutiesInfo .Slots [slotIndex ]
1056- if ! exists {
1057- slotInfo = & SlotInfo {
1058- Index : slotIndex ,
1059- Committees : map [uint64 ]* CommitteeInfo {},
1060- }
1061- r .intervalDutiesInfo .Slots [slotIndex ] = slotInfo
1062- }
10631076 slotInfo .Committees [committeeIndex ] = & CommitteeInfo {
10641077 Index : committeeIndex ,
10651078 Positions : rpValidators ,
0 commit comments