Skip to content

refactor(node): micro-dedups — shared PruneGuard, EIP-712 domains computed once, provider factory in run() #1252

Closed

Description

@thiras

Three small, independent dedups (bundle or split as convenient; each is mechanical):

1. Shared PruneGuard

crates/node/src/dispatch.rs:266-273 and crates/node/src/rate_limit.rs:234-241 define an identical AtomicBool RAII prune-guard, with near-identical keyed-limiter prune-sweep logic around it. Share one guard (and the sweep shape if it falls out naturally). ~30 lines.

2. EIP-712 domains computed once

runtime/mod.rs run() re-derives the same signing domains with identical args at multiple sites: slash_judge_domain ×3 (mod.rs:673, 1012, 1613), voucher_domain ×2 (976, 1606), bind_node_id_domain ×2 (978, 1618). Compute each once and clone the handle.

3. Provider factory

ProviderBuilder::new().connect_http(rpc_url…) appears ×10 in run() (mod.rs:715, 725, 766, 908, 1044, 1230, 1382, 1836, …), mostly wrapped in with_poll_interval, in four variants (read-only / wallet / buyer-wallet / plain-head). A small factory with one constructor per variant removes the repetition and makes the poll-interval wiring single-sourced.

Combined ~60-80 prod lines; all low risk, no behavior change. Related contract-address parse blocks (×4, ~8 lines each, e.g. mod.rs:662-671) can ride along with the factory if convenient — note the zero-address guard follow-up in #1219 touches the same parse sites, so coordinate.

Activity

  1. added
    rust
    prio:low
    on Jul 17, 2026
  2. self-assigned this
    on Jul 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

prio:lowrust

Type

No type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions