From 623fc578677545886929766f3a0b0a347d38ff5a Mon Sep 17 00:00:00 2001 From: Marian Vanderka Date: Thu, 5 Dec 2024 14:31:21 +0100 Subject: [PATCH] Fix/seq dies (#853) --- pallets/rolldown/src/lib.rs | 6 +++--- pallets/rolldown/src/tests.rs | 13 ++++++++----- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/pallets/rolldown/src/lib.rs b/pallets/rolldown/src/lib.rs index 6c598a7e9..72af04f83 100644 --- a/pallets/rolldown/src/lib.rs +++ b/pallets/rolldown/src/lib.rs @@ -1496,7 +1496,7 @@ impl Pallet { (update.pendingDeposits.len() as u128) + (update.pendingCancelResolutions.len() as u128); - ensure!(last_id > LastProcessedRequestOnL2::::get(l1), Error::::WrongRequestId); + ensure!(last_id >= LastProcessedRequestOnL2::::get(l1), Error::::WrongRequestId); let mut deposit_it = update.pendingDeposits.iter(); let mut cancel_it = update.pendingCancelResolutions.iter(); @@ -1521,8 +1521,8 @@ impl Pallet { 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, }) } diff --git a/pallets/rolldown/src/tests.rs b/pallets/rolldown/src/tests.rs index be64780af..30d09331e 100644 --- a/pallets/rolldown/src/tests.rs +++ b/pallets/rolldown/src/tests.rs @@ -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::(10); @@ -1044,10 +1047,10 @@ fn reject_update_without_new_updates() { 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 - ); + assert_ok!(Rolldown::update_l2_from_l1_unsafe( + RuntimeOrigin::signed(ALICE), + deposit_update + )); }); }