Skip to content

perf(experimental): activate reckless-by-default IBD and harden the switch-off - #1

Merged
nullPointerEnjoyer merged 24 commits into
experimental/ibd-and-indexer-performancefrom
perf/ibd-reckless-activation-delta
Nov 13, 2026
Merged

nullPointerEnjoyer merged 24 commits into
experimental/ibd-and-indexer-performancefrom
perf/ibd-reckless-activation-delta

Conversation

@nullPointerEnjoyer

Copy link
Copy Markdown
Owner

Problem

--enable-db-reckless-mode-in-ibd and the other boolean CLI options used ArgAction::SetTrue on Option<bool>. clap materializes Some(false) for an absent flag, so:

  • the daemon's reckless-by-default IBD behavior (runner.rs) was unreachable: every flagless start looked like an explicit opt-out, keeping db fsync per commit during IBD (measured: commit stage 18.6 ms/block, ~76% of IBD wall time)
  • config-file values for these options were silently overridden (options.X.or(config_X) always saw Some(false))

Master is unaffected: it has no daemon default-on, so the old flag semantics are coherent there as an opt-in.

Changes

  • ArgAction::Set with value_name = "true|false" on every Option<bool> option (absence yields None, so config file / env can take precedence)
  • migrated in-repo bare-flag callers (functional tests, build-tools) to explicit =true
  • CHANGELOG notes under [Unreleased] (breaking: value-less boolean flags and bare ML_* env vars no longer parse; they require an explicit true/false)
  • regression tests: clap layer (absent → None, explicit values, bare flag rejected), env-var layer (valid/invalid values), and an end-to-end clap→config-merge test whose config value differs from the buggy materialized default (fails without the fix)
  • switch-off hardening: the reckless-mode counter is decremented before consuming the set-once IBD flag, so a failed forced db sync is retried on the next tip update; the LMDB switch-off always force-syncs (idempotent); counter underflow recovers with a warning instead of panicking in debug builds
  • a fail-once storage-mock test pins the retry path; the runner logs the default-on activation with the opt-out syntax

Measured impact (full mainnet sync to 725,000, same host and protocol as the earlier A/B runs)

run reckless during IBD time rate
baseline off (bug) 20,034s (5h34m) 36.2 blk/s
this branch on 5,164s (1h26m) 140.4 blk/s

Cumulative stage wall at 725k blocks: 24.70 → 6.65 ms/block (commit 18.62 → 0.48 ms/block; connect unchanged at ~6 ms/block). The switch-off was exercised in vivo on catch-up to a fresh tip: reckless mode disabled, forced sync ok.

Testing

cargo test -p node-lib (21 unit + 3 integration), -p chainstate (51), -p chainstate-test-suite (454) — all green.

@nullPointerEnjoyer

Copy link
Copy Markdown
Owner Author

CI status

CI had never run on this branch series (the base experimental branch had zero workflow runs), so enabling it peeled through several layers of accumulated issues. All fixed on this branch; current state on 60bd6e1d:

check status
static_checks (ubuntu / macos / windows): fmt, cargo-deny, cargo-vet, clippy (all-targets + production), codecheck.py, wasm docs ✅ pass on all three
build_ubuntu: cargo test --release --workspace --features trezor,ledger ✅ pass (1h13m)
build_macos / build_windows ⏳ queued (runner availability on the fork; macOS passed on the prior commit, windows static checks pass)
wasm build+test, loom, ledger/trezor suites ✅ pass

What CI surfaced and this PR fixes (all pre-existing on the series — the code had never been compiled with -D warnings or run as a workspace):

  • rustfmt: 195 violations across the workspace.
  • cargo-deny: missing RUSTSEC-2026-0441 (pin-utils, unmaintained) ignore + tokio 1.50.0 with the AsyncFd unsoundness advisory → tokio bumped to 1.51.6, matching master.
  • cargo-vet: supply-chain state was months stale → refreshed imports, audits aligned with master, syn/libc pinned to master's exact versions.
  • clippy (all-targets): wallet-controller's test mock didn't implement the get_block_tx_fees trait method (workspace didn't compile); 10 findings in chainstate/src/detail (useless conversions, needless tail returns, one match that discarded its value via a stray ;); 16 in scanner-lib (needless borrows, unused imports, #[allow]s for the argument-heavy scanner helpers).
  • clippy (production): unwrap_used on lock acquisitions → poisoned-lock recovery via unwrap_or_else(|e| e.into_inner()) (consistent with the existing Drop-path handling; the memo caches are re-verified by design); float_arithmetic → allowed on the two instrumentation-only report functions; items_after_statements → consts moved to module scope.
  • codecheck.py: 4 experimental files missing license headers.
  • workspace tests: rpc_docs was out of date (the tx-fee RPCs had never been documented) → regenerated docs/RPC.md; get_utxos_batch_semantics never initialized its storage and asserted a spent-height semantics that neither reader (including master's get_utxo) implements → setup added and the assertion reworked to the test's own contract (batch agrees with the single fetch; the newest row's payload wins).
  • stack test scanner_reconnects_after_node_disconnection: the mock node RPC server predated the scanner-fees feature and served only four methods, so the scanner spun in MethodNotFound retries until the tip timeout → registered chainstate_get_block_tx_fees (named params, chainstate namespace prefix) and mempool_get_fee_rate_points.

Verified locally before pushing: full-workspace clippy (both passes) clean; the containerized suites green (postgres 8/8, stack in_memory 115, mempool_bridge_reconnect, postgres_stream, scanner_reconnect); chainstate 51; node-lib 21+3.

@nullPointerEnjoyer
nullPointerEnjoyer merged commit 60bd6e1 into experimental/ibd-and-indexer-performance Nov 13, 2026
33 of 35 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.

1 participant