Skip to content

Commit

Permalink
feat(rollup): engine controller
Browse files Browse the repository at this point in the history
  • Loading branch information
refcell committed Oct 21, 2024
1 parent 51b3b9a commit 130b323
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 12 deletions.
7 changes: 0 additions & 7 deletions crates/rollup/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ pub const DEFAULT_L2_CHAIN_ID: u64 = 10;
/// The default L1 RPC URL to use.
pub const DEFAULT_L1_RPC_URL: &str = "https://cloudflare-eth.com";

/// The default L2 RPC URL to use.
pub const DEFAULT_L2_RPC_URL: &str = "https://optimism.llamarpc.com/";

/// The default L1 Beacon Client RPC URL to use.
pub const DEFAULT_L1_BEACON_CLIENT_URL: &str = "http://localhost:5052/";

Expand All @@ -34,10 +31,6 @@ pub struct HeraArgsExt {
#[clap(long = "hera.l2-config-file")]
pub l2_config_file: Option<PathBuf>,

/// RPC URL of an L2 execution client
#[clap(long = "hera.l2-rpc-url", default_value = DEFAULT_L2_RPC_URL)]
pub l2_rpc_url: Url,

/// RPC URL of an L1 execution client
/// (This is only needed when running in Standalone mode)
#[clap(long = "hera.l1-rpc-url", default_value = DEFAULT_L1_RPC_URL)]
Expand Down
20 changes: 20 additions & 0 deletions crates/rollup/src/engine/controller.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//! The engine controller keeps the state of the engine.
use op_alloy_protocol::L2BlockInfo;

/// The engine controller.
#[derive(Debug, Clone)]
pub struct EngineController {
/// The block head state.
pub unsafe_head: L2BlockInfo,
/// A cross unsafe head.
pub cross_unsafe_head: L2BlockInfo,
/// The pending local safe head.
pub pending_local_safe_head: L2BlockInfo,
/// The local safe head.
pub local_safe_head: L2BlockInfo,
/// Derived from L1 and cross-verified.
pub safe_head: L2BlockInfo,
/// The finalized safe head.
pub finalized_head: L2BlockInfo,
}
7 changes: 7 additions & 0 deletions crates/rollup/src/engine/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//! The engine module contains logic for interacting with the L2 Engine API.
mod controller;
pub use controller::EngineController;

mod relay;
pub use relay::EngineRelay;
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! The engine relay handles forwarding [OpAttributesWithParent] to the L2 Engine API.
use std::ops::Deref;

use alloy_network::AnyNetwork;
Expand Down Expand Up @@ -25,12 +27,12 @@ type HyperAuthClient<B = Full<Bytes>> = HyperClient<B, AuthService<Client<HttpCo

/// The [`Engine`] is responsible for interacting with an L2 Engine API server.
#[derive(Debug, Clone)]
pub struct Engine {
pub struct EngineRelay {
provider: RootProvider<Http<HyperAuthClient>, AnyNetwork>,
}

impl Engine {
/// Creates a new [`Engine`] from the provided [Url] and [JwtSecret].
impl EngineRelay {
/// Creates a new [`EngineRelay`] from the provided [Url] and [JwtSecret].
pub fn new_http(url: Url, jwt: JwtSecret) -> Self {
let hyper_client = Client::builder(TokioExecutor::new()).build_http::<Full<Bytes>>();

Expand Down Expand Up @@ -66,7 +68,7 @@ impl Engine {
}
}

impl Deref for Engine {
impl Deref for EngineRelay {
type Target = RootProvider<Http<HyperAuthClient>, AnyNetwork>;

fn deref(&self) -> &Self::Target {
Expand Down
2 changes: 1 addition & 1 deletion crates/rollup/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ mod cli;
pub use cli::HeraArgsExt;

mod engine;
pub use engine::Engine;
pub use engine::{EngineRelay, EngineController};

mod validator;
pub use validator::TrustedPayloadValidator;
Expand Down

0 comments on commit 130b323

Please sign in to comment.