Skip to content

fix(sync): the explorer sync check runs on mainnet only - #51

Merged
MorningLightMountain713 merged 5 commits into
masterfrom
fix/sync-check-mainnet-only
Oct 27, 2026
Merged

MorningLightMountain713 merged 5 commits into
masterfrom
fix/sync-check-mainnet-only

Conversation

@MorningLightMountain713

@MorningLightMountain713 MorningLightMountain713 commented Oct 15, 2026 •

Copy link
Copy Markdown

Summary

The explorer sync check runs on mainnet only.

Check_Sync compares fluxd's height with explorer.runonflux.io and explorer.zelcash.online, which serve mainnet. On any other chain (testnet, labnet, regtest) the comparison always reads "not synced" — a labnet node at height 9569 against a network height of ~3,040,000 — and the fix action stops and starts a healthy fluxd.

On the cycles where the existing random skip lets the check run, the watchdog reads fluxd's chain from getblockchaininfo (chain: main, test, labnet, regtest) and runs the check only when the chain is main; on another chain it logs why the check is off. The chain is read every time the check would run, so a fluxd restarted on another chain is seen at its next check. An unreadable answer (fluxd not answering, still loading, output without a chain) is unknown, never mainnet, and the check does not run that cycle. Mainnet behaviour is unchanged.

  • fluxd_chain.js: fluxdChain(result) (the chain named by getblockchaininfo's output, or null), syncCheckApplies(chain) (mainnet only), and runSyncCheck (one cycle: the random skip, then the chain read and Check_Sync on mainnet).
  • watchdog.js: flux_check() calls runSyncCheck with the real roll, getblockchaininfo, Check_Sync and log.

Tests

  • test/fluxd_chain.test.js: the chain read for each network; empty, error text, an RPC error object, an empty or non-string chain, null, no stdout and no result are all unknown; the check applies on main only. Making syncCheckApplies accept any known chain, or defaulting an unknown chain to main, each fails a test.
  • runSyncCheck: a skip roll neither asks fluxd nor checks; a check roll on main checks; another chain logs and does not check; no answer does not check; a chain change between two cycles is followed. Removing the skip, asking before the roll, checking on any chain, treating no answer as mainnet, dropping the log, or keeping the first chain read each fails a test.
  • npm test 36 pass; eslint and prettier clean.

On nodes (at 30bb225)

Node Chain master this change
isotest10 (ArcaneOS, labnet) labnet 19:41 Flux daemon is not synced (9569, diff: 3030437) → systemctl stop fluxd.service / start; "not synced" again 19:49, 19:53 20:02 Sync check off: the explorers it compares with serve mainnet, and fluxd is on labnet; no sync line and no fluxd stop over the next four cycles
isotest9 (ArcaneOS, mainnet) main Flux daemon is synced (…) on the cycles it runs the same: synced (3040050) 20:02, synced (3040074) 20:14, random skips between

On nodes (at c532d2c)

🤖 Generated with Claude Code

@Cabecinha84 Cabecinha84 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack.

Minor nits (not blocking)

  1. The cached chain never expires. If a node's flux.conf switches between testnet and mainnet and fluxd is restarted
    while the watchdog keeps running, the old chain stays in memory until the watchdog restarts. On a testnet→mainnet
    switch the sync check would stay off. This is rare and the trade-off is reasonable. A one-line comment saying so
    would be enough.
  2. The repo has no CI. No checks run on the branch, so the green tests come only from the author's run and mine.
  3. The version bump was removed (the version is set at release). That is fine; just remember to bump the patch version
    when releasing.

@MorningLightMountain713

Copy link
Copy Markdown
Author
  1. The chain is now read each time the check would run (runSyncCheck in fluxd_chain.js), so a fluxd restarted on another chain is seen at its next check; nothing is kept between checks. Tests cover the skip roll, mainnet, another chain, no answer, and a chain change between two checks.
  2. CI added in ci: lint, format and tests run on every pull request and push to master #55: lint and format on Node 24, tests on Node 20 and 24.
  3. The version is set in one release commit after fix(sync): the explorer sync check runs on mainnet only #51, fix: update fluxd or fluxbench only when apt can install it #52 and fix(cloudui): the update runs in the background, a stopped update leaves nothing behind, and a missing version file is updated #54 merge.

The check compares fluxd's height with the Flux explorers, which serve
mainnet. On testnet, labnet or regtest it always read "not synced" and
restarted a healthy fluxd. The watchdog reads fluxd's chain once fluxd answers
and runs the check on mainnet alone; an unknown chain is not mainnet, so the
check waits for the answer rather than acting on a guess.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A fluxd restarted on another chain is seen at its next check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…uxd_chain.js, with tests

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@MorningLightMountain713
MorningLightMountain713 merged commit 6043e7c into master Oct 27, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants