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

Add OpenZeppelin ERC20 transfers integration test #408

Merged
merged 3 commits into from
Apr 1, 2022

Conversation

ed255
Copy link
Member

@ed255 ed255 commented Mar 25, 2022

  • Add a test contract of a basic ERC20 Token using the OpenZeppelin
    implementation.
  • Add WETH9 base contract (not used yet in the integration tests)
  • Introduce three integration testing blocks:
    • 1 tx: failed ERC20 transfer
    • 1 tx: successful ERC20 transfer
    • 4 txs: interleaved successful and failed ERC20 transfers
  • Add macros in circuit_input_builder and circuits integration tests to
    define tests of each testing block easily.

Resolve #404


NOTE: The folder integration-tests/contracts/vendor/openzeppelin-contracts/ is a subtree repository from https://github.com/OpenZeppelin/openzeppelin-contracts.git and so there's no need to review any file from that folder.

@ed255 ed255 force-pushed the feature/integration-test-openzeppelin-erc201 branch from 8f8f45d to 35e9fec Compare March 25, 2022 15:08
@lispc
Copy link
Collaborator

lispc commented Mar 25, 2022

great job! Btw I finished end2end contract call proving using Greeter.sol ( set_value & retrieve ).

scroll-tech#120

( bus-mapping of sstore & sload / is_zero / shr / calldataload are needed and implemented there) .

I am going to test & debug ERC20 contracts here next week!!!

@ed255
Copy link
Member Author

ed255 commented Mar 25, 2022

Here's a summary of the output from running the tests:

  • The failure ERC20 transfer doesn't seem to use any more currently unimplemented opcodes than the successful transfer.
  • Used opcodes not implemented in bus-mapping nor evm circuit: SHA3, SSTORE, LOG3
  • Used opcodes not implemented in evm circuit: ISZERO, CALLDATASIZE, CALLDATALOAD, SHR (I think some of them are implemented but are missing from the OpcodeId to ExecutionState conversion in witness.rs from evm_circuit)

@ed255
Copy link
Member Author

ed255 commented Mar 25, 2022

great job! Btw I finished end2end contract call proving using Greeter.sol ( set_value & retrieve ).

scroll-tech#120

( bus-mapping of sstore & sload / is_zero / shr / calldataload are needed and implemented there) .

I am going to test & debug ERC20 contracts here next week!!!

That's great! 🎉 Looking forward to incorporate the changes in your PR as well :)

@ed255 ed255 force-pushed the feature/integration-test-openzeppelin-erc201 branch from 35e9fec to 3d81525 Compare March 25, 2022 16:08
@ed255 ed255 requested a review from CPerezz March 25, 2022 16:19
@ed255 ed255 force-pushed the feature/integration-test-openzeppelin-erc201 branch from 3d81525 to 776d748 Compare March 25, 2022 16:32
Copy link
Member

@CPerezz CPerezz left a comment

Choose a reason for hiding this comment

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

Everything looks good!

I maybe would have all of the contract stuff as a git sub-tree or sub-module (Highly encourage sub-tree) so that we are always in sync with these files and are easy to update.

WDYT @ed255 ??

Aside from that (which is not mandatory, just a quuestion) LGTM!!

Nice work!!!! 🥳

integration-tests/tests/circuits.rs Show resolved Hide resolved
@lispc
Copy link
Collaborator

lispc commented Mar 29, 2022

if we disable SHA3 & LOG3 ( I use dummy op which have no real constraints), multi ERC20 transfer including both success and failure can be proved now in my draft branch. scroll-tech#127

@ed255
Copy link
Member Author

ed255 commented Mar 29, 2022

I maybe would have all of the contract stuff as a git sub-tree or sub-module (Highly encourage sub-tree) so that we are always in sync with these files and are easy to update.

Thanks for the suggestion! I originally thought about using git submodule, but then I just copied the files we needed. But I think it's cleaner if we keep the original structure, so I just added the openzeppelin-contracts repository as a git subtree!

@ed255 ed255 force-pushed the feature/integration-test-openzeppelin-erc201 branch from bde86ea to 0e92b9b Compare March 29, 2022 16:13
@CPerezz
Copy link
Member

CPerezz commented Mar 30, 2022

I maybe would have all of the contract stuff as a git sub-tree or sub-module (Highly encourage sub-tree) so that we are always in sync with these files and are easy to update.

Thanks for the suggestion! I originally thought about using git submodule, but then I just copied the files we needed. But I think it's cleaner if we keep the original structure, so I just added the openzeppelin-contracts repository as a git subtree!

I would maybe add a README with some instructions/info about the fact that this is a sub-tree, how to update it (in case needed) etc..

WDYT @ed255 ?

@ed255
Copy link
Member Author

ed255 commented Mar 30, 2022

I would maybe add a README with some instructions/info about the fact that this is a sub-tree, how to update it (in case needed) etc..

Thanks for the suggestion! I've added a README in 7a0c1d3

@adria0
Copy link
Member

adria0 commented Apr 1, 2022

@CPerezz @ed255 I think that it will be better if we use gitmodules, mainly because in #382 also needs to import a repo that is really big https://github.com/ethereum/tests, and will be nice to have a unique way to import other sources.

I've been using submodules and works for me, but maybe git sub-tree has some kind of property that makes better to use in this project.

@ed255
Copy link
Member Author

ed255 commented Apr 1, 2022

@CPerezz @ed255 I think that it will be better if we use gitmodules, mainly because in #382 also needs to import a repo that is really big https://github.com/ethereum/tests, and will be nice to have a unique way to import other sources.

I've been using submodules and works for me, but maybe git sub-tree has some kind of property that makes better to use in this project.

I would also prefer to switch to submodules. I think it's much cleaner because we're not introducing so many files into our repository, and we just add a pointer to an external repository.
Also this submodule is only used for integration testing which has it's own setup, so most of the people can just not init the submodule and they'll be fine. Only when running the integration test we need the submodule initialized, but the integration test is controlled via a run.sh script so we can automate that.

@CPerezz
Copy link
Member

CPerezz commented Apr 1, 2022

@ed255 @adria0 Makes sense to go on the sub-module way if we don't need to edit any of the files that we will have in the sub-module.

Also, take into account that any changes done in the sub-module will always follow master/HEAD and so we will not be able to change anything if a new addition/modification goes against us.

@ed255 ed255 force-pushed the feature/integration-test-openzeppelin-erc201 branch from 7a0c1d3 to 558141a Compare April 1, 2022 13:48
@ed255
Copy link
Member Author

ed255 commented Apr 1, 2022

I've replaced the subtree by a submodule!

@ed255 @adria0 Makes sense to go on the sub-module way if we don't need to edit any of the files that we will have in the sub-module.

Yeah we don't need to edit any file from the external repository. And even if we had to touch some files in there, I'd prefer forking the external repo, doing the edit in the fork, and having a submodule pointing to our fork, just to keep things clean and separated.

Also, take into account that any changes done in the sub-module will always follow master/HEAD and so we will not be able to change anything if a new addition/modification goes against us.

I think that's not the case! When adding a submodule the commit id is stored, so everyone gets the same revision. Updates are manual. See 558141a where the commit id for the openzeppelin-contracts is stored in our repository.

@ed255 ed255 force-pushed the feature/integration-test-openzeppelin-erc201 branch from 558141a to e4d1da0 Compare April 1, 2022 13:52
- Add a test contract of a basic ERC20 Token using the OpenZeppelin
  implementation.
- Add WETH9 base contract (not used yet in the integration tests)
- Introduce three integration testing blocks:
    - 1 tx: failed ERC20 transfer
    - 1 tx: successful ERC20 transfer
    - 4 txs: interleaved successful and failed ERC20 transfers
- Add macros in circuit_input_builder and circuits integration tests to
  define tests of each testing block easily.
@ed255 ed255 force-pushed the feature/integration-test-openzeppelin-erc201 branch from e4d1da0 to b46e76a Compare April 1, 2022 14:11
@ed255 ed255 merged commit b6b5c62 into main Apr 1, 2022
zemse pushed a commit to zemse/zkevm-circuits that referenced this pull request Mar 22, 2023
@ChihChengLiang ChihChengLiang deleted the feature/integration-test-openzeppelin-erc201 branch May 17, 2023 08:13
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.

Add integration test with ERC20 (OpenZeppelin) transfer
4 participants