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(blob): blobsub #3539

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

feat(blob): blobsub #3539

wants to merge 3 commits into from

Conversation

distractedm1nd
Copy link
Member

Introduces blob.Subscribe. Takes a share.Namespace, returns a <-chan *BlobsubResponse containing a height uint64 and blobs []*blob.Blob.

I made the decision to not support subscribing to multiple namespaces with one call, because the complexity of the return type mitigates the benefits for the client. It is likely more convenient to have one subscription per namespace:

Imagine you are watching two namespaces for different things. On the client side, you would have a select statement reading from the two channels in two cases. This is cleaner than receiving everything in one case, but then having to manually parse and send to the respective handlers yourself.

TODO:

  • Unit tests
  • Mockgen
  • Document w @jcstein

Copy link
Member

@Wondertan Wondertan left a comment

Choose a reason for hiding this comment

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

Lovely


for {
select {
case header, ok := <-headerCh:
Copy link
Member

Choose a reason for hiding this comment

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

There is an edge case possible here. The HeaderSub doesn't guarantee a contiguous stream of headers, and there might be gaps that we have to handle. It shouldn't be hard to handle those through the header store, though.

Copy link
Member Author

Choose a reason for hiding this comment

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

I wasn't aware that it doesn't guarantee a contiguous stream of headers - to me, this sounds like something that needs to be fixed in headersub itself. Otherwise, we need to make it public because that is not intuitive and it's how everybody is currently using it. I would be fine holding off on merging this until that is fixed, can we discuss it further?

Copy link
Member

Choose a reason for hiding this comment

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

What if we will cache non-contiguous headers?

Copy link
Member

Choose a reason for hiding this comment

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

Agreed, we can move this issue separately. I think there might be a potential reason to fix this on go-header level with a Subscriber wrapper that does exactly gap filling. This way users relying on header subscriptions would not need to think of that edge case. Need to think of the implications of that tho

Copy link
Member

Choose a reason for hiding this comment

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

Mind parking this in an issue?

blob/service.go Outdated Show resolved Hide resolved
blob/service.go Outdated Show resolved Hide resolved
blob/service.go Outdated
height uint64
}

func (s *Service) Subscribe(ctx context.Context, ns share.Namespace) (<-chan *BlobsubResponse, error) {
Copy link
Member

Choose a reason for hiding this comment

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

These should follow GetAll semantics on the plurality of namespaces. We have yet to decide whether to keep GetAll with a single namespace or multiple; the subscription should be consistent with it, so we should decide on that first.

Copy link
Member

@Wondertan Wondertan Jul 1, 2024

Choose a reason for hiding this comment

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

(I would also call the method SubscribeAll)

Copy link
Member

Choose a reason for hiding this comment

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

I don't think we should have multiple namespaces for subscription. For GetAll it's fine since it is a single call, but for a long-term subscription, it adds complexity in handling on the user's side. So, if you insist on consistency, I'd rather make GetAll with a single namespace than SubscribeAll with multiple namespaces.

Copy link
Member

Choose a reason for hiding this comment

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

You would need to write two codepaths for the same blob handling logic, if these are inconsistent. As a dev, I would hate doing the same thing twice.

Copy link
Member

@Wondertan Wondertan Jul 1, 2024

Choose a reason for hiding this comment

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

On the single vs multiple namespace. Try to imagine how the implementation of the protocol that relies on multiple namespaces would look like(e.g. Rollkit). If you do it sequentially, you add another roundtrip. If you do it concurrently, you bring complexity for devs to synchronise both.

Copy link
Member Author

Choose a reason for hiding this comment

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

For the reasons I stated in the description, I will not be extending this to add multiple namespaces. I also do not think consistency is so important here, these are two very different types of methods - and as I described, a single channel per namespace makes the most sense for multiple namespace handling anyways.

Changing GetAll is out of scope here and so I would defer that to a discussion. I don't think this feature should be blocked on this at all

Copy link
Member

Choose a reason for hiding this comment

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

Try to imagine how the implementation of the protocol that relies on multiple namespaces

Having multiple subscriptions and a generic logic that parses them they will directly know from which namespace the blob comes.

blob/service.go Outdated Show resolved Hide resolved
blob/service.go Outdated Show resolved Hide resolved
blob/service.go Show resolved Hide resolved
@ramin ramin self-requested a review July 2, 2024 09:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:blob kind:feat Attached to feature PRs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants