mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-01-29 09:08:05 -05:00
feat(eip4844): add EIP4844 to the TxType enum (#3953)
This commit is contained in:
@@ -147,6 +147,9 @@ impl Decodable for ReceiptWithBloom {
|
||||
} else if receipt_type == 0x02 {
|
||||
buf.advance(1);
|
||||
Self::decode_receipt(buf, TxType::EIP1559)
|
||||
} else if receipt_type == 0x03 {
|
||||
buf.advance(1);
|
||||
Self::decode_receipt(buf, TxType::EIP4844)
|
||||
} else {
|
||||
Err(reth_rlp::DecodeError::Custom("invalid receipt type"))
|
||||
}
|
||||
@@ -251,6 +254,9 @@ impl<'a> ReceiptWithBloomEncoder<'a> {
|
||||
TxType::EIP1559 => {
|
||||
out.put_u8(0x02);
|
||||
}
|
||||
TxType::EIP4844 => {
|
||||
out.put_u8(0x03);
|
||||
}
|
||||
_ => unreachable!("legacy handled; qed."),
|
||||
}
|
||||
out.put_slice(payload.as_ref());
|
||||
@@ -270,7 +276,7 @@ impl<'a> Encodable for ReceiptWithBloomEncoder<'a> {
|
||||
fn length(&self) -> usize {
|
||||
let mut payload_len = self.receipt_length();
|
||||
// account for eip-2718 type prefix and set the list
|
||||
if matches!(self.receipt.tx_type, TxType::EIP1559 | TxType::EIP2930) {
|
||||
if matches!(self.receipt.tx_type, TxType::EIP1559 | TxType::EIP2930 | TxType::EIP4844) {
|
||||
payload_len += 1;
|
||||
// we include a string header for typed receipts, so include the length here
|
||||
payload_len += length_of_length(payload_len);
|
||||
|
||||
@@ -27,6 +27,8 @@ pub enum TxType {
|
||||
EIP2930 = 1_isize,
|
||||
/// Transaction with Priority fee
|
||||
EIP1559 = 2_isize,
|
||||
/// Shard Blob Transactions - EIP-4844
|
||||
EIP4844 = 3_isize,
|
||||
}
|
||||
|
||||
impl From<TxType> for u8 {
|
||||
@@ -35,6 +37,7 @@ impl From<TxType> for u8 {
|
||||
TxType::Legacy => LEGACY_TX_TYPE_ID,
|
||||
TxType::EIP2930 => EIP2930_TX_TYPE_ID,
|
||||
TxType::EIP1559 => EIP1559_TX_TYPE_ID,
|
||||
TxType::EIP4844 => EIP4844_TX_TYPE_ID,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -54,6 +57,7 @@ impl Compact for TxType {
|
||||
TxType::Legacy => 0,
|
||||
TxType::EIP2930 => 1,
|
||||
TxType::EIP1559 => 2,
|
||||
TxType::EIP4844 => 3,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,7 +66,8 @@ impl Compact for TxType {
|
||||
match identifier {
|
||||
0 => TxType::Legacy,
|
||||
1 => TxType::EIP2930,
|
||||
_ => TxType::EIP1559,
|
||||
2 => TxType::EIP1559,
|
||||
_ => TxType::EIP4844,
|
||||
},
|
||||
buf,
|
||||
)
|
||||
|
||||
@@ -112,7 +112,7 @@ impl Transaction {
|
||||
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::EIP2930 => (Some(U128::from(signed_tx.max_fee_per_gas())), None),
|
||||
TxType::EIP1559 => {
|
||||
TxType::EIP1559 | TxType::EIP4844 => {
|
||||
// the gas price field for EIP1559 is set to `min(tip, gasFeeCap - baseFee) +
|
||||
// baseFee`
|
||||
let gas_price = base_fee
|
||||
|
||||
Reference in New Issue
Block a user