-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
age
logic for events is broken
#8429
Comments
AFAICS this is specced. See https://spec.matrix.org/v1.2/rooms/v1/#event-format through https://spec.matrix.org/v1.2/rooms/v9/#event-format. The |
Some spec history:
|
Hrm, it seems like it might have got a bit more specced since this issue was first opened. Note that https://spec.matrix.org/v1.1/client-server-api/ doesn't mention But yes, it seems pretty clear now. |
FTR, this caused a bug on android, where verification requests were discarded as their age couldn't be determined (no age field other federation). It's not really clear if the field is mandatory. As per spec a
Can't find any reference for verification via room messages, but the code was expected to use the |
The spec does not mark
I don't think it would make sense to do this on a room-by-room basis? Also, it's really confusing that we have both an age and a timestamp. I think I'm leaning towards "we should remove this from the spec and Synapse", unless anyone can explain how this is useful for clients? |
Here is some information about where this gets touched meaningfully(AFAICT). FTR, I couldn't tease this behavior out of Complement anywhere during transmission, however I was able to find it exposed just before a
The ones marked with checks are the ones I suspect. The rest are easy to discount, as they look to be doing what they are 'supposed' to do(provided that (RECEIVING)
(SENDING)
Here is a log line demonstrating the
From a Complement run, so not important information to worry about redacting.
I was able to format it with |
There is a bunch of code inside synapse which tries to add an
unspeccedage
field to events.The intention of such a field is to try to mitigate problems with incorrectly-set clocks. Rather than saying "this event was created at 12:00", we can say "this event was created 10 minutes ago"; for certain applications (notably VoIP signalling), that information is more useful.
It would be more useful still if it was actually specced, but that's a side-issue.Considering a flow from client to client over federation, I think the intention of the implementation is this:
age_ts
.age_ts
from the event and replaces it with a rawage
field giving the number of milliseconds that have elapsed sinceage_ts
.age_ts
based on the time it received the transaction.age_ts
withage
.Assuming that a given server's clock is consistently inaccurate, it is kinda plausible, though obviously it neglects any delays between formatting transactions and them being received at the destination.
However, I suspect it doesn't actually work. The C-S code in synapse stores
age_ts
in theunsigned
property of the event (which is probably correctno, we haveinternal_metadata
for this sort of thing); however, the logic in the federation sender which tries to replaceage_ts
actually looks for the property in the top level of the event rather than inunsigned
. It therefore leavesage_ts
in place inunsigned
. The federation receiver logic will accept anage
in eitherunsigned
or at the top level, and replaces it with anage_ts
at the top level. The C-S code doesn't know to strip it out of there, which means it leaks out to the C-S API (see matrix-org/matrix-spec-proposals#2685).This has clearly been broken for ages, and nobody has really noticed.
Given none of it is specced, I am inclined to say that we should strip it all out.(Update 2023/01/17: it's specced nowadays.)The text was updated successfully, but these errors were encountered: