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

Update to cairo v0.9.0 #364

Merged
merged 37 commits into from Jun 28, 2022
Merged

Conversation

andrew-fleming
Copy link
Collaborator

@andrew-fleming andrew-fleming commented Jun 17, 2022

Fixes #360, #357.

Thiis PR updates the cairo-lang version in tox to cairo-lang==0.9.0. Further, this PR refactors all of the test modules in order to conform to cairo-lang's v0.9.0 release. The bulk of this PR's proposed changes include:

  • changing contract_def for contract_class in the StarknetContract object
  • updating the memoization pattern to account for contract classes instead of contract definitions

This PR also proposes to refactor the proxy pattern by:

  • declaring implementation contracts instead of deploying them like normal contracts
  • changing the proxy reference to the implementation contract
    • the reference is now stored as a declared contract class hash as opposed to the contract address
  • using the new library_call and library_call_l1_handler instead of delegate_call and delegate_l1_handler
  • adding _hash to storage and methods e.g. get_implementation_hash instead of get_implementation
    • the idea is to be explicit with how proxies reference the implementation. Easy fix to change back if preferred

Finally, this PR also proposes to add the AdminChanged event to the Proxy library.

PR Checklist

  • Tests
  • Documentation
  • Changelog entry

@andrew-fleming andrew-fleming marked this pull request as ready for review June 18, 2022 00:21
ericglau added a commit to ericglau/contracts-wizard that referenced this pull request Jun 22, 2022
Copy link
Contributor

@martriay martriay left a comment

Choose a reason for hiding this comment

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

Phew! Long PR 😅

Great work, left some comments.

docs/Proxies.md Outdated Show resolved Hide resolved
docs/Proxies.md Outdated Show resolved Hide resolved
docs/Proxies.md Outdated Show resolved Hide resolved
docs/Proxies.md Outdated Show resolved Hide resolved
docs/Proxies.md Outdated Show resolved Hide resolved
tests/token/erc20/test_ERC20_Upgradeable.py Outdated Show resolved Hide resolved
Comment on lines +106 to +113
execution_info = await signer.send_transactions(
admin,
[
(proxy.contract_address, 'name', []),
(proxy.contract_address, 'symbol', []),
(proxy.contract_address, 'decimals', []),
(proxy.contract_address, 'totalSupply', [])
]
Copy link
Contributor

Choose a reason for hiding this comment

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

ahhhh so much better!

Comment on lines +135 to +141
# fetch values
execution_info = await signer.send_transactions(
admin,
[
(proxy.contract_address, 'balanceOf', [admin.contract_address]),
(proxy.contract_address, 'balanceOf', [USER]),
(proxy.contract_address, 'totalSupply', [])
Copy link
Contributor

Choose a reason for hiding this comment

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

i guess this also speeds up testing?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I forgot to compare! I'll confirm

Copy link
Contributor

@martriay martriay Jun 24, 2022

Choose a reason for hiding this comment

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

well it wasn't expected since the focus is not performance

Comment on lines 115 to 119
# check initial admin
execution_info = await signer.send_transaction(
admin, proxy.contract_address, 'getAdmin', []
)
assert execution_info.result.response == [admin.contract_address]
Copy link
Contributor

Choose a reason for hiding this comment

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

is this necessary? it looks like we're testing the fixture instead of the library behavior

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I suppose it's not necessary, more of a sanity check. We can remove it

@@ -15,7 +15,7 @@ passenv =
HOME
PYTHONPATH
deps =
cairo-lang==0.8.2.1
cairo-lang==0.9.0
Copy link
Contributor

Choose a reason for hiding this comment

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

we should probably release + pin nile too

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Agreed

@martriay martriay merged commit f7d319f into OpenZeppelin:main Jun 28, 2022
@andrew-fleming andrew-fleming deleted the update-0.9.0 branch June 28, 2022 23:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update to Cairo 0.9.0
2 participants