Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Output Yul ASTs #9590

Closed
Tracked by #13720
leonardoalt opened this issue Aug 6, 2020 · 14 comments · Fixed by #14177
Closed
Tracked by #13720

Output Yul ASTs #9590

leonardoalt opened this issue Aug 6, 2020 · 14 comments · Fixed by #14177
Labels
easy difficulty good first issue candidate Could be a "good first issue" but something is blocking it or it has open questions. low effort There is not much implementation work to be done. The task is very easy or tiny. medium impact Default level of impact must have eventually Something we consider essential but not enough to prevent us from releasing Solidity 1.0 without it. protocol design 🔮 Potential changes to ABI, meta data, standard JSON

Comments

@leonardoalt
Copy link
Member

It would be helpful/essential for verification tools to have access to the Yul ASTs that are generated throughout compilation via Yul.

@leonardoalt leonardoalt changed the title Output Yul AST Output Yul ASTs Aug 6, 2020
@chriseth
Copy link
Contributor

chriseth commented Aug 6, 2020

Related to #9053

@chriseth
Copy link
Contributor

I'm wondering - is it really essential or would it also work to run solidity in yul mode and output the ast?

@leonardoalt
Copy link
Member Author

Which ast would that be? What I'm imagining is that all the Yul compilation steps could be exported:

  • Solidity -> Yul
  • Yul -> Optimized Yul
  • Optimized Yul -> Dialect Yul (if applicable)

@cameel cameel added feature good first issue protocol design 🔮 Potential changes to ABI, meta data, standard JSON labels Oct 2, 2020
@axic
Copy link
Member

axic commented Nov 26, 2020

Which ast would that be? What I'm imagining is that all the Yul compilation steps could be exported:

Solidity -> Yul

This is called ir in standard json, and displayed via --ir on cli.

Yul -> Optimized Yul

This is displayed on cli via --ir-optimized.

Optimized Yul -> Dialect Yul (if applicable)

This is not available yet.

@chriseth
Copy link
Contributor

I'm still not sure what this issue is about and what functionality we are really missing here.

@Marenz
Copy link
Contributor

Marenz commented Sep 21, 2021

As far as I understood, it's about the YulAST, being output as JSON just like our Solidity AST can be exported...

@cameel
Copy link
Member

cameel commented Dec 10, 2021

This feature was also requested in #11043.

@bendyarm
Copy link

I believe this issue has its roots in a discussion @acoglio and I had with @leonardoalt .

In order to verify the correctness of specific applications of Yul optimizers, you need the before and after Yul code.

Right now, the "standard JSON" form can contain "ir" and "irOptimized", but those are source code, not ASTs. Yul surface syntax is unambiguous so that's not too bad. It does require that we trust the prettyprinter and that we have a formal grammar and parser. (We have those now. E.g., the ABNF grammar could be useful to others.)

However, it would be higher assurance if, in addition to the before and after Yul code, the before and after internal ASTs (that are input and output to the optimizers) could be serialized to the JSON output structure, as @Marenz suggests.

@cameel

This comment has been minimized.

@cameel cameel added low effort There is not much implementation work to be done. The task is very easy or tiny. medium impact Default level of impact must have eventually Something we consider essential but not enough to prevent us from releasing Solidity 1.0 without it. labels Sep 26, 2022
@cameel cameel added good first issue candidate Could be a "good first issue" but something is blocking it or it has open questions. and removed good first issue labels Dec 5, 2022
@gnidan
Copy link
Member

gnidan commented Jul 11, 2023

I notice this is closed, but I don't get any output for irAst for *.yul files. Does this require --via-ir? Seems like a separate concern... standalone Yul files don't always go through the new IR pipeline, after all.

@cameel
Copy link
Member

cameel commented Jul 12, 2023

@gnidan irAst is only for *.sol files. That's to distinguish it from the ast output, which gives you the Solidity AST. For Yul you just use the ast output to get the AST.

It's independent of --via-ir. If you don't use this option, you still get the AST of IR produced by the new pipeline but that IR is just no what what the bytecode was generated from.

@haltman-at
Copy link
Contributor

haltman-at commented Jul 26, 2023

Hey, so I just tried this with Solidity 0.8.21, and I'm still not getting ASTs for my Yul sources? I'm not using irAst or anything, I'm just using the usual ast output selection, but I'm not getting anything.

Edit: It's not just that there's no AST; it's that there's no sources output at all, only contracts and errors! Should I suggest reopening #11043...? Or is there some other way I'm supposed to do this for Yul...?

Edit: Oh, I see -- I have to request the AST at the contract level, instead of at the file level. (Even though it ultimately appears in sources, not contracts.) That seems like a bug? But at least it's workable...

@haltman-at
Copy link
Contributor

Oh, yikes, here's a bug -- the sources output gives the ID as 1, rather than zero! Oy...

@haltman-at
Copy link
Contributor

(OK, I filed two issues for these -- #14452 and #14453.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
easy difficulty good first issue candidate Could be a "good first issue" but something is blocking it or it has open questions. low effort There is not much implementation work to be done. The task is very easy or tiny. medium impact Default level of impact must have eventually Something we consider essential but not enough to prevent us from releasing Solidity 1.0 without it. protocol design 🔮 Potential changes to ABI, meta data, standard JSON
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants