fixing the non-monotonic timestamps
As @Fabián Heredia Montiel describes in this thread @elavoie managed to travel back in time and create a message with a timestamp that was less than a the timestamp on the previous message. I wrote a script to check for other occurances of this, and found 4 other cases, all between 19th december 2017, 7th feburary 2018.
Some people have argued for abandoning the idea of monotonic timestamps. Let me be clear, I do not like that idea, but I will not pronounce it "off the table".
However, I do insist on some things:
- The protocol should aim for stability, we try to avoid changes that cannot be unmade.
- We should avoid designs that include aspects that are difficult to change, but we can't avoid this completely. examples include: maximum message size, number of recipients, wether feeds can fork, and other message validation rules such as wether timestamps may decrease. These changes must be considered very carefully before making them.
- Sometimes, there has been a bug or otherwise messages get through that ought to have been invalid, such as, messages that excede the character length, by having utf-8 characters, because javascript's string length is the number of characters, not the number of bytes. Although these things are embarrasing, every protocol has things like this.
- eventually, once other parts are solid, we should create a (probably) binary feed encoding that fixes all those problems. And that can be the default encoding for new feeds. (we'll always need to support the old formats, if people want to read the old messages, unfortunately)
- when we realize that we messed something up (such as this timestamp thing) our response should be proportional to the scale of the problem.
Okay, those I think are loosly the principles we should follow to design a stable protocol.
On this specific issue, I want to say: monotonic timestamps are good. Firstly, requiring the timestamps to be monotonic also implies that they are unique. This is a very useful property in a database! If there are no restrictions on timestamps, it's an invitation for people to use whatever timestamp they like, in ways that affect clients in weird ways!
But at the same time, since it seems we did allow messages to disorder for a period (before ssb-validate@3.0.7) we should make that official - messages from that period have the order requirement relaxed. Okay, for this period, timetravel was briefly allowed and inparticular @elavoie used it.
I realize this makes the message format weirder and weirder, yes, this is embarrasing. But I am doing my best here. Okay various javascript quirks are sneaking in, and because of immutability we can't remove some of them. All protocols have things like this. Lets start thinking about what the ideal encoding might look like, and implement an move to that later. In the mean time, lets solidify what we have to, including those mistakes, where necessary.