Skip to content

Commit 9012f2f

Browse files
authored
Merge branch 'main' into cian/benchmark-results-artifact
2 parents f0f71bd + 146e6e1 commit 9012f2f

3 files changed

Lines changed: 21 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1818
### Fixed
1919

2020
- Avoid evicting yet to be processed heights [#3204](https://github.com/evstack/ev-node/pull/3204)
21+
- Bound Badger index cache memory to prevent growth with chain length [3209](https://github.com/evstack/ev-node/pull/3209)
2122
- Refetch latest da height instead of da height +1 when P2P is offline [#3201](https://github.com/evstack/ev-node/pull/3201)
2223
- Fix race on startup sync. [#3162](https://github.com/evstack/ev-node/pull/3162)
2324
- Strict raft state. [#3167](https://github.com/evstack/ev-node/pull/3167)

block/internal/syncing/syncer.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,11 @@ func (s *Syncer) waitForGenesis() bool {
517517
}
518518

519519
func (s *Syncer) PipeEvent(ctx context.Context, event common.DAHeightEvent) error {
520+
// Avoid sending already seen events to channel (would have been skipped in processHeightEvent anyway)
521+
if s.cache.IsHeaderSeen(event.Header.Hash().String()) {
522+
return nil
523+
}
524+
520525
select {
521526
case s.heightInCh <- event:
522527
return nil
@@ -537,6 +542,7 @@ func (s *Syncer) processHeightEvent(ctx context.Context, event *common.DAHeightE
537542
Uint64("height", height).
538543
Uint64("da_height", event.DaHeight).
539544
Str("hash", headerHash).
545+
Str("source", string(event.Source)).
540546
Msg("processing height event")
541547

542548
currentHeight, err := s.store.Height(ctx)
@@ -547,7 +553,10 @@ func (s *Syncer) processHeightEvent(ctx context.Context, event *common.DAHeightE
547553

548554
// Skip if already processed
549555
if height <= currentHeight || s.cache.IsHeaderSeen(headerHash) {
550-
s.logger.Debug().Uint64("height", height).Msg("height already processed")
556+
s.logger.Debug().
557+
Uint64("height", height).
558+
Str("source", string(event.Source)).
559+
Msg("height already processed")
551560
return
552561
}
553562

@@ -656,6 +665,7 @@ func (s *Syncer) processHeightEvent(ctx context.Context, event *common.DAHeightE
656665
s.logger.Error().Err(err).
657666
Uint64("event-height", event.Header.Height()).
658667
Uint64("state-height", s.getLastState().LastBlockHeight).
668+
Str("source", string(event.Source)).
659669
Msg("failed to sync next block")
660670
// If the error is not due to a validation error, re-store the event as pending
661671
switch {

pkg/store/badger_options.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,20 @@ import (
66
badger4 "github.com/ipfs/go-ds-badger4"
77
)
88

9+
const (
10+
// DefaultBadgerIndexCacheSize bounds Badger's table index and bloom filter
11+
// cache to avoid growth with chain length.
12+
DefaultBadgerIndexCacheSize int64 = 256 << 20 // 256 MiB
13+
)
14+
915
// BadgerOptions returns ev-node tuned Badger options for the node workload.
1016
// These defaults favor write throughput for append-heavy usage.
1117
func BadgerOptions() *badger4.Options {
1218
opts := badger4.DefaultOptions
1319

20+
// Bound Badger-owned caches explicitly instead of inheriting a large block
21+
// cache and an unbounded index cache from the upstream defaults.
22+
opts.Options = opts.WithIndexCacheSize(DefaultBadgerIndexCacheSize)
1423
// Disable conflict detection to reduce write overhead; ev-node does not rely
1524
// on Badger's multi-writer conflict checks for correctness.
1625
opts.Options = opts.WithDetectConflicts(false)

0 commit comments

Comments
 (0)