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

chore: bump deps #456

Merged
merged 1 commit into from
Jan 10, 2025
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
365 changes: 181 additions & 184 deletions Cargo.lock

Large diffs are not rendered by default.

40 changes: 20 additions & 20 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,29 +39,29 @@ use_self = "warn"
pevm = { path = "crates/pevm", features = ["full"] }

# alloy
alloy-chains = "0.1.51"
alloy-consensus = "0.8.3"
alloy-primitives = { version = "0.8.15", features = [
alloy-chains = "0.1.54"
alloy-consensus = "0.9.2"
alloy-primitives = { version = "0.8.18", features = [
"asm-keccak",
"map-fxhash",
] }
alloy-provider = "0.8.3"
alloy-provider = "0.9.2"
alloy-rlp = "0.3.10"
alloy-rpc-types-eth = "0.8.3"
alloy-transport = "0.8.3"
alloy-transport-http = "0.8.3"
alloy-trie = "0.7.7"
alloy-rpc-types-eth = "0.9.2"
alloy-transport = "0.9.2"
alloy-transport-http = "0.9.2"
alloy-trie = "0.7.8"

# Will remove [revm] with https://github.com/risechain/pevm/issues/382.
revm = { git = "https://github.com/risechain/revm", rev = "94a69feabb941c43d0d554cd8fa689a3d6904274", features = [
revm = { git = "https://github.com/risechain/revm", rev = "ac75f1ef59ecae15238f5a2e94e71c3bcc01d45c", features = [
"serde",
] }
revme = { git = "https://github.com/risechain/revm", rev = "94a69feabb941c43d0d554cd8fa689a3d6904274" }
revme = { git = "https://github.com/risechain/revm", rev = "ac75f1ef59ecae15238f5a2e94e71c3bcc01d45c" }

# OP
op-alloy-consensus = "0.8.5"
op-alloy-network = "0.8.5"
op-alloy-rpc-types = "0.8.5"
op-alloy-consensus = "0.9.2"
op-alloy-network = "0.9.2"
op-alloy-rpc-types = "0.9.2"

# Allocators
rpmalloc = { version = "0.2.2", features = ["thread_cache", "global_cache"] }
Expand All @@ -70,20 +70,20 @@ tikv-jemallocator = "0.6.0"

bincode = "1.3.3"
# We can roll our own but [revm] depends on this anyway.
bitflags = "2.6.0"
bitflags = "2.7.0"
bitvec = "1.0.1"
clap = { version = "4.5.23", features = ["derive"] }
clap = { version = "4.5.26", features = ["derive"] }
criterion = "0.5.1"
dashmap = "6.1.0"
flate2 = "1.0.35"
hashbrown = "0.15.2"
rand = "0.8.5"
rayon = "1.10.0"
reqwest = "0.12.9"
reqwest = "0.12.12"
rustc-hash = "2.1.0"
serde = "1.0.216"
serde_json = "1.0.134"
serde = "1.0.217"
serde_json = "1.0.135"
smallvec = "1.13.2"
thiserror = "2.0.9"
tokio = { version = "1.42.0", features = ["rt-multi-thread"] }
thiserror = "2.0.10"
tokio = { version = "1.43.0", features = ["rt-multi-thread"] }
walkdir = "2.5.0"
18 changes: 4 additions & 14 deletions crates/pevm/src/chain/ethereum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,6 @@ impl PevmEthereum {
// TODO: support Ethereum Sepolia and other testnets
}

/// Error type for [`PevmEthereum::get_block_spec`].
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum EthereumBlockSpecError {
/// When [`header.total_difficulty`] is none.
MissingTotalDifficulty,
}

/// Represents errors that can occur when parsing transactions
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum EthereumTransactionParsingError {
Expand All @@ -58,7 +51,7 @@ fn get_ethereum_gas_price(tx: &TxEnvelope) -> Result<U256, EthereumTransactionPa
impl PevmChain for PevmEthereum {
type Transaction = alloy_rpc_types_eth::Transaction;
type Envelope = TxEnvelope;
type BlockSpecError = EthereumBlockSpecError;
type BlockSpecError = ();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit late to the party, but this could be std::convert::Infallible which makes Result::Err not constructable and makes functions always return Result::Ok

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes, thanks. More care and justice for pevm soon™️!

type TransactionParsingError = EthereumTransactionParsingError;

fn id(&self) -> u64 {
Expand All @@ -80,12 +73,9 @@ impl PevmChain for PevmEthereum {
SpecId::CANCUN
} else if header.timestamp >= 1681338455 {
SpecId::SHANGHAI
} else if (header
.total_difficulty
.ok_or(EthereumBlockSpecError::MissingTotalDifficulty)?)
.saturating_sub(header.difficulty)
>= U256::from(58_750_000_000_000_000_000_000_u128)
{
}
// Checking for total difficulty is more precise but many RPC providers stopped returning it...
else if header.number >= 15537394 {
SpecId::MERGE
} else if header.number >= 12965000 {
SpecId::LONDON
Expand Down
8 changes: 5 additions & 3 deletions crates/pevm/src/compat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
// Ideally REVM & Alloy would provide all these.

use alloy_rpc_types_eth::Header;
use revm::primitives::{BlobExcessGasAndPrice, BlockEnv, U256};
use revm::primitives::{BlobExcessGasAndPrice, BlockEnv, SpecId, U256};

/// Get the REVM block env of an Alloy block.
// https://github.com/paradigmxyz/reth/blob/280aaaedc4699c14a5b6e88f25d929fe22642fa3/crates/primitives/src/revm/env.rs#L23-L48
// TODO: Better error handling & properly test this, especially
// [blob_excess_gas_and_price].
pub(crate) fn get_block_env(header: &Header) -> BlockEnv {
pub(crate) fn get_block_env(header: &Header, spec_id: SpecId) -> BlockEnv {
BlockEnv {
number: U256::from(header.number),
coinbase: header.beneficiary,
Expand All @@ -17,6 +17,8 @@ pub(crate) fn get_block_env(header: &Header) -> BlockEnv {
basefee: U256::from(header.base_fee_per_gas.unwrap_or_default()),
difficulty: header.difficulty,
prevrandao: Some(header.mix_hash),
blob_excess_gas_and_price: header.excess_blob_gas.map(BlobExcessGasAndPrice::new),
blob_excess_gas_and_price: header.excess_blob_gas.map(|excess_blob_gas| {
BlobExcessGasAndPrice::new(excess_blob_gas, spec_id.is_enabled_in(SpecId::PRAGUE))
}),
}
}
6 changes: 3 additions & 3 deletions crates/pevm/src/pevm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ impl Pevm {
let spec_id = chain
.get_block_spec(&block.header)
.map_err(PevmError::BlockSpecError)?;
let block_env = get_block_env(&block.header);
let block_env = get_block_env(&block.header, spec_id);
let tx_envs = match &block.transactions {
BlockTransactions::Full(txs) => txs
.iter()
Expand Down Expand Up @@ -231,7 +231,7 @@ impl Pevm {
}

let mut fully_evaluated_results = Vec::with_capacity(block_size);
let mut cumulative_gas_used: u128 = 0;
let mut cumulative_gas_used: u64 = 0;
for i in 0..block_size {
let mut execution_result = index_mutex!(self.execution_results, i).take().unwrap();
cumulative_gas_used =
Expand Down Expand Up @@ -439,7 +439,7 @@ pub fn execute_revm_sequential<S: Storage, C: PevmChain>(
let mut db = CacheDB::new(StorageWrapper(storage));
let mut evm = build_evm(&mut db, chain, spec_id, block_env, None, true);
let mut results = Vec::with_capacity(txs.len());
let mut cumulative_gas_used: u128 = 0;
let mut cumulative_gas_used: u64 = 0;
for tx in txs {
*evm.tx_mut() = tx;
match evm.transact() {
Expand Down
8 changes: 4 additions & 4 deletions crates/pevm/src/vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl PevmTxExecutionResult {
Self {
receipt: Receipt {
status: result.is_success().into(),
cumulative_gas_used: result.gas_used() as u128,
cumulative_gas_used: result.gas_used(),
logs: result.into_logs(),
},
state: state
Expand Down Expand Up @@ -655,7 +655,7 @@ impl<'a, S: Storage, C: PevmChain> Vm<'a, S, C> {
tx,
U256::from(result_and_state.result.gas_used()),
#[cfg(feature = "optimism")]
&evm.context.evm,
&mut evm.context.evm,
)?;

drop(evm); // release db
Expand Down Expand Up @@ -715,7 +715,7 @@ impl<'a, S: Storage, C: PevmChain> Vm<'a, S, C> {
write_set: &mut WriteSet,
tx: &TxEnv,
gas_used: U256,
#[cfg(feature = "optimism")] evm_context: &EvmContext<DB>,
#[cfg(feature = "optimism")] evm_context: &mut EvmContext<DB>,
) -> Result<(), VmExecutionError> {
let mut gas_price = if let Some(priority_fee) = tx.gas_priority_fee {
std::cmp::min(
Expand Down Expand Up @@ -750,7 +750,7 @@ impl<'a, S: Storage, C: PevmChain> Vm<'a, S, C> {
let Some(enveloped_tx) = &tx.optimism.enveloped_tx else {
panic!("[OPTIMISM] Failed to load enveloped transaction.");
};
let Some(l1_block_info) = &evm_context.l1_block_info else {
let Some(l1_block_info) = &mut evm_context.l1_block_info else {
panic!("[OPTIMISM] Missing l1_block_info.");
};
let l1_cost = l1_block_info.calculate_tx_l1_cost(enveloped_tx, self.spec_id);
Expand Down
2 changes: 1 addition & 1 deletion crates/pevm/tests/common/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ pub fn test_execute_alloy<C, S>(
);

assert_eq!(
block.header.gas_used as u128,
block.header.gas_used,
tx_results
.iter()
.last()
Expand Down
61 changes: 30 additions & 31 deletions crates/pevm/tests/ethereum/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,10 @@ use rayon::iter::{IntoParallelIterator, IntoParallelRefIterator, ParallelIterato
use revm::db::PlainAccount;
use revm::primitives::ruint::ParseError;
use revm::primitives::{
calc_excess_blob_gas, AccountInfo, AuthorizationList, BlobExcessGasAndPrice, BlockEnv,
Bytecode, TransactTo, TxEnv, KECCAK_EMPTY, U256,
};
use revme::cmd::statetest::models::{
Env, SpecName, TestSuite, TestUnit, TransactionParts, TxPartIndices,
calc_excess_blob_gas, AccountInfo, BlobExcessGasAndPrice, BlockEnv, Bytecode, SpecId,
TransactTo, TxEnv, KECCAK_EMPTY, U256,
};
use revme::cmd::statetest::models::{Env, SpecName, Test, TestSuite, TestUnit, TransactionParts};
use revme::cmd::statetest::{
merkle_trie::{log_rlp_hash, state_merkle_trie_root},
utils::recover_address,
Expand All @@ -37,7 +35,7 @@ use walkdir::{DirEntry, WalkDir};
#[path = "../common/mod.rs"]
pub mod common;

fn build_block_env(env: &Env) -> BlockEnv {
fn build_block_env(env: &Env, spec_id: SpecId) -> BlockEnv {
BlockEnv {
number: env.current_number,
coinbase: env.current_coinbase,
Expand All @@ -49,25 +47,31 @@ fn build_block_env(env: &Env) -> BlockEnv {
blob_excess_gas_and_price: if let Some(current_excess_blob_gas) =
env.current_excess_blob_gas
{
Some(BlobExcessGasAndPrice::new(current_excess_blob_gas.to()))
Some(BlobExcessGasAndPrice::new(
current_excess_blob_gas.to(),
spec_id.is_enabled_in(SpecId::PRAGUE),
))
} else if let (Some(parent_blob_gas_used), Some(parent_excess_blob_gas)) =
(env.parent_blob_gas_used, env.parent_excess_blob_gas)
{
Some(BlobExcessGasAndPrice::new(calc_excess_blob_gas(
parent_blob_gas_used.to(),
parent_excess_blob_gas.to(),
)))
Some(BlobExcessGasAndPrice::new(
calc_excess_blob_gas(
parent_blob_gas_used.to(),
parent_excess_blob_gas.to(),
env.parent_target_blobs_per_block
.map(|i| i.to())
// https://github.com/bluealloy/revm/blob/a2451cdb30bd9d9aaca95f13bd50e2eafb619d8f/crates/specification/src/eip4844.rs#L23
.unwrap_or(3 * (1 << 17)),
),
spec_id.is_enabled_in(SpecId::PRAGUE),
))
} else {
None
},
}
}

fn build_tx_env(
path: &Path,
tx: &TransactionParts,
indexes: &TxPartIndices,
) -> Result<TxEnv, ParseError> {
fn build_tx_env(path: &Path, tx: &TransactionParts, test: &Test) -> Result<TxEnv, ParseError> {
Ok(TxEnv {
caller: if let Some(address) = tx.sender {
address
Expand All @@ -76,33 +80,26 @@ fn build_tx_env(
} else {
panic!("Failed to parse caller for {path:?}");
},
gas_limit: tx.gas_limit[indexes.gas].saturating_to(),
gas_limit: tx.gas_limit[test.indexes.gas].saturating_to(),
gas_price: tx.gas_price.or(tx.max_fee_per_gas).unwrap_or_default(),
transact_to: match tx.to {
Some(address) => TransactTo::Call(address),
None => TransactTo::Create,
},
value: U256::from_str(&tx.value[indexes.value])?,
data: tx.data[indexes.data].clone(),
value: U256::from_str(&tx.value[test.indexes.value])?,
data: tx.data[test.indexes.data].clone(),
nonce: Some(tx.nonce.saturating_to()),
chain_id: Some(1), // Ethereum mainnet
access_list: tx
.access_lists
.get(indexes.data)
.get(test.indexes.data)
.and_then(Option::as_deref)
.cloned()
.unwrap_or_default(),
gas_priority_fee: tx.max_priority_fee_per_gas,
blob_hashes: tx.blob_versioned_hashes.clone(),
max_fee_per_blob_gas: tx.max_fee_per_blob_gas,
authorization_list: tx.authorization_list.as_ref().map(|auth_list| {
AuthorizationList::Recovered(
auth_list
.iter()
.map(|auth| auth.clone().into_recovered())
.collect(),
)
}),
authorization_list: test.eip7702_authorization_list().unwrap(),
#[cfg(feature = "optimism")]
optimism: revm::primitives::OptimismFields::default(),
})
Expand All @@ -118,7 +115,7 @@ fn run_test_unit(path: &Path, unit: TestUnit) {
}

tests.into_par_iter().for_each(|test| {
let tx_env = build_tx_env(path, &unit.transaction, &test.indexes);
let tx_env = build_tx_env(path, &unit.transaction, &test);
if test.expect_exception.as_deref() == Some("TR_RLP_WRONGVALUE") && tx_env.is_err() {
return;
}
Expand Down Expand Up @@ -146,13 +143,15 @@ fn run_test_unit(path: &Path, unit: TestUnit) {
);
}

let spec_id = spec_name.to_spec_id();

match (
test.expect_exception.as_deref(),
Pevm::default().execute_revm_parallel(
&PevmEthereum::mainnet(),
&InMemoryStorage::new(chain_state.clone(), Arc::new(bytecodes), Default::default()),
spec_name.to_spec_id(),
build_block_env(&unit.env),
spec_id,
build_block_env(&unit.env, spec_id),
vec![tx_env.unwrap()],
NonZeroUsize::MIN,
),
Expand Down
Loading