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

feat(internal/client): Introduction of Client that implements LockImportRun, BlockchainEvents, and PrecommitActions. #4477

Open
wants to merge 16 commits into
base: refactor/client-db
Choose a base branch
from

Conversation

timwu20
Copy link
Contributor

@timwu20 timwu20 commented Jan 17, 2025

Changes

  • Introduction of BlockchainEvents interface.
  • Introduction of PreCommitActions interface.
  • Introduction of new Client type that implements both BlockchainEvents and PrecommitActions interfaces.
  • Introduction of Client.LockImportRun function that will be used as a dependency in future work.
  • Unpinning functionality and background goroutine within Client to unpin blocks from memory based on notifications
  • Pubsub module utilized in sending out storage notifications from Client.

Tests

go test -tags integration github.com/ChainSafe/gossamer

Issues

closes #4455, #4456, #4457

@timwu20 timwu20 force-pushed the tim/client-notifications branch 2 times, most recently from b93e7cc to cf9fb20 Compare January 17, 2025 20:23
@timwu20 timwu20 force-pushed the refactor/client-db branch from 8fe8796 to 8cc1aa9 Compare January 19, 2025 06:43
@timwu20 timwu20 force-pushed the tim/client-notifications branch 2 times, most recently from e690825 to 0fc61bb Compare January 19, 2025 07:02
@timwu20 timwu20 force-pushed the tim/client-notifications branch from 0fc61bb to fdc527e Compare January 19, 2025 07:04
@timwu20 timwu20 marked this pull request as ready for review January 20, 2025 14:55
@timwu20 timwu20 changed the title Tim/client notifications feat(client): Introduction of Client that implements LockImportRun, BlockchainEvents, and PrecommitActions. Jan 20, 2025
@timwu20 timwu20 changed the title feat(client): Introduction of Client that implements LockImportRun, BlockchainEvents, and PrecommitActions. feat(internal/client): Introduction of Client that implements LockImportRun, BlockchainEvents, and PrecommitActions. Jan 20, 2025
@timwu20 timwu20 force-pushed the tim/client-notifications branch from 82c2680 to 3ba7d9e Compare January 20, 2025 15:03
Copy link
Contributor

@haikoschol haikoschol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just some typos & nits

internal/client/api/backend.go Outdated Show resolved Hide resolved
internal/client/api/notifications.go Outdated Show resolved Hide resolved
internal/client/api/registry.go Outdated Show resolved Hide resolved
internal/client/client.go Outdated Show resolved Hide resolved
internal/client/client.go Outdated Show resolved Hide resolved
Comment on lines +43 to +46
npw.pinnedBlocks.Add(hash, count)
if count == 0 {
npw.pinnedBlocks.Remove(hash)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
npw.pinnedBlocks.Add(hash, count)
if count == 0 {
npw.pinnedBlocks.Remove(hash)
}
if count == 0 {
npw.pinnedBlocks.Remove(hash)
} else {
npw.pinnedBlocks.Add(hash, count)
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since pinnedBlocks is an lru cache this is expected behaviour. We should be modifying the count before we remove. See the substrate impl.

defer s.Unlock()
_, ok := s.channels[subsID]
if !ok {
panic(fmt.Sprintf("invalid subsID: %d", subsID))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this warrant a panic? I would have gone with a debug log (or maybe warning).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I replicated this from the substrate impl. I think given this is an internal registry type, we want to alert the developer that this is wrong behaviour. We shouldn't be unregistering subscription IDs that do not exist.

timwu20 and others added 2 commits January 22, 2025 10:52
Co-authored-by: Haiko Schol <hs@haikoschol.com>
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

Successfully merging this pull request may close these issues.

2 participants