10

I found it a bit confusing that part of the logic for block verification is in sc_consensus::import_queue::Verifier::verify() implementation and another part is in sc_consensus::block_import::BlockImport::import_block() implementation.

Vefifier description says "Verify a justification of a block", but after looking at https://stackoverflow.com/a/58059237/3806795 and source code of Aura and BABE, it doesn't seem that verifier there has anything to do with finality.

sc-consensus-pow is much simpler, from it it seems that Verify is for things that can be verified right away without assuming that any other block was imported and BlockImport verifies the rest.

Do I understand correctly that Verify needs to do quick isolated check and BlockImport everything that requires previous blocks to be imported and there should be no overlap in what they check (in other words it is guaranteed that Verify::verify() will called be first, so no need to do the same work again in BlockImport::import_block())?

For context: I'm working on a custom non-PoS consensus and want to make sure I'm doing it properly.

1 Answer 1

5

The idea of Verifier was that it is only being used to verify the block in isolation as you said. This means for POS for example that you only verify the seal of a block.

Currently that isn't the case, AURA and BABE for example also check the inherents. We are planing some greater refactoring in the future where we will need this isolated block header verification.

For your own consensus, I would propose that you implement the block verifier as described. The block import can then any kind of verification that needs to access any state or needs access to the full block.

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.