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

Adapt to cairo-lang 0.10.1 #307

Merged
merged 20 commits into from
Oct 19, 2022
Merged

Adapt to cairo-lang 0.10.1 #307

merged 20 commits into from
Oct 19, 2022

Conversation

FabijanC
Copy link
Collaborator

@FabijanC FabijanC commented Oct 10, 2022

Usage related changes

Development related changes

  • Update readme on local cairo-lang installation (simplify)
  • Replace DummyExecutionInfo() with TransactionExecutionInfo.empty()
  • Refactor starknet_wrapper.py to extract common logic of transactions:
    • Error catching is done through an async with block
    • Had to rename some private methods to have one underscore instead of two (e.g. __update_state -> _update_state) to be able to use them in the tx handler.

Checklist:

  • Applied formatting - ./scripts/format.sh
  • No linter errors - ./scripts/lint.sh
  • Performed code self-review
  • Rebased to the last commit of the target branch (or merged it into my branch)
  • Documented the changes
  • Linked the issues which this PR resolves
  • Updated the tests
  • All tests are passing
  • Reverted pyproject.toml to use official cairo-lang release instead of archived 0.10.1-pre

@FabijanC FabijanC marked this pull request as ready for review October 18, 2022 07:17
@FabijanC FabijanC requested a review from mikiw October 18, 2022 07:17
test/util.py Show resolved Hide resolved
Copy link
Contributor

@mikiw mikiw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine to me!

@Arcticae
Copy link

@FabijanC i am running some tests from protostar against this branch, and discovered a possible bug (not present in the current release):

[2022-10-18 16:21:01 +0200] [66433] [ERROR] Exception on /gateway/add_transaction [POST]
Traceback (most recent call last):
  File "/Users/timelock/Library/Caches/pypoetry/virtualenvs/protostar-yi2_MPdx-py3.9/lib/python3.9/site-packages/flask/app.py", line 2073, in wsgi_app
    response = self.full_dispatch_request()
  File "/Users/timelock/Library/Caches/pypoetry/virtualenvs/protostar-yi2_MPdx-py3.9/lib/python3.9/site-packages/flask/app.py", line 1518, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/Users/timelock/Library/Caches/pypoetry/virtualenvs/protostar-yi2_MPdx-py3.9/lib/python3.9/site-packages/flask_cors/extension.py", line 165, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
  File "/Users/timelock/Library/Caches/pypoetry/virtualenvs/protostar-yi2_MPdx-py3.9/lib/python3.9/site-packages/flask/app.py", line 1516, in full_dispatch_request
    rv = self.dispatch_request()
  File "/Users/timelock/Library/Caches/pypoetry/virtualenvs/protostar-yi2_MPdx-py3.9/lib/python3.9/site-packages/flask/app.py", line 1502, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
  File "/Users/timelock/Library/Caches/pypoetry/virtualenvs/protostar-yi2_MPdx-py3.9/lib/python3.9/site-packages/asgiref/sync.py", line 218, in __call__
    return call_result.result()
  File "/Users/timelock/.asdf/installs/python/3.9.14/lib/python3.9/concurrent/futures/_base.py", line 439, in result
    return self.__get_result()
  File "/Users/timelock/.asdf/installs/python/3.9.14/lib/python3.9/concurrent/futures/_base.py", line 391, in __get_result
    raise self._exception
  File "/Users/timelock/Library/Caches/pypoetry/virtualenvs/protostar-yi2_MPdx-py3.9/lib/python3.9/site-packages/asgiref/sync.py", line 284, in main_wrap
    result = await self.awaitable(*args, **kwargs)
  File "/Users/timelock/Library/Caches/pypoetry/virtualenvs/protostar-yi2_MPdx-py3.9/lib/python3.9/site-packages/starknet_devnet/blueprints/gateway.py", line 29, in add_transaction
    contract_class_hash, transaction_hash = await state.starknet_wrapper.declare(
  File "/Users/timelock/Library/Caches/pypoetry/virtualenvs/protostar-yi2_MPdx-py3.9/lib/python3.9/site-packages/starknet_devnet/starknet_wrapper.py", line 275, in declare
    return class_hash_int, tx_handler.internal_tx.hash_value
UnboundLocalError: local variable 'class_hash_int' referenced before assignment

I tested this on running a declare tx, which has too low max_fee. Underlying exception handled by
__get_transaction_handler contextmanager is:

(500, {'code': <StarknetErrorCode.FEE_TRANSFER_FAILURE: 7>, 'message': 'Actual fee exceeded max fee.\n134900000000000 > 1'})

@FabijanC
Copy link
Collaborator Author

@Arcticae Thanks for reporting! Will make sure to include a fix before the release.

@FabijanC FabijanC merged commit a8b8f7c into master Oct 19, 2022
@FabijanC FabijanC deleted the adapt-0.10.1 branch October 19, 2022 07:46
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

StarkNet 0.10.1 adaptations Refactor DummyExecutionInfo
4 participants