@@ -948,58 +948,61 @@ 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
954- }
955- blockTime := r .genesisTime .Add (time .Second * time .Duration (r .networkState .BeaconConfig .SecondsPerSlot * attestation .SlotIndex ))
956951
957- // Check if each RP validator attested successfully
958- for position , validator := range rpCommittee . Positions {
959- if ! attestation . AggregationBits . BitAt ( uint64 ( position )) {
952+ for _ , committeeIndex := range attestation . CommitteeIndices () {
953+ rpCommittee , exists := slotInfo . Committees [ uint64 ( committeeIndex )]
954+ if ! exists {
960955 continue
961956 }
957+ blockTime := r .genesisTime .Add (time .Second * time .Duration (r .networkState .BeaconConfig .SecondsPerSlot * attestation .SlotIndex ))
962958
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 )
959+ // Check if each RP validator attested successfully
960+ for position , validator := range rpCommittee .Positions {
961+ if ! attestation .ValidatorAttested (committeeIndex , position , slotInfo .CommitteeSizes ) {
962+ continue
963+ }
972964
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- }
965+ // This was seen, so remove it from the missing attestations and add it to the completed ones
966+ delete (rpCommittee .Positions , position )
967+ if len (rpCommittee .Positions ) == 0 {
968+ delete (slotInfo .Committees , uint64 (committeeIndex ))
969+ }
970+ if len (slotInfo .Committees ) == 0 {
971+ delete (r .intervalDutiesInfo .Slots , attestation .SlotIndex )
972+ }
973+ delete (validator .MissingAttestationSlots , attestation .SlotIndex )
979974
980- eligibleBorrowedEth := nodeDetails .EligibleBorrowedEth
981- _ , percentOfBorrowedEth := r .networkState .GetStakedRplValueInEthAndPercentOfBorrowedEth (eligibleBorrowedEth , nodeDetails .RplStake )
975+ // Check if this minipool was opted into the SP for this block
976+ nodeDetails := r .nodeDetails [validator .NodeIndex ]
977+ if blockTime .Before (nodeDetails .OptInTime ) || blockTime .After (nodeDetails .OptOutTime ) {
978+ // Not opted in
979+ continue
980+ }
982981
983- // Mark this duty as completed
984- validator . CompletedAttestations [ attestation . SlotIndex ] = true
982+ eligibleBorrowedEth := nodeDetails . EligibleBorrowedEth
983+ _ , percentOfBorrowedEth := r . networkState . GetStakedRplValueInEthAndPercentOfBorrowedEth ( eligibleBorrowedEth , nodeDetails . RplStake )
985984
986- // Get the pseudoscore for this attestation
987- details := r .networkState .MinipoolDetailsByAddress [validator .Address ]
988- bond , fee := details .GetMinipoolBondAndNodeFee (blockTime )
985+ // Mark this duty as completed
986+ validator .CompletedAttestations [attestation .SlotIndex ] = true
989987
990- if r . rewardsFile . RulesetVersion >= 10 {
991- fee = fees . GetMinipoolFeeWithBonus ( bond , fee , percentOfBorrowedEth )
992- }
988+ // Get the pseudoscore for this attestation
989+ details := r . networkState . MinipoolDetailsByAddress [ validator . Address ]
990+ bond , fee := details . GetMinipoolBondAndNodeFee ( blockTime )
993991
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)
992+ if r .rewardsFile .RulesetVersion >= 10 {
993+ fee = fees .GetMinipoolFeeWithBonus (bond , fee , percentOfBorrowedEth )
994+ }
998995
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 ++
996+ minipoolScore := big .NewInt (0 ).Sub (oneEth , fee ) // 1 - fee
997+ minipoolScore .Mul (minipoolScore , bond ) // Multiply by bond
998+ minipoolScore .Div (minipoolScore , thirtyTwoEth ) // Divide by 32 to get the bond as a fraction of a total validator
999+ minipoolScore .Add (minipoolScore , fee ) // Total = fee + (bond/32)(1 - fee)
1000+
1001+ // Add it to the minipool's score and the total score
1002+ validator .AttestationScore .Add (& validator .AttestationScore .Int , minipoolScore )
1003+ r .totalAttestationScore .Add (r .totalAttestationScore , minipoolScore )
1004+ r .successfulAttestations ++
1005+ }
10031006 }
10041007 }
10051008
@@ -1020,6 +1023,18 @@ func (r *treeGeneratorImpl_v9_v10) getDutiesForEpoch(committees beacon.Committee
10201023 blockTime := r .genesisTime .Add (time .Second * time .Duration (r .beaconConfig .SecondsPerSlot * slotIndex ))
10211024 committeeIndex := committees .Index (idx )
10221025
1026+ // Add the committee size to the list, for calculating offset in post-electra aggregation_bits
1027+ slotInfo , exists := r .intervalDutiesInfo .Slots [slotIndex ]
1028+ if ! exists {
1029+ slotInfo = & SlotInfo {
1030+ Index : slotIndex ,
1031+ Committees : map [uint64 ]* CommitteeInfo {},
1032+ CommitteeSizes : map [uint64 ]int {},
1033+ }
1034+ r .intervalDutiesInfo .Slots [slotIndex ] = slotInfo
1035+ }
1036+ slotInfo .CommitteeSizes [committeeIndex ] = committees .ValidatorCount (idx )
1037+
10231038 // Check if there are any RP validators in this committee
10241039 rpValidators := map [int ]* MinipoolInfo {}
10251040 for position , validator := range committees .Validators (idx ) {
@@ -1052,14 +1067,6 @@ func (r *treeGeneratorImpl_v9_v10) getDutiesForEpoch(committees beacon.Committee
10521067
10531068 // If there are some RP validators, add this committee to the map
10541069 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- }
10631070 slotInfo .Committees [committeeIndex ] = & CommitteeInfo {
10641071 Index : committeeIndex ,
10651072 Positions : rpValidators ,
0 commit comments