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

Remove dualcase SRC5 #882

Merged
merged 22 commits into from Mar 18, 2024
Merged

Conversation

TAdev0
Copy link
Contributor

@TAdev0 TAdev0 commented Jan 30, 2024

Fixes #841

PR Checklist

  • Tests
  • Documentation
  • Added entry to CHANGELOG.md
  • Tried the feature on a public network

@TAdev0
Copy link
Contributor Author

TAdev0 commented Feb 1, 2024

@martriay what would be the best way to test this removal feature on a public network?

@martriay
Copy link
Contributor

martriay commented Feb 1, 2024

maybe for this module we don't need that

@TAdev0
Copy link
Contributor Author

TAdev0 commented Feb 1, 2024

@martriay i don't know why, but after removing dualSRC5, i get a new class hash for ERC721 (which is expected), but i get the same class hash for Account. Is this the normal behaviour? Account also exposes SRC5Impl, the class hash shoud also be modified, no?

@TAdev0
Copy link
Contributor Author

TAdev0 commented Feb 1, 2024

mmh actually it seems neither ERC721 nor Account exposes SRC5Camel, this means the class hash shouldn't change for both?

@TAdev0
Copy link
Contributor Author

TAdev0 commented Feb 1, 2024

update: now i get it . I changed _check_on_erc721_received function in the ERC721 so that it doesn't use DualCaseSRC5anymore, this is why class hash changed for ERC721 and not for Account !

@martriay
Copy link
Contributor

martriay commented Feb 1, 2024

Then we should test those presets onchain.

@TAdev0
Copy link
Contributor Author

TAdev0 commented Feb 1, 2024

How should i test that? Deploying the ERC721 preset and check that _check_on_ERC721_received works as expected?

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.

The PR is looking good! Yes, we need to test the callback works properly, and we wanted to go the extra mile we could also test that it does not work for camelCase ERC721Receivers, although that's very complex to set up, not really needed I guess.

src/tests/mocks/src5_mocks.cairo Outdated Show resolved Hide resolved
@TAdev0
Copy link
Contributor Author

TAdev0 commented Feb 7, 2024

@martriay ok now i found out the issue : removing dualcase SRC5 will break compatibility in some cases.

I cannot send ERC721 tokens to a Braavos Goerli wallet cairo0, because it only implements camelCase supportsInterface. I finally succceded with an Argent wallet cairo2 as a receiver, with a succesfull on_erc721_received callback.

Braavos account contract are still in cairo 0 on mainnet, with only camelCase impl for supportInterface function. Any ERC721 transfers to such an account will fail if the ERC721 contract doesnt implement dualcase SRC5.

Here is the goerli address of the ERC721 contract i deployed, minting 1 token to the deployer.
0x6c087b2e2bc55bb8168cabe4486761787bf3aac4d77a4c39a0a8de4385493c7

And the tx hash of the safeTransferFrom call, to transfer 1 token on a Argent wallet
0x73a77d6f740162aaff45e709cb93f7e280f9c4bee4fbb973af87f32707d8993

Copy link
Member

@ericnordelo ericnordelo left a comment

Choose a reason for hiding this comment

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

Looking good! Left a couple of comments and we still need to remove the supportsInterface method from ABIs like the Account and the EDRC721 ones in the interface files.

src/token/erc721/erc721.cairo Outdated Show resolved Hide resolved
src/token/erc721/erc721.cairo Outdated Show resolved Hide resolved
@ericnordelo
Copy link
Member

Braavos account contract are still in cairo 0 on mainnet, with only camelCase impl for supportInterface function. Any ERC721 transfers to such an account will fail if the ERC721 contract doesnt implement dualcase SRC5.

With dualcase SRC5 they shouldn't work either, because the interface used in Cairo 0 was ERC165 like, not the one we are using with SRC5 nowadays.

@TAdev0
Copy link
Contributor Author

TAdev0 commented Feb 8, 2024

@ericnordelo oh ok thank you very much for these informations!

@TAdev0
Copy link
Contributor Author

TAdev0 commented Feb 8, 2024

@ericnordelo i think we should also remove all the test_dual_supportsInterface functions in tests?

@TAdev0
Copy link
Contributor Author

TAdev0 commented Feb 8, 2024

@ericnordelo pr updated.

There are still some mentions to camelCase supportsInterface in various files (mocks especially), but i think these ones shouldn't be removed?

Copy link
Member

@ericnordelo ericnordelo left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Collaborator

@andrew-fleming andrew-fleming left a comment

Choose a reason for hiding this comment

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

Thanks for picking this up, @TAdev0! I left a couple comments, but we're looking good so far.

There are still some mentions to camelCase supportsInterface in various files (mocks especially), but i think these ones shouldn't be removed?

I think they can be removed. The camelCase supportsInterface was only there to support the dual casings and I don't see why we should keep them. This also includes removing the supportsInterface fallback from the dual case modules (example here). The try_selector_with_fallback should be replaced with the standard call_contract_syscall. Correct me if I'm wrong @martriay @ericnordelo

src/account/interface.cairo Outdated Show resolved Hide resolved
src/tests/mocks/src5_mocks.cairo Outdated Show resolved Hide resolved
@TAdev0
Copy link
Contributor Author

TAdev0 commented Feb 16, 2024

@andrew-fleming just updated the PR. Now supportsInterface is removed everywhere.

There is just one mention, still, in erc1155.doc. But there is no snake case supports_interface (its erc165 compliant) so i guess we should leave it like this ?

Copy link
Collaborator

@andrew-fleming andrew-fleming left a comment

Choose a reason for hiding this comment

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

There is just one mention, still, in erc1155.doc. But there is no snake case supports_interface (its erc165 compliant) so i guess we should leave it like this ?

Yeah, the erc1155 doc is from cairo v0, so no need to worry about that here. LGTM! Thanks again for picking this up 🙏

@ericnordelo
Copy link
Member

Thanks again for taking the time @TAdev0. After solving the conflicts, we can merge this to main already.

@TAdev0
Copy link
Contributor Author

TAdev0 commented Mar 15, 2024

@ericnordelo @andrew-fleming i resolved conflicts and updated the code for ERC1155 which used again the DualCaseSRC5 interface.

For now, i'm having issues declaring the contracts on a testnet, i don"t know why. ERC721 and ERC1155 class hashes still need to be updated, can you take care of it? I can try again tomorrow but sncast seems not to be working on sepolia

@andrew-fleming
Copy link
Collaborator

For now, i'm having issues declaring the contracts on a testnet, i don"t know why...I can try again tomorrow but sncast seems not to be working on sepolia

The RPC probably hasn't updated to Sierra 1.5 yet. I switched to blast and declared/deployed the relevant presets in this PR on sepolia.

ERC721

ERC1155


ERC721 and ERC1155 class hashes still need to be updated, can you take care of it?

The class hashes are only going to be updated during releases from now on, so we don't have to worry about that anymore. And I think we're good to go :) thanks, @TAdev0!

@andrew-fleming andrew-fleming merged commit b87bb29 into OpenZeppelin:main Mar 18, 2024
5 checks passed
@TAdev0
Copy link
Contributor Author

TAdev0 commented Mar 18, 2024

great! thank you :)

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.

Remove dualcase SRC5
4 participants