Skip to content

[hackathon] refactor: decouple signet-node from reth via HostNotifier trait#100

Closed
prestwich wants to merge 19 commits intodevelopfrom
feat/host-context-adapter
Closed

[hackathon] refactor: decouple signet-node from reth via HostNotifier trait#100
prestwich wants to merge 19 commits intodevelopfrom
feat/host-context-adapter

Conversation

@prestwich
Copy link
Member

@prestwich prestwich commented Mar 13, 2026

[Claude Code]

Summary

  • Introduces signet-node-types crate with a HostNotifier trait, HostNotification, and HostNotificationKind — a host-chain-agnostic abstraction for receiving chain notifications
  • Introduces signet-host-reth crate with RethHostNotifier (the reth/ExEx implementation), RethChain wrapper, alias oracle, and RPC config helpers extracted from signet-node
  • Introduces signet-host-rpc crate with RpcHostNotifier — an RPC/WebSocket-based host chain follower using newHeads subscriptions, reorg detection via ring buffer, and backfill support
  • Makes AliasOracle::should_alias async via return-position impl Trait in trait (RPITIT), enabling future async implementations
  • Refactors SignetNode and SignetNodeBuilder to be generic over N: HostNotifier, removing all reth dependencies from signet-node
  • Removes reth-exex and reth-node-api dependencies from signet-node-config
  • Makes signet-block-processor::process_block generic over C: Extractable
  • Extends Extractable trait in the SDK with first_number(), tip_number(), len(), is_empty() metadata methods
  • Bumps SDK dependencies to 0.16.0-rc.14

Motivation

signet-node was tightly coupled to reth's ExExContext, making it impossible to run the node against alternative host chain backends. This refactoring isolates all reth-specific code behind the HostNotifier trait boundary, enabling future integrations with non-reth hosts (including pure RPC-based followers).

Design

  • Design spec: docs/superpowers/specs/2026-03-13-host-context-adapter-design.md
  • Implementation plan: docs/superpowers/plans/2026-03-13-host-context-adapter.md

Key decisions

  • HostNotifier::Error bound is core::error::Error (not eyre::Report, which doesn't implement it)
  • Safe/finalized block numbers are bundled into HostNotification at notification time, avoiding provider lookups during processing
  • set_head and send_finished_height take u64 block numbers; hash resolution is the backend's responsibility
  • RethChain uses repr(transparent) transmute (matching existing ExtractableChainShim pattern) for zero-cost Extractable implementation
  • RethHostError uses thiserror (library crate convention) rather than eyre
  • RpcHostNotifier never emits ChainReverted — the newHeads subscription only fires for new blocks, so pure reverts are invisible
  • [patch.crates-io] entries now point to GitHub branches (not local paths)

Note

This branch includes SDK patches pointing to the feat/extractable-metadata branch on GitHub. The SDK changes need to be published before this can merge cleanly.

Test plan

  • All workspace tests pass (cargo t --workspace, skipping pre-existing slow test_stateful_rpc_calls)
  • Workspace clippy clean (cargo clippy --workspace --all-features --all-targets)
  • signet-node/Cargo.toml has zero reth dependencies
  • Integration tests exercise the full path through RethHostNotifierSignetNode

🤖 Generated with Claude Code

prestwich and others added 12 commits March 13, 2026 12:05
Spec for decoupling signet-node from reth's ExExContext by introducing
a HostNotifier trait in signet-node-types, with the reth implementation
isolated in a new signet-host-reth crate.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
14-task plan covering: Extractable extension in SDK, signet-node-types
crate, signet-host-reth crate, signet-node refactoring, and test updates.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
first_number and tip_number now return Option<u64> instead of panicking
on empty chain segments.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Introduces the signet-node-types crate containing HostNotification,
HostNotificationKind, and the HostNotifier trait — the core abstraction
layer for host chain events with no reth dependencies.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Introduces the signet-host-reth crate which isolates all reth ExEx
dependencies behind the HostNotifier trait. This includes:

- RethChain: owning wrapper around reth's Chain implementing Extractable
  with O(1) metadata accessors via inlined transmute logic
- RethHostNotifier: ExEx-backed implementation of HostNotifier that
  handles hash resolution internally
- RethAliasOracle/Factory: moved from signet-node for reuse
- RPC config helpers: rpc_config_from_args and serve_config_from_args
- decompose_exex_context: splits ExExContext into notifier + config
- RethHostError: proper error type satisfying core::error::Error

Also re-exports RecoveredBlockShim from signet-blobber.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
signet-node is now reth-free. All host chain interaction flows through
the HostNotifier trait from signet-node-types.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
process_block and run_evm now accept any Extractable chain type,
removing the hard dependency on ExtractableChainShim.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Use decompose_exex_context to construct RethHostNotifier and pass
it through the new builder API.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The decomposed reth context has IPC/HTTP disabled by default. Tests
need the Signet-configured IPC path for RPC communication.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…t_head

Eliminates num_hash_slow() calls by using the provider's sealed_header
method, which returns pre-cached hashes instead of recomputing from RLP.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace local path overrides with git references to the
feat/extractable-metadata branch so CI can resolve dependencies.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@prestwich prestwich changed the title refactor: decouple signet-node from reth via HostNotifier trait [hackathon] refactor: decouple signet-node from reth via HostNotifier trait Mar 13, 2026
prestwich and others added 6 commits March 13, 2026 14:24
The upstream signet-sdk changed `Extractable::blocks_and_receipts` to
return `BlockAndReceipts` structs instead of tuples. Update both shim
implementations to construct the new struct type.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
RPC-based HostNotifier implementation that follows a host chain via
WebSocket newHeads subscription. Supports backfill, ring-buffer reorg
detection, and epoch-aware safe/finalized block tag caching.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Aligns workspace dependency versions with the feat/extractable-metadata
branch, eliminating duplicate signet-types/signet-constants crate
resolutions.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add MissingBlock error variant for correct semantics, tighten RpcBlock
field visibility, guard backfill_batch_size against zero, and document
RPC reorg detection limitations and ChainReverted non-emission.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
prestwich added a commit that referenced this pull request Mar 13, 2026
Add MissingBlock error variant for correct semantics, tighten RpcBlock
field visibility, guard backfill_batch_size against zero, and document
RPC reorg detection limitations and ChainReverted non-emission.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@prestwich
Copy link
Member Author

replaced by #104 #105 #106 and #107

@prestwich prestwich closed this Mar 13, 2026
prestwich added a commit that referenced this pull request Mar 13, 2026
Add MissingBlock error variant for correct semantics, tighten RpcBlock
field visibility, guard backfill_batch_size against zero, and document
RPC reorg detection limitations and ChainReverted non-emission.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
prestwich added a commit that referenced this pull request Mar 13, 2026
Add MissingBlock error variant for correct semantics, tighten RpcBlock
field visibility, guard backfill_batch_size against zero, and document
RPC reorg detection limitations and ChainReverted non-emission.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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