Skip to content

Commit

Permalink
Fix/seq dies (#853)
Browse files Browse the repository at this point in the history
  • Loading branch information
vanderian authored Dec 5, 2024
1 parent 013384b commit 623fc57
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
6 changes: 3 additions & 3 deletions pallets/rolldown/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1496,7 +1496,7 @@ impl<T: Config> Pallet<T> {
(update.pendingDeposits.len() as u128) +
(update.pendingCancelResolutions.len() as u128);

ensure!(last_id > LastProcessedRequestOnL2::<T>::get(l1), Error::<T>::WrongRequestId);
ensure!(last_id >= LastProcessedRequestOnL2::<T>::get(l1), Error::<T>::WrongRequestId);

let mut deposit_it = update.pendingDeposits.iter();
let mut cancel_it = update.pendingCancelResolutions.iter();
Expand All @@ -1521,8 +1521,8 @@ impl<T: Config> Pallet<T> {
update_hash: update.abi_encode_hash(),
update_size: update.pendingDeposits.len() as u128 +
update.pendingCancelResolutions.len() as u128,
max_id: lowest_id,
min_id: last_id,
min_id: lowest_id,
max_id: last_id,
})
}

Expand Down
13 changes: 8 additions & 5 deletions pallets/rolldown/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1028,7 +1028,10 @@ fn reject_update_with_invalid_too_high_request_id() {

#[test]
#[serial]
fn reject_update_without_new_updates() {
// changed to accept
// seq gets the rights BEFORE LastProcessedRequestOnL2 is updated
// a single request would be duplicated, extrinsic fail and break seq
fn accept_update_without_new_updates() {
ExtBuilder::new().execute_with_default_mocks(|| {
forward_to_block::<Test>(10);

Expand All @@ -1044,10 +1047,10 @@ fn reject_update_without_new_updates() {
forward_to_block::<Test>(16);
assert_eq!(LastProcessedRequestOnL2::<Test>::get(consts::CHAIN), 1u128.into());

assert_err!(
Rolldown::update_l2_from_l1_unsafe(RuntimeOrigin::signed(ALICE), deposit_update),
Error::<Test>::WrongRequestId
);
assert_ok!(Rolldown::update_l2_from_l1_unsafe(
RuntimeOrigin::signed(ALICE),
deposit_update
));
});
}

Expand Down

0 comments on commit 623fc57

Please sign in to comment.