Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: do not propagate full 4844 transactions #4105

Merged
merged 3 commits into from
Aug 8, 2023
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
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 23 additions & 5 deletions crates/net/network/src/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ use reth_interfaces::{
use reth_metrics::common::mpsc::UnboundedMeteredReceiver;
use reth_network_api::{Peers, ReputationChangeKind};
use reth_primitives::{
FromRecoveredTransaction, IntoRecoveredTransaction, PeerId, TransactionSigned, TxHash, H256,
FromRecoveredTransaction, IntoRecoveredTransaction, PeerId, TransactionSigned, TxHash, TxType,
H256,
};
use reth_rlp::Encodable;
use reth_transaction_pool::{
Expand Down Expand Up @@ -247,10 +248,24 @@ where
let mut hashes = PooledTransactionsHashesBuilder::new(peer.version);
let mut full_transactions = FullTransactionsBuilder::default();

// Iterate through the transactions to propagate and fill the hashes and full
// transaction lists, before deciding whether or not to send full transactions to the
// peer.
for tx in to_propagate.iter() {
if peer.transactions.insert(tx.hash()) {
hashes.push(tx);
full_transactions.push(tx);

// Do not send full 4844 transaction hashes to peers.
//
// Nodes MUST NOT automatically broadcast blob transactions to their peers.
// Instead, those transactions are only announced using
// `NewPooledTransactionHashes` messages, and can then be manually requested
// via `GetPooledTransactions`.
//
// From: <https://eips.ethereum.org/EIPS/eip-4844#networking>
if tx.tx_type() != TxType::EIP4844 {
full_transactions.push(tx);
}
}
}
let mut new_pooled_hashes = hashes.build();
Expand Down Expand Up @@ -612,7 +627,6 @@ where

/// A transaction that's about to be propagated to multiple peers.
struct PropagateTransaction {
tx_type: u8,
size: usize,
transaction: Arc<TransactionSigned>,
}
Expand All @@ -624,8 +638,12 @@ impl PropagateTransaction {
self.transaction.hash()
}

fn tx_type(&self) -> TxType {
self.transaction.tx_type()
}

fn new(transaction: Arc<TransactionSigned>) -> Self {
Self { tx_type: transaction.tx_type().into(), size: transaction.length(), transaction }
Self { size: transaction.length(), transaction }
}
}

Expand Down Expand Up @@ -685,7 +703,7 @@ impl PooledTransactionsHashesBuilder {
PooledTransactionsHashesBuilder::Eth68(msg) => {
msg.hashes.push(tx.hash());
msg.sizes.push(tx.size);
msg.types.push(tx.tx_type);
msg.types.push(tx.transaction.tx_type().into());
}
}
}
Expand Down
Loading