Skip to content

Commit

Permalink
bump alloy version (paradigmxyz#7344)
Browse files Browse the repository at this point in the history
  • Loading branch information
tcoratger authored and Ruteri committed Apr 17, 2024
1 parent 4d2c54e commit 2d070e8
Show file tree
Hide file tree
Showing 12 changed files with 163 additions and 152 deletions.
199 changes: 108 additions & 91 deletions Cargo.lock

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions Cargo.toml
Expand Up @@ -246,21 +246,21 @@ reth-trie-parallel = { path = "crates/trie-parallel" }
# revm
revm = { version = "7.2.0", features = ["std", "secp256k1"], default-features = false }
revm-primitives = { version = "3.1.0", features = ["std"], default-features = false }
revm-inspectors = { git = "https://github.com/paradigmxyz/evm-inspectors", rev = "b3082f3" }
revm-inspectors = { git = "https://github.com/paradigmxyz/evm-inspectors", rev = "0ad0338" }

# eth
alloy-chains = { version = "0.1", feature = ["serde", "rlp", "arbitrary"] }
alloy-primitives = "0.6"
alloy-dyn-abi = "0.6"
alloy-sol-types = "0.6"
alloy-rlp = "0.3"
alloy-primitives = "0.6.4"
alloy-dyn-abi = "0.6.4"
alloy-sol-types = "0.6.4"
alloy-rlp = "0.3.4"
alloy-trie = "0.3"
alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy", rev = "410850b" }
alloy-rpc-trace-types = { git = "https://github.com/alloy-rs/alloy", rev = "410850b" }
alloy-rpc-engine-types = { git = "https://github.com/alloy-rs/alloy", rev = "410850b" }
alloy-genesis = { git = "https://github.com/alloy-rs/alloy", rev = "410850b" }
alloy-node-bindings = { git = "https://github.com/alloy-rs/alloy", rev = "410850b" }
alloy-eips = { git = "https://github.com/alloy-rs/alloy", rev = "410850b" }
alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy", rev = "7e39c85" }
alloy-rpc-trace-types = { git = "https://github.com/alloy-rs/alloy", rev = "7e39c85" }
alloy-rpc-engine-types = { git = "https://github.com/alloy-rs/alloy", rev = "7e39c85" }
alloy-genesis = { git = "https://github.com/alloy-rs/alloy", rev = "7e39c85" }
alloy-node-bindings = { git = "https://github.com/alloy-rs/alloy", rev = "7e39c85" }
alloy-eips = { git = "https://github.com/alloy-rs/alloy", rev = "7e39c85" }

# TODO: Remove
ethers-core = { version = "2.0.14", default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion crates/blockchain-tree/src/blockchain_tree.rs
Expand Up @@ -1406,7 +1406,7 @@ mod tests {
ChainSpecBuilder::default()
.chain(MAINNET.chain)
.genesis(Genesis {
alloc: HashMap::from([(
alloc: BTreeMap::from([(
signer,
GenesisAccount { balance: initial_signer_balance, ..Default::default() },
)]),
Expand Down
2 changes: 1 addition & 1 deletion crates/node-api/src/engine/payload.rs
Expand Up @@ -32,7 +32,7 @@ where
}

/// Return the withdrawals for the payload or attributes.
pub fn withdrawals(&self) -> Option<&Vec<reth_rpc_types::withdrawal::Withdrawal>> {
pub fn withdrawals(&self) -> Option<&Vec<reth_rpc_types::Withdrawal>> {
match self {
Self::ExecutionPayload { payload, .. } => payload.withdrawals(),
Self::PayloadAttributes(attributes) => attributes.withdrawals(),
Expand Down
2 changes: 1 addition & 1 deletion crates/node-api/src/engine/traits.rs
Expand Up @@ -7,7 +7,7 @@ use reth_primitives::{
};
use reth_rpc_types::{
engine::{OptimismPayloadAttributes, PayloadAttributes as EthPayloadAttributes, PayloadId},
withdrawal::Withdrawal,
Withdrawal,
};

/// Represents a built payload type that contains a built [SealedBlock] and can be converted into
Expand Down
4 changes: 2 additions & 2 deletions crates/node-core/src/init.rs
Expand Up @@ -319,15 +319,15 @@ mod tests {
let chain_spec = Arc::new(ChainSpec {
chain: Chain::from_id(1),
genesis: Genesis {
alloc: HashMap::from([
alloc: BTreeMap::from([
(
address_with_balance,
GenesisAccount { balance: U256::from(1), ..Default::default() },
),
(
address_with_storage,
GenesisAccount {
storage: Some(HashMap::from([(storage_key, B256::random())])),
storage: Some(BTreeMap::from([(storage_key, B256::random())])),
..Default::default()
},
),
Expand Down
6 changes: 3 additions & 3 deletions crates/primitives/src/genesis.rs
Expand Up @@ -15,7 +15,7 @@ mod allocator {
rand::{thread_rng, RngCore},
KeyPair, Secp256k1,
};
use std::collections::{hash_map::Entry, HashMap};
use std::collections::{hash_map::Entry, BTreeMap, HashMap};

/// This helps create a custom genesis alloc by making it easy to add funded accounts with known
/// signers to the genesis block.
Expand Down Expand Up @@ -109,7 +109,7 @@ mod allocator {
pub fn new_funded_account_with_storage(
&mut self,
balance: U256,
storage: HashMap<B256, B256>,
storage: BTreeMap<B256, B256>,
) -> (KeyPair, Address) {
let secp = Secp256k1::new();
let pair = KeyPair::new(&secp, &mut self.rng);
Expand All @@ -129,7 +129,7 @@ mod allocator {
pub fn new_account_with_code_and_storage(
&mut self,
code: Bytes,
storage: HashMap<B256, B256>,
storage: BTreeMap<B256, B256>,
) -> (KeyPair, Address) {
let secp = Secp256k1::new();
let pair = KeyPair::new(&secp, &mut self.rng);
Expand Down
24 changes: 10 additions & 14 deletions crates/rpc/rpc-types-compat/src/engine/payload.rs
Expand Up @@ -124,7 +124,7 @@ pub fn try_block_to_payload_v1(value: SealedBlock) -> ExecutionPayloadV1 {
/// Converts [SealedBlock] to [ExecutionPayloadV2]
pub fn try_block_to_payload_v2(value: SealedBlock) -> ExecutionPayloadV2 {
let transactions = value.raw_transactions();
let standalone_withdrawals: Vec<reth_rpc_types::withdrawal::Withdrawal> = value
let standalone_withdrawals: Vec<reth_rpc_types::Withdrawal> = value
.withdrawals
.clone()
.unwrap_or_default()
Expand Down Expand Up @@ -157,7 +157,7 @@ pub fn try_block_to_payload_v2(value: SealedBlock) -> ExecutionPayloadV2 {
pub fn block_to_payload_v3(value: SealedBlock) -> ExecutionPayloadV3 {
let transactions = value.raw_transactions();

let withdrawals: Vec<reth_rpc_types::withdrawal::Withdrawal> = value
let withdrawals: Vec<reth_rpc_types::Withdrawal> = value
.withdrawals
.clone()
.unwrap_or_default()
Expand Down Expand Up @@ -295,21 +295,21 @@ pub fn validate_block_hash(
Ok(sealed_block)
}

/// Converts [Withdrawal] to [reth_rpc_types::withdrawal::Withdrawal]
/// Converts [Withdrawal] to [reth_rpc_types::Withdrawal]
pub fn convert_withdrawal_to_standalone_withdraw(
withdrawal: Withdrawal,
) -> reth_rpc_types::withdrawal::Withdrawal {
reth_rpc_types::withdrawal::Withdrawal {
) -> reth_rpc_types::Withdrawal {
reth_rpc_types::Withdrawal {
index: withdrawal.index,
validator_index: withdrawal.validator_index,
address: withdrawal.address,
amount: withdrawal.amount,
}
}

/// Converts [reth_rpc_types::withdrawal::Withdrawal] to [Withdrawal]
/// Converts [reth_rpc_types::Withdrawal] to [Withdrawal]
pub fn convert_standalone_withdraw_to_withdrawal(
standalone: reth_rpc_types::withdrawal::Withdrawal,
standalone: reth_rpc_types::Withdrawal,
) -> Withdrawal {
Withdrawal {
index: standalone.index,
Expand All @@ -326,13 +326,9 @@ pub fn convert_to_payload_body_v1(value: Block) -> ExecutionPayloadBodyV1 {
tx.encode_enveloped(&mut out);
out.into()
});
let withdraw: Option<Vec<reth_rpc_types::withdrawal::Withdrawal>> =
value.withdrawals.map(|withdrawals| {
withdrawals
.into_iter()
.map(convert_withdrawal_to_standalone_withdraw)
.collect::<Vec<_>>()
});
let withdraw: Option<Vec<reth_rpc_types::Withdrawal>> = value.withdrawals.map(|withdrawals| {
withdrawals.into_iter().map(convert_withdrawal_to_standalone_withdraw).collect::<Vec<_>>()
});
ExecutionPayloadBodyV1 { transactions: transactions.collect(), withdrawals: withdraw }
}

Expand Down
35 changes: 18 additions & 17 deletions crates/rpc/rpc-types-compat/src/transaction/mod.rs
Expand Up @@ -7,11 +7,11 @@ use alloy_rpc_types::{
};
use reth_primitives::{
BlockNumber, Transaction as PrimitiveTransaction, TransactionKind as PrimitiveTransactionKind,
TransactionSignedEcRecovered, TxType, B256, U128, U256, U64,
TransactionSignedEcRecovered, TxType, B256, U128, U256, U8,
};
#[cfg(feature = "optimism")]
use reth_rpc_types::optimism::OptimismTransactionFields;
use reth_rpc_types::{AccessListItem, Transaction};
use reth_rpc_types::{AccessList, AccessListItem, Transaction};
use signature::from_primitive_signature;
pub use typed::*;
/// Create a new rpc transaction result for a mined transaction, using the given block hash,
Expand Down Expand Up @@ -75,13 +75,14 @@ fn fill(
}
};

let chain_id = signed_tx.chain_id().map(U64::from);
// let chain_id = signed_tx.chain_id().map(U64::from);
let chain_id = signed_tx.chain_id();
let mut blob_versioned_hashes = Vec::new();

#[allow(unreachable_patterns)]
let access_list = match &mut signed_tx.transaction {
PrimitiveTransaction::Legacy(_) => None,
PrimitiveTransaction::Eip2930(tx) => Some(
PrimitiveTransaction::Eip2930(tx) => Some(AccessList(
tx.access_list
.0
.iter()
Expand All @@ -90,8 +91,8 @@ fn fill(
storage_keys: item.storage_keys.iter().map(|key| key.0.into()).collect(),
})
.collect(),
),
PrimitiveTransaction::Eip1559(tx) => Some(
)),
PrimitiveTransaction::Eip1559(tx) => Some(AccessList(
tx.access_list
.0
.iter()
Expand All @@ -100,12 +101,12 @@ fn fill(
storage_keys: item.storage_keys.iter().map(|key| key.0.into()).collect(),
})
.collect(),
),
)),
PrimitiveTransaction::Eip4844(tx) => {
// extract the blob hashes from the transaction
blob_versioned_hashes = std::mem::take(&mut tx.blob_versioned_hashes);

Some(
Some(AccessList(
tx.access_list
.0
.iter()
Expand All @@ -114,7 +115,7 @@ fn fill(
storage_keys: item.storage_keys.iter().map(|key| key.0.into()).collect(),
})
.collect(),
)
))
}
_ => {
// OP deposit tx
Expand All @@ -127,27 +128,27 @@ fn fill(

Transaction {
hash: signed_tx.hash(),
nonce: U64::from(signed_tx.nonce()),
nonce: signed_tx.nonce(),
from: signer,
to,
value: signed_tx.value(),
gas_price,
max_fee_per_gas,
max_priority_fee_per_gas: signed_tx.max_priority_fee_per_gas().map(U128::from),
gas_price: gas_price.map(U256::from),
max_fee_per_gas: max_fee_per_gas.map(U256::from),
max_priority_fee_per_gas: signed_tx.max_priority_fee_per_gas().map(U256::from),
signature: Some(signature),
gas: U256::from(signed_tx.gas_limit()),
input: signed_tx.input().clone(),
chain_id,
access_list,
transaction_type: Some(U64::from(signed_tx.tx_type() as u8)),
transaction_type: Some(U8::from(signed_tx.tx_type() as u8)),

// These fields are set to None because they are not stored as part of the transaction
block_hash,
block_number: block_number.map(U256::from),
transaction_index,
// EIP-4844 fields
max_fee_per_blob_gas: signed_tx.max_fee_per_blob_gas().map(U128::from),
blob_versioned_hashes,
max_fee_per_blob_gas: signed_tx.max_fee_per_blob_gas().map(U256::from),
blob_versioned_hashes: Some(blob_versioned_hashes),
// Optimism fields
#[cfg(feature = "optimism")]
other: OptimismTransactionFields {
Expand Down Expand Up @@ -208,7 +209,7 @@ pub fn transaction_to_call_request(tx: TransactionSignedEcRecovered) -> Transact
gas: Some(U256::from(gas)),
value: Some(value),
input: TransactionInput::new(input),
nonce: Some(U64::from(nonce)),
nonce: Some(nonce),
chain_id,
access_list,
max_fee_per_blob_gas: max_fee_per_blob_gas.map(U256::from),
Expand Down
12 changes: 6 additions & 6 deletions crates/rpc/rpc/src/eth/api/transactions.rs
Expand Up @@ -692,7 +692,7 @@ where
let nonce =
self.get_transaction_count(from, Some(BlockId::Number(BlockNumberOrTag::Pending)))?;
// note: `.to()` can't panic because the nonce is constructed from a `u64`
request.nonce = Some(U64::from(nonce.to::<u64>()));
request.nonce = Some(nonce.to::<u64>());
}

let chain_id = self.chain_id();
Expand Down Expand Up @@ -731,7 +731,7 @@ where
// gas price required
(Some(_), None, None, None, None, None) => {
Some(TypedTransactionRequest::Legacy(LegacyTransactionRequest {
nonce: nonce.unwrap_or_default(),
nonce: U64::from(nonce.unwrap_or_default()),
gas_price: gas_price.unwrap_or_default(),
gas_limit: gas.unwrap_or_default(),
value: value.unwrap_or_default(),
Expand All @@ -747,7 +747,7 @@ where
// if only accesslist is set, and no eip1599 fees
(_, None, Some(access_list), None, None, None) => {
Some(TypedTransactionRequest::EIP2930(EIP2930TransactionRequest {
nonce: nonce.unwrap_or_default(),
nonce: U64::from(nonce.unwrap_or_default()),
gas_price: gas_price.unwrap_or_default(),
gas_limit: gas.unwrap_or_default(),
value: value.unwrap_or_default(),
Expand All @@ -767,7 +767,7 @@ where
(None, _, _, None, None, None) => {
// Empty fields fall back to the canonical transaction schema.
Some(TypedTransactionRequest::EIP1559(EIP1559TransactionRequest {
nonce: nonce.unwrap_or_default(),
nonce: U64::from(nonce.unwrap_or_default()),
max_fee_per_gas: max_fee_per_gas.unwrap_or_default(),
max_priority_fee_per_gas: max_priority_fee_per_gas.unwrap_or_default(),
gas_limit: gas.unwrap_or_default(),
Expand All @@ -794,7 +794,7 @@ where
// As per the EIP, we follow the same semantics as EIP-1559.
Some(TypedTransactionRequest::EIP4844(EIP4844TransactionRequest {
chain_id: 0,
nonce: nonce.unwrap_or_default(),
nonce: U64::from(nonce.unwrap_or_default()),
max_priority_fee_per_gas: max_priority_fee_per_gas.unwrap_or_default(),
max_fee_per_gas: max_fee_per_gas.unwrap_or_default(),
gas_limit: gas.unwrap_or_default(),
Expand Down Expand Up @@ -1519,7 +1519,7 @@ pub(crate) fn build_transaction_receipt_with_block_receipts(

#[allow(clippy::needless_update)]
let mut res_receipt = TransactionReceipt {
transaction_hash: Some(meta.tx_hash),
transaction_hash: meta.tx_hash,
transaction_index: U64::from(meta.index),
block_hash: Some(meta.block_hash),
block_number: Some(U256::from(meta.block_number)),
Expand Down
4 changes: 1 addition & 3 deletions crates/rpc/rpc/src/eth/revm_utils.rs
Expand Up @@ -358,9 +358,7 @@ pub(crate) fn create_txn_env(
let gas_limit = gas.unwrap_or_else(|| block_env.gas_limit.min(U256::from(u64::MAX)));
let env = TxEnv {
gas_limit: gas_limit.try_into().map_err(|_| RpcInvalidTransactionError::GasUintOverflow)?,
nonce: nonce
.map(|n| n.try_into().map_err(|_| RpcInvalidTransactionError::NonceTooHigh))
.transpose()?,
nonce,
caller: from.unwrap_or_default(),
gas_price,
gas_priority_fee: max_priority_fee_per_gas,
Expand Down
3 changes: 1 addition & 2 deletions examples/custom-node/src/main.rs
Expand Up @@ -52,8 +52,7 @@ use reth_rpc_types::{
ExecutionPayloadEnvelopeV2, ExecutionPayloadEnvelopeV3,
PayloadAttributes as EthPayloadAttributes, PayloadId,
},
withdrawal::Withdrawal,
ExecutionPayloadV1,
ExecutionPayloadV1, Withdrawal,
};
use reth_tracing::{RethTracer, Tracer};
use serde::{Deserialize, Serialize};
Expand Down

0 comments on commit 2d070e8

Please sign in to comment.