!5332fix/base-200ms-block-time-denim → develop176f15143c

BASE block-time constant: 2000ms → 200ms

AI-generatedEverything on this page was written by an AI agent from the diff: the summaries, the narration, the diagrams, the flags and the glossary. It can be wrong or incomplete, so check it against the code before you rely on it.

2commits
4files
44lines changed
16lines to read
2s→200msBASE block time
3.22.0coordinated rollout

Where the diff is

Where the block time goes

3-minute explainer

What changed

Who moves

Quotes, TxStatus, tools/events and mocknet move; production bifrost does not.

production bifrostno changeQuoteSwap24s → 2sTxStatus, events÷ 10mocknet bifrost2s → 200ms

Consensus

The function has no ctx, so only the binary can gate it.

200QuoteSwapcontractAppHash

Contract-visible value

12 × 200 / 1000 truncates to 2, not 2.4.

confirmations (unchanged)12seconds before24seconds after2

Mocknet fallback

The 0s override now means 200ms on 3s blocks.

assumed block2s → 200msreal block3sgate flip45 min → 7.5 hsolvency poll2s → 200ms

Tests

Reverting fails three packages; one test name and two comments are stale.

200 passes (ran)2000 fails (ran)

Look here first

Unconditional constant reaches consensusNo ctx or version gate. Contracts can read QuoteSwap's seconds, so mixed binaries can diverge; ship only at one coordinated height.chain.go:654 ↗verify
645+ //
646+ // CONSENSUS: this is NOT bifrost-only. QuoteSwap is wasm-whitelisted
647+ // (app/wasm.go), and querier_quotes.go derives the contract-visible
648+ // InboundConfirmationSeconds from this value, so a CosmWasm contract can read it
649+ // during tx execution — a 24s BASE quote becomes 2s. Changing it is therefore a
650+ // consensus-visible change and must activate coordinated (all nodes switch at one
651+ // height, e.g. the 3.22.0 upgrade), NOT via an uncoordinated rolling patch, or
652+ // old and new binaries can diverge on an AppHash. (bifrost's own consumers —
653+ // health gate, resume-lag, confirmation waits — are off-chain and want 200 now.)
654+ return 200
641655 case TRONChain:
642656 return 3_000
643657 case XRPChain:
644658 return 4_000 // approx 3-5 seconds
645659 case NOBLEChain:
646660 return 1_500
647661 case SOLChain:
648662 // Measured mainnet p50 214ms (range 209-220) over 30 getRecentPerformanceSamples
649663 // on 2026-10-27; was 400, then 300 (SIMD-0525). Solana slot time keeps falling,
650664 // so this hardcoded default WILL go stale again — bifrost reads the live value
651665 // from the MimirKeySOLSlotMilliseconds vote at the keysign height and only falls
652666 // back here when it is unset. Non-consensus: outside bifrost this feeds only the
653667 // read-only quote/confirmation ETA queriers, never a state transition.
BASE quote falls 24s to 2sInteger division gives 2, not the description's 2.4. TotalSwapSeconds moves too. Scanner also waits for safe head, so real delay is longer; unmeasured.chain.go:649 ↗verify
640+ // Base's Denim upgrade (2026-11-05 18:00 UTC) cut the canonical block time from
641+ // 2s to ~0.2s. The old 2_000 over-stated the per-block duration by 10x, so
642+ // bifrost's scanner health gate (blockscanner.go: lagDuration =
643+ // (chainHeight-currentBlock)*ms) read a caught-up scanner as 10x further behind
644+ // than it was and tripped it unhealthy, so no node would sign BASE.
645+ //
646+ // CONSENSUS: this is NOT bifrost-only. QuoteSwap is wasm-whitelisted
647+ // (app/wasm.go), and querier_quotes.go derives the contract-visible
648+ // InboundConfirmationSeconds from this value, so a CosmWasm contract can read it
649+ // during tx execution — a 24s BASE quote becomes 2s. Changing it is therefore a
650+ // consensus-visible change and must activate coordinated (all nodes switch at one
651+ // height, e.g. the 3.22.0 upgrade), NOT via an uncoordinated rolling patch, or
652+ // old and new binaries can diverge on an AppHash. (bifrost's own consumers —
653+ // health gate, resume-lag, confirmation waits — are off-chain and want 200 now.)
654+ return 200
641655 case TRONChain:
642656 return 3_000
643657 case XRPChain:
644658 return 4_000 // approx 3-5 seconds
645659 case NOBLEChain:
646660 return 1_500
647661 case SOLChain:
648662 // Measured mainnet p50 214ms (range 209-220) over 30 getRecentPerformanceSamples
Mocknet now assumes 200ms on 3s blocksCompose sets the override to 0s, so it falls back here. Health gate relaxes to 7.5h; solvency runner polls at 200ms. Compose line 266 unchanged.config_test.go:309 ↗careful
301301 _ = os.Unsetenv(k)
302302 }
303303 }(k, original, set)
304304 }
305305
306306 Init()
307307 bf := GetBifrost()
308308 c.Check(bf.Chains.BASE.BlockScanner.ApproximateBlockTime, Equals, time.Duration(0))
309− c.Check(bf.Chains.BASE.BlockScanner.ApproximateBlockMilliseconds(), Equals, int64(2_000))
309+ c.Check(bf.Chains.BASE.BlockScanner.ApproximateBlockMilliseconds(), Equals, int64(200))
310310 c.Check(bf.Chains.ETH.BlockScanner.ApproximateBlockTime, Equals, 12*time.Second)
311311 }
312312
313313 func (Test) TestInitSetsListenAddresses(c *C) {
314314 // Reset config to clear any previously set listen addresses
315315 config = Config{}
316316 Init()
317317
318318 tn := GetThornode()
319319 c.Assert(tn.Tendermint.RPC.ListenAddress, Not(Equals), "")
320320 c.Assert(strings.Contains(tn.Tendermint.RPC.ListenAddress, "tcp://"), Equals, true)
321321 c.Assert(tn.Tendermint.P2P.ListenAddress, Not(Equals), "")
322322 c.Assert(strings.Contains(tn.Tendermint.P2P.ListenAddress, "tcp://"), Equals, true)
Stale comments outside the diffdefault.yaml:263-268 and config_test.go:261 still say the constant is 2s. The override is now redundant; its note says remove it.config_test.go:233 ↗look
225225 chains := bf.GetChains()
226226 c.Assert(len(chains) > 0, Equals, true)
227227 }
228228
229229 func (Test) TestApproximateBlockMilliseconds(c *C) {
230230 // unset: falls back to the chain constant
231231 sc := BifrostBlockScannerConfiguration{ChainID: common.BASEChain}
232232 c.Check(sc.ApproximateBlockMilliseconds(), Equals, common.BASEChain.ApproximateBlockMilliseconds())
233− c.Check(sc.ApproximateBlockMilliseconds(), Equals, int64(2_000))
233+ c.Check(sc.ApproximateBlockMilliseconds(), Equals, int64(200))
234234
235235 // set: the override wins over the chain constant
236236 sc.ApproximateBlockTime = 200 * time.Millisecond
237237 c.Check(sc.ApproximateBlockMilliseconds(), Equals, int64(200))
238238
239239 // explicit zero, negative and sub-millisecond values are treated as unset, so
240240 // callers that divide by the result never see 0
241241 for _, d := range []time.Duration{0, -time.Second, 500 * time.Microsecond} {
242242 sc.ApproximateBlockTime = d
243− c.Check(sc.ApproximateBlockMilliseconds(), Equals, int64(2_000), Commentf("override %s", d))
243+ c.Check(sc.ApproximateBlockMilliseconds(), Equals, int64(200), Commentf("override %s", d))
244244 }
245245
Test named Unhealthy asserts healthyBody now expects healthy at the same gap. The name says the opposite; rename it.blockscanner_extra_test.go:1125 ↗look
1121−// show the bifrost-side override, not the (consensus-visible) common constant, is
1122−// what fixes the health gate.
1118+// TestBaseScannerHealthyAfterDenim. Before the BASE block-time constant was fixed,
1119+// a scanner with no bifrost override fell back to common.BASEChain's stale 2000ms
1120+// constant and read UNHEALTHY, and the bifrost override was the stopgap. Now that
1121+// the consensus-visible constant is 200, the same no-override scanner falls back to
1122+// 200 and reads HEALTHY: fixing the constant removes the need for the override on
1123+// the health gate (the override still governs the other windows — see
1124+// TestMaxResumeLagBlocksUsesBlockTimeOverride).
11231125 func (s *BlockScannerExtraSuite) TestBaseScannerUnhealthyWithoutBlockTimeOverride(c *C) {
1124− c.Assert(common.BASEChain.ApproximateBlockMilliseconds(), Equals, int64(2_000))
1125− c.Check(s.scanBaseAtDenimGap(c, 0), Equals, false)
1126+ c.Assert(common.BASEChain.ApproximateBlockMilliseconds(), Equals, int64(200))
1127+ c.Check(s.scanBaseAtDenimGap(c, 0), Equals, true)
11261128 }
11271129
11281130 // TestMaxResumeLagBlocksUsesBlockTimeOverride checks the resume-lag window is
11291131 // sized from the ApproximateBlockTime override when set, and from the chain
11301132 // constant otherwise.
11311133 func (s *BlockScannerExtraSuite) TestMaxResumeLagBlocksUsesBlockTimeOverride(c *C) {
11321134 b := &BlockScanner{cfg: config.BifrostBlockScannerConfiguration{
11331135 ChainID: common.BASEChain,
11341136 MaxResumeBlockLag: time.Hour,
Tests pin the constant onlyReverting fails common, config and blockscanner (ran). Nothing asserts the quote seconds; the description lists only two of the four files.chain_test.go:85 ↗look
7676
7777 // Test ApproximateBlockMilliseconds
7878 c.Assert(NOBLEChain.ApproximateBlockMilliseconds(), Equals, int64(1500))
7979 c.Assert(GAIAChain.ApproximateBlockMilliseconds(), Equals, int64(6000))
80+// Base's Denim upgrade (2026-11-05) cut the block time from 2s to ~0.2s. This
81+// constant is consensus-visible (QuoteSwap derives InboundConfirmationSeconds
82+// from it), so it must track the live rate and activate coordinated at 3.22.0.
83+// Bifrost's own scanner reads block time through a node-local override, not this
84+// constant.
85+c.Assert(BASEChain.ApproximateBlockMilliseconds(), Equals, int64(200))
8086
8187 // Test InboundNotes
8288 c.Assert(NOBLEChain.InboundNotes(), Equals, "Transfer the inbound_address the asset with the memo. Do not use multi-in, multi-out transactions.")
8389 c.Assert(GAIAChain.InboundNotes(), Equals, "Transfer the inbound_address the asset with the memo. Do not use multi-in, multi-out transactions.")
8490
8591 // Tron chain tests
8692 tronGasUnits, _ := TRONChain.GetGasUnits()
8793 c.Assert(tronGasUnits, Equals, "sun")
8894 c.Assert(TRONChain.GetGasAssetDecimal(), Equals, int64(6))
8995 c.Assert(TRONChain.ApproximateBlockMilliseconds(), Equals, int64(3000))
9096
9197 // TAO chain tests
9298 c.Assert(TAOChain.GetGasAsset(), Equals, TAOAsset)

Ask an AI about this change

Chat assistantClaude, ChatGPT, … (reads a link)

Coding agentClaude Code, Cursor, … (reads the repo)

The context file is context.md. Use Copy with context for an AI that can't open links; it pastes the whole file in.

Glossary

AppHash
The hash of chain state that validators agree on. Nodes computing different results diverge.
ApproximateBlockTime
Node-local bifrost override of block time, approximate_block_time in config. 0s falls back to the common constant. config/config.go ↗
Denim
Base's upgrade of 2026-11-05 that, per this MR, cut block time from 2s to about 0.2s.
MaxHealthyLag
Config max_healthy_lag, 30m by default. The scanner reads unhealthy once estimated lag reaches this. blockscanner.go ↗
Mocknet
The docker-compose test network. Its BASE mines every 3s and it sets the override to 0s. docker-compose.yml ↗
QuoteSwap
The swap quote query. It is whitelisted for CosmWasm, so contracts can read its result during tx execution. app/wasm.go ↗
Safe head
The newest L2 block labelled safe. BASE's scanner follows it, which adds lag the 12 confirmations don't count. querier_quotes.go ↗
Solvency runner
Bifrost's periodic solvency check loop. Its backoff follows the block time bifrost assumes, including mocknet's. evm/client.go ↗