forked from paradigmxyz/reth
-
Notifications
You must be signed in to change notification settings - Fork 10
chore: moved proof initialization to reth-optimism-node
#640
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
dhyaniarun1993
merged 14 commits into
unstable
from
sadiq/refactor-proof-initialization
Jan 28, 2026
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
19a4df7
moved proof initialization to reth-optimism-node
sadiq1971 8f287ad
removed unused deps
sadiq1971 a84fbc7
added feature to dep
sadiq1971 be33167
fixed dep issue
sadiq1971 1616e7d
moved full launch to proof storage
sadiq1971 512512c
merged unstable
sadiq1971 2d8055b
dep updated
sadiq1971 19e109a
dep updated
sadiq1971 8757191
dep updated
sadiq1971 98f3eb6
dep updated
sadiq1971 e283c7c
fix cargo check
dhyaniarun1993 da3b5c9
revert e2e_testsuite
dhyaniarun1993 d6ea3b9
lintfix
dhyaniarun1993 33ca5cc
restructure args
dhyaniarun1993 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,109 @@ | ||
| //! Node luncher with proof history support. | ||
|
|
||
| use crate::{args::RollupArgs, OpNode}; | ||
| use eyre::ErrReport; | ||
| use futures_util::FutureExt; | ||
| use reth_db::DatabaseEnv; | ||
| use reth_db_api::database_metrics::DatabaseMetrics; | ||
| use reth_node_builder::{FullNodeComponents, NodeBuilder, WithLaunchContext}; | ||
| use reth_optimism_chainspec::OpChainSpec; | ||
| use reth_optimism_exex::OpProofsExEx; | ||
| use reth_optimism_rpc::{ | ||
| debug::{DebugApiExt, DebugApiOverrideServer}, | ||
| eth::proofs::{EthApiExt, EthApiOverrideServer}, | ||
| }; | ||
| use reth_optimism_trie::{db::MdbxProofsStorage, OpProofsStorage}; | ||
| use reth_tasks::TaskExecutor; | ||
| use std::{sync::Arc, time::Duration}; | ||
| use tokio::time::sleep; | ||
| use tracing::info; | ||
|
|
||
| /// - no proofs history (plain node), | ||
| /// - in-mem proofs storage, | ||
| /// - MDBX proofs storage. | ||
| pub async fn launch_node_with_proof_history( | ||
| builder: WithLaunchContext<NodeBuilder<Arc<DatabaseEnv>, OpChainSpec>>, | ||
| args: RollupArgs, | ||
| ) -> eyre::Result<(), ErrReport> { | ||
| let RollupArgs { | ||
| proofs_history, | ||
| proofs_history_window, | ||
| proofs_history_prune_interval, | ||
| proofs_history_verification_interval, | ||
| .. | ||
| } = args; | ||
|
|
||
| // Start from a plain OpNode builder | ||
| let mut node_builder = builder.node(OpNode::new(args.clone())); | ||
|
|
||
| if proofs_history { | ||
| let path = args | ||
| .proofs_history_storage_path | ||
| .clone() | ||
| .expect("Path must be provided if not using in-memory storage"); | ||
| info!(target: "reth::cli", "Using on-disk storage for proofs history"); | ||
|
|
||
| let mdbx = Arc::new( | ||
| MdbxProofsStorage::new(&path) | ||
| .map_err(|e| eyre::eyre!("Failed to create MdbxProofsStorage: {e}"))?, | ||
| ); | ||
| let storage: OpProofsStorage<Arc<MdbxProofsStorage>> = mdbx.clone().into(); | ||
|
|
||
| let storage_exec = storage.clone(); | ||
|
|
||
| node_builder = node_builder | ||
| .on_node_started(move |node| { | ||
| spawn_proofs_db_metrics( | ||
| node.task_executor, | ||
| mdbx, | ||
| node.config.metrics.push_gateway_interval, | ||
| ); | ||
| Ok(()) | ||
| }) | ||
| .install_exex("proofs-history", async move |exex_context| { | ||
| Ok(OpProofsExEx::builder(exex_context, storage_exec) | ||
| .with_proofs_history_window(proofs_history_window) | ||
| .with_proofs_history_prune_interval(proofs_history_prune_interval) | ||
| .with_verification_interval(proofs_history_verification_interval) | ||
| .build() | ||
| .run() | ||
| .boxed()) | ||
| }) | ||
| .extend_rpc_modules(move |ctx| { | ||
| let api_ext = EthApiExt::new(ctx.registry.eth_api().clone(), storage.clone()); | ||
| let debug_ext = DebugApiExt::new( | ||
| ctx.node().provider().clone(), | ||
| ctx.registry.eth_api().clone(), | ||
| storage, | ||
| Box::new(ctx.node().task_executor().clone()), | ||
| ctx.node().evm_config().clone(), | ||
| ); | ||
| ctx.modules.replace_configured(api_ext.into_rpc())?; | ||
| ctx.modules.replace_configured(debug_ext.into_rpc())?; | ||
| Ok(()) | ||
| }); | ||
| } | ||
|
|
||
| // In all cases (with or without proofs), launch the node. | ||
| let handle = node_builder.launch_with_debug_capabilities().await?; | ||
| handle.node_exit_future.await | ||
| } | ||
| /// Spawns a task that periodically reports metrics for the proofs DB. | ||
| fn spawn_proofs_db_metrics( | ||
| executor: TaskExecutor, | ||
| storage: Arc<MdbxProofsStorage>, | ||
| metrics_report_interval: Duration, | ||
| ) { | ||
| executor.spawn_critical("op-proofs-storage-metrics", async move { | ||
| info!( | ||
| target: "reth::cli", | ||
| ?metrics_report_interval, | ||
| "Starting op-proofs-storage metrics task" | ||
| ); | ||
|
|
||
| loop { | ||
| sleep(metrics_report_interval).await; | ||
| storage.report_metrics(); | ||
| } | ||
| }); | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.