Skip to content

Commit 360499b

Browse files
authored
feat: make reaper poll duration configurable (#2951)
<!-- Please read and fill out this form before submitting your PR. Please make sure you have reviewed our contributors guide before submitting your first PR. NOTE: PR titles should follow semantic commits: https://www.conventionalcommits.org/en/v1.0.0/ --> ## Overview Enable reaper poll interval to be configurable to help reduce E2E tx latency <!-- Please provide an explanation of the PR, including the appropriate context, background, goal, and rationale. If there is an issue with this information, please provide a tl;dr and link the issue. Ex: Closes #<issue number> -->
1 parent 66b491b commit 360499b

File tree

7 files changed

+10
-6
lines changed

7 files changed

+10
-6
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
coverage.txt
2+
*.out
23
proto/pb
34
proto/tendermint
45
types/pb/tendermint

block/components.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ func NewAggregatorComponents(
227227
logger,
228228
executor,
229229
cacheManager,
230-
reaping.DefaultInterval,
230+
config.Node.ScrapeInterval.Duration,
231231
)
232232
if err != nil {
233233
return nil, fmt.Errorf("failed to create reaper: %w", err)

block/internal/reaping/reaper.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,8 @@ import (
1919
)
2020

2121
const (
22-
// DefaultInterval is the default reaper interval
23-
DefaultInterval = 1 * time.Second
2422
// MaxBackoffInterval is the maximum backoff interval for retries
2523
MaxBackoffInterval = 30 * time.Second
26-
// BackoffMultiplier is the multiplier for exponential backoff
27-
BackoffMultiplier = 2
2824
)
2925

3026
// Reaper is responsible for periodically retrieving transactions from the executor,

node/helpers_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ func getTestConfig(t *testing.T, n int) evconfig.Config {
9999
BlockTime: evconfig.DurationWrapper{Duration: 100 * time.Millisecond},
100100
MaxPendingHeadersAndData: 1000,
101101
LazyBlockInterval: evconfig.DurationWrapper{Duration: 5 * time.Second},
102+
ScrapeInterval: evconfig.DurationWrapper{Duration: time.Second},
102103
},
103104
DA: evconfig.DAConfig{
104105
BlockTime: evconfig.DurationWrapper{Duration: 200 * time.Millisecond},

pkg/config/config.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ const (
4949
FlagReadinessWindowSeconds = FlagPrefixEvnode + "node.readiness_window_seconds"
5050
// FlagReadinessMaxBlocksBehind configures how many blocks behind best-known head is still considered ready
5151
FlagReadinessMaxBlocksBehind = FlagPrefixEvnode + "node.readiness_max_blocks_behind"
52+
// FlagScrapeInterval is a flag for specifying the reaper scrape interval
53+
FlagScrapeInterval = FlagPrefixEvnode + "node.scrape_interval"
5254
// FlagClearCache is a flag for clearing the cache
5355
FlagClearCache = FlagPrefixEvnode + "clear_cache"
5456

@@ -203,6 +205,7 @@ type NodeConfig struct {
203205
MaxPendingHeadersAndData uint64 `mapstructure:"max_pending_headers_and_data" yaml:"max_pending_headers_and_data" comment:"Maximum number of headers or data pending DA submission. When this limit is reached, the aggregator pauses block production until some headers or data are confirmed. Use 0 for no limit."`
204206
LazyMode bool `mapstructure:"lazy_mode" yaml:"lazy_mode" comment:"Enables lazy aggregation mode, where blocks are only produced when transactions are available or after LazyBlockTime. Optimizes resources by avoiding empty block creation during periods of inactivity."`
205207
LazyBlockInterval DurationWrapper `mapstructure:"lazy_block_interval" yaml:"lazy_block_interval" comment:"Maximum interval between blocks in lazy aggregation mode (LazyAggregator). Ensures blocks are produced periodically even without transactions to keep the chain active. Generally larger than BlockTime."`
208+
ScrapeInterval DurationWrapper `mapstructure:"scrape_interval" yaml:"scrape_interval" comment:"Interval at which the reaper polls the execution layer for new transactions. Lower values reduce transaction detection latency but increase RPC load. Examples: \"250ms\", \"500ms\", \"1s\"."`
206209

207210
// Readiness / health configuration
208211
ReadinessWindowSeconds uint64 `mapstructure:"readiness_window_seconds" yaml:"readiness_window_seconds" comment:"Time window in seconds used to calculate ReadinessMaxBlocksBehind based on block time. Default: 15 seconds."`
@@ -337,6 +340,7 @@ func AddFlags(cmd *cobra.Command) {
337340
cmd.Flags().Duration(FlagLazyBlockTime, def.Node.LazyBlockInterval.Duration, "maximum interval between blocks in lazy aggregation mode")
338341
cmd.Flags().Uint64(FlagReadinessWindowSeconds, def.Node.ReadinessWindowSeconds, "time window in seconds for calculating readiness threshold based on block time (default: 15s)")
339342
cmd.Flags().Uint64(FlagReadinessMaxBlocksBehind, def.Node.ReadinessMaxBlocksBehind, "how many blocks behind best-known head the node can be and still be considered ready (0 = must be at head)")
343+
cmd.Flags().Duration(FlagScrapeInterval, def.Node.ScrapeInterval.Duration, "interval at which the reaper polls the execution layer for new transactions")
340344

341345
// Data Availability configuration flags
342346
cmd.Flags().String(FlagDAAddress, def.DA.Address, "DA address (host:port)")

pkg/config/config_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ func TestAddFlags(t *testing.T) {
6363
assertFlagValue(t, flags, FlagLazyBlockTime, DefaultConfig().Node.LazyBlockInterval.Duration)
6464
assertFlagValue(t, flags, FlagReadinessWindowSeconds, DefaultConfig().Node.ReadinessWindowSeconds)
6565
assertFlagValue(t, flags, FlagReadinessMaxBlocksBehind, DefaultConfig().Node.ReadinessMaxBlocksBehind)
66+
assertFlagValue(t, flags, FlagScrapeInterval, DefaultConfig().Node.ScrapeInterval)
6667

6768
// DA flags
6869
assertFlagValue(t, flags, FlagDAAddress, DefaultConfig().DA.Address)
@@ -107,7 +108,7 @@ func TestAddFlags(t *testing.T) {
107108
assertFlagValue(t, flags, FlagRPCEnableDAVisualization, DefaultConfig().RPC.EnableDAVisualization)
108109

109110
// Count the number of flags we're explicitly checking
110-
expectedFlagCount := 44 // Update this number if you add more flag checks above
111+
expectedFlagCount := 45 // Update this number if you add more flag checks above
111112

112113
// Get the actual number of flags (both regular and persistent)
113114
actualFlagCount := 0

pkg/config/defaults.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ func DefaultConfig() Config {
6868
Light: false,
6969
ReadinessWindowSeconds: defaultReadinessWindowSeconds,
7070
ReadinessMaxBlocksBehind: calculateReadinessMaxBlocksBehind(defaultBlockTime.Duration, defaultReadinessWindowSeconds),
71+
ScrapeInterval: DurationWrapper{1 * time.Second},
7172
},
7273
DA: DAConfig{
7374
Address: "http://localhost:7980",

0 commit comments

Comments
 (0)