mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 22:07:58 +00:00
Change best effort queue behaviour in dispute-coordinator (#6275)
* Change best effort queue behaviour in `dispute-coordinator` Use the same type of queue (`BTreeMap<CandidateComparator, ParticipationRequest>`) for best effort and priority in `dispute-coordinator`. Rework `CandidateComparator` to handle unavailable parent block numbers. Best effort queue will order disputes the same way as priority does - by parent's block height. Disputes on candidates for which the parent's block number can't be obtained will be treated with the lowest priority. * Fix tests: Handle `ChainApiMessage::BlockNumber` in `handle_sync_queries` * Some tests are deadlocking on sending messages via overseer so change `SingleItemSink`to `mpsc::Sender` with a buffer of 1 * Fix a race in test after adding a buffered queue for overseer messages * Fix the rest of the tests * Guide update - best-effort queue * Guide update: clarification about spam votes * Fix tests in `availability-distribution` * Update comments * Add `make_buffered_subsystem_context` in `subsystem-test-helpers` * Code review feedback * Code review feedback * Code review feedback * Don't add best effort candidate if it is already in priority queue * Remove an old comment * Fix insert in best_effort
This commit is contained in:
committed by
GitHub
parent
ad41e56e6e
commit
ccad411e46
@@ -177,7 +177,7 @@ where
|
||||
/// A test subsystem context.
|
||||
pub struct TestSubsystemContext<M, S> {
|
||||
tx: TestSubsystemSender,
|
||||
rx: SingleItemStream<FromOrchestra<M>>,
|
||||
rx: mpsc::Receiver<FromOrchestra<M>>,
|
||||
spawn: S,
|
||||
}
|
||||
|
||||
@@ -239,7 +239,7 @@ pub struct TestSubsystemContextHandle<M> {
|
||||
///
|
||||
/// Useful for shared ownership situations (one can have multiple senders, but only one
|
||||
/// receiver.
|
||||
pub tx: SingleItemSink<FromOrchestra<M>>,
|
||||
pub tx: mpsc::Sender<FromOrchestra<M>>,
|
||||
|
||||
/// Direct access to the receiver.
|
||||
pub rx: mpsc::UnboundedReceiver<AllMessages>,
|
||||
@@ -280,11 +280,22 @@ impl<M> TestSubsystemContextHandle<M> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Make a test subsystem context.
|
||||
/// Make a test subsystem context with `buffer_size == 0`. This is used by most
|
||||
/// of the tests.
|
||||
pub fn make_subsystem_context<M, S>(
|
||||
spawner: S,
|
||||
) -> (TestSubsystemContext<M, SpawnGlue<S>>, TestSubsystemContextHandle<M>) {
|
||||
let (overseer_tx, overseer_rx) = single_item_sink();
|
||||
make_buffered_subsystem_context(spawner, 0)
|
||||
}
|
||||
|
||||
/// Make a test subsystem context with buffered overseer channel. Some tests (e.g.
|
||||
/// `dispute-coordinator`) create too many parallel operations and deadlock unless
|
||||
/// the channel is buffered. Usually `buffer_size=1` is enough.
|
||||
pub fn make_buffered_subsystem_context<M, S>(
|
||||
spawner: S,
|
||||
buffer_size: usize,
|
||||
) -> (TestSubsystemContext<M, SpawnGlue<S>>, TestSubsystemContextHandle<M>) {
|
||||
let (overseer_tx, overseer_rx) = mpsc::channel(buffer_size);
|
||||
let (all_messages_tx, all_messages_rx) = mpsc::unbounded();
|
||||
|
||||
(
|
||||
|
||||
Reference in New Issue
Block a user