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

feat[tool]: add node_id map to source map #3811

Merged

Conversation

charles-cooper
Copy link
Member

@charles-cooper charles-cooper commented Feb 25, 2024

add node_id map to source map which links directly back to the AST output to improve source code integrations for third parties

refactor:

  • get rid of vyper.codegen.core.getpos()
  • rename IRnode.source_pos to IRnode.ast_source
  • thread ast_source through to sourcemap generation
  • refactor a couple places in codegen which were passing IRnode to Expr constructor

i also rewrote the source map compression routine a bit. it might have gotten broken but at this point i don't think anybody really uses the compressed source map (i checked with ape and hardhat here and waiting to hear back from slither), they prefer the other formats.
other major tooling:

  • brownie uses the compressed source map but it has been sunset, nothing we can do there
  • titanoboa uses the vyper ast directly, in a way very similar to the export here actually
  • not sure what foundry does, they don't support vyper now, they might in the future but idk if it would really be a blocker if we dropped the compressed source map

fixes #1609

What I did

How I did it

How to verify it

Commit message

this commit adds a new, AST-based map to the source map which links
program counters (pcs) directly back to the AST output. this should
improve the ability of third parties to implement source code
integrations (debuggers, storage map tracers, etc).

refactors:
- get rid of `vyper.codegen.core.getpos()`
- rename `IRnode.source_pos` to `IRnode.ast_source`
- refactor a couple places in codegen which were passing `IRnode`s to
  the `Expr` constructor
- rewrote the source map compression routine a bit. it might have gotten
  broken but at this point the compressed source map does not seem
  widely used.

Description for the changelog

Cute Animal Picture

Put a link to a cute animal picture inside the parenthesis-->

add node_id map to source map, to improve source code integrations for
third parties

refactor:
- get rid of getpos()
- rename `IRnode.source_pos` to `IRnode.ast_source`
- thread ast_source through to sourcemap generation
@codecov-commenter
Copy link

codecov-commenter commented Feb 25, 2024

Codecov Report

Attention: Patch coverage is 98.16514% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 86.20%. Comparing base (9428196) to head (b952144).

Files Patch % Lines
vyper/codegen/expr.py 94.73% 1 Missing ⚠️
vyper/ir/compile_ir.py 95.23% 1 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3811      +/-   ##
==========================================
- Coverage   86.21%   86.20%   -0.02%     
==========================================
  Files          92       92              
  Lines       13998    14008      +10     
  Branches     3076     3077       +1     
==========================================
+ Hits        12068    12075       +7     
- Misses       1494     1496       +2     
- Partials      436      437       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@charles-cooper charles-cooper changed the title feat[tool]: add node_id map to source map feat[tool]: add node_id map to source map Feb 25, 2024
@charles-cooper charles-cooper marked this pull request as draft February 26, 2024 17:05
node ids are not unique across modules
remove its node attributes so it doesn't get in the source map
vyper/ir/compile_ir.py Fixed Show fixed Hide fixed
@charles-cooper charles-cooper marked this pull request as ready for review March 9, 2024 16:32
vyper/compiler/output.py Fixed Show fixed Hide fixed
docs/compiling-a-contract.rst Show resolved Hide resolved
@charles-cooper charles-cooper merged commit 246f4a7 into vyperlang:master Mar 12, 2024
83 checks passed
@charles-cooper charles-cooper deleted the feat/improved-source-map branch March 12, 2024 15:11
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 this pull request may close these issues.

Replace self.pos with self.ast_node on LLLNode
4 participants