Skip to content
This repository has been archived by the owner on Dec 15, 2023. It is now read-only.

Declaring Cairo 1 Contract fail in forked mode #460

Closed
2 tasks
qperrot opened this issue May 5, 2023 · 1 comment · Fixed by #463
Closed
2 tasks

Declaring Cairo 1 Contract fail in forked mode #460

qperrot opened this issue May 5, 2023 · 1 comment · Fixed by #463
Assignees
Labels
Difficulty: intermediate mobilise some notions about the field, but can be learn Duration: few days will take a few days Techno: python Python Type: bug Something isn't working

Comments

@qperrot
Copy link

qperrot commented May 5, 2023

Describe the bug (observed vs expected behavior)
Error will tring to do :
const declareResponse = await account.declare({ contract: compiledContract, casm: compiledSierraCasm, });
With devnet running in forking mode.

A clear and concise description of what the bug is. If applicable, add screenshots to help explain your problem. However, prefer providing plain text.

[2023-05-05 15:28:33 +0200] [76540] [ERROR] {'prime': ['Unknown field.'], 'hints': ['Unknown field.'], 'pythonic_hints': ['Unknown field.'], 'compiler_version': ['Unknown field.'], 'bytecode': ['Unknown field.']}
Traceback (most recent call last):
  File "/users/cairo_venv/lib/python3.9/site-packages/starkware/starkware_utils/error_handling.py", line 262, in wrap_with_stark_exception
    yield
  File "/users/cairo_venv/lib/python3.9/site-packages/starkware/starknet/business_logic/transaction/state_objects.py", line 120, in apply_concurrent_changes
    return self._apply_specific_concurrent_changes(
  File "/users/cairo_venv/lib/python3.9/site-packages/starkware/starknet/business_logic/transaction/objects.py", line 669, in _apply_specific_concurrent_changes
    state.get_compiled_class_hash(class_hash=self.class_hash),
  File "/users/cairo_venv/lib/python3.9/site-packages/starkware/starknet/business_logic/state/state.py", line 530, in get_compiled_class_hash
    return self.state.get_compiled_class_hash(class_hash=class_hash)
  File "/users/cairo_venv/lib/python3.9/site-packages/starkware/starknet/business_logic/state/state.py", line 62, in get_compiled_class_hash
    return execute_coroutine_threadsafe(
  File "/users/cairo_venv/lib/python3.9/site-packages/starkware/python/utils.py", line 570, in execute_coroutine_threadsafe
    return future.result()
  File "/opt/homebrew/Cellar/[email protected]/3.9.16/Frameworks/Python.framework/Versions/3.9/lib/python3.9/concurrent/futures/_base.py", line 446, in result
    return self.__get_result()
  File "/opt/homebrew/Cellar/[email protected]/3.9.16/Frameworks/Python.framework/Versions/3.9/lib/python3.9/concurrent/futures/_base.py", line 391, in __get_result
    raise self._exception
  File "/users/cairo_venv/lib/python3.9/site-packages/starkware/starknet/business_logic/state/state.py", line 236, in get_compiled_class_hash
    compiled_class_hash = await self.state_reader.get_compiled_class_hash(
  File "/users/cairo_venv/lib/python3.9/site-packages/starkware/starknet/business_logic/state/state.py", line 236, in get_compiled_class_hash
    compiled_class_hash = await self.state_reader.get_compiled_class_hash(
  File "/users/cairo_venv/lib/python3.9/site-packages/starknet_devnet/forked_state.py", line 109, in get_compiled_class_hash
    compiled_class = CompiledClassBase.load(compiled_class_dict)
  File "/users/cairo_venv/lib/python3.9/site-packages/starkware/starkware_utils/serializable_dataclass.py", line 23, in load
    return cls.Schema().load(data=data)
  File "/users/cairo_venv/lib/python3.9/site-packages/marshmallow_dataclass/__init__.py", line 638, in load
    all_loaded = super().load(data, many=many, **kwargs)
  File "/users/cairo_venv/lib/python3.9/site-packages/marshmallow/schema.py", line 722, in load
    return self._do_load(
  File "/users/cairo_venv/lib/python3.9/site-packages/marshmallow/schema.py", line 909, in _do_load
    raise exc
marshmallow.exceptions.ValidationError: {'prime': ['Unknown field.'], 'hints': ['Unknown field.'], 'pythonic_hints': ['Unknown field.'], 'compiler_version': ['Unknown field.'], 'bytecode': ['Unknown field.']}

Not reproducible on alpha-goerli

  • This issue is only present on Devnet and cannot be reproduced on alpha-goerli (check the box if true).

To Reproduce
Steps to reproduce the behavior:

  1. ... starknet-devnet --fork-network alpha-goerli.
  2. ...StarknetJs
    const declareResponse = await account.declare({ contract: compiledContract, casm: compiledSierraCasm, });
    ...

Devnet version

This code works if I am not running devnet in fork mode.

  • I am using Devnet version: 0.5.1
  • This happens with a dockerized Devnet (check the box if true).
  • This does not appear on the following Devnet version:

System specifications

  • OS:
  • CPU:
  • Memory:
  • Python version:
@FabijanC FabijanC self-assigned this May 5, 2023
@FabijanC FabijanC added Type: bug Something isn't working Techno: python Python Difficulty: intermediate mobilise some notions about the field, but can be learn Duration: few days will take a few days labels May 5, 2023
@github-project-automation github-project-automation bot moved this to 🆕 New in starknet-devnet May 5, 2023
@FabijanC
Copy link
Collaborator

FabijanC commented May 8, 2023

This happens when trying to declare an already declared Cairo1 class in forked mode. The loading here:

compiled_class = CompiledClassBase.load(compiled_class_dict)

should be done using the utility function already defined in

def _load_compiled_class(class_dict: dict) -> CompiledClassBase:

Will create a fix today.

@FabijanC FabijanC mentioned this issue May 8, 2023
9 tasks
@github-project-automation github-project-automation bot moved this from 🆕 New to ✅ Done in starknet-devnet May 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Difficulty: intermediate mobilise some notions about the field, but can be learn Duration: few days will take a few days Techno: python Python Type: bug Something isn't working
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants