Skip to content

Commit

Permalink
chore(ethereum): replace reth-primitives with alloy (#11155)
Browse files Browse the repository at this point in the history
Signed-off-by: Abhishekkochar <abhishekkochar2@gmail.com>
  • Loading branch information
Abhishekkochar authored Sep 24, 2024
1 parent c851a17 commit 6e64a14
Show file tree
Hide file tree
Showing 13 changed files with 39 additions and 19 deletions.
5 changes: 5 additions & 0 deletions Cargo.lock

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

3 changes: 3 additions & 0 deletions crates/ethereum/consensus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@ reth-consensus-common.workspace = true
reth-primitives.workspace = true
reth-consensus.workspace = true

# alloy
alloy-primitives.workspace = true

tracing.workspace = true
6 changes: 4 additions & 2 deletions crates/ethereum/consensus/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#![cfg_attr(not(test), warn(unused_crate_dependencies))]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]

use alloy_primitives::U256;
use reth_chainspec::{EthChainSpec, EthereumHardfork, EthereumHardforks};
use reth_consensus::{Consensus, ConsensusError, PostExecutionInput};
use reth_consensus_common::validation::{
Expand All @@ -18,7 +19,7 @@ use reth_consensus_common::validation::{
};
use reth_primitives::{
constants::MINIMUM_GAS_LIMIT, BlockWithSenders, Header, SealedBlock, SealedHeader,
EMPTY_OMMER_ROOT_HASH, U256,
EMPTY_OMMER_ROOT_HASH,
};
use std::{fmt::Debug, sync::Arc, time::SystemTime};

Expand Down Expand Up @@ -232,8 +233,9 @@ impl<ChainSpec: Send + Sync + EthChainSpec + EthereumHardforks + Debug> Consensu
#[cfg(test)]
mod tests {
use super::*;
use alloy_primitives::{Sealable, B256};
use reth_chainspec::{ChainSpec, ChainSpecBuilder};
use reth_primitives::{alloy_primitives::Sealable, proofs, B256};
use reth_primitives::proofs;

fn header_with_gas_limit(gas_limit: u64) -> SealedHeader {
let header = Header { gas_limit: gas_limit.into(), ..Default::default() };
Expand Down
5 changes: 2 additions & 3 deletions crates/ethereum/consensus/src/validation.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use alloy_primitives::{Bloom, B256};
use reth_chainspec::EthereumHardforks;
use reth_consensus::ConsensusError;
use reth_primitives::{
gas_spent_by_transactions, BlockWithSenders, Bloom, GotExpected, Receipt, Request, B256,
};
use reth_primitives::{gas_spent_by_transactions, BlockWithSenders, GotExpected, Receipt, Request};

/// Validate a block with regard to execution results:
///
Expand Down
4 changes: 4 additions & 0 deletions crates/ethereum/engine-primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ reth-rpc-types-compat.workspace = true
alloy-rlp.workspace = true
reth-chain-state.workspace = true

# alloy
alloy-primitives.workspace = true
alloy-eips.workspace = true

# misc
serde.workspace = true
sha2.workspace = true
Expand Down
4 changes: 3 additions & 1 deletion crates/ethereum/engine-primitives/src/payload.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
//! Contains types required for building a payload.

use alloy_eips::eip4844::BlobTransactionSidecar;
use alloy_primitives::{Address, B256, U256};
use alloy_rlp::Encodable;
use reth_chain_state::ExecutedBlock;
use reth_payload_primitives::{BuiltPayload, PayloadBuilderAttributes};
use reth_primitives::{Address, BlobTransactionSidecar, SealedBlock, Withdrawals, B256, U256};
use reth_primitives::{SealedBlock, Withdrawals};
use reth_rpc_types::engine::{
ExecutionPayloadEnvelopeV2, ExecutionPayloadEnvelopeV3, ExecutionPayloadEnvelopeV4,
ExecutionPayloadV1, PayloadAttributes, PayloadId,
Expand Down
1 change: 1 addition & 0 deletions crates/ethereum/evm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ reth-execution-types.workspace = true
revm-primitives.workspace = true

# Alloy
alloy-primitives.workspace = true
alloy-eips.workspace = true
alloy-sol-types.workspace = true

Expand Down
2 changes: 1 addition & 1 deletion crates/ethereum/evm/src/dao_fork.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! DAO Fork related constants from [EIP-779](https://eips.ethereum.org/EIPS/eip-779).
//! It happened on Ethereum block 1_920_000

use reth_primitives::{address, Address};
use alloy_primitives::{address, Address};

/// Dao hardfork beneficiary that received ether from accounts from DAO and DAO creator children.
pub static DAO_HARDFORK_BENEFICIARY: Address = address!("bf4ed7b27f1d666546e30d74d50d173d20bca754");
Expand Down
2 changes: 1 addition & 1 deletion crates/ethereum/evm/src/eip6110.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
//! EIP-6110 deposit requests parsing
use alloc::{string::ToString, vec::Vec};
use alloy_eips::eip6110::{DepositRequest, MAINNET_DEPOSIT_CONTRACT_ADDRESS};
use alloy_primitives::Log;
use alloy_sol_types::{sol, SolEvent};
use reth_chainspec::ChainSpec;
use reth_evm::execute::BlockValidationError;
use reth_primitives::{Receipt, Request};
use revm_primitives::Log;

sol! {
#[allow(missing_docs)]
Expand Down
11 changes: 5 additions & 6 deletions crates/ethereum/evm/src/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use crate::{
EthEvmConfig,
};
use alloc::{boxed::Box, sync::Arc, vec, vec::Vec};
use alloy_primitives::{BlockNumber, U256};
use core::fmt::Display;
use reth_chainspec::{ChainSpec, EthereumHardforks, MAINNET};
use reth_ethereum_consensus::validate_block_post_execution;
Expand All @@ -20,9 +21,7 @@ use reth_evm::{
ConfigureEvm,
};
use reth_execution_types::ExecutionOutcome;
use reth_primitives::{
BlockNumber, BlockWithSenders, EthereumHardfork, Header, Receipt, Request, U256,
};
use reth_primitives::{BlockWithSenders, EthereumHardfork, Header, Receipt, Request};
use reth_prune_types::PruneModes;
use reth_revm::{
batch::BlockBatchRecord,
Expand Down Expand Up @@ -478,17 +477,17 @@ mod tests {
eip4788::{BEACON_ROOTS_ADDRESS, BEACON_ROOTS_CODE, SYSTEM_ADDRESS},
eip7002::{WITHDRAWAL_REQUEST_PREDEPLOY_ADDRESS, WITHDRAWAL_REQUEST_PREDEPLOY_CODE},
};
use alloy_primitives::{b256, fixed_bytes, keccak256, Bytes, TxKind, B256};
use reth_chainspec::{ChainSpecBuilder, ForkCondition};
use reth_primitives::{
constants::{EMPTY_ROOT_HASH, ETH_TO_WEI},
keccak256, public_key_to_address, Account, Block, BlockBody, Transaction, TxKind, TxLegacy,
B256,
public_key_to_address, Account, Block, BlockBody, Transaction, TxLegacy,
};
use reth_revm::{
database::StateProviderDatabase, test_utils::StateProviderTest, TransitionState,
};
use reth_testing_utils::generators::{self, sign_tx_with_key_pair};
use revm_primitives::{b256, fixed_bytes, Bytes, BLOCKHASH_SERVE_WINDOW};
use revm_primitives::BLOCKHASH_SERVE_WINDOW;
use secp256k1::{Keypair, Secp256k1};
use std::collections::HashMap;

Expand Down
9 changes: 5 additions & 4 deletions crates/ethereum/evm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
extern crate alloc;

use alloc::vec::Vec;
use alloy_primitives::{Address, Bytes, TxKind, U256};
use reth_chainspec::{ChainSpec, Head};
use reth_evm::{ConfigureEvm, ConfigureEvmEnv, NextBlockEnvAttributes};
use reth_primitives::{transaction::FillTxEnv, Address, Header, TransactionSigned, U256};
use reth_primitives::{transaction::FillTxEnv, Header, TransactionSigned};
use revm_primitives::{
AnalysisKind, BlobExcessGasAndPrice, BlockEnv, Bytes, CfgEnv, CfgEnvWithHandlerCfg, Env,
SpecId, TxEnv, TxKind,
AnalysisKind, BlobExcessGasAndPrice, BlockEnv, CfgEnv, CfgEnvWithHandlerCfg, Env, SpecId, TxEnv,
};
use std::sync::Arc;

Expand Down Expand Up @@ -194,11 +194,12 @@ impl ConfigureEvm for EthEvmConfig {
#[cfg(test)]
mod tests {
use super::*;
use alloy_primitives::{B256, U256};
use reth_chainspec::{Chain, ChainSpec, MAINNET};
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/ethereum/payload/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,8 @@ reth-chain-state.workspace = true
# ethereum
revm.workspace = true

# alloy
alloy-primitives.workspace = true

# misc
tracing.workspace = true
3 changes: 2 additions & 1 deletion crates/ethereum/payload/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
#![allow(clippy::useless_let_if_seq)]

use alloy_primitives::U256;
use reth_basic_payload_builder::{
commit_withdrawals, is_better_payload, BuildArguments, BuildOutcome, PayloadBuilder,
PayloadConfig, WithdrawalsOutcome,
Expand All @@ -33,7 +34,7 @@ use reth_primitives::{
proofs::{self, calculate_requests_root},
revm_primitives::{BlockEnv, CfgEnvWithHandlerCfg},
Block, BlockBody, EthereumHardforks, Header, IntoRecoveredTransaction, Receipt,
EMPTY_OMMER_ROOT_HASH, U256,
EMPTY_OMMER_ROOT_HASH,
};
use reth_provider::StateProviderFactory;
use reth_revm::database::StateProviderDatabase;
Expand Down

0 comments on commit 6e64a14

Please sign in to comment.