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

build: bump deps #437

Merged
merged 1 commit into from
Nov 27, 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
492 changes: 265 additions & 227 deletions Cargo.lock

Large diffs are not rendered by default.

48 changes: 25 additions & 23 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,49 +33,51 @@ use_self = "warn"
pevm = { path = "crates/pevm", features = ["full"] }

# alloy
alloy-chains = "0.1.46"
alloy-consensus = "0.5.4"
alloy-primitives = { version = "0.8.10", features = [
alloy-chains = "0.1.47"
alloy-consensus = "0.6.4"
alloy-primitives = { version = "0.8.13", features = [
"asm-keccak",
"map-fxhash",
] }
alloy-provider = "0.5.4"
alloy-provider = "0.6.4"
alloy-rlp = "0.3.9"
alloy-rpc-types-eth = "0.5.4"
alloy-transport = "0.5.4"
alloy-transport-http = "0.5.4"
alloy-trie = "0.7.2"
alloy-rpc-types-eth = "0.6.4"
alloy-transport = "0.6.4"
alloy-transport-http = "0.6.4"
alloy-trie = "0.7.4"

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

# OP
op-alloy-consensus = "0.5.2"
op-alloy-network = "0.5.2"
op-alloy-rpc-types = "0.5.2"
op-alloy-consensus = "0.6.8"
op-alloy-network = "0.6.8"
op-alloy-rpc-types = "0.6.8"

# Allocators
rpmalloc = { version = "0.2.2", features = ["thread_cache", "global_cache"] }
snmalloc-rs = "0.3.6"
tikv-jemallocator = "0.6.0"

bincode = "1.3.3"
# We can roll our own but [revm] depends on this anyway.
bitflags = "2.6.0"
bitvec = "1.0.1"
clap = { version = "4.5.20", features = ["derive"] }
clap = { version = "4.5.21", features = ["derive"] }
criterion = "0.5.1"
dashmap = "6.1.0"
flate2 = "1.0.34"
hashbrown = "0.15.1"
flate2 = "1.0.35"
hashbrown = "0.15.2"
rand = "0.8.5"
rayon = "1.10.0"
reqwest = "0.12.9"
rpmalloc = { version = "0.2.2", features = ["thread_cache", "global_cache"] }
rustc-hash = "2.0.0"
serde = "1.0.214"
serde_json = "1.0.132"
serde = "1.0.215"
serde_json = "1.0.133"
smallvec = "1.13.2"
snmalloc-rs = "0.3.6"
thiserror = "1.0.68"
tikv-jemallocator = "0.6.0"
tokio = { version = "1.41.0", features = ["rt-multi-thread"] }
thiserror = "2.0.3"
tokio = { version = "1.41.1", features = ["rt-multi-thread"] }
walkdir = "2.5.0"
2 changes: 1 addition & 1 deletion bins/fetch/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ async fn main() -> Result<(), Box<dyn Error>> {

// Execute the block and track the pre-state in the RPC storage.
Pevm::default()
.execute(&storage, &chain, block.clone(), NonZeroUsize::MIN, true)
.execute(&storage, &chain, &block, NonZeroUsize::MIN, true)
.map_err(|err| format!("Failed to execute block: {:?}", err))?;

let block_dir = format!("data/blocks/{}", block.header.number);
Expand Down
4 changes: 2 additions & 2 deletions crates/pevm/benches/mainnet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ pub fn criterion_benchmark(c: &mut Criterion) {
pevm.execute(
black_box(&storage),
black_box(&chain),
black_box(block.clone()),
black_box(&block),
black_box(concurrency_level),
black_box(true),
)
Expand All @@ -65,7 +65,7 @@ pub fn criterion_benchmark(c: &mut Criterion) {
pevm.execute(
black_box(&storage),
black_box(&chain),
black_box(block.clone()),
black_box(&block),
black_box(concurrency_level),
black_box(false),
)
Expand Down
27 changes: 22 additions & 5 deletions crates/pevm/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

use std::fmt::Debug;

use alloy_primitives::B256;
use alloy_rpc_types_eth::{BlockTransactions, Header};
use alloy_consensus::{Signed, TxLegacy};
use alloy_primitives::{Address, B256};
use alloy_rpc_types_eth::{BlockTransactions, Header, Transaction};
use revm::{
primitives::{BlockEnv, SpecId, TxEnv},
Handler,
Expand Down Expand Up @@ -44,6 +45,10 @@ pub trait PevmChain: Debug {
/// The transaction type
type Transaction: Debug + Clone + PartialEq;

/// The envelope type
// TODO: Support more tx conversions
type Envelope: Debug + From<Signed<TxLegacy>>;

/// The error type for [`Self::get_block_spec`].
type BlockSpecError: Debug + Clone + PartialEq;

Expand All @@ -53,14 +58,26 @@ pub trait PevmChain: Debug {
/// Get chain id.
fn id(&self) -> u64;

/// Build `Self::Transaction` type from Alloy's transaction
fn build_tx_from_alloy_tx(&self, tx: alloy_rpc_types_eth::Transaction) -> Self::Transaction;
/// Mock RPC transaction for testing.
fn mock_rpc_tx(envelope: Self::Envelope, from: Address) -> Transaction<Self::Envelope> {
Transaction {
inner: envelope,
from,
block_hash: None,
block_number: None,
transaction_index: None,
effective_gas_price: None,
}
}

/// Mock `Self::Transaction` for testing.
fn mock_tx(&self, envelope: Self::Envelope, from: Address) -> Self::Transaction;

/// Get block's [`SpecId`]
fn get_block_spec(&self, header: &Header) -> Result<SpecId, Self::BlockSpecError>;

/// Get [`TxEnv`]
fn get_tx_env(&self, tx: Self::Transaction) -> Result<TxEnv, Self::TransactionParsingError>;
fn get_tx_env(&self, tx: &Self::Transaction) -> Result<TxEnv, Self::TransactionParsingError>;

/// Build [`MvMemory`]
fn build_mv_memory(&self, _block_env: &BlockEnv, txs: &[TxEnv]) -> MvMemory {
Expand Down
67 changes: 25 additions & 42 deletions crates/pevm/src/chain/ethereum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

use std::{collections::BTreeMap, fmt::Debug};

use alloy_consensus::{ReceiptEnvelope, TxType};
use alloy_primitives::{B256, U256};
use alloy_consensus::{ReceiptEnvelope, Transaction, TxEnvelope, TxType};
use alloy_primitives::{Address, B256, U256};
use alloy_provider::network::eip2718::Encodable2718;
use alloy_rpc_types_eth::{BlockTransactions, Header};
use hashbrown::HashMap;
Expand Down Expand Up @@ -43,45 +43,32 @@ pub enum EthereumBlockSpecError {
/// Represents errors that can occur when parsing transactions
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum EthereumTransactionParsingError {
/// [tx.type] is invalid.
InvalidType(u8),
/// [`tx.gas_price`] is none.
MissingGasPrice,
/// [`tx.max_fee_per_gas`] is none.
MissingMaxFeePerGas,
}

fn get_ethereum_gas_price(
tx: &alloy_rpc_types_eth::Transaction,
) -> Result<U256, EthereumTransactionParsingError> {
let tx_type_raw: u8 = tx.transaction_type.unwrap_or_default();
let Ok(tx_type) = TxType::try_from(tx_type_raw) else {
return Err(EthereumTransactionParsingError::InvalidType(tx_type_raw));
};

match tx_type {
fn get_ethereum_gas_price(tx: &TxEnvelope) -> Result<U256, EthereumTransactionParsingError> {
match tx.tx_type() {
TxType::Legacy | TxType::Eip2930 => tx
.gas_price
.gas_price()
.map(U256::from)
.ok_or(EthereumTransactionParsingError::MissingGasPrice),
TxType::Eip1559 | TxType::Eip4844 | TxType::Eip7702 => tx
.max_fee_per_gas
.map(U256::from)
.ok_or(EthereumTransactionParsingError::MissingMaxFeePerGas),
TxType::Eip1559 | TxType::Eip4844 | TxType::Eip7702 => Ok(U256::from(tx.max_fee_per_gas())),
}
}

impl PevmChain for PevmEthereum {
type Transaction = alloy_rpc_types_eth::Transaction;
type Envelope = TxEnvelope;
type BlockSpecError = EthereumBlockSpecError;
type TransactionParsingError = EthereumTransactionParsingError;

fn id(&self) -> u64 {
self.id
}

fn build_tx_from_alloy_tx(&self, tx: alloy_rpc_types_eth::Transaction) -> Self::Transaction {
tx
fn mock_tx(&self, envelope: Self::Envelope, from: Address) -> Self::Transaction {
Self::mock_rpc_tx(envelope, from)
}

/// Get the REVM spec id of an Alloy block.
Expand Down Expand Up @@ -127,21 +114,23 @@ impl PevmChain for PevmEthereum {
// https://github.com/paradigmxyz/reth/blob/280aaaedc4699c14a5b6e88f25d929fe22642fa3/crates/primitives/src/revm/env.rs#L234-L339
// https://github.com/paradigmxyz/reth/blob/280aaaedc4699c14a5b6e88f25d929fe22642fa3/crates/primitives/src/alloy_compat.rs#L112-L233
// TODO: Properly test this.
fn get_tx_env(&self, tx: Self::Transaction) -> Result<TxEnv, EthereumTransactionParsingError> {
fn get_tx_env(&self, tx: &Self::Transaction) -> Result<TxEnv, EthereumTransactionParsingError> {
Ok(TxEnv {
caller: tx.from,
gas_limit: tx.gas,
gas_price: get_ethereum_gas_price(&tx)?,
gas_priority_fee: tx.max_priority_fee_per_gas.map(U256::from),
transact_to: tx.to.into(),
value: tx.value,
data: tx.input,
nonce: Some(tx.nonce),
chain_id: tx.chain_id,
access_list: tx.access_list.unwrap_or_default().into(),
blob_hashes: tx.blob_versioned_hashes.unwrap_or_default(),
max_fee_per_blob_gas: tx.max_fee_per_blob_gas.map(U256::from),
authorization_list: tx.authorization_list.map(AuthorizationList::Signed),
gas_limit: tx.gas_limit(),
gas_price: get_ethereum_gas_price(&tx.inner)?,
gas_priority_fee: tx.max_priority_fee_per_gas().map(U256::from),
transact_to: tx.kind(),
value: tx.value(),
data: tx.input().clone(),
nonce: Some(tx.nonce()),
chain_id: tx.chain_id(),
access_list: tx.access_list().cloned().unwrap_or_default().to_vec(),
blob_hashes: tx.blob_versioned_hashes().unwrap_or_default().to_vec(),
max_fee_per_blob_gas: tx.max_fee_per_blob_gas().map(U256::from),
authorization_list: tx
.authorization_list()
.map(|auths| AuthorizationList::Signed(auths.to_vec())),
#[cfg(feature = "optimism")]
optimism: revm::primitives::OptimismFields::default(),
})
Expand Down Expand Up @@ -194,13 +183,7 @@ impl PevmChain for PevmEthereum {
}

// 1. Create a [Vec<TxType>]
let tx_types: Vec<TxType> = txs
.txns()
.map(|tx| {
let byte = tx.transaction_type.unwrap_or_default();
TxType::try_from(byte).map_err(|_| CalculateReceiptRootError::InvalidTxType(byte))
})
.collect::<Result<_, _>>()?;
let tx_types: Vec<TxType> = txs.txns().map(|tx| tx.inner.tx_type()).collect::<Vec<_>>();

// 2. Create an iterator of [ReceiptEnvelope]
let receipt_envelope_iter =
Expand Down
Loading