17

In recent years new protocols for externalising data have become popular. Schemes like Protocol Buffers & Avro are in common use.

Stellar uses XDR, a scheme from the 1980s which is (as far as I can tell) not popular in recent years.

I don't question the decision, but I do think there might be some interesting and compelling reasons for choosing XDR over other formats.

Why was XDR chosen?

18

This was not an easy choice indeed. It sounded weird at first to use something like XDR but it ended up winning compared to others for a few reasons:

  • there is an RFC and it's extremely simple. The implementations have very little attack surface and the risk of having strange inconsistencies between implementations is very low.
  • the serialized form (on the wire) is entirely specified in the RFC. This is extremely important as we're computing cryptographic hashes of the content: all implementations will serialize the same thing the same way.
  • it's extremely strict when it comes to missing fields or additional fields. When the protocol evolves, it ensures that if code was not written with explicit support for that version it will just fail when deserializing the data. One of the core tenets that we tried to apply when designing the new protocol was to keep users safe; in this case it ensures that code running on top of the Stellar network is always getting the inputs that the developers intended.
  • 2
    Great answer, thank you. I was frustrated by the XDR serialization routines at first, but with this additional info it makes perfect sense. Old school technology might not have the shiny new object appeal, but the fact that it's battle tested can't be underestimated. – Ross Bates Jan 23 '18 at 22:41
  • 1
    Why not protobuf? What are the reasons it was less suitable? – lazycat Jan 25 '18 at 9:28
  • 2
    It was the runner up but it fell short at the time (I don’t know where it’s at these days) on the serialized form because it was not fully specified for use in crypto (ie, it was only specified enough to be an RPC framework); also in order to be more strict we would have had to basically disable most of the cool features that it has for example to make it fail when encountering unknown fields – MonsieurNicolas Jan 25 '18 at 15:16
  • 1
    After having worked a lot with both XDR and protobuf recently in the context of Stellar I'm glad they chose XDR since you can easily write a parser for it. Protobuf requires a lot of additional libraries/tooling and is still evolving. – ZuluCrypto Jan 25 '18 at 18:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.