Skip to content

refactor: remove dead code and duplication in the node - #25

Merged
MehranMazhar merged 1 commit into
mainfrom
claude/refactor-node-fp5nae
Oct 6, 2026
Merged

MehranMazhar merged 1 commit into
mainfrom
claude/refactor-node-fp5nae

Conversation

@MehranMazhar

Copy link
Copy Markdown
Member

Requested by Mehran · project thread

📋 Description

Before: main.rs declared mod node itself, so the whole module tree compiled twice (once in the library, once in the binary). That second copy is why 13 #[allow(dead_code)] attributes were needed. The repo also held unused functions, two unused crates, copy-pasted RPC handlers and a few stray files.

After: the binary uses clutch_node::node::… from the library, the tree compiles once, and the build has zero warnings with no allow(dead_code) anywhere. 145 lines added, 305 removed.

What changed:

  • Removed unused code: Database::get_keys_by_cf_name, StateUpdate::from_legacy / from_legacy_vec, the async-trait crate and the direct tungstenite 0.24 crate. The node already uses tokio_tungstenite::tungstenite. The lockfile only loses entries.
  • websocket.rs: send_transaction and send_raw_transaction share one submit path. The five list_* methods share one list_response, and the three trip lists share one TripFilter. Error texts and response shapes are unchanged.
  • Transaction: sign, sign_personal and sign_tron share one sign_bytes. The signed bytes and verification are unchanged.
  • balance_effect.rs: the per-account index entries now serialize the records that were already built, instead of building the same struct a second time. The stored bytes are identical.
  • blockchain.rs:
    • Two doc comments had drifted onto the wrong function: validate_authorities and drop_intra_block_conflicts. They are back on the right ones.
    • Fixed a broken line continuation that put 14 spaces inside a panic message.
    • Developer mode now writes its JSON dump through one helper.
  • Sync handlers: dropped parameters they never used.
  • Deleted files:
    • sweep.timestamp, a cargo-sweep marker. It is now in .gitignore.
    • setup-protection.ps1, which only printed manual steps.
    • The root pull_request_template.md, a duplicate of .github/PULL_REQUEST_TEMPLATE.md.
    • examples/README.md, which listed four example files that never existed.

No RPC method, response field, wire or RLP format, signature scheme, state key or stored value changed, so this needs no chain reset. block_reward/reward_recipient in get_block_by_index are left in on purpose: the explorer may still read them.

🎯 Type of Change

  • 🔧 Refactoring

🧪 Testing

  • Unit tests pass (cargo test -- --test-threads=1: all suites green, the same command CI runs)
  • cargo build --all-targets with zero warnings

✅ Checklist

  • I have performed a self-review of my code
  • My changes generate no new warnings
  • New and existing unit tests pass locally with my changes

🤖 Generated with Claude Code

https://claude.ai/code/session_01VPqyiX6mcp9E33S59NwbKo


Generated by Claude Code

- main.rs uses the library crate instead of compiling `mod node` a second
  time, which made every #[allow(dead_code)] in the tree necessary; drop them
- remove unused code: Database::get_keys_by_cf_name,
  StateUpdate::from_legacy/_vec, the async-trait and direct tungstenite deps
- websocket: one submit path for send_transaction/send_raw_transaction, one
  TripFilter and list_response for the five list methods
- Transaction: one sign_bytes helper behind sign/sign_personal/sign_tron
- balance effects: index entries reuse the records already built
- blockchain: doc comments back on the functions they describe, one JSON
  dump helper for developer mode
- sync handlers: drop parameters they never used
- delete sweep.timestamp, setup-protection.ps1 (printed manual steps only),
  the duplicate root PR template and examples/README.md (it listed example
  files that never existed)

No RPC method, response shape, wire format or stored format changes.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01VPqyiX6mcp9E33S59NwbKo
@MehranMazhar MehranMazhar self-assigned this Oct 6, 2026
@MehranMazhar
MehranMazhar merged commit 85ecb6b into main Oct 6, 2026
5 checks passed
@MehranMazhar
MehranMazhar deleted the claude/refactor-node-fp5nae branch October 6, 2026 21:01
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.

2 participants