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

This commit is contained in:
Emilia Hane
2024-11-19 13:53:34 +01:00
committed by GitHub
parent 0db10a13a5
commit da77ffc951
9 changed files with 84 additions and 67 deletions

81
Cargo.lock generated
View File

@ -4579,9 +4579,9 @@ dependencies = [
[[package]] [[package]]
name = "libc" name = "libc"
version = "0.2.164" version = "0.2.162"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "433bfe06b8c75da9b2e3fbea6e5329ff87748f0b144ef75306e674c3f6f7c13f" checksum = "18d287de67fe55fd7e1581fe933d965a5a9477b38e949cfa9f8574ef01506398"
[[package]] [[package]]
name = "libloading" name = "libloading"
@ -4964,9 +4964,9 @@ dependencies = [
[[package]] [[package]]
name = "mockall" name = "mockall"
version = "0.13.1" version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "39a6bfcc6c8c7eed5ee98b9c3e33adc726054389233e201c95dab2d41a3839d2" checksum = "d4c28b3fb6d753d28c20e826cd46ee611fda1cf3cde03a443a974043247c065a"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"downcast", "downcast",
@ -4978,9 +4978,9 @@ dependencies = [
[[package]] [[package]]
name = "mockall_derive" name = "mockall_derive"
version = "0.13.1" version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "25ca3004c2efe9011bd4e461bd8256445052b9615405b4f7ea43fc8ca5c20898" checksum = "341014e7f530314e9a1fdbc7400b244efea7122662c96bfa248c31da5bfb2020"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"proc-macro2", "proc-macro2",
@ -5286,9 +5286,9 @@ checksum = "b410bbe7e14ab526a0e86877eb47c6996a2bd7746f027ba551028c925390e4e9"
[[package]] [[package]]
name = "op-alloy-consensus" name = "op-alloy-consensus"
version = "0.6.7" version = "0.6.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72da577a88d35b893fae6467112651f26ef023434c196b2a0b3dc75bc853e0e4" checksum = "bff54d1d790eca1f3aedbd666162e9c42eceff90b9f9d24b352ed9c2df1e901a"
dependencies = [ dependencies = [
"alloy-consensus", "alloy-consensus",
"alloy-eips", "alloy-eips",
@ -5299,14 +5299,14 @@ dependencies = [
"derive_more 1.0.0", "derive_more 1.0.0",
"serde", "serde",
"serde_with", "serde_with",
"thiserror 2.0.3", "spin",
] ]
[[package]] [[package]]
name = "op-alloy-genesis" name = "op-alloy-genesis"
version = "0.6.7" version = "0.6.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "818180672dd14ca6642fb57942e1cbd602669f42b6e0222b7ea9bbcae065d67e" checksum = "ae84fd64fbc53b3e958ea5a96d7f5633e4a111092e41c51672c2d91835c09efb"
dependencies = [ dependencies = [
"alloy-consensus", "alloy-consensus",
"alloy-eips", "alloy-eips",
@ -5314,14 +5314,13 @@ dependencies = [
"alloy-sol-types", "alloy-sol-types",
"serde", "serde",
"serde_repr", "serde_repr",
"thiserror 2.0.3",
] ]
[[package]] [[package]]
name = "op-alloy-network" name = "op-alloy-network"
version = "0.6.7" version = "0.6.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "12f82e805bad171ceae2af45efaecf8d0b50622cff3473e3c998ff1dd340de35" checksum = "d71e777450ee3e9c5177e00865e9b4496472b623c50f146fc907b667c6b4ab37"
dependencies = [ dependencies = [
"alloy-consensus", "alloy-consensus",
"alloy-network", "alloy-network",
@ -5334,32 +5333,29 @@ dependencies = [
[[package]] [[package]]
name = "op-alloy-protocol" name = "op-alloy-protocol"
version = "0.6.7" version = "0.6.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1803a1ac96203b8f713b1fa9b7509c46c645ca7bc22b582761a7495e999d4301" checksum = "1e854d2d4958d0a213731560172e8455536329ee9574473ff79fa953da91eb6a"
dependencies = [ dependencies = [
"alloc-no-stdlib",
"alloy-consensus", "alloy-consensus",
"alloy-eips", "alloy-eips",
"alloy-primitives", "alloy-primitives",
"alloy-rlp", "alloy-rlp",
"alloy-serde", "alloy-serde",
"async-trait", "async-trait",
"brotli", "derive_more 1.0.0",
"miniz_oxide",
"op-alloy-consensus", "op-alloy-consensus",
"op-alloy-genesis", "op-alloy-genesis",
"serde", "serde",
"thiserror 2.0.3",
"tracing", "tracing",
"unsigned-varint", "unsigned-varint",
] ]
[[package]] [[package]]
name = "op-alloy-rpc-types" name = "op-alloy-rpc-types"
version = "0.6.7" version = "0.6.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a838c125256e02e2f9da88c51e263b02a06cda7e60382fe2551a3385b516f5bb" checksum = "981b7f8ab11fe85ba3c1723702f000429b8d0c16b5883c93d577895f262cbac6"
dependencies = [ dependencies = [
"alloy-consensus", "alloy-consensus",
"alloy-eips", "alloy-eips",
@ -5376,9 +5372,9 @@ dependencies = [
[[package]] [[package]]
name = "op-alloy-rpc-types-engine" name = "op-alloy-rpc-types-engine"
version = "0.6.7" version = "0.6.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c227fcc7d81d4023363ba12406e57ebcc1c7cbb1075c38ea471ae32138d4706d" checksum = "a227b16c9c5df68b112c8db9d268ebf46b3e26c744b4d59d4949575cd603a292"
dependencies = [ dependencies = [
"alloy-eips", "alloy-eips",
"alloy-primitives", "alloy-primitives",
@ -5390,7 +5386,6 @@ dependencies = [
"op-alloy-protocol", "op-alloy-protocol",
"serde", "serde",
"snap", "snap",
"thiserror 2.0.3",
] ]
[[package]] [[package]]
@ -5470,9 +5465,9 @@ dependencies = [
[[package]] [[package]]
name = "parity-scale-codec" name = "parity-scale-codec"
version = "3.7.0" version = "3.6.12"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8be4817d39f3272f69c59fe05d0535ae6456c2dc2fa1ba02910296c7e0a5c590" checksum = "306800abfa29c7f16596b5970a588435e3d5b3149683d00c12b699cc19f895ee"
dependencies = [ dependencies = [
"arbitrary", "arbitrary",
"arrayvec", "arrayvec",
@ -5481,20 +5476,19 @@ dependencies = [
"bytes", "bytes",
"impl-trait-for-tuples", "impl-trait-for-tuples",
"parity-scale-codec-derive", "parity-scale-codec-derive",
"rustversion",
"serde", "serde",
] ]
[[package]] [[package]]
name = "parity-scale-codec-derive" name = "parity-scale-codec-derive"
version = "3.7.0" version = "3.6.12"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8781a75c6205af67215f382092b6e0a4ff3734798523e69073d4bcd294ec767b" checksum = "d830939c76d294956402033aee57a6da7b438f2294eb94864c37b0569053a42c"
dependencies = [ dependencies = [
"proc-macro-crate", "proc-macro-crate",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.87", "syn 1.0.109",
] ]
[[package]] [[package]]
@ -8268,6 +8262,7 @@ dependencies = [
"reth-optimism-chainspec", "reth-optimism-chainspec",
"reth-optimism-consensus", "reth-optimism-consensus",
"reth-optimism-forks", "reth-optimism-forks",
"reth-optimism-primitives",
"reth-primitives", "reth-primitives",
"reth-prune-types", "reth-prune-types",
"reth-revm", "reth-revm",
@ -8387,6 +8382,7 @@ dependencies = [
"derive_more 1.0.0", "derive_more 1.0.0",
"op-alloy-consensus", "op-alloy-consensus",
"reth-codecs", "reth-codecs",
"reth-node-types",
"reth-primitives", "reth-primitives",
"reth-primitives-traits", "reth-primitives-traits",
"rstest", "rstest",
@ -9749,9 +9745,9 @@ dependencies = [
[[package]] [[package]]
name = "rustix" name = "rustix"
version = "0.38.41" version = "0.38.40"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d7f649912bc1495e167a6edee79151c84b1bad49748cb4f1f1167f459f6224f6" checksum = "99e4ea3e1cdc4b559b8e5650f9c8e5998e3e5c1343b4eaf034565f32318d63c0"
dependencies = [ dependencies = [
"bitflags 2.6.0", "bitflags 2.6.0",
"errno", "errno",
@ -9762,9 +9758,9 @@ dependencies = [
[[package]] [[package]]
name = "rustls" name = "rustls"
version = "0.23.17" version = "0.23.16"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f1a745511c54ba6d4465e8d5dfbd81b45791756de28d4981af70d6dca128f1e" checksum = "eee87ff5d9b36712a58574e12e9f0ea80f915a5b0ac518d322b24a465617925e"
dependencies = [ dependencies = [
"log", "log",
"once_cell", "once_cell",
@ -10062,9 +10058,9 @@ dependencies = [
[[package]] [[package]]
name = "serde_json" name = "serde_json"
version = "1.0.133" version = "1.0.132"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c7fceb2473b9166b2294ef05efcb65a3db80803f0b03ef86a5fc88a2b85ee377" checksum = "d726bfaff4b320266d395898905d0eba0345aae23b54aee3a737e260fd46db03"
dependencies = [ dependencies = [
"indexmap 2.6.0", "indexmap 2.6.0",
"itoa", "itoa",
@ -10389,6 +10385,9 @@ name = "spin"
version = "0.9.8" version = "0.9.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67"
dependencies = [
"lock_api",
]
[[package]] [[package]]
name = "spki" name = "spki"
@ -10992,9 +10991,9 @@ dependencies = [
[[package]] [[package]]
name = "tower-http" name = "tower-http"
version = "0.6.2" version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "403fa3b783d4b626a8ad51d766ab03cb6d2dbfc46b1c5d4448395e6628dc9697" checksum = "8437150ab6bbc8c5f0f519e3d5ed4aa883a83dd4cdd3d1b21f9482936046cb97"
dependencies = [ dependencies = [
"async-compression", "async-compression",
"base64 0.22.1", "base64 0.22.1",
@ -11594,9 +11593,9 @@ dependencies = [
[[package]] [[package]]
name = "wasmtimer" name = "wasmtimer"
version = "0.4.1" version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0048ad49a55b9deb3953841fa1fc5858f0efbcb7a18868c899a360269fac1b23" checksum = "bb4f099acbc1043cc752b91615b24b02d7f6fcd975bd781fed9f50b3c3e15bf7"
dependencies = [ dependencies = [
"futures", "futures",
"js-sys", "js-sys",

View File

@ -48,6 +48,7 @@ reth-primitives = { workspace = true, features = ["test-utils"] }
reth-optimism-chainspec.workspace = true reth-optimism-chainspec.workspace = true
alloy-genesis.workspace = true alloy-genesis.workspace = true
alloy-consensus.workspace = true alloy-consensus.workspace = true
reth-optimism-primitives.workspace = true
[features] [features]
default = ["std"] default = ["std"]

View File

@ -211,6 +211,7 @@ mod tests {
AccountRevertInit, BundleStateInit, Chain, ExecutionOutcome, RevertsInit, AccountRevertInit, BundleStateInit, Chain, ExecutionOutcome, RevertsInit,
}; };
use reth_optimism_chainspec::BASE_MAINNET; use reth_optimism_chainspec::BASE_MAINNET;
use reth_optimism_primitives::OpPrimitives;
use reth_primitives::{Account, Log, Receipt, Receipts, SealedBlockWithSenders, TxType}; use reth_primitives::{Account, Log, Receipt, Receipts, SealedBlockWithSenders, TxType};
use reth_revm::{ use reth_revm::{
@ -602,7 +603,8 @@ mod tests {
// Create a Chain object with a BTreeMap of blocks mapped to their block numbers, // Create a Chain object with a BTreeMap of blocks mapped to their block numbers,
// including block1_hash and block2_hash, and the execution_outcome // 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 that the proper receipt vector is returned for block1_hash
assert_eq!(chain.receipts_by_block_hash(block1_hash), Some(vec![&receipt1])); assert_eq!(chain.receipts_by_block_hash(block1_hash), Some(vec![&receipt1]));

View File

@ -1,18 +1,14 @@
//! Optimism Node types config. //! Optimism Node types config.
use crate::{ use std::sync::Arc;
args::RollupArgs,
engine::OpEngineValidator,
txpool::{OpTransactionPool, OpTransactionValidator},
OpEngineTypes,
};
use alloy_consensus::Header; use alloy_consensus::Header;
use reth_basic_payload_builder::{BasicPayloadJobGenerator, BasicPayloadJobGeneratorConfig}; use reth_basic_payload_builder::{BasicPayloadJobGenerator, BasicPayloadJobGeneratorConfig};
use reth_chainspec::{EthChainSpec, Hardforks}; use reth_chainspec::{EthChainSpec, Hardforks};
use reth_evm::{execute::BasicBlockExecutorProvider, ConfigureEvm}; use reth_evm::{execute::BasicBlockExecutorProvider, ConfigureEvm};
use reth_network::{NetworkConfig, NetworkHandle, NetworkManager, PeersInfo}; use reth_network::{NetworkConfig, NetworkHandle, NetworkManager, PeersInfo};
use reth_node_api::{ use reth_node_api::{
AddOnsContext, EngineValidator, FullNodeComponents, NodeAddOns, NodePrimitives, PayloadBuilder, AddOnsContext, EngineValidator, FullNodeComponents, NodeAddOns, PayloadBuilder,
}; };
use reth_node_builder::{ use reth_node_builder::{
components::{ components::{
@ -32,7 +28,6 @@ use reth_optimism_rpc::{
OpEthApi, OpEthApi,
}; };
use reth_payload_builder::{PayloadBuilderHandle, PayloadBuilderService}; use reth_payload_builder::{PayloadBuilderHandle, PayloadBuilderService};
use reth_primitives::{Block, Receipt, TransactionSigned, TxType};
use reth_provider::CanonStateSubscriptions; use reth_provider::CanonStateSubscriptions;
use reth_rpc_server_types::RethRpcModule; use reth_rpc_server_types::RethRpcModule;
use reth_tracing::tracing::{debug, info}; use reth_tracing::tracing::{debug, info};
@ -41,18 +36,13 @@ use reth_transaction_pool::{
TransactionValidationTaskExecutor, TransactionValidationTaskExecutor,
}; };
use reth_trie_db::MerklePatriciaTrie; use reth_trie_db::MerklePatriciaTrie;
use std::sync::Arc;
/// Optimism primitive types. use crate::{
#[derive(Debug, Default, Clone, PartialEq, Eq)] args::RollupArgs,
pub struct OpPrimitives; engine::OpEngineValidator,
txpool::{OpTransactionPool, OpTransactionValidator},
impl NodePrimitives for OpPrimitives { OpEngineTypes,
type Block = Block; };
type SignedTx = TransactionSigned;
type TxType = TxType;
type Receipt = Receipt;
}
/// Type configuration for a regular Optimism node. /// Type configuration for a regular Optimism node.
#[derive(Debug, Default, Clone)] #[derive(Debug, Default, Clone)]
@ -125,7 +115,7 @@ where
} }
impl NodeTypes for OpNode { 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 ChainSpec = OpChainSpec;
type StateCommitment = MerklePatriciaTrie; type StateCommitment = MerklePatriciaTrie;
} }

View File

@ -7,7 +7,7 @@ use alloy_eips::{
use alloy_primitives::{keccak256, Address, Bytes, B256, B64, U256}; use alloy_primitives::{keccak256, Address, Bytes, B256, B64, U256};
use alloy_rlp::Encodable; use alloy_rlp::Encodable;
use alloy_rpc_types_engine::{ExecutionPayloadEnvelopeV2, ExecutionPayloadV1, PayloadId}; 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. /// Re-export for use in downstream arguments.
pub use op_alloy_rpc_types_engine::OpPayloadAttributes; pub use op_alloy_rpc_types_engine::OpPayloadAttributes;
use op_alloy_rpc_types_engine::{OpExecutionPayloadEnvelopeV3, OpExecutionPayloadEnvelopeV4}; use op_alloy_rpc_types_engine::{OpExecutionPayloadEnvelopeV3, OpExecutionPayloadEnvelopeV4};

View File

@ -13,9 +13,10 @@ workspace = true
[dependencies] [dependencies]
# reth # reth
reth-node-types.workspace = true
reth-primitives.workspace = true
reth-primitives-traits.workspace = true reth-primitives-traits.workspace = true
reth-codecs = { workspace = true, optional = true } reth-codecs = { workspace = true, optional = true }
reth-primitives = { workspace = true, features = ["reth-codec"], optional = true }
# ethereum # ethereum
alloy-primitives.workspace = true alloy-primitives.workspace = true
@ -41,7 +42,7 @@ rstest.workspace = true
default = ["reth-codec"] default = ["reth-codec"]
reth-codec = [ reth-codec = [
"dep:reth-codecs", "dep:reth-codecs",
"dep:reth-primitives" "reth-primitives/reth-codec"
] ]
serde = [ serde = [
"dep:serde", "dep:serde",

View File

@ -9,3 +9,19 @@
pub mod bedrock; pub mod bedrock;
pub mod tx_type; pub mod tx_type;
pub use tx_type::OpTxType;
use reth_node_types::NodePrimitives;
use reth_primitives::{Block, Receipt, TransactionSigned};
/// Optimism primitive types.
#[derive(Debug, Default, Clone, PartialEq, Eq)]
pub struct OpPrimitives;
impl NodePrimitives for OpPrimitives {
type Block = Block;
type SignedTx = TransactionSigned;
type TxType = OpTxType;
type Receipt = Receipt;
}

View File

@ -1,8 +1,16 @@
//! Block body abstraction. //! Block body abstraction.
use crate::{InMemorySize, MaybeSerde};
use alloc::fmt; use alloc::fmt;
use alloy_consensus::Transaction; use alloy_consensus::Transaction;
use reth_codecs::Compact;
use crate::{FullSignedTx, InMemorySize, MaybeSerde};
/// Helper trait that unifies all behaviour required by transaction to support full node operations.
pub trait FullBlockBody: BlockBody<Transaction: FullSignedTx> + Compact {}
impl<T> FullBlockBody for T where T: BlockBody<Transaction: FullSignedTx> + Compact {}
/// Abstraction for block's body. /// Abstraction for block's body.
#[auto_impl::auto_impl(&, Arc)] #[auto_impl::auto_impl(&, Arc)]

View File

@ -36,7 +36,7 @@ pub use integer_list::{IntegerList, IntegerListError};
pub mod block; pub mod block;
pub use block::{ pub use block::{
body::BlockBody, body::{BlockBody, FullBlockBody},
header::{BlockHeader, FullBlockHeader}, header::{BlockHeader, FullBlockHeader},
Block, FullBlock, Block, FullBlock,
}; };