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

import paths updated for zkSync scripts #811

Merged
merged 10 commits into from
Sep 30, 2024
Merged

import paths updated for zkSync scripts #811

merged 10 commits into from
Sep 30, 2024

Conversation

0xDEnYO
Copy link
Contributor

@0xDEnYO 0xDEnYO commented Sep 25, 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 Sep 25, 2024

Warning

Rate limit exceeded

@0xDEnYO has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 12 minutes and 7 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Files that changed from the base of the PR and between 199488d and dfdd520.

Walkthrough

The changes involve updates to import paths across multiple TypeScript deployment scripts within the zksync directory. The modifications reflect a restructuring of the project's directory hierarchy, requiring adjustments to the relative paths for various configuration files and modules. These updates ensure that the scripts maintain correct references to the necessary resources after the reorganization.

Changes

Files Change Summary
script/deploy/zksync/006_deploy_receiver.ts, 007_deploy_fee_collector.ts, 008_deploy_service_fee_collector.ts, 013_deploy_lifuel_fee_collector.ts, 015_deploy_celerim_facet.ts, 017_deploy_token_wrapper.ts, 018_deploy_symbiosis_facet.ts Updated import paths for PeripheryRegistryFacet, globalConfig, and other configuration files to reflect a new relative path of ../../../.
script/deploy/zksync/010_deploy_cbridge_facet.ts, 011_deploy_cbridge_facet_packed.ts, 012_deploy_across_facet.ts, 016_deploy_across_facet_packed.ts Updated import paths for cbridge.json and across.json to reflect a new relative path of ../../../.
script/utils/diamond.ts Updated import paths for IDiamondCut and IDiamondLoupe types to reflect a new relative path of ../../.
package.json Added a newline character at the end of the file.

Possibly related PRs

  • Reorg zksync and util scripts #799: The changes in this PR involve a reorganization of the zksync scripts, including updates to import paths that align with the directory restructuring seen in the main PR.

Suggested reviewers

  • ezynda3

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 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
Copy link
Collaborator

Test Coverage Report

Line Coverage: 75.15% (1576 / 2097 lines)
Function Coverage: 83.25% ( 343 / 412 functions)
Branch Coverage: 49.31% ( 253 / 513 branches)
Test coverage (75.15%) is above min threshold (74%). 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: 5

🧹 Outside diff range and nitpick comments (7)
script/deploy/zksync/010_deploy_cbridge_facet.ts (1)

Line range hint 16-31: Consider enhancing error handling in the deployment function

The deployment function looks good overall, but there's an opportunity to improve error handling. Currently, if the network configuration is missing, the function logs a message and returns silently. Consider throwing an error in this case to make deployment failures more explicit.

Here's a suggested improvement:

 const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
   if (!(config as CBridgeConfig)[network.name]) {
-    console.log(`No cBridge config set for ${network.name}. Skipping...`)
-    return
+    throw new Error(`No cBridge config set for ${network.name}. Deployment cannot proceed.`)
   }

   const CBRIDGE = (config as CBridgeConfig)[network.name].cBridge
+  if (!CBRIDGE) {
+    throw new Error(`CBRIDGE address not set for ${network.name}. Deployment cannot proceed.`)
+  }

   await deployFacet(hre, 'CBridgeFacet', { args: [CBRIDGE] })
 }

This change will make the deployment process fail explicitly if the required configuration is missing, which can help prevent silent failures and make debugging easier.

script/deploy/zksync/016_deploy_across_facet_packed.ts (1)

Line range hint 7-11: Consider improving type safety and error handling

While the current implementation works, there are a few areas where we could enhance type safety and error handling:

  1. Instead of casting config to AcrossConfig multiple times, consider creating a typed variable:

    const typedConfig: AcrossConfig = config as AcrossConfig;
  2. Enhance error handling for missing network configuration:

    if (!(network.name in typedConfig)) {
      throw new Error(`No Across config set for ${network.name}. Skipping...`);
    }
  3. Consider using a more specific type for the imported config, rather than relying on type assertion:

    import config from '../../../config/across.json' assert { type: 'json' };
  4. Add checks for required config values:

    const networkConfig = typedConfig[network.name];
    if (!networkConfig.acrossSpokePool || !networkConfig.weth) {
      throw new Error(`Missing required config for ${network.name}`);
    }

These changes would make the script more robust and easier to maintain.

Also applies to: 16-22

script/deploy/zksync/015_deploy_celerim_facet.ts (3)

Line range hint 1-9: Consider standardizing import styles and improving type definitions.

  1. For consistency, consider using named imports throughout the file. For example, change import fs from 'fs' to import { readFileSync } from 'fs'.

  2. The CBridgeConfig interface could be moved to a separate types file for better organization and reusability.

  3. To avoid type assertions, consider properly typing the imported config:

import config from '../../../config/cbridge.json' assert { type: 'json' };
const typedConfig: CBridgeConfig = config;

This way, you can use typedConfig[network.name] without type assertions.

Also applies to: 12-15


Line range hint 30-34: Consider using asynchronous file reading.

Replace the synchronous fs.readFileSync with an asynchronous version for better performance, especially in a deployment script where file I/O shouldn't block the event loop:

import { promises as fs } from 'fs';

// Inside an async function
const data = JSON.parse(await fs.readFile(addressesFile, 'utf8')) as AddressesFile;

Line range hint 52-57: Remove or uncomment dependencies as needed.

The commented-out dependencies at the end of the file should either be removed if they're no longer needed, or uncommented if they're still required. Keeping commented-out code can lead to confusion and maintenance issues.

script/deploy/zksync/007_deploy_fee_collector.ts (1)

Line range hint 22-23: Consider adding validation for the WITHDRAW_WALLET address

The script uses globalConfig.withdrawWallet as an argument for the FeeCollector contract. While using a predefined address from a config file is generally good practice, it's important to ensure that this address is valid before using it in the deployment.

Consider adding a validation check for the WITHDRAW_WALLET address before using it in the deployment. You can use ethers.js to validate the address. Here's an example of how you could implement this:

const WITHDRAW_WALLET = globalConfig.withdrawWallet

if (!ethers.utils.isAddress(WITHDRAW_WALLET)) {
  throw new Error(`Invalid withdraw wallet address: ${WITHDRAW_WALLET}`)
}

// Rest of the deployment script...

This check will ensure that the deployment fails early if the withdraw wallet address is not valid, preventing potential issues down the line.

script/deploy/zksync/013_deploy_lifuel_fee_collector.ts (1)

⚠️ Remaining Import Path References Detected

Multiple scripts still reference '../typechain' and '../config/global.json'. These outdated import paths may cause import errors or unexpected behaviors.

Affected Files:

  • script/utils/diamond.ts
  • script/deploy/zksync/017_deploy_token_wrapper.ts
  • script/deploy/zksync/013_deploy_lifuel_fee_collector.ts
  • script/deploy/zksync/007_deploy_fee_collector.ts
  • script/demoScripts/demoThorSwap.ts
  • ... (and others listed in the shell script output)

Please update all import paths to align with the new directory structure to ensure seamless functionality.

🔗 Analysis chain

Line range hint 1-71: Functionality appears unaffected, consider manual testing

The changes to the import paths do not affect the script's logic or functionality. The usage of PeripheryRegistryFacet and globalConfig remains consistent with the previous version. However, to ensure everything works as expected after the directory restructuring, it would be prudent to perform a manual test of this deployment script in a test environment.

To further verify the script's integrity, let's check for any references to the old import paths:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining references to the old import paths

# Test 1: Check for any remaining references to '../typechain'
if rg -q "../typechain" .; then
    echo "Warning: Found references to '../typechain'. Please check these occurrences:"
    rg "../typechain" .
else
    echo "No references to '../typechain' found. Good!"
fi

# Test 2: Check for any remaining references to '../config/global.json'
if rg -q "../config/global.json" .; then
    echo "Warning: Found references to '../config/global.json'. Please check these occurrences:"
    rg "../config/global.json" .
else
    echo "No references to '../config/global.json' found. Good!"
fi

Length of output: 4917

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between fe08498 and 4badbaf.

📒 Files selected for processing (11)
  • script/deploy/zksync/006_deploy_receiver.ts (1 hunks)
  • script/deploy/zksync/007_deploy_fee_collector.ts (1 hunks)
  • script/deploy/zksync/008_deploy_service_fee_collector.ts (1 hunks)
  • script/deploy/zksync/010_deploy_cbridge_facet.ts (1 hunks)
  • script/deploy/zksync/011_deploy_cbridge_facet_packed.ts (1 hunks)
  • script/deploy/zksync/012_deploy_across_facet.ts (1 hunks)
  • script/deploy/zksync/013_deploy_lifuel_fee_collector.ts (1 hunks)
  • script/deploy/zksync/015_deploy_celerim_facet.ts (1 hunks)
  • script/deploy/zksync/016_deploy_across_facet_packed.ts (1 hunks)
  • script/deploy/zksync/017_deploy_token_wrapper.ts (1 hunks)
  • script/deploy/zksync/018_deploy_symbiosis_facet.ts (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • script/deploy/zksync/012_deploy_across_facet.ts
  • script/deploy/zksync/018_deploy_symbiosis_facet.ts
🔇 Additional comments not posted (14)
script/deploy/zksync/010_deploy_cbridge_facet.ts (2)

Line range hint 1-37: Overall assessment: Good with minor suggestions

The main change to the import path looks correct, pending verification. The rest of the file follows good TypeScript practices, using interfaces for type-checking and a structured approach to deployment. The suggested improvement to error handling would make the script more robust, but overall, the code is well-structured and maintainable.


5-5: Verify the updated import path

The import path for the cbridge.json config file has been updated to reflect a change in the file structure. This change looks correct, assuming the script file has been moved deeper into the directory structure.

To ensure the new path is correct and consistent with other files, please run the following script:

✅ Verification successful

Import path verified successfully

The cbridge.json config file exists at the new path, and all relevant files import it correctly.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the existence of the config file and check for consistency in other files

# Test 1: Check if the config file exists at the new path
if [ -f "config/cbridge.json" ]; then
  echo "Config file exists at the new path."
else
  echo "Error: Config file not found at config/cbridge.json"
fi

# Test 2: Check for other occurrences of cbridge.json imports
echo "Other occurrences of cbridge.json imports:"
rg --type typescript "import.*from.*cbridge\.json"

Length of output: 296


Script:

#!/bin/bash
# Description: Verify the existence of the config file and check for consistency in other files

# Test 1: Check if the config file exists at the new path
if [ -f "config/cbridge.json" ]; then
  echo "Config file exists at the new path."
else
  echo "Error: Config file not found at config/cbridge.json"
fi

# Test 2: Check for other occurrences of cbridge.json imports in .ts and .tsx files
echo "Other occurrences of cbridge.json imports:"
rg --glob '*.ts' "import.*from.*cbridge\.json"
rg --glob '*.tsx' "import.*from.*cbridge\.json"

Length of output: 760

script/deploy/zksync/011_deploy_cbridge_facet_packed.ts (2)

Line range hint 1-38: File integrity maintained after import path update.

The change in the import path for cbridge.json doesn't affect the rest of the file's functionality. The imported config object is used correctly throughout the script, and no other imports or file references require updates based on this change.


5-5: LGTM. Verify the new import path.

The import path update for the cbridge.json config file looks correct, aligning with the PR objective of updating import paths for zkSync scripts.

To ensure the new path is correct, please run the following verification script:

script/deploy/zksync/016_deploy_across_facet_packed.ts (1)

5-5: LGTM! Verify the new import path.

The updated import path for the config file is consistent with the PR objectives. This change suggests that the script file has been moved deeper into the directory structure.

To ensure the new path is correct, please run the following script:

This script will verify the existence of the config file, display its content, and check for any remaining occurrences of the old import path in the zksync deploy scripts.

script/deploy/zksync/015_deploy_celerim_facet.ts (1)

10-11: Import paths updated correctly.

The import paths for config/cbridge.json and config/global.json have been updated to reflect the new directory structure. This change is consistent with the PR objectives of updating import paths for zkSync scripts.

To ensure the new paths are correct, let's verify the existence of these config files:

✅ Verification successful

Import paths verified successfully.

The configuration files cbridge.json and global.json exist at the updated paths, ensuring that the import statements are correct and consistent with the new directory structure. No issues found.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify the existence of the config files
echo "Checking for cbridge.json:"
fd --type f "cbridge.json" --exec echo "Found: {}"
echo "Checking for global.json:"
fd --type f "global.json" --exec echo "Found: {}"

Length of output: 281

script/deploy/zksync/017_deploy_token_wrapper.ts (2)

Line range hint 1-67: Suggestion: Test the deployment process

While the import path changes don't directly affect the script's logic, it's crucial to verify that the deployment process still functions correctly after these modifications.

Please ensure that:

  1. The script can be executed without any import-related errors.
  2. The TokenWrapper contract is deployed successfully.
  3. The PeripheryRegistry is updated correctly with the new TokenWrapper address.

Consider running the deployment in a test environment to confirm these points.


Line range hint 1-67: LGTM. Well-structured deployment script.

The overall structure and functionality of the script are well-implemented. It includes:

  • Network-specific deployment protection
  • Proper use of hardhat and ethers for deployment and interactions
  • Checks to prevent unnecessary registry updates
  • Contract verification step

These are all good practices for deployment scripts.

script/deploy/zksync/007_deploy_fee_collector.ts (1)

Line range hint 1-67: LGTM! The script structure and functionality remain intact

The changes to the import statements don't affect the functionality of the script. The usage of PeripheryRegistryFacet and globalConfig in the script body is correct, and the overall structure follows best practices for Hardhat deployment scripts. The script correctly deploys a FeeCollector contract and registers it with a PeripheryRegistry.

script/deploy/zksync/008_deploy_service_fee_collector.ts (2)

Line range hint 1-71: Confirm: Rest of the script unaffected by import changes

I've reviewed the entire script, and it appears that the functionality remains intact despite the changes to the import paths. The usage of imported entities (PeripheryRegistryFacet, diamondContractName, updateDeploymentLogs, verifyContract, and globalConfig) is consistent with their new import locations.

The script's specific behavior for 'zksync' and 'zksyncGoerli' networks is maintained, and no other parts of the script required updates due to the import changes.


Line range hint 1-71: Summary: Import paths updated as part of project restructuring

This pull request successfully updates the import paths for PeripheryRegistryFacet and globalConfig in the 008_deploy_service_fee_collector.ts script. These changes appear to be part of a larger effort to restructure the project's directory hierarchy.

The modifications ensure that the script maintains correct references to necessary resources after the reorganization, while the core functionality of the script remains unchanged. This update is crucial for the continued proper operation of the deployment process for the ServiceFeeCollector contract on zkSync networks.

As a final note, it might be beneficial to review other scripts in the script/deploy/zksync/ directory to ensure consistent updates across all affected files.

script/deploy/zksync/006_deploy_receiver.ts (3)

11-12: Verify the correctness of the updated stargate and amarok config import paths.

The import paths for stargateConfig and amarokConfig have been changed from ../config/... to ../../../config/.... These changes are consistent with the previous import path updates. Please ensure that these new paths are correct and that the stargate.json and amarok.json files exist at the specified locations.

Run the following script to verify the import paths:

#!/bin/bash
# Description: Verify the existence of the stargate.json and amarok.json files and their content.

# Test 1: Check if the config files exist
for file in stargate.json amarok.json; do
  if [ -f "config/$file" ]; then
    echo "$file exists in the config directory."
  else
    echo "$file not found in the config directory."
  fi
done

# Test 2: Check the content of the config files (if they exist)
for file in stargate.json amarok.json; do
  if [ -f "config/$file" ]; then
    echo "Content of $file:"
    cat "config/$file"
    echo ""
  fi
done

# Test 3: Check for any remaining old import paths
rg --type typescript '../config/stargate.json'
rg --type typescript '../config/amarok.json'

10-10: Verify the correctness of the updated global config import path.

The import path for globalConfig has been changed from ../config/global.json to ../../../config/global.json. This change is consistent with the previous import path update. Please ensure that this new path is correct and that the global.json file exists at the specified location.

Run the following script to verify the import path:

#!/bin/bash
# Description: Verify the existence of the global.json file and its content.

# Test 1: Check if the global.json file exists
if [ -f "config/global.json" ]; then
  echo "global.json file exists in the config directory."
else
  echo "global.json file not found in the config directory."
fi

# Test 2: Check the content of global.json (if it exists)
if [ -f "config/global.json" ]; then
  echo "Content of global.json:"
  cat config/global.json
fi

# Test 3: Check for any remaining old import paths
rg --type typescript '../config/global.json'

4-12: Summary of changes and potential impact.

The changes in this file are limited to updating import paths for various configurations and types. These updates are consistent with the PR objectives of updating import paths for zkSync scripts. While the changes appear straightforward, it's crucial to ensure that:

  1. The new paths are correct and the imported files exist at the specified locations.
  2. These changes don't inadvertently break the functionality of the deployment script.
  3. Similar updates have been made consistently across all affected files in the project.

To ensure the script still functions correctly with the updated import paths, run the following verification:

If any issues are found during verification, please address them before merging this PR.

@0xDEnYO 0xDEnYO marked this pull request as ready for review September 26, 2024 02:10
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

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 4badbaf and 199488d.

📒 Files selected for processing (2)
  • package.json (1 hunks)
  • script/utils/diamond.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • package.json

script/utils/diamond.ts Show resolved Hide resolved
@0xDEnYO 0xDEnYO marked this pull request as draft September 26, 2024 07:03
@0xDEnYO 0xDEnYO marked this pull request as ready for review September 26, 2024 07:04
@0xDEnYO 0xDEnYO enabled auto-merge (squash) September 26, 2024 07:20
@0xDEnYO 0xDEnYO marked this pull request as draft September 30, 2024 02:48
auto-merge was automatically disabled September 30, 2024 02:48

Pull request was converted to draft

@0xDEnYO 0xDEnYO marked this pull request as ready for review September 30, 2024 02:49
@0xDEnYO 0xDEnYO enabled auto-merge (squash) September 30, 2024 02:50
@0xDEnYO 0xDEnYO merged commit e7667ad into main Sep 30, 2024
11 checks passed
@0xDEnYO 0xDEnYO deleted the fixZkSyncScripts branch September 30, 2024 02:54
@coderabbitai coderabbitai bot mentioned this pull request Nov 25, 2024
7 tasks
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