eth-brownie / brownie

A Python-based development and testing framework for smart contracts targeting the Ethereum Virtual Machine.
https://eth-brownie.readthedocs.io
MIT License
2.63k stars 549 forks source link

Pop from an empty deque #1118

Open mesozoic-technology opened 3 years ago

mesozoic-technology commented 3 years ago

Environment information

What was wrong?

brownie compile err'd out with this stack trace:

WARNING: deployed size of MyContract is 24672.0 bytes, exceeds EIP-170 limit of 24577
 - MyContract
  File "brownie/_cli/__main__.py", line 64, in main
    importlib.import_module(f"brownie._cli.{cmd}").main()
  File "brownie/_cli/compile.py", line 50, in main
    proj = project.load()
  File "brownie/project/main.py", line 745, in load
    return Project(name, project_path)
  File "brownie/project/main.py", line 180, in __init__
    self.load()
  File "brownie/project/main.py", line 235, in load
    self._compile(changed, self._compiler_config, False)
  File "brownie/project/main.py", line 92, in _compile
    build_json = compiler.compile_and_format(
  File "brownie/project/compiler/__init__.py", line 142, in compile_and_format
    build_json.update(generate_build_json(input_json, output_json, compiler_data, silent))
  File "brownie/project/compiler/__init__.py", line 313, in generate_build_json
    build_json[contract_alias] = solidity._get_unique_build_json(
  File "brownie/project/compiler/solidity.py", line 260, in _get_unique_build_json
    pc_map, statement_map, branch_map = _generate_coverage_data(
  File "brownie/project/compiler/solidity.py", line 359, in _generate_coverage_data
    pc_list.append({"op": opcodes.popleft(), "pc": pc})
IndexError: pop from an empty deque

It doesn't have to do only with the contract size being exceeded because I removed some small parts of the code and it worked, but the size was still exceeded. But it seems to happen when the size has been exceeded or is very large.

How can it be fixed?

When I turned the optimizer off this problem stopped

iamdefinitelyahuman commented 3 years ago

Which version of solidity are you using?

mesozoic-technology commented 3 years ago

0.8.2

On Sun, Jun 20, 2021 at 3:08 AM Ben Hauser @.***> wrote:

Which version of solidity are you using?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/eth-brownie/brownie/issues/1118#issuecomment-864510136, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADG5UGMOSCC7CVTOQMBJ3K3TTWHYPANCNFSM467UE2RA .

mesozoic-technology commented 3 years ago

Sorry for whatever reason the version of brownie didn't make it into this issue either - Brownie v1.14.6 - Python development framework for Ethereum. Updated at the top...

mesozoic-technology commented 3 years ago

Here's the offending code. The contract size here is only about 16k actually, and it is giving this very strange pop from empty deque error.

https://github.com/overlay-market/overlay-v1-core/blob/liquidations/contracts/market/OverlayV1Market.sol#L213

mesozoic-technology commented 3 years ago

@iamdefinitelyahuman what's the status on a bug fix for this? it would make it very difficult for me to use brownie to develop my codebase if it can't compile my code with the optimizer.

mesozoic-technology commented 3 years ago

changing the optimizer runs to 800 seems to solve this problem

0xyqrz commented 3 years ago

Having the same issue when compiling with 200 optimizer runs (but 800 works):

Environment information

$ brownie compile
Brownie v1.14.6 - Python development framework for Ethereum

Compiling contracts...
  Solc version: 0.8.6
  Optimizer: Enabled  Runs: 200
  EVM Version: Istanbul
Generating build data...
[a bunch of unique contract names]
  File "brownie/_cli/__main__.py", line 64, in main
    importlib.import_module(f"brownie._cli.{cmd}").main()
  File "brownie/_cli/compile.py", line 50, in main
    proj = project.load()
  File "brownie/project/main.py", line 745, in load
    return Project(name, project_path)
  File "brownie/project/main.py", line 180, in __init__
    self.load()
  File "brownie/project/main.py", line 235, in load
    self._compile(changed, self._compiler_config, False)
  File "brownie/project/main.py", line 92, in _compile
    build_json = compiler.compile_and_format(
  File "brownie/project/compiler/__init__.py", line 142, in compile_and_format
    build_json.update(generate_build_json(input_json, output_json, compiler_data, silent))
  File "brownie/project/compiler/__init__.py", line 313, in generate_build_json
    build_json[contract_alias] = solidity._get_unique_build_json(
  File "brownie/project/compiler/solidity.py", line 260, in _get_unique_build_json
    pc_map, statement_map, branch_map = _generate_coverage_data(
  File "brownie/project/compiler/solidity.py", line 359, in _generate_coverage_data
    pc_list.append({"op": opcodes.popleft(), "pc": pc})
IndexError: pop from an empty deque
0xyqrz commented 3 years ago

Maybe this is related? https://github.com/eth-brownie/brownie/issues/963 https://github.com/eth-brownie/brownie/pull/974

autoluminescent commented 2 years ago

I have the same issue. Also managed to work around it by increasing the optimiser runs (using a binary search I figured out that the threshold was 581, but I figure that probably depends on the contracts).

Environment

reednaa commented 2 years ago

Replicated the issue with a minimal contract in Vyper 0.3.0.

Creating the following env:

mainFolder
– contracts
–– example.vy

example.vy

# @version ^0.3.0

a: uint256

@internal
def _func(_value : uint256):
    self.a = _value

Throws IndexError: pop from an empty deque on brownie compile

Workaround: Use Vyper 0.2.16

Environment information

liam-ot commented 2 years ago

experienced this with brownie v1.19.0 upgrading to v1.19.1 resolved the issue

balajipachai commented 7 months ago

https://github.com/overlay-market/overlay-v1-core/blob/liquidations/contracts/market/OverlayV1Market.sol#L213

Using vyper 0.2.16 does solve this issue