config: default TrickleDelay to 1ms if non-positive
What changed, and why it matters
This commit changes LND's configuration validation so that if a user sets the 'TrickleDelay' option to zero or a negative number, it is automatically reset to 1 millisecond. TrickleDelay controls how long the node waits before sending out batched gossip messages to peers. A zero or negative delay could break the trickle timer, likely causing messages to be sent continuously or the timer logic to fail. The fix is defensive: it prevents a misconfiguration from disabling or overloading the gossip trickle mechanism.
Treat as a low-severity hardening fix. Review whether TrickleDelay=0 or negative values could previously cause resource exhaustion or gossip storms, and consider whether the default should be the existing positive default rather than 1ms. No urgent action required unless the trickle timer is confirmed to misbehave with zero/negative values in production.
Security signals we found
Input validation/defaulting for a timing configuration parameter
Prevents non-positive timer interval that could disable or overload gossip trickling
No explicit security framing by the vendor in commit message or diff
Test added only validates the defaulting expression, not full ValidateConfig integration
Evidence from the diff
In ValidateConfig, a new check is added: if cfg.TrickleDelay <= 0, it is defaulted to 1 ms and an info log is emitted. The accompanying test duplicates this logic rather than calling ValidateConfig directly. The change is a hardening/defaulting patch, not a full refactor of the trickle timer. It does not alter behavior for positive values.
Changed components
lnd config validation (config.go ValidateConfig)gossip trickle timer interval (TrickleDelay)Inspect captured patch +65 / −0
diff --git a/config.go b/config.go
index e9ce410..d5f4a90 100644
--- a/config.go
+++ b/config.go
@@ -1819,6 +1819,15 @@ func ValidateConfig(cfg Config, interceptor signal.Interceptor, fileParser,
return nil, mkErr("unable to parse node color: %v", err)
}
+ // Validate TrickleDelay and default to 1ms if non-positive to ensure
+ // the trickle timer can still function.
+ if cfg.TrickleDelay <= 0 {
+ srvrLog.Infof("TrickleDelay is non-positive (%v ms), "+
+ "setting to 1ms", cfg.TrickleDelay)
+
+ cfg.TrickleDelay = 1
+ }
+
// All good, return the sanitized result.
return &cfg, nil
}
diff --git a/config_test.go b/config_test.go
index 7655807..e287b59 100644
--- a/config_test.go
+++ b/config_test.go
@@ -117,3 +117,59 @@ func TestSupplyEnvValue(t *testing.T) {
})
}
}
+
+// TestValidateConfigTrickleDelay tests that the TrickleDelay configuration
+// is properly validated and defaulted in ValidateConfig. This test directly
+// verifies the validation logic without going through the full ValidateConfig
+// function which has many dependencies.
+func TestValidateConfigTrickleDelay(t *testing.T) {
+ t.Parallel()
+
+ tests := []struct {
+ name string
+ trickleDelay int
+ expectedDelay int
+ }{
+ {
+ name: "zero delay defaults to 1ms",
+ trickleDelay: 0,
+ expectedDelay: 1,
+ },
+ {
+ name: "negative delay defaults to 1ms",
+ trickleDelay: -1000,
+ expectedDelay: 1,
+ },
+ {
+ name: "positive delay unchanged",
+ trickleDelay: 5000,
+ expectedDelay: 5000,
+ },
+ {
+ name: "minimum valid delay (1ms)",
+ trickleDelay: 1,
+ expectedDelay: 1,
+ },
+ }
+
+ for _, tc := range tests {
+ t.Run(tc.name, func(t *testing.T) {
+ // Create a config with the test's TrickleDelay.
+ cfg := Config{
+ TrickleDelay: tc.trickleDelay,
+ }
+
+ // Simulate the validation logic from ValidateConfig.
+ if cfg.TrickleDelay <= 0 {
+ cfg.TrickleDelay = 1
+ }
+
+ // Verify the TrickleDelay was set to the expected
+ // value.
+ require.Equal(
+ t, tc.expectedDelay, cfg.TrickleDelay,
+ "TrickleDelay mismatch",
+ )
+ })
+ }
+}
Why this scored 32/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.