monadNewHeads subscription. This documentation page explains how it
is done with execution events.
Block tags
As explained here, blocks must be identified by their unique ID prior to finalization. Even so, it is often useful to know what the proposed block number is, even before we know if the block will committed with that number or not. The following structure — called a “block tag” — appears as a field in several execution event payload types, to communicate the block ID and the (proposed) block number together.The four consensus events
The four block commit states correspond to four execution event types. Events of these types are published to announce that a particular block is moving to a new commit state.First consensus event: BLOCK_START (proposed state)
BLOCK_START event, whose event
payload contains a block_tag field that introduces the unique ID for the
block and the block number it will eventually have, if it gets finalized.
Almost all execution events (transaction logs, call frames, receipts, etc.)
occur between the BLOCK_START and BLOCK_END events. In the current
implementation, block execution is never pipelined, so all events between
BLOCK_START and BLOCK_END pertain to a single block, and there will not
be another BLOCK_START until the current block is ended.
Unlike the other events in this list, BLOCK_START is both a “consensus
event” (it means the associated block is in proposed state) and an “EVM event,”
because execution information about the block is being made available to you.
The other events in this list are not like that. They are “pure” consensus
events: they tell you what happened to a proposed block in the consensus
algorithm, after you’ve already seen all of its EVM events.
To understand the implications of this state, see
here.
There’s no reason why a block has to start in the proposed state. If
execution is lagging behind consensus, it’s possible that a block might have
advanced to a later state in the consensus algorithm. For example, suppose
consensus has been working on a block for a while, and by the time execution
finally sees it, perhaps consensus knows that it has progressed to voted.In the current implementation, however, execution will not know this. It
implicitly considers everything it executes to only be proposed. This is only
literally true if execution is not lagging behind.
Second consensus event: BLOCK_QC (voted state)
Third consensus event: BLOCK_FINALIZED
Fourth consensus event: BLOCK_VERIFIED
BLOCK_VERIFIED. This time, it is sufficient to identify the block only by
its block number. Because verified blocks are already finalized, they are
part of the canonical blockchain and cannot be reverted without a hard fork.
Thus, we no longer need the block tag.
To understand all the implications of seeing this event, see
here.
