3

I'm currently building a listener for KSM blocks. I used the api.rpc.chain.subscribeFinalizedHeads method with the RPC node wss://kusama-rpc.polkadot.io. As a simple test, I had the callback simply console log the block number. One thing I noticed is that there are some blocks being skipped by the subscriber. 1 out of every 6 blocks seems to not be picked up. If I type the missing block into a scanner online, it exists and shows up. However, the built-in subscriber seems to be missing it.

Does anyone have any insight into why this could be? I don't want to be missing transactions.

1 Answer 1

9

The finalization doesn't happen block-by-block, but rather can finalize a chain. Consider the following -

A
|
B
|--|
C  D
|  |
E  F
|
G

Assume that A & B are finalized. A fork happens. Now when G is finalized, it means that both C & E are as well - since G builds on E, which builds on C, which builds on a previously finalized B.

So Grandpa doesn't need to finalize block-by-block, but would finalize a full chain at once. The subscription returns the last block finalized, which would mean the block's parent and the parents of that, are finalized as well.

So in this example you would receive finalization updates for - A, B & G

1

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.