Skip to content
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

chore(sdk): Move reth_optimism_node::OpPrimitives into reth-optimism-primitives #12649

Merged
merged 11 commits into from
Nov 19, 2024
81 changes: 40 additions & 41 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions crates/optimism/evm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ reth-primitives = { workspace = true, features = ["test-utils"] }
reth-optimism-chainspec.workspace = true
alloy-genesis.workspace = true
alloy-consensus.workspace = true
reth-optimism-primitives.workspace = true

[features]
default = ["std"]
Expand Down
4 changes: 3 additions & 1 deletion crates/optimism/evm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ mod tests {
AccountRevertInit, BundleStateInit, Chain, ExecutionOutcome, RevertsInit,
};
use reth_optimism_chainspec::BASE_MAINNET;
use reth_optimism_primitives::OpPrimitives;
use reth_primitives::{Account, Log, Receipt, Receipts, SealedBlockWithSenders, TxType};

use reth_revm::{
Expand Down Expand Up @@ -602,7 +603,8 @@ mod tests {

// Create a Chain object with a BTreeMap of blocks mapped to their block numbers,
// including block1_hash and block2_hash, and the execution_outcome
let chain: Chain = Chain::new([block1, block2], execution_outcome.clone(), None);
let chain: Chain<OpPrimitives> =
Chain::new([block1, block2], execution_outcome.clone(), None);

// Assert that the proper receipt vector is returned for block1_hash
assert_eq!(chain.receipts_by_block_hash(block1_hash), Some(vec![&receipt1]));
Expand Down
30 changes: 10 additions & 20 deletions crates/optimism/node/src/node.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
//! Optimism Node types config.

use crate::{
args::RollupArgs,
engine::OpEngineValidator,
txpool::{OpTransactionPool, OpTransactionValidator},
OpEngineTypes,
};
use std::sync::Arc;

use alloy_consensus::Header;
use reth_basic_payload_builder::{BasicPayloadJobGenerator, BasicPayloadJobGeneratorConfig};
use reth_chainspec::{EthChainSpec, Hardforks};
use reth_evm::{execute::BasicBlockExecutorProvider, ConfigureEvm};
use reth_network::{NetworkConfig, NetworkHandle, NetworkManager, PeersInfo};
use reth_node_api::{
AddOnsContext, EngineValidator, FullNodeComponents, NodeAddOns, NodePrimitives, PayloadBuilder,
AddOnsContext, EngineValidator, FullNodeComponents, NodeAddOns, PayloadBuilder,
};
use reth_node_builder::{
components::{
Expand All @@ -32,7 +28,6 @@ use reth_optimism_rpc::{
OpEthApi,
};
use reth_payload_builder::{PayloadBuilderHandle, PayloadBuilderService};
use reth_primitives::{Block, Receipt, TransactionSigned, TxType};
use reth_provider::CanonStateSubscriptions;
use reth_rpc_server_types::RethRpcModule;
use reth_tracing::tracing::{debug, info};
Expand All @@ -41,18 +36,13 @@ use reth_transaction_pool::{
TransactionValidationTaskExecutor,
};
use reth_trie_db::MerklePatriciaTrie;
use std::sync::Arc;

/// Optimism primitive types.
#[derive(Debug, Default, Clone, PartialEq, Eq)]
pub struct OpPrimitives;

impl NodePrimitives for OpPrimitives {
type Block = Block;
type SignedTx = TransactionSigned;
type TxType = TxType;
type Receipt = Receipt;
}
use crate::{
args::RollupArgs,
engine::OpEngineValidator,
txpool::{OpTransactionPool, OpTransactionValidator},
OpEngineTypes,
};

/// Type configuration for a regular Optimism node.
#[derive(Debug, Default, Clone)]
Expand Down Expand Up @@ -125,7 +115,7 @@ where
}

impl NodeTypes for OpNode {
type Primitives = OpPrimitives;
type Primitives = reth_primitives::EthPrimitives; // todo: replace with OpPrimitives when EthPrimitives is only used in reth-ethereum-* crates
type ChainSpec = OpChainSpec;
type StateCommitment = MerklePatriciaTrie;
}
Expand Down
2 changes: 1 addition & 1 deletion crates/optimism/payload/src/payload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use alloy_eips::{
use alloy_primitives::{keccak256, Address, Bytes, B256, B64, U256};
use alloy_rlp::Encodable;
use alloy_rpc_types_engine::{ExecutionPayloadEnvelopeV2, ExecutionPayloadV1, PayloadId};
use op_alloy_consensus::{decode_holocene_extra_data, EIP1559ParamError};
use op_alloy_consensus::eip1559::{decode_holocene_extra_data, EIP1559ParamError};
/// Re-export for use in downstream arguments.
pub use op_alloy_rpc_types_engine::OpPayloadAttributes;
use op_alloy_rpc_types_engine::{OpExecutionPayloadEnvelopeV3, OpExecutionPayloadEnvelopeV4};
Expand Down
5 changes: 3 additions & 2 deletions crates/optimism/primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ workspace = true

[dependencies]
# reth
reth-node-types.workspace = true
reth-primitives.workspace = true
reth-primitives-traits.workspace = true
reth-codecs = { workspace = true, optional = true }
reth-primitives = { workspace = true, features = ["reth-codec"], optional = true }

# ethereum
alloy-primitives.workspace = true
Expand All @@ -41,7 +42,7 @@ rstest.workspace = true
default = ["reth-codec"]
reth-codec = [
"dep:reth-codecs",
"dep:reth-primitives"
"reth-primitives/reth-codec"
]
serde = [
"dep:serde",
Expand Down
Loading
Loading