Manual seal should build heartbeat blocks every now and again if there were no blocks being produced for some time.
@seunlanlege I suppose you can mentor this?
And I would like to tackle this this week.
Will check with either @seunlanlege or @JoshOrndorff
We might also add a minimum block period. Currently if I send 1000tx/sec I get 1000 blocks per sec.
@seunlanlege @JoshOrndorff
I am looking into this issue today, read thru the src code in consensus/manual-seal. I also tangentially think about im-online pallet, and how it is sending heartbeats.
My question is that manual-seal is a consensus mechanism. When we say do a heartbeat block in manual seal, I would assume the runtime should include / implement something like im-online pallet trait. So this depends on what pallets the runtime composed. How do we go about doing heartbeat just in the consensus layer and not involving another pallet?
No, the heartbeat is not related to im-online.
What is meant by heartbeat is, that you just produce a block every x seconds or whatever. That is the heartbeat, the block that was build without requiring any transaction.
but if we are regularly producing a block, that also sound to me like defeating the purpose of manual / instant sealing. It will just like producing block every 6s (or whatever time we set).
so I am thinking is it possible to send heartbeat but not producing block, so:
but if we are regularly producing a block, that also sound to me like defeating the purpose of manual / instant sealing. It will just like producing block every 6s (or whatever time we set).
This is the whole idea behind this issue and nothing else. It should produce a block every x seconds to make the user aware that the system is "alive". No one will use manual seal in a production environment anyway.
I'm online is not related here. That pallet lets validators prove to the runtime that they are indeed online when they are supposed to be. It makes sense in PoS because if a validator goes offline, you want to slash them. But in instant seal validators are anonymous and there is nobody to slash anyway. Creating a block is enough to show that the network is live.
if we are regularly producing a block, that also sound to me like defeating the purpose of manual / instant sealing.
We can make it configurable so that the heartbeat block is optional. Or more generally we can set the duration of the heartbeat block to be configurable and setting it to 0 means no heartbeats. In a given node, that configurability could be passed along to a node operator via a commandline flag. But I recommend getting basic heartbeat blocks working first, and then think about customizing.
Also the idea isn't to produce a block _every_ n seconds. It is to produce a block when there has not been any other block for n seconds. For example let's say we set n=30s. If users are submitting transactions every ten seconds then the existing instant seal block production works just fine and no additional blocks are produced. But if there is a period of inactivity (no transactions) on the network, then the every 30 sec rule kicks in to show the network is live.
can use the heartbeat to wake the off-chain worker up if necessary
I think that's a cool idea. This issue was opened because a user said "why does my ocw never run?" Making the heartbeat kick off the OCW at a regular interval would solve that without requiring a block. But that is a change that is not related to this consensus algorithm, and should be handled separately.
Manual seal should build heartbeat blocks every now and again if there were no blocks being produced for some time.
I recommend actually leaving manual and instant seal as-is and make a new 'RegulaSeal'? code-wise it should be the same and now we support all for testing.
Manual seal should build heartbeat blocks every now and again if there were no blocks being produced for some time.
I recommend actually leaving manual and instant seal as-is and make a new 'RegulaSeal'? code-wise it should be the same and now we support all for testing.
Nope. That makes no sense at all. Just is just a simple configuration option which can be set. We don't need to copy all the code.
Manual seal should build heartbeat blocks every now and again if there were no blocks being produced for some time.
I recommend actually leaving manual and instant seal as-is and make a new 'RegulaSeal'? code-wise it should be the same and now we support all for testing.
Nope. That makes no sense at all. Just is just a simple configuration option which can be set. We don't need to copy all the code.
I assumed what I recommended won't need code duplication and will have a common underlying code. My point is that let's support this as well and keep the old seals as well, which seems to be already settled.