11package services
22
33import (
4- "bytes"
5- "context"
6- "encoding/gob"
74 "fmt"
8- "strconv"
9- "strings"
105 "sync"
11- "sync/atomic"
126 "time"
137
14- "github.com/gobitfly/beaconchain/pkg/commons/cache"
15- "github.com/gobitfly/beaconchain/pkg/commons/db"
168 "github.com/gobitfly/beaconchain/pkg/commons/log"
17- "github.com/gobitfly/beaconchain/pkg/commons/types"
189 "github.com/gobitfly/beaconchain/pkg/commons/utils"
19- constypes "github.com/gobitfly/beaconchain/pkg/consapi/types"
2010 "github.com/gobitfly/beaconchain/pkg/monitoring/constants"
2111 "github.com/gobitfly/beaconchain/pkg/monitoring/services"
22- "github.com/juliangruber/go-intersect"
23- "github.com/lib/pq"
24- "github.com/pkg/errors"
25- "golang.org/x/sync/errgroup"
2612)
2713
28- var currentDutiesInfo atomic.Pointer [SyncData ]
14+ // var currentDutiesInfo atomic.Pointer[SyncData]
2915
3016func (s * Services ) startSlotVizDataService (wg * sync.WaitGroup ) {
3117 o := sync.Once {}
@@ -49,7 +35,8 @@ func (s *Services) startSlotVizDataService(wg *sync.WaitGroup) {
4935}
5036
5137func (s * Services ) updateSlotVizData () error {
52- var dutiesInfo * SyncData
38+ return nil
39+ /*var dutiesInfo *SyncData
5340 if currentDutiesInfo.Load() == nil {
5441 dutiesInfo = s.initDutiesInfo()
5542 } else {
@@ -287,19 +274,39 @@ func (s *Services) updateSlotVizData() error {
287274
288275 currentDutiesInfo.Store(dutiesInfo)
289276
290- return nil
277+ return nil*/
291278}
292279
293280// GetCurrentDutiesInfo returns the current duties info and a function to release the lock
294281// Call release lock after you are done with accessing the data, otherwise it will block the slot viz service from updating
295282func (s * Services ) GetCurrentDutiesInfo () (* SyncData , error ) {
296- if currentDutiesInfo .Load () == nil {
283+ dutiesInfo := SyncData {}
284+ // dummy data to avoid downloading duties from redis
285+ dutiesInfo .PropAssignmentsForSlot = make (map [uint64 ]uint64 )
286+ // validators in megatron
287+ dutiesInfo .PropAssignmentsForSlot [3_000_000 ] = 1
288+ dutiesInfo .PropAssignmentsForSlot [3_000_001 ] = 7
289+ dutiesInfo .PropAssignmentsForSlot [3_000_002 ] = 13
290+ dutiesInfo .PropAssignmentsForSlot [3_000_003 ] = 19
291+ dutiesInfo .PropAssignmentsForSlot [3_000_004 ] = 25
292+ dutiesInfo .PropAssignmentsForSlot [3_000_005 ] = 31
293+ // and some others
294+ dutiesInfo .PropAssignmentsForSlot [3_000_006 ] = 29141
295+ dutiesInfo .PropAssignmentsForSlot [3_000_007 ] = 500167
296+ dutiesInfo .PropAssignmentsForSlot [3_000_008 ] = 531705
297+ dutiesInfo .PropAssignmentsForSlot [3_000_009 ] = 542402
298+ dutiesInfo .PropAssignmentsForSlot [3_000_010 ] = 845851
299+ dutiesInfo .PropAssignmentsForSlot [3_000_011 ] = 894749
300+
301+ return & dutiesInfo , nil
302+
303+ /*if currentDutiesInfo.Load() == nil {
297304 return nil, fmt.Errorf("%w: dutiesInfo", ErrWaiting)
298305 }
299- return currentDutiesInfo .Load (), nil
306+ return currentDutiesInfo.Load(), nil*/
300307}
301308
302- func (s * Services ) initDutiesInfo () * SyncData {
309+ /* func (s *Services) initDutiesInfo() *SyncData {
303310 dutiesInfo := SyncData{}
304311 dutiesInfo.LatestSlot = uint64(0)
305312 dutiesInfo.LatestProposedSlot = uint64(0)
@@ -433,9 +440,9 @@ func (s *Services) copyAndCleanDutiesInfo() *SyncData {
433440 }
434441 }
435442 return dutiesInfo
436- }
443+ }*/
437444
438- func (s * Services ) getMaxValidatorDutiesInfoSlot () uint64 {
445+ /* func (s *Services) getMaxValidatorDutiesInfoSlot() uint64 {
439446 headEpoch := cache.LatestEpoch.Get()
440447 slotsPerEpoch := utils.Config.Chain.ClConfig.SlotsPerEpoch
441448
@@ -451,15 +458,15 @@ func (s *Services) getMaxValidatorDutiesInfoSlot() uint64 {
451458 - Attestation data amount is the main culprit for the database call since it returns huge amounts of data
452459 - Other fields used by slotviz do not change as well (sync bits, exec block). If we at some point include changing fields for headEpoch -2
453460 we should consider making this a separate call to avoid loading all attestation data again
454- */
461+
455462 if err == nil && p.AssignmentsFetchedForEpoch > 0 && headEpoch > 0 { // if we have fetched epoch assignments before
456463 minEpoch = headEpoch - 1
457464 }
458465
459466 maxValidatorDutiesInfoSlot := minEpoch * slotsPerEpoch
460467
461468 return maxValidatorDutiesInfoSlot
462- }
469+ }*/
463470
464471type SyncData struct {
465472 LatestSlot uint64
0 commit comments