Skip to content

fix: network-selection safety — flag chimera, anchor sanity gate, per-network gateway, t-address prefix - #145

Merged
Reiers merged 1 commit into
mainfrom
fix/network-selection-safety
Jul 23, 2026
Merged

fix: network-selection safety — flag chimera, anchor sanity gate, per-network gateway, t-address prefix#145
Reiers merged 1 commit into
mainfrom
fix/network-selection-safety

Conversation

@Reiers

@Reiers Reiers commented Jul 23, 2026

Copy link
Copy Markdown
Owner

Found live while standing up a calibration node (2026-07-23). Full story in the commit message; short version:

1. init --network calibration built a mainnet/calibration chimera

init/doctor's --network meant F3 wire name, while daemon/beacon/auth's --network means Filecoin network. The obvious command produced: mainnet data dir + mainnet bootstrap sources + /f3/certexch/get/1/calibration protocol probes + f-prefixed wallet + a wrong-network trust anchor written with '✓ Quorum reached'. Filecoin-network values via --network are now interpreted as --filecoin-network (shared resolveNetworkFlags).

2. Anchor sanity gate (the scary one)

The chimera anchored to an F3 cert 392k epochs (~136 days) behind wall-clock and still claimed success. Epochs are wall-clock scheduled, so expected-head is computable from genesis alone. init now refuses anchors >2880 epochs from expected (--allow-stale-anchor to override). New build.Network.GenesisUnix() / .ExpectedHeadEpoch() + test pinned to live head observations from both networks.

3. Wrong-network gateway poisoned the calibration fetch chain

The MAINNET gateway was raced into every network's fetch chain. On calibration each cold fetch burned the gateway's race timeout first: live effect was WalletBalance timing out >60s on a synced node. Calibration now disables the default gateway (explicit --gateway honored); fetch chain skips the source when unset.

4. f-prefix addresses on calibration

address.CurrentNetwork was never set. Calibration wallets printed f3...; faucets/explorers expect t3.... daemon + init now set the prefix per network (lotus behavior).

Evidence

  • Chimera + stale anchor: session log, anchor epoch 5824156 vs expected ~6217000 (mainnet) / 3916334 (calibration) — matched neither
  • Post-fix: correct init writes data/calibration/bootstrap-anchor.json at epoch 3916341 (live calibration head)
  • go build ./... && go vet && go test -short ./cmd/lantern ./build green

… per-network gateway + address prefix

Four related footguns found while standing up a calibration node on the
cluster (2026-07-23):

1. CLI flag chimera: daemon/beacon/auth use --network for the FILECOIN
   network, but init/doctor used --network for the F3 wire name.
   'lantern init --network calibration' produced a mainnet data dir +
   mainnet bootstrap sources + a 'calibration' F3 protocol name, and
   wrote a WRONG-NETWORK trust anchor claiming success. init/doctor now
   interpret filecoin-network values passed via --network as
   --filecoin-network (resolveNetworkFlags, shared).

2. No anchor sanity gate: the chimera above anchored to an F3 cert
   ~392k epochs (~136 days) behind the wall-clock expected head and
   still declared quorum success. Filecoin epochs are wall-clock
   scheduled, so the expected epoch is computable from genesis time
   alone: init now refuses to write an anchor >2880 epochs (24h) from
   expected (--allow-stale-anchor overrides). build.Network gains
   GenesisUnix() + ExpectedHeadEpoch() with a unit test pinned to live
   observations from both networks.

3. Wrong-network gateway poisoning: the daemon raced the MAINNET
   gateway into the fetch chain on every network. On calibration each
   cold-block fetch burned the gateway's full race timeout before a
   correct source was tried, starving state reads (WalletBalance timed
   out >60s live). Calibration now disables the default gateway
   (explicit --gateway still honored) and the fetch chain skips the
   gateway source when unset.

4. Address prefix: address.CurrentNetwork was never set, so calibration
   nodes printed f-prefixed addresses. Faucets/explorers on calibration
   expect t-prefix. daemon + init now set the prefix from the network
   (matching lotus).
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.

1 participant