optimism: replace reth-primitive imports (#10800)

This commit is contained in:
Håvard Anda Estensen
2024-09-10 12:51:43 +02:00
committed by GitHub
parent 1b74f16ec3
commit 0213e8841f
24 changed files with 56 additions and 40 deletions

2
Cargo.lock generated
View File

@ -7206,6 +7206,7 @@ dependencies = [
name = "reth-evm-optimism" name = "reth-evm-optimism"
version = "1.0.6" version = "1.0.6"
dependencies = [ dependencies = [
"alloy-primitives",
"reth-chainspec", "reth-chainspec",
"reth-ethereum-forks", "reth-ethereum-forks",
"reth-evm", "reth-evm",
@ -7941,6 +7942,7 @@ dependencies = [
name = "reth-optimism-payload-builder" name = "reth-optimism-payload-builder"
version = "1.0.6" version = "1.0.6"
dependencies = [ dependencies = [
"alloy-primitives",
"alloy-rlp", "alloy-rlp",
"reth-basic-payload-builder", "reth-basic-payload-builder",
"reth-chain-state", "reth-chain-state",

View File

@ -42,12 +42,10 @@ reth-cli-runner.workspace = true
reth-node-builder.workspace = true reth-node-builder.workspace = true
reth-tracing.workspace = true reth-tracing.workspace = true
# eth # eth
alloy-primitives.workspace = true alloy-primitives.workspace = true
alloy-rlp.workspace = true alloy-rlp.workspace = true
# misc # misc
futures-util.workspace = true futures-util.workspace = true
clap = { workspace = true, features = ["derive", "env"] } clap = { workspace = true, features = ["derive", "env"] }
@ -68,10 +66,10 @@ tempfile.workspace = true
reth-stages = { workspace = true, features = ["test-utils"] } reth-stages = { workspace = true, features = ["test-utils"] }
reth-db-common.workspace = true reth-db-common.workspace = true
[features] [features]
optimism = [ optimism = [
"reth-primitives/optimism", "reth-primitives/optimism",
"reth-evm-optimism/optimism", "reth-evm-optimism/optimism",
"reth-provider/optimism", "reth-provider/optimism",
"reth-node-optimism/optimism", "reth-node-optimism/optimism",
] ]

View File

@ -252,8 +252,8 @@ pub struct ImportReceiptsResult {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use alloy_primitives::hex;
use reth_db_common::init::init_genesis; use reth_db_common::init::init_genesis;
use reth_primitives::hex;
use reth_stages::test_utils::TestStageDB; use reth_stages::test_utils::TestStageDB;
use tempfile::tempfile; use tempfile::tempfile;
use tokio::{ use tokio::{

View File

@ -1,9 +1,10 @@
//! Codec for reading raw receipts from a file. //! Codec for reading raw receipts from a file.
use alloy_primitives::B256;
use alloy_rlp::{Decodable, RlpDecodable}; use alloy_rlp::{Decodable, RlpDecodable};
use reth_primitives::{ use reth_primitives::{
bytes::{Buf, BytesMut}, bytes::{Buf, BytesMut},
Address, Bloom, Bytes, Log, Receipt, TxType, B256, Address, Bloom, Bytes, Log, Receipt, TxType,
}; };
use tokio_util::codec::Decoder; use tokio_util::codec::Decoder;
@ -94,7 +95,8 @@ impl TryFrom<HackReceipt> for ReceiptWithBlockNumber {
#[cfg(test)] #[cfg(test)]
pub(crate) mod test { pub(crate) mod test {
use reth_primitives::{alloy_primitives::LogData, hex}; use alloy_primitives::hex;
use reth_primitives::alloy_primitives::LogData;
use super::*; use super::*;

View File

@ -19,12 +19,14 @@ reth-consensus.workspace = true
reth-primitives.workspace = true reth-primitives.workspace = true
reth-trie-common.workspace = true reth-trie-common.workspace = true
# ethereum
alloy-primitives.workspace = true
tracing.workspace = true tracing.workspace = true
[dev-dependencies] [dev-dependencies]
alloy-primitives.workspace = true alloy-primitives.workspace = true
reth-optimism-chainspec.workspace = true reth-optimism-chainspec.workspace = true
[features] [features]
optimism = ["reth-primitives/optimism"] optimism = ["reth-primitives/optimism"]

View File

@ -9,6 +9,7 @@
// The `optimism` feature must be enabled to use this crate. // The `optimism` feature must be enabled to use this crate.
#![cfg(feature = "optimism")] #![cfg(feature = "optimism")]
use alloy_primitives::U256;
use reth_chainspec::{ChainSpec, EthereumHardforks, OptimismHardforks}; use reth_chainspec::{ChainSpec, EthereumHardforks, OptimismHardforks};
use reth_consensus::{Consensus, ConsensusError, PostExecutionInput}; use reth_consensus::{Consensus, ConsensusError, PostExecutionInput};
use reth_consensus_common::validation::{ use reth_consensus_common::validation::{
@ -17,9 +18,7 @@ use reth_consensus_common::validation::{
validate_block_pre_execution, validate_header_base_fee, validate_header_extradata, validate_block_pre_execution, validate_header_base_fee, validate_header_extradata,
validate_header_gas, validate_header_gas,
}; };
use reth_primitives::{ use reth_primitives::{BlockWithSenders, Header, SealedBlock, SealedHeader, EMPTY_OMMER_ROOT_HASH};
BlockWithSenders, Header, SealedBlock, SealedHeader, EMPTY_OMMER_ROOT_HASH, U256,
};
use std::{sync::Arc, time::SystemTime}; use std::{sync::Arc, time::SystemTime};
mod proof; mod proof;

View File

@ -1,7 +1,8 @@
//! Helper function for Receipt root calculation for Optimism hardforks. //! Helper function for Receipt root calculation for Optimism hardforks.
use alloy_primitives::B256;
use reth_chainspec::{ChainSpec, OptimismHardfork}; use reth_chainspec::{ChainSpec, OptimismHardfork};
use reth_primitives::{ReceiptWithBloom, B256}; use reth_primitives::ReceiptWithBloom;
use reth_trie_common::root::ordered_trie_root_with_encoder; use reth_trie_common::root::ordered_trie_root_with_encoder;
/// Calculates the receipt root for a header. /// Calculates the receipt root for a header.

View File

@ -1,9 +1,8 @@
use crate::proof::calculate_receipt_root_optimism; use crate::proof::calculate_receipt_root_optimism;
use alloy_primitives::{Bloom, B256};
use reth_chainspec::{ChainSpec, EthereumHardforks}; use reth_chainspec::{ChainSpec, EthereumHardforks};
use reth_consensus::ConsensusError; use reth_consensus::ConsensusError;
use reth_primitives::{ use reth_primitives::{gas_spent_by_transactions, BlockWithSenders, GotExpected, Receipt};
gas_spent_by_transactions, BlockWithSenders, Bloom, GotExpected, Receipt, B256,
};
/// Validate a block with regard to execution results: /// Validate a block with regard to execution results:
/// ///

View File

@ -21,6 +21,9 @@ reth-execution-errors.workspace = true
reth-execution-types.workspace = true reth-execution-types.workspace = true
reth-prune-types.workspace = true reth-prune-types.workspace = true
# ethereum
alloy-primitives.workspace = true
# Optimism # Optimism
reth-optimism-consensus.workspace = true reth-optimism-consensus.workspace = true

View File

@ -19,7 +19,7 @@ pub enum OptimismBlockExecutionError {
BlobTransactionRejected, BlobTransactionRejected,
/// Thrown when a database account could not be loaded. /// Thrown when a database account could not be loaded.
#[error("failed to load account {0}")] #[error("failed to load account {0}")]
AccountLoadFailed(reth_primitives::Address), AccountLoadFailed(alloy_primitives::Address),
} }
impl From<OptimismBlockExecutionError> for BlockExecutionError { impl From<OptimismBlockExecutionError> for BlockExecutionError {

View File

@ -1,6 +1,7 @@
//! Optimism block executor. //! Optimism block executor.
use crate::{l1::ensure_create2_deployer, OptimismBlockExecutionError, OptimismEvmConfig}; use crate::{l1::ensure_create2_deployer, OptimismBlockExecutionError, OptimismEvmConfig};
use alloy_primitives::{BlockNumber, U256};
use reth_chainspec::{ChainSpec, EthereumHardforks, OptimismHardfork}; use reth_chainspec::{ChainSpec, EthereumHardforks, OptimismHardfork};
use reth_evm::{ use reth_evm::{
execute::{ execute::{
@ -12,7 +13,7 @@ use reth_evm::{
}; };
use reth_execution_types::ExecutionOutcome; use reth_execution_types::ExecutionOutcome;
use reth_optimism_consensus::validate_block_post_execution; use reth_optimism_consensus::validate_block_post_execution;
use reth_primitives::{BlockNumber, BlockWithSenders, Header, Receipt, Receipts, TxType, U256}; use reth_primitives::{BlockWithSenders, Header, Receipt, Receipts, TxType};
use reth_prune_types::PruneModes; use reth_prune_types::PruneModes;
use reth_revm::{ use reth_revm::{
batch::BlockBatchRecord, db::states::bundle_state::BundleRetention, batch::BlockBatchRecord, db::states::bundle_state::BundleRetention,
@ -441,10 +442,10 @@ where
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use alloy_primitives::{b256, Address, StorageKey, StorageValue};
use reth_chainspec::ChainSpecBuilder; use reth_chainspec::ChainSpecBuilder;
use reth_primitives::{ use reth_primitives::{
b256, Account, Address, Block, Signature, StorageKey, StorageValue, Transaction, Account, Block, Signature, Transaction, TransactionSigned, TxEip1559, BASE_MAINNET,
TransactionSigned, TxEip1559, BASE_MAINNET,
}; };
use reth_revm::{ use reth_revm::{
database::StateProviderDatabase, test_utils::StateProviderTest, L1_BLOCK_CONTRACT, database::StateProviderDatabase, test_utils::StateProviderTest, L1_BLOCK_CONTRACT,

View File

@ -1,9 +1,10 @@
//! Optimism-specific implementation and utilities for the executor //! Optimism-specific implementation and utilities for the executor
use crate::OptimismBlockExecutionError; use crate::OptimismBlockExecutionError;
use alloy_primitives::{address, b256, hex, Address, Bytes, B256, U256};
use reth_chainspec::{ChainSpec, OptimismHardfork}; use reth_chainspec::{ChainSpec, OptimismHardfork};
use reth_execution_errors::BlockExecutionError; use reth_execution_errors::BlockExecutionError;
use reth_primitives::{address, b256, hex, Address, Block, Bytes, B256, U256}; use reth_primitives::Block;
use revm::{ use revm::{
primitives::{Bytecode, HashMap, SpecId}, primitives::{Bytecode, HashMap, SpecId},
DatabaseCommit, L1BlockInfo, DatabaseCommit, L1BlockInfo,
@ -303,7 +304,8 @@ mod tests {
#[test] #[test]
fn sanity_l1_block() { fn sanity_l1_block() {
use reth_primitives::{hex_literal::hex, Bytes, Header, TransactionSigned}; use alloy_primitives::{hex_literal::hex, Bytes};
use reth_primitives::{Header, TransactionSigned};
let bytes = Bytes::from_static(&hex!("7ef9015aa044bae9d41b8380d781187b426c6fe43df5fb2fb57bd4466ef6a701e1f01e015694deaddeaddeaddeaddeaddeaddeaddeaddead000194420000000000000000000000000000000000001580808408f0d18001b90104015d8eb900000000000000000000000000000000000000000000000000000000008057650000000000000000000000000000000000000000000000000000000063d96d10000000000000000000000000000000000000000000000000000000000009f35273d89754a1e0387b89520d989d3be9c37c1f32495a88faf1ea05c61121ab0d1900000000000000000000000000000000000000000000000000000000000000010000000000000000000000002d679b567db6187c0c8323fa982cfb88b74dbcc7000000000000000000000000000000000000000000000000000000000000083400000000000000000000000000000000000000000000000000000000000f4240")); let bytes = Bytes::from_static(&hex!("7ef9015aa044bae9d41b8380d781187b426c6fe43df5fb2fb57bd4466ef6a701e1f01e015694deaddeaddeaddeaddeaddeaddeaddeaddead000194420000000000000000000000000000000000001580808408f0d18001b90104015d8eb900000000000000000000000000000000000000000000000000000000008057650000000000000000000000000000000000000000000000000000000063d96d10000000000000000000000000000000000000000000000000000000000009f35273d89754a1e0387b89520d989d3be9c37c1f32495a88faf1ea05c61121ab0d1900000000000000000000000000000000000000000000000000000000000000010000000000000000000000002d679b567db6187c0c8323fa982cfb88b74dbcc7000000000000000000000000000000000000000000000000000000000000083400000000000000000000000000000000000000000000000000000000000f4240"));
let l1_info_tx = TransactionSigned::decode_enveloped(&mut bytes.as_ref()).unwrap(); let l1_info_tx = TransactionSigned::decode_enveloped(&mut bytes.as_ref()).unwrap();

View File

@ -9,12 +9,13 @@
// The `optimism` feature must be enabled to use this crate. // The `optimism` feature must be enabled to use this crate.
#![cfg(feature = "optimism")] #![cfg(feature = "optimism")]
use alloy_primitives::{Address, U256};
use reth_chainspec::ChainSpec; use reth_chainspec::ChainSpec;
use reth_evm::{ConfigureEvm, ConfigureEvmEnv}; use reth_evm::{ConfigureEvm, ConfigureEvmEnv};
use reth_primitives::{ use reth_primitives::{
revm_primitives::{AnalysisKind, CfgEnvWithHandlerCfg, TxEnv}, revm_primitives::{AnalysisKind, CfgEnvWithHandlerCfg, TxEnv},
transaction::FillTxEnv, transaction::FillTxEnv,
Address, Head, Header, TransactionSigned, U256, Head, Header, TransactionSigned,
}; };
use reth_revm::{inspector_handle_register, Database, Evm, EvmBuilder, GetInspector}; use reth_revm::{inspector_handle_register, Database, Evm, EvmBuilder, GetInspector};
@ -136,11 +137,12 @@ impl ConfigureEvm for OptimismEvmConfig {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use alloy_primitives::{B256, U256};
use reth_chainspec::{Chain, ChainSpec}; use reth_chainspec::{Chain, ChainSpec};
use reth_evm::execute::ProviderError; use reth_evm::execute::ProviderError;
use reth_primitives::{ use reth_primitives::{
revm_primitives::{BlockEnv, CfgEnv, SpecId}, revm_primitives::{BlockEnv, CfgEnv, SpecId},
Genesis, Header, B256, KECCAK_EMPTY, U256, Genesis, Header, KECCAK_EMPTY,
}; };
use reth_revm::{ use reth_revm::{
db::{CacheDB, EmptyDBTyped}, db::{CacheDB, EmptyDBTyped},

View File

@ -39,6 +39,9 @@ reth-optimism-rpc.workspace = true
reth-rpc.workspace = true reth-rpc.workspace = true
reth-optimism-chainspec.workspace = true reth-optimism-chainspec.workspace = true
# ethereum
alloy-primitives.workspace = true
# async # async
async-trait.workspace = true async-trait.workspace = true
reqwest = { workspace = true, features = ["rustls-tls-native-roots"] } reqwest = { workspace = true, features = ["rustls-tls-native-roots"] }

View File

@ -224,10 +224,11 @@ pub struct OpL1BlockInfo {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::txpool::OpTransactionValidator; use crate::txpool::OpTransactionValidator;
use alloy_primitives::{TxKind, U256};
use reth::primitives::Signature;
use reth_chainspec::MAINNET; use reth_chainspec::MAINNET;
use reth_primitives::{ use reth_primitives::{
Signature, Transaction, TransactionSigned, TransactionSignedEcRecovered, TxDeposit, TxKind, Transaction, TransactionSigned, TransactionSignedEcRecovered, TxDeposit,
U256,
}; };
use reth_provider::test_utils::MockEthProvider; use reth_provider::test_utils::MockEthProvider;
use reth_transaction_pool::{ use reth_transaction_pool::{

View File

@ -1,6 +1,7 @@
use std::sync::Arc; use std::sync::Arc;
use alloy_genesis::Genesis; use alloy_genesis::Genesis;
use alloy_primitives::{Address, B256};
use reth::{rpc::types::engine::PayloadAttributes, tasks::TaskManager}; use reth::{rpc::types::engine::PayloadAttributes, tasks::TaskManager};
use reth_chainspec::ChainSpecBuilder; use reth_chainspec::ChainSpecBuilder;
use reth_e2e_test_utils::{transaction::TransactionTestContext, wallet::Wallet, NodeHelperType}; use reth_e2e_test_utils::{transaction::TransactionTestContext, wallet::Wallet, NodeHelperType};
@ -9,7 +10,6 @@ use reth_node_optimism::{
}; };
use reth_optimism_chainspec::BASE_MAINNET; use reth_optimism_chainspec::BASE_MAINNET;
use reth_payload_builder::EthPayloadBuilderAttributes; use reth_payload_builder::EthPayloadBuilderAttributes;
use reth_primitives::{Address, B256};
use tokio::sync::Mutex; use tokio::sync::Mutex;
/// Optimism Node Helper type /// Optimism Node Helper type

View File

@ -31,6 +31,7 @@ reth-chain-state.workspace = true
# ethereum # ethereum
revm.workspace = true revm.workspace = true
alloy-primitives.workspace = true
alloy-rlp.workspace = true alloy-rlp.workspace = true
# misc # misc

View File

@ -4,6 +4,7 @@ use crate::{
error::OptimismPayloadBuilderError, error::OptimismPayloadBuilderError,
payload::{OptimismBuiltPayload, OptimismPayloadBuilderAttributes}, payload::{OptimismBuiltPayload, OptimismPayloadBuilderAttributes},
}; };
use alloy_primitives::U256;
use reth_basic_payload_builder::*; use reth_basic_payload_builder::*;
use reth_chain_state::ExecutedBlock; use reth_chain_state::ExecutedBlock;
use reth_chainspec::{EthereumHardforks, OptimismHardfork}; use reth_chainspec::{EthereumHardforks, OptimismHardfork};
@ -13,7 +14,7 @@ use reth_payload_builder::error::PayloadBuilderError;
use reth_primitives::{ use reth_primitives::{
constants::{BEACON_NONCE, EMPTY_RECEIPTS, EMPTY_TRANSACTIONS}, constants::{BEACON_NONCE, EMPTY_RECEIPTS, EMPTY_TRANSACTIONS},
eip4844::calculate_excess_blob_gas, eip4844::calculate_excess_blob_gas,
proofs, Block, Header, IntoRecoveredTransaction, Receipt, TxType, EMPTY_OMMER_ROOT_HASH, U256, proofs, Block, Header, IntoRecoveredTransaction, Receipt, TxType, EMPTY_OMMER_ROOT_HASH,
}; };
use reth_provider::StateProviderFactory; use reth_provider::StateProviderFactory;
use reth_revm::database::StateProviderDatabase; use reth_revm::database::StateProviderDatabase;

View File

@ -13,7 +13,7 @@ pub enum OptimismPayloadBuilderError {
L1BlockInfoParseFailed, L1BlockInfoParseFailed,
/// Thrown when a database account could not be loaded. /// Thrown when a database account could not be loaded.
#[error("failed to load account {0}")] #[error("failed to load account {0}")]
AccountLoadFailed(reth_primitives::Address), AccountLoadFailed(alloy_primitives::Address),
/// Thrown when force deploy of create2deployer code fails. /// Thrown when force deploy of create2deployer code fails.
#[error("failed to force create2deployer account code")] #[error("failed to force create2deployer account code")]
ForceCreate2DeployerFail, ForceCreate2DeployerFail,

View File

@ -2,6 +2,7 @@
//! Optimism builder support //! Optimism builder support
use alloy_primitives::{Address, B256, U256};
use alloy_rlp::Encodable; use alloy_rlp::Encodable;
use reth_chain_state::ExecutedBlock; use reth_chain_state::ExecutedBlock;
use reth_chainspec::{ChainSpec, EthereumHardforks}; use reth_chainspec::{ChainSpec, EthereumHardforks};
@ -11,8 +12,7 @@ use reth_payload_primitives::{BuiltPayload, PayloadBuilderAttributes};
use reth_primitives::{ use reth_primitives::{
revm_primitives::{BlobExcessGasAndPrice, BlockEnv, CfgEnv, CfgEnvWithHandlerCfg, SpecId}, revm_primitives::{BlobExcessGasAndPrice, BlockEnv, CfgEnv, CfgEnvWithHandlerCfg, SpecId},
transaction::WithEncoded, transaction::WithEncoded,
Address, BlobTransactionSidecar, Header, SealedBlock, TransactionSigned, Withdrawals, B256, BlobTransactionSidecar, Header, SealedBlock, TransactionSigned, Withdrawals,
U256,
}; };
/// Re-export for use in downstream arguments. /// Re-export for use in downstream arguments.
pub use reth_rpc_types::optimism::OptimismPayloadAttributes; pub use reth_rpc_types::optimism::OptimismPayloadAttributes;

View File

@ -32,8 +32,8 @@ reth-chainspec.workspace = true
# ethereum # ethereum
alloy-primitives.workspace = true alloy-primitives.workspace = true
op-alloy-network.workspace = true op-alloy-network.workspace = true
revm.workspace = true
op-alloy-rpc-types.workspace = true op-alloy-rpc-types.workspace = true
revm.workspace = true
# async # async
parking_lot.workspace = true parking_lot.workspace = true
@ -58,4 +58,4 @@ optimism = [
"reth-provider/optimism", "reth-provider/optimism",
"reth-rpc-eth-api/optimism", "reth-rpc-eth-api/optimism",
"revm/optimism", "revm/optimism",
] ]

View File

@ -1,10 +1,8 @@
use alloy_primitives::{Bytes, TxKind, U256};
use reth_chainspec::ChainSpec; use reth_chainspec::ChainSpec;
use reth_evm::ConfigureEvm; use reth_evm::ConfigureEvm;
use reth_node_api::{FullNodeComponents, NodeTypes}; use reth_node_api::{FullNodeComponents, NodeTypes};
use reth_primitives::{ use reth_primitives::revm_primitives::{BlockEnv, OptimismFields, TxEnv};
revm_primitives::{BlockEnv, OptimismFields, TxEnv},
Bytes, TxKind, U256,
};
use reth_rpc_eth_api::{ use reth_rpc_eth_api::{
helpers::{Call, EthCall, LoadState, SpawnBlocking}, helpers::{Call, EthCall, LoadState, SpawnBlocking},
FromEthApiError, IntoEthApiError, FromEthApiError, IntoEthApiError,

View File

@ -1,10 +1,11 @@
//! Loads OP pending block for a RPC response. //! Loads OP pending block for a RPC response.
use alloy_primitives::{BlockNumber, B256};
use reth_chainspec::ChainSpec; use reth_chainspec::ChainSpec;
use reth_evm::ConfigureEvm; use reth_evm::ConfigureEvm;
use reth_node_api::{FullNodeComponents, NodeTypes}; use reth_node_api::{FullNodeComponents, NodeTypes};
use reth_primitives::{ use reth_primitives::{
revm_primitives::BlockEnv, BlockNumber, BlockNumberOrTag, Receipt, SealedBlockWithSenders, B256, revm_primitives::BlockEnv, BlockNumberOrTag, Receipt, SealedBlockWithSenders,
}; };
use reth_provider::{ use reth_provider::{
BlockReader, BlockReaderIdExt, ChainSpecProvider, EvmEnvProvider, ExecutionOutcome, BlockReader, BlockReaderIdExt, ChainSpecProvider, EvmEnvProvider, ExecutionOutcome,

View File

@ -73,7 +73,7 @@ impl SequencerClient {
let body = serde_json::to_string(&serde_json::json!({ let body = serde_json::to_string(&serde_json::json!({
"jsonrpc": "2.0", "jsonrpc": "2.0",
"method": "eth_sendRawTransaction", "method": "eth_sendRawTransaction",
"params": [format!("0x{}", reth_primitives::hex::encode(tx))], "params": [format!("0x{}", alloy_primitives::hex::encode(tx))],
"id": self.next_request_id() "id": self.next_request_id()
})) }))
.map_err(|_| { .map_err(|_| {