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

zksync wrappers #1539

Draft
wants to merge 8 commits into
base: ccip-develop
Choose a base branch
from
Draft
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
235 changes: 235 additions & 0 deletions contracts/scripts/native_solc_zksolc_compile_ccip
Original file line number Diff line number Diff line change
@@ -0,0 +1,235 @@
#!/usr/bin/env bash

set -e

echo " ┌──────────────────────────────────────────────┐"
echo " │ Compiling CCIP contracts... │"
echo " └──────────────────────────────────────────────┘"

SOLC_VERSION="0.8.24"
OPTIMIZE_RUNS=26000
OPTIMIZE_RUNS_OFFRAMP=18000
OPTIMIZE_RUNS_ONRAMP=4100
OPTIMIZE_RUNS_MULTI_OFFRAMP=800


SCRIPTPATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
python3 -m pip install --require-hashes -r "$SCRIPTPATH"/requirements.txt
solc-select install $SOLC_VERSION
solc-select use $SOLC_VERSION
export SOLC_VERSION=$SOLC_VERSION

ROOT="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; cd ../../ && pwd -P )"

compileContract () {
local contract
contract=$(basename "$1" ".sol")

local optimize_runs=$OPTIMIZE_RUNS

case $1 in
"ccip/offRamp/EVM2EVMOffRamp.sol")
echo "OffRamp uses $OPTIMIZE_RUNS_OFFRAMP optimizer runs."
optimize_runs=$OPTIMIZE_RUNS_OFFRAMP
;;
"ccip/offRamp/OffRamp.sol")
echo "MultiOffRamp uses $OPTIMIZE_RUNS_MULTI_OFFRAMP optimizer runs."
optimize_runs=$OPTIMIZE_RUNS_MULTI_OFFRAMP
;;
"ccip/onRamp/EVM2EVMOnRamp.sol")
echo "OnRamp uses $OPTIMIZE_RUNS_ONRAMP optimizer runs."
optimize_runs=$OPTIMIZE_RUNS_ONRAMP
;;
"ccip/test/helpers/CCIPReaderTester.sol")
echo "CCIPReaderTester uses 1 optimizer runs for reduced contract size."
optimize_runs=1
;;
esac

solc --overwrite --optimize --optimize-runs $optimize_runs --metadata-hash none \
-o "$ROOT"/contracts/solc/v$SOLC_VERSION/"$contract" \
--abi --bin --allow-paths "$ROOT"/contracts/src/v0.8 \
--bin-runtime --hashes --metadata --metadata-literal --combined-json abi,hashes,metadata,srcmap,srcmap-runtime \
--evm-version paris \
"$ROOT"/contracts/src/v0.8/"$1"
}

compileContractZK () {
local contract
contract=$(basename "$1" ".sol")

local optimize_runs=$OPTIMIZE_RUNS

case $1 in
"ccip/offRamp/EVM2EVMOffRamp.sol")
echo "OffRamp uses $OPTIMIZE_RUNS_OFFRAMP optimizer runs."
optimize_runs=$OPTIMIZE_RUNS_OFFRAMP
;;
"ccip/offRamp/OffRamp.sol")
echo "MultiOffRamp uses $OPTIMIZE_RUNS_MULTI_OFFRAMP optimizer runs."
optimize_runs=$OPTIMIZE_RUNS_MULTI_OFFRAMP
;;
"ccip/onRamp/EVM2EVMOnRamp.sol")
echo "OnRamp uses $OPTIMIZE_RUNS_ONRAMP optimizer runs."
optimize_runs=$OPTIMIZE_RUNS_ONRAMP
;;
"ccip/test/helpers/CCIPReaderTester.sol")
echo "CCIPReaderTester uses 1 optimizer runs for reduced contract size."
optimize_runs=1
;;
esac

zksolc --overwrite -O3 \
-o "$ROOT"/contracts/zksolc/v$SOLC_VERSION/"$contract" \
--bin --allow-paths "$ROOT"/contracts/src/v0.8 \
--metadata --metadata-literal \
"$ROOT"/contracts/src/v0.8/"$1"
}




# Solc produces and overwrites intermediary contracts.
# Contracts should be ordered in reverse-import-complexity-order to minimize overwrite risks.
compileContract ccip/offRamp/EVM2EVMOffRamp.sol
compileContract ccip/offRamp/OffRamp.sol
compileContract ccip/rmn/RMNRemote.sol
compileContract ccip/applications/PingPongDemo.sol
compileContract ccip/applications/SelfFundedPingPong.sol
compileContract ccip/applications/EtherSenderReceiver.sol
compileContract ccip/onRamp/OnRamp.sol
compileContract ccip/onRamp/EVM2EVMOnRamp.sol
compileContract ccip/CommitStore.sol
compileContract ccip/MultiAggregateRateLimiter.sol
compileContract ccip/Router.sol
compileContract ccip/FeeQuoter.sol
compileContract ccip/RMN.sol
compileContract ccip/ARMProxy.sol
compileContract ccip/tokenAdminRegistry/TokenAdminRegistry.sol
compileContract ccip/tokenAdminRegistry/RegistryModuleOwnerCustom.sol
compileContract ccip/capability/CCIPHome.sol
compileContract ccip/NonceManager.sol
compileContract shared/token/ERC677/BurnMintERC677.sol
compileContract ccip/PriceRegistry.sol


# Pools
compileContract ccip/pools/LockReleaseTokenPool.sol
compileContract ccip/pools/BurnMintTokenPool.sol
compileContract ccip/pools/BurnFromMintTokenPool.sol
compileContract ccip/pools/BurnWithFromMintTokenPool.sol
compileContract ccip/pools/LockReleaseTokenPoolAndProxy.sol
compileContract ccip/pools/BurnMintTokenPoolAndProxy.sol
compileContract ccip/pools/BurnWithFromMintTokenPoolAndProxy.sol
compileContract ccip/pools/BurnWithFromMintRebasingTokenPool.sol
compileContract ccip/pools/TokenPool.sol


# Test helpers
compileContract ccip/test/helpers/BurnMintERC677Helper.sol
compileContract ccip/test/helpers/CommitStoreHelper.sol
compileContract ccip/test/helpers/MessageHasher.sol
compileContract ccip/test/helpers/CCIPReaderTester.sol
compileContract ccip/test/helpers/ReportCodec.sol
compileContract ccip/test/helpers/receivers/MaybeRevertMessageReceiver.sol
compileContract ccip/test/helpers/MultiOCR3Helper.sol
compileContract ccip/test/mocks/MockE2EUSDCTokenMessenger.sol
compileContract ccip/test/mocks/MockE2EUSDCTransmitter.sol
compileContract ccip/test/WETH9.sol


# Encoding Utils
compileContract ccip/interfaces/encodingutils/ICCIPEncodingUtils.sol

# Customer contracts
compileContract ccip/pools/USDC/USDCTokenPool.sol

compileContract tests/MockV3Aggregator.sol




compileContractZK ccip/offRamp/EVM2EVMOffRamp.sol
compileContractZK ccip/offRamp/OffRamp.sol
compileContractZK ccip/rmn/RMNRemote.sol
compileContractZK ccip/applications/PingPongDemo.sol
compileContractZK ccip/applications/SelfFundedPingPong.sol
compileContractZK ccip/applications/EtherSenderReceiver.sol
compileContractZK ccip/onRamp/OnRamp.sol
compileContractZK ccip/onRamp/EVM2EVMOnRamp.sol
compileContractZK ccip/CommitStore.sol
compileContractZK ccip/MultiAggregateRateLimiter.sol
compileContractZK ccip/Router.sol
compileContractZK ccip/FeeQuoter.sol
compileContractZK ccip/RMN.sol
compileContractZK ccip/ARMProxy.sol
compileContractZK ccip/tokenAdminRegistry/TokenAdminRegistry.sol
compileContractZK ccip/tokenAdminRegistry/RegistryModuleOwnerCustom.sol
compileContractZK ccip/capability/CCIPHome.sol
compileContractZK ccip/NonceManager.sol
compileContractZK shared/token/ERC677/BurnMintERC677.sol
compileContractZK ccip/PriceRegistry.sol


# Pools
compileContractZK ccip/pools/LockReleaseTokenPool.sol
compileContractZK ccip/pools/BurnMintTokenPool.sol
compileContractZK ccip/pools/BurnFromMintTokenPool.sol
compileContractZK ccip/pools/BurnWithFromMintTokenPool.sol
compileContractZK ccip/pools/LockReleaseTokenPoolAndProxy.sol
compileContractZK ccip/pools/BurnMintTokenPoolAndProxy.sol
compileContractZK ccip/pools/BurnWithFromMintTokenPoolAndProxy.sol
compileContractZK ccip/pools/BurnWithFromMintRebasingTokenPool.sol
compileContractZK ccip/pools/TokenPool.sol


# Test helpers
compileContractZK ccip/test/helpers/BurnMintERC677Helper.sol
compileContractZK ccip/test/helpers/CommitStoreHelper.sol
compileContractZK ccip/test/helpers/MessageHasher.sol
compileContractZK ccip/test/helpers/CCIPReaderTester.sol
compileContractZK ccip/test/helpers/ReportCodec.sol
compileContractZK ccip/test/helpers/receivers/MaybeRevertMessageReceiver.sol
compileContractZK ccip/test/helpers/MultiOCR3Helper.sol
compileContractZK ccip/test/mocks/MockE2EUSDCTokenMessenger.sol
compileContractZK ccip/test/mocks/MockE2EUSDCTransmitter.sol
# this breaks with paybale error
compileContractZK ccip/test/WETH9.sol


# Encoding Utils
compileContractZK ccip/interfaces/encodingutils/ICCIPEncodingUtils.sol

# Customer contracts
compileContractZK ccip/pools/USDC/USDCTokenPool.sol

compileContractZK tests/MockV3Aggregator.sol


SOLC_VERSION="0.8.19"
solc-select install $SOLC_VERSION
solc-select use $SOLC_VERSION
export SOLC_VERSION=$SOLC_VERSION

compileContractShared () {
local contract
contract=$(basename "$1" ".sol")

solc --overwrite --optimize --optimize-runs $OPTIMIZE_RUNS --metadata-hash none \
-o "$ROOT"/contracts/solc/v$SOLC_VERSION/"$contract" \
--abi --bin --allow-paths "$ROOT"/contracts/src/v0.8\
"$ROOT"/contracts/src/v0.8/"$1"
}

compileContractSharedZK () {
local contract
contract=$(basename "$1" ".sol")

zksolc --overwrite -O3 \
-o "$ROOT"/contracts/zksolc/v$SOLC_VERSION/"$contract" \
--bin --allow-paths "$ROOT"/contracts/src/v0.8 \
"$ROOT"/contracts/src/v0.8/"$1"
}

compileContractShared shared/token/ERC677/LinkToken.sol
compileContractSharedZK shared/token/ERC677/LinkToken.sol
Loading
Loading