Skip to content

Commit

Permalink
feat: install op debug exeuction witness (#12622)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse authored Nov 18, 2024
1 parent 5056a08 commit 4b4f9cf
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 16 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 28 additions & 4 deletions crates/node/builder/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ where
}
}

impl<N, EthApi, EV> NodeAddOns<N> for RpcAddOns<N, EthApi, EV>
impl<N, EthApi, EV> RpcAddOns<N, EthApi, EV>
where
N: FullNodeComponents<
Types: ProviderNodeTypes,
Expand All @@ -408,9 +408,16 @@ where
EthApi: EthApiTypes + FullEthApiServer + AddDevSigners + Unpin + 'static,
EV: EngineValidatorBuilder<N>,
{
type Handle = RpcHandle<N, EthApi>;

async fn launch_add_ons(self, ctx: AddOnsContext<'_, N>) -> eyre::Result<Self::Handle> {
/// Launches the RPC servers with the given context and an additional hook for extending
/// modules.
pub async fn launch_add_ons_with<F>(
self,
ctx: AddOnsContext<'_, N>,
ext: F,
) -> eyre::Result<RpcHandle<N, EthApi>>
where
F: FnOnce(&mut TransportRpcModules) -> eyre::Result<()>,
{
let Self { eth_api_builder, engine_validator_builder, hooks, _pd: _ } = self;

let engine_validator = engine_validator_builder.build(&ctx).await?;
Expand Down Expand Up @@ -467,6 +474,7 @@ where

let RpcHooks { on_rpc_started, extend_rpc_modules } = hooks;

ext(ctx.modules)?;
extend_rpc_modules.extend_rpc_modules(ctx)?;

let server_config = config.rpc.rpc_server_config();
Expand Down Expand Up @@ -513,6 +521,22 @@ where
}
}

impl<N, EthApi, EV> NodeAddOns<N> for RpcAddOns<N, EthApi, EV>
where
N: FullNodeComponents<
Types: ProviderNodeTypes,
PayloadBuilder: PayloadBuilder<PayloadType = <N::Types as NodeTypesWithEngine>::Engine>,
>,
EthApi: EthApiTypes + FullEthApiServer + AddDevSigners + Unpin + 'static,
EV: EngineValidatorBuilder<N>,
{
type Handle = RpcHandle<N, EthApi>;

async fn launch_add_ons(self, ctx: AddOnsContext<'_, N>) -> eyre::Result<Self::Handle> {
self.launch_add_ons_with(ctx, |_| Ok(())).await
}
}

/// Helper trait implemented for add-ons producing [`RpcHandle`]. Used by common node launcher
/// implementations.
pub trait RethRpcAddOns<N: FullNodeComponents>:
Expand Down
1 change: 1 addition & 0 deletions crates/optimism/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ reth-evm.workspace = true
reth-revm = { workspace = true, features = ["std"] }
reth-beacon-consensus.workspace = true
reth-trie-db.workspace = true
reth-rpc-server-types.workspace = true

# op-reth
reth-optimism-payload-builder.workspace = true
Expand Down
34 changes: 23 additions & 11 deletions crates/optimism/node/src/node.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
//! Optimism Node types config.

use std::sync::Arc;

use crate::{
args::RollupArgs,
engine::OpEngineValidator,
txpool::{OpTransactionPool, OpTransactionValidator},
OpEngineTypes,
};
use alloy_consensus::Header;
use reth_basic_payload_builder::{BasicPayloadJobGenerator, BasicPayloadJobGeneratorConfig};
use reth_chainspec::{EthChainSpec, Hardforks};
Expand All @@ -23,23 +27,21 @@ use reth_optimism_chainspec::OpChainSpec;
use reth_optimism_consensus::OpBeaconConsensus;
use reth_optimism_evm::{OpEvmConfig, OpExecutionStrategyFactory};
use reth_optimism_payload_builder::builder::OpPayloadTransactions;
use reth_optimism_rpc::OpEthApi;
use reth_optimism_rpc::{
witness::{DebugExecutionWitnessApiServer, OpDebugWitnessApi},
OpEthApi,
};
use reth_payload_builder::{PayloadBuilderHandle, PayloadBuilderService};
use reth_primitives::{Block, Receipt, TransactionSigned, TxType};
use reth_provider::CanonStateSubscriptions;
use reth_rpc_server_types::RethRpcModule;
use reth_tracing::tracing::{debug, info};
use reth_transaction_pool::{
blobstore::DiskFileBlobStore, CoinbaseTipOrdering, TransactionPool,
TransactionValidationTaskExecutor,
};
use reth_trie_db::MerklePatriciaTrie;

use crate::{
args::RollupArgs,
engine::OpEngineValidator,
txpool::{OpTransactionPool, OpTransactionValidator},
OpEngineTypes,
};
use std::sync::Arc;

/// Optimism primitive types.
#[derive(Debug, Default, Clone)]
Expand Down Expand Up @@ -163,7 +165,17 @@ where
self,
ctx: reth_node_api::AddOnsContext<'_, N>,
) -> eyre::Result<Self::Handle> {
self.0.launch_add_ons(ctx).await
// install additional OP specific rpc methods
let debug_ext =
OpDebugWitnessApi::new(ctx.node.provider().clone(), ctx.node.evm_config().clone());

self.0
.launch_add_ons_with(ctx, move |modules| {
debug!(target: "reth::cli", "Installing debug payload witness rpc endpoint");
modules.merge_if_module_configured(RethRpcModule::Debug, debug_ext.into_rpc())?;
Ok(())
})
.await
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/optimism/rpc/src/witness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use reth_optimism_chainspec::OpChainSpec;
use reth_optimism_payload_builder::OpPayloadBuilder;
use reth_primitives::SealedHeader;
use reth_provider::{BlockReaderIdExt, ProviderError, ProviderResult, StateProviderFactory};
use reth_rpc_api::DebugExecutionWitnessApiServer;
pub use reth_rpc_api::DebugExecutionWitnessApiServer;
use reth_rpc_server_types::{result::internal_rpc_err, ToRpcResult};
use std::{fmt::Debug, sync::Arc};

Expand Down

0 comments on commit 4b4f9cf

Please sign in to comment.