-
Notifications
You must be signed in to change notification settings - Fork 27
feat(based-op-reth): based-op changes for reth without fork #266
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
Open
pamungkaski
wants to merge
27
commits into
develop
Choose a base branch
from
ki/reth/new-frag
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 13 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
821290e
unsealed block
1e16fb1
non reth code
2cd06b5
match logic for envv0
915590c
match logic for seal frag v0
e86f651
cleanup
a0b89e8
remove sync
3fb23e9
add docs
e85de73
fmted
7f397e2
add derive
d98d58f
feat: scaffold reth node
mempirate 0c0cd1d
feat: scaffold reth node
mempirate 32c66f0
feat(reth): scaffold engine API
mempirate ce981ed
feat(reth): progress on engine API
mempirate bc8bb93
feat(reth): smol CLI test
mempirate 56a7f62
feat(reth): eth API overrides
mempirate 90a3869
chore: unsealed as latest
mempirate f406b2e
some API for unsealed block
53d75b5
feat(based-op-reth): execute_frag on state machine (#270)
pamungkaski bfde721
docs(reth): comments
mempirate dff25c3
fix: get block number use canonical instead of unsealed block state
pamungkaski a15e79b
docs: remove flashblocks
Karrq c298941
feat(docker): reth-node
Karrq 3702a95
feat(compose): added compose with reth node
Karrq 459e949
chore: fmt
Karrq e5557dd
fix: relax RPC api
Karrq 915ecfe
fix ensure_env expected block
pamungkaski 1036364
feat(based-op-reth): save l1 block info when executing frag (#277)
pamungkaski 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
Large diffs are not rendered by default.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| [package] | ||
| edition.workspace = true | ||
| name = "reth" | ||
| repository.workspace = true | ||
| rust-version.workspace = true | ||
| version.workspace = true | ||
|
|
||
| [dependencies] | ||
| alloy-consensus.workspace = true | ||
| alloy-eips.workspace = true | ||
| alloy-network.workspace = true | ||
| alloy-primitives.workspace = true | ||
| alloy-rpc-types.workspace = true | ||
| anyhow = "1.0.98" | ||
| bop-common.workspace = true | ||
| clap.workspace = true | ||
| eyre.workspace = true | ||
| futures.workspace = true | ||
| jsonrpsee.workspace = true | ||
| op-alloy-rpc-types.workspace = true | ||
| thiserror.workspace = true | ||
| tokio.workspace = true | ||
| tracing.workspace = true | ||
|
|
||
| reth-exex = { git = "https://github.com/paradigmxyz/reth", tag = "v1.9.3" } | ||
| reth-node-builder = { git = "https://github.com/paradigmxyz/reth", tag = "v1.9.3" } | ||
| reth-optimism-chainspec = { git = "https://github.com/paradigmxyz/reth", tag = "v1.9.3" } | ||
| reth-optimism-cli = { git = "https://github.com/paradigmxyz/reth", tag = "v1.9.3" } | ||
| reth-optimism-node = { git = "https://github.com/paradigmxyz/reth", tag = "v1.9.3" } | ||
| reth-rpc = { git = "https://github.com/paradigmxyz/reth", tag = "v1.9.3" } |
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,65 @@ | ||
| use bop_common::p2p::{EnvV0, FragV0, SealV0, Signed}; | ||
| use jsonrpsee::{ | ||
| core::{RpcResult, async_trait}, | ||
| proc_macros::rpc, | ||
| types::{ErrorCode, ErrorObject}, | ||
| }; | ||
|
|
||
| use crate::{driver::Driver, error::DriverError}; | ||
|
|
||
| #[rpc(server, namespace = "engine")] | ||
| pub trait BasedEngineApi { | ||
| #[method(name = "envV0")] | ||
| async fn env_v0(&self, env: Signed<EnvV0>) -> RpcResult<()>; | ||
|
|
||
| #[method(name = "newFragV0")] | ||
| async fn new_frag_v0(&self, frag: Signed<FragV0>) -> RpcResult<()>; | ||
|
|
||
| #[method(name = "sealFragV0")] | ||
| async fn seal_frag_v0(&self, seal: Signed<SealV0>) -> RpcResult<()>; | ||
| } | ||
|
|
||
| pub struct BasedEngineApi { | ||
| driver: Driver, | ||
| } | ||
|
|
||
| impl BasedEngineApi { | ||
| /// Initialize a new based engine API instance. | ||
| pub fn new(driver: Driver) -> Self { | ||
| Self { driver } | ||
| } | ||
| } | ||
|
|
||
| #[async_trait] | ||
| impl BasedEngineApiServer for BasedEngineApi { | ||
| #[tracing::instrument(skip(self))] | ||
| async fn env_v0(&self, env: Signed<EnvV0>) -> RpcResult<()> { | ||
| tracing::debug!("handling engine_envV0"); | ||
|
|
||
| self.driver.env_v0(env.message).await?; | ||
| Ok(()) | ||
| } | ||
|
|
||
| #[tracing::instrument(skip(self))] | ||
| async fn new_frag_v0(&self, frag: Signed<FragV0>) -> RpcResult<()> { | ||
| tracing::debug!("handling engine_newFragV0"); | ||
|
|
||
| self.driver.new_frag_v0(frag.message).await?; | ||
| Ok(()) | ||
| } | ||
|
|
||
| #[tracing::instrument(skip(self))] | ||
| async fn seal_frag_v0(&self, seal: Signed<SealV0>) -> RpcResult<()> { | ||
| tracing::debug!("handling engine_sealFragV0"); | ||
|
|
||
| self.driver.seal_frag_v0(seal.message).await?; | ||
| Ok(()) | ||
| } | ||
| } | ||
|
|
||
| impl From<DriverError> for ErrorObject<'static> { | ||
| // TODO: Better error handling | ||
| fn from(e: DriverError) -> Self { | ||
| ErrorObject::owned(ErrorCode::InternalError.code(), e.to_string(), Option::<()>::None) | ||
| } | ||
| } |
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 @@ | ||
| pub mod engine; |
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,76 @@ | ||
| use clap::Parser; | ||
| use futures::TryStreamExt as _; | ||
| use reth_exex::ExExEvent; | ||
| use reth_node_builder::Node; | ||
| use reth_optimism_cli::{Cli, chainspec::OpChainSpecParser}; | ||
| use reth_optimism_node::{OpNode, args::RollupArgs}; | ||
|
|
||
| use crate::{ | ||
| api::engine::{BasedEngineApi, BasedEngineApiServer as _}, | ||
| driver::Driver, | ||
| }; | ||
|
|
||
| #[derive(Parser, Debug, Clone)] | ||
| pub struct BasedOpRethArgs { | ||
| #[command(flatten)] | ||
| pub rollup: RollupArgs, | ||
| #[command(flatten)] | ||
| pub based_op: BasedOpArgs, | ||
| } | ||
|
|
||
| #[derive(Parser, Debug, Clone)] | ||
| pub struct BasedOpArgs { | ||
| /// Whether to use the unsealed block as the "latest" state in RPC calls. | ||
| #[arg(long)] | ||
| unsealed_as_latest: bool, | ||
| } | ||
|
|
||
| pub fn run() -> eyre::Result<()> { | ||
| Cli::<OpChainSpecParser, BasedOpRethArgs>::parse().run(|builder, args| async move { | ||
| let driver = Driver::new(args.based_op.unsealed_as_latest); | ||
|
|
||
| let op_node = OpNode::new(args.rollup.clone()); | ||
|
|
||
| let node_handle = builder | ||
| .with_types::<OpNode>() | ||
| .with_components(op_node.components()) | ||
| .with_add_ons(op_node.add_ons()) | ||
| // Install the execution extension to handle canonical chain updates | ||
| .install_exex("based-op", { | ||
| // Get a clone of the driver handle. | ||
| let driver = driver.clone(); | ||
| move |mut ctx| async move { | ||
| Ok(async move { | ||
| while let Some(note) = ctx.notifications.try_next().await? { | ||
| if let Some(committed) = note.committed_chain() { | ||
| // Handle committed blocks by notifying the driver | ||
| for block in committed.blocks_iter() { | ||
| driver.forkchoice_updated(block.clone().into_block()).await?; | ||
| } | ||
| let _ = ctx.events.send(ExExEvent::FinishedHeight(committed.tip().num_hash())); | ||
| } | ||
| } | ||
|
|
||
| Ok(()) | ||
| }) | ||
| } | ||
| }) | ||
| .extend_rpc_modules(move |ctx| { | ||
| // Add based engine API modules to the existing auth module. | ||
| ctx.auth_module | ||
| .merge_auth_methods(BasedEngineApi::new(driver).into_rpc()) | ||
| .expect("failed to merge modules"); | ||
| // TODO: | ||
| // - Replace / extend the engine API | ||
| // - Replace eth API | ||
| Ok(()) | ||
| }) | ||
| .launch() | ||
| .await?; | ||
|
|
||
| // Run to completion | ||
| node_handle.wait_for_node_exit().await?; | ||
|
|
||
| Ok(()) | ||
| }) | ||
| } |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Loving this tbh