Skip to content

Commit

Permalink
feat(primitives): move revm-primitives to reth-primitives (paradi…
Browse files Browse the repository at this point in the history
  • Loading branch information
tcoratger authored Oct 19, 2023
1 parent 5dd5555 commit 5d217a2
Show file tree
Hide file tree
Showing 32 changed files with 90 additions and 109 deletions.
13 changes: 1 addition & 12 deletions Cargo.lock

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

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ members = [
"crates/primitives",
"crates/prune",
"crates/revm",
"crates/revm/revm-primitives",
"crates/revm/revm-inspectors",
"crates/rpc/ipc",
"crates/rpc/rpc",
Expand Down
8 changes: 4 additions & 4 deletions crates/payload/basic/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ use reth_primitives::{
eip4844::MAX_DATA_GAS_PER_BLOCK, BEACON_NONCE, EMPTY_RECEIPTS, EMPTY_TRANSACTIONS,
EMPTY_WITHDRAWALS, ETHEREUM_BLOCK_GAS_LIMIT, RETH_CLIENT_VERSION, SLOT_DURATION,
},
proofs, Block, BlockNumberOrTag, Bytes, ChainSpec, Header, IntoRecoveredTransaction, Receipt,
Receipts, SealedBlock, Withdrawal, B256, EMPTY_OMMER_ROOT, U256,
proofs,
revm::{compat::into_reth_log, env::tx_env_with_recovered},
Block, BlockNumberOrTag, Bytes, ChainSpec, Header, IntoRecoveredTransaction, Receipt, Receipts,
SealedBlock, Withdrawal, B256, EMPTY_OMMER_ROOT, U256,
};
use reth_provider::{BlockReaderIdExt, BlockSource, BundleStateWithReceipts, StateProviderFactory};
use reth_revm::{
database::StateProviderDatabase,
env::tx_env_with_recovered,
into_reth_log,
state_change::{apply_beacon_root_contract_call, post_block_withdrawals_balance_increments},
};
use reth_tasks::TaskSpawner;
Expand Down
1 change: 0 additions & 1 deletion crates/payload/builder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ reth-primitives.workspace = true
reth-rpc-types.workspace = true
reth-transaction-pool.workspace = true
reth-interfaces.workspace = true
reth-revm-primitives = { path = "../../revm/revm-primitives" }
reth-rpc-types-compat.workspace = true

## ethereum
Expand Down
4 changes: 2 additions & 2 deletions crates/payload/builder/src/payload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
use alloy_rlp::Encodable;
use reth_primitives::{
Address, BlobTransactionSidecar, ChainSpec, Header, SealedBlock, Withdrawal, B256, U256,
revm::config::revm_spec_by_timestamp_after_merge, Address, BlobTransactionSidecar, ChainSpec,
Header, SealedBlock, Withdrawal, B256, U256,
};
use reth_revm_primitives::config::revm_spec_by_timestamp_after_merge;
use reth_rpc_types::engine::{
ExecutionPayloadEnvelopeV2, ExecutionPayloadEnvelopeV3, ExecutionPayloadV1, PayloadAttributes,
PayloadId,
Expand Down
6 changes: 4 additions & 2 deletions crates/primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ proptest = { workspace = true, optional = true }
proptest-derive = { workspace = true, optional = true }
strum = { workspace = true, features = ["derive"] }

revm.workspace = true

[dev-dependencies]
serde_json.workspace = true
test-fuzz = "4"
Expand All @@ -83,8 +85,8 @@ hash-db = "~0.15"
reth-primitives = { path = ".", features = ["value-256"] }


# necessary so we don't hit a "undeclared 'std'":
# https://github.com/paradigmxyz/reth/pull/177#discussion_r1021172198
# necessary so we don't hit a "undeclared 'std'":
# https://github.com/paradigmxyz/reth/pull/177#discussion_r1021172198
secp256k1.workspace = true
criterion = "0.5"
pprof = { version = "0.12", features = ["flamegraph", "frame-pointer", "criterion"] }
Expand Down
2 changes: 2 additions & 0 deletions crates/primitives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ mod precaution;
pub mod proofs;
mod prune;
mod receipt;
/// Helpers for working with revm
pub mod revm;
pub mod serde_helper;
pub mod snapshot;
pub mod stage;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use reth_primitives::{
use crate::{
revm_primitives::{AccountInfo, Log},
Account, Address, Log as RethLog, TransactionKind, KECCAK_EMPTY, U256,
};
Expand All @@ -8,7 +8,7 @@ use revm::{
};

/// Check equality between Revm and Reth `Log`s.
pub fn is_log_equal(revm_log: &Log, reth_log: &reth_primitives::Log) -> bool {
pub fn is_log_equal(revm_log: &Log, reth_log: &crate::Log) -> bool {
revm_log.address == reth_log.address &&
revm_log.data == reth_log.data &&
revm_log.topics == reth_log.topics
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
//! Reth block execution/validation configuration and constants
use reth_primitives::{revm_primitives, ChainSpec, Hardfork, Head};
use crate::{revm_primitives, ChainSpec, Hardfork, Head};

/// Returns the spec id at the given timestamp.
///
Expand Down Expand Up @@ -56,7 +54,7 @@ pub fn revm_spec(chain_spec: &ChainSpec, block: Head) -> revm_primitives::SpecId
#[cfg(test)]
mod tests {
use super::*;
use reth_primitives::{ChainSpecBuilder, Head, MAINNET, U256};
use crate::{ChainSpecBuilder, Head, MAINNET, U256};

#[test]
fn test_to_revm_spec() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::config::revm_spec;
use reth_primitives::{
use crate::{
constants::{BEACON_ROOTS_ADDRESS, SYSTEM_ADDRESS},
recover_signer,
revm::config::revm_spec,
revm_primitives::{AnalysisKind, BlockEnv, CfgEnv, Env, SpecId, TransactTo, TxEnv},
Address, Bytes, Chain, ChainSpec, Head, Header, Transaction, TransactionKind,
TransactionSignedEcRecovered, TxEip1559, TxEip2930, TxEip4844, TxLegacy, B256, U256,
Expand Down
20 changes: 20 additions & 0 deletions crates/primitives/src/revm/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/// The `compat` module contains a set of utility functions that bridge the gap between Revm and
/// Reth Ethereum implementations.
///
/// These functions enable the conversion of data structures between the two implementations, such
/// as converting `Log` structures, `AccountInfo`, and `Account` objects.
///
/// Additionally, it provides a function to calculate intrinsic gas usage for transactions beyond
/// the Merge hardfork, offering compatibility for both Shanghai and Merge Ethereum specifications.
///
/// These utilities facilitate interoperability and data exchange between Revm and Reth
/// implementations.
pub mod compat;
/// Reth block execution/validation configuration and constants
pub mod config;
/// The `env` module provides essential utilities for managing Ethereum transaction and block
/// environments.
///
/// It includes functions to fill transaction and block environments with relevant data, handle
/// system contract calls, and recover the signer of Ethereum headers.
pub mod env;
1 change: 0 additions & 1 deletion crates/revm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ description = "reth specific revm utilities"
reth-primitives.workspace = true
reth-interfaces.workspace = true
reth-provider.workspace = true
reth-revm-primitives = { path = "./revm-primitives" }
reth-revm-inspectors = { path = "./revm-inspectors" }
reth-consensus-common = { path = "../consensus/common" }

Expand Down
14 changes: 0 additions & 14 deletions crates/revm/revm-primitives/Cargo.toml

This file was deleted.

19 changes: 0 additions & 19 deletions crates/revm/revm-primitives/src/lib.rs

This file was deleted.

2 changes: 0 additions & 2 deletions crates/revm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ pub use factory::Factory;

/// reexport for convenience
pub use reth_revm_inspectors::*;
/// reexport for convenience
pub use reth_revm_primitives::*;

/// Re-export everything
pub use revm::{self, *};
Expand Down
6 changes: 4 additions & 2 deletions crates/revm/src/processor.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
use crate::{
database::StateProviderDatabase,
env::{fill_cfg_and_block_env, fill_tx_env},
eth_dao_fork::{DAO_HARDFORK_BENEFICIARY, DAO_HARDKFORK_ACCOUNTS},
into_reth_log,
stack::{InspectorStack, InspectorStackConfig},
state_change::{apply_beacon_root_contract_call, post_block_balance_increments},
};
Expand All @@ -11,6 +9,10 @@ use reth_interfaces::{
RethError,
};
use reth_primitives::{
revm::{
compat::into_reth_log,
env::{fill_cfg_and_block_env, fill_tx_env},
},
Address, Block, BlockNumber, Bloom, ChainSpec, Hardfork, Header, PruneMode, PruneModes,
PruneSegmentError, Receipt, ReceiptWithBloom, Receipts, TransactionSigned, B256,
MINIMUM_PRUNING_DISTANCE, U256,
Expand Down
4 changes: 2 additions & 2 deletions crates/revm/src/state_change.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use reth_consensus_common::calc;
use reth_interfaces::executor::{BlockExecutionError, BlockValidationError};
use reth_primitives::{
constants::SYSTEM_ADDRESS, Address, ChainSpec, Header, Withdrawal, B256, U256,
constants::SYSTEM_ADDRESS, revm::env::fill_tx_env_with_beacon_root_contract_call, Address,
ChainSpec, Header, Withdrawal, B256, U256,
};
use reth_revm_primitives::env::fill_tx_env_with_beacon_root_contract_call;
use revm::{primitives::ResultAndState, Database, DatabaseCommit, EVM};
use std::{collections::HashMap, fmt::Debug};

Expand Down
4 changes: 2 additions & 2 deletions crates/rpc/rpc/src/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ use alloy_rlp::{Decodable, Encodable};
use async_trait::async_trait;
use jsonrpsee::core::RpcResult;
use reth_primitives::{
Account, Address, Block, BlockId, BlockNumberOrTag, Bytes, TransactionSigned, B256,
revm::env::tx_env_with_recovered, Account, Address, Block, BlockId, BlockNumberOrTag, Bytes,
TransactionSigned, B256,
};
use reth_provider::{BlockReaderIdExt, HeaderProvider, StateProviderBox};
use reth_revm::{
database::{StateProviderDatabase, SubState},
env::tx_env_with_recovered,
tracing::{
js::{JsDbRequest, JsInspector},
FourByteInspector, TracingInspector, TracingInspectorConfig,
Expand Down
6 changes: 2 additions & 4 deletions crates/rpc/rpc/src/eth/api/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,11 @@ use crate::{
EthApi,
};
use reth_network_api::NetworkInfo;
use reth_primitives::{BlockId, BlockNumberOrTag, Bytes, U256};
use reth_primitives::{revm::env::tx_env_with_recovered, BlockId, BlockNumberOrTag, Bytes, U256};
use reth_provider::{
BlockReaderIdExt, ChainSpecProvider, EvmEnvProvider, StateProvider, StateProviderFactory,
};
use reth_revm::{
access_list::AccessListInspector, database::StateProviderDatabase, env::tx_env_with_recovered,
};
use reth_revm::{access_list::AccessListInspector, database::StateProviderDatabase};
use reth_rpc_types::{
state::StateOverride, AccessListWithGasUsed, BlockError, Bundle, CallRequest, EthCallResponse,
StateContext,
Expand Down
6 changes: 3 additions & 3 deletions crates/rpc/rpc/src/eth/api/pending_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ use crate::eth::error::{EthApiError, EthResult};
use core::fmt::Debug;
use reth_primitives::{
constants::{eip4844::MAX_DATA_GAS_PER_BLOCK, BEACON_NONCE},
proofs, Block, BlockId, BlockNumberOrTag, ChainSpec, Header, IntoRecoveredTransaction, Receipt,
proofs,
revm::{compat::into_reth_log, env::tx_env_with_recovered},
Block, BlockId, BlockNumberOrTag, ChainSpec, Header, IntoRecoveredTransaction, Receipt,
Receipts, SealedBlock, SealedHeader, B256, EMPTY_OMMER_ROOT, U256,
};
use reth_provider::{BundleStateWithReceipts, ChainSpecProvider, StateProviderFactory};
use reth_revm::{
database::StateProviderDatabase,
env::tx_env_with_recovered,
into_reth_log,
state_change::{apply_beacon_root_contract_call, post_block_withdrawals_balance_increments},
};
use reth_transaction_pool::TransactionPool;
Expand Down
2 changes: 1 addition & 1 deletion crates/rpc/rpc/src/eth/api/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use async_trait::async_trait;
use reth_network_api::NetworkInfo;
use reth_primitives::{
eip4844::calc_blob_gasprice,
revm::env::{fill_block_env_with_coinbase, tx_env_with_recovered},
Address, BlockId, BlockNumberOrTag, Bytes, FromRecoveredPooledTransaction, Header,
IntoRecoveredTransaction, Receipt, SealedBlock,
TransactionKind::{Call, Create},
Expand All @@ -25,7 +26,6 @@ use reth_provider::{
};
use reth_revm::{
database::StateProviderDatabase,
env::{fill_block_env_with_coinbase, tx_env_with_recovered},
tracing::{TracingInspector, TracingInspectorConfig},
};
use reth_rpc_types::{
Expand Down
2 changes: 1 addition & 1 deletion crates/rpc/rpc/src/eth/revm_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
use crate::eth::error::{EthApiError, EthResult, RpcInvalidTransactionError};
use reth_primitives::{
revm::env::{fill_tx_env, fill_tx_env_with_recovered},
AccessList, Address, TransactionSigned, TransactionSignedEcRecovered, TxHash, B256, U256,
};
use reth_revm::env::{fill_tx_env, fill_tx_env_with_recovered};
use reth_rpc_types::{
state::{AccountOverride, StateOverride},
BlockOverrides, CallRequest,
Expand Down
5 changes: 3 additions & 2 deletions crates/rpc/rpc/src/trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ use crate::{
use async_trait::async_trait;
use jsonrpsee::core::RpcResult as Result;
use reth_consensus_common::calc::{base_block_reward, block_reward};
use reth_primitives::{BlockId, BlockNumberOrTag, Bytes, SealedHeader, B256, U256};
use reth_primitives::{
revm::env::tx_env_with_recovered, BlockId, BlockNumberOrTag, Bytes, SealedHeader, B256, U256,
};
use reth_provider::{BlockReader, ChainSpecProvider, EvmEnvProvider, StateProviderFactory};
use reth_revm::{
database::StateProviderDatabase,
env::tx_env_with_recovered,
tracing::{parity::populate_state_diff, TracingInspector, TracingInspectorConfig},
};
use reth_rpc_api::TraceApiServer;
Expand Down
1 change: 0 additions & 1 deletion crates/storage/codecs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ proptest-derive = { workspace = true, optional = true }

[dev-dependencies]
revm-primitives = { workspace = true, features = ["serde", "arbitrary"] }

serde = "1.0"
modular-bitfield = "0.11.2"
test-fuzz = "4"
Expand Down
1 change: 0 additions & 1 deletion crates/storage/provider/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ description = "Reth storage provider."
# reth
reth-primitives.workspace = true
reth-interfaces.workspace = true
reth-revm-primitives = { path = "../../revm/revm-primitives" }
reth-db.workspace = true
reth-trie = { path = "../../trie" }
reth-nippy-jar = { path = "../nippy-jar" }
Expand Down
Loading

0 comments on commit 5d217a2

Please sign in to comment.