Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions ocp/worker/geyser/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,16 @@ func (p *runtime) backupTimelockStateWorker(runtimeCtx context.Context, state ti
return
}

reprocessDelay := p.conf.backupTimelockWorkerReprocessDelay.Get(runtimeCtx)

var wg sync.WaitGroup
for _, timelockRecord := range timelockRecords {
if lastProcessed, ok := p.backupTimelockProcessedCache.Load(timelockRecord.Address); ok {
if time.Since(lastProcessed.(time.Time)) < reprocessDelay {
continue
}
}

wg.Add(1)

go func(timelockRecord *timelock.Record) {
Expand All @@ -85,7 +93,10 @@ func (p *runtime) backupTimelockStateWorker(runtimeCtx context.Context, state ti
err := updateTimelockAccountRecord(tracedCtx, p.data, timelockRecord)
if err != nil {
log.With(zap.Error(err)).Warn("failed to update timelock account")
return
}

p.backupTimelockProcessedCache.Store(timelockRecord.Address, time.Now())
}(timelockRecord)
}

Expand Down
13 changes: 9 additions & 4 deletions ocp/worker/geyser/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ const (
BackupTimelockWorkerBatchSizeConfigEnvName = envConfigPrefix + "BACKUP_TIMELOCK_WORKER_BATCH_SIZE"
defaultBackupTimelockWorkerBatchSize = 100

BackupTimelockWorkerReprocessDelayConfigEnvName = envConfigPrefix + "BACKUP_TIMELOCK_WORKER_REPROCESS_DELAY"
defaultBackupTimelockWorkerReprocessDelay = time.Hour

BackupExternalDepositWorkerIntervalConfigEnvName = envConfigPrefix + "BACKUP_EXTERNAL_DEPOSIT_WORKER_INTERVAL"
defaultBackupExternalDepositWorkerInterval = time.Second

Expand All @@ -45,8 +48,9 @@ type conf struct {
backupExternalDepositWorkerInterval config.Duration
backupExternalDepositWorkerBatchSize config.Uint64

backupTimelockWorkerInterval config.Duration
backupTimelockWorkerBatchSize config.Uint64
backupTimelockWorkerInterval config.Duration
backupTimelockWorkerBatchSize config.Uint64
backupTimelockWorkerReprocessDelay config.Duration
}

// ConfigProvider defines how config values are pulled
Expand All @@ -65,8 +69,9 @@ func WithEnvConfigs() ConfigProvider {
backupExternalDepositWorkerInterval: env.NewDurationConfig(BackupExternalDepositWorkerIntervalConfigEnvName, defaultBackupExternalDepositWorkerInterval),
backupExternalDepositWorkerBatchSize: env.NewUint64Config(BackupExternalDepositWorkerBatchSizeConfigEnvName, defaultBackupExternalDepositWorkerBatchSize),

backupTimelockWorkerInterval: env.NewDurationConfig(BackupTimelockWorkerIntervalConfigEnvName, defaultBackupTimelockWorkerInterval),
backupTimelockWorkerBatchSize: env.NewUint64Config(BackupTimelockWorkerBatchSizeConfigEnvName, defaultBackupTimelockWorkerBatchSize),
backupTimelockWorkerInterval: env.NewDurationConfig(BackupTimelockWorkerIntervalConfigEnvName, defaultBackupTimelockWorkerInterval),
backupTimelockWorkerBatchSize: env.NewUint64Config(BackupTimelockWorkerBatchSizeConfigEnvName, defaultBackupTimelockWorkerBatchSize),
backupTimelockWorkerReprocessDelay: env.NewDurationConfig(BackupTimelockWorkerReprocessDelayConfigEnvName, defaultBackupTimelockWorkerReprocessDelay),
}
}
}
1 change: 1 addition & 0 deletions ocp/worker/geyser/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ type runtime struct {

backupTimelockStateWorkerDuration *time.Duration
backupTimelockStateWorkerStatus bool
backupTimelockProcessedCache sync.Map // address -> time.Time

backupExternalDepositWorkerStatus bool
}
Expand Down