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

(Need help) AST parser fails due to missing "ast" field #191

Closed
TilakMaddy opened this issue Feb 27, 2024 · 7 comments · Fixed by #192
Closed

(Need help) AST parser fails due to missing "ast" field #191

TilakMaddy opened this issue Feb 27, 2024 · 7 comments · Fixed by #192

Comments

@TilakMaddy
Copy link
Collaborator

TilakMaddy commented Feb 27, 2024

Step 1. Nuke the ~/.svm folder (where foundry installs solc)
Step 2. foundryup
Step 3. forge build

Then AST parser fails

Sample of the output of cli/reportgen.sh

Error reading Foundry output file: /Users/tilakmadichetti/Documents/OpenSource/realaderyn/tests/contract-playground/out/DepositContract.sol/ERC165.json: missing field `ast` at line 1 column 3887
Error reading Foundry output file: /Users/tilakmadichetti/Documents/OpenSource/realaderyn/tests/contract-playground/out/IContractInheritance.sol/IContractInheritance.0.8.20.json: missing field `ast` at line 1 column 2921
Error reading Foundry output file: /Users/tilakmadichetti/Documents/OpenSource/realaderyn/tests/contract-playground/out/KeccakContract.sol/KeccakContract.json: missing field `ast` at line 1 column 15512
Error reading Foundry output file: /Users/tilakmadichetti/Documents/OpenSource/realaderyn/tests/contract-playground/out/DepositContract.sol/IDepositContract.json: missing field `ast` at line 1 column 7661
Error reading Foundry output file: /Users/tilakmadichetti/Documents/OpenSource/realaderyn/tests/contract-playground/out/Counter.sol/Counter.json: missing field `ast` at line 1 column 7588
Error reading Foundry output file: /Users/tilakmadichetti/Documents/OpenSource/realaderyn/tests/contract-playground/out/2/Nested.sol/Nested.json: missing field `ast` at line 1 column 4285
Error reading Foundry output file: /Users/tilakmadichetti/Documents/OpenSource/realaderyn/tests/contract-playground/out/Counter.sol/Counter.0.8.20.json: missing field `ast` at line 1 column 7588
Error reading Foundry output file: /Users/tilakmadichetti/Documents/OpenSource/realaderyn/tests/contract-playground/out/UniswapV2Swapper.sol/UniswapV2Swapper.json: missing field `ast` at line 1 column 27405
Error reading Foundry output file: /Users/tilakmadichetti/Documents/OpenSource/realaderyn/tests/contract-playground/out/UnsafeERC721Mint.sol/UnsafeERC721Mint.json: missing field `ast` at line 1 column 60363

Any help is greatly appreciated : )

I am concerned that for nyth projects, in the testing section we pass the path to json file. Can this be something we can avoid ?

@TilakMaddy
Copy link
Collaborator Author

TilakMaddy commented Feb 28, 2024

@alexroan It appears to me that the new format of json files output by solc doesn't contain ast node

example :

Error reading Foundry output file: /XXX/tests/contract-playground/out/Counter.sol/Counter.json: missing field `ast` at line 1 column 7588
Error reading Foundry output file: /XXX/tests/contract-playground/out/2/Nested.sol/Nested.json: missing field `ast` at line 1 column 4285

I am finding it difficult to reproduce json output

Do you mind taking a look at it ?

@alexroan
Copy link
Contributor

alexroan commented Feb 28, 2024

Ah this could have been caused by this: #183

Some AST Nodes don't actually have an ID field @TilakMaddy . This error may be occurring during the parent->child link construction where IDs are crucial.

You're right, output files don't actually produce an AST object in the json after running foundryup

@alexroan
Copy link
Contributor

foundry-rs/foundry#7197 <- Here's the culprit

I've added this PR to fix this issue: #192

@TilakMaddy
Copy link
Collaborator Author

Thanks Alex, for showing me where it originated!

@gakonst
Copy link

gakonst commented Mar 1, 2024

Sorry about that folks - we should have notified users!

@TilakMaddy
Copy link
Collaborator Author

TilakMaddy commented Mar 1, 2024

Helloi @gakonst ! It's okay ... It's been fixed now : )

I have a small question for you. Would greatly appreciate any thoughts.

So right now, we're shelling out forge build --ast to generate the out folder with all the contracts' jsons.

I was wondering if it's possible that we can use forge codebase as a rust dependency somehow in the Cargo.toml file and make this operation happen ...

What do you think ? Good idea / bad idea / doesn't matter....haha which one is it.:P ??

@alexroan
Copy link
Contributor

alexroan commented Mar 9, 2024

I like where your head is at. Perhaps open an issue/PR in the foundry codebase @TilakMaddy ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants