You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(config): fail loudly on invalid or fractional numeric config (#24536)
## Human-written summary
Invalid numeric values in config were silently ignored and replaced with
the default. Also, config entries defined with `numberConfigHelper`
accepted non-integer values but silently truncated them.
## Context
The numeric config helpers mishandled bad input in two ways:
- `numberConfigHelper` / `optionalNumberConfigHelper` parsed with
`parseInt`, which silently truncated decimals — an integer config set to
`0.8` became `0` with no warning. In the worst case (A-1312) that turned
a fractional retention window into `0`, i.e. "delete immediately".
- `numberConfigHelper`, `floatConfigHelper` and `percentageConfigHelper`
swallowed any unparseable value and returned the config default (the
JSDoc even documented "...or is invalid"), so a typo'd env var ran
silently with an unexpected value.
## Approach
The config default is for an **unset** env var only — empty/unset is
already resolved to the default before `parseEnv` runs, so the only
thing `parseEnv` returning a default achieved was hiding bad input. The
helpers now parse strictly and throw on any set-but-invalid value:
- `numberConfigHelper` / `optionalNumberConfigHelper`: parse with
`parseFloat` and require a safe integer (no more silent truncation).
- `floatConfigHelper` / `percentageConfigHelper`: require a finite
number; percentage additionally enforces 0–1.
`bigint`, `enum` and the secret helpers already threw on invalid input.
`booleanConfigHelper` is intentionally unchanged: `parseBooleanEnv` is a
total function (unrecognized tokens map to `false`), it never
substitutes the configured default.
Auditing all ~150 `numberConfigHelper` call sites then surfaced options
that legitimately take fractional values and would now wrongly reject
them; these were moved to `floatConfigHelper`:
- p2p gossipsub tx scoring — topic weight, invalid-message-delivery
weight, and decay (default `0.5`), which feed libp2p's float
`TopicScoreParams`.
- sequencer `perBlockDAAllocationMultiplier` (default `1.5`); its
sibling `perBlockAllocationMultiplier` already used `floatConfigHelper`.
- L1 tx fee percentages — `gasLimitBufferPercentage`,
`priorityFeeBumpPercentage`, `priorityFeeRetryBumpPercentage`.
- bot `minFeePadding`, consumed as the fractional overpay factor `1 +
padding`; its zod schema no longer pins it to an integer.
## Impact
A node whose numeric config env var (or CLI flag) is set to a
non-numeric, fractional (for integer options), or out-of-range value now
fails at startup with a clear error instead of silently running with a
truncated or default value. Operators relying on the old lenient
behavior must correct the value.
Fixes A-1398
0 commit comments