ethereum / populus

The Ethereum development framework with the most cute animal pictures
http://populus.readthedocs.org/
321 stars 321 forks source link

Regression with solc 0.4.19 #398

Closed Netherdrake closed 6 years ago

Netherdrake commented 6 years ago
In [2]: populus.__version__
Out[2]: '2.0.1'

0.4.18

~/G/t/foo % solc --version
solc, the solidity compiler commandline interface
Version: 0.4.18+commit.9cf6e910.Linux.g++

~/G/t/foo % populus compile
> Found 1 contract source files
  - contracts/Greeter.sol
> Compiled 1 contracts
  - contracts/Greeter.sol:Greeter
> Wrote compiled assets to: build/contracts.json

0.4.19

~/G/t/foo % solc --version
solc, the solidity compiler commandline interface
Version: 0.4.19+commit.c4cbbb05.Linux.g++

~/G/t/foo % populus compile
Traceback (most recent call last):
  File "/home/user/anaconda3/bin/populus", line 11, in <module>
    sys.exit(main())
  File "/home/user/anaconda3/lib/python3.6/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/home/user/anaconda3/lib/python3.6/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/home/user/anaconda3/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/user/anaconda3/lib/python3.6/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/user/anaconda3/lib/python3.6/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/home/user/anaconda3/lib/python3.6/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/user/anaconda3/lib/python3.6/site-packages/populus/cli/compile_cmd.py", line 29, in compile_cmd
    compile_project(project, watch)
  File "/home/user/anaconda3/lib/python3.6/site-packages/populus/api/compile_contracts.py", line 17, in compile_project
    _, compiled_contracts = compile_project_contracts(project)
  File "/home/user/anaconda3/lib/python3.6/site-packages/populus/compilation/__init__.py", line 54, in compile_project_contracts
    compiled_contracts = post_process_compiled_contracts(base_compiled_contracts)
  File "/home/user/anaconda3/lib/python3.6/site-packages/populus/utils/compile.py", line 135, in post_process_compiled_contracts
    add_full_dependencies_to_compiled_contracts,
  File "cytoolz/functoolz.pyx", line 586, in cytoolz.functoolz.pipe (cytoolz/functoolz.c:10663)
  File "cytoolz/functoolz.pyx", line 562, in cytoolz.functoolz.c_pipe (cytoolz/functoolz.c:10494)
  File "/home/user/anaconda3/lib/python3.6/site-packages/eth_utils/functional.py", line 22, in inner
    return callback(fn(*args, **kwargs))
  File "/home/user/anaconda3/lib/python3.6/site-packages/populus/utils/compile.py", line 102, in add_direct_dependencies_to_compiled_contracts
    in itertools.chain(contract_data['linkrefs'], contract_data['linkrefs_runtime'])
KeyError: 'linkrefs'
~/G/t/foo % 
veox commented 6 years ago

Can confirm, with same populus/solc versions, on a freshly-created project (using populus init).

On entry to post_process_compiled_contracts(), in populus/utils/compile.py, this is what's passed to the function:

({'name': 'Greeter', 'source_path': 'contracts/Greeter.sol'},)
veox commented 6 years ago

With --logging DEBUG (and a tiny modification to also print compilation_result in SolcStandardJSONBackend.get_compiled_contracts(...):

Found 1 project source files: contracts/Greeter.sol
Found 0 test source files: 
Import remappings: []
Compiler Settings: {'optimize': True, 'output_values': ['abi', 'bin', 'bin-runtime', 'metadata']}
std_input sections: dict_keys(['language', 'sources', 'settings'])
Input Description JSON settings are: {'remappings': []}
Command line options are: {}
Compilation result: {'contracts': {'contracts/Greeter.sol': {'Greeter': {'evm': {}}}}, 'sources': {'contracts/Greeter.sol': {'id': 0}}}
Traceback (most recent call last):
    <seemingly same as in OP>
veox commented 6 years ago

Luckily, I still have a package for solc v0.4.18. Output from that looks the same, except compilation_result is populated (as expected).

Therefore, the bug is likely purely due to upstream changes: solc expects something new that's not provided (yet).

0.4.19 release notes say:

Standard JSON: Support the outputSelection field for selective compilation of target artifacts.

Docs on which in turn provide hints on what's missing. (Not linking specific doc version, since there seems to be misconfiguration there - they're not available.)

veox commented 6 years ago

Testing fix ATM - hope it's backward-compatible, otherwise not a no-brainer...