Skip to content

Commit

Permalink
adding zk support script and makefile action
Browse files Browse the repository at this point in the history
  • Loading branch information
yashnevatia committed Dec 2, 2024
1 parent 04fb045 commit f2c6a91
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 0 deletions.
1 change: 1 addition & 0 deletions contracts/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ artifacts
cache
node_modules
solc
zksolc
abi
coverage
coverage.json
Expand Down
6 changes: 6 additions & 0 deletions contracts/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ artifact-generate:
./scripts/generate_compiled_json_ccip.sh $(contract) $(solcversion) $(artifactpath)


.PHONY: wrappers-ccip-zksupport
wrappers-ccip-zksupport: pnpmdep mockery abigen ## Recompiles solidity contracts for ccip and their go wrappers with zksync support
./scripts/native_solc_compile_all_ccip_zks
go generate ../core/gethwrappers/ccip


help:
@echo ""
@echo " .__ .__ .__ .__ __"
Expand Down
98 changes: 98 additions & 0 deletions contracts/scripts/native_solc_compile_all_ccip_zks
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
#!/usr/bin/env bash

set -e

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

SOLC_VERSION="0.8.24"
OPTIMIZE_RUNS=26000
OPTIMIZE_RUNS_OFFRAMP=500
ZKSOLC_VERSION="1.5.6"


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/OffRamp.sol")
echo "OffRamp uses $OPTIMIZE_RUNS_OFFRAMP optimizer runs."
optimize_runs=$OPTIMIZE_RUNS_OFFRAMP
;;
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"

zksolc --overwrite -O3 --metadata-hash none \
-o "$ROOT"/contracts/zksolc/v$ZKSOLC_VERSION/"$contract" \
--bin --allow-paths "$ROOT"/contracts/src/v0.8 \
--metadata --metadata-literal \
--evm-version paris \
"$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/OffRamp.sol
compileContract ccip/FeeQuoter.sol
compileContract ccip/onRamp/OnRamp.sol
compileContract ccip/applications/PingPongDemo.sol
compileContract ccip/applications/EtherSenderReceiver.sol
compileContract ccip/rmn/RMNRemote.sol
compileContract ccip/rmn/RMNHome.sol
compileContract ccip/rmn/ARMProxy.sol
compileContract ccip/MultiAggregateRateLimiter.sol
compileContract ccip/Router.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 shared/token/ERC20/BurnMintERC20.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/TokenPool.sol


# Test helpers
compileContract ccip/test/helpers/BurnMintERC677Helper.sol
compileContract ccip/test/helpers/MessageHasher.sol
compileContract ccip/test/helpers/USDCReaderTester.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
compileContract ccip/test/helpers/CCIPReaderTester.sol

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

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

compileContract tests/MockV3Aggregator.sol

0 comments on commit f2c6a91

Please sign in to comment.