Skip to content

Commit

Permalink
Enforcing aggressive logs and blocks cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mateusz-sekara committed Apr 23, 2024
1 parent 35f0bc5 commit 71a248e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
5 changes: 3 additions & 2 deletions core/chains/evm/logpoller/log_poller.go
Original file line number Diff line number Diff line change
Expand Up @@ -611,15 +611,16 @@ func (lp *logPoller) backgroundWorkerRun() {
case <-lp.ctx.Done():
return
case <-blockPruneTick:
blockPruneTick = time.After(utils.WithJitter(lp.pollPeriod * 1000))
blockPruneTick = time.After(utils.WithJitter(1000 * time.Second))
lp.keepFinalizedBlocksDepth = 1000
if allRemoved, err := lp.PruneOldBlocks(lp.ctx); err != nil {
lp.lggr.Errorw("Unable to prune old blocks", "err", err)
} else if !allRemoved {
// Tick faster when cleanup can't keep up with the pace of new blocks
blockPruneTick = time.After(utils.WithJitter(lp.pollPeriod * 100))
}
case <-logPruneTick:
logPruneTick = time.After(utils.WithJitter(lp.pollPeriod * 2401)) // = 7^5 avoids common factors with 1000
logPruneTick = time.After(utils.WithJitter(2401 * time.Second)) // = 7^5 avoids common factors with 1000
if allRemoved, err := lp.PruneExpiredLogs(lp.ctx); err != nil {
lp.lggr.Errorw("Unable to prune expired logs", "err", err)
} else if !allRemoved {
Expand Down
7 changes: 4 additions & 3 deletions core/services/ocr2/plugins/ccip/internal/ccipdata/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/ethereum/go-ethereum/core/types"

cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip"

"github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller"
"github.com/smartcontractkit/chainlink/v2/core/logger"
)
Expand All @@ -27,14 +28,14 @@ const (
// be able to bring back processing without replaying any logs from chain. You can read that param as
// "how long CCIP can be down and still be able to process all the messages after getting back to life".
// Breaching this threshold would require replaying chain using LogPoller from the beginning of the outage.
CommitExecLogsRetention = 30 * 24 * time.Hour // 30 days
CommitExecLogsRetention = 1 * time.Hour // 30 days
// CacheEvictionLogsRetention defines the duration for which logs used for caching on-chain data are kept.
// Restarting node clears the cache entirely and rebuilds it from scratch by fetching data from chain,
// so we don't need to keep these logs for very long. All events relying on cache.NewLogpollerEventsBased should use this retention.
CacheEvictionLogsRetention = 7 * 24 * time.Hour // 7 days
CacheEvictionLogsRetention = 1 * time.Hour // 7 days
// PriceUpdatesLogsRetention defines the duration for which logs with price updates are kept.
// These logs are emitted whenever the token price or gas price is updated and Commit scans very small time windows (e.g. 2 hours)
PriceUpdatesLogsRetention = 1 * 24 * time.Hour // 1 day
PriceUpdatesLogsRetention = 1 * time.Hour // 1 day
)

type Event[T any] struct {
Expand Down

0 comments on commit 71a248e

Please sign in to comment.