-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Conversation
Signed-off-by: Alexandru Vasile <[email protected]>
Signed-off-by: Alexandru Vasile <[email protected]>
Signed-off-by: Alexandru Vasile <[email protected]>
Signed-off-by: Alexandru Vasile <[email protected]>
Signed-off-by: Alexandru Vasile <[email protected]>
Signed-off-by: Alexandru Vasile <[email protected]>
Signed-off-by: Alexandru Vasile <[email protected]>
Signed-off-by: Alexandru Vasile <[email protected]>
Signed-off-by: Alexandru Vasile <[email protected]>
I guess this is mostly needed to pin unfinalized blocks. A lot of this logic, including maintaining pinned set and reference counting is already in |
Yep, that should be the main use case the way I see it. It might also be possible for the client to keep around a finalized block that would exceed the pruning window of
That does indeed make sense, I'll have a go at it! Thanks for the feedback! |
There a couple of additional issues with this PR:
How exactly is this going to be implemented with this API? The RPC layer can't just call
It seems to me it that the whole thing should rather be implemented as a simple delay before blocks are garbage collected. Instead of discarding all unfinalized sibling chains of some block N as soon as it is finalized, we'd discard them when e.g. N+64 is finalized. |
We could check whether the block still exists when processing the notification, and ignore that notification if it doesn't.
Note that the API doesn't give you a way to retrieve justifications right now, and I don't think it's a useful feature for the
This seems sensible to me. As far as I know we don't expect the block bodies and all to occupy a lot of memory.
This works as well. The server can send a "stop" if a JSON-RPC client still has a block N pinned when N+64 is finalized. |
While this is right, this is also right for everything else in the node. IMO it would probably be nice to have all blocks pinned that are still in some "notification" in the node. When the last notification for a block is dropped, the pinning could be stopped. |
This is what I've been doing in smoldot, for what it's worth: Everything that needs to be aware of the latest blocks needs to use an API similar to the
It works pretty well and is IMO a good pattern. |
Hey, is anyone still working on this? Due to the inactivity this issue has been automatically marked as stale. It will be closed if no further activity occurs. Thank you for your contributions. |
The block pinning is a feature required by the RPC Spec V2.
The block pinning feature should be called for subscribers of the
chainHead_unstable_follow
method.This PR exposes two methods:
When a block is pinned it enters the pinning queue (
Backend::pinned_blocks
) andincrements its reference count. While a block is in the pinning queue will not be
pruned, regardless of the pruning settings.
When a block is unpinned the block can enter the pruning queue (
Backend::pruning_queue
) iff:The PR builds upon the
state_at
function that is not keeping the block's body around.Testing Done
test_pinned_blocks_on_finalize
test_pinned_blocks_on_finalize_with_fork
Part of #12475.