-
Notifications
You must be signed in to change notification settings - Fork 2.6k
on_idle hook #4064
Comments
Just an overall note that at the moment we do not expose the weight to the client (aka. |
We really want this feature to allow us to leverage the "free" weights in the block. It could help #6594 as well. |
Sounds good idea, though I think the function should return the weight it consumes ahead of time so that we don't go beyond block weight. Also transaction-payment adjust fee depending on how much full the blocks are, this logic might be affected. |
@coriolinus I reckon this is quite similar to what we just talked about today, neh? If implemented, the parachain can also use the same mechanism (Or basically the part that reports block weight to the proposer). |
No. The parachain stuff is not connected in any way to this. Parachain candidates etc are passed as inherent to the relay chain. Inherents are before transactions. |
This means a transaction can not use the weight of an inherent. Besides that, the proposer will never be aware of the weight or similar stuff. Weight is FRAME specific and other runtimes could use anything. |
Good point about Weight is FRAME specific. Can we modify the proposer so an arbitrary data is passed around? And FRAME can interpreted it as weight. |
Data passed from where to where? Can you please explain more what you want to do? |
Here is my proposal:
|
why should this involve client ? isn't it possible to do everything inside the runtime ? how I would see it is that just before |
I see this exactly in the same way. |
Oh the block producer discussion got me confused. Yes we do have everything available in the runtime so we can just update the So we can just update the macro to support |
adding a hook is not difficult in #6877 thus if you want to make a PR I can "backport" to attribute macro |
This could also be useful for the scheduler, no? |
@JesseAbram working on this here: #8209 |
Depends on the type of the chain, it usually have peak and off-peak hours. It will be good if there is a way to run some maintenance task on off-peak hours, for example, claim contract states, actively and progressively migrate storage format, doing expensive but not urgent calculation like calculate the winners of an election.
When block producer finished packing all the transactions and still have lots free remaining block weights (with #4058, it is possible to have a good estimation of the free amount before execute
on_finalize
hooks), it can call theon_idle(block_number: BlockNumber, free_weight: Weight) -> Weight
to perform additional non-urgent work. This hook can return a number to indicate how much weight it used, and allow other modules to consume the unused part.Chain operator can always dispatch an operational transaction to force perform the maintenance task if the the chain is too busy and never calls
on_idle
hook. Oron_initalize
can do the maintenance task if it noticeson_idle
was never called in last N blocks.The text was updated successfully, but these errors were encountered: