IntersectMBO / plutus

The Plutus language implementation and tools

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add useful conformance tests for syntax of builtins

nielstron opened this issue · comments

Describe the feature you'd like

Currently the conformance tests for lists and data objects do fail. They are expected to fail.
https://github.com/input-output-hk/plutus/blob/47bad0842ba7611ed16a48b32ab1959da4c213db/plutus-conformance/test-cases/uplc/evaluation/builtin/constant/data/dataInteger/dataInteger.uplc.expected

However, there actually is a notation to parse data and lists.
Here are some examples that don't fail.

(con data #00)
(con (list bool) [True, False])
(con (pair data integer) (#40, 0))

Describe alternatives you've considered

No response

Where data is encoded as the CBOR hex representation of the underlying datum. Also note that due to underspecification of the UPLC Syntax, independent projects like aiken, have brought forward their own syntax for UPLC

Thank you for the report.

However, there actually is a notation to parse data and lists.
Here are some examples that don't fail.

(con data #00)
(con (list bool) [True, False])
(con (pair data integer) (#40, 0))

OK, it's a bit complicated and ridiculous. It's true that all these examples indeed have the specified syntax, however:

  1. we're considering changing it, see #4751
  2. parsing of lists and pairs is supported, but parsing of data is not at the moment

The reason why the current situation is a mess is that we've never really cared about the syntax of PLC/PIR, only about its serialization format. However given the number of complaints from the community we're reconsidering this approach.

We'll discuss the issue and I'll get back to you afterwards.

To give you an update, we've been discussing the issue, but it's going so slowly due to everyone being overbooked with other stuff. But it's being worked on, hopefully we'll see a light at the end of the tunnel at some point.

A side note: Aiken has also gone forward and defined notation for the underspecified pairs, lists and datas

As it seems now, the UPLC notations are already diverging and will likely diverge even more

https://aiken-lang.org/uplc/syntax

In Syntax of builtins #4751 I've added a description of syntax for constant terms. It remains to update the parser and the tests for data. (The syntax for pairs and lists is the same as the current supported one, and the corresponding tests have been updated).

commented

I just want to say (from the aiken side) that we don't intend for the implementation we have to push this in any particular direction. Whatever the plutus team lands on I'm happy to follow 🫡.

I also wouldn't mind helping with this on the haskell side, I'm not very sharp with haskell but I'm somewhat familiar with where the parser is for this already. Not sure if this one is open to outside contributors.

@rvcas

I just want to say (from the aiken side) that we don't intend for the implementation we have to push this in any particular direction. Whatever the plutus team lands on I'm happy to follow 🫡.

Great to know, thanks!

I also wouldn't mind helping with this on the haskell side, I'm not very sharp with haskell but I'm somewhat familiar with where the parser is for this already. Not sure if this one is open to outside contributors.

It wasn't a big task, it's just that we couldn't get around to it with all the other stuff, so collaborating with you would be a comparable amount of effort for us. But thank you a ton for proposing and I apologize for not responding earlier.

This whole issue was finally resolved in #5391 where we implemented the specified syntax for builtins (including lists, pairs and Data). Conformance tests are updated, so as long your parser passes the conformance test suite, you should be fine.

Sorry it took so long!

Closing the issue as "done", but do feel free to reopen if you disagree.

commented