Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 1 addition & 12 deletions crates/common/types/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ pub enum Transaction {

/// The same as a Transaction enum, only that blob transactions are in wrapped format, including
/// the blobs bundle.
/// PrivilegedL2Transaction is not included as it is not expected to be sent over P2P.
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum P2PTransaction {
LegacyTransaction(LegacyTransaction),
EIP2930Transaction(EIP2930Transaction),
EIP1559Transaction(EIP1559Transaction),
EIP4844TransactionWithBlobs(WrappedEIP4844Transaction),
EIP7702Transaction(EIP7702Transaction),
PrivilegedL2Transaction(PrivilegedL2Transaction),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably document this change somewhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 63675e2

}

impl TryInto<Transaction> for P2PTransaction {
Expand All @@ -61,9 +61,6 @@ impl TryInto<Transaction> for P2PTransaction {
P2PTransaction::EIP2930Transaction(itx) => Ok(Transaction::EIP2930Transaction(itx)),
P2PTransaction::EIP1559Transaction(itx) => Ok(Transaction::EIP1559Transaction(itx)),
P2PTransaction::EIP7702Transaction(itx) => Ok(Transaction::EIP7702Transaction(itx)),
P2PTransaction::PrivilegedL2Transaction(itx) => {
Ok(Transaction::PrivilegedL2Transaction(itx))
}
_ => Err("Can't convert blob p2p transaction into regular transaction. Blob bundle would be lost.".to_string()),
}
}
Expand Down Expand Up @@ -102,9 +99,6 @@ impl RLPDecode for P2PTransaction {
// EIP7702
0x4 => EIP7702Transaction::decode_unfinished(tx_encoding)
.map(|(tx, rem)| (P2PTransaction::EIP7702Transaction(tx), rem)),
// PrivilegedL2
0x7e => PrivilegedL2Transaction::decode_unfinished(tx_encoding)
.map(|(tx, rem)| (P2PTransaction::PrivilegedL2Transaction(tx), rem)),
ty => Err(RLPDecodeError::Custom(format!(
"Invalid transaction type: {ty}"
))),
Expand Down Expand Up @@ -1439,7 +1433,6 @@ mod canonic_encoding {
P2PTransaction::EIP1559Transaction(_) => TxType::EIP1559,
P2PTransaction::EIP4844TransactionWithBlobs(_) => TxType::EIP4844,
P2PTransaction::EIP7702Transaction(_) => TxType::EIP7702,
P2PTransaction::PrivilegedL2Transaction(_) => TxType::Privileged,
}
}

Expand All @@ -1455,7 +1448,6 @@ mod canonic_encoding {
P2PTransaction::EIP1559Transaction(t) => t.encode(buf),
P2PTransaction::EIP4844TransactionWithBlobs(t) => t.encode(buf),
P2PTransaction::EIP7702Transaction(t) => t.encode(buf),
P2PTransaction::PrivilegedL2Transaction(t) => t.encode(buf),
};
}

Expand All @@ -1482,9 +1474,6 @@ mod canonic_encoding {
P2PTransaction::EIP7702Transaction(t) => {
Transaction::EIP7702Transaction(t.clone()).compute_hash()
}
P2PTransaction::PrivilegedL2Transaction(t) => {
Transaction::PrivilegedL2Transaction(t.clone()).compute_hash()
}
}
}
}
Expand Down
8 changes: 6 additions & 2 deletions crates/networking/p2p/rlpx/connection/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,7 @@ async fn send_all_pooled_tx_hashes(
.get_all_txs_by_sender()?
.into_values()
.flatten()
.filter(|tx| !tx.is_privileged())
.collect();
if !txs.is_empty() {
state
Expand Down Expand Up @@ -933,8 +934,11 @@ async fn handle_incoming_message(
for tx in &txs.transactions {
// Reject blob transactions in L2 mode
#[cfg(feature = "l2")]
if is_l2_mode && matches!(tx, Transaction::EIP4844Transaction(_)) {
debug!(peer=%state.node, "Rejecting blob transaction in L2 mode - blob transactions are not supported in L2");
if (is_l2_mode && matches!(tx, Transaction::EIP4844Transaction(_)))
|| tx.is_privileged()
{
let tx_type = tx.tx_type();
debug!(peer=%state.node, "Rejecting transaction in L2 mode - {tx_type} transactions are not broadcasted in L2");
continue;
}

Expand Down
5 changes: 4 additions & 1 deletion crates/networking/p2p/tx_broadcaster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,9 @@ impl TxBroadcaster {
let full_txs = txs_to_broadcast
.iter()
.map(|tx| tx.transaction().clone())
.filter(|tx| !matches!(tx, Transaction::EIP4844Transaction { .. }))
.filter(|tx| {
!matches!(tx, Transaction::EIP4844Transaction { .. }) && !tx.is_privileged()
})
.collect::<Vec<Transaction>>();

let blob_txs = txs_to_broadcast
Expand Down Expand Up @@ -262,6 +264,7 @@ impl TxBroadcaster {
.known_txs
.get(&hash)
.is_some_and(|record| record.peers.is_set(peer_idx))
&& !tx.is_privileged()
})
.cloned()
.collect::<Vec<MempoolTransaction>>();
Expand Down