@@ -492,36 +492,38 @@ func isBitSet(input uint8, n int) bool {
492492func GetProcessedConsolidations (
493493 prevBeaconState * spec.VersionedBeaconState ,
494494 currentBeaconState * spec.VersionedBeaconState ,
495- ) map [uint64 ][]* electra.PendingConsolidation {
495+ ) ( map [uint64 ][]* electra.PendingConsolidation , error ) {
496496 consolidations := make (map [uint64 ][]* electra.PendingConsolidation )
497497
498498 validators := GetValidators (currentBeaconState )
499499 prevPendingConsolidations := GetPendingConsolidations (prevBeaconState )
500500 currPendingConsolidations := GetPendingConsolidations (currentBeaconState )
501501
502- if prevPendingConsolidations == nil {
503- return consolidations
502+ if prevPendingConsolidations == nil || currPendingConsolidations == nil {
503+ return nil , errors .New ("state with nil pending consolidations found" )
504+ }
505+
506+ if len (validators ) == 0 {
507+ return consolidations , nil
504508 }
505509
506510 // Set of current pending consolidations
507- currPendingConsolidationsSet := make (map [string ]bool )
511+ currPendingConsolidationsSet := make (map [electra. PendingConsolidation ]bool )
508512 for _ , consolidation := range currPendingConsolidations {
509- key := fmt .Sprintf ("%d-%d" , consolidation .SourceIndex , consolidation .TargetIndex )
510- currPendingConsolidationsSet [key ] = true
513+ currPendingConsolidationsSet [* consolidation ] = true
511514 }
512515
513516 // If the consolidation is not in the current set, it was processed or source slashed
514517 for _ , consolidation := range prevPendingConsolidations {
515- key := fmt .Sprintf ("%d-%d" , consolidation .SourceIndex , consolidation .TargetIndex )
516- if _ , ok := currPendingConsolidationsSet [key ]; ! ok {
518+ if _ , ok := currPendingConsolidationsSet [* consolidation ]; ! ok {
517519 sourceValidator := validators [consolidation .SourceIndex ]
518520 if sourceValidator .Slashed {
519521 continue
520522 }
521523 consolidations [uint64 (consolidation .TargetIndex )] = append (consolidations [uint64 (consolidation .TargetIndex )], consolidation )
522524 }
523525 }
524- return consolidations
526+ return consolidations , nil
525527}
526528
527529func logMetrics (
0 commit comments