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

View File

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

View File

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

View File

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

View File

@ -19,12 +19,14 @@ reth-consensus.workspace = true
reth-primitives.workspace = true
reth-trie-common.workspace = true
# ethereum
alloy-primitives.workspace = true
tracing.workspace = true
[dev-dependencies]
alloy-primitives.workspace = true
reth-optimism-chainspec.workspace = true
[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.
#![cfg(feature = "optimism")]
use alloy_primitives::U256;
use reth_chainspec::{ChainSpec, EthereumHardforks, OptimismHardforks};
use reth_consensus::{Consensus, ConsensusError, PostExecutionInput};
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_header_gas,
};
use reth_primitives::{
BlockWithSenders, Header, SealedBlock, SealedHeader, EMPTY_OMMER_ROOT_HASH, U256,
};
use reth_primitives::{BlockWithSenders, Header, SealedBlock, SealedHeader, EMPTY_OMMER_ROOT_HASH};
use std::{sync::Arc, time::SystemTime};
mod proof;

View File

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

View File

@ -1,9 +1,8 @@
use crate::proof::calculate_receipt_root_optimism;
use alloy_primitives::{Bloom, B256};
use reth_chainspec::{ChainSpec, EthereumHardforks};
use reth_consensus::ConsensusError;
use reth_primitives::{
gas_spent_by_transactions, BlockWithSenders, Bloom, GotExpected, Receipt, B256,
};
use reth_primitives::{gas_spent_by_transactions, BlockWithSenders, GotExpected, Receipt};
/// 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-prune-types.workspace = true
# ethereum
alloy-primitives.workspace = true
# Optimism
reth-optimism-consensus.workspace = true

View File

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

View File

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

View File

@ -1,9 +1,10 @@
//! Optimism-specific implementation and utilities for the executor
use crate::OptimismBlockExecutionError;
use alloy_primitives::{address, b256, hex, Address, Bytes, B256, U256};
use reth_chainspec::{ChainSpec, OptimismHardfork};
use reth_execution_errors::BlockExecutionError;
use reth_primitives::{address, b256, hex, Address, Block, Bytes, B256, U256};
use reth_primitives::Block;
use revm::{
primitives::{Bytecode, HashMap, SpecId},
DatabaseCommit, L1BlockInfo,
@ -303,7 +304,8 @@ mod tests {
#[test]
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 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.
#![cfg(feature = "optimism")]
use alloy_primitives::{Address, U256};
use reth_chainspec::ChainSpec;
use reth_evm::{ConfigureEvm, ConfigureEvmEnv};
use reth_primitives::{
revm_primitives::{AnalysisKind, CfgEnvWithHandlerCfg, TxEnv},
transaction::FillTxEnv,
Address, Head, Header, TransactionSigned, U256,
Head, Header, TransactionSigned,
};
use reth_revm::{inspector_handle_register, Database, Evm, EvmBuilder, GetInspector};
@ -136,11 +137,12 @@ impl ConfigureEvm for OptimismEvmConfig {
#[cfg(test)]
mod tests {
use super::*;
use alloy_primitives::{B256, U256};
use reth_chainspec::{Chain, ChainSpec};
use reth_evm::execute::ProviderError;
use reth_primitives::{
revm_primitives::{BlockEnv, CfgEnv, SpecId},
Genesis, Header, B256, KECCAK_EMPTY, U256,
Genesis, Header, KECCAK_EMPTY,
};
use reth_revm::{
db::{CacheDB, EmptyDBTyped},

View File

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

View File

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

View File

@ -1,6 +1,7 @@
use std::sync::Arc;
use alloy_genesis::Genesis;
use alloy_primitives::{Address, B256};
use reth::{rpc::types::engine::PayloadAttributes, tasks::TaskManager};
use reth_chainspec::ChainSpecBuilder;
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_payload_builder::EthPayloadBuilderAttributes;
use reth_primitives::{Address, B256};
use tokio::sync::Mutex;
/// Optimism Node Helper type

View File

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

View File

@ -4,6 +4,7 @@ use crate::{
error::OptimismPayloadBuilderError,
payload::{OptimismBuiltPayload, OptimismPayloadBuilderAttributes},
};
use alloy_primitives::U256;
use reth_basic_payload_builder::*;
use reth_chain_state::ExecutedBlock;
use reth_chainspec::{EthereumHardforks, OptimismHardfork};
@ -13,7 +14,7 @@ use reth_payload_builder::error::PayloadBuilderError;
use reth_primitives::{
constants::{BEACON_NONCE, EMPTY_RECEIPTS, EMPTY_TRANSACTIONS},
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_revm::database::StateProviderDatabase;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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