-
Notifications
You must be signed in to change notification settings - Fork 578
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
Generalise event lifetime preferences #236
Comments
I think the "d" tag is good to be queryable. That way a client can ask for a given note by referring to the "d" tag rather than the changing event id. I have no idea what "d" stands for, maybe "document", as I think one of the original use-cases for P.R,E. was editable documents. |
As an aside/old-man-complaint... I am not convinced of the utility of general purpose "expiration" tag. Just send a deletion event when you want your event to expire. Puts unnecessary burden on the relays IMO. Feel like most users will opt to not use the expiration "feature" and the relay will just always be checking for events to delete without ever being able to delete very much. On the other hand, ephemeral events is super relay friendly 👍 Agreed that it would be nice to have an ephemeral event related to kind 1. Naively could just define 20001 as ephemeral kind 1. I guess it is not a very principled solution though. and many unanswered questions viz UI |
Also love |
Thank you! You're completely right about the I partially agree about not using
It does add a bit of extra load on the relays, but in strfry I've added an index on this field so the periodic checking for expired events is very inexpensive. Good point that an event of |
I like this. It is sad that we made bad choices in the past. |
Seems easy enough to implement. Will need to reserve the Also Seems like Perhaps could add custom query rules to NIP-40, something like, in the filter JSON keys like:
Obvious interpretation as filters on the "expiration" tag. Events which do not have the expiration tag should not be returned etc etc. Would be kind of cool. |
Also, to reduce long-lived spam, popular people like |
EDIT (mis-read this). This could work too. What would the different possible values for expiration represent, how ephemeral it is? :) Maybe instead of overloading TBH I can't think of many use-cases for users querying by expiration and/or ephemeralness. I agree your method for querying numeric ranges is cool, but I don't think we should burden relay implementors with that unless we have some really solid use-cases. |
Yes I just figured that since it would be straightforward to check if Re: querying for expiring events. Yes I agree that it would be annoying to coordinate all the different relay codebases to add a custom filter parsing rule just to query Re: changing to If a One potential source of conflict is if people put Also a bit strange if kind If the Perhaps there could be a "fake" relay hint added to One more question. Do you specify if there is an event with |
I think it makes the most sense for events with default-replaceable kinds to be treated as NIP-33 events. So if there is no d tag it effectively uses an empty string as the replacement key. That way the interpretation of events without d tags does not change. If people start adding events with non-empty d-tags, then these new events will exist in parallel with the events without d-tags. I agree this might cause some confusion for clients that only expect one kind 3 event, but clients really ought to handle this case anyway, since a relay does not have to implement NIP-02 (and even then, NIP-02 says replacement is "SHOULD").
Agreed, deletions is an interesting case. NIP-09 says "Publishing a deletion event against a deletion has no effect. Clients and relays are not obliged to support "undelete" functionality." Which doesn't seem definitive either way to me. Personally I see no reason not to support "undeletes" (either with subsequent NIP-09 deletions or with d-tags). The relay-side code is even easier that way. Deletes are actually another interesting use-case for composing ephemeral events. The natural processing of an ephemeral deletion would be to delete the referenced events but not store the deletion event itself -- this might be useful for cleaning up old junk from relays without leaving a bunch of delete events lying around. Of course, somebody could re-submit the old events if they kept copies of them, but that's not always a concern. I can't really think of any other events that shouldn't compose with ephemeral events. As mentioned above, I believe you can always emulate ephemeralness with a NIP-09 deletion anyway. Somebody making a reply to an ephemeral event -- that's actually a tricky one and I could see it causing problems, although these problems are much the same as exist now when replying to an event that subsequently gets deleted. I think your suggestion about flagging ephemeral events in the UI is a good one. If Thank you for thinking through all these edge cases! |
Alright. I am on board! Excited to hear what others think. 👍 |
I love this 🔥 Thanks @hoytech for pointing this out |
d is for deduplication |
I'm in agreement as well. |
OK, I think that gives us enough quorum to proceed with this. |
On the other hand I think this is a bad idea now. We don't want to create unnecessary burden on clients by allowing every event to become instantly replaceable. If |
Is it better for kinds to opt-in (as part of their NIP) to non-replaceability? And then have relays ignore the |
Who understands these things except for the developers/programmers/and coders? |
Rise from grave \o/ cause this issue is masterpiece.
Yes. Though what makes an event "truly" replaceable for the viewing user is using an For example, when clients use |
The code for dealing with replaceable and non-replaceable events is very different at a fundamental level. Replaceable events have a big overhead. This proposal would allow anyone to turn any event kind into replaceable and that would cause havoc in all client and relay implementations. |
The original proposal for NIP-16 actually had an This was removed due to it increasing complexity: What would you do if you received a replaceable event for a kind that had a non-replaceable event also? What if the replaceable event was also ephemeral? So on. This would also cause problems for applications that have some expectations, such as kind 1s being able to be marked as ephemeral. |
No, it depends. Bear with me.
What happens is that Coracle and Gossip' replies to Amethyst's See my point? |
Simple:
edit: the ephemeral part, don't see any problem. If client sends event with ["expiration", " edit2: this issue wants relays to treat expiration=0 as ephemeral (broadcast received event to whoever is listening with the right sub filter when relay receives it), though I think today some relays would treat it as expired and maybe don't broadcast it? |
Yes, but couldn't your point be reduced to "anyone can do anything and if two people happen to do the same thing then they will be compatible, therefore we don't need any standards"? |
From a client perspective:
As a major plus, all versions of the "fake replaceables" are kept. Event kind ranges can be deprecated. |
Perfect. Though I'd say replaceables should set |
The opposite. In a reality where kind range doesn't dictate replaceability of events for relays (relays would rely solely on The NIP where kind X is speced would need to define if kind X is regular, replaceable or PRE (and if ephemeral). This info would be used by clients to:
|
Example, all NIPs could add a table like below example for NIP-02: Kinds used by this NIP
__ Example of how such table could look like for NIP-28: Kinds used by this NIP
|
... Just use kind ranges. They are self documenting and don't need relays to handle all types of weird shit. |
@Semisol from the thing you quoted: "this info would be used by clients". Relays would not need to care about what NIPs other than NIP-01 say. Would not need to differentiate between event kinds. I will give an example of how NIP-01 would look like brb. |
How a new NIP-01 lore could look like: NIP-01[...All mambojambo about basic things such as relays, events, clients, keys, event structure, searchable tags and non-searchable, how to calc event id and sign the id, client-relay and relay-client messages...] Relay event treatmentRelays treat events received through a client-relay "EVENT" message the same way: no matter the kind, The only distinction made is between events with and without a Client event treatmentRelay developers may ignore this section. For clients, event kinds are an alias for their real meaning. For example, There are three types of events: regular, replaceable (RE) and parameterized replaceable events (PRE). They are treated differently by clients, when structuring them, referencing them and when fetching them from relays. To know the type of a specific event kind, check the NIP where the event kind is introduced. Event structure by type
Event referencing by type
Event fetching by type
|
Background
Implementing NIP-33 and NIP-40 for my relay (strfry) caused me to think a bit about user-specified event lifetime preferences. We can roughly classify these into the following categories:
Note that if a relay supports NIP-09 deletions then all of the above could in principle be implemented with delete events:
By using deletions, any of these categories of event lifetimes could be implemented for events of any kind.
Problems
Replaceable, parameterised replaceable, and ephemeral events are specified to only apply to events within ranges of kinds. To me this seems sub-optimal:
Importance of parameterised replaceable events
I believe NIP-33 is a very important specification and will be heavily used by future protocols.
The NIP itself doesn't contain any use-cases, but as a basic example, I could imagine using these types of event lifetimes for sharding and segregating your kind-3 contact lists. You could imagine having multiple different contact lists, like
family
,friends
,co-workers
,randos1
, andrandos2
. This would future-proof contact lists growing too large, improve the efficiency of updates, and provide a natural organisation schema for users.Furthermore, if it were possible to use parameterised replaceable events on kind 3, this would all work with minimal client changes and a reasonable backwards compatibility story. I'm not saying this is a good idea and we should do it, just pointing out the possibility.
Note that replaceable events are just a special case of parameterised replaceable events with a static replacement key.
Proposal
Here are two minor changes that I believe would generalise the protocol:
expiration
tag with value0
. This would indicate that the event is intended to be ephemeral, and should be treated as described in NIP-16, regardless of kind.d
tag on events of any kind. This indicates the event is to be treated as a parameterised replaceable event as described in NIP-33, using the value of this tag as a replacement key. This works for any kind, but the kinds of the replaced and replacing events must still match. The absence of ad
tag does not result in an implicit emptyd
tag as described in NIP-33.Disadvantages
d
tag.d
tag and unintentionally have multiple events of the same kind on a relay. However, when querying, clients that expect replaceable behaviour could take care to select the latest one (bycreated_at
). Additionally, the user could correct this situation using a NIP-09 deletion.Back-compat
The two above changes would not break any of the existing NIPs. However, I think it could make sense to create a NIP that supersedes NIPs 16 and 33, and mark the coupling of event lifetime with the 10k kind-ranges deprecated.
Additionally, here is how a relay could internally implement backwards compatibility using the
d
andexpiration
primitives:expiration
tag with value0
added to the front of the tag list. NIP-40 is clarified to specify that in the case of multipleexpiration
tags, the first tag's value is to be used."d"
tags with""
values added to the end of their tags list.History
replace
tag instead of NIP-33'sd
tag, but this would not have been queryable as pointed out by @barkyq below.The text was updated successfully, but these errors were encountered: