chore: alloy 0.4 (#11334)

This commit is contained in:
Matthias Seitz
2024-09-30 14:48:37 +02:00
committed by GitHub
parent e8153e5e2c
commit a5538bc041
80 changed files with 425 additions and 518 deletions

View File

@ -212,22 +212,7 @@ impl<'a> arbitrary::Arbitrary<'a> for Block {
.collect::<arbitrary::Result<Vec<_>>>()?;
// then generate up to 2 ommers
let ommers = (0..2)
.map(|_| {
let mut header = Header::arbitrary(u)?;
header.gas_limit = (header.gas_limit as u64).into();
header.gas_used = (header.gas_used as u64).into();
header.base_fee_per_gas = header
.base_fee_per_gas
.map(|base_fee_per_gas| (base_fee_per_gas as u64).into());
header.blob_gas_used =
header.blob_gas_used.map(|blob_gas_used| (blob_gas_used as u64).into());
header.excess_blob_gas =
header.excess_blob_gas.map(|excess_blob_gas| (excess_blob_gas as u64).into());
Ok(header)
})
.collect::<arbitrary::Result<Vec<_>>>()?;
let ommers = (0..2).map(|_| Header::arbitrary(u)).collect::<arbitrary::Result<Vec<_>>>()?;
Ok(Self {
header: u.arbitrary()?,
@ -685,16 +670,7 @@ impl<'a> arbitrary::Arbitrary<'a> for BlockBody {
// then generate up to 2 ommers
let ommers = (0..2)
.map(|_| {
let mut header = Header::arbitrary(u)?;
header.gas_limit = (header.gas_limit as u64).into();
header.gas_used = (header.gas_used as u64).into();
header.base_fee_per_gas = header
.base_fee_per_gas
.map(|base_fee_per_gas| (base_fee_per_gas as u64).into());
header.blob_gas_used =
header.blob_gas_used.map(|blob_gas_used| (blob_gas_used as u64).into());
header.excess_blob_gas =
header.excess_blob_gas.map(|excess_blob_gas| (excess_blob_gas as u64).into());
let header = Header::arbitrary(u)?;
Ok(header)
})

View File

@ -20,7 +20,7 @@ impl FillTxEnv for TransactionSigned {
tx_env.caller = sender;
match self.as_ref() {
Transaction::Legacy(tx) => {
tx_env.gas_limit = tx.gas_limit as u64;
tx_env.gas_limit = tx.gas_limit;
tx_env.gas_price = U256::from(tx.gas_price);
tx_env.gas_priority_fee = None;
tx_env.transact_to = tx.to;
@ -34,7 +34,7 @@ impl FillTxEnv for TransactionSigned {
tx_env.authorization_list = None;
}
Transaction::Eip2930(tx) => {
tx_env.gas_limit = tx.gas_limit as u64;
tx_env.gas_limit = tx.gas_limit;
tx_env.gas_price = U256::from(tx.gas_price);
tx_env.gas_priority_fee = None;
tx_env.transact_to = tx.to;
@ -48,7 +48,7 @@ impl FillTxEnv for TransactionSigned {
tx_env.authorization_list = None;
}
Transaction::Eip1559(tx) => {
tx_env.gas_limit = tx.gas_limit as u64;
tx_env.gas_limit = tx.gas_limit;
tx_env.gas_price = U256::from(tx.max_fee_per_gas);
tx_env.gas_priority_fee = Some(U256::from(tx.max_priority_fee_per_gas));
tx_env.transact_to = tx.to;
@ -62,7 +62,7 @@ impl FillTxEnv for TransactionSigned {
tx_env.authorization_list = None;
}
Transaction::Eip4844(tx) => {
tx_env.gas_limit = tx.gas_limit as u64;
tx_env.gas_limit = tx.gas_limit;
tx_env.gas_price = U256::from(tx.max_fee_per_gas);
tx_env.gas_priority_fee = Some(U256::from(tx.max_priority_fee_per_gas));
tx_env.transact_to = TxKind::Call(tx.to);
@ -76,7 +76,7 @@ impl FillTxEnv for TransactionSigned {
tx_env.authorization_list = None;
}
Transaction::Eip7702(tx) => {
tx_env.gas_limit = tx.gas_limit as u64;
tx_env.gas_limit = tx.gas_limit;
tx_env.gas_price = U256::from(tx.max_fee_per_gas);
tx_env.gas_priority_fee = Some(U256::from(tx.max_priority_fee_per_gas));
tx_env.transact_to = tx.to.into();
@ -93,7 +93,7 @@ impl FillTxEnv for TransactionSigned {
#[cfg(feature = "optimism")]
Transaction::Deposit(tx) => {
tx_env.access_list.clear();
tx_env.gas_limit = tx.gas_limit as u64;
tx_env.gas_limit = tx.gas_limit;
tx_env.gas_price = U256::ZERO;
tx_env.gas_priority_fee = None;
tx_env.transact_to = tx.to;

View File

@ -140,35 +140,29 @@ impl<'a> arbitrary::Arbitrary<'a> for Transaction {
fn arbitrary(u: &mut arbitrary::Unstructured<'a>) -> arbitrary::Result<Self> {
let mut tx = match TxType::arbitrary(u)? {
TxType::Legacy => {
let mut tx = TxLegacy::arbitrary(u)?;
tx.gas_limit = (tx.gas_limit as u64).into();
let tx = TxLegacy::arbitrary(u)?;
Self::Legacy(tx)
}
TxType::Eip2930 => {
let mut tx = TxEip2930::arbitrary(u)?;
tx.gas_limit = (tx.gas_limit as u64).into();
let tx = TxEip2930::arbitrary(u)?;
Self::Eip2930(tx)
}
TxType::Eip1559 => {
let mut tx = TxEip1559::arbitrary(u)?;
tx.gas_limit = (tx.gas_limit as u64).into();
let tx = TxEip1559::arbitrary(u)?;
Self::Eip1559(tx)
}
TxType::Eip4844 => {
let mut tx = TxEip4844::arbitrary(u)?;
tx.gas_limit = (tx.gas_limit as u64).into();
let tx = TxEip4844::arbitrary(u)?;
Self::Eip4844(tx)
}
TxType::Eip7702 => {
let mut tx = TxEip7702::arbitrary(u)?;
tx.gas_limit = (tx.gas_limit as u64).into();
let tx = TxEip7702::arbitrary(u)?;
Self::Eip7702(tx)
}
#[cfg(feature = "optimism")]
TxType::Deposit => {
let mut tx = TxDeposit::arbitrary(u)?;
tx.gas_limit = (tx.gas_limit as u64).into();
let tx = TxDeposit::arbitrary(u)?;
Self::Deposit(tx)
}
};
@ -320,9 +314,9 @@ impl Transaction {
Self::Eip1559(TxEip1559 { gas_limit, .. }) |
Self::Eip4844(TxEip4844 { gas_limit, .. }) |
Self::Eip7702(TxEip7702 { gas_limit, .. }) |
Self::Eip2930(TxEip2930 { gas_limit, .. }) => *gas_limit as u64,
Self::Eip2930(TxEip2930 { gas_limit, .. }) => *gas_limit,
#[cfg(feature = "optimism")]
Self::Deposit(TxDeposit { gas_limit, .. }) => *gas_limit as u64,
Self::Deposit(TxDeposit { gas_limit, .. }) => *gas_limit,
}
}
@ -560,13 +554,13 @@ impl Transaction {
/// This sets the transaction's gas limit.
pub fn set_gas_limit(&mut self, gas_limit: u64) {
match self {
Self::Legacy(tx) => tx.gas_limit = gas_limit.into(),
Self::Eip2930(tx) => tx.gas_limit = gas_limit.into(),
Self::Eip1559(tx) => tx.gas_limit = gas_limit.into(),
Self::Eip4844(tx) => tx.gas_limit = gas_limit.into(),
Self::Eip7702(tx) => tx.gas_limit = gas_limit.into(),
Self::Legacy(tx) => tx.gas_limit = gas_limit,
Self::Eip2930(tx) => tx.gas_limit = gas_limit,
Self::Eip1559(tx) => tx.gas_limit = gas_limit,
Self::Eip4844(tx) => tx.gas_limit = gas_limit,
Self::Eip7702(tx) => tx.gas_limit = gas_limit,
#[cfg(feature = "optimism")]
Self::Deposit(tx) => tx.gas_limit = gas_limit.into(),
Self::Deposit(tx) => tx.gas_limit = gas_limit,
}
}
@ -1865,7 +1859,7 @@ mod tests {
nonce: 26,
max_priority_fee_per_gas: 1500000000,
max_fee_per_gas: 1500000013,
gas_limit: MIN_TRANSACTION_GAS as u128,
gas_limit: MIN_TRANSACTION_GAS,
to: Address::from_slice(&hex!("61815774383099e24810ab832a5b2a5425c154d5")[..]).into(),
value: U256::from(3000000000000000000u64),
input: Default::default(),