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

CCIP-3007 : Add script for zksync compile contract #1276

Merged
merged 23 commits into from
Sep 5, 2024
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
2 changes: 2 additions & 0 deletions contracts/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@ typechain
# Foundry
foundry-cache
foundry-artifacts
artifacts-zk
cache-zk

.openzeppelin
116 changes: 116 additions & 0 deletions contracts/hardhat.ccip.zksync.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
import '@nomicfoundation/hardhat-ethers'
import '@nomicfoundation/hardhat-verify'
import '@nomicfoundation/hardhat-chai-matchers'
import '@matterlabs/hardhat-zksync-solc'
import '@typechain/hardhat'
import 'hardhat-abi-exporter'
import { subtask } from 'hardhat/config'
import { TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS } from 'hardhat/builtin-tasks/task-names'
import '@matterlabs/hardhat-zksync-verify'

const COMPILER_SETTINGS = {
optimizer: {
enabled: true,
runs: 1000000,
AnieeG marked this conversation as resolved.
Show resolved Hide resolved
},
metadata: {
bytecodeHash: 'none',
},
}

// prune forge style tests from hardhat paths
subtask(TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS).setAction(
async (_, __, runSuper) => {
const paths = await runSuper()
const noTests = paths.filter((p: string) => !p.endsWith('.t.sol'))
const noCCIPTests = noTests.filter(
(p: string) => !p.includes('/v0.8/ccip/test'),
)
return noCCIPTests.filter(
(p: string) => !p.includes('src/v0.8/vendor/forge-std'),
)
},
)

/**
* @type import('hardhat/config').HardhatUserConfig
*/
let config = {
abiExporter: {
path: './abi',
runOnCompile: true,
},
paths: {
artifacts: './artifacts',
cache: './cache',
sources: './src/v0.8/ccip',
tests: './test/v0.8/ccip, ./src/v0.8/ccip/test',
},
typechain: {
outDir: './typechain',
target: 'ethers-v5',
},
defaultNetwork: 'zkSync',
networks: {
env: {
url: process.env.NODE_HTTP_URL || '',
},
hardhat: {
allowUnlimitedContractSize: Boolean(
process.env.ALLOW_UNLIMITED_CONTRACT_SIZE,
),
hardfork: 'merge',
},
zkSyncSepolia: {
url: 'https://sepolia.era.zksync.dev',
ethNetwork: 'sepolia',
zksync: true, // enables zksolc compiler
verifyURL:
'https://explorer.sepolia.era.zksync.dev/contract_verification',
},
zkSync: {
url: 'https://mainnet.era.zksync.io', // The testnet RPC URL of ZKsync Era network.
ethNetwork: 'mainnet', // The Ethereum Web3 RPC URL, or the identifier of the network (e.g. `mainnet` or `sepolia`)
zksync: true,
// Verification endpoint for Sepolia
verifyURL:
'https://zksync2-mainnet-explorer.zksync.io/contract_verification',
},
},
solidity: {
AnieeG marked this conversation as resolved.
Show resolved Hide resolved
compilers: [
{
version: '0.8.24',
settings: {
...COMPILER_SETTINGS,
evmVersion: 'paris',
},
},
],
},
zksolc: {
settings: {
compilerPath: 'zksolc',
version: 'v1.5.3',
optimizer: {
enabled: true,
mode: '3',
fallback_to_optimizing_for_size: false,
},
experimental: {
dockerImage: '',
tag: '',
},
// contractsToCompile: ['RMN', 'ARMProxy'], // uncomment this to compile only specific contracts
},
},
warnings: !process.env.HIDE_WARNINGS,
}

if (process.env.NETWORK_NAME && process.env.EXPLORER_API_KEY) {
config = {
...config,
}
}

export default config
5 changes: 5 additions & 0 deletions contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
"clean": "hardhat clean",
"compile:native": "./scripts/native_solc_compile_all",
"compile": "hardhat compile --no-typechain",
"zksync:compile": "npx hardhat compile --config ./hardhat.ccip.zksync.config.ts --no-typechain",
"zksync:verify:sepolia": "npx hardhat run scripts/zksyncverify/zksync-verify.ts --network zkSyncSepolia --config ./hardhat.ccip.zksync.config.ts",
"zksync:verify": "npx hardhat run scripts/zksyncverify/zksync-verify.ts --network zkSync --config ./hardhat.ccip.zksync.config.ts",
"coverage": "hardhat coverage",
"prepare": "chmod +x .husky/prepare.sh && ./.husky/prepare.sh",
"prepublishOnly": "pnpm compile && ./scripts/prepublish_generate_abi_folder",
Expand Down Expand Up @@ -77,6 +80,7 @@
"@ethersproject/bignumber": "~5.7.0",
"@ethersproject/contracts": "~5.7.0",
"@ethersproject/providers": "~5.7.2",
"@matterlabs/hardhat-zksync-solc": "^1.2.1",
"@nomicfoundation/hardhat-chai-matchers": "^1.0.6",
"@nomicfoundation/hardhat-ethers": "^3.0.6",
"@nomicfoundation/hardhat-network-helpers": "^1.0.11",
Expand Down Expand Up @@ -121,6 +125,7 @@
"@changesets/changelog-github": "^0.5.0",
"@changesets/cli": "~2.27.7",
"@eth-optimism/contracts": "0.6.0",
"@matterlabs/hardhat-zksync-verify": "^1.6.0",
"@openzeppelin/contracts": "4.9.3",
"@openzeppelin/contracts-upgradeable": "4.9.3",
"@scroll-tech/contracts": "0.1.0",
Expand Down
Loading
Loading