mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
Rename TxType variants to UpperCamelCase (#7012)
This commit is contained in:
@ -45,7 +45,7 @@ mod tests {
|
|||||||
fn roundtrip_eip1559() {
|
fn roundtrip_eip1559() {
|
||||||
let receipts = Receipts(vec![vec![ReceiptWithBloom {
|
let receipts = Receipts(vec![vec![ReceiptWithBloom {
|
||||||
receipt: Receipt {
|
receipt: Receipt {
|
||||||
tx_type: TxType::EIP1559,
|
tx_type: TxType::Eip1559,
|
||||||
success: false,
|
success: false,
|
||||||
cumulative_gas_used: 0,
|
cumulative_gas_used: 0,
|
||||||
logs: vec![],
|
logs: vec![],
|
||||||
|
|||||||
@ -335,17 +335,17 @@ impl TxTypesCounter {
|
|||||||
TxType::Legacy => {
|
TxType::Legacy => {
|
||||||
self.legacy += 1;
|
self.legacy += 1;
|
||||||
}
|
}
|
||||||
TxType::EIP2930 => {
|
TxType::Eip2930 => {
|
||||||
self.eip2930 += 1;
|
self.eip2930 += 1;
|
||||||
}
|
}
|
||||||
TxType::EIP1559 => {
|
TxType::Eip1559 => {
|
||||||
self.eip1559 += 1;
|
self.eip1559 += 1;
|
||||||
}
|
}
|
||||||
TxType::EIP4844 => {
|
TxType::Eip4844 => {
|
||||||
self.eip4844 += 1;
|
self.eip4844 += 1;
|
||||||
}
|
}
|
||||||
#[cfg(feature = "optimism")]
|
#[cfg(feature = "optimism")]
|
||||||
TxType::DEPOSIT => {}
|
TxType::Deposit => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -245,10 +245,10 @@ impl ValidateTx68 for EthMessageFilter {
|
|||||||
// the biggest transaction so far is a blob transaction, which is currently max 2^17,
|
// the biggest transaction so far is a blob transaction, which is currently max 2^17,
|
||||||
// encoded length, nonetheless, the blob tx may become bigger in the future.
|
// encoded length, nonetheless, the blob tx may become bigger in the future.
|
||||||
match ty {
|
match ty {
|
||||||
TxType::Legacy | TxType::EIP2930 | TxType::EIP1559 => Some(MAX_MESSAGE_SIZE),
|
TxType::Legacy | TxType::Eip2930 | TxType::Eip1559 => Some(MAX_MESSAGE_SIZE),
|
||||||
TxType::EIP4844 => None,
|
TxType::Eip4844 => None,
|
||||||
#[cfg(feature = "optimism")]
|
#[cfg(feature = "optimism")]
|
||||||
TxType::DEPOSIT => None,
|
TxType::Deposit => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -393,7 +393,7 @@ mod test {
|
|||||||
#[test]
|
#[test]
|
||||||
fn eth68_announcement_too_small_tx() {
|
fn eth68_announcement_too_small_tx() {
|
||||||
let types =
|
let types =
|
||||||
vec![TxType::MAX_RESERVED_EIP as u8, TxType::Legacy as u8, TxType::EIP2930 as u8];
|
vec![TxType::MAX_RESERVED_EIP as u8, TxType::Legacy as u8, TxType::Eip2930 as u8];
|
||||||
let sizes = vec![
|
let sizes = vec![
|
||||||
0, // the first length isn't valid
|
0, // the first length isn't valid
|
||||||
0, // neither is the second
|
0, // neither is the second
|
||||||
@ -433,10 +433,10 @@ mod test {
|
|||||||
#[test]
|
#[test]
|
||||||
fn eth68_announcement_duplicate_tx_hash() {
|
fn eth68_announcement_duplicate_tx_hash() {
|
||||||
let types = vec![
|
let types = vec![
|
||||||
TxType::EIP1559 as u8,
|
TxType::Eip1559 as u8,
|
||||||
TxType::EIP4844 as u8,
|
TxType::Eip4844 as u8,
|
||||||
TxType::EIP1559 as u8,
|
TxType::Eip1559 as u8,
|
||||||
TxType::EIP4844 as u8,
|
TxType::Eip4844 as u8,
|
||||||
];
|
];
|
||||||
let sizes = vec![1, 1, 1, MAX_MESSAGE_SIZE];
|
let sizes = vec![1, 1, 1, MAX_MESSAGE_SIZE];
|
||||||
// first three or the same
|
// first three or the same
|
||||||
|
|||||||
@ -326,7 +326,7 @@ mod builder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// A sequencer's block should never contain blob transactions.
|
// A sequencer's block should never contain blob transactions.
|
||||||
if matches!(sequencer_tx.tx_type(), TxType::EIP4844) {
|
if matches!(sequencer_tx.tx_type(), TxType::Eip4844) {
|
||||||
return Err(PayloadBuilderError::other(
|
return Err(PayloadBuilderError::other(
|
||||||
OptimismPayloadBuilderError::BlobTransactionRejected,
|
OptimismPayloadBuilderError::BlobTransactionRejected,
|
||||||
))
|
))
|
||||||
@ -426,7 +426,7 @@ mod builder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// A sequencer's block should never contain blob transactions.
|
// A sequencer's block should never contain blob transactions.
|
||||||
if pool_tx.tx_type() == TxType::EIP4844 as u8 {
|
if pool_tx.tx_type() == TxType::Eip4844 as u8 {
|
||||||
return Err(PayloadBuilderError::other(
|
return Err(PayloadBuilderError::other(
|
||||||
OptimismPayloadBuilderError::BlobTransactionRejected,
|
OptimismPayloadBuilderError::BlobTransactionRejected,
|
||||||
))
|
))
|
||||||
|
|||||||
@ -318,7 +318,7 @@ mod tests {
|
|||||||
// 0xb0d6ee650637911394396d81172bd1c637d568ed1fbddab0daddfca399c58b53
|
// 0xb0d6ee650637911394396d81172bd1c637d568ed1fbddab0daddfca399c58b53
|
||||||
ReceiptWithBloom {
|
ReceiptWithBloom {
|
||||||
receipt: Receipt {
|
receipt: Receipt {
|
||||||
tx_type: TxType::DEPOSIT,
|
tx_type: TxType::Deposit,
|
||||||
success: true,
|
success: true,
|
||||||
cumulative_gas_used: 46913,
|
cumulative_gas_used: 46913,
|
||||||
logs: vec![],
|
logs: vec![],
|
||||||
@ -332,7 +332,7 @@ mod tests {
|
|||||||
// 0x2f433586bae30573c393adfa02bc81d2a1888a3d6c9869f473fb57245166bd9a
|
// 0x2f433586bae30573c393adfa02bc81d2a1888a3d6c9869f473fb57245166bd9a
|
||||||
ReceiptWithBloom {
|
ReceiptWithBloom {
|
||||||
receipt: Receipt {
|
receipt: Receipt {
|
||||||
tx_type: TxType::EIP1559,
|
tx_type: TxType::Eip1559,
|
||||||
success: true,
|
success: true,
|
||||||
cumulative_gas_used: 118083,
|
cumulative_gas_used: 118083,
|
||||||
logs: vec![
|
logs: vec![
|
||||||
@ -376,7 +376,7 @@ mod tests {
|
|||||||
// 0x6c33676e8f6077f46a62eabab70bc6d1b1b18a624b0739086d77093a1ecf8266
|
// 0x6c33676e8f6077f46a62eabab70bc6d1b1b18a624b0739086d77093a1ecf8266
|
||||||
ReceiptWithBloom {
|
ReceiptWithBloom {
|
||||||
receipt: Receipt {
|
receipt: Receipt {
|
||||||
tx_type: TxType::EIP1559,
|
tx_type: TxType::Eip1559,
|
||||||
success: true,
|
success: true,
|
||||||
cumulative_gas_used: 189253,
|
cumulative_gas_used: 189253,
|
||||||
logs: vec![
|
logs: vec![
|
||||||
@ -420,7 +420,7 @@ mod tests {
|
|||||||
// 0x4d3ecbef04ba7ce7f5ab55be0c61978ca97c117d7da448ed9771d4ff0c720a3f
|
// 0x4d3ecbef04ba7ce7f5ab55be0c61978ca97c117d7da448ed9771d4ff0c720a3f
|
||||||
ReceiptWithBloom {
|
ReceiptWithBloom {
|
||||||
receipt: Receipt {
|
receipt: Receipt {
|
||||||
tx_type: TxType::EIP1559,
|
tx_type: TxType::Eip1559,
|
||||||
success: true,
|
success: true,
|
||||||
cumulative_gas_used: 346969,
|
cumulative_gas_used: 346969,
|
||||||
logs: vec![
|
logs: vec![
|
||||||
@ -494,7 +494,7 @@ mod tests {
|
|||||||
// 0xf738af5eb00ba23dbc1be2dbce41dbc0180f0085b7fb46646e90bf737af90351
|
// 0xf738af5eb00ba23dbc1be2dbce41dbc0180f0085b7fb46646e90bf737af90351
|
||||||
ReceiptWithBloom {
|
ReceiptWithBloom {
|
||||||
receipt: Receipt {
|
receipt: Receipt {
|
||||||
tx_type: TxType::EIP1559,
|
tx_type: TxType::Eip1559,
|
||||||
success: true,
|
success: true,
|
||||||
cumulative_gas_used: 623249,
|
cumulative_gas_used: 623249,
|
||||||
logs: vec![
|
logs: vec![
|
||||||
@ -548,7 +548,7 @@ mod tests {
|
|||||||
let bloom = bloom!("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001");
|
let bloom = bloom!("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001");
|
||||||
let receipt = ReceiptWithBloom {
|
let receipt = ReceiptWithBloom {
|
||||||
receipt: Receipt {
|
receipt: Receipt {
|
||||||
tx_type: TxType::EIP2930,
|
tx_type: TxType::Eip2930,
|
||||||
success: true,
|
success: true,
|
||||||
cumulative_gas_used: 102068,
|
cumulative_gas_used: 102068,
|
||||||
logs,
|
logs,
|
||||||
@ -569,7 +569,7 @@ mod tests {
|
|||||||
let bloom = bloom!("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001");
|
let bloom = bloom!("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001");
|
||||||
let receipt = ReceiptWithBloom {
|
let receipt = ReceiptWithBloom {
|
||||||
receipt: Receipt {
|
receipt: Receipt {
|
||||||
tx_type: TxType::EIP2930,
|
tx_type: TxType::Eip2930,
|
||||||
success: true,
|
success: true,
|
||||||
cumulative_gas_used: 102068,
|
cumulative_gas_used: 102068,
|
||||||
logs,
|
logs,
|
||||||
|
|||||||
@ -214,7 +214,7 @@ impl proptest::arbitrary::Arbitrary for Receipt {
|
|||||||
{
|
{
|
||||||
// Only receipts for deposit transactions may contain a deposit nonce
|
// Only receipts for deposit transactions may contain a deposit nonce
|
||||||
#[cfg(feature = "optimism")]
|
#[cfg(feature = "optimism")]
|
||||||
let (deposit_nonce, deposit_receipt_version) = if tx_type == TxType::DEPOSIT {
|
let (deposit_nonce, deposit_receipt_version) = if tx_type == TxType::Deposit {
|
||||||
// The deposit receipt version is only present if the deposit nonce is present
|
// The deposit receipt version is only present if the deposit nonce is present
|
||||||
let deposit_receipt_version = _deposit_nonce.and(_deposit_receipt_version);
|
let deposit_receipt_version = _deposit_nonce.and(_deposit_receipt_version);
|
||||||
(_deposit_nonce, deposit_receipt_version)
|
(_deposit_nonce, deposit_receipt_version)
|
||||||
@ -251,7 +251,7 @@ impl<'a> arbitrary::Arbitrary<'a> for Receipt {
|
|||||||
|
|
||||||
// Only receipts for deposit transactions may contain a deposit nonce
|
// Only receipts for deposit transactions may contain a deposit nonce
|
||||||
#[cfg(feature = "optimism")]
|
#[cfg(feature = "optimism")]
|
||||||
let (deposit_nonce, deposit_receipt_version) = if tx_type == TxType::DEPOSIT {
|
let (deposit_nonce, deposit_receipt_version) = if tx_type == TxType::Deposit {
|
||||||
let deposit_nonce = Option::<u64>::arbitrary(u)?;
|
let deposit_nonce = Option::<u64>::arbitrary(u)?;
|
||||||
let deposit_nonce_version =
|
let deposit_nonce_version =
|
||||||
deposit_nonce.map(|_| Option::<u64>::arbitrary(u)).transpose()?.flatten();
|
deposit_nonce.map(|_| Option::<u64>::arbitrary(u)).transpose()?.flatten();
|
||||||
@ -295,7 +295,7 @@ impl ReceiptWithBloom {
|
|||||||
|
|
||||||
let receipt = match tx_type {
|
let receipt = match tx_type {
|
||||||
#[cfg(feature = "optimism")]
|
#[cfg(feature = "optimism")]
|
||||||
TxType::DEPOSIT => {
|
TxType::Deposit => {
|
||||||
let remaining = |b: &[u8]| rlp_head.payload_length - (started_len - b.len()) > 0;
|
let remaining = |b: &[u8]| rlp_head.payload_length - (started_len - b.len()) > 0;
|
||||||
let deposit_nonce =
|
let deposit_nonce =
|
||||||
remaining(b).then(|| alloy_rlp::Decodable::decode(b)).transpose()?;
|
remaining(b).then(|| alloy_rlp::Decodable::decode(b)).transpose()?;
|
||||||
@ -364,20 +364,20 @@ impl Decodable for ReceiptWithBloom {
|
|||||||
match receipt_type {
|
match receipt_type {
|
||||||
0x01 => {
|
0x01 => {
|
||||||
buf.advance(1);
|
buf.advance(1);
|
||||||
Self::decode_receipt(buf, TxType::EIP2930)
|
Self::decode_receipt(buf, TxType::Eip2930)
|
||||||
}
|
}
|
||||||
0x02 => {
|
0x02 => {
|
||||||
buf.advance(1);
|
buf.advance(1);
|
||||||
Self::decode_receipt(buf, TxType::EIP1559)
|
Self::decode_receipt(buf, TxType::Eip1559)
|
||||||
}
|
}
|
||||||
0x03 => {
|
0x03 => {
|
||||||
buf.advance(1);
|
buf.advance(1);
|
||||||
Self::decode_receipt(buf, TxType::EIP4844)
|
Self::decode_receipt(buf, TxType::Eip4844)
|
||||||
}
|
}
|
||||||
#[cfg(feature = "optimism")]
|
#[cfg(feature = "optimism")]
|
||||||
0x7E => {
|
0x7E => {
|
||||||
buf.advance(1);
|
buf.advance(1);
|
||||||
Self::decode_receipt(buf, TxType::DEPOSIT)
|
Self::decode_receipt(buf, TxType::Deposit)
|
||||||
}
|
}
|
||||||
_ => Err(alloy_rlp::Error::Custom("invalid receipt type")),
|
_ => Err(alloy_rlp::Error::Custom("invalid receipt type")),
|
||||||
}
|
}
|
||||||
@ -448,7 +448,7 @@ impl<'a> ReceiptWithBloomEncoder<'a> {
|
|||||||
rlp_head.payload_length += self.receipt.logs.length();
|
rlp_head.payload_length += self.receipt.logs.length();
|
||||||
|
|
||||||
#[cfg(feature = "optimism")]
|
#[cfg(feature = "optimism")]
|
||||||
if self.receipt.tx_type == TxType::DEPOSIT {
|
if self.receipt.tx_type == TxType::Deposit {
|
||||||
if let Some(deposit_nonce) = self.receipt.deposit_nonce {
|
if let Some(deposit_nonce) = self.receipt.deposit_nonce {
|
||||||
rlp_head.payload_length += deposit_nonce.length();
|
rlp_head.payload_length += deposit_nonce.length();
|
||||||
}
|
}
|
||||||
@ -468,7 +468,7 @@ impl<'a> ReceiptWithBloomEncoder<'a> {
|
|||||||
self.bloom.encode(out);
|
self.bloom.encode(out);
|
||||||
self.receipt.logs.encode(out);
|
self.receipt.logs.encode(out);
|
||||||
#[cfg(feature = "optimism")]
|
#[cfg(feature = "optimism")]
|
||||||
if self.receipt.tx_type == TxType::DEPOSIT {
|
if self.receipt.tx_type == TxType::Deposit {
|
||||||
if let Some(deposit_nonce) = self.receipt.deposit_nonce {
|
if let Some(deposit_nonce) = self.receipt.deposit_nonce {
|
||||||
deposit_nonce.encode(out)
|
deposit_nonce.encode(out)
|
||||||
}
|
}
|
||||||
@ -497,17 +497,17 @@ impl<'a> ReceiptWithBloomEncoder<'a> {
|
|||||||
match self.receipt.tx_type {
|
match self.receipt.tx_type {
|
||||||
TxType::Legacy => unreachable!("legacy already handled"),
|
TxType::Legacy => unreachable!("legacy already handled"),
|
||||||
|
|
||||||
TxType::EIP2930 => {
|
TxType::Eip2930 => {
|
||||||
out.put_u8(0x01);
|
out.put_u8(0x01);
|
||||||
}
|
}
|
||||||
TxType::EIP1559 => {
|
TxType::Eip1559 => {
|
||||||
out.put_u8(0x02);
|
out.put_u8(0x02);
|
||||||
}
|
}
|
||||||
TxType::EIP4844 => {
|
TxType::Eip4844 => {
|
||||||
out.put_u8(0x03);
|
out.put_u8(0x03);
|
||||||
}
|
}
|
||||||
#[cfg(feature = "optimism")]
|
#[cfg(feature = "optimism")]
|
||||||
TxType::DEPOSIT => {
|
TxType::Deposit => {
|
||||||
out.put_u8(0x7E);
|
out.put_u8(0x7E);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -617,7 +617,7 @@ mod tests {
|
|||||||
// Deposit Receipt (post-regolith)
|
// Deposit Receipt (post-regolith)
|
||||||
let expected = ReceiptWithBloom {
|
let expected = ReceiptWithBloom {
|
||||||
receipt: Receipt {
|
receipt: Receipt {
|
||||||
tx_type: TxType::DEPOSIT,
|
tx_type: TxType::Deposit,
|
||||||
cumulative_gas_used: 46913,
|
cumulative_gas_used: 46913,
|
||||||
logs: vec![],
|
logs: vec![],
|
||||||
success: true,
|
success: true,
|
||||||
@ -643,7 +643,7 @@ mod tests {
|
|||||||
// Deposit Receipt (post-regolith)
|
// Deposit Receipt (post-regolith)
|
||||||
let expected = ReceiptWithBloom {
|
let expected = ReceiptWithBloom {
|
||||||
receipt: Receipt {
|
receipt: Receipt {
|
||||||
tx_type: TxType::DEPOSIT,
|
tx_type: TxType::Deposit,
|
||||||
cumulative_gas_used: 46913,
|
cumulative_gas_used: 46913,
|
||||||
logs: vec![],
|
logs: vec![],
|
||||||
success: true,
|
success: true,
|
||||||
|
|||||||
@ -176,7 +176,7 @@ impl TxEip1559 {
|
|||||||
|
|
||||||
/// Get transaction type
|
/// Get transaction type
|
||||||
pub(crate) fn tx_type(&self) -> TxType {
|
pub(crate) fn tx_type(&self) -> TxType {
|
||||||
TxType::EIP1559
|
TxType::Eip1559
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Calculates a heuristic for the in-memory size of the [TxEip1559] transaction.
|
/// Calculates a heuristic for the in-memory size of the [TxEip1559] transaction.
|
||||||
|
|||||||
@ -154,7 +154,7 @@ impl TxEip2930 {
|
|||||||
|
|
||||||
/// Get transaction type
|
/// Get transaction type
|
||||||
pub(crate) fn tx_type(&self) -> TxType {
|
pub(crate) fn tx_type(&self) -> TxType {
|
||||||
TxType::EIP2930
|
TxType::Eip2930
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Encodes the legacy transaction in RLP for signing.
|
/// Encodes the legacy transaction in RLP for signing.
|
||||||
|
|||||||
@ -289,7 +289,7 @@ impl TxEip4844 {
|
|||||||
|
|
||||||
/// Get transaction type
|
/// Get transaction type
|
||||||
pub(crate) fn tx_type(&self) -> TxType {
|
pub(crate) fn tx_type(&self) -> TxType {
|
||||||
TxType::EIP4844
|
TxType::Eip4844
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Encodes the legacy transaction in RLP for signing.
|
/// Encodes the legacy transaction in RLP for signing.
|
||||||
|
|||||||
@ -1266,11 +1266,11 @@ impl TransactionSigned {
|
|||||||
return Err(RlpError::Custom("unsupported typed transaction type"))
|
return Err(RlpError::Custom("unsupported typed transaction type"))
|
||||||
};
|
};
|
||||||
let transaction = match tx_type {
|
let transaction = match tx_type {
|
||||||
TxType::EIP2930 => Transaction::Eip2930(TxEip2930::decode_inner(data)?),
|
TxType::Eip2930 => Transaction::Eip2930(TxEip2930::decode_inner(data)?),
|
||||||
TxType::EIP1559 => Transaction::Eip1559(TxEip1559::decode_inner(data)?),
|
TxType::Eip1559 => Transaction::Eip1559(TxEip1559::decode_inner(data)?),
|
||||||
TxType::EIP4844 => Transaction::Eip4844(TxEip4844::decode_inner(data)?),
|
TxType::Eip4844 => Transaction::Eip4844(TxEip4844::decode_inner(data)?),
|
||||||
#[cfg(feature = "optimism")]
|
#[cfg(feature = "optimism")]
|
||||||
TxType::DEPOSIT => Transaction::Deposit(TxDeposit::decode_inner(data)?),
|
TxType::Deposit => Transaction::Deposit(TxDeposit::decode_inner(data)?),
|
||||||
TxType::Legacy => unreachable!("path for legacy tx has diverged before this method"),
|
TxType::Legacy => unreachable!("path for legacy tx has diverged before this method"),
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1278,7 +1278,7 @@ impl TransactionSigned {
|
|||||||
let signature = Signature::decode(data)?;
|
let signature = Signature::decode(data)?;
|
||||||
|
|
||||||
#[cfg(feature = "optimism")]
|
#[cfg(feature = "optimism")]
|
||||||
let signature = if let TxType::DEPOSIT = tx_type {
|
let signature = if let TxType::Deposit = tx_type {
|
||||||
Signature::optimism_deposit_tx_signature()
|
Signature::optimism_deposit_tx_signature()
|
||||||
} else {
|
} else {
|
||||||
Signature::decode(data)?
|
Signature::decode(data)?
|
||||||
@ -1664,7 +1664,7 @@ mod tests {
|
|||||||
// https://sepolia.etherscan.io/getRawTx?tx=0x9a22ccb0029bc8b0ddd073be1a1d923b7ae2b2ea52100bae0db4424f9107e9c0
|
// https://sepolia.etherscan.io/getRawTx?tx=0x9a22ccb0029bc8b0ddd073be1a1d923b7ae2b2ea52100bae0db4424f9107e9c0
|
||||||
let raw_tx = alloy_primitives::hex::decode("0x03f9011d83aa36a7820fa28477359400852e90edd0008252089411e9ca82a3a762b4b5bd264d4173a242e7a770648080c08504a817c800f8a5a0012ec3d6f66766bedb002a190126b3549fce0047de0d4c25cffce0dc1c57921aa00152d8e24762ff22b1cfd9f8c0683786a7ca63ba49973818b3d1e9512cd2cec4a0013b98c6c83e066d5b14af2b85199e3d4fc7d1e778dd53130d180f5077e2d1c7a001148b495d6e859114e670ca54fb6e2657f0cbae5b08063605093a4b3dc9f8f1a0011ac212f13c5dff2b2c6b600a79635103d6f580a4221079951181b25c7e654901a0c8de4cced43169f9aa3d36506363b2d2c44f6c49fc1fd91ea114c86f3757077ea01e11fdd0d1934eda0492606ee0bb80a7bf8f35cc5f86ec60fe5031ba48bfd544").unwrap();
|
let raw_tx = alloy_primitives::hex::decode("0x03f9011d83aa36a7820fa28477359400852e90edd0008252089411e9ca82a3a762b4b5bd264d4173a242e7a770648080c08504a817c800f8a5a0012ec3d6f66766bedb002a190126b3549fce0047de0d4c25cffce0dc1c57921aa00152d8e24762ff22b1cfd9f8c0683786a7ca63ba49973818b3d1e9512cd2cec4a0013b98c6c83e066d5b14af2b85199e3d4fc7d1e778dd53130d180f5077e2d1c7a001148b495d6e859114e670ca54fb6e2657f0cbae5b08063605093a4b3dc9f8f1a0011ac212f13c5dff2b2c6b600a79635103d6f580a4221079951181b25c7e654901a0c8de4cced43169f9aa3d36506363b2d2c44f6c49fc1fd91ea114c86f3757077ea01e11fdd0d1934eda0492606ee0bb80a7bf8f35cc5f86ec60fe5031ba48bfd544").unwrap();
|
||||||
let decoded = TransactionSigned::decode_enveloped(&mut raw_tx.as_slice()).unwrap();
|
let decoded = TransactionSigned::decode_enveloped(&mut raw_tx.as_slice()).unwrap();
|
||||||
assert_eq!(decoded.tx_type(), TxType::EIP4844);
|
assert_eq!(decoded.tx_type(), TxType::Eip4844);
|
||||||
|
|
||||||
let from = decoded.recover_signer();
|
let from = decoded.recover_signer();
|
||||||
assert_eq!(from, Some(address!("A83C816D4f9b2783761a22BA6FADB0eB0606D7B2")));
|
assert_eq!(from, Some(address!("A83C816D4f9b2783761a22BA6FADB0eB0606D7B2")));
|
||||||
|
|||||||
@ -138,7 +138,7 @@ impl TxDeposit {
|
|||||||
|
|
||||||
/// Get the transaction type
|
/// Get the transaction type
|
||||||
pub(crate) fn tx_type(&self) -> TxType {
|
pub(crate) fn tx_type(&self) -> TxType {
|
||||||
TxType::DEPOSIT
|
TxType::Deposit
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -36,27 +36,27 @@ pub enum TxType {
|
|||||||
#[default]
|
#[default]
|
||||||
Legacy = 0_isize,
|
Legacy = 0_isize,
|
||||||
/// AccessList transaction
|
/// AccessList transaction
|
||||||
EIP2930 = 1_isize,
|
Eip2930 = 1_isize,
|
||||||
/// Transaction with Priority fee
|
/// Transaction with Priority fee
|
||||||
EIP1559 = 2_isize,
|
Eip1559 = 2_isize,
|
||||||
/// Shard Blob Transactions - EIP-4844
|
/// Shard Blob Transactions - EIP-4844
|
||||||
EIP4844 = 3_isize,
|
Eip4844 = 3_isize,
|
||||||
/// Optimism Deposit transaction.
|
/// Optimism Deposit transaction.
|
||||||
#[cfg(feature = "optimism")]
|
#[cfg(feature = "optimism")]
|
||||||
DEPOSIT = 126_isize,
|
Deposit = 126_isize,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TxType {
|
impl TxType {
|
||||||
/// The max type reserved by an EIP.
|
/// The max type reserved by an EIP.
|
||||||
pub const MAX_RESERVED_EIP: TxType = Self::EIP4844;
|
pub const MAX_RESERVED_EIP: TxType = Self::Eip4844;
|
||||||
|
|
||||||
/// Check if the transaction type has an access list.
|
/// Check if the transaction type has an access list.
|
||||||
pub const fn has_access_list(&self) -> bool {
|
pub const fn has_access_list(&self) -> bool {
|
||||||
match self {
|
match self {
|
||||||
TxType::Legacy => false,
|
TxType::Legacy => false,
|
||||||
TxType::EIP2930 | TxType::EIP1559 | TxType::EIP4844 => true,
|
TxType::Eip2930 | TxType::Eip1559 | TxType::Eip4844 => true,
|
||||||
#[cfg(feature = "optimism")]
|
#[cfg(feature = "optimism")]
|
||||||
TxType::DEPOSIT => false,
|
TxType::Deposit => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -65,11 +65,11 @@ impl From<TxType> for u8 {
|
|||||||
fn from(value: TxType) -> Self {
|
fn from(value: TxType) -> Self {
|
||||||
match value {
|
match value {
|
||||||
TxType::Legacy => LEGACY_TX_TYPE_ID,
|
TxType::Legacy => LEGACY_TX_TYPE_ID,
|
||||||
TxType::EIP2930 => EIP2930_TX_TYPE_ID,
|
TxType::Eip2930 => EIP2930_TX_TYPE_ID,
|
||||||
TxType::EIP1559 => EIP1559_TX_TYPE_ID,
|
TxType::Eip1559 => EIP1559_TX_TYPE_ID,
|
||||||
TxType::EIP4844 => EIP4844_TX_TYPE_ID,
|
TxType::Eip4844 => EIP4844_TX_TYPE_ID,
|
||||||
#[cfg(feature = "optimism")]
|
#[cfg(feature = "optimism")]
|
||||||
TxType::DEPOSIT => DEPOSIT_TX_TYPE_ID,
|
TxType::Deposit => DEPOSIT_TX_TYPE_ID,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -85,18 +85,18 @@ impl TryFrom<u8> for TxType {
|
|||||||
|
|
||||||
fn try_from(value: u8) -> Result<Self, Self::Error> {
|
fn try_from(value: u8) -> Result<Self, Self::Error> {
|
||||||
#[cfg(feature = "optimism")]
|
#[cfg(feature = "optimism")]
|
||||||
if value == TxType::DEPOSIT as u8 {
|
if value == TxType::Deposit as u8 {
|
||||||
return Ok(TxType::DEPOSIT)
|
return Ok(TxType::Deposit)
|
||||||
}
|
}
|
||||||
|
|
||||||
if value == TxType::Legacy as u8 {
|
if value == TxType::Legacy as u8 {
|
||||||
return Ok(TxType::Legacy)
|
return Ok(TxType::Legacy)
|
||||||
} else if value == TxType::EIP2930 as u8 {
|
} else if value == TxType::Eip2930 as u8 {
|
||||||
return Ok(TxType::EIP2930)
|
return Ok(TxType::Eip2930)
|
||||||
} else if value == TxType::EIP1559 as u8 {
|
} else if value == TxType::Eip1559 as u8 {
|
||||||
return Ok(TxType::EIP1559)
|
return Ok(TxType::Eip1559)
|
||||||
} else if value == TxType::EIP4844 as u8 {
|
} else if value == TxType::Eip4844 as u8 {
|
||||||
return Ok(TxType::EIP4844)
|
return Ok(TxType::Eip4844)
|
||||||
}
|
}
|
||||||
|
|
||||||
Err("invalid tx type")
|
Err("invalid tx type")
|
||||||
@ -110,9 +110,9 @@ impl Compact for TxType {
|
|||||||
{
|
{
|
||||||
match self {
|
match self {
|
||||||
TxType::Legacy => 0,
|
TxType::Legacy => 0,
|
||||||
TxType::EIP2930 => 1,
|
TxType::Eip2930 => 1,
|
||||||
TxType::EIP1559 => 2,
|
TxType::Eip1559 => 2,
|
||||||
TxType::EIP4844 => {
|
TxType::Eip4844 => {
|
||||||
// Write the full transaction type to the buffer when encoding > 3.
|
// Write the full transaction type to the buffer when encoding > 3.
|
||||||
// This allows compat decoding the [TyType] from a single byte as
|
// This allows compat decoding the [TyType] from a single byte as
|
||||||
// opposed to 2 bits for the backwards-compatible encoding.
|
// opposed to 2 bits for the backwards-compatible encoding.
|
||||||
@ -120,7 +120,7 @@ impl Compact for TxType {
|
|||||||
3
|
3
|
||||||
}
|
}
|
||||||
#[cfg(feature = "optimism")]
|
#[cfg(feature = "optimism")]
|
||||||
TxType::DEPOSIT => {
|
TxType::Deposit => {
|
||||||
buf.put_u8(self as u8);
|
buf.put_u8(self as u8);
|
||||||
3
|
3
|
||||||
}
|
}
|
||||||
@ -134,14 +134,14 @@ impl Compact for TxType {
|
|||||||
(
|
(
|
||||||
match identifier {
|
match identifier {
|
||||||
0 => TxType::Legacy,
|
0 => TxType::Legacy,
|
||||||
1 => TxType::EIP2930,
|
1 => TxType::Eip2930,
|
||||||
2 => TxType::EIP1559,
|
2 => TxType::Eip1559,
|
||||||
3 => {
|
3 => {
|
||||||
let extended_identifier = buf.get_u8();
|
let extended_identifier = buf.get_u8();
|
||||||
match extended_identifier {
|
match extended_identifier {
|
||||||
EIP4844_TX_TYPE_ID => TxType::EIP4844,
|
EIP4844_TX_TYPE_ID => TxType::Eip4844,
|
||||||
#[cfg(feature = "optimism")]
|
#[cfg(feature = "optimism")]
|
||||||
DEPOSIT_TX_TYPE_ID => TxType::DEPOSIT,
|
DEPOSIT_TX_TYPE_ID => TxType::Deposit,
|
||||||
_ => panic!("Unsupported TxType identifier: {}", extended_identifier),
|
_ => panic!("Unsupported TxType identifier: {}", extended_identifier),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -160,11 +160,11 @@ mod tests {
|
|||||||
fn test_txtype_to_compat() {
|
fn test_txtype_to_compat() {
|
||||||
let cases = vec![
|
let cases = vec![
|
||||||
(TxType::Legacy, 0, vec![]),
|
(TxType::Legacy, 0, vec![]),
|
||||||
(TxType::EIP2930, 1, vec![]),
|
(TxType::Eip2930, 1, vec![]),
|
||||||
(TxType::EIP1559, 2, vec![]),
|
(TxType::Eip1559, 2, vec![]),
|
||||||
(TxType::EIP4844, 3, vec![EIP4844_TX_TYPE_ID]),
|
(TxType::Eip4844, 3, vec![EIP4844_TX_TYPE_ID]),
|
||||||
#[cfg(feature = "optimism")]
|
#[cfg(feature = "optimism")]
|
||||||
(TxType::DEPOSIT, 3, vec![DEPOSIT_TX_TYPE_ID]),
|
(TxType::Deposit, 3, vec![DEPOSIT_TX_TYPE_ID]),
|
||||||
];
|
];
|
||||||
|
|
||||||
for (tx_type, expected_identifier, expected_buf) in cases {
|
for (tx_type, expected_identifier, expected_buf) in cases {
|
||||||
@ -183,11 +183,11 @@ mod tests {
|
|||||||
fn test_txtype_from_compact() {
|
fn test_txtype_from_compact() {
|
||||||
let cases = vec![
|
let cases = vec![
|
||||||
(TxType::Legacy, 0, vec![]),
|
(TxType::Legacy, 0, vec![]),
|
||||||
(TxType::EIP2930, 1, vec![]),
|
(TxType::Eip2930, 1, vec![]),
|
||||||
(TxType::EIP1559, 2, vec![]),
|
(TxType::Eip1559, 2, vec![]),
|
||||||
(TxType::EIP4844, 3, vec![EIP4844_TX_TYPE_ID]),
|
(TxType::Eip4844, 3, vec![EIP4844_TX_TYPE_ID]),
|
||||||
#[cfg(feature = "optimism")]
|
#[cfg(feature = "optimism")]
|
||||||
(TxType::DEPOSIT, 3, vec![DEPOSIT_TX_TYPE_ID]),
|
(TxType::Deposit, 3, vec![DEPOSIT_TX_TYPE_ID]),
|
||||||
];
|
];
|
||||||
|
|
||||||
for (expected_type, identifier, buf) in cases {
|
for (expected_type, identifier, buf) in cases {
|
||||||
|
|||||||
@ -127,7 +127,7 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
// An optimism block should never contain blob transactions.
|
// An optimism block should never contain blob transactions.
|
||||||
if matches!(transaction.tx_type(), TxType::EIP4844) {
|
if matches!(transaction.tx_type(), TxType::Eip4844) {
|
||||||
return Err(BlockExecutionError::OptimismBlockExecution(
|
return Err(BlockExecutionError::OptimismBlockExecution(
|
||||||
OptimismBlockExecutionError::BlobTransactionRejected,
|
OptimismBlockExecutionError::BlobTransactionRejected,
|
||||||
))
|
))
|
||||||
|
|||||||
@ -54,8 +54,8 @@ fn fill(
|
|||||||
|
|
||||||
let (gas_price, max_fee_per_gas) = match signed_tx.tx_type() {
|
let (gas_price, max_fee_per_gas) = match signed_tx.tx_type() {
|
||||||
TxType::Legacy => (Some(U128::from(signed_tx.max_fee_per_gas())), None),
|
TxType::Legacy => (Some(U128::from(signed_tx.max_fee_per_gas())), None),
|
||||||
TxType::EIP2930 => (Some(U128::from(signed_tx.max_fee_per_gas())), None),
|
TxType::Eip2930 => (Some(U128::from(signed_tx.max_fee_per_gas())), None),
|
||||||
TxType::EIP1559 | TxType::EIP4844 => {
|
TxType::Eip1559 | TxType::Eip4844 => {
|
||||||
// the gas price field for EIP1559 is set to `min(tip, gasFeeCap - baseFee) +
|
// the gas price field for EIP1559 is set to `min(tip, gasFeeCap - baseFee) +
|
||||||
// baseFee`
|
// baseFee`
|
||||||
let gas_price = base_fee
|
let gas_price = base_fee
|
||||||
@ -69,7 +69,7 @@ fn fill(
|
|||||||
(Some(U128::from(gas_price)), Some(U128::from(signed_tx.max_fee_per_gas())))
|
(Some(U128::from(gas_price)), Some(U128::from(signed_tx.max_fee_per_gas())))
|
||||||
}
|
}
|
||||||
#[cfg(feature = "optimism")]
|
#[cfg(feature = "optimism")]
|
||||||
TxType::DEPOSIT => (None, None),
|
TxType::Deposit => (None, None),
|
||||||
};
|
};
|
||||||
|
|
||||||
let chain_id = signed_tx.chain_id().map(U64::from);
|
let chain_id = signed_tx.chain_id().map(U64::from);
|
||||||
|
|||||||
@ -147,7 +147,7 @@ fn block1(number: BlockNumber) -> (SealedBlockWithSenders, BundleStateWithReceip
|
|||||||
.state_storage(account1, HashMap::from([(slot, (U256::ZERO, U256::from(10)))]))
|
.state_storage(account1, HashMap::from([(slot, (U256::ZERO, U256::from(10)))]))
|
||||||
.build(),
|
.build(),
|
||||||
Receipts::from_vec(vec![vec![Some(Receipt {
|
Receipts::from_vec(vec![vec![Some(Receipt {
|
||||||
tx_type: TxType::EIP2930,
|
tx_type: TxType::Eip2930,
|
||||||
success: true,
|
success: true,
|
||||||
cumulative_gas_used: 300,
|
cumulative_gas_used: 300,
|
||||||
logs: vec![Log {
|
logs: vec![Log {
|
||||||
@ -205,7 +205,7 @@ fn block2(
|
|||||||
.revert_storage(number, account, Vec::from([(slot, U256::from(10))]))
|
.revert_storage(number, account, Vec::from([(slot, U256::from(10))]))
|
||||||
.build(),
|
.build(),
|
||||||
Receipts::from_vec(vec![vec![Some(Receipt {
|
Receipts::from_vec(vec![vec![Some(Receipt {
|
||||||
tx_type: TxType::EIP1559,
|
tx_type: TxType::Eip1559,
|
||||||
success: false,
|
success: false,
|
||||||
cumulative_gas_used: 400,
|
cumulative_gas_used: 400,
|
||||||
logs: vec![Log {
|
logs: vec![Log {
|
||||||
@ -271,7 +271,7 @@ fn block3(
|
|||||||
let bundle = BundleStateWithReceipts::new(
|
let bundle = BundleStateWithReceipts::new(
|
||||||
bundle_state_builder.build(),
|
bundle_state_builder.build(),
|
||||||
Receipts::from_vec(vec![vec![Some(Receipt {
|
Receipts::from_vec(vec![vec![Some(Receipt {
|
||||||
tx_type: TxType::EIP1559,
|
tx_type: TxType::Eip1559,
|
||||||
success: true,
|
success: true,
|
||||||
cumulative_gas_used: 400,
|
cumulative_gas_used: 400,
|
||||||
logs: vec![Log {
|
logs: vec![Log {
|
||||||
@ -360,7 +360,7 @@ fn block4(
|
|||||||
let bundle = BundleStateWithReceipts::new(
|
let bundle = BundleStateWithReceipts::new(
|
||||||
bundle_state_builder.build(),
|
bundle_state_builder.build(),
|
||||||
Receipts::from_vec(vec![vec![Some(Receipt {
|
Receipts::from_vec(vec![vec![Some(Receipt {
|
||||||
tx_type: TxType::EIP1559,
|
tx_type: TxType::Eip1559,
|
||||||
success: true,
|
success: true,
|
||||||
cumulative_gas_used: 400,
|
cumulative_gas_used: 400,
|
||||||
logs: vec![Log {
|
logs: vec![Log {
|
||||||
@ -444,7 +444,7 @@ fn block5(
|
|||||||
let bundle = BundleStateWithReceipts::new(
|
let bundle = BundleStateWithReceipts::new(
|
||||||
bundle_state_builder.build(),
|
bundle_state_builder.build(),
|
||||||
Receipts::from_vec(vec![vec![Some(Receipt {
|
Receipts::from_vec(vec![vec![Some(Receipt {
|
||||||
tx_type: TxType::EIP1559,
|
tx_type: TxType::Eip1559,
|
||||||
success: true,
|
success: true,
|
||||||
cumulative_gas_used: 400,
|
cumulative_gas_used: 400,
|
||||||
logs: vec![Log {
|
logs: vec![Log {
|
||||||
|
|||||||
@ -591,17 +591,17 @@ mod tests {
|
|||||||
let d_sender = address!("000000000000000000000000000000000000000d");
|
let d_sender = address!("000000000000000000000000000000000000000d");
|
||||||
|
|
||||||
// create a chain of transactions by sender A, B, C
|
// create a chain of transactions by sender A, B, C
|
||||||
let mut tx_set = MockTransactionSet::dependent(a_sender, 0, 4, TxType::EIP1559);
|
let mut tx_set = MockTransactionSet::dependent(a_sender, 0, 4, TxType::Eip1559);
|
||||||
let a = tx_set.clone().into_vec();
|
let a = tx_set.clone().into_vec();
|
||||||
|
|
||||||
let b = MockTransactionSet::dependent(b_sender, 0, 3, TxType::EIP1559).into_vec();
|
let b = MockTransactionSet::dependent(b_sender, 0, 3, TxType::Eip1559).into_vec();
|
||||||
tx_set.extend(b.clone());
|
tx_set.extend(b.clone());
|
||||||
|
|
||||||
// C has the same number of txs as B
|
// C has the same number of txs as B
|
||||||
let c = MockTransactionSet::dependent(c_sender, 0, 3, TxType::EIP1559).into_vec();
|
let c = MockTransactionSet::dependent(c_sender, 0, 3, TxType::Eip1559).into_vec();
|
||||||
tx_set.extend(c.clone());
|
tx_set.extend(c.clone());
|
||||||
|
|
||||||
let d = MockTransactionSet::dependent(d_sender, 0, 1, TxType::EIP1559).into_vec();
|
let d = MockTransactionSet::dependent(d_sender, 0, 1, TxType::Eip1559).into_vec();
|
||||||
tx_set.extend(d.clone());
|
tx_set.extend(d.clone());
|
||||||
|
|
||||||
let all_txs = tx_set.into_vec();
|
let all_txs = tx_set.into_vec();
|
||||||
@ -665,7 +665,7 @@ mod tests {
|
|||||||
let a_sender = address!("000000000000000000000000000000000000000a");
|
let a_sender = address!("000000000000000000000000000000000000000a");
|
||||||
|
|
||||||
// 2 txs, that should put the pool over the size limit but not max txs
|
// 2 txs, that should put the pool over the size limit but not max txs
|
||||||
let a_txs = MockTransactionSet::dependent(a_sender, 0, 2, TxType::EIP1559)
|
let a_txs = MockTransactionSet::dependent(a_sender, 0, 2, TxType::Eip1559)
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|mut tx| {
|
.map(|mut tx| {
|
||||||
tx.set_size(default_limits.max_size / 2 + 1);
|
tx.set_size(default_limits.max_size / 2 + 1);
|
||||||
@ -696,19 +696,19 @@ mod tests {
|
|||||||
|
|
||||||
// create a chain of transactions by sender A, B, C
|
// create a chain of transactions by sender A, B, C
|
||||||
let mut tx_set =
|
let mut tx_set =
|
||||||
MockTransactionSet::dependent(a_sender, 0, 4, reth_primitives::TxType::EIP1559);
|
MockTransactionSet::dependent(a_sender, 0, 4, reth_primitives::TxType::Eip1559);
|
||||||
let a = tx_set.clone().into_vec();
|
let a = tx_set.clone().into_vec();
|
||||||
|
|
||||||
let b = MockTransactionSet::dependent(b_sender, 0, 3, reth_primitives::TxType::EIP1559)
|
let b = MockTransactionSet::dependent(b_sender, 0, 3, reth_primitives::TxType::Eip1559)
|
||||||
.into_vec();
|
.into_vec();
|
||||||
tx_set.extend(b.clone());
|
tx_set.extend(b.clone());
|
||||||
|
|
||||||
// C has the same number of txs as B
|
// C has the same number of txs as B
|
||||||
let c = MockTransactionSet::dependent(c_sender, 0, 3, reth_primitives::TxType::EIP1559)
|
let c = MockTransactionSet::dependent(c_sender, 0, 3, reth_primitives::TxType::Eip1559)
|
||||||
.into_vec();
|
.into_vec();
|
||||||
tx_set.extend(c.clone());
|
tx_set.extend(c.clone());
|
||||||
|
|
||||||
let d = MockTransactionSet::dependent(d_sender, 0, 1, reth_primitives::TxType::EIP1559)
|
let d = MockTransactionSet::dependent(d_sender, 0, 1, reth_primitives::TxType::Eip1559)
|
||||||
.into_vec();
|
.into_vec();
|
||||||
tx_set.extend(d.clone());
|
tx_set.extend(d.clone());
|
||||||
|
|
||||||
|
|||||||
@ -695,19 +695,19 @@ mod tests {
|
|||||||
|
|
||||||
// create a chain of transactions by sender A, B, C
|
// create a chain of transactions by sender A, B, C
|
||||||
let mut tx_set =
|
let mut tx_set =
|
||||||
MockTransactionSet::dependent(a_sender, 0, 4, reth_primitives::TxType::EIP1559);
|
MockTransactionSet::dependent(a_sender, 0, 4, reth_primitives::TxType::Eip1559);
|
||||||
let a = tx_set.clone().into_vec();
|
let a = tx_set.clone().into_vec();
|
||||||
|
|
||||||
let b = MockTransactionSet::dependent(b_sender, 0, 3, reth_primitives::TxType::EIP1559)
|
let b = MockTransactionSet::dependent(b_sender, 0, 3, reth_primitives::TxType::Eip1559)
|
||||||
.into_vec();
|
.into_vec();
|
||||||
tx_set.extend(b.clone());
|
tx_set.extend(b.clone());
|
||||||
|
|
||||||
// C has the same number of txs as B
|
// C has the same number of txs as B
|
||||||
let c = MockTransactionSet::dependent(c_sender, 0, 3, reth_primitives::TxType::EIP1559)
|
let c = MockTransactionSet::dependent(c_sender, 0, 3, reth_primitives::TxType::Eip1559)
|
||||||
.into_vec();
|
.into_vec();
|
||||||
tx_set.extend(c.clone());
|
tx_set.extend(c.clone());
|
||||||
|
|
||||||
let d = MockTransactionSet::dependent(d_sender, 0, 1, reth_primitives::TxType::EIP1559)
|
let d = MockTransactionSet::dependent(d_sender, 0, 1, reth_primitives::TxType::Eip1559)
|
||||||
.into_vec();
|
.into_vec();
|
||||||
tx_set.extend(d.clone());
|
tx_set.extend(d.clone());
|
||||||
|
|
||||||
@ -747,10 +747,10 @@ mod tests {
|
|||||||
let d = address!("000000000000000000000000000000000000000d");
|
let d = address!("000000000000000000000000000000000000000d");
|
||||||
|
|
||||||
// Create transaction chains for senders A, B, C, and D.
|
// Create transaction chains for senders A, B, C, and D.
|
||||||
let a_txs = MockTransactionSet::sequential_transactions_by_sender(a, 4, TxType::EIP1559);
|
let a_txs = MockTransactionSet::sequential_transactions_by_sender(a, 4, TxType::Eip1559);
|
||||||
let b_txs = MockTransactionSet::sequential_transactions_by_sender(b, 3, TxType::EIP1559);
|
let b_txs = MockTransactionSet::sequential_transactions_by_sender(b, 3, TxType::Eip1559);
|
||||||
let c_txs = MockTransactionSet::sequential_transactions_by_sender(c, 3, TxType::EIP1559);
|
let c_txs = MockTransactionSet::sequential_transactions_by_sender(c, 3, TxType::Eip1559);
|
||||||
let d_txs = MockTransactionSet::sequential_transactions_by_sender(d, 1, TxType::EIP1559);
|
let d_txs = MockTransactionSet::sequential_transactions_by_sender(d, 1, TxType::Eip1559);
|
||||||
|
|
||||||
// Set up expected pending transactions.
|
// Set up expected pending transactions.
|
||||||
let expected_pending = vec![
|
let expected_pending = vec![
|
||||||
|
|||||||
@ -2742,7 +2742,7 @@ mod tests {
|
|||||||
pool.set_block_info(block_info);
|
pool.set_block_info(block_info);
|
||||||
|
|
||||||
// 2 txs, that should put the pool over the size limit but not max txs
|
// 2 txs, that should put the pool over the size limit but not max txs
|
||||||
let a_txs = MockTransactionSet::dependent(a_sender, 0, 2, TxType::EIP4844)
|
let a_txs = MockTransactionSet::dependent(a_sender, 0, 2, TxType::Eip4844)
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|mut tx| {
|
.map(|mut tx| {
|
||||||
tx.set_size(default_limits.max_size / 2 + 1);
|
tx.set_size(default_limits.max_size / 2 + 1);
|
||||||
@ -2780,7 +2780,7 @@ mod tests {
|
|||||||
pool.update_basefee(pool_base_fee);
|
pool.update_basefee(pool_base_fee);
|
||||||
|
|
||||||
// 2 txs, that should put the pool over the size limit but not max txs
|
// 2 txs, that should put the pool over the size limit but not max txs
|
||||||
let a_txs = MockTransactionSet::dependent(a_sender, 0, 2, TxType::EIP1559)
|
let a_txs = MockTransactionSet::dependent(a_sender, 0, 2, TxType::Eip1559)
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|mut tx| {
|
.map(|mut tx| {
|
||||||
tx.set_size(default_limits.max_size / 2 + 1);
|
tx.set_size(default_limits.max_size / 2 + 1);
|
||||||
|
|||||||
@ -293,9 +293,9 @@ impl MockTransaction {
|
|||||||
#[allow(unreachable_patterns)]
|
#[allow(unreachable_patterns)]
|
||||||
match tx_type {
|
match tx_type {
|
||||||
TxType::Legacy => Self::legacy(),
|
TxType::Legacy => Self::legacy(),
|
||||||
TxType::EIP2930 => Self::eip2930(),
|
TxType::Eip2930 => Self::eip2930(),
|
||||||
TxType::EIP1559 => Self::eip1559(),
|
TxType::Eip1559 => Self::eip1559(),
|
||||||
TxType::EIP4844 => Self::eip4844(),
|
TxType::Eip4844 => Self::eip4844(),
|
||||||
|
|
||||||
_ => unreachable!("Invalid transaction type"),
|
_ => unreachable!("Invalid transaction type"),
|
||||||
}
|
}
|
||||||
@ -703,9 +703,9 @@ impl PoolTransaction for MockTransaction {
|
|||||||
fn tx_type(&self) -> u8 {
|
fn tx_type(&self) -> u8 {
|
||||||
match self {
|
match self {
|
||||||
MockTransaction::Legacy { .. } => TxType::Legacy.into(),
|
MockTransaction::Legacy { .. } => TxType::Legacy.into(),
|
||||||
MockTransaction::Eip1559 { .. } => TxType::EIP1559.into(),
|
MockTransaction::Eip1559 { .. } => TxType::Eip1559.into(),
|
||||||
MockTransaction::Eip4844 { .. } => TxType::EIP4844.into(),
|
MockTransaction::Eip4844 { .. } => TxType::Eip4844.into(),
|
||||||
MockTransaction::Eip2930 { .. } => TxType::EIP2930.into(),
|
MockTransaction::Eip2930 { .. } => TxType::Eip2930.into(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user