refactor: rewrite block processor and node to use signet-storage#79
Conversation
Replace the reth ProviderFactory-based storage with HotKv for rollup state reads. The processor becomes a stateless executor that reads from hot storage, runs the EVM, and returns ExecutedBlock. Extraction is moved to the node (PR3) to avoid lifetime issues with borrowed Extracts. - Replace Db: NodeTypesDbTrait generic with H: HotKv - Replace state_provider_database() with revm_state() using RevmRead - Remove on_host_commit() and commit_evm_results() - Add process_block() returning ExecutedBlock - Add build_executed_block() for type conversion - Remove signet-db, signet-node-types, reth-exex, reth-node-api deps - Add signet-hot, signet-storage-types deps - Remove Chain/PrimitivesOf/ExExNotification type aliases from lib.rs Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace reth's ProviderFactory/BlockchainProvider with UnifiedStorage and swap signet-rpc for signet-rpc-storage. The node now holds Arc<UnifiedStorage<H>> and shares state with the RPC context through BlockTags (atomic block tag tracking) and broadcast::Sender (new block notifications). Key changes: - StorageRpcCtx accepts Arc<UnifiedStorage<H>> for shared ownership - Node struct uses HotKv generic instead of NodeTypesDbTrait - Block processing uses signet-extract's Extractor + ExtractableChainShim - Genesis loading via HistoryWrite::load_genesis + UnsafeDbWrite::commit - Fix metrics bug: record_notification_received now correctly increments the received counter instead of the processed counter Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace TmpDb/ProviderFactory with MemKv/UnifiedStorage in all node test infrastructure. Update signet-storage crates to v0.6.2 to fix MemKv intra-transaction read visibility. Align the cold-storage gas oracle with reth's GasPriceOracle by adding default_gas_price (1 Gwei), ignore_price (2 wei), and max_price (500 Gwei) to StorageRpcConfig. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
These crates are fully replaced by signet-storage, signet-hot, and signet-rpc-storage respectively. Remove 6,700+ lines of dead code and clean up 22 unused workspace dependencies. Replace reth-db tempdir_path with tempfile in signet-node-config. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Reclaim the signet-rpc name now that the old reth-backed crate is deleted. Rename directory, package, and all import paths. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…nner Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
[Claude Code] PR Review:
|
| File | Items | Issue |
|---|---|---|
rpc/src/config/ctx.rs |
storage(), cold(), hot_reader(), constants(), chain_id(), config(), acquire_tracing_permit(), tx_cache(), revm_state_at_height() |
pub but only used within crate — should be pub(crate) |
rpc/src/eth/error.rs:34 |
EthError::into_string() |
pub but zero callers — remove |
rpc/src/debug/error.rs:38 |
DebugError::into_string() |
pub but zero callers — remove |
node/src/node.rs:269 |
on_notification() |
pub but only called within crate |
node/src/node.rs:446 |
on_host_revert() |
pub but only called within crate |
node/src/rpc.rs:23 |
start_rpc() |
pub but only called from node.rs |
node/src/serve.rs:49-57 |
ServeConfig fields |
struct is pub(crate) but all fields are pub |
Style / Nits
7. Supported methods listed under "Unsupported" comment
crates/rpc/src/eth/mod.rs:65-90 — syncing, gasPrice, maxPriorityFeePerGas, feeHistory, createAccessList are fully implemented but placed after the // Unsupported methods comment.
8. Imports from same crate not grouped
6 files have separate use signet_hot::X / use signet_hot::Y that should be use signet_hot::{X, Y}:
rpc/src/config/ctx.rs:13-15(alsotrevmat lines 21-22)rpc/src/debug/mod.rs:12-13rpc/src/debug/endpoints.rs:19-20rpc/src/eth/mod.rs:21-22rpc/src/signet/mod.rs:8-9rpc/src/signet/endpoints.rs:11-12
9. Imperative loop for signet events
crates/block-processor/src/v1/processor.rs:272-285 — Three sequential for loops with a manual index counter. Could be a chained iterator with .zip(0u64..).
10. vec![executed] allocation per block inside a loop
crates/node/src/node.rs:308 — self.storage.append_blocks(vec![executed]) allocates per iteration. Consider batching.
11. Outdated README
crates/block-processor/README.md references deleted types but is include_str!'d into crate docs.
12. Doc issues
node/src/node.rs:24:/// Make it easier to write some argsis vague on a type aliasnode/src/serve.rs:80,92:serve_httpandserve_wshave identical doc comments — should distinguish HTTP vs WebSocketnode/src/serve.rs:159:Result<JoinHandle<()>, eyre::Error>instead ofeyre::Result<JoinHandle<()>>(inconsistent)
13. Function-scoped imports in test file
crates/rpc/tests/eth_rpc.rs:140, 414-415, 821 — should be hoisted to module level. SealedHeader at line 821 is redundant with the top-level import at line 21.
14. Missing tracing instrumentation
block-processor/src/v1/processor.rs:run_evmandbuild_executed_blockhave no#[instrument]node/src/serve.rs:169: spawned RPC server future has no span
15. Test infrastructure
node-tests/src/context.rs:352-358: polling loop has no timeout — will hang if cold storage never reaches expected heightnode-tests/src/context.rs:274-277:signet_events_in_rangeis defined but never called
ff4e661 to
809d6d7
Compare
- Fix log_index per-receipt → per-block (kind.rs) - Fix hash/height mismatch in update_highest_processed_height (node.rs) - Fix serve_ipc panic: expect → ? (serve.rs) - Use seal_unchecked to avoid redundant header re-hashing (processor.rs) - Refactor imperative event loop → functional chain (processor.rs) - Add #[instrument(skip_all)] to run_evm and build_executed_block - Add TODO for two-reader consistency risk (processor.rs) - Group signet_hot imports across 6 RPC files - Move supported methods above "Unsupported" comment (eth/mod.rs) - Hoist function-scoped imports to module level (eth_rpc.rs) - Fix stale signet_rpc_storage reference (eth_rpc.rs) - Differentiate HTTP/WS doc comments, fix Result type (serve.rs) - Wrap cold storage polling loop in 30s timeout (context.rs) - Remove dead signet_events_in_range method (context.rs) - Update README to reflect new API types Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
[Claude Code] All review items addressed in
Verification: clippy clean on all 4 crates (all-features + no-default-features), |
Summary
signet-hot/signet-storage-typesinstead ofsignet-db/signet-node-typessignet-nodeto useUnifiedStorageandsignet-rpc-storageinstead of reth'sProviderFactoryandsignet-rpcHotKv, runs EVM, returnsExecutedBlockExtractor+ExtractableChainShimand shares state with RPC throughBlockTagsandbroadcast::SenderBlock Processor Changes
Dependencies (
Cargo.toml):signet-db,signet-node-types,reth-exex,reth-node-apisignet-hot,signet-storage-typesProcessor (
processor.rs):Db: NodeTypesDbTrait→H: HotKvru_provider: ProviderFactory→hot: Hstate_provider_database()→revm_state()usingRevmRead::at_height()on_host_commit()(monolithic loop) →process_block()(single block →ExecutedBlock)commit_evm_results()removed — processor no longer writes to storagebuild_executed_block()handles type conversion (receipts, events, headers)Node Changes
Dependencies (
Cargo.toml):signet-db,signet-node-types,signet-rpc,reth-db,reth-db-common,reth-chainspecsignet-storage,signet-rpc-storage,signet-extract,signet-storage-types,signet-hot,trevmNode struct (
node.rs):Db: NodeTypesDbTrait→H: HotKvru_provider: ProviderFactory→storage: Arc<UnifiedStorage<H>>tags: BlockTagsandnotif_tx: broadcast::Sender<NewBlockNotification>for RPC state sharingNodePrimitivesProviderandCanonStateSubscriptionstrait implsprocess_committed_chain()drives extraction + processing loopnotify_new_block()sends notifications on broadcast channelupdate_block_tags()replacesupdate_canon_heights()/update_canon_state()Builder (
builder.rs):NotADb/with_db()/with_factory()→NotAStorage/with_storage(Arc<UnifiedStorage<H>>)HistoryRead::has_block()+HistoryWrite::load_genesis()+UnsafeDbWrite::commit()RPC (
rpc.rs):signet_rpc::RpcCtx→signet_rpc_storage::StorageRpcCtxwith sharedArc<UnifiedStorage>,BlockTags,broadcast::SenderRPC Storage (
rpc-storage/src/config/ctx.rs):StorageRpcCtx::new()now acceptsArc<UnifiedStorage<H>>for shared ownership with the nodeMetrics (
metrics.rs):record_notification_received()was callinginc_notifications_processed()instead ofinc_notifications_received()N: NodePrimitivesBreaking changes
SignetNodeBuilderno longer haswith_db()/with_factory()— usewith_storage()insteadTest plan
cargo clippy -p signet-block-processor --all-features --all-targets— cleancargo clippy -p signet-block-processor --no-default-features --all-targets— cleancargo clippy -p signet-node --all-features --all-targets— cleancargo clippy -p signet-node --no-default-features --all-targets— cleancargo clippy -p signet-rpc-storage --all-features --all-targets— cleancargo clippy -p signet-rpc-storage --no-default-features --all-targets— cleancargo t -p signet-block-processor— passescargo t -p signet-rpc-storage— 33 passedcargo t -p signet-node— passescargo +nightly fmt— applied🤖 Generated with Claude Code