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

Update zksync flow #901

Merged
merged 2 commits into from
Dec 11, 2024
Merged

Update zksync flow #901

merged 2 commits into from
Dec 11, 2024

Conversation

ezynda3
Copy link
Contributor

@ezynda3 ezynda3 commented Dec 10, 2024

Which Jira task belongs to this PR?

Why did I implement it this way?

Checklist before requesting a review

  • I have performed a self-review of my code
  • This pull request is as small as possible and only tackles one problem
  • I have added tests that cover the functionality / test the bug
  • I have updated any required documentation

Checklist for reviewer (DO NOT DEPLOY and contracts BEFORE CHECKING THIS!!!)

  • I have checked that any arbitrary calls to external contracts are validated and or restricted
  • I have checked that any privileged calls (i.e. storage modifications) are validated and or restricted
  • I have ensured that any new contracts have had AT A MINIMUM 1 preliminary audit conducted on by <company/auditor>

Copy link
Contributor

coderabbitai bot commented Dec 10, 2024

Walkthrough

This pull request introduces several changes across multiple scripts and configuration files. It adds entries to the .gitignore file to exclude forge and cast, deletes the Dockerfile used for building Foundry images, and modifies the deployment script to streamline the deployment process for the zksync network. Additionally, a new function for installing Foundry tools is introduced in helper functions, and the main script is updated to enhance functionality and user interaction.

Changes

File Change Summary
foundry-zksync/.gitignore Added entries for forge and cast to be ignored by Git.
foundry-zksync/Dockerfile Deleted the Dockerfile that contained instructions for building a Docker image for the Foundry project.
script/deploy/deploySingleContract.sh Modified to remove Docker commands, added checks for existing deployments, refined SALT handling, and improved error handling and user interaction.
script/helperFunctions.sh Introduced a new function install_foundry_zksync for downloading and installing Foundry tools with error handling and documentation enhancements.
script/scriptMaster.sh Added a new function install_foundry_zksync, updated control flow for user prompts, and included TODO comments for future enhancements.

Possibly related PRs

  • import paths updated for zkSync scripts #811: This PR updates import paths for zkSync scripts, which may relate to the changes in the .gitignore file that includes forge and cast, as these tools are likely used in the scripts being modified.
  • Deprecate Makefile #822: The deprecation of the Makefile in this PR indicates a shift towards using forge, which aligns with the changes in the main PR that adds forge to the .gitignore.
  • read min coverage from secrets instead of hardcoded value #859: This PR modifies the handling of minimum test coverage, which may indirectly relate to the changes in the main PR as both involve aspects of project configuration and management.
  • Script improvements #874: The improvements in the scripts for diamond synchronization may relate to the overall project structure and management, similar to the changes made in the main PR regarding the .gitignore file.

Suggested reviewers

  • 0xDEnYO

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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 using 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 generate docstrings to generate docstrings for this PR. (Experiment)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

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.

@lifi-action-bot lifi-action-bot marked this pull request as draft December 10, 2024 09:18
@ezynda3 ezynda3 marked this pull request as ready for review December 10, 2024 09:18
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: 1

🧹 Outside diff range and nitpick comments (3)
script/helperFunctions.sh (3)

3750-3768: Ensure reliable download by handling failed attempts

The download section uses either curl or wget based on availability. Consider adding error handling to check if neither tool is available and provide a clear error message. Additionally, ensure that if the download fails, the script exits gracefully.

Apply this diff to improve error handling:

 if command -v curl &> /dev/null; then
     curl -L -o "${install_dir}/${filename}" "$download_url"
+    DOWNLOAD_STATUS=$?
 elif command -v wget &> /dev/null; then
     wget -O "${install_dir}/${filename}" "$download_url"
+    DOWNLOAD_STATUS=$?
 else
     echo "Neither curl nor wget is installed"
     return 1
 fi

-# Check if download was successful
-# $? contains the return status of the last command
-if [ $? -ne 0 ]; then
+if [ $DOWNLOAD_STATUS -ne 0 ]; then
     echo "Download failed"
     return 1
 fi

3714-3723: Enhance operating system detection for broader compatibility

The current OS detection handles darwin and linux-gnu cases. Consider expanding the pattern matching to include other variations of Linux identifiers, such as linux-gnueabihf or linux-musl, to ensure broader compatibility across different Linux distributions.

Example modification:

 elif [[ "$OSTYPE" == "linux-"* ]]; then
     os="linux"

3769-3777: Verify the integrity of downloaded files

To ensure the security and integrity of the downloaded binaries, consider adding a checksum verification step after downloading the file. This can prevent issues arising from corrupted or tampered files.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 2e885fc and ffe35f4.

📒 Files selected for processing (5)
  • foundry-zksync/.gitignore (1 hunks)
  • foundry-zksync/Dockerfile (0 hunks)
  • script/deploy/deploySingleContract.sh (2 hunks)
  • script/helperFunctions.sh (3 hunks)
  • script/scriptMaster.sh (1 hunks)
💤 Files with no reviewable changes (1)
  • foundry-zksync/Dockerfile
✅ Files skipped from review due to trivial changes (1)
  • foundry-zksync/.gitignore
🧰 Additional context used
📓 Learnings (1)
script/deploy/deploySingleContract.sh (1)
Learnt from: 0xDEnYO
PR: lifinance/contracts#782
File: script/deploy/deploySingleContract.sh:231-231
Timestamp: 2024-11-26T01:18:52.125Z
Learning: In the `deploySingleContract.sh` script, environment variable assignments preceding the `forge script` command (e.g., `DEPLOYSALT=$DEPLOYSALT ... forge script ...`) are acceptable and function correctly, even when variable expansions like `$DIAMOND_TYPE` and `$NETWORK` are used later in the same command.
🪛 Shellcheck (0.10.0)
script/deploy/deploySingleContract.sh

[warning] 227-227: This assignment is only seen by the forked process.

(SC2097)


[warning] 227-227: This expansion will not see the mentioned assignment.

(SC2098)

🔇 Additional comments (3)
script/deploy/deploySingleContract.sh (2)

210-213: Ensure environment variables are correctly used with zkSync-specific commands

The added commands set FOUNDRY_PROFILE=zksync and invoke the zkSync-specific forge commands. This is appropriate for handling zkSync deployments. Ensure that the environment variable FOUNDRY_PROFILE is recognized by the forge command and that the --zksync flag is necessary for your build process.


226-227: Confirm environment variable assignments in command invocation

The line assigns multiple environment variables before invoking the forge script command for zkSync deployments. While this pattern works in many shells, some static analysis tools may warn about variable assignments preceding commands not being visible within the command. Since prior learnings indicate that this approach functions correctly in your environment, you can proceed but consider validating to ensure compatibility.

🧰 Tools
🪛 Shellcheck (0.10.0)

[warning] 227-227: This assignment is only seen by the forked process.

(SC2097)


[warning] 227-227: This expansion will not see the mentioned assignment.

(SC2098)

script/scriptMaster.sh (1)

137-138: Ensure zkSync binaries are installed before deployment

By invoking install_foundry_zksync, the script now proactively checks and installs the zkSync-specific Foundry binaries if they are not already present. This enhances the robustness of deployments to the zkSync network by ensuring that all necessary tools are available.

script/helperFunctions.sh Show resolved Hide resolved
@lifi-action-bot
Copy link
Collaborator

Test Coverage Report

Line Coverage: 77.92% (2139 / 2745 lines)
Function Coverage: 84.00% ( 373 / 444 functions)
Branch Coverage: 37.47% ( 208 / 555 branches)
Test coverage (77.92%) is above min threshold (76%). Check passed.

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 and nitpick comments (1)
script/helperFunctions.sh (1)

3741-3818: Consider adding checksum verification for downloaded binaries.

While the installation logic is well-implemented, it would be safer to verify the integrity of downloaded binaries using checksums before execution.

 # Download the file using curl or wget, whichever is available
 if command -v curl &> /dev/null; then
     curl -L -o "${install_dir}/${filename}" "$download_url"
+    # Download checksum file
+    curl -L -o "${install_dir}/${filename}.sha256" "${download_url}.sha256"
 elif command -v wget &> /dev/null; then
     wget -O "${install_dir}/${filename}" "$download_url"
+    # Download checksum file
+    wget -O "${install_dir}/${filename}.sha256" "${download_url}.sha256"
 else
     echo "Neither curl nor wget is installed"
     return 1
 fi

+# Verify checksum
+if ! sha256sum -c "${install_dir}/${filename}.sha256"; then
+    echo "Checksum verification failed"
+    rm -f "${install_dir}/${filename}" "${install_dir}/${filename}.sha256"
+    return 1
+fi
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between ffe35f4 and 8141f48.

📒 Files selected for processing (1)
  • script/helperFunctions.sh (3 hunks)
🧰 Additional context used
📓 Learnings (1)
script/helperFunctions.sh (1)
Learnt from: ezynda3
PR: lifinance/contracts#901
File: script/helperFunctions.sh:3693-3701
Timestamp: 2024-12-10T09:27:41.956Z
Learning: In the Bash script `script/helperFunctions.sh`, the `install_foundry_zksync` function does not require external specification of `FOUNDRY_ZKSYNC_VERSION` via environment variables. The hardcoded version is acceptable.
🔇 Additional comments (3)
script/helperFunctions.sh (3)

1430-1431: LGTM: ZKSync verification integration looks good!

The code properly integrates ZKSync contract verification using foundry-zksync, with appropriate handling of debug/non-debug modes and correct chain configuration.

Also applies to: 1439-1440, 1449-1450, 1456-1457, 1459-1459


3680-3701: LGTM: Well-documented function with proper version handling!

The function documentation and version handling are well-implemented. The hardcoded version is acceptable as confirmed in the learnings.


3713-3740: LGTM: Robust platform detection implementation!

The code implements comprehensive platform detection with:

  • Support for macOS and Linux
  • Handling of x86_64 and ARM architectures
  • Clear error handling for unsupported platforms

@ezynda3 ezynda3 merged commit 5ce2653 into main Dec 11, 2024
17 of 18 checks passed
@ezynda3 ezynda3 deleted the update-zksync-deployment-flow branch December 11, 2024 10:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants