From 1b648f217885e532ab595aa00acb82fdfffb9f84 Mon Sep 17 00:00:00 2001 From: blockchaindevsh Date: Tue, 14 Apr 2026 13:18:27 +0800 Subject: [PATCH] feat(codecs): add EIP-4844 blob transaction support for OP Stack storage codecs Add Eip4844 match arms to Compact impls for OpTxType, OpTypedTransaction, OpTxEnvelope, and OpReceipt, enabling L2 blob transaction storage. Co-Authored-By: Claude Opus 4.6 (1M context) --- crates/primitives-traits/src/size.rs | 4 ++++ crates/storage/codecs/src/alloy/optimism.rs | 1 + .../codecs/src/alloy/transaction/optimism.rs | 20 ++++++++++++++++++- 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/crates/primitives-traits/src/size.rs b/crates/primitives-traits/src/size.rs index e2343cfb95f..9484e8a986e 100644 --- a/crates/primitives-traits/src/size.rs +++ b/crates/primitives-traits/src/size.rs @@ -154,6 +154,7 @@ mod op { Self::Legacy(receipt) | Self::Eip2930(receipt) | Self::Eip1559(receipt) | + Self::Eip4844(receipt) | Self::Eip7702(receipt) => receipt.size(), Self::Deposit(receipt) => receipt.size(), } @@ -166,6 +167,7 @@ mod op { Self::Legacy(tx) => tx.size(), Self::Eip2930(tx) => tx.size(), Self::Eip1559(tx) => tx.size(), + Self::Eip4844(tx) => tx.size(), Self::Eip7702(tx) => tx.size(), Self::Deposit(tx) => tx.size(), } @@ -178,6 +180,7 @@ mod op { Self::Legacy(tx) => tx.size(), Self::Eip2930(tx) => tx.size(), Self::Eip1559(tx) => tx.size(), + Self::Eip4844(tx) => tx.size(), Self::Eip7702(tx) => tx.size(), } } @@ -189,6 +192,7 @@ mod op { Self::Legacy(tx) => tx.size(), Self::Eip2930(tx) => tx.size(), Self::Eip1559(tx) => tx.size(), + Self::Eip4844(tx) => tx.size(), Self::Eip7702(tx) => tx.size(), Self::Deposit(tx) => tx.size(), } diff --git a/crates/storage/codecs/src/alloy/optimism.rs b/crates/storage/codecs/src/alloy/optimism.rs index 43956939784..ced81333aff 100644 --- a/crates/storage/codecs/src/alloy/optimism.rs +++ b/crates/storage/codecs/src/alloy/optimism.rs @@ -62,6 +62,7 @@ impl From> for OpReceipt { OpTxType::Legacy => Self::Legacy(inner), OpTxType::Eip2930 => Self::Eip2930(inner), OpTxType::Eip1559 => Self::Eip1559(inner), + OpTxType::Eip4844 => Self::Eip4844(inner), OpTxType::Eip7702 => Self::Eip7702(inner), OpTxType::Deposit => { Self::Deposit(OpDepositReceipt { inner, deposit_nonce, deposit_receipt_version }) diff --git a/crates/storage/codecs/src/alloy/transaction/optimism.rs b/crates/storage/codecs/src/alloy/transaction/optimism.rs index 7f9c318e6a1..a897d197743 100644 --- a/crates/storage/codecs/src/alloy/transaction/optimism.rs +++ b/crates/storage/codecs/src/alloy/transaction/optimism.rs @@ -10,7 +10,8 @@ use crate::{ Compact, }; use alloy_consensus::{ - constants::EIP7702_TX_TYPE_ID, Signed, TxEip1559, TxEip2930, TxEip7702, TxLegacy, + constants::{EIP4844_TX_TYPE_ID, EIP7702_TX_TYPE_ID}, + Signed, TxEip1559, TxEip2930, TxEip4844, TxEip7702, TxLegacy, }; use alloy_primitives::{Address, Bytes, Sealed, Signature, TxKind, B256, U256}; use bytes::BufMut; @@ -93,6 +94,10 @@ impl crate::Compact for OpTxType { Self::Legacy => COMPACT_IDENTIFIER_LEGACY, Self::Eip2930 => COMPACT_IDENTIFIER_EIP2930, Self::Eip1559 => COMPACT_IDENTIFIER_EIP1559, + Self::Eip4844 => { + buf.put_u8(EIP4844_TX_TYPE_ID); + COMPACT_EXTENDED_IDENTIFIER_FLAG + } Self::Eip7702 => { buf.put_u8(EIP7702_TX_TYPE_ID); COMPACT_EXTENDED_IDENTIFIER_FLAG @@ -117,6 +122,7 @@ impl crate::Compact for OpTxType { COMPACT_EXTENDED_IDENTIFIER_FLAG => { let extended_identifier = buf.get_u8(); match extended_identifier { + EIP4844_TX_TYPE_ID => Self::Eip4844, EIP7702_TX_TYPE_ID => Self::Eip7702, op_alloy_consensus::DEPOSIT_TX_TYPE_ID => Self::Deposit, _ => panic!("Unsupported OpTxType identifier: {extended_identifier}"), @@ -139,6 +145,7 @@ impl Compact for OpTypedTransaction { Self::Legacy(tx) => tx.to_compact(out), Self::Eip2930(tx) => tx.to_compact(out), Self::Eip1559(tx) => tx.to_compact(out), + Self::Eip4844(tx) => tx.to_compact(out), Self::Eip7702(tx) => tx.to_compact(out), Self::Deposit(tx) => tx.to_compact(out), }; @@ -160,6 +167,10 @@ impl Compact for OpTypedTransaction { let (tx, buf) = Compact::from_compact(buf, buf.len()); (Self::Eip1559(tx), buf) } + OpTxType::Eip4844 => { + let (tx, buf) = Compact::from_compact(buf, buf.len()); + (Self::Eip4844(tx), buf) + } OpTxType::Eip7702 => { let (tx, buf) = Compact::from_compact(buf, buf.len()); (Self::Eip7702(tx), buf) @@ -178,6 +189,7 @@ impl ToTxCompact for OpTxEnvelope { Self::Legacy(tx) => tx.tx().to_compact(buf), Self::Eip2930(tx) => tx.tx().to_compact(buf), Self::Eip1559(tx) => tx.tx().to_compact(buf), + Self::Eip4844(tx) => tx.tx().to_compact(buf), Self::Eip7702(tx) => tx.tx().to_compact(buf), Self::Deposit(tx) => tx.to_compact(buf), }; @@ -204,6 +216,11 @@ impl FromTxCompact for OpTxEnvelope { let tx = Signed::new_unhashed(tx, signature); (Self::Eip1559(tx), buf) } + OpTxType::Eip4844 => { + let (tx, buf) = TxEip4844::from_compact(buf, buf.len()); + let tx = Signed::new_unhashed(tx, signature); + (Self::Eip4844(tx), buf) + } OpTxType::Eip7702 => { let (tx, buf) = TxEip7702::from_compact(buf, buf.len()); let tx = Signed::new_unhashed(tx, signature); @@ -226,6 +243,7 @@ impl Envelope for OpTxEnvelope { Self::Legacy(tx) => tx.signature(), Self::Eip2930(tx) => tx.signature(), Self::Eip1559(tx) => tx.signature(), + Self::Eip4844(tx) => tx.signature(), Self::Eip7702(tx) => tx.signature(), Self::Deposit(_) => &DEPOSIT_SIGNATURE, }