Support the object source map returned by vyper 0.4 - #702
Open
Eljees wants to merge 1 commit into
Open
Conversation
Signed-off-by: Eljees <3.14hell@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Compiling any project with vyper 0.4.x currently crashes:
Since 0.4, vyper returns
evm.deployedBytecode.sourceMapas an object rather than a string:I did not find an existing issue for this, so I am opening the PR directly - happy to file one if you prefer to track it.
Fix
The same solc-style map is still there, under
pc_pos_map_compressed:So the fix is to read that key when the compiler hands back an object, and keep the existing path untouched for 0.3.7, where
sourceMapis a string. This restores real source maps rather than only avoiding the crash.I kept the change to the source map alone.
compile()already logs"Vyper != 0.3.7 support is a best effort and might fail", andscripts/ci_test_vyper.shpinsvyper>=0.3.7,<0.4, so I did not want to claim full 0.4 support in this PR. If you would like the CI script extended to a 0.3.7 + 0.4.x matrix, I am glad to do it here or in a follow-up.Tests
New
tests/test_vyper.py. It needs no vyper binary:_run_vyper_standard_jsonis monkeypatched to return a 0.4-shaped artifact, and the test asserts the resultingsrcmaps_runtime.Before the fix:
After the fix:
1 passed.Checked end to end against real compilers as well:
staticcall: 392 source map entries, ABI and AST populated, no crash.tests/vyper/auction.vyfrom this repository: 1858 entries, unchanged.Also run:
ruff check crytic_compile/ tests/(clean),ruff format --check(clean),ty check crytic_compile/(no new diagnostics compared tomaster).