diff --git a/pallets/rolldown/src/lib.rs b/pallets/rolldown/src/lib.rs index eeb8c51ef..2cbee326c 100644 --- a/pallets/rolldown/src/lib.rs +++ b/pallets/rolldown/src/lib.rs @@ -1449,7 +1449,7 @@ impl Pallet { Error::::WrongRequestId ); - let last_id = lowest_id + + let last_id = lowest_id.saturating_sub(1u128) + (update.pendingDeposits.len() as u128) + (update.pendingCancelResolutions.len() as u128); diff --git a/pallets/rolldown/src/tests.rs b/pallets/rolldown/src/tests.rs index d71f6c002..99c0a8853 100644 --- a/pallets/rolldown/src/tests.rs +++ b/pallets/rolldown/src/tests.rs @@ -979,6 +979,31 @@ fn reject_update_with_invalid_too_high_request_id() { }); } +#[test] +#[serial] +fn reject_update_without_new_updates() { + ExtBuilder::new().execute_with_default_mocks(|| { + forward_to_block::(10); + + let deposit_update = L1UpdateBuilder::default() + .with_requests(vec![L1UpdateRequest::Deposit(Default::default())]) + .with_offset(1u128) + .build(); + + Rolldown::update_l2_from_l1_unsafe(RuntimeOrigin::signed(ALICE), deposit_update.clone()) + .unwrap(); + assert_eq!(LastProcessedRequestOnL2::::get(consts::CHAIN), 0u128.into()); + + forward_to_block::(16); + assert_eq!(LastProcessedRequestOnL2::::get(consts::CHAIN), 1u128.into()); + + assert_err!( + Rolldown::update_l2_from_l1_unsafe(RuntimeOrigin::signed(ALICE), deposit_update), + Error::::WrongRequestId + ); + }); +} + #[test] #[serial] fn reject_second_update_in_the_same_block() {