Skip to content
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4,834 changes: 3,824 additions & 1,010 deletions based/Cargo.lock

Large diffs are not rendered by default.

24 changes: 14 additions & 10 deletions based/crates/common/src/p2p.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ pub type ExtraData = VariableList<u8, MaxExtraDataSize>;
#[derive(Debug, Clone, PartialEq, Eq, TreeHash, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct EnvV0 {
number: u64,
parent_hash: B256,
beneficiary: Address,
timestamp: u64,
gas_limit: u64,
basefee: u64,
difficulty: U256,
prevrandao: B256,
pub number: u64,
pub parent_hash: B256,
pub beneficiary: Address,
pub timestamp: u64,
pub gas_limit: u64,
pub basefee: u64,
pub difficulty: U256,
pub prevrandao: B256,
#[serde(with = "ssz_types::serde_utils::hex_var_list")]
extra_data: ExtraData,
parent_beacon_block_root: B256,
pub extra_data: ExtraData,
pub parent_beacon_block_root: B256,
}

impl EnvV0 {
Expand Down Expand Up @@ -81,6 +81,10 @@ impl FragV0 {
let txs = builder_txs.map(|tx| tx.encode().to_vec()).map(Transaction::from).collect::<Vec<_>>();
Self { block_number, seq, txs: Transactions::from(txs), is_last, blob_gas_used }
}

pub fn is_first(&self) -> bool {
self.seq == 0
}
}

/// A message sealing a sequence of frags, with fields from the block header
Expand Down
27 changes: 27 additions & 0 deletions based/crates/reth/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[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
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-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" }
55 changes: 55 additions & 0 deletions based/crates/reth/src/cli.rs
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Loving this tbh

Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
use clap::Parser;
use futures::TryStreamExt as _;
use reth_exex::ExExEvent;
use reth_optimism_cli::{Cli, chainspec::OpChainSpecParser};
use reth_optimism_node::{OpNode, args::RollupArgs};

#[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 {}

pub fn run() -> eyre::Result<()> {
Cli::<OpChainSpecParser, BasedOpRethArgs>::parse().run(|builder, mut args| async move {
let op_node = OpNode::new(args.rollup.clone());

let add_ons = op_node.add_ons_builder().build();

let node_handle = builder
.with_types::<OpNode>()
.with_components(op_node.components())
.with_add_ons(add_ons)
// Install the execution extension to handle canonical chain updates
.install_exex("based-op", {
move |mut ctx| async move {
Ok(async move {
while let Some(note) = ctx.notifications.try_next().await? {
if let Some(committed) = note.committed_chain() {
for b in committed.blocks_iter() {
// TODO: Handle committed block
}
let _ = ctx.events.send(ExExEvent::FinishedHeight(committed.tip().num_hash()));
}
}

Ok(())
})
}
})
// .extend_rpc_modules(move |rpx_context| {
// // WTF
// Ok(())
// })
.launch()
.await?;

// TODO
Ok(())
})
}
Loading
Loading