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

Annotate internal function IDs #14050

Merged
merged 1 commit into from Apr 12, 2023
Merged

Conversation

r0qs
Copy link
Member

@r0qs r0qs commented Mar 15, 2023

fixes #13425

@r0qs r0qs force-pushed the contract-ast-internal-function-ids branch from 6858ace to 9d39d00 Compare March 15, 2023 13:38
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a fairly large test case, which in turn generates an even larger AST JSON. Could this be split into multiple test cases? (I'm fine with also leaving this one as an all encompassing one as well, but additional smaller test cases would be nice)

Copy link
Member Author

@r0qs r0qs Mar 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test was extracted from:

BOOST_AUTO_TEST_CASE(indirect_calls)

But I'm not sure how to split it, I mean, the test is only to check it the internalFunctionID is exported for internal functions, but I'm not really sure of all the cases that this will be trigger, do you have any suggestions of corner cases?

I could also just simplify it and have only (f)();

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not even talking about edge cases per se - e.g. you could have a separate case with just a free function (like free1 in the current test case), which would yield a much smaller AST. Same thing goes for a minimal contract with one internal function, and one public/external, where the AST will again be quite small, and the internal function will have the internalFunctionID member, whereas the public/external won't. And so on, and so on.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, for the current AST tests we have, any new tests comes with like 1000 lines of boilerplate, so splitting this up into several cases actually makes things even worse :-). In the future, we should really have targetted AST tests that just selectively check for a subset of fields - me being too lazy to write something like that is actually the blocker on nice stuff like #13378...

So if you're up for it, you can just do that for this PR - but I'm also fine with keeping the large test case here and dealing with that separately (it should be a separate PR no matter what anyways). Maybe better to move this forward like it is and then build a nicer way to test json ASTs only afterwards to be sure to finally get this out in the next release (Truffle has been asking for these function IDs for ages now).

libsolidity/ast/ASTAnnotations.h Outdated Show resolved Hide resolved
@r0qs r0qs force-pushed the contract-ast-internal-function-ids branch from bcb97dd to 2f957ac Compare March 17, 2023 17:32
@ekpyron
Copy link
Member

ekpyron commented Mar 20, 2023

Apart from the comments above, this is mostly ready I think and mainly missing a changelog entry.

@ekpyron
Copy link
Member

ekpyron commented Mar 20, 2023

We can also try and draw @haltman-at's attention to the binaries in this PR, resp. to the AST in https://github.com/ethereum/solidity/blob/96dee72fe5b5fb6e68fbe25cdf00c3470a2ce794/test/libsolidity/ASTJSON/ast_internal_function_id_export.json (and the internalFunctionID fields in that) to confirm that this is a good enough fix for #13425 for the needs of the Truffle debugger.

@r0qs r0qs marked this pull request as ready for review March 20, 2023 17:01
Changelog.md Outdated Show resolved Hide resolved
@r0qs r0qs force-pushed the contract-ast-internal-function-ids branch from 1fa878d to 8c048e1 Compare March 20, 2023 18:24
Copy link
Member

@ekpyron ekpyron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can squash this and then merge this (although I'd wait for a bit to see if @haltman-at is around for confirming that this in fact solves #13425 for them). Also nice that pregenerating the IDs like this actually ends up being much simpler than what we used to do on-the-fly.

… dispatch.

Co-authored-by: Daniel <daniel@ekpyron.org>
@r0qs r0qs force-pushed the contract-ast-internal-function-ids branch from 8c048e1 to a0e62bb Compare March 20, 2023 19:16
@github-actions github-actions bot added the stale The issue/PR was marked as stale because it has been open for too long. label Apr 6, 2023
@r0qs r0qs removed the stale The issue/PR was marked as stale because it has been open for too long. label Apr 11, 2023
@r0qs
Copy link
Member Author

r0qs commented Apr 11, 2023

@haltman-at we would love to hear your comments on this before merging. If the PR indeed fixes the issue for your use case.

@r0qs r0qs self-assigned this Apr 11, 2023
@ethereum ethereum deleted a comment from github-actions bot Apr 11, 2023
@ekpyron
Copy link
Member

ekpyron commented Apr 12, 2023

I think this should solve the issue, so I'm merging this.

@ekpyron ekpyron merged commit 6bc6ae9 into develop Apr 12, 2023
@ekpyron ekpyron deleted the contract-ast-internal-function-ids branch April 12, 2023 12:11
@haltman-at
Copy link
Contributor

(FWIW, I was on sabbatical for a few weeks and so didn't have a chance to test this out, but I'll assume you all know what you're doing. :) Will still try to test it before release still if I have a chance I guess...)

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