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

chore: add missing pc maps to vyper_json output #3333

Merged
merged 18 commits into from
Apr 7, 2023

Conversation

tserg
Copy link
Collaborator

@tserg tserg commented Apr 4, 2023

What I did

Fix #3293 by adding breakpoints, pc_breakpoints and error_map - pc_pos_map is already there so I have skipped that.

Additionally, fixed a minor bug with detecting breakpoints.

How I did it

Mostly replicating how it is done for source_map.

How to verify it

Commit message

chore: add missing pc maps to `vyper_json` output

Description for the changelog

Add missing pc maps to vyper_json output

Cute Animal Picture

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

@codecov-commenter
Copy link

codecov-commenter commented Apr 5, 2023

Codecov Report

Merging #3333 (f2b43af) into master (a4c2449) will decrease coverage by 0.11%.
The diff coverage is 50.00%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@            Coverage Diff             @@
##           master    #3333      +/-   ##
==========================================
- Coverage   88.93%   88.82%   -0.11%     
==========================================
  Files          84       84              
  Lines       10606    10608       +2     
  Branches     2215     2216       +1     
==========================================
- Hits         9432     9423       -9     
- Misses        768      778      +10     
- Partials      406      407       +1     
Impacted Files Coverage Δ
vyper/compiler/__init__.py 88.09% <ø> (ø)
vyper/cli/vyper_json.py 78.62% <50.00%> (-0.13%) ⬇️

... and 3 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@@ -755,7 +755,7 @@ def note_line_num(line_number_map, item, pos):

def note_breakpoint(line_number_map, item, pos):
# Record line number attached to pos.
if item == "DEBUG":
if item in ("BREAKPOINT", "DEBUG"):
Copy link
Member

Choose a reason for hiding this comment

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

hmm

Copy link
Collaborator Author

@tserg tserg Apr 6, 2023

Choose a reason for hiding this comment

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

I made this change as the breakpoints were not showing up in the output.

Copy link
Member

Choose a reason for hiding this comment

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

i did not plan for the new breakpoint instruction to show up in the output. right now pc_breakpoints should be empty

@antazoey
Copy link
Contributor

antazoey commented Apr 5, 2023

Decompressed pos map is not there tho. Brb, will link what we have to suddenly do in ape-vyper once we switched to vyper-json.

@antazoey
Copy link
Contributor

antazoey commented Apr 5, 2023

this is what we had to change to get back to the same data structure we were relying on: https://github.com/ApeWorX/ape-vyper/blob/main/ape_vyper/compiler.py#L241-L263

not the end of the world but i relied on brownie to figure out how to get there, and since the data was already present in the normal way of compiling, it could be added to the vyper-json too.

@tserg
Copy link
Collaborator Author

tserg commented Apr 5, 2023

Understood, I will add the original pc_pos_map as well.

@tserg
Copy link
Collaborator Author

tserg commented Apr 6, 2023

@unparalleled-js I have added pc_pos_map, does this fulfil Ape's requirements?

"source_map": output.build_source_map_output,
"pc_pos_map": output.build_source_map_output,
Copy link
Member

Choose a reason for hiding this comment

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

hmm why is this a dup of source_map?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I wasn't quite sure how to handle pc_pos_map since it is technically already in the source_map output. I think what you said below makes sense, so source_map output will contain both pc_pos_map and pc_pos_map_compressed, and there is no need for a separate pc_pos_map option. Did I understand it right?

Copy link
Member

Choose a reason for hiding this comment

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

right. i'm not sure if we can actually replace the source_map option since people might depend on it, but we could add it like source_map_full or something

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hm, so we would still separate it into source_map -> pc_pos_map_compressed, and source_map_full -> pc_pos_map?

Copy link
Member

Choose a reason for hiding this comment

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

i think source_map should still return the compressed pc map, but source_map_full should return everything, just like the cli -f source_map output.

Copy link
Member

@charles-cooper charles-cooper left a comment

Choose a reason for hiding this comment

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

i mean i think a much better approach is just to not select down into pc_pos_map for the source_map output. i think source_map output should already have everything needed.

@@ -38,7 +38,7 @@ def test_keys():
"breakpoints": data["breakpoints"],
"pcBreakpoints": data["pc_breakpoints"],
"sourceMap": data["source_map"]["pc_pos_map_compressed"],
"pcPosMap": data["source_map"]["pc_pos_map"],
"sourceMapFull": data["source_map"],
Copy link
Member

Choose a reason for hiding this comment

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

nice. i think we can remove the other new fields now, since they are contained within sourceMapFull.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

do we want the other new fields to be sorted?

@charles-cooper charles-cooper marked this pull request as ready for review April 6, 2023 17:17
@charles-cooper charles-cooper enabled auto-merge (squash) April 7, 2023 02:01
@charles-cooper charles-cooper merged commit 1cf56a9 into vyperlang:master Apr 7, 2023
@tserg tserg deleted the chore/vyper_json branch April 7, 2023 04:08
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.

Add missing PC Maps to vyper_json output
4 participants