Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ artifacts-zk

# Foundry files
out
zkout

# Upgradeability files
.openzeppelin
Expand Down
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

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

Using export in the example will make FOUNDRY_PROFILE persist beyond the deployment; it might be better to set it at runtime so it's not persistent:

Suggested change
export FOUNDRY_PROFILE=zksync
forge script script/016DeployZkSyncSpokePool.s.sol:DeployZkSyncSpokePool --rpc-url zksync --broadcast --verify -vvvv
FOUNDRY_PROFILE=zksync forge script script/016DeployZkSyncSpokePool.s.sol:DeployZkSyncSpokePool --rpc-url zksync --broadcast --verify -vvvv

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.
Expand Down
23 changes: 23 additions & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,31 @@ fs_permissions = [{ access = "read", path = "./"}]
solc = "0.8.23"
evm_version = "prague"

[profile.zksync.zksync]
compile = true
fallback_oz = true
mode = '3'
zksolc = "1.5.7"

[rpc_endpoints]
arbitrum = "${NODE_URL_42161}"
base = "${NODE_URL_8453}"
bsc = "${NODE_URL_56}"
ethereum = "${NODE_URL_1}"
ink = "${NODE_URL_57073}"
lens = "${NODE_URL_262}"
linea = "${NODE_URL_59144}"
lisk = "${NODE_URL_1135}"
mode = "${NODE_URL_34443}"
optimism = "${NODE_URL_10}"
polygon = "${NODE_URL_137}"
redstone = "${NODE_URL_690}"
scroll = "${NODE_URL_534352}"
soneium = "${NODE_URL_1868}"
unichain = "${NODE_URL_130}"
world-chain = "${NODE_URL_480}"
zksync = "${NODE_URL_324}"


[etherscan]
ethereum = { key = "${ETHERSCAN_API_KEY}" }
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@
"main": "dist/index.js",
"scripts": {
"compile-zksync": "COMPILE_ZK=true yarn hardhat compile",
"forge-script-zksync": " FOUNDRY_PROFILE=zksync forge script --zksync --suppress-errors sendtransfer",
"lint": "yarn lint-solidity && yarn lint-js && yarn lint-rust",
"lint-solidity": "yarn solhint ./contracts/**/*.sol",
"lint-js": "yarn prettier --list-different **/*.js **/*.ts",
"lint-rust": "cargo +nightly fmt --all -- --check && cargo clippy",
"lint-fix": "yarn prettier --write **/*.js **/*.ts ./programs/**/*.rs ./contracts**/*.sol && cargo +nightly fmt --all && cargo clippy",
"clean-fast": "for dir in node_modules cache cache-zk artifacts artifacts-zk dist typechain out; do mv \"${dir}\" \"_${dir}\"; rm -rf \"_${dir}\" &; done",
"clean": "rm -rf node_modules cache cache-zk artifacts artifacts-zk dist typechain out",
"clean-fast": "for dir in node_modules cache cache-zk artifacts artifacts-zk dist typechain out zkout; do mv \"${dir}\" \"_${dir}\"; rm -rf \"_${dir}\" &; done",
"clean": "rm -rf node_modules cache cache-zk artifacts artifacts-zk dist typechain out zkout",
"generate-svm-artifacts": "bash ./scripts/svm/buildHelpers/buildIdl.sh && sh ./scripts/svm/buildHelpers/generateSvmAssets.sh && yarn generate-svm-clients",
"generate-svm-clients": "yarn ts-node ./scripts/svm/buildHelpers/generateSvmClients.ts && yarn ts-node ./scripts/svm/buildHelpers/renameClientsImports.ts",
"build-evm": "hardhat compile",
Expand Down
6 changes: 3 additions & 3 deletions script/059DeployLensSpokePool.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Copy link
Member

Choose a reason for hiding this comment

The 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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you dont need the zksync suffix, as long as FOUNDRY_PROFILE=zksync is there, it will compile with zksolc

And if you dont have that env var for lens and zksync then the check will fail

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this flag is the same as adding the --zksync flag

// --broadcast --verify --verifier blockscout --verifier-url https://verify.lens.xyz/contract_verification

contract DeployLensSpokePool is Script, Test, DeploymentUtils {
function run() external {
Expand Down
26 changes: 26 additions & 0 deletions script/utils/DeploymentUtils.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

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

@fusmanii We have the family attribute in the networks definitions in constants - wdyt about just evaluating on that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@pxrl I can make the change in my constants.json pr since I don't have the family attribute exposed yet

Copy link
Contributor

Choose a reason for hiding this comment

The 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.

Copy link
Contributor Author

@fusmanii fusmanii Sep 17, 2025

Choose a reason for hiding this comment

The 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

}
Loading