This repository has been archived by the owner on Nov 15, 2023. It is now read-only.
Extend finality notifications to include displaced leaves #10605
Labels
J0-enhancement
An additional feature request.
U2-some_time_soon
Issue is worth doing soon.
Z2-medium
Can be fixed by a coder with good Rust knowledge but little knowledge of the codebase.
The client provides a stream for listening for finality notifications, thus allowing other clients to hook into the finality pipeline. Currently it sends a notification for each block that gets finalized with the following format:
substrate/client/api/src/client.rs
Lines 273 to 280 in 7409589
Finalizing a block can lead to a bunch of forks becoming stale (i.e. they cannot progress any further). In such cases, it might be useful to know that these forks can be abandoned so that potentially some data can be pruned (e.g. BABE block weight). Currently, this is handled in the backend where we keep track of the open leaves but this information is not exposed back to the client. I propose updating the finality notifcation struct to include this data:
stale_heads
would include the latest block of each of these forks, all stale fork blocks could then be found by traversing these heads back until reaching the finalized chain.Additionally, I suggest that the notification should also include the block number of the previously best finalized block. This is because currently the client will create notifications for all intermediary finalized blocks, e.g. if block 5 is the current best finalized and we then finalize block 10 then the client will send notifications for 6, 7, 8, 9 and 10. By passing along the last finalized number in the notification we can avoid having to create all these intermediary notifications and instead the consumer of the notification can decide whether it needs to do anything on the intermediary blocks or not. The current implementation also has a edge case where we don't send more than 256 notifications, which can lead to some unexpected results (https://github.com/paritytech/substrate/blob/master/client/service/src/client/client.rs#L833-L842).
The text was updated successfully, but these errors were encountered: