-
Notifications
You must be signed in to change notification settings - Fork 51
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
Conversation
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 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. WalkthroughThe changes involve updates to import paths across multiple TypeScript deployment scripts within the Changes
Possibly related PRs
Suggested reviewers
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Test Coverage ReportLine Coverage: 75.15% (1576 / 2097 lines) |
There was a problem hiding this 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 functionThe 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 handlingWhile the current implementation works, there are a few areas where we could enhance type safety and error handling:
Instead of casting
config
toAcrossConfig
multiple times, consider creating a typed variable:const typedConfig: AcrossConfig = config as AcrossConfig;Enhance error handling for missing network configuration:
if (!(network.name in typedConfig)) { throw new Error(`No Across config set for ${network.name}. Skipping...`); }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' };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.
For consistency, consider using named imports throughout the file. For example, change
import fs from 'fs'
toimport { readFileSync } from 'fs'
.The
CBridgeConfig
interface could be moved to a separate types file for better organization and reusability.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 addressThe 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 DetectedMultiple 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 testingThe changes to the import paths do not affect the script's logic or functionality. The usage of
PeripheryRegistryFacet
andglobalConfig
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!" fiLength of output: 4917
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 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 suggestionsThe 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 pathThe 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 importedconfig
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
andconfig/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
andglobal.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 processWhile 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:
- The script can be executed without any import-related errors.
- The TokenWrapper contract is deployed successfully.
- 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 intactThe changes to the import statements don't affect the functionality of the script. The usage of
PeripheryRegistryFacet
andglobalConfig
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 changesI'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
, andglobalConfig
) 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 restructuringThis pull request successfully updates the import paths for
PeripheryRegistryFacet
andglobalConfig
in the008_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
andamarokConfig
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 thestargate.json
andamarok.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 theglobal.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:
- The new paths are correct and the imported files exist at the specified locations.
- These changes don't inadvertently break the functionality of the deployment script.
- 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.
There was a problem hiding this 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
📒 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
Which Jira task belongs to this PR?
Why did I implement it this way?
Checklist before requesting a review
Checklist for reviewer (DO NOT DEPLOY and contracts BEFORE CHECKING THIS!!!)