Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AssertionError when trying to make large immutable array #3750

Closed
Leminkay opened this issue Jan 29, 2024 · 1 comment
Closed

AssertionError when trying to make large immutable array #3750

Leminkay opened this issue Jan 29, 2024 · 1 comment
Labels
bug - codegen bug - type 0 compiler halts or panics instead of generating code

Comments

@Leminkay
Copy link

Leminkay commented Jan 29, 2024

Version Information

  • vyper Version (output of vyper --version): 0.3.10
  • OS: linux
  • Python Version (output of python --version): 3.10.12

What's your issue about?

Compiler throws AssertionError when trying to create large immutable arrays (fixed & dynamic).

IM_BYTES_0 : immutable(String[65536])

@external
def __init__():
    IM_BYTES_0 = "Test"
Error compiling: test.vy
Traceback (most recent call last):
  File "/home/lemy/.local/bin/vyper", line 8, in <module>
    sys.exit(_parse_cli_args())
  File "/home/lemy/.local/lib/python3.10/site-packages/vyper/cli/vyper_compile.py", line 63, in _parse_cli_args
    return _parse_args(sys.argv[1:])
  File "/home/lemy/.local/lib/python3.10/site-packages/vyper/cli/vyper_compile.py", line 185, in _parse_args
    compiled = compile_files(
  File "/home/lemy/.local/lib/python3.10/site-packages/vyper/cli/vyper_compile.py", line 321, in compile_files
    compiler_data = vyper.compile_codes(
  File "/home/lemy/.local/lib/python3.10/site-packages/vyper/compiler/__init__.py", line 143, in compile_codes
    exc_handler(contract_name, exc)
  File "/home/lemy/.local/lib/python3.10/site-packages/vyper/cli/vyper_compile.py", line 219, in exc_handler
    raise exception
  File "/home/lemy/.local/lib/python3.10/site-packages/vyper/compiler/__init__.py", line 140, in compile_codes
    out[contract_name][output_format] = formatter(compiler_data)
  File "/home/lemy/.local/lib/python3.10/site-packages/vyper/compiler/output.py", line 262, in build_bytecode_output
    return f"0x{compiler_data.bytecode.hex()}"
  File "/usr/lib/python3.10/functools.py", line 981, in __get__
    val = self.func(instance)
  File "/home/lemy/.local/lib/python3.10/site-packages/vyper/compiler/phases.py", line 193, in bytecode
    return generate_bytecode(self.assembly, insert_compiler_metadata=insert_compiler_metadata)
  File "/home/lemy/.local/lib/python3.10/site-packages/vyper/compiler/phases.py", line 353, in generate_bytecode
    return compile_ir.assembly_to_evm(assembly, insert_compiler_metadata=insert_compiler_metadata)[
  File "/home/lemy/.local/lib/python3.10/site-packages/vyper/ir/compile_ir.py", line 1100, in assembly_to_evm
    bytecode, source_maps, _ = assembly_to_evm_with_symbol_map(
  File "/home/lemy/.local/lib/python3.10/site-packages/vyper/ir/compile_ir.py", line 1274, in assembly_to_evm_with_symbol_map
    bytecode, _ = assembly_to_evm(PUSH_N(ofst, n))
  File "/home/lemy/.local/lib/python3.10/site-packages/vyper/ir/compile_ir.py", line 42, in PUSH_N
    assert x == 0
AssertionError
@charles-cooper charles-cooper added bug - codegen bug - type 0 compiler halts or panics instead of generating code labels Feb 2, 2024
@cyberthirst
Copy link
Collaborator

fixed as of #3729

the PoC now fails with:

vyper.exceptions.StorageLayoutException: Invalid storage slot, tried to allocate slots 0 through 65568

  contract "tests/custom/test.vy:1", line 1:0 
  ---> 1 IM_BYTES_0 : immutable(String[65536])
  -------^

for a DynArray:

IM_BYTES_0 : immutable(DynArray[uint256, 65536])

@deploy
def __init__():
    IM_BYTES_0 = []
vyper.exceptions.StorageLayoutException: Invalid storage slot, tried to allocate slots 0 through 2097184

  contract "tests/custom/test.vy:1", line 1:0 
  ---> 1 IM_BYTES_0 : immutable(DynArray[uint256, 65536])
  -------^
       2

the allocators are now created with a max_slot:

self.immutables_allocator = SimpleAllocator(max_slot=0x6000)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug - codegen bug - type 0 compiler halts or panics instead of generating code
Projects
None yet
Development

No branches or pull requests

3 participants