Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

pallet-message-queue: add queue pausing #14318

Merged
merged 3 commits into from
Jun 28, 2023
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
Prev Previous commit
Remove check
Otherwise it would not start servicing queues that started paused
and became unpaused afterwards.

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
  • Loading branch information
ggwpez committed Jun 8, 2023
commit add93828aad419edecd8a3c0cbb7b4eb2cd6c0b6
4 changes: 1 addition & 3 deletions frame/message-queue/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -705,8 +705,6 @@ impl<T: Config> Pallet<T> {
}

fn ready_ring_unknit(origin: &MessageOriginOf<T>, neighbours: Neighbours<MessageOriginOf<T>>) {
debug_assert!(!T::QueuePausedQuery::is_paused(origin));

if origin == &neighbours.next {
debug_assert!(
origin == &neighbours.prev,
Expand Down Expand Up @@ -783,7 +781,7 @@ impl<T: Config> Pallet<T> {
BookStateFor::<T>::insert(origin, book_state);
return
}
} else if !T::QueuePausedQuery::is_paused(origin) {
} else {
debug_assert!(
book_state.ready_neighbours.is_none(),
"Must not be in ready ring if not ready"
Expand Down
30 changes: 30 additions & 0 deletions frame/message-queue/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1233,6 +1233,9 @@ fn ready_ring_knit_and_unknit_works() {
BookStateFor::<Test>::insert(There, empty_book::<Test>());
BookStateFor::<Test>::insert(Everywhere(0), empty_book::<Test>());

// Pausing should make no difference:
PausedQueues::set(vec![Here, There, Everywhere(0)]);

// Knit them into the ready ring.
assert_ring(&[]);
knit(&Here);
Expand Down Expand Up @@ -1427,3 +1430,30 @@ fn execute_overweight_respects_suspension() {
);
});
}

#[test]
fn service_queue_suspension_ready_ring_works() {
test_closure(|| {
let origin = MessageOrigin::Here;
PausedQueues::set(vec![origin]);
MessageQueue::enqueue_message(msg("weight=5"), origin);

MessageQueue::service_queues(Weight::MAX);
// It did not execute but is in the ready ring.
assert!(System::events().is_empty(), "Paused");
assert_ring(&[origin]);

// Now when we un-pause, it will execute.
PausedQueues::take();
MessageQueue::service_queues(Weight::MAX);
assert_last_event::<Test>(
Event::Processed {
id: blake2_256(b"weight=5"),
origin,
weight_used: 5.into_weight(),
success: true,
}
.into(),
);
});
}