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

[CHORE] Smart Contract Improvements #14

Open
17 of 20 tasks
tim-schultz opened this issue May 23, 2023 · 2 comments · Fixed by #16
Open
17 of 20 tasks

[CHORE] Smart Contract Improvements #14

tim-schultz opened this issue May 23, 2023 · 2 comments · Fixed by #16
Assignees

Comments

@tim-schultz
Copy link
Contributor

tim-schultz commented May 23, 2023

Testing

  • Make unit tests as easy to understand as possible. Remove duplicate mocks and comments where necessary
  • Ensure final contracts have 100% test coverage. As of 5/18 we are at 91.3%
    Image
  • Write fuzz tests? - It looks like https://github.com/crytic/echidna is a popular choice

Both Contracts

  • Lock the solidity version

GitcoinAttester

  • remove setEASAddress and set address in constructor
  • eas address is redundant if we have EAS contract we can get address

GitcoinVerifier

  • revert within the _verify function. With this method you could remove the if statement all together and revert for the independent reasons(nonce/signature)
  • remove _hashArray
  • DOMAIN_SEPARATOR (contracts/GitcoinVerifier.sol#22) should be immutable
  • attester (contracts/GitcoinVerifier.sol#16) should be immutable
  • issuer (contracts/GitcoinVerifier.sol#17) should be immutable
  • bytes32 private constant EIP712DOMAIN_TYPEHASH, bytes32 private constant STAMP_TYPEHASH, bytes32 private constant PASSPORT_TYPEHASH can be prehashed and the values can be assigned to the bytes32 value - will minimize gas in deployment
  • Add an onlyOwner withdraw function to contract. Funds would currently be locked forever. This would also require the contract to be updated to ownable. Another option could be an allowed address set in the constructor/deployment
  • Convert loops to unchecked loop to reduce gas usage https://hackmd.io/@totomanov/gas-optimization-loops#2-Increment-the-variable-in-an-unchecked-block

General

  • remove console.logs
  • Adjust hardhat compiler version to match solidity version that we lock to
  • Move to yarn? We use this for all other project
  • Ensure all contracts are fully commented
  • Improve error handling - revert should be specific to case that causes revert
  • Deployment Checklist(set env variables, contract owners, verifiers, etc..)
@tim-schultz tim-schultz converted this from a draft issue May 23, 2023
@tim-schultz tim-schultz moved this from Backlog to In Progress (WIP) in Passport May 25, 2023
@tim-schultz tim-schultz removed their assignment May 25, 2023
@tim-schultz tim-schultz moved this from In Progress (WIP) to Backlog in Passport May 25, 2023
@chibie chibie moved this from Backlog to In Progress (WIP) in Passport May 29, 2023
@chibie chibie self-assigned this May 29, 2023
@tim-schultz
Copy link
Contributor Author

It would be great to be able to run tests against any environment. Currently they will only pass you have your rpc set to point at Sepolia.

This can be changed by deploying a mock version of EAS instead of referencing the version that is deployed on Sepolia https://github.com/gitcoinco/eas-proxy/blob/7f6700b981b8ae77a84a77f51d1a80dc8b5d051e/test/GitcoinAttester.ts#L89

@chibie chibie reopened this May 31, 2023
@chibie chibie moved this from In Progress (WIP) to Product/UX Review in Passport May 31, 2023
@Jkd-eth Jkd-eth moved this from Product/UX Review to Ready to Deploy in Passport Jun 2, 2023
@tim-schultz tim-schultz moved this from Ready to Deploy to Done in Passport Jun 7, 2023
@dmrazzy
Copy link

dmrazzy commented Jul 23, 2024

Change

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 a pull request may close this issue.

3 participants