fix: check encoded size (#16473)

This commit is contained in:
Matthias Seitz
2025-05-26 15:12:29 +02:00
committed by GitHub
parent 7b49b75a60
commit 52be0031e8
2 changed files with 6 additions and 4 deletions

View File

@@ -1151,7 +1151,6 @@ impl PoolTransaction for EthPooledTransaction {
}
fn from_pooled(tx: Recovered<Self::Pooled>) -> Self {
let encoded_length = tx.encode_2718_len();
let (tx, signer) = tx.into_parts();
match tx {
PooledTransactionVariant::Eip4844(tx) => {
@@ -1161,11 +1160,14 @@ impl PoolTransaction for EthPooledTransaction {
let tx = Signed::new_unchecked(tx, sig, hash);
let tx = TransactionSigned::from(tx);
let tx = Recovered::new_unchecked(tx, signer);
// we only need the encoded length of the transaction, excluding the blob sidecar
let encoded_length = tx.encode_2718_len();
let mut pooled = Self::new(tx, encoded_length);
pooled.blob_sidecar = EthBlobTransactionSidecar::Present(blob);
pooled
}
tx => {
let encoded_length = tx.encode_2718_len();
// no blob sidecar
let tx = Recovered::new_unchecked(tx.into(), signer);
Self::new(tx, encoded_length)

View File

@@ -318,11 +318,11 @@ where
};
// Reject transactions over defined size to prevent DOS attacks
let tx_input_len = transaction.input().len();
if tx_input_len > self.max_tx_input_bytes {
let tx_len = transaction.encoded_length();
if tx_len > self.max_tx_input_bytes {
return Err(TransactionValidationOutcome::Invalid(
transaction,
InvalidPoolTransactionError::OversizedData(tx_input_len, self.max_tx_input_bytes),
InvalidPoolTransactionError::OversizedData(tx_len, self.max_tx_input_bytes),
))
}