fix(#123): --devnet-head-poll-interval knob + auto-match block cadence (findings 8+9)#127
Merged
Merged
Conversation
Closes lantern#123 findings 8+9. On a single-node docker devnet the gossipsub mesh can't form, so ChainHead + eth_blockNumber arrive ONLY via the RPC-fallback poll. The mainnet-oriented 30s cadence set by startGossipHead (and its cmd/lantern twin) is 7.5x block-time on a 4s-epoch devnet, so head trails live by ~80 epochs = ~320s at all times \u2014 breaks any timing-sensitive consumer (curio schedulers, proving-window logic, latency-sensitive read-your-write patterns). On devnet, the daemon now derives the effective poll interval from build.GetDevnetConfig().BlockDelaySecs (captured at devnet-init time by #125), falling back to 4s if the config is absent or older than #125. Operators can override with --devnet-head-poll-interval (CLI) or Config.DevnetHeadPollInterval (embedded). Mainnet + calibration paths are untouched: the gossip-primary logic (30s catch-up cadence when libp2p is enabled) still runs; only when network == build.Devnet does the derivation fire. Applied to both consumer paths: - cmd/lantern/main.go (standalone `lantern daemon` CLI) - pkg/daemon/start.go (embedded consumers like curio-core) Live smoke, curio-fork docker devnet at height 17798+: Cold-boot head lag (default, sync every 4s): t=10s lotus=17798 lantern=17794 lag= 4 epochs t=30s lotus=17803 lantern=17796 lag= 7 epochs t=60s lotus=17810 lantern=17803 lag= 7 epochs With --devnet-head-poll-interval 2s (user override honored): Boot log: "header store: ... (sync every 2s, buf=64)" Pre-fix baseline (from #123 finding 8+9): ~80 epochs sustained. Full suite: go test ./... reports 52 packages ok, no failures.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes the last two findings from #123:
ChainHeadandeth_blockNumberhead lag on single-node docker devnet.The problem
On a single-node docker devnet the gossipsub mesh can't form (no peers), so
ChainHeadandeth_blockNumberarrive ONLY via the RPC-fallback poll. The mainnet-oriented 30s cadence set bystartGossipHead(and its cmd/lantern twin) is 7.5x block-time on a 4s-epoch devnet, so head trails live by ~80 epochs = ~320s at all times. Breaks any timing-sensitive consumer (curio schedulers, proving-window logic, latency-sensitive read-your-write patterns).The fix
On devnet, the daemon derives the effective poll interval from
build.GetDevnetConfig().BlockDelaySecs(captured at devnet-init time by #125), falling back to 4s if the config is absent or predates #125.--devnet-head-poll-interval(cmd/lantern) — zero means auto (derive from config), nonzero overrides.Config.DevnetHeadPollInterval(pkg/daemon) — same semantics for consumers like curio-core.Both consumer paths gated on
network == build.Devnet. Mainnet + calibration paths untouched.Live evidence
Curio-fork docker devnet at height 17798+, tested via alternating
Filecoin.ChainHeadon lotus (127.0.0.1:1234) vs Lantern (127.0.0.1:2348):Cold boot, default (sync every 4s from BlockDelaySecs):
Sustained lag: 4-7 epochs. Pre-fix baseline (from #123 finding 8+9): ~80 epochs sustained.
With user override
--devnet-head-poll-interval 2s:Boot log confirms:
header store: ... (sync every 2s, buf=64). Lag stays in 5-8 epochs; the remaining floor comes from other Sync knobs (BootstrapDepth,MaxBacktrack), not poll interval. Poll cadence itself is the correct value.Blast radius
BlockDelaySecs): fall back to 4s, still 7.5x better than pre-fix.Tests
No new unit tests: the change is a single conditional on
network == build.Devnetgating a derived value, and existing devnet-init tests already cover theBlockDelaySecsfield.go test ./...reports 52 packages ok.What's left from #123 followups
cmd/lanternmpool wiring baseline (pre-existing gap discovered during fix(#123): close all ten devnet RPC parity gaps against local Curio devnet #125 smoke).