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

feat: deploy zrc 20 script #338

Merged
merged 3 commits into from
Sep 10, 2024
Merged

feat: deploy zrc 20 script #338

merged 3 commits into from
Sep 10, 2024

Conversation

skosito
Copy link
Contributor

@skosito skosito commented Aug 19, 2024

  • adds script to deploy zrc20 with all args from constructor passed as env vars to script

  • removes fungible module sender check from constructor in zrc20

  • do we need more zevm scripts? probably gateway zevm, can do in different PR
    what about system contract?

closes: #333

Summary by CodeRabbit

  • New Features

    • Introduced the ability to deploy ZRC20 tokens on the ZK-EVM blockchain with a new deployment script.
    • Added new environment variables to support configurable ZRC20 token attributes.
  • Documentation

    • Updated README files to streamline information regarding deployment scripts and environment variable setup.
    • Enhanced documentation links for better accessibility to the latest contract references.
  • Bug Fixes

    • Removed outdated references in deployment documentation to improve clarity.

Copy link
Contributor

coderabbitai bot commented Aug 19, 2024

Walkthrough

Walkthrough

The changes introduce a new deployment script for ZRC20 tokens, enhancing the project's configurability by adding environment variables for token parameters. The constructor's access control in the ZRC20 contract has been relaxed, allowing broader initialization access. Documentation updates include hyperlink modifications to ensure users reference the latest source code, improving navigability and accuracy for developers interacting with the system.

Changes

Files Change Summary
v2/.env.sample Added environment variables for ZRC20 token deployment parameters (name, symbol, decimals, etc.).
v2/contracts/zevm/ZRC20.sol Removed access control check in the constructor, allowing any address to initialize the contract.
v2/scripts/deploy/DeployZRC20.s.sol New script added to deploy ZRC20 token contracts with customizable parameters from the environment.
v2/docs/src/*.md Updated Git source links to point to new commits, ensuring direct access to the latest documentation.
v2/scripts/deploy/readme.md New documentation file providing setup instructions for deployment scripts and environment variables.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant DeployZRC20 Script
    participant ZRC20 Contract
    participant Environment

    User->>DeployZRC20 Script: Execute run()
    DeployZRC20 Script->>Environment: Retrieve token parameters
    DeployZRC20 Script->>ZRC20 Contract: Create instance with parameters
    ZRC20 Contract-->>DeployZRC20 Script: Confirm deployment
    DeployZRC20 Script-->>User: Return success
Loading

Assessment against linked issues

Objective Addressed Explanation
Add script to deploy ZRC20 (Issue #333)
Allow customization of constructor values (Issue #333)

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?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.62%. Comparing base (9193cf9) to head (b8229cd).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #338      +/-   ##
==========================================
+ Coverage   82.35%   82.62%   +0.27%     
==========================================
  Files           7        7              
  Lines         306      305       -1     
  Branches       99       98       -1     
==========================================
  Hits          252      252              
+ Misses         54       53       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Outside diff range, codebase verification and nitpick comments (4)
v2/scripts/deploy/readme.md (3)

3-3: Grammar Correction: Improve sentence structure.

Consider rephrasing for clarity: "Check .env.sample for an example of how it should look."

- check `.env.sample` for example on how it should look like.
+ check `.env.sample` for an example of how it should look.
Tools
LanguageTool

[grammar] ~3-~3: ‘Like’ cannot be used with the question word ‘how’ in this context.
Context: ...pts, check .env.sample for example on how it should look like. Currently, .env.sample is set with t...

(HOW_IT_SHOULD_BE)


6-6: Grammar Correction: Add missing articles.

Consider adding "the" for clarity: "To execute the deployment script, the following format is needed:"

- To execute deployment script, following format is needed:
+ To execute the deployment script, the following format is needed:
Tools
LanguageTool

[uncategorized] ~6-~6: You might be missing the article “the” here.
Context: ... first account private key. To execute deployment script, following format is needed: ``...

(AI_EN_LECTOR_MISSING_DETERMINER_THE)


[uncategorized] ~6-~6: You might be missing the article “the” here.
Context: ...ate key. To execute deployment script, following format is needed: ``` forge script scr...

(AI_EN_LECTOR_MISSING_DETERMINER_THE)


8-10: Specify Language for Code Block.

Add a language identifier to the code block for better syntax highlighting in Markdown.

- ```
+ ```shell
Tools
Markdownlint

8-8: null
Fenced code blocks should have a language specified

(MD040, fenced-code-language)

v2/scripts/deploy/DeployZRC20.s.sol (1)

1-45: Deployment Script Implementation Looks Good.

The script effectively uses environment variables for configuration and includes necessary checks to verify deployment success.

Consider improving the error message for clarity:

- require(address(zrc20) != address(0), "deployment failed");
+ require(address(zrc20) != address(0), "ZRC20 deployment failed");
Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 9193cf9 and b8229cd.

Files ignored due to path filters (7)
  • v2/pkg/beaconproxy.sol/beaconproxy.go is excluded by !v2/pkg/**
  • v2/pkg/gatewayevmzevm.t.sol/gatewayevmzevmtest.go is excluded by !v2/pkg/**
  • v2/pkg/gatewayzevm.t.sol/gatewayzevminboundtest.go is excluded by !v2/pkg/**
  • v2/pkg/gatewayzevm.t.sol/gatewayzevmoutboundtest.go is excluded by !v2/pkg/**
  • v2/pkg/zrc20.sol/zrc20.go is excluded by !v2/pkg/**
  • v2/pkg/zrc20.t.sol/zrc20test.go is excluded by !v2/pkg/**
  • v2/types/factories/ZRC20.sol/ZRC20__factory.ts is excluded by !v2/types/**
Files selected for processing (38)
  • v2/.env.sample (1 hunks)
  • v2/contracts/zevm/ZRC20.sol (1 hunks)
  • v2/docs/src/README.md (1 hunks)
  • v2/docs/src/contracts/Revert.sol/interface.Revertable.md (1 hunks)
  • v2/docs/src/contracts/Revert.sol/struct.RevertContext.md (1 hunks)
  • v2/docs/src/contracts/Revert.sol/struct.RevertOptions.md (1 hunks)
  • v2/docs/src/contracts/evm/ERC20Custody.sol/contract.ERC20Custody.md (1 hunks)
  • v2/docs/src/contracts/evm/GatewayEVM.sol/contract.GatewayEVM.md (1 hunks)
  • v2/docs/src/contracts/evm/ZetaConnectorBase.sol/abstract.ZetaConnectorBase.md (1 hunks)
  • v2/docs/src/contracts/evm/ZetaConnectorNative.sol/contract.ZetaConnectorNative.md (1 hunks)
  • v2/docs/src/contracts/evm/ZetaConnectorNonNative.sol/contract.ZetaConnectorNonNative.md (1 hunks)
  • v2/docs/src/contracts/evm/interfaces/IERC20Custody.sol/interface.IERC20Custody.md (1 hunks)
  • v2/docs/src/contracts/evm/interfaces/IERC20Custody.sol/interface.IERC20CustodyErrors.md (1 hunks)
  • v2/docs/src/contracts/evm/interfaces/IERC20Custody.sol/interface.IERC20CustodyEvents.md (1 hunks)
  • v2/docs/src/contracts/evm/interfaces/IGatewayEVM.sol/interface.IGatewayEVM.md (1 hunks)
  • v2/docs/src/contracts/evm/interfaces/IGatewayEVM.sol/interface.IGatewayEVMErrors.md (1 hunks)
  • v2/docs/src/contracts/evm/interfaces/IGatewayEVM.sol/interface.IGatewayEVMEvents.md (1 hunks)
  • v2/docs/src/contracts/evm/interfaces/IZetaConnector.sol/interface.IZetaConnectorEvents.md (1 hunks)
  • v2/docs/src/contracts/evm/interfaces/IZetaNonEthNew.sol/interface.IZetaNonEthNew.md (1 hunks)
  • v2/docs/src/contracts/zevm/GatewayZEVM.sol/contract.GatewayZEVM.md (1 hunks)
  • v2/docs/src/contracts/zevm/ZRC20.sol/contract.ZRC20.md (1 hunks)
  • v2/docs/src/contracts/zevm/ZRC20.sol/interface.ZRC20Errors.md (1 hunks)
  • v2/docs/src/contracts/zevm/interfaces/IGatewayZEVM.sol/interface.IGatewayZEVM.md (1 hunks)
  • v2/docs/src/contracts/zevm/interfaces/IGatewayZEVM.sol/interface.IGatewayZEVMErrors.md (1 hunks)
  • v2/docs/src/contracts/zevm/interfaces/IGatewayZEVM.sol/interface.IGatewayZEVMEvents.md (1 hunks)
  • v2/docs/src/contracts/zevm/interfaces/ISystem.sol/interface.ISystem.md (1 hunks)
  • v2/docs/src/contracts/zevm/interfaces/IWZETA.sol/interface.IWETH9.md (1 hunks)
  • v2/docs/src/contracts/zevm/interfaces/IZRC20.sol/enum.CoinType.md (1 hunks)
  • v2/docs/src/contracts/zevm/interfaces/IZRC20.sol/interface.IZRC20.md (1 hunks)
  • v2/docs/src/contracts/zevm/interfaces/IZRC20.sol/interface.IZRC20Metadata.md (1 hunks)
  • v2/docs/src/contracts/zevm/interfaces/IZRC20.sol/interface.ZRC20Events.md (1 hunks)
  • v2/docs/src/contracts/zevm/interfaces/UniversalContract.sol/interface.UniversalContract.md (1 hunks)
  • v2/docs/src/contracts/zevm/interfaces/UniversalContract.sol/interface.zContract.md (1 hunks)
  • v2/docs/src/contracts/zevm/interfaces/UniversalContract.sol/struct.zContext.md (1 hunks)
  • v2/docs/src/index.md (1 hunks)
  • v2/scripts/deploy/DeployZRC20.s.sol (1 hunks)
  • v2/scripts/deploy/deterministic/readme.md (1 hunks)
  • v2/scripts/deploy/readme.md (1 hunks)
Files skipped from review due to trivial changes (34)
  • v2/docs/src/README.md
  • v2/docs/src/contracts/Revert.sol/interface.Revertable.md
  • v2/docs/src/contracts/Revert.sol/struct.RevertContext.md
  • v2/docs/src/contracts/Revert.sol/struct.RevertOptions.md
  • v2/docs/src/contracts/evm/ERC20Custody.sol/contract.ERC20Custody.md
  • v2/docs/src/contracts/evm/GatewayEVM.sol/contract.GatewayEVM.md
  • v2/docs/src/contracts/evm/ZetaConnectorBase.sol/abstract.ZetaConnectorBase.md
  • v2/docs/src/contracts/evm/ZetaConnectorNative.sol/contract.ZetaConnectorNative.md
  • v2/docs/src/contracts/evm/ZetaConnectorNonNative.sol/contract.ZetaConnectorNonNative.md
  • v2/docs/src/contracts/evm/interfaces/IERC20Custody.sol/interface.IERC20Custody.md
  • v2/docs/src/contracts/evm/interfaces/IERC20Custody.sol/interface.IERC20CustodyErrors.md
  • v2/docs/src/contracts/evm/interfaces/IERC20Custody.sol/interface.IERC20CustodyEvents.md
  • v2/docs/src/contracts/evm/interfaces/IGatewayEVM.sol/interface.IGatewayEVM.md
  • v2/docs/src/contracts/evm/interfaces/IGatewayEVM.sol/interface.IGatewayEVMErrors.md
  • v2/docs/src/contracts/evm/interfaces/IGatewayEVM.sol/interface.IGatewayEVMEvents.md
  • v2/docs/src/contracts/evm/interfaces/IZetaConnector.sol/interface.IZetaConnectorEvents.md
  • v2/docs/src/contracts/evm/interfaces/IZetaNonEthNew.sol/interface.IZetaNonEthNew.md
  • v2/docs/src/contracts/zevm/GatewayZEVM.sol/contract.GatewayZEVM.md
  • v2/docs/src/contracts/zevm/ZRC20.sol/contract.ZRC20.md
  • v2/docs/src/contracts/zevm/ZRC20.sol/interface.ZRC20Errors.md
  • v2/docs/src/contracts/zevm/interfaces/IGatewayZEVM.sol/interface.IGatewayZEVM.md
  • v2/docs/src/contracts/zevm/interfaces/IGatewayZEVM.sol/interface.IGatewayZEVMErrors.md
  • v2/docs/src/contracts/zevm/interfaces/IGatewayZEVM.sol/interface.IGatewayZEVMEvents.md
  • v2/docs/src/contracts/zevm/interfaces/ISystem.sol/interface.ISystem.md
  • v2/docs/src/contracts/zevm/interfaces/IWZETA.sol/interface.IWETH9.md
  • v2/docs/src/contracts/zevm/interfaces/IZRC20.sol/enum.CoinType.md
  • v2/docs/src/contracts/zevm/interfaces/IZRC20.sol/interface.IZRC20.md
  • v2/docs/src/contracts/zevm/interfaces/IZRC20.sol/interface.IZRC20Metadata.md
  • v2/docs/src/contracts/zevm/interfaces/IZRC20.sol/interface.ZRC20Events.md
  • v2/docs/src/contracts/zevm/interfaces/UniversalContract.sol/interface.UniversalContract.md
  • v2/docs/src/contracts/zevm/interfaces/UniversalContract.sol/interface.zContract.md
  • v2/docs/src/contracts/zevm/interfaces/UniversalContract.sol/struct.zContext.md
  • v2/docs/src/index.md
  • v2/scripts/deploy/deterministic/readme.md
Additional context used
LanguageTool
v2/scripts/deploy/readme.md

[grammar] ~3-~3: ‘Like’ cannot be used with the question word ‘how’ in this context.
Context: ...pts, check .env.sample for example on how it should look like. Currently, .env.sample is set with t...

(HOW_IT_SHOULD_BE)


[uncategorized] ~6-~6: You might be missing the article “the” here.
Context: ... first account private key. To execute deployment script, following format is needed: ``...

(AI_EN_LECTOR_MISSING_DETERMINER_THE)


[uncategorized] ~6-~6: You might be missing the article “the” here.
Context: ...ate key. To execute deployment script, following format is needed: ``` forge script scr...

(AI_EN_LECTOR_MISSING_DETERMINER_THE)

Markdownlint
v2/scripts/deploy/readme.md

8-8: null
Fenced code blocks should have a language specified

(MD040, fenced-code-language)

Additional comments not posted (2)
v2/.env.sample (1)

9-20: Environment Variables for ZRC20 Deployment Look Good.

The addition of these environment variables aligns with the PR's objective to enhance configurability for ZRC20 deployments.

v2/contracts/zevm/ZRC20.sol (1)

Line range hint 42-42: Potential Security Risk: Relaxed Access Control in Constructor.

The removal of the sender check in the constructor broadens accessibility, which could lead to unauthorized deployments. Ensure that this change does not introduce security vulnerabilities.

Consider reviewing the implications of this change in the broader context of the system's security model.

Comment on lines +10 to +17
address gateway = vm.envAddress("GATEWAY_PROXY_ZEVM");
address systemContract = vm.envAddress("SYSTEM_CONTRACT");
string memory name = vm.envString("ZRC20_NAME");
string memory symbol = vm.envString("ZRC20_SYMBOL");
uint8 decimals = uint8(vm.envUint("ZRC20_DECIMALS"));
uint chainID = vm.envUint("ZRC20_CHAIN_ID");
CoinType coinType = CoinType(vm.envUint("ZRC20_COIN_TYPE"));
uint gasLimit = vm.envUint("ZRC20_GAS_LIMIT");
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: we should by default check programmatically that every variable is correctly set and contains a valid value. One way of doing it would be by using try catch after every address, and revert the script execution if it's not valid.

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 script to deploy ZRC20
4 participants