vyperlang / titanoboa-zksync

A Zksync plugin for the Titanoboa Vyper interpreter
MIT License
5 stars 6 forks source link

use dict index to get value instead of guessing filename #7

Closed bout3fiddy closed 2 months ago

bout3fiddy commented 3 months ago

What I did

The compiler output contains a key-value pair with three keys: compile output, vyper version and zkvyper version.

Currently the compile output used filename with the prefix of './' removed. this doesnt work if './' is not in the prefix:

(venv) % python scripts/deploy_infra.py 
Traceback (most recent call last):
  ...
    contract_obj = boa.loads_partial(source_code=new_source, filename=contract_file)
  File ".../venv/lib/python3.10/site-packages/boa/interpret.py", line 163, in loads_partial
    data = compiler_data(source_code, name, deployer_class, **compiler_args)
  File ".../venv/lib/python3.10/site-packages/boa/interpret.py", line 110, in compiler_data
    return _disk_cache.caching_lookup(cache_key, func)
  File ".../venv/lib/python3.10/site-packages/boa/util/disk_cache.py", line 70, in caching_lookup
    res = func()
  File ".../venv/lib/python3.10/site-packages/boa/interpret.py", line 100, in func
    ret = deployer.create_compiler_data(
  File ".../venv/lib/python3.10/site-packages/boa_zksync/deployer.py", line 36, in create_compiler_data
    return compile_zksync_source(source_code, contract_name, compiler_args)
  File "...venv/lib/python3.10/site-packages/boa_zksync/compile.py", line 70, in compile_zksync_source
    return compile_zksync(name, filename, compiler_args, source_code)
  File ".../venv/lib/python3.10/site-packages/boa_zksync/compile.py", line 43, in compile_zksync
    compile_output = output[filename.removeprefix("./")]
KeyError: '/var/folders/w7/3c51j_5j2gq4n13mljt4rrb80000gn/T/tmp8ziczmee/VyperContract.vy'

How I did it

I added a helper method to fetch the correct key, but then it also breaks if the other key names change or if the number of keys change.

How to verify it

you can try to deloy curve stableswap infra on zksync here:

https://github.com/curvefi/stableswap-ng/blob/main/scripts/deploy_infra.py

you need to call python scripts/deploy_infra.py and that should cleanly deploy. ensure you have the right env keys (it will bork at first but you'll find the changes you need to do'.

Description for the changelog

Fetch compiler output from stdout without guessing the path of the temp filename.

Cute Animal Picture

image

DanielSchiavini commented 2 months ago

Merged via #8