Skip to content

refactor(node): dedupe runtime helpers (#1252) - #1274

Merged
thiras merged 6 commits into
mainfrom
refactor/1252-runtime-micro-dedups
Jul 18, 2026
Merged

thiras merged 6 commits into
mainfrom
refactor/1252-runtime-micro-dedups

Conversation

@altanoruc

@altanoruc altanoruc commented Jul 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • extract the duplicated panic-safe keyed-prune RAII reset into one shared PruneGuard
  • compute the slash, voucher, and node-binding EIP-712 domains once during runtime setup and reuse them
  • centralize HTTP provider construction by runtime role while preserving polling intervals and simple nonce management

Impact

This is a behavior-preserving mechanical cleanup that removes drift-prone runtime setup duplication. The provider-role regression test pins the deliberate shared-head polling exception and both wallet roles.

Validation

  • cargo test -p decdn-node -- --test-threads=1
  • cargo clippy -p decdn-node --all-targets -- -D warnings
  • cargo fmt -- --check
  • git diff --check

Closes #1252

Summary by CodeRabbit

  • Improvements
    • Enhanced runtime reliability so pruning single-flight behavior automatically resumes after unexpected interruptions.
    • Refined internal HTTP provider construction via a centralized factory while keeping the existing polling behavior for read-only, shared-head, seller, and buyer connections.
    • Added checks to ensure per-role polling policies remain consistent.
  • Documentation
    • Added new implementation plan and design spec for runtime “micro-deduplications” to guide and verify the reliability and refactor work.

@gemini-code-assist

Copy link
Copy Markdown

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@coderabbitai

coderabbitai Bot commented Jul 17, 2026 •

Copy link
Copy Markdown

Review Change Stack

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Free

Run ID: dceee0f3-2785-4927-9809-97ab1614dc06

📥 Commits

Reviewing files that changed from the base of the PR and between 42eef18 and c2367f7.

📒 Files selected for processing (2)
  • crates/node/src/lib.rs
  • crates/node/src/runtime/mod.rs
🚧 Files skipped from review as they are similar to previous changes (2)
  • crates/node/src/lib.rs
  • crates/node/src/runtime/mod.rs

Walkthrough

The runtime refactor centralizes panic-safe pruning, adds role-based provider construction, migrates runtime bootstraps, reuses EIP-712 domains through cloning, and documents the implementation and verification plan.

Changes

Runtime micro-deduplications

Layer / File(s) Summary
Runtime design and implementation plan
docs/superpowers/plans/..., docs/superpowers/specs/...
Documents the shared prune guard, EIP-712 domain reuse, provider factory, polling policies, and verification workflow.
Shared panic-safe prune guard
crates/node/src/lib.rs, crates/node/src/prune_guard.rs, crates/node/src/dispatch.rs, crates/node/src/rate_limit.rs
Moves PruneGuard into a crate-private module and reuses its Drop-based atomic reset from both limiter paths.
Role-based runtime providers and domain reuse
crates/node/src/runtime/mod.rs
Adds ProviderFactory, migrates runtime provider bootstraps, preserves polling and wallet behavior, reuses signing domains, and tests role-specific polling policies.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant RuntimeRun
  participant ProviderFactory
  participant AlloyProviders
  participant RuntimeWatchers
  participant WalletHandlers
  RuntimeRun->>ProviderFactory: construct role-specific providers
  ProviderFactory->>AlloyProviders: apply polling and wallet nonce configuration
  AlloyProviders-->>RuntimeRun: return configured providers
  RuntimeRun->>RuntimeWatchers: initialize read-only watcher providers
  RuntimeRun->>WalletHandlers: initialize seller and buyer wallet providers
Loading

Note

🎁 Summarized by CodeRabbit Free

Your organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login.

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Jul 17, 2026 •

Copy link
Copy Markdown

Coverage report

Total: 81.51% (was 81.47%, ▲ +0.04%) — 48882/59967 lines

File Coverage Lines Δ
crates/node/src/dispatch.rs 94.80% 583/615 ▼ 0.03%
crates/node/src/prune_guard.rs 100.00% 3/3 new
crates/node/src/rate_limit.rs 84.87% 202/238 ▼ 0.19%
crates/node/src/runtime/mod.rs 48.81% 1008/2065 ▲ +1.60%
History
Commit Total Δ vs base
d80979d 81.57% ▲ +0.04%
42eef18 81.67% ▲ +0.06%
c2367f7 (HEAD) 81.51% ▲ +0.04%

@altanoruc
altanoruc marked this pull request as ready for review July 18, 2026 04:25

Copy link
Copy Markdown
Contributor Author

Review: refactor(node): dedupe runtime helpers (#1252)

Tightly-scoped, behavior-preserving cleanup — the three dedups (shared PruneGuard, single-sourced EIP-712 domains, ProviderFactory) each read cleanly and map 1:1 onto the originals. The provider_factory_preserves_role_polling_policy test is the right call: it pins the deliberate shared-head exception (250 ms Alloy default) alongside the three overridden roles, so a future accidental "fix" that adds with_poll_interval to the head provider would fail loudly. prune_guard.rs lands at 100% coverage.

Two things before merge, then some nits.

🔴 Blocking — CI is red

markdownlint fails with 9 MD032/blanks-around-lists errors, all in docs/superpowers/plans/2026-07-17-issue-1252-runtime-micro-dedups.md (lines 25, 32, 63, 71, 98, 101, 150, 154, 260). Each is a list that starts immediately under a **Files:** / **Interfaces:** label with no blank line between; markdownlint requires a blank line before and after every list. The CI success gate is failing only because of this. Fix = insert a blank line between each bold label and the bullet list that follows.

🟡 Should these planning/spec docs be in the PR at all?

docs/superpowers/ doesn't exist on main — this PR introduces it, and the two files are 361 of the 481 added lines (~75% of the diff). They're agent-workflow scratch (the plan opens with "For agentic workers: REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development…"), and the repo's established home for design records is adr/ (per CLAUDE.md), not a new docs/ subtree.

Recommendation: drop both files from this PR — the Summary/Impact/Validation in the PR body already captures the intent, and keeping the refactor commit free of process scratch keeps git blame/history focused on the code. If the team does want implementation plans in-tree, that's a separate convention worth its own discussion, and at minimum they'd need to pass markdownlint (likely added to the lint ignore globs alongside .github/agents/**).

🟢 Nits (non-blocking)

  • ProviderFactory::seller_wallet and buyer_wallet are byte-identical — both just Self::wallet(url, signer, interval). The separate-instance requirement (independent nonce lanes) is already satisfied by calling wallet twice, so the two wrappers don't buy anything over calling wallet directly at the two sites. Either collapse them, or add a one-line doc noting they're intentionally kept apart so seller/buyer policy can diverge later. As written, the test's separate seller/buyer asserts are just restating wallet's single behavior.
  • Slightly stale comment above let node_origin_bind_domain = bind_domain; — it still reads "same construction as the serving-side bind_domain (:961) so an upstream verifies against an identical domain." Now that it's literally the same value (a move, not a re-derivation) the domains are identical by construction; worth a quick reword, and the hard-coded (:961) line reference will drift.

Assessment

The Rust changes are correct and low-risk: the clone-then-final-move ordering for the three domains is sound (compiles clean, clippy green), and the provider role mapping preserves poll intervals, simple nonce management, and separate instances. Once markdownlint is green and the docs question is settled, this is good to go.


Generated by Claude Code

claude and others added 3 commits July 18, 2026 08:07
Insert the blank line MD032 requires between each **Files:**/**Interfaces:**
label and the bullet list that follows it. Resolves the 9 markdownlint
errors (lines 25, 32, 63, 71, 98, 101, 150, 154, 260) that were failing
the `markdownlint` job — and the aggregate `CI success` gate — on #1274.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_014b9yLJ4z5UQPJgPdViwDum
…-micro-dedups

# Conflicts:
#	crates/node/src/runtime/mod.rs
The #1117 comment described `node_origin_bind_domain` as sharing "same
construction as" the serving-side `bind_domain` at line :961, but the
runtime dedup turned that into a direct value reuse (`= bind_domain`) and
the pointer had drifted (`bind_domain` is constructed at :813; :961 is
unrelated pull-through logic). Reword to reflect the reuse and drop the
brittle line number.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@thiras
thiras merged commit 109994c into main Jul 18, 2026
23 checks passed
@thiras
thiras deleted the refactor/1252-runtime-micro-dedups branch July 18, 2026 20:58
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.

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

3 participants