Skip to content

Support the object source map returned by vyper 0.4 - #702

Open
Eljees wants to merge 1 commit into
crytic:masterfrom
Eljees:fix/vyper-04-source-map
Open

Support the object source map returned by vyper 0.4#702
Eljees wants to merge 1 commit into
crytic:masterfrom
Eljees:fix/vyper-04-source-map

Conversation

@Eljees

@Eljees Eljees commented Aug 8, 2026

Copy link
Copy Markdown

Compiling any project with vyper 0.4.x currently crashes:

  File "crytic_compile/platform/vyper.py", line 102, in compile
    ]["sourceMap"].split(";")
AttributeError: 'dict' object has no attribute 'split'

Since 0.4, vyper returns evm.deployedBytecode.sourceMap as an object rather than a string:

breakpoints, error_map, pc_ast_map, pc_ast_map_item_keys,
pc_breakpoints, pc_jump_map, pc_pos_map, pc_pos_map_compressed

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:

0:152:0:-;-1:-1:-1;-1:-1:-1;...

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 sourceMap is 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", and scripts/ci_test_vyper.sh pins vyper>=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_json is monkeypatched to return a 0.4-shaped artifact, and the test asserts the resulting srcmaps_runtime.

Before the fix:

E   AttributeError: 'dict' object has no attribute 'split'
crytic_compile/platform/vyper.py:102

After the fix: 1 passed.

Checked end to end against real compilers as well:

  • vyper 0.4.3, a contract using an interface, an event, a default argument, natspec and staticcall: 392 source map entries, ABI and AST populated, no crash.
  • vyper 0.3.7, tests/vyper/auction.vy from 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 to master).

Signed-off-by: Eljees <3.14hell@gmail.com>
@CLAassistant

CLAassistant commented Aug 8, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

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.

2 participants