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

AST Comparison API #686

Open
7 of 23 tasks
Tracked by #314
jubnzv opened this issue Aug 14, 2024 · 2 comments
Open
7 of 23 tasks
Tracked by #314

AST Comparison API #686

jubnzv opened this issue Aug 14, 2024 · 2 comments
Assignees
Labels
api Tact's TypeScript API for third-party tools enhancement New feature or request

Comments

@jubnzv
Copy link
Member

jubnzv commented Aug 14, 2024

We need an API that provides a way to compare any Tact AST:

  • AstComparator:
    • Provide an API to check AST equivalence without renaming
  • AstHasher: Write the hashing module that doesn't take names into account
  • AstRenamer: Canonicalize binder names introducing something like de Bruijn indices
    • Rename elements
      • Top-level/contract/trait entries
      • Native functions: rename to match their original names.
      • Struct/message/contract fields
      • Function arguments
    • Handle dependencies
      • Build dependency graphs for the AST entries. This is required to rename and sort them properly. (TODO: create a separate module for this?)
      • Provide topological sort of the renamed entries. We have to write additional logic to handle mutually recursive function calls.
    • Rename uses of renamed elements in the source code
  • AstSorter: Improve the sorting routines
    • Lexicographically sort top-level entries
    • Imports
    • Function/constant/trait/contract attributes
  • Compare ASTs after partial evaluation
@jubnzv jubnzv added enhancement New feature or request api Tact's TypeScript API for third-party tools labels Aug 14, 2024
@jubnzv jubnzv self-assigned this Aug 14, 2024
@anton-trunov
Copy link
Member

anton-trunov commented Aug 14, 2024

Would be nice to have those bullet points in the OP configurable

jubnzv added a commit to jubnzv/tact that referenced this issue Aug 14, 2024
@jubnzv jubnzv mentioned this issue Aug 14, 2024
6 tasks
@anton-trunov
Copy link
Member

A couple more things regarding order-independence of things:

  • the order of function parameters can be irrelevant (provided the same shuffling has been done at all the call sites as well)
  • the order of fields in structs can be irrelevant.

But, the above two cases can result in different gas consumption! So we cannot really ignore order for the above two cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Tact's TypeScript API for third-party tools enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants