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

Validation of pubsub messages? #16

Open
sim31 opened this issue Feb 15, 2023 · 5 comments
Open

Validation of pubsub messages? #16

sim31 opened this issue Feb 15, 2023 · 5 comments
Labels
question Further information is requested

Comments

@sim31
Copy link

sim31 commented Feb 15, 2023

As I understand agregore browser enables pubsub subscriptions through fetch API.

I'm planning to use agregore for my project, but in addition to using pubsub it will eventually need to validate messages received through pubsub. I read that it is possible to tell libp2p which messages are valid so that invalid ones are not propagated. This would be useful for my use case. Searching around, I found that the way to do it in js is probably through datastore-pubsub.

I could probably add a dependency to js-datastore-pubsub for my webapp, but I see agregore already depends on ipfs-core, which depends on datastore-pubsub. And I was planning to use fetch API provided by agregore anyway.

Would it make sense for agregore to provide datastore-pubsub like API? Any advice for a solution in the short-term?

@RangerMauve RangerMauve added the question Further information is requested label Feb 15, 2023
@RangerMauve
Copy link
Owner

At this stage, I would just perform the validation of the data upon receiving it in your JavaScript once you get the message in your EventSource.

Getting the validation logic from JS into the p2p protocol handler is a bit hard to do at the moment. We're making use of js-ipfs-core for wrapping over libp2p's pubsub right now and it looks like there's no interface there for doing extra validation the way there is in Go. https://github.com/ipfs/js-ipfs/blob/master/docs/core-api/PUBSUB.md

What sort of validation logic were you hoping to do? Checking that the structure makes sense?

@sim31
Copy link
Author

sim31 commented Feb 15, 2023

I can do the validation after getting the message from EventSource. I'm more worried about the propagation of messages. Pubsub topic strings will be public and I'm wondering what will happen if someone starts spamming with invalid messages to that topic.

Does the ipfs node within agregore automatically propagate messages they subscribe to? If detect invalid only in my logic that won't stop the propagation of the messages I imagine, right?

@sim31
Copy link
Author

sim31 commented Feb 15, 2023

To answer your question about validation logic: validation might depend on some objects which will have to be fetched from IPFS by some peers. Some peers might already have it. I'd like peers who already have to not propagate invalid messages, so as to not make new peers do unecessary fetching and validation.

@RangerMauve
Copy link
Owner

Do you have any thoughts on what the fetch/EventSource interface should do to enable this?

It feels like we would need to add some way to execute arbitrary code that gets passed in from JS (maybe WASM?) but that also feels like major overkill.

Is this a major blocker for getting your app started / do you anticipate it being mandatory for things to work within the next 6 months or so?

@sim31
Copy link
Author

sim31 commented Feb 16, 2023

It's definitely not a blocker to get started. I just suspect it might become an issue later. I'm also considering some workarounds using IPNS.

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

No branches or pull requests

2 participants