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
34 changes: 31 additions & 3 deletions crates/scroll/node/src/builder/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use reth_transaction_pool::{
blobstore::DiskFileBlobStore, CoinbaseTipOrdering, EthPoolTransaction,
TransactionValidationTaskExecutor,
};
use scroll_alloy_consensus::ScrollTransaction;
use scroll_alloy_hardforks::ScrollHardforks;

/// A basic scroll transaction pool.
Expand Down Expand Up @@ -52,7 +53,7 @@ where
ChainSpec: EthChainSpec + ScrollHardforks + ChainConfig<Config = ScrollChainConfig>,
>,
>,
T: EthPoolTransaction<Consensus = TxTy<Node::Types>>,
T: EthPoolTransaction<Consensus = TxTy<Node::Types>> + ScrollTransaction,
{
type Pool = ScrollTransactionPool<Node::Provider, DiskFileBlobStore, T>;

Expand Down Expand Up @@ -138,7 +139,7 @@ mod tests {
use crate::ScrollNode;

use alloy_consensus::{transaction::Recovered, Header, Signed, TxLegacy};
use alloy_primitives::{private::rand::random_iter, Bytes, Signature, B256, U256};
use alloy_primitives::{private::rand::random_iter, Bytes, Sealed, Signature, B256, U256};
use reth_chainspec::Head;
use reth_db::mock::DatabaseMock;
use reth_node_api::FullNodeTypesAdapter;
Expand All @@ -160,7 +161,7 @@ mod tests {
error::{InvalidPoolTransactionError, PoolErrorKind},
PoolConfig, TransactionOrigin, TransactionPool,
};
use scroll_alloy_consensus::ScrollTxEnvelope;
use scroll_alloy_consensus::{ScrollTxEnvelope, TxL1Message};
use scroll_alloy_evm::curie::L1_GAS_PRICE_ORACLE_ADDRESS;

async fn pool() -> (
Expand Down Expand Up @@ -351,4 +352,31 @@ mod tests {
// drop all validation tasks.
drop(manager);
}

#[tokio::test]
async fn test_validate_one_disallow_l1_messages() {
// create the pool.
let (pool, manager) = pool().await;
let tx = ScrollTxEnvelope::L1Message(Sealed::new_unchecked(
TxL1Message::default(),
B256::default(),
));

// Create a pool transaction with the L1 message.
let pool_tx =
ScrollPooledTransaction::new(Recovered::new_unchecked(tx, Default::default()), 0);

// add the transaction to the pool and expect an `OversizedData` error.
let err = pool.add_transaction(TransactionOrigin::Local, pool_tx).await.unwrap_err();
assert!(matches!(
err.kind,
PoolErrorKind::InvalidTransaction(InvalidPoolTransactionError::Consensus(
InvalidTransactionError::TxTypeNotSupported
))
));

// explicitly drop the manager here otherwise the `TransactionValidationTaskExecutor` will
// drop all validation tasks.
drop(manager);
}
}
11 changes: 11 additions & 0 deletions crates/scroll/txpool/src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use reth_scroll_primitives::ScrollTransactionSigned;
use reth_transaction_pool::{
EthBlobTransactionSidecar, EthPoolTransaction, EthPooledTransaction, PoolTransaction,
};
use scroll_alloy_consensus::ScrollTransaction;
use std::sync::{Arc, OnceLock};

/// Pool transaction for Scroll.
Expand Down Expand Up @@ -209,6 +210,16 @@ where
}
}

impl<Cons: ScrollTransaction, Pooled> ScrollTransaction for ScrollPooledTransaction<Cons, Pooled> {
fn is_l1_message(&self) -> bool {
self.transaction.is_l1_message()
}

fn queue_index(&self) -> Option<u64> {
self.transaction.queue_index()
}
}

#[cfg(test)]
mod tests {
use crate::{ScrollPooledTransaction, ScrollTransactionValidator};
Expand Down
11 changes: 9 additions & 2 deletions crates/scroll/txpool/src/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use reth_transaction_pool::{
TransactionValidator,
};
use revm_scroll::l1block::L1BlockInfo;
use scroll_alloy_consensus::ScrollTransaction;
use std::sync::{
atomic::{AtomicU64, Ordering},
Arc,
Expand Down Expand Up @@ -85,7 +86,7 @@ impl<Client, Tx> ScrollTransactionValidator<Client, Tx> {
impl<Client, Tx> ScrollTransactionValidator<Client, Tx>
where
Client: ChainSpecProvider<ChainSpec: ScrollHardforks> + StateProviderFactory + BlockReaderIdExt,
Tx: EthPoolTransaction,
Tx: EthPoolTransaction + ScrollTransaction,
{
/// Create a new [`ScrollTransactionValidator`].
pub fn new(inner: EthTransactionValidator<Client, Tx>) -> Self {
Expand Down Expand Up @@ -139,6 +140,12 @@ where
transaction: Tx,
) -> TransactionValidationOutcome<Tx> {
if transaction.is_eip4844() {
return TransactionValidationOutcome::Invalid(
transaction,
InvalidTransactionError::Eip4844Disabled.into(),
)
}
if transaction.is_l1_message() {
return TransactionValidationOutcome::Invalid(
transaction,
InvalidTransactionError::TxTypeNotSupported.into(),
Expand Down Expand Up @@ -232,7 +239,7 @@ where
impl<Client, Tx> TransactionValidator for ScrollTransactionValidator<Client, Tx>
where
Client: ChainSpecProvider<ChainSpec: ScrollHardforks> + StateProviderFactory + BlockReaderIdExt,
Tx: EthPoolTransaction,
Tx: EthPoolTransaction + ScrollTransaction,
{
type Transaction = Tx;

Expand Down
Loading