Closed skosito closed 4 months ago
This update primarily enhances testing and code management. It introduces .eslintignore
and .gitignore
updates for ignoring the crytic-export
directory, changes function visibility in ERC20CustodyNew
and GatewayEVM
contracts, adds a new error type, and includes reinitialization checks. Additionally, it provides configurations for Echidna testing and integrates new test files for fuzz testing mechanisms.
Files/Paths | Change Summary |
---|---|
.eslintignore , .gitignore |
Added crytic-export to ignore list, preserving other existing entries. |
contracts/.../ERC20CustodyNew.sol |
Changed withdrawAndCall function visibility from external to public . |
contracts/.../GatewayEVM.sol |
Added new error type CustodyInitialized and added reinitialization check in setCustody function. |
echidna.yaml |
Introduced new file with configurations for crytic-compile . |
test/fuzz/ERC20CustodyNewEchidnaTest.sol |
New file to extend ERC20CustodyNew for testing withdrawal and calling functionality. |
test/fuzz/GatewayEVMEchidnaTest.sol |
New file to extend GatewayEVM for testing token execution with balance assertions. |
test/fuzz/readme.md |
Added setup instructions for Echidna, including installation, Solidity version configuration, and running tests. |
sequenceDiagram
participant Developer
participant ERC20CustodyNew
participant GatewayEVM
Note right of Developer: Setup Echidna Testing
Developer->>ERC20CustodyNew: Call withdrawAndCall as public
Developer->>GatewayEVM: Deploy and setup initial custody
GatewayEVM-->Developer: Error if custody already initialized
Developer->>Echidna: Configure and run tests
Echidna->>ERC20CustodyNew&GatewayEVM: Test fuzz cases
In fields of code where changes flow,
Functions now more public show,
Echidna tests run bright and fast,
Ensuring our contracts last.
Ignoring files both here and there,
Protects our repo, light as air.
With checks and balances now in place,
Our smart contracts bask in grace.
🐇✨
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
@lumtis @fadeev @fbac could you please check this draft and let me know your thoughts, especially on points in PR description? thanks
@coderabbitai full review
Attention: Patch coverage is 0%
with 2 lines
in your changes missing coverage. Please review.
Project coverage is 48.09%. Comparing base (
b0fbc16
) to head (4ec838c
).
Files | Patch % | Lines |
---|---|---|
contracts/prototypes/evm/ERC20CustodyNew.sol | 0.00% | 1 Missing :warning: |
contracts/prototypes/evm/GatewayEVM.sol | 0.00% | 1 Missing :warning: |
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
I think using Foundry more is a good idea. What I still like about Hardhat is the ability to import and use TypeScript tools, we're using them for everything in tutorials: balances, faucet, transaction tracking, code generation. But I think Hardhat-Foundry plugin is a good middle-ground.
I don't have enough experience with Echidna yet to make a proper statement. Regarding hardhat vs. foundry I'd say I prefer foundry because it allows native solidity testing, fuzzing and in general better it's a better testing suite than hh is. On the other hand, I get that it can be hard to fully migrate.
I agree with the proposed hardhat-foundry usage, it's a good middle ground and the full migration can happen if everyone agrees about foundry being the best solution.
Also, I'll be studying echidna so I can have informed opinions on it.
Looks good to me.
We don't need to be complete in this PR, just write the base.
foundry instead of hardhat: too much effort atm to migrate
What concrete work to migrate outside of rewriting the test and deployment scripts? Also myaybe we can have both supported atm?
i think tests and scripts, probably not that much effort if we only do it for v2 i will convert this PR to ready for review and try hadhat-foundry plugin in next PR (https://github.com/zeta-chain/protocol-contracts/issues/210), so PRs are smaller and more focused, because even if we move to foundry having echidna setup might still be beneficial
i think tests and scripts, probably not that much effort if we only do it for v2
We could also consider create entire new repo for v2 as the env is just completely different
@skosito can we add instructions in the PR how it can be tested?
yes, i added a readme in tests/fuzz/readme.md
, but also copied to PR description
Tested the commands, looking good to me
thank you, @fbac @fadeev could you please review as well, need 1 more review to close this one?
to test:
Setup echidna
Execute contract tests
just simple tests for now, and instructions on how to run, once we agree on approach we can open more issues for adding more fuzz tests same way its started here
alternatives: foundry has built in fuzz testing, and bunch of tools for better testing in general (for example cheatcodes: https://book.getfoundry.sh/forge/cheatcodes)
Summary by CodeRabbit
New Features
echidna.yaml
forcrytic-compile
configuration.ERC20CustodyNewEchidnaTest.sol
andGatewayEVMEchidnaTest.sol
for advanced testing.readme.md
.Bug Fixes
setCustody
function inGatewayEVM.sol
to prevent reinitialization.Refactor
withdrawAndCall
function visibility fromexternal
topublic
inERC20CustodyNew
.Chores
.eslintignore
and.gitignore
to includecrytic-export
directory.