Skip to content
Merged
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
4 changes: 3 additions & 1 deletion Cargo.lock

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

9 changes: 3 additions & 6 deletions crates/optimism/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ reth-rpc-api.workspace = true
reth-optimism-payload-builder.workspace = true
reth-optimism-evm.workspace = true
reth-optimism-rpc.workspace = true
reth-optimism-storage.workspace = true
reth-optimism-txpool.workspace = true
reth-optimism-chainspec.workspace = true
reth-optimism-consensus = { workspace = true, features = ["std"] }
Expand Down Expand Up @@ -94,9 +95,7 @@ asm-keccak = [
"reth-optimism-node/asm-keccak",
"reth-node-core/asm-keccak",
]
js-tracer = [
"reth-node-builder/js-tracer",
]
js-tracer = ["reth-node-builder/js-tracer"]
test-utils = [
"reth-tasks",
"reth-e2e-test-utils",
Expand All @@ -119,6 +118,4 @@ test-utils = [
"reth-primitives-traits/test-utils",
"reth-trie-common/test-utils",
]
reth-codec = [
"reth-optimism-primitives/reth-codec",
]
reth-codec = ["reth-optimism-primitives/reth-codec"]
2 changes: 2 additions & 0 deletions crates/optimism/node/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,5 @@ pub use reth_optimism_payload_builder::{
};

pub use reth_optimism_evm::*;

pub use reth_optimism_storage::OpStorage;
7 changes: 3 additions & 4 deletions crates/optimism/node/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,19 @@ use reth_optimism_payload_builder::{
config::{OpBuilderConfig, OpDAConfig},
OpBuiltPayload, OpPayloadBuilderAttributes, OpPayloadPrimitives,
};
use reth_optimism_primitives::{DepositReceipt, OpPrimitives, OpTransactionSigned};
use reth_optimism_primitives::{DepositReceipt, OpPrimitives};
use reth_optimism_rpc::{
eth::{ext::OpEthExtApi, OpEthApiBuilder},
miner::{MinerApiExtServer, OpMinerExtApi},
witness::{DebugExecutionWitnessApiServer, OpDebugWitnessApi},
OpEthApi, OpEthApiError, SequencerClient,
};
use reth_optimism_storage::OpStorage;
use reth_optimism_txpool::{
supervisor::{SupervisorClient, DEFAULT_SUPERVISOR_URL},
OpPooledTx,
};
use reth_provider::{providers::ProviderFactoryBuilder, CanonStateSubscriptions, EthStorage};
use reth_provider::{providers::ProviderFactoryBuilder, CanonStateSubscriptions};
use reth_rpc_api::DebugApiServer;
use reth_rpc_eth_api::{ext::L2EthApiExtServer, FullEthApiServer};
use reth_rpc_eth_types::error::FromEvmError;
Expand Down Expand Up @@ -79,8 +80,6 @@ impl<N> OpNodeTypes for N where
>
{
}
/// Storage implementation for Optimism.
pub type OpStorage = EthStorage<OpTransactionSigned>;

/// Type configuration for a regular Optimism node.
#[derive(Debug, Default, Clone)]
Expand Down
5 changes: 3 additions & 2 deletions crates/optimism/storage/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ workspace = true

[dependencies]
# reth
reth-node-api.workspace = true
reth-chainspec.workspace = true
reth-primitives-traits.workspace = true
reth-optimism-forks.workspace = true
reth-optimism-primitives = { workspace = true, features = ["serde", "reth-codec"] }
reth-storage-api = { workspace = true, features = ["db-api"] }
reth-db-api.workspace = true
reth-provider.workspace = true

# ethereum
alloy-primitives.workspace = true
Expand All @@ -37,7 +39,6 @@ std = [
"reth-stages-types/std",
"alloy-consensus/std",
"reth-chainspec/std",
"reth-optimism-forks/std",
"reth-optimism-primitives/std",
"reth-primitives-traits/std",
]
55 changes: 47 additions & 8 deletions crates/optimism/storage/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,60 @@ use alloy_consensus::Header;
use alloy_primitives::BlockNumber;
use core::marker::PhantomData;
use reth_chainspec::{ChainSpecProvider, EthChainSpec, EthereumHardforks};
use reth_optimism_forks::OpHardforks;
use reth_db_api::transaction::{DbTx, DbTxMut};
use reth_node_api::{FullNodePrimitives, FullSignedTx};
use reth_optimism_primitives::OpTransactionSigned;
use reth_primitives_traits::{Block, FullBlockHeader, SignedTransaction};
use reth_provider::{
providers::{ChainStorage, NodeTypesForProvider},
DatabaseProvider,
};
use reth_storage_api::{
errors::ProviderResult, BlockBodyReader, BlockBodyWriter, DBProvider, ReadBodyInput,
StorageLocation,
errors::ProviderResult, BlockBodyReader, BlockBodyWriter, ChainStorageReader,
ChainStorageWriter, DBProvider, ReadBodyInput, StorageLocation,
};

/// Optimism storage implementation.
#[derive(Debug, Clone, Copy)]
pub struct OptStorage<T = OpTransactionSigned, H = Header>(PhantomData<(T, H)>);
pub struct OpStorage<T = OpTransactionSigned, H = Header>(PhantomData<(T, H)>);

impl<T, H> Default for OpStorage<T, H> {
fn default() -> Self {
Self(Default::default())
}
}

impl<N, T, H> ChainStorage<N> for OpStorage<T, H>
where
T: FullSignedTx,
H: FullBlockHeader,
N: FullNodePrimitives<
Block = alloy_consensus::Block<T, H>,
BlockHeader = H,
BlockBody = alloy_consensus::BlockBody<T, H>,
SignedTx = T,
>,
{
fn reader<TX, Types>(&self) -> impl ChainStorageReader<DatabaseProvider<TX, Types>, N>
where
TX: DbTx + 'static,
Types: NodeTypesForProvider<Primitives = N>,
{
self
}

fn writer<TX, Types>(&self) -> impl ChainStorageWriter<DatabaseProvider<TX, Types>, N>
where
TX: DbTxMut + DbTx + 'static,
Types: NodeTypesForProvider<Primitives = N>,
{
self
}
}

impl<Provider, T, H> BlockBodyWriter<Provider, alloy_consensus::BlockBody<T, H>>
for OptStorage<T, H>
impl<Provider, T, H> BlockBodyWriter<Provider, alloy_consensus::BlockBody<T, H>> for OpStorage<T, H>
where
Provider: DBProvider<Tx: DbTxMut>,
T: SignedTransaction,
H: FullBlockHeader,
{
Expand All @@ -42,9 +81,9 @@ where
}
}

impl<Provider, T, H> BlockBodyReader<Provider> for OptStorage<T, H>
impl<Provider, T, H> BlockBodyReader<Provider> for OpStorage<T, H>
where
Provider: ChainSpecProvider<ChainSpec: EthChainSpec + OpHardforks> + DBProvider,
Provider: ChainSpecProvider<ChainSpec: EthChainSpec + EthereumHardforks> + DBProvider,
T: SignedTransaction,
H: FullBlockHeader,
{
Expand Down
2 changes: 1 addition & 1 deletion crates/optimism/storage/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
extern crate alloc;

mod chain;
pub use chain::OptStorage;
pub use chain::OpStorage;

#[cfg(test)]
mod tests {
Expand Down
2 changes: 1 addition & 1 deletion examples/custom-node/src/engine_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use reth_ethereum::node::api::{
NodeTypes,
};
use reth_node_builder::rpc::EngineApiBuilder;
use reth_op::node::node::OpStorage;
use reth_op::node::OpStorage;
use reth_payload_builder::PayloadStore;
use reth_rpc_api::IntoEngineApiRpcModule;
use reth_rpc_engine_api::EngineApiError;
Expand Down
Loading