Skip to content

Commit

Permalink
negative payload and registration fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
lukanus committed Jul 13, 2023
1 parent 658e7f3 commit b6d34e2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
7 changes: 7 additions & 0 deletions beacon/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,13 @@ func (s *Manager) Run(ctx context.Context, state State, client BeaconClient, d D
case ev := <-c:
t := time.Now()

if ev.Data.ProposalSlot == 0 {
logger.
WithField("slot", ev.Data.ProposalSlot).
Warn("error processing slot - zero slot")
continue
}

err := s.processNewSlot(ctx, state, client, ev, d, vCache)

headSlot := state.HeadSlot()
Expand Down
14 changes: 9 additions & 5 deletions cmd/dreamboat/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ func main() {
// VALIDATOR MANAGEMENT
var valDS ValidatorStore
if cfg.Validators.DB.URL != "" {
valPG, err := trPostgres.Open(cfg.Validators.DB.URL, 10, 10, 10*time.Second)
valPG, err := trPostgres.Open(cfg.Validators.DB.URL, cfg.Validators.DB.MaxOpenConns, cfg.Validators.DB.MaxIdleConns, cfg.Validators.DB.ConnMaxIdleTime)
if err != nil {
logger.WithError(err).Error("failed to connect to validator database")
return
Expand All @@ -230,7 +230,7 @@ func main() {
// DATAAPI
var daDS relay.DataAPIStore
if cfg.DataAPI.DB.URL != "" {
valPG, err := trPostgres.Open(cfg.DataAPI.DB.URL, 10, 10, 10*time.Second) // TODO(l): make configurable
valPG, err := trPostgres.Open(cfg.DataAPI.DB.URL, cfg.DataAPI.DB.MaxOpenConns, cfg.DataAPI.DB.MaxIdleConns, cfg.DataAPI.DB.ConnMaxIdleTime) // TODO(l): make configurable
if err != nil {
logger.WithError(err).Error("failed to connect to dataapi database")
}
Expand Down Expand Up @@ -467,12 +467,16 @@ func asyncPopulateAllRegistrations(ctx context.Context, l log.Logger, vs Validat
}
}

func preloadValidators(ctx context.Context, l log.Logger, vs ValidatorStore, vc *lru.Cache[types.PublicKey, structs.ValidatorCacheEntry]) {
func preloadValidators(ctx context.Context, l log.Logger, vs ValidatorStore, writeTTLSeconds float64, vc *lru.Cache[types.PublicKey, structs.ValidatorCacheEntry]) {
ch := make(chan structs.ValidatorCacheEntry, 100)
go asyncPopulateAllRegistrations(ctx, l, vs, ch)
for v := range ch {
v := v
vc.ContainsOrAdd(v.Entry.Message.Pubkey, v)
k := v
if time.Since(v.Time).Seconds() > writeTTLSeconds {
// set initial timer to half cache
k.Time = time.Now().Add(-1 * time.Duration(0.5*writeTTLSeconds*float64(time.Second)))
}
vc.ContainsOrAdd(v.Entry.Message.Pubkey, k)
}
l.With(log.F{"count": vc.Len()}).Info("Loaded cache validators")
}
Expand Down

0 comments on commit b6d34e2

Please sign in to comment.