NethermindEth / warp

Warp - Bringing Solidity to Starknet at warp speed. Warp is a Solidity to Cairo Compiler, this allows teams to write/migrate Solidity to Cairo for easy onboarding into the StarkNet ecosystem.
https://nethermind.io/warp/
Apache License 2.0
752 stars 69 forks source link

Error running warp transpile #139

Closed dkillen closed 2 years ago

dkillen commented 2 years ago

I am running macOS Monterey 12.0.1. I have followed the installation guide in the repository's README. For context, I also have a python venv in which I am using cairo which I can use to compile, deploy and interact with cairo contracts. I have also built docker containers for cairo and OpenZeppelin Nile which both appear to work without error at this time. I have built a docker container for warp (following the installation instructions in the README). I have also tried the warp installation on my Linux machine (Ubuntu 20.04) neither of which work and display the same error set out below.

On my MacBook I have installed the following with brew:

  1. python3.7.12
  2. gmp
  3. boost

I then created a new python venv activated it and installed sol-warp==0.2.15 with pip.

Everything appears to install properly and without error. However, when I run warp transpile I get the following error:

(sol-warp) # warp transpile ERC20.sol WARP Traceback (most recent call last): File "/Users/david/sol-warp/bin/warp", line 5, in from cli.warp_cli import main File "/Users/david/sol-warp/lib/python3.7/site-packages/cli/warp_cli.py", line 13, in from cli.commands import _deploy, _invoke, _status File "/Users/david/sol-warp/lib/python3.7/site-packages/cli/commands.py", line 13, in from starkware.starknet.services.api.contract_definition import ContractDefinition File "/Users/david/sol-warp/lib/python3.7/site-packages/starkware/starknet/services/api/contract_definition.py", line 9, in from starkware.cairo.lang.compiler.program import Program File "/Users/david/sol-warp/lib/python3.7/site-packages/starkware/cairo/lang/compiler/program.py", line 10, in from starkware.cairo.lang.compiler.debug_info import DebugInfo File "/Users/david/sol-warp/lib/python3.7/site-packages/starkware/cairo/lang/compiler/debug_info.py", line 10, in from starkware.cairo.lang.compiler.preprocessor.flow import FlowTrackingDataActual File "/Users/david/sol-warp/lib/python3.7/site-packages/starkware/cairo/lang/compiler/preprocessor/flow.py", line 16, in from starkware.cairo.lang.compiler.references import FlowTrackingError, Reference File "/Users/david/sol-warp/lib/python3.7/site-packages/starkware/cairo/lang/compiler/references.py", line 18, in from starkware.cairo.lang.compiler.fields import ExpressionAsStr File "/Users/david/sol-warp/lib/python3.7/site-packages/starkware/cairo/lang/compiler/fields.py", line 4, in from starkware.cairo.lang.compiler.parser import parse_expr, parse_type File "/Users/david/sol-warp/lib/python3.7/site-packages/starkware/cairo/lang/compiler/parser.py", line 34, in propagate_positions=True, File "/Users/david/sol-warp/lib/python3.7/site-packages/lark/lark.py", line 355, in init assert_config(lexer, ('basic', 'contextual', 'dynamic', 'dynamic_complete')) File "/Users/david/sol-warp/lib/python3.7/site-packages/lark/exceptions.py", line 21, in assert_config raise ConfigurationError(msg % (value, options)) lark.exceptions.ConfigurationError: Got 'standard', expected one of ('basic', 'contextual', 'dynamic', 'dynamic_complete')

Your help with this would be appreciated.

temyurchenko commented 2 years ago

Hi, could you please try installing version 0.2.16 and see if the problem persists?

dkillen commented 2 years ago

I have installed sol-warp v0.2.16 in my python venv.

To clarify, these are the versions of required packages I have installed in following the README:

I get a similar error to that above when doing attempting a transpile:

(sol-warp) david@imladris ~/dev/trufflesuite/starkware/warp > warp transpile ERC20.sol WARP Traceback (most recent call last): File "/Users/david/sol-warp/bin/warp", line 5, in from cli.warp_cli import main File "/Users/david/sol-warp/lib/python3.7/site-packages/cli/warp_cli.py", line 9, in from cli.commands import _deploy, _invoke, _status File "/Users/david/sol-warp/lib/python3.7/site-packages/cli/commands.py", line 13, in from starkware.starknet.services.api.contract_definition import ContractDefinition File "/Users/david/sol-warp/lib/python3.7/site-packages/starkware/starknet/services/api/contract_definition.py", line 9, in from starkware.cairo.lang.compiler.program import Program File "/Users/david/sol-warp/lib/python3.7/site-packages/starkware/cairo/lang/compiler/program.py", line 10, in from starkware.cairo.lang.compiler.debug_info import DebugInfo File "/Users/david/sol-warp/lib/python3.7/site-packages/starkware/cairo/lang/compiler/debug_info.py", line 10, in from starkware.cairo.lang.compiler.preprocessor.flow import FlowTrackingDataActual File "/Users/david/sol-warp/lib/python3.7/site-packages/starkware/cairo/lang/compiler/preprocessor/flow.py", line 23, in from starkware.cairo.lang.compiler.references import ApDeductionError, FlowTrackingError, Reference File "/Users/david/sol-warp/lib/python3.7/site-packages/starkware/cairo/lang/compiler/references.py", line 19, in from starkware.cairo.lang.compiler.fields import ExpressionAsStr File "/Users/david/sol-warp/lib/python3.7/site-packages/starkware/cairo/lang/compiler/fields.py", line 4, in from starkware.cairo.lang.compiler.parser import parse_expr, parse_type File "/Users/david/sol-warp/lib/python3.7/site-packages/starkware/cairo/lang/compiler/parser.py", line 34, in propagate_positions=True, File "/Users/david/sol-warp/lib/python3.7/site-packages/lark/lark.py", line 355, in init assert_config(lexer, ('basic', 'contextual', 'dynamic', 'dynamic_complete')) File "/Users/david/sol-warp/lib/python3.7/site-packages/lark/exceptions.py", line 21, in assert_config raise ConfigurationError(msg % (value, options)) lark.exceptions.ConfigurationError: Got 'standard', expected one of ('basic', 'contextual', 'dynamic', 'dynamic_complete')

I'm not really a python guy but, I don't think getting warp installed and running needs a lot of python experience. Hopefully, this is helpful.

temyurchenko commented 2 years ago

Can you please do pip list > installed.txt and provide the installed.txt file?

dkillen commented 2 years ago

installed.txt

temyurchenko commented 2 years ago

I see that both lark and lark-parser are installed. However, lark introduces a breaking renaming change, which causes the error above.

I wonder if that lark package is left from the previous installation? Could you please try with a fresh environment?

dkillen commented 2 years ago

pip list prior to installing warp - installed-fresh.txt pip list after installing warp - installed-after.txt

It seems to have cleaned up lark. But, I now get a different error running warp transpile. This is an interesting error in the Trace "RuntimeError: Unsupported OS: Darwin-21.1.0-x86_64-i386-64bit"

warp-test) david@imladris ~/dev/trufflesuite/starkware/warp > warp transpile ERC20.sol WARP Traceback (most recent call last): File "/Users/david/warp-test/bin/kudu", line 44, in main(sys.argv) File "/Users/david/warp-test/bin/kudu", line 32, in main raise RuntimeError(f"Unsupported OS: {platform.platform()}") RuntimeError: Unsupported OS: Darwin-21.1.0-x86_64-i386-64bit

Traceback (most recent call last): File "/Users/david/warp-test/bin/warp", line 8, in sys.exit(main()) File "/Users/david/warp-test/lib/python3.7/site-packages/cli/warp_cli.py", line 120, in main warp() File "/Users/david/warp-test/lib/python3.7/site-packages/click/core.py", line 1128, in call return self.main(args, kwargs) File "/Users/david/warp-test/lib/python3.7/site-packages/click/core.py", line 1053, in main rv = self.invoke(ctx) File "/Users/david/warp-test/lib/python3.7/site-packages/click/core.py", line 1659, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/Users/david/warp-test/lib/python3.7/site-packages/click/core.py", line 1395, in invoke return ctx.invoke(self.callback, ctx.params) File "/Users/david/warp-test/lib/python3.7/site-packages/click/core.py", line 754, in invoke return __callback(args, **kwargs) File "/Users/david/warp-test/lib/python3.7/site-packages/cli/warp_cli.py", line 37, in transpile output = transpile_from_solidity(file_path, contract_name) File "/Users/david/warp-test/lib/python3.7/site-packages/yul/main.py", line 50, in transpile_from_solidity raise e File "/Users/david/warp-test/lib/python3.7/site-packages/yul/main.py", line 46, in transpile_from_solidity capture_output=True, File "/usr/local/opt/python@3.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 512, in run output=stdout, stderr=stderr) subprocess.CalledProcessError: Command '['kudu', '--yul-json-ast', 'ERC20.sol', 'WARP']' returned non-zero exit status 1.

temyurchenko commented 2 years ago

The issue is that we have to rely on some binary files and we might have not prebuilt them for macos12.

Could you please run python -c "import platform; print(platform.system())" followed by python -c "import platform; print(platform.mac_ver())"?

And then report the results

dkillen commented 2 years ago

Result from the first command: Darwin Result from the second command: ('10.16', ('', '', ''), 'x86_64')

temyurchenko commented 2 years ago

That's rather funny that macos 10.15 returns ('10.15', ...), macos 11 returns ('11', ...) and macos 12 returns ('10.16', ..).

Seems like some kind of bug, but we'll take that behaviour into account. Could you please for now test on linux?

temyurchenko commented 2 years ago

Actually, it appears that it is a somewhat known issue and there is a workaround. WIll you please try that for now?

dkillen commented 2 years ago

So this command works:

SYSTEM_VERSION_COMPAT=0 warp transpile ERC20.sol WARP

The output from this command SYSTEM_VERSION_COMPAT=0 python3 -c "import platform; print(platform.mac_ver())" is ('12.0.1', ('', '', ''), 'x86_64')

temyurchenko commented 2 years ago

Is the solution satisfactory enough to close the issue?

dkillen commented 2 years ago

Yes I think so. Thank you for your help.