Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
5,950 changes: 4,724 additions & 1,226 deletions based/Cargo.lock

Large diffs are not rendered by default.

45 changes: 20 additions & 25 deletions based/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ version = "0.1.0"
alloy-consensus = "1.0.41"
alloy-eips = "1.0.41"
alloy-network = "1.0.41"
alloy-primitives = { version = "1.0.41", default-features = false, features = [
"getrandom",
] }
alloy-primitives = { version = "1.0.41", default-features = false, features = ["getrandom"] }
alloy-provider = "1.0.41"
alloy-rlp = "0.3.12"
alloy-rpc-types = { version = "1.0.41", features = ["engine"] }
Expand All @@ -41,29 +39,25 @@ either = "1.15.0"
ethereum_ssz = "0.9.0"
eyre = "0.6.12"
futures = "0.3.31"
hickory-resolver = "=0.25.0-alpha.5" # Use the exact version reth expects
hickory-resolver = "=0.25.0-alpha.5" # Use the exact version reth expects
http = "1.3.1"
hyper = "1.5.2"
jsonrpsee = { version = "0.26", features = ["http-client", "macros", "server", "jsonrpsee-client-transport"] }
jsonrpsee = { version = "0.26", features = ["http-client", "jsonrpsee-client-transport", "macros", "server"] }
metrics = "0.24.1"
metrics-exporter-prometheus = "0.16.2"
mio = { features = ["net", "os-poll"], version = "1.0.4" }
mio_httpc = { features = ["native"], version = "0.10.6" }
moka = "0.12.10"
op-alloy-consensus = { version = "0.22.0", default-features = false, features = [
"k256",
] }
op-alloy-consensus = { version = "0.22.0", default-features = false, features = ["k256"] }
op-alloy-flz = { version = "0.13.1", default-features = false }
op-alloy-network = "0.22.0"
op-alloy-rpc-types = "0.22.0"
op-alloy-rpc-types-engine = { version = "0.22.0", default-features = false, features = [
"serde",
] }
op-alloy-rpc-types-engine = { version = "0.22.0", default-features = false, features = ["serde"] }
op-revm = "12.0.1"
parking_lot = "0.12.3"
paste = "0.1.18"
quanta = "0.12.3"
rand = "0.9.0"
rand = "0.9.2"
reqwest = { version = "0.12.12", features = ["blocking", "json"] }

reth-chain-state = { git = "https://github.com/gattaca-com/based-op-reth", rev = "b053849462eb48e61b24d965cfee59cead7f8a3b", package = "reth-chain-state" }
Expand All @@ -73,10 +67,12 @@ reth-consensus = { git = "https://github.com/gattaca-com/based-op-reth", rev = "
reth-db = { git = "https://github.com/gattaca-com/based-op-reth", rev = "b053849462eb48e61b24d965cfee59cead7f8a3b", package = "reth-db" }
reth-db-api = { git = "https://github.com/gattaca-com/based-op-reth", rev = "b053849462eb48e61b24d965cfee59cead7f8a3b", package = "reth-db-api" }
reth-db-common = { git = "https://github.com/gattaca-com/based-op-reth", rev = "b053849462eb48e61b24d965cfee59cead7f8a3b", package = "reth-db-common" }
reth-engine-tree = { git = "https://github.com/gattaca-com/based-op-reth", rev = "b053849462eb48e61b24d965cfee59cead7f8a3b", package = "reth-engine-tree" }
reth-evm = { git = "https://github.com/gattaca-com/based-op-reth", rev = "b053849462eb48e61b24d965cfee59cead7f8a3b", package = "reth-evm" }
reth-execution-errors = { git = "https://github.com/gattaca-com/based-op-reth", rev = "b053849462eb48e61b24d965cfee59cead7f8a3b", package = "reth-execution-errors" }
reth-engine-tree = { git = "https://github.com/gattaca-com/based-op-reth", rev = "b053849462eb48e61b24d965cfee59cead7f8a3b", package = "reth-engine-tree" }
reth-node-ethereum = { git = "https://github.com/gattaca-com/based-op-reth", rev = "b053849462eb48e61b24d965cfee59cead7f8a3b", package = "reth-node-ethereum", features = ["test-utils"] }
reth-node-ethereum = { git = "https://github.com/gattaca-com/based-op-reth", rev = "b053849462eb48e61b24d965cfee59cead7f8a3b", package = "reth-node-ethereum", features = [
"test-utils",
] }
reth-node-types = { git = "https://github.com/gattaca-com/based-op-reth", rev = "b053849462eb48e61b24d965cfee59cead7f8a3b", package = "reth-node-types" }
reth-optimism-chainspec = { git = "https://github.com/gattaca-com/based-op-reth", rev = "b053849462eb48e61b24d965cfee59cead7f8a3b", package = "reth-optimism-chainspec" }
reth-optimism-cli = { git = "https://github.com/gattaca-com/based-op-reth", rev = "b053849462eb48e61b24d965cfee59cead7f8a3b", package = "reth-optimism-cli" }
Expand All @@ -85,33 +81,31 @@ reth-optimism-evm = { git = "https://github.com/gattaca-com/based-op-reth", rev
reth-optimism-forks = { git = "https://github.com/gattaca-com/based-op-reth", rev = "b053849462eb48e61b24d965cfee59cead7f8a3b", package = "reth-optimism-forks" }
reth-optimism-node = { git = "https://github.com/gattaca-com/based-op-reth", rev = "b053849462eb48e61b24d965cfee59cead7f8a3b", package = "reth-optimism-node" }
reth-optimism-payload-builder = { git = "https://github.com/gattaca-com/based-op-reth", rev = "b053849462eb48e61b24d965cfee59cead7f8a3b", package = "reth-optimism-payload-builder" }
reth-optimism-txpool = { git = "https://github.com/gattaca-com/based-op-reth", rev = "b053849462eb48e61b24d965cfee59cead7f8a3b", package = "reth-optimism-txpool" }
reth-optimism-primitives = { git = "https://github.com/gattaca-com/based-op-reth", rev = "b053849462eb48e61b24d965cfee59cead7f8a3b", package = "reth-optimism-primitives" }
reth-optimism-txpool = { git = "https://github.com/gattaca-com/based-op-reth", rev = "b053849462eb48e61b24d965cfee59cead7f8a3b", package = "reth-optimism-txpool" }
reth-primitives = { git = "https://github.com/gattaca-com/based-op-reth", rev = "b053849462eb48e61b24d965cfee59cead7f8a3b", package = "reth-primitives" }
reth-primitives-traits = { git = "https://github.com/gattaca-com/based-op-reth", rev = "b053849462eb48e61b24d965cfee59cead7f8a3b", package = "reth-primitives-traits" }
reth-provider = { git = "https://github.com/gattaca-com/based-op-reth", rev = "b053849462eb48e61b24d965cfee59cead7f8a3b", package = "reth-provider", features = ["test-utils"] }
reth-provider = { git = "https://github.com/gattaca-com/based-op-reth", rev = "b053849462eb48e61b24d965cfee59cead7f8a3b", package = "reth-provider", features = [
"test-utils",
] }
reth-revm = { git = "https://github.com/gattaca-com/based-op-reth", rev = "b053849462eb48e61b24d965cfee59cead7f8a3b", package = "reth-revm" }
reth-rpc-builder = { git = "https://github.com/gattaca-com/based-op-reth", rev = "b053849462eb48e61b24d965cfee59cead7f8a3b", package = "reth-rpc-builder" }
reth-rpc-layer = { git = "https://github.com/gattaca-com/based-op-reth", rev = "b053849462eb48e61b24d965cfee59cead7f8a3b", package = "reth-rpc-layer" }
reth-stages-types = { git = "https://github.com/gattaca-com/based-op-reth", rev = "b053849462eb48e61b24d965cfee59cead7f8a3b", package = "reth-stages-types" }
reth-storage-api = { git = "https://github.com/gattaca-com/based-op-reth", rev = "b053849462eb48e61b24d965cfee59cead7f8a3b", package = "reth-storage-api" }
reth-storage-errors = { git = "https://github.com/gattaca-com/based-op-reth", rev = "b053849462eb48e61b24d965cfee59cead7f8a3b", package = "reth-storage-errors" }
reth-trie = { git = "https://github.com/gattaca-com/based-op-reth", rev = "b053849462eb48e61b24d965cfee59cead7f8a3b", package = "reth-trie" }
reth-trie-common = { git = "https://github.com/gattaca-com/based-op-reth", rev = "b053849462eb48e61b24d965cfee59cead7f8a3b", package = "reth-trie-common", features = ["test-utils"] }
reth-trie-common = { git = "https://github.com/gattaca-com/based-op-reth", rev = "b053849462eb48e61b24d965cfee59cead7f8a3b", package = "reth-trie-common", features = [
"test-utils",
] }
reth-trie-db = { git = "https://github.com/gattaca-com/based-op-reth", rev = "b053849462eb48e61b24d965cfee59cead7f8a3b", package = "reth-trie-db" }
reth-trie-parallel = { git = "https://github.com/gattaca-com/based-op-reth", rev = "b053849462eb48e61b24d965cfee59cead7f8a3b", package = "reth-trie-parallel" }

revm = { version = "31.0.1", features = [
"optional_balance_check",
"secp256k1",
"std",
], default-features = false }
revm = { version = "31.0.1", features = ["optional_balance_check", "secp256k1", "std"], default-features = false }
revm-handler = "12.0.0"
revm-inspector = "12.0.1"
revm-interpreter = "29.0.1"
revm-primitives = { version = "21.0.2", features = [
"std",
], default-features = false }
revm-primitives = { version = "21.0.2", features = ["std"], default-features = false }

rustc-hash = "2.0.0"
serde = { version = "1.0.217", features = ["derive"] }
Expand All @@ -124,6 +118,7 @@ strum_macros = "0.24"
tabwriter = "1.4.1"
thiserror = "2.0.11"
tokio = { version = "1.43.0", features = ["full"] }
tokio-stream = "0.1.17"
toml = "0.8.19"
tower = { version = "0.5", features = ["timeout"] }
tower-http = { version = "0.6", features = ["cors"] }
Expand Down
30 changes: 20 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 Expand Up @@ -145,6 +149,12 @@ impl From<EnvV0> for VersionedMessage {
}
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct Signed<T: TreeHash> {
pub message: T,
pub signature: Bytes,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct SignedVersionedMessage {
pub message: VersionedMessage,
Expand Down
53 changes: 53 additions & 0 deletions based/crates/reth/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
[package]
edition.workspace = true
name = "based-op-reth"
repository.workspace = true
rust-version.workspace = true
version.workspace = true

[[bin]]
name = "reth-node"
path = "src/bin/reth-node.rs"

[dependencies]
alloy-consensus.workspace = true
alloy-eips.workspace = true
alloy-network.workspace = true
alloy-primitives.workspace = true
alloy-rpc-types.workspace = true
alloy-rpc-types-eth = "1.1.3"
anyhow = "1.0.98"
arc-swap = "1.7.1"
bop-common.workspace = true
clap.workspace = true
eyre.workspace = true
futures.workspace = true
jsonrpsee.workspace = true
op-alloy-consensus = "0.22.1"
op-alloy-network.workspace = true
op-alloy-rpc-types.workspace = true
reth = { git = "https://github.com/paradigmxyz/reth", tag = "v1.9.3" }
reth-chainspec = { git = "https://github.com/paradigmxyz/reth", tag = "v1.9.3", package = "reth-chainspec" }
reth-db = { git = "https://github.com/paradigmxyz/reth", tag = "v1.9.3" }
reth-engine-tree = { git = "https://github.com/paradigmxyz/reth", tag = "v1.9.3", package = "reth-engine-tree" }
reth-evm = { git = "https://github.com/paradigmxyz/reth", tag = "v1.9.3", package = "reth-evm" }
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", package = "reth-optimism-chainspec" }
reth-optimism-cli = { git = "https://github.com/paradigmxyz/reth", tag = "v1.9.3" }
reth-optimism-evm = { git = "https://github.com/paradigmxyz/reth", tag = "v1.9.3", package = "reth-optimism-evm" }
reth-optimism-node = { git = "https://github.com/paradigmxyz/reth", tag = "v1.9.3" }
reth-optimism-primitives = { git = "https://github.com/paradigmxyz/reth", tag = "v1.9.3", package = "reth-optimism-primitives" }
reth-optimism-rpc = { git = "https://github.com/paradigmxyz/reth", tag = "v1.9.3", package = "reth-optimism-rpc" }
reth-revm = { git = "https://github.com/paradigmxyz/reth", tag = "v1.9.3", package = "reth-revm" }
reth-rpc = { git = "https://github.com/paradigmxyz/reth", tag = "v1.9.3" }
reth-rpc-convert = { git = "https://github.com/paradigmxyz/reth", tag = "v1.9.3", package = "reth-rpc-convert" }
reth-rpc-eth-api = { git = "https://github.com/paradigmxyz/reth", tag = "v1.9.3" }
reth-storage-api = { git = "https://github.com/paradigmxyz/reth", tag = "v1.9.3", package = "reth-storage-api" }
reth-storage-errors = { git = "https://github.com/paradigmxyz/reth", tag = "v1.9.3", package = "reth-storage-errors" }
revm = { version = "31.0.1", features = ["optional_balance_check", "secp256k1", "std"], default-features = false }
thiserror.workspace = true
tokio.workspace = true
tokio-stream.workspace = true
tracing.workspace = true
reth_optimism_consensus = { git = "https://github.com/paradigmxyz/reth", tag = "v1.9.3", package = "reth-optimism-consensus" }
65 changes: 65 additions & 0 deletions based/crates/reth/src/api/engine.rs
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)
}
}
Loading
Loading