3

Let's say I have a consensus engine called X. I know that most consensus engines import blocks through something with the trait ImportQueue, and BasicQueue is a popular choice for that. Consensus engines that rely on BasicQueue must also implement a Verifier trait to check the blocks for correct inherents and signatures and so forth.

My question is, what happens if I don't use BasicQueue but my consensus engine provides its own implementation of ImportQueue?

Can I then build the verification and importing functionality in one go through an impl of ImportQueue? If yes, how, i.e. which functions of the trait are we supposed to build the verification functionality in?

pub trait ImportQueue<B: BlockT>: Send {
    fn service(&self) -> Box<dyn ImportQueueService<B>>;
    fn service_ref(&mut self) -> &mut dyn ImportQueueService<B>;
    fn poll_actions(&mut self, cx: &mut Context<'_>, link: &mut dyn Link<B>);
    fn run<'async_trait>(
        self,
        link: Box<dyn Link<B>>
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
    where
        Self: 'async_trait;
}

Bonus Question: Is there a real world implemenation of a consensus engine not using BasicQueue for ImportQueue?

1 Answer 1

0

Short answer, I would not recommend implementing your own ImportQueue right now. The interface currently is really specific to the current implementation.

My question is, what happens if I don't use BasicQueue but my consensus engine provides its own implementation of ImportQueue?

It should work, if your implementation is working.

Can I then build the verification and importing functionality in one go through an impl of ImportQueue? If yes, how, i.e. which functions of the trait are we supposed to build the verification functionality in?

Yes you can do this, you should do the verification before importing a new block. ImportQueueService::import_blocks is the function you are searching for.

Bonus Question: Is there a real world implemenation of a consensus engine not using BasicQueue for ImportQueue?

AFAIK, no.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.