Skip to content

fix(client): RPC extensions overwrite each other due to reth hook replacement model #438

@niran

Description

@niran

Problem

Reth's extend_rpc_modules and on_node_started use a replacement model - each call replaces the previous hook rather than accumulating. This causes only the last extension's hooks to execute.

Current behavior in bin/node/src/main.rs:

  1. TxPoolExtension calls extend_rpc_modules → sets hook 1
  2. MeteringExtension calls extend_rpc_modulesreplaces with hook 2
  3. FlashblocksExtension calls extend_rpc_modulesreplaces with hook 3

Result: Only FlashblocksExtension's RPC methods are registered. base_meterBundle and base_transactionStatus endpoints are missing even when --enable-metering is passed.

Symptoms

  • "Starting Metering RPC" log message does NOT appear
  • "Starting Transaction Status RPC" log message does NOT appear
  • "Starting Flashblocks RPC" log message DOES appear (last extension wins)
  • base_meterBundle RPC endpoint returns "method not found"

Root Cause

Confirmed by reading reth v1.9.3 source: RpcHooks struct stores hooks as single Box fields with set_* methods, not as vectors with push methods. Each extend_rpc_modules call overwrites the previous hook.

Solution

Create a BaseBuilder wrapper that accumulates extend_rpc_modules and on_node_started hooks in Vecs, then applies them all in a single reth call when launching. This maintains the existing extension API while fixing the accumulation issue.

Implementation

  1. Create BaseBuilder in crates/client/node/src/builder.rs with:

    • add_rpc_module() - accumulates RPC hooks
    • add_node_started_hook() - accumulates node-started hooks
    • finalize() - combines all hooks into single reth calls
  2. Update BaseNodeExtension trait to use BaseBuilder instead of OpBuilder

  3. Update all extensions to use new method names

Affected Files

  • crates/client/node/src/builder.rs (NEW)
  • crates/client/node/src/lib.rs
  • crates/client/node/src/extension.rs
  • crates/client/node/src/runner.rs
  • crates/client/txpool/src/extension.rs
  • crates/client/metering/src/extension.rs
  • crates/client/flashblocks/src/extension.rs
  • crates/client/node/src/test_utils/node.rs

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-clientArea: client cratesF-bugFlag: Something isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions