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

optimism: replace reth-primitive imports #10800

Merged
merged 1 commit into from
Sep 10, 2024
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
2 changes: 2 additions & 0 deletions Cargo.lock

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

8 changes: 3 additions & 5 deletions crates/optimism/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand All @@ -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",
]
]
2 changes: 1 addition & 1 deletion crates/optimism/cli/src/commands/import_receipts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down
6 changes: 4 additions & 2 deletions crates/optimism/cli/src/receipt_file_codec.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -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::*;

Expand Down
6 changes: 4 additions & 2 deletions crates/optimism/consensus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
5 changes: 2 additions & 3 deletions crates/optimism/consensus/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand All @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion crates/optimism/consensus/src/proof.rs
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
5 changes: 2 additions & 3 deletions crates/optimism/consensus/src/validation.rs
Original file line number Diff line number Diff line change
@@ -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:
///
Expand Down
3 changes: 3 additions & 0 deletions crates/optimism/evm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion crates/optimism/evm/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
7 changes: 4 additions & 3 deletions crates/optimism/evm/src/execute.rs
Original file line number Diff line number Diff line change
@@ -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::{
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 4 additions & 2 deletions crates/optimism/evm/src/l1.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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();
Expand Down
6 changes: 4 additions & 2 deletions crates/optimism/evm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -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},
Expand Down
3 changes: 3 additions & 0 deletions crates/optimism/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand Down
5 changes: 3 additions & 2 deletions crates/optimism/node/src/txpool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down
2 changes: 1 addition & 1 deletion crates/optimism/node/tests/e2e/utils.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions crates/optimism/payload/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ reth-chain-state.workspace = true

# ethereum
revm.workspace = true
alloy-primitives.workspace = true
alloy-rlp.workspace = true

# misc
Expand Down
3 changes: 2 additions & 1 deletion crates/optimism/payload/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion crates/optimism/payload/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions crates/optimism/payload/src/payload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions crates/optimism/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -58,4 +58,4 @@ optimism = [
"reth-provider/optimism",
"reth-rpc-eth-api/optimism",
"revm/optimism",
]
]
6 changes: 2 additions & 4 deletions crates/optimism/rpc/src/eth/call.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
3 changes: 2 additions & 1 deletion crates/optimism/rpc/src/eth/pending_block.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
2 changes: 1 addition & 1 deletion crates/optimism/rpc/src/eth/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(|_| {
Expand Down
Loading