Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 6 additions & 0 deletions crates/engine/src/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,12 @@ where

match result {
Ok(block) => {
// Skip block if no transactions are present in block.
if block.body.transactions.is_empty() {
tracing::trace!(target: "scroll::engine", "no transactions in block");
return None;
}

// Update the unsafe block info and return the block
let block_info = BlockInfo::new(block.number, block.hash_slow());
tracing::trace!(target: "scroll::engine", ?block_info, "updating unsafe block info from new payload");
Expand Down
54 changes: 54 additions & 0 deletions crates/sequencer/tests/e2e.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,60 @@ use tokio::{
time::{Duration, Instant},
};

#[tokio::test]
async fn skip_block_with_no_transactions() {
reth_tracing::init_test_tracing();

const BLOCK_BUILDING_DURATION: Duration = Duration::from_millis(0);

// setup a test node
let (mut nodes, _tasks, _wallet) = setup(1, false).await.unwrap();
let node = nodes.pop().unwrap();

// create a forkchoice state
let genesis_hash = node.inner.chain_spec().genesis_hash();
let fcs = ForkchoiceState::new(
BlockInfo { hash: genesis_hash, number: 0 },
Default::default(),
Default::default(),
);

// create the engine driver connected to the node
let auth_client = node.inner.engine_http_client();
let engine_client = ScrollAuthApiEngineClient::new(auth_client);
let mut engine_driver = EngineDriver::new(
Arc::new(engine_client),
(*SCROLL_DEV).clone(),
None::<ScrollRootProvider>,
fcs,
false,
BLOCK_BUILDING_DURATION,
);

// create a test database
let database = Arc::new(setup_test_db().await);
let provider = Arc::new(DatabaseL1MessageProvider::new(database.clone(), 0));

// create a sequencer
let mut sequencer = Sequencer::new(
provider,
Default::default(),
SCROLL_GAS_LIMIT,
4,
1,
L1MessageInclusionMode::BlockDepth(0),
);

// send a new payload attributes request.
sequencer.build_payload_attributes();
let payload_attributes = sequencer.next().await.unwrap();
engine_driver.handle_build_new_payload(payload_attributes);

// assert that no new payload event is emitted
let res = tokio::time::timeout(Duration::from_secs(1), engine_driver.next()).await;
assert!(res.is_err(), "expected no new payload, but a block was built: {:?}", res.ok());
}

#[tokio::test]
async fn can_build_blocks() {
reth_tracing::init_test_tracing();
Expand Down