You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
refactor(node): decompose the 1,857-line run() bring-up into ordered phase functions #1253
Runtime::run() (crates/node/src/runtime/mod.rs:437-2294) is a single ~1,857-line straight-line function carrying #[allow(clippy::cognitive_complexity, clippy::too_many_lines)] (mod.rs:436). It is the entire daemon bring-up plus a ~270-line manual teardown block (mod.rs:2017-2287), with the wiring state expressed as dozens of ad-hoc locals: 17 oneshot stop channels, 9 CancellationTokens, 12 tasks.spawn sites, and 15+ _c/_for_buyer Arc clones threaded between sections (e.g. mod.rs:1637-1651).
This is a legibility refactor, not a line-count one — the wiring itself is legitimate (no domain-logic duplication was found; runtime is thin adapters as intended).
Proposed shape
Split into ~5 phase functions with explicit inputs/outputs, e.g.:
identity / keystore / stores
chain providers + watchers
handlers + router
background tasks (GC runners, gossip, admin)
shutdown (the existing ordered teardown, kept verbatim)
Each phase returns a small struct of the handles the next phase needs, which turns today's implicit Arc-clone web into named, reviewable seams.
Constraints
Teardown ordering is load-bearing and must not change: admin_stop_order (mod.rs:2091), capacity-bond-watcher cancel after router (mod.rs:2116-2133), origin checkpoint flush (mod.rs:2064-2068), receipt-writer tail-drain, timeout abort backstops.
Activity
refactor(node): await the run() phases directly, drop now-vestigial B…