Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement BlockchainEvents interface for Client type #4456

Open
timwu20 opened this issue Jan 14, 2025 · 0 comments
Open

Implement BlockchainEvents interface for Client type #4456

timwu20 opened this issue Jan 14, 2025 · 0 comments

Comments

@timwu20
Copy link
Contributor

timwu20 commented Jan 14, 2025

Issue Summary

Taken from the design doc regarding BlockchainEvents (link):

Given that LockImportRun is the trigger for storage, finality and block import notifications we will be able to implement the BlockchainEvents and PreCommitActions traits.

BlockchainEvents contains the methods for registering channels for storage, finality and block import notifications. I propose adding a RegisterXXXNotification and accompanying UnregisterXXXNotification method for the finality and block import notifications. The storage notifcations are a little more complicated. Based on the rust code the sc_api::StorageNotifications type handles registering and unregistering of storage notifications. Listening on storage notifications is actually based on supplied top trie keys as well child trie keys (see code). We should mirror the implementation of the associated registry and business logic around going through registered storage notification listeners, and only notifying listeners based on the supplied top and child filter keys.

Taken from the design doc regarding pinning and unpinning blocks where notifications are sent:

... One thing to note is that blocks are pinned (stored in memory, and not pruned) in db.Backend when notifications are sent out. That means unpinning of blocks falls on the recipient of said notifications. This is usally handled in the rust code by reference counting the notifications with pin handles, and unpinning happens when the notification gets dropped (see code). Since in Go we don't have the Drop trait, we will need to manually drop the handle which will essentially unpin the block from the db.Backend and allow pruning to happen.

Acceptance Criteria

  • Introduction of BlockchainEvents interface.
  • Implementation of BlockchainEvents into Client type.
  • Implement background reference counting async worker to unpin.
  • Implement listener, and associated drop method

Other information and links

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant