-
Notifications
You must be signed in to change notification settings - Fork 111
Description
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:
TxPoolExtensioncallsextend_rpc_modules→ sets hook 1MeteringExtensioncallsextend_rpc_modules→ replaces with hook 2FlashblocksExtensioncallsextend_rpc_modules→ replaces 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_meterBundleRPC 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
-
Create
BaseBuilderincrates/client/node/src/builder.rswith:add_rpc_module()- accumulates RPC hooksadd_node_started_hook()- accumulates node-started hooksfinalize()- combines all hooks into single reth calls
-
Update
BaseNodeExtensiontrait to useBaseBuilderinstead ofOpBuilder -
Update all extensions to use new method names
Affected Files
crates/client/node/src/builder.rs(NEW)crates/client/node/src/lib.rscrates/client/node/src/extension.rscrates/client/node/src/runner.rscrates/client/txpool/src/extension.rscrates/client/metering/src/extension.rscrates/client/flashblocks/src/extension.rscrates/client/node/src/test_utils/node.rs