Skip to content

Commit

Permalink
feat: further reduce diff with upstream
Browse files Browse the repository at this point in the history
Signed-off-by: Gregory Edison <[email protected]>
  • Loading branch information
greged93 committed Jan 8, 2025
1 parent 22db520 commit ffff7e0
Show file tree
Hide file tree
Showing 32 changed files with 90 additions and 148 deletions.
2 changes: 1 addition & 1 deletion crates/engine/tree/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,6 @@ test-utils = [
"reth-trie-sparse/test-utils",
"reth-prune-types?/test-utils",
"reth-trie-db/test-utils",
"reth-trie-parallel/test-utils",
"reth-trie-parallel/test-utils",
]
skip-state-root-validation = ["reth-stages/skip-state-root-validation"]
2 changes: 0 additions & 2 deletions crates/engine/tree/benches/channel_perf.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//! Benchmark comparing `std::sync::mpsc` and `crossbeam` channels for `StateRootTask`.
#![allow(missing_docs)]
#![allow(clippy::needless_update)]

use criterion::{criterion_group, criterion_main, BatchSize, BenchmarkId, Criterion};
use proptest::test_runner::TestRunner;
Expand All @@ -27,7 +26,6 @@ fn create_bench_state(num_accounts: usize) -> EvmState {
balance: U256::from(100),
nonce: 10,
code_hash: B256::from_slice(&rng.gen::<[u8; 32]>()),
code: Default::default(),
..Default::default()
},
storage,
Expand Down
2 changes: 0 additions & 2 deletions crates/engine/tree/benches/state_root_task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ fn create_bench_state_updates(params: &BenchParams) -> Vec<EvmState> {
}

fn convert_revm_to_reth_account(revm_account: &RevmAccount) -> Option<RethAccount> {
#[allow(clippy::needless_update)]
match revm_account.status {
AccountStatus::SelfDestructed => None,
_ => Some(RethAccount {
Expand All @@ -104,7 +103,6 @@ fn convert_revm_to_reth_account(revm_account: &RevmAccount) -> Option<RethAccoun
} else {
Some(revm_account.info.code_hash)
},
..Default::default()
}),
}
}
Expand Down
11 changes: 7 additions & 4 deletions crates/engine/util/src/reorg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use reth_primitives::{
};
use reth_provider::{BlockReader, ExecutionOutcome, ProviderError, StateProviderFactory};
use reth_revm::{
database::StateProviderDatabase,
db::{states::bundle_state::BundleRetention, State},
DatabaseCommit,
};
Expand Down Expand Up @@ -291,8 +292,10 @@ where

// Configure state
let state_provider = provider.state_by_block_hash(reorg_target.parent_hash)?;
let mut db = reth_revm::database::StateProviderDatabase::new(&state_provider);
let mut state = State::builder().with_database(&mut db).with_bundle_update().build();
let mut state = State::builder()
.with_database_ref(StateProviderDatabase::new(&state_provider))
.with_bundle_update()
.build();

// Configure environments
let EvmEnv { cfg_env_with_handler_cfg, block_env } =
Expand Down Expand Up @@ -377,9 +380,9 @@ where
// and 4788 contract call
state.merge_transitions(BundleRetention::PlainState);

let outcome = ExecutionOutcome::new(
let outcome: ExecutionOutcome = ExecutionOutcome::new(
state.take_bundle(),
Receipts::<Receipt>::from(vec![receipts]),
Receipts::from(vec![receipts]),
reorg_target.number,
Default::default(),
);
Expand Down
2 changes: 1 addition & 1 deletion crates/ethereum/evm/src/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1123,7 +1123,7 @@ mod tests {
let initial_balance = 100;
db.insert_account(
withdrawal_recipient,
Account { balance: U256::from(initial_balance), nonce: 1, ..Default::default() },
Account { balance: U256::from(initial_balance), nonce: 1, bytecode_hash: None },
None,
HashMap::default(),
);
Expand Down
1 change: 0 additions & 1 deletion crates/evm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ reth-prune-types.workspace = true
reth-revm.workspace = true
reth-storage-errors.workspace = true

# scroll
revm.workspace = true
revm-primitives.workspace = true

Expand Down
2 changes: 1 addition & 1 deletion crates/evm/src/either.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ use alloc::boxed::Box;
use alloy_primitives::BlockNumber;
use reth_prune_types::PruneModes;
use reth_storage_errors::provider::ProviderError;
use revm::State;
use revm_primitives::db::Database;

// re-export Either
pub use futures_util::future::Either;
use revm::State;

impl<A, B> BlockExecutorProvider for Either<A, B>
where
Expand Down
10 changes: 5 additions & 5 deletions crates/exex/exex/src/backfill/job.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,9 @@ where
"Executing block range"
);

let db = StateProviderDatabase::new(
let mut executor = self.executor.batch_executor(StateProviderDatabase::new(
self.provider.history_by_block_number(self.range.start().saturating_sub(1))?,
);
let mut executor = self.executor.batch_executor(db);
));
executor.set_prune_modes(self.prune_modes.clone());

let mut fetch_block_duration = Duration::default();
Expand Down Expand Up @@ -202,8 +201,9 @@ where
.ok_or_else(|| ProviderError::HeaderNotFound(block_number.into()))?;

// Configure the executor to use the previous block's state.
let provider = self.provider.history_by_block_number(block_number.saturating_sub(1))?;
let executor = self.executor.executor(StateProviderDatabase::new(provider));
let executor = self.executor.executor(StateProviderDatabase::new(
self.provider.history_by_block_number(block_number.saturating_sub(1))?,
));

trace!(target: "exex::backfill", number = block_number, txs = block_with_senders.block.body().transactions().len(), "Executing block");

Expand Down
2 changes: 0 additions & 2 deletions crates/exex/exex/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
#![cfg_attr(not(test), warn(unused_crate_dependencies))]

use reth_revm as _;

mod backfill;
pub use backfill::*;

Expand Down
3 changes: 0 additions & 3 deletions crates/exex/test-utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,3 @@ eyre.workspace = true
rand.workspace = true
tempfile.workspace = true
thiserror.workspace = true

[features]
scroll = []
3 changes: 0 additions & 3 deletions crates/exex/test-utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
)]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
#![cfg_attr(not(test), warn(unused_crate_dependencies))]
// Don't use the crate if `scroll` feature is used.
#![cfg_attr(feature = "scroll", allow(unused_crate_dependencies))]
#![cfg(not(feature = "scroll"))]

use std::{
fmt::Debug,
Expand Down
4 changes: 2 additions & 2 deletions crates/net/network/src/transactions/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//! announcements. Validation and filtering of announcements is network dependent.
use crate::metrics::{AnnouncedTxTypesMetrics, TxTypesCounter};
use alloy_primitives::{PrimitiveSignature, TxHash};
use alloy_primitives::{PrimitiveSignature as Signature, TxHash};
use derive_more::{Deref, DerefMut};
use reth_eth_wire::{
DedupPayload, Eth68TxMetadata, HandleMempoolData, PartiallyValidData, ValidAnnouncementData,
Expand All @@ -14,7 +14,7 @@ use std::{fmt, fmt::Display, mem};
use tracing::trace;

/// The size of a decoded signature in bytes.
pub const SIGNATURE_DECODED_SIZE_BYTES: usize = mem::size_of::<PrimitiveSignature>();
pub const SIGNATURE_DECODED_SIZE_BYTES: usize = mem::size_of::<Signature>();

/// Interface for validating a `(ty, size, hash)` tuple from a
/// [`NewPooledTransactionHashes68`](reth_eth_wire::NewPooledTransactionHashes68)..
Expand Down
7 changes: 1 addition & 6 deletions crates/payload/basic/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,12 +203,7 @@ where
// this only includes changed accounts and storage but is better than nothing
let storage =
acc.storage.iter().map(|(key, slot)| (*key, slot.present_value)).collect();
cached.insert_account(
addr,
#[allow(clippy::useless_conversion)]
info.into(),
storage,
);
cached.insert_account(addr, info, storage);
}
}

Expand Down
8 changes: 1 addition & 7 deletions crates/primitives-traits/src/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub mod compact_ids {

/// An Ethereum account.
#[cfg_attr(any(test, feature = "serde"), derive(serde::Serialize, serde::Deserialize))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Default)]
#[cfg_attr(any(test, feature = "arbitrary"), derive(arbitrary::Arbitrary))]
#[cfg_attr(any(test, feature = "reth-codec"), derive(reth_codecs::Compact))]
#[cfg_attr(any(test, feature = "reth-codec"), reth_codecs::add_arbitrary_tests(compact))]
Expand All @@ -39,12 +39,6 @@ pub struct Account {
pub bytecode_hash: Option<B256>,
}

impl Default for Account {
fn default() -> Self {
Self { nonce: 0, balance: U256::ZERO, bytecode_hash: None }
}
}

impl Account {
/// Whether the account has bytecode.
pub const fn has_bytecode(&self) -> bool {
Expand Down
9 changes: 3 additions & 6 deletions crates/revm/src/cached.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@ use alloy_primitives::{
Address, B256, U256,
};
use core::cell::RefCell;
use revm::{
primitives::{
db::{Database, DatabaseRef},
Bytecode,
},
shared::AccountInfo,
use revm::primitives::{
db::{Database, DatabaseRef},
AccountInfo, Bytecode,
};

/// A container type that caches reads from an underlying [`DatabaseRef`].
Expand Down
2 changes: 1 addition & 1 deletion crates/revm/src/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use alloy_primitives::{Address, B256, U256};
use core::ops::{Deref, DerefMut};
use reth_primitives::Account;
use reth_storage_errors::provider::{ProviderError, ProviderResult};
use revm::{db::DatabaseRef, primitives::Bytecode, shared::AccountInfo, Database};
use revm::{db::DatabaseRef, primitives::Bytecode, AccountInfo, Database};

/// A helper trait responsible for providing state necessary for EVM execution.
///
Expand Down
2 changes: 1 addition & 1 deletion crates/revm/src/either.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use alloy_primitives::{Address, B256, U256};
use revm::{primitives::Bytecode, shared::AccountInfo, Database};
use revm::{primitives::Bytecode, AccountInfo, Database};

/// An enum type that can hold either of two different [`Database`] implementations.
///
Expand Down
11 changes: 7 additions & 4 deletions crates/rpc/rpc-eth-api/src/helpers/pending_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,12 @@ use reth_provider::{
BlockReader, BlockReaderIdExt, ChainSpecProvider, ProviderBlock, ProviderError, ProviderHeader,
ProviderReceipt, ProviderTx, ReceiptProvider, StateProviderFactory,
};
use reth_revm::primitives::{
BlockEnv, CfgEnvWithHandlerCfg, EVMError, Env, ExecutionResult, InvalidTransaction,
ResultAndState,
use reth_revm::{
database::StateProviderDatabase,
primitives::{
BlockEnv, CfgEnvWithHandlerCfg, EVMError, Env, ExecutionResult, InvalidTransaction,
ResultAndState,
},
};
use reth_rpc_eth_types::{EthApiError, PendingBlock, PendingBlockEnv, PendingBlockEnvOrigin};
use reth_transaction_pool::{
Expand Down Expand Up @@ -257,7 +260,7 @@ pub trait LoadPendingBlock:
.provider()
.history_by_block_hash(parent_hash)
.map_err(Self::Error::from_eth_err)?;
let state = reth_revm::database::StateProviderDatabase::new(state_provider);
let state = StateProviderDatabase::new(state_provider);
let mut db = State::builder().with_database(state).with_bundle_update().build();

let mut cumulative_gas_used = 0;
Expand Down
6 changes: 2 additions & 4 deletions crates/scroll/consensus/src/curie.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
use revm::{
db::states::StorageSlot,
primitives::{address, bytes, Address, Bytecode, Bytes, U256},
shared::AccountInfo,
Database, State,
AccountInfo, Database, State,
};

/// L1 gas price oracle address.
Expand Down Expand Up @@ -126,8 +125,7 @@ mod tests {
db::states::{bundle_state::BundleRetention, plain_account::PlainStorage, StorageSlot},
keccak256,
primitives::{bytes, poseidon, U256},
shared::AccountInfo,
Bytecode, Database, EmptyDB, State,
AccountInfo, Bytecode, Database, EmptyDB, State,
};
use std::str::FromStr;

Expand Down
3 changes: 1 addition & 2 deletions crates/scroll/evm/src/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,7 @@ mod tests {
use revm::{
db::states::{bundle_state::BundleRetention, StorageSlot},
primitives::{Address, B256, U256},
shared::AccountInfo,
Bytecode, EmptyDBTyped, TxKind,
AccountInfo, Bytecode, EmptyDBTyped, TxKind,
};

const BLOCK_GAS_LIMIT: u64 = 10_000_000;
Expand Down
5 changes: 0 additions & 5 deletions crates/scroll/revm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@ pub use revm::{
JournaledState,
};

/// Shared module, available for all feature flags.
pub mod shared {
pub use revm::{db::states::BundleState, primitives::AccountInfo};
}

/// Match the `revm` module structure
pub mod handler {
pub use revm::handler::*;
Expand Down
4 changes: 0 additions & 4 deletions crates/stages/stages/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ reth-trie-db = { workspace = true, features = ["metrics"] }

reth-testing-utils = { workspace = true, optional = true }

# scroll
reth-scroll-primitives = { workspace = true, optional = true }

alloy-eips.workspace = true
alloy-primitives.workspace = true
alloy-consensus.workspace = true
Expand Down Expand Up @@ -132,7 +129,6 @@ scroll = [
"reth-db/scroll",
"reth-evm-ethereum/scroll",
"reth-exex/scroll",
"reth-scroll-primitives"
]
skip-state-root-validation = []

Expand Down
4 changes: 0 additions & 4 deletions crates/stages/stages/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,6 @@
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
#![cfg_attr(not(test), warn(unused_crate_dependencies))]

use reth_revm as _;
#[cfg(feature = "scroll")]
use reth_scroll_primitives as _;

#[allow(missing_docs)]
#[cfg(any(test, feature = "test-utils"))]
pub mod test_utils;
Expand Down
11 changes: 6 additions & 5 deletions crates/stages/stages/src/stages/execution.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use super::missing_static_data_error;
use crate::stages::MERKLE_STAGE_DEFAULT_CLEAN_THRESHOLD;
use alloy_consensus::{BlockHeader, Header, Sealable};
use alloy_eips::{eip1898::BlockWithParent, NumHash};
Expand Down Expand Up @@ -37,6 +36,8 @@ use std::{
};
use tracing::*;

use super::missing_static_data_error;

/// The execution stage executes all transactions and
/// update history indexes.
///
Expand Down Expand Up @@ -302,8 +303,8 @@ where

self.ensure_consistency(provider, input.checkpoint().block_number, None)?;

let state = LatestStateProviderRef::new(provider);
let mut executor = self.executor_provider.batch_executor(StateProviderDatabase(state));
let db = StateProviderDatabase(LatestStateProviderRef::new(provider));
let mut executor = self.executor_provider.batch_executor(db);
executor.set_tip(max_block);
executor.set_prune_modes(prune_modes);

Expand Down Expand Up @@ -1192,15 +1193,15 @@ mod tests {
Account {
nonce: 0,
balance: U256::from(0x1bc16d674eca30a0u64),
bytecode_hash: None,
bytecode_hash: None
}
),
(
caller_address,
Account {
nonce: 1,
balance: U256::from(0xde0b6b3a761cf60u64),
bytecode_hash: None,
bytecode_hash: None
}
)
]
Expand Down
Loading

0 comments on commit ffff7e0

Please sign in to comment.