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

Feature: add zksync support to v1.5.0 #742

Merged
merged 23 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
2891ee8
feat: add zksync support to the project
mmv08 Aug 26, 2024
1d1cc31
Add zksync support to proxy address calculation functions
mmv08 Aug 26, 2024
fa637f6
fix: remove unnecessary await
mmv08 Aug 26, 2024
633c130
Update tsconfig.json to include src/utils directory
mmv08 Aug 26, 2024
f287fbe
Remove unused types and simplify contract instantiation.
mmv08 Aug 26, 2024
79f02c8
Remove unnecessary await parentheses in Safe.setup call.
mmv08 Aug 27, 2024
bfa8fe5
"Refactor imports to use ethers directly instead of hre for consisten…
mmv08 Aug 27, 2024
7bbb778
"Use deployerAccount variable consistently instead of process.env"
mmv08 Aug 27, 2024
b3fd69a
Change import from "hardhat" to only import "ethers".
mmv08 Aug 27, 2024
1191ce0
"Update hre import to use deployments and ethers"
mmv08 Aug 27, 2024
11dd4c9
"Update test/migration/subTests.spec.ts to use hre and ethers imports…
mmv08 Aug 27, 2024
e92e979
Migrate zkSync to Sepolia and fix deploy tasks for ZK environment
mmv08 Aug 27, 2024
e645808
Skip zksync tests until node plugin is updated.
mmv08 Aug 27, 2024
d907eb3
feat: add zkSync deployment support
mmv08 Aug 27, 2024
99868c7
Refactor deploy-contracts task for zkSync deployment support
mmv08 Aug 27, 2024
e43ae89
Fix deployer account retrieval for ZkSync networks
mmv08 Aug 27, 2024
112778e
"Update dependencies to latest versions"
mmv08 Aug 27, 2024
8f0ac6d
"Update zksolc version to 1.5.3 and types/chai to 4.3.19"
mmv08 Sep 2, 2024
c46b60b
Update versions of several dependencies
mmv08 Sep 2, 2024
e74a9a0
"Refactor zk verification to improve readability and maintainability"
mmv08 Sep 2, 2024
df9ab82
Skip tests for zkSync network in migration and sign message library s…
mmv08 Sep 2, 2024
293a312
"Update TypeScript ESLint dependencies to latest version"
mmv08 Sep 3, 2024
e546942
Update dependencies to latest versions of @matterlabs/hardhat-zksync-…
mmv08 Sep 5, 2024
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
4 changes: 4 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,9 @@ SAFE_CONTRACT_UNDER_TEST="Safe"
SOLIDITY_VERSION= # Example: '0.8.19'
# For running coverage tests, `details` section of solidity settings are required, else could be removed.
SOLIDITY_SETTINGS= # Example: '{"viaIR":true,"optimizer":{"enabled":true, "details": {"yul": true, "yulDetails": { "optimizerSteps": ""}}}}'
# Set to 1 to run hardhat in zksync mode. This will enable the ZK compiler and run the hardhat node in zksync mode.
HARDHAT_ENABLE_ZKSYNC=0
# Sets hardhat chain id. In general, you don't need this, it's only used for testing the SafeToL2Setup contract.
HARDHAT_CHAIN_ID=31337
# (Optional) Hardhat-deploy only supports zksync deployment if the private key for the account is provided. Specify the private key here.
ZKSYNC_DEPLOYER_PK="0x7726827caac94a7f9e1b160f7ea819f172f7b6f9d2a97f992c38edeab82d4110"
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ jobs:
cache: "npm"
- run: npm ci
- run: npm run lint:ts:prettier
- run: npm run build:ts:dev # runs typecheck
- run: npm run lint:ts

tests:
Expand Down
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.idea/
build/
node_modules/
.DS_Store
Expand All @@ -18,4 +19,7 @@ typechain-types
# Certora Formal Verification related files
.certora_internal
.certora_recent_jobs.json
.zip-output-url.txt
.zip-output-url.txt

# zksync era node log
era_test_node.log
3 changes: 0 additions & 3 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npm run lint:sol:prettier
npm run lint:ts:prettier
npm run lint:sol
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ This will deploy the contracts deterministically and verify the contracts on eth
Preparation:
- Set `MNEMONIC` in `.env`
- Set `INFURA_KEY` in `.env`
- For zkSync, set `ZKSYNC_DEPLOYER_PK` in `.env`

```bash
npm run deploy-all <network>
Expand Down
36 changes: 35 additions & 1 deletion hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import "@nomicfoundation/hardhat-toolbox";
import type { HardhatUserConfig, HttpNetworkUserConfig } from "hardhat/types";
import "@matterlabs/hardhat-zksync-deploy";
import "@matterlabs/hardhat-zksync-solc";
import "@matterlabs/hardhat-zksync-verify";
import "@matterlabs/hardhat-zksync-ethers";
import "@matterlabs/hardhat-zksync-node";
import "hardhat-deploy";
import dotenv from "dotenv";
import yargs from "yargs";
Expand All @@ -16,7 +21,17 @@ const argv = yargs

// Load environment variables.
dotenv.config();
const { NODE_URL, INFURA_KEY, MNEMONIC, ETHERSCAN_API_KEY, PK, SOLIDITY_VERSION, SOLIDITY_SETTINGS, HARDHAT_CHAIN_ID } = process.env;
const {
NODE_URL,
INFURA_KEY,
MNEMONIC,
ETHERSCAN_API_KEY,
PK,
SOLIDITY_VERSION,
SOLIDITY_SETTINGS,
HARDHAT_ENABLE_ZKSYNC = "0",
HARDHAT_CHAIN_ID = 31337,
} = process.env;

const DEFAULT_MNEMONIC = "candy maple cake sugar pudding cream honey rich smooth crumble sweet treat";

Expand Down Expand Up @@ -73,11 +88,16 @@ const userConfig: HardhatUserConfig = {
solidity: {
compilers: [{ version: primarySolidityVersion, settings: soliditySettings }, { version: defaultSolidityVersion }],
},
zksolc: {
version: "1.5.2",
settings: {},
},
networks: {
hardhat: {
allowUnlimitedContractSize: true,
blockGasLimit: 100000000,
gas: 100000000,
zksync: HARDHAT_ENABLE_ZKSYNC === "1",
chainId: typeof HARDHAT_CHAIN_ID === "string" && !Number.isNaN(parseInt(HARDHAT_CHAIN_ID)) ? parseInt(HARDHAT_CHAIN_ID) : 31337,
},
mainnet: {
Expand Down Expand Up @@ -116,6 +136,20 @@ const userConfig: HardhatUserConfig = {
...sharedNetworkConfig,
url: `https://api.avax.network/ext/bc/C/rpc`,
},
zkSyncMainnet: {
...sharedNetworkConfig,
url: "https://mainnet.era.zksync.io",
ethNetwork: "mainnet",
zksync: true,
verifyURL: "https://zksync2-mainnet-explorer.zksync.io/contract_verification",
},
zkSyncSepolia: {
...sharedNetworkConfig,
url: "https://sepolia.era.zksync.dev",
ethNetwork: "goerli",
zksync: true,
verifyURL: "https://explorer.sepolia.era.zksync.dev/contract_verification",
},
},
deterministicDeployment,
namedAccounts: {
Expand Down
Loading
Loading