On Fri, Jun 26, 2020 at 10:44 AM 'Bartek Nowotarski' via Stellar
Developers <
stell...@googlegroups.com> wrote:
> Big one: have you considered Reverse Polish notation instead of the tree-like structure for ClaimPredicate? I think it would be more powerful if we want to extend it in the future and would make running and validating it easier. It would be also easier to represent in downstream systems (list vs tree).
Hmm, I think RPN wouldn't bring anything new to the table here, and
would incur additional costs. Specifically:
- XDR is already a serial (pre-order) encoding of a tree. Downstream
clients already need to be able to deserialize XDR in order to work
with any of this. Adding a new RPN (post-order) encoding for sub-trees
within XDR increases the burden on downstream clients, doesn't reduce
it.
- We already have an idiom for versioning / extending XDR that works
ok: version unions. It's not beautiful but it does work and explicitly
defines version-compatibility points in need of coverage.
- If you want to delay XDR-decoding of some sub-tree, say either to
enforce a "whole sub-tree" size limit or perhaps as an extreme case of
versioning "everything" in a sub-tree, serializing an "inner" XDR tree
into an opaque array embedded in an "outer" XDR structure also works.
We do this in a few places already (eg. when signing payloads or
versioning upgrades).
- XDR definitions have strong well-formedness and type-compatibility
rules baked into them already. A new encoding for sub-trees would need
additional rules around this, eg. to prohibit [pubkey, pubkey, +] as
an operator-operand-incompatible tree or [1, +] as a non-well-formed
tree.
-Graydon