Skip to content

Commit 7c01d98

Browse files
invis-bitflyguybrush
authored andcommitted
add(exporter): cooldowns for payload exporter & rewards finalizer
1 parent e35300d commit 7c01d98

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

backend/pkg/exporter/modules/execution_payloads_exporter.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"fmt"
88
"math/big"
99
"sync"
10+
"time"
1011

1112
"github.com/gobitfly/beaconchain/pkg/commons/db"
1213
"github.com/gobitfly/beaconchain/pkg/commons/log"
@@ -21,6 +22,7 @@ import (
2122
type executionPayloadsExporter struct {
2223
ModuleContext ModuleContext
2324
ExportMutex *sync.Mutex
25+
CooldownTs time.Time
2426
}
2527

2628
func NewExecutionPayloadsExporter(moduleContext ModuleContext) ModuleInterface {
@@ -31,6 +33,10 @@ func NewExecutionPayloadsExporter(moduleContext ModuleContext) ModuleInterface {
3133
}
3234

3335
func (d *executionPayloadsExporter) OnHead(event *constypes.StandardEventHeadResponse) (err error) {
36+
if time.Now().Before(d.CooldownTs) {
37+
log.Warnf("execution rewards finalizer is on cooldown till %s", d.CooldownTs)
38+
return nil
39+
}
3440
// if mutex is locked, return early
3541
if !d.ExportMutex.TryLock() {
3642
log.Infof("execution payloads exporter is already running")
@@ -39,6 +45,7 @@ func (d *executionPayloadsExporter) OnHead(event *constypes.StandardEventHeadRes
3945
defer d.ExportMutex.Unlock()
4046
err = d.maintainTable()
4147
if err != nil {
48+
d.CooldownTs = time.Now().Add(1 * time.Minute)
4249
return fmt.Errorf("error maintaining table: %w", err)
4350
}
4451
return nil

backend/pkg/exporter/modules/execution_rewards_finalizer.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ func (d *executionRewardsFinalizer) OnFinalizedCheckpoint(event *constypes.Stand
4949
func (d *executionRewardsFinalizer) OnHead(event *constypes.StandardEventHeadResponse) (err error) {
5050
if time.Now().Before(d.CooldownTs) {
5151
log.Warnf("execution rewards finalizer is on cooldown till %s", d.CooldownTs)
52+
return nil
5253
}
5354
// if mutex is locked, return early
5455
if !d.ExportMutex.TryLock() {

0 commit comments

Comments
 (0)