-
Notifications
You must be signed in to change notification settings - Fork 75
feat(Foundry): zkSync support #1097
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
Changes from all commits
3160b04
831c41e
211d1e2
96d46f1
ebedbbd
edcc212
1598dcd
812d0f1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,6 +28,7 @@ artifacts-zk | |
|
|
||
| # Foundry files | ||
| out | ||
| zkout | ||
|
|
||
| # Upgradeability files | ||
| .openzeppelin | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -77,6 +77,24 @@ forge script script/001DeployHubPool.s.sol:DeployHubPool --rpc-url ethereum --br | |||||||||
|
|
||||||||||
| ``` | ||||||||||
|
|
||||||||||
| #### Foundry (ZKSync) | ||||||||||
|
|
||||||||||
| To enable ZKSync support, the zksync fork of foundry must be installed (see [here](https://foundry-book.zksync.io/introduction/installation#using-foundryup-zksync) for instructions). | ||||||||||
|
|
||||||||||
| Also, the `FOUNDRY_PROFILE` environment variable must be set to `zksync`. | ||||||||||
|
|
||||||||||
| ```shell | ||||||||||
| export FOUNDRY_PROFILE=zksync | ||||||||||
|
|
||||||||||
| forge script script/016DeployZkSyncSpokePool.s.sol:DeployZkSyncSpokePool --rpc-url zksync --broadcast --verify -vvvv | ||||||||||
|
Comment on lines
+87
to
+89
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good point, merging this and will add this change to a follow up pr |
||||||||||
| ``` | ||||||||||
|
|
||||||||||
| Alternatively, the `yarn forge-script-zksync` command can be used to deploy the contract. | ||||||||||
|
|
||||||||||
| ```shell | ||||||||||
| yarn forge-script-zksync script/016DeployZkSyncSpokePool.s.sol:DeployZkSyncSpokePool --rpc-url zksync --broadcast --verify -vvvv | ||||||||||
| ``` | ||||||||||
|
|
||||||||||
| ### SVM | ||||||||||
|
|
||||||||||
| Before deploying for the first time make sure all program IDs in `lib.rs` and `Anchor.toml` are the same as listed when running `anchor keys list`. If not, update them to match the deployment keypairs under `target/deploy/` and commit the changes. | ||||||||||
|
|
||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,11 +11,11 @@ import { DeploymentUtils } from "./utils/DeploymentUtils.sol"; | |
|
|
||
| // How to run: | ||
| // 1. `source .env` where `.env` has MNEMONIC="x x x ... x" | ||
| // 2. forge script script/059DeployLensSpokePool.s.sol:DeployLensSpokePool --rpc-url $NODE_URL_1 -vvvv | ||
| // 2. yarn forge-script-zksync script/059DeployLensSpokePool.s.sol:DeployLensSpokePool --rpc-url lens -vvvv | ||
| // 3. Verify the above works in simulation mode. | ||
| // 4. Deploy with: | ||
| // forge script script/059DeployLensSpokePool.s.sol:DeployLensSpokePool --rpc-url \ | ||
| // $NODE_URL_1 --broadcast --verify --verifier blockscout --verifier-url https://verify.lens.xyz/contract_verification | ||
| // yarn forge-script-zksync script/059DeployLensSpokePool.s.sol:DeployLensSpokePool --rpc-url lens \ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So what would happen if you ran this script without the zksync suffix? Would an error throw somewhere? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you dont need the zksync suffix, as long as And if you dont have that env var for lens and zksync then the check will fail There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this flag is the same as adding the |
||
| // --broadcast --verify --verifier blockscout --verifier-url https://verify.lens.xyz/contract_verification | ||
|
|
||
| contract DeployLensSpokePool is Script, Test, DeploymentUtils { | ||
| function run() external { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,6 +30,10 @@ contract DeploymentUtils is Script, Test, Constants, DeployedAddresses { | |
| bool isNewProxy; | ||
| } | ||
|
|
||
| constructor() { | ||
| checkZkSyncChain(block.chainid); | ||
| } | ||
|
|
||
| /** | ||
| * @notice Get deployment information for SpokePool deployment | ||
| * @dev This function mimics getSpokePoolDeploymentInfo from utils.hre.ts | ||
|
|
@@ -190,4 +194,26 @@ contract DeploymentUtils is Script, Test, Constants, DeployedAddresses { | |
| chainId == getChainId("LISK_SEPOLIA") || | ||
| chainId == getChainId("MODE_SEPOLIA"); | ||
| } | ||
|
|
||
| /** | ||
| * @notice Check if a chain ID is a ZkSync chain | ||
| * @dev This function will revert if the chain ID is a ZkSync chain but the FOUNDRY_PROFILE is not zksync | ||
| * @param chainId Chain ID to check | ||
| */ | ||
| function checkZkSyncChain(uint256 chainId) internal view { | ||
| bool isZkSyncChain = chainId == getChainId("ZK_SYNC") || | ||
| chainId == getChainId("ZK_SYNC_SEPOLIA") || | ||
| chainId == getChainId("LENS") || | ||
| chainId == getChainId("LENS_TESTNET"); | ||
|
|
||
| string memory foundryProfile = vm.envOr("FOUNDRY_PROFILE", string("default")); | ||
|
|
||
| if (isZkSyncChain) { | ||
| vm.assertEq( | ||
| foundryProfile, | ||
| string("zksync"), | ||
| "Chain is a ZkSync chain but FOUNDRY_PROFILE is not zksync. Use yarn forge-script-zksync to deploy" | ||
| ); | ||
| } | ||
| } | ||
|
Comment on lines
+203
to
+218
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @fusmanii We have the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All good, though that PR is now closed - is there something to replace it? Just want to make sure we circle back to it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yup, recreating that pr since it got very messy, will include in that |
||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.