bump alloy version (#7344)

This commit is contained in:
Thomas Coratger
2024-03-27 12:41:31 +01:00
committed by GitHub
parent 4d798c7b65
commit 8b4898b651
12 changed files with 163 additions and 152 deletions

View File

@ -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() },
)]),

View File

@ -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(),

View File

@ -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

View File

@ -319,7 +319,7 @@ 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() },
@ -327,7 +327,7 @@ mod tests {
(
address_with_storage,
GenesisAccount {
storage: Some(HashMap::from([(storage_key, B256::random())])),
storage: Some(BTreeMap::from([(storage_key, B256::random())])),
..Default::default()
},
),

View File

@ -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.
@ -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);
@ -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);

View File

@ -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()
@ -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()
@ -295,11 +295,11 @@ 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,
@ -307,9 +307,9 @@ pub fn convert_withdrawal_to_standalone_withdraw(
}
}
/// 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,
@ -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 }
}

View File

@ -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,
@ -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()
@ -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()
@ -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()
@ -114,7 +115,7 @@ fn fill(
storage_keys: item.storage_keys.iter().map(|key| key.0.into()).collect(),
})
.collect(),
)
))
}
_ => {
// OP deposit tx
@ -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 {
@ -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),

View File

@ -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();
@ -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(),
@ -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(),
@ -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(),
@ -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(),
@ -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)),

View File

@ -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,