1+ #! /usr/bin/env bash
2+
3+ set -e
4+
5+ echo " ┌──────────────────────────────────────────────┐"
6+ echo " │ Compiling CCIP contracts... │"
7+ echo " └──────────────────────────────────────────────┘"
8+
9+ SOLC_VERSION=" 0.8.24"
10+ OPTIMIZE_RUNS=26000
11+ OPTIMIZE_RUNS_OFFRAMP=18000
12+ OPTIMIZE_RUNS_ONRAMP=4100
13+ OPTIMIZE_RUNS_MULTI_OFFRAMP=800
14+
15+
16+ SCRIPTPATH=" $( cd " $( dirname " $0 " ) " > /dev/null 2>&1 ; pwd -P ) "
17+ python3 -m pip install --require-hashes -r " $SCRIPTPATH " /requirements.txt
18+ solc-select install $SOLC_VERSION
19+ solc-select use $SOLC_VERSION
20+ export SOLC_VERSION=$SOLC_VERSION
21+
22+ ROOT=" $( cd " $( dirname " $0 " ) " > /dev/null 2>&1 ; cd ../../ && pwd -P ) "
23+
24+ compileContract () {
25+ local contract
26+ contract=$( basename " $1 " " .sol" )
27+
28+ local optimize_runs=$OPTIMIZE_RUNS
29+
30+ case $1 in
31+ " ccip/offRamp/EVM2EVMOffRamp.sol" )
32+ echo " OffRamp uses $OPTIMIZE_RUNS_OFFRAMP optimizer runs."
33+ optimize_runs=$OPTIMIZE_RUNS_OFFRAMP
34+ ;;
35+ " ccip/offRamp/OffRamp.sol" )
36+ echo " MultiOffRamp uses $OPTIMIZE_RUNS_MULTI_OFFRAMP optimizer runs."
37+ optimize_runs=$OPTIMIZE_RUNS_MULTI_OFFRAMP
38+ ;;
39+ " ccip/onRamp/EVM2EVMOnRamp.sol" )
40+ echo " OnRamp uses $OPTIMIZE_RUNS_ONRAMP optimizer runs."
41+ optimize_runs=$OPTIMIZE_RUNS_ONRAMP
42+ ;;
43+ " ccip/test/helpers/CCIPReaderTester.sol" )
44+ echo " CCIPReaderTester uses 1 optimizer runs for reduced contract size."
45+ optimize_runs=1
46+ ;;
47+ esac
48+
49+ solc --overwrite --optimize --optimize-runs $optimize_runs --metadata-hash none \
50+ -o " $ROOT " /contracts/solc/v$SOLC_VERSION /" $contract " \
51+ --abi --bin --allow-paths " $ROOT " /contracts/src/v0.8 \
52+ --bin-runtime --hashes --metadata --metadata-literal --combined-json abi,hashes,metadata,srcmap,srcmap-runtime \
53+ --evm-version paris \
54+ " $ROOT " /contracts/src/v0.8/" $1 "
55+ }
56+
57+ compileContractZK () {
58+ local contract
59+ contract=$( basename " $1 " " .sol" )
60+
61+ local optimize_runs=$OPTIMIZE_RUNS
62+
63+ case $1 in
64+ " ccip/offRamp/EVM2EVMOffRamp.sol" )
65+ echo " OffRamp uses $OPTIMIZE_RUNS_OFFRAMP optimizer runs."
66+ optimize_runs=$OPTIMIZE_RUNS_OFFRAMP
67+ ;;
68+ " ccip/offRamp/OffRamp.sol" )
69+ echo " MultiOffRamp uses $OPTIMIZE_RUNS_MULTI_OFFRAMP optimizer runs."
70+ optimize_runs=$OPTIMIZE_RUNS_MULTI_OFFRAMP
71+ ;;
72+ " ccip/onRamp/EVM2EVMOnRamp.sol" )
73+ echo " OnRamp uses $OPTIMIZE_RUNS_ONRAMP optimizer runs."
74+ optimize_runs=$OPTIMIZE_RUNS_ONRAMP
75+ ;;
76+ " ccip/test/helpers/CCIPReaderTester.sol" )
77+ echo " CCIPReaderTester uses 1 optimizer runs for reduced contract size."
78+ optimize_runs=1
79+ ;;
80+ esac
81+
82+ zksolc --overwrite -O3 \
83+ -o " $ROOT " /contracts/zksolc/v$SOLC_VERSION /" $contract " \
84+ --bin --allow-paths " $ROOT " /contracts/src/v0.8 \
85+ --metadata --metadata-literal \
86+ " $ROOT " /contracts/src/v0.8/" $1 "
87+ }
88+
89+
90+
91+
92+ # Solc produces and overwrites intermediary contracts.
93+ # Contracts should be ordered in reverse-import-complexity-order to minimize overwrite risks.
94+ compileContract ccip/offRamp/EVM2EVMOffRamp.sol
95+ compileContract ccip/offRamp/OffRamp.sol
96+ compileContract ccip/rmn/RMNRemote.sol
97+ compileContract ccip/applications/PingPongDemo.sol
98+ compileContract ccip/applications/SelfFundedPingPong.sol
99+ compileContract ccip/applications/EtherSenderReceiver.sol
100+ compileContract ccip/onRamp/OnRamp.sol
101+ compileContract ccip/onRamp/EVM2EVMOnRamp.sol
102+ compileContract ccip/CommitStore.sol
103+ compileContract ccip/MultiAggregateRateLimiter.sol
104+ compileContract ccip/Router.sol
105+ compileContract ccip/FeeQuoter.sol
106+ compileContract ccip/RMN.sol
107+ compileContract ccip/ARMProxy.sol
108+ compileContract ccip/tokenAdminRegistry/TokenAdminRegistry.sol
109+ compileContract ccip/tokenAdminRegistry/RegistryModuleOwnerCustom.sol
110+ compileContract ccip/capability/CCIPHome.sol
111+ compileContract ccip/NonceManager.sol
112+ compileContract shared/token/ERC677/BurnMintERC677.sol
113+ compileContract ccip/PriceRegistry.sol
114+
115+
116+ # Pools
117+ compileContract ccip/pools/LockReleaseTokenPool.sol
118+ compileContract ccip/pools/BurnMintTokenPool.sol
119+ compileContract ccip/pools/BurnFromMintTokenPool.sol
120+ compileContract ccip/pools/BurnWithFromMintTokenPool.sol
121+ compileContract ccip/pools/LockReleaseTokenPoolAndProxy.sol
122+ compileContract ccip/pools/BurnMintTokenPoolAndProxy.sol
123+ compileContract ccip/pools/BurnWithFromMintTokenPoolAndProxy.sol
124+ compileContract ccip/pools/BurnWithFromMintRebasingTokenPool.sol
125+ compileContract ccip/pools/TokenPool.sol
126+
127+
128+ # Test helpers
129+ compileContract ccip/test/helpers/BurnMintERC677Helper.sol
130+ compileContract ccip/test/helpers/CommitStoreHelper.sol
131+ compileContract ccip/test/helpers/MessageHasher.sol
132+ compileContract ccip/test/helpers/CCIPReaderTester.sol
133+ compileContract ccip/test/helpers/ReportCodec.sol
134+ compileContract ccip/test/helpers/receivers/MaybeRevertMessageReceiver.sol
135+ compileContract ccip/test/helpers/MultiOCR3Helper.sol
136+ compileContract ccip/test/mocks/MockE2EUSDCTokenMessenger.sol
137+ compileContract ccip/test/mocks/MockE2EUSDCTransmitter.sol
138+ compileContract ccip/test/WETH9.sol
139+
140+
141+ # Encoding Utils
142+ compileContract ccip/interfaces/encodingutils/ICCIPEncodingUtils.sol
143+
144+ # Customer contracts
145+ compileContract ccip/pools/USDC/USDCTokenPool.sol
146+
147+ compileContract tests/MockV3Aggregator.sol
148+
149+
150+
151+
152+ compileContractZK ccip/offRamp/EVM2EVMOffRamp.sol
153+ compileContractZK ccip/offRamp/OffRamp.sol
154+ compileContractZK ccip/rmn/RMNRemote.sol
155+ compileContractZK ccip/applications/PingPongDemo.sol
156+ compileContractZK ccip/applications/SelfFundedPingPong.sol
157+ compileContractZK ccip/applications/EtherSenderReceiver.sol
158+ compileContractZK ccip/onRamp/OnRamp.sol
159+ compileContractZK ccip/onRamp/EVM2EVMOnRamp.sol
160+ compileContractZK ccip/CommitStore.sol
161+ compileContractZK ccip/MultiAggregateRateLimiter.sol
162+ compileContractZK ccip/Router.sol
163+ compileContractZK ccip/FeeQuoter.sol
164+ compileContractZK ccip/RMN.sol
165+ compileContractZK ccip/ARMProxy.sol
166+ compileContractZK ccip/tokenAdminRegistry/TokenAdminRegistry.sol
167+ compileContractZK ccip/tokenAdminRegistry/RegistryModuleOwnerCustom.sol
168+ compileContractZK ccip/capability/CCIPHome.sol
169+ compileContractZK ccip/NonceManager.sol
170+ compileContractZK shared/token/ERC677/BurnMintERC677.sol
171+ compileContractZK ccip/PriceRegistry.sol
172+
173+
174+ # Pools
175+ compileContractZK ccip/pools/LockReleaseTokenPool.sol
176+ compileContractZK ccip/pools/BurnMintTokenPool.sol
177+ compileContractZK ccip/pools/BurnFromMintTokenPool.sol
178+ compileContractZK ccip/pools/BurnWithFromMintTokenPool.sol
179+ compileContractZK ccip/pools/LockReleaseTokenPoolAndProxy.sol
180+ compileContractZK ccip/pools/BurnMintTokenPoolAndProxy.sol
181+ compileContractZK ccip/pools/BurnWithFromMintTokenPoolAndProxy.sol
182+ compileContractZK ccip/pools/BurnWithFromMintRebasingTokenPool.sol
183+ compileContractZK ccip/pools/TokenPool.sol
184+
185+
186+ # Test helpers
187+ compileContractZK ccip/test/helpers/BurnMintERC677Helper.sol
188+ compileContractZK ccip/test/helpers/CommitStoreHelper.sol
189+ compileContractZK ccip/test/helpers/MessageHasher.sol
190+ compileContractZK ccip/test/helpers/CCIPReaderTester.sol
191+ compileContractZK ccip/test/helpers/ReportCodec.sol
192+ compileContractZK ccip/test/helpers/receivers/MaybeRevertMessageReceiver.sol
193+ compileContractZK ccip/test/helpers/MultiOCR3Helper.sol
194+ compileContractZK ccip/test/mocks/MockE2EUSDCTokenMessenger.sol
195+ compileContractZK ccip/test/mocks/MockE2EUSDCTransmitter.sol
196+ # this breaks with paybale error
197+ compileContractZK ccip/test/WETH9.sol
198+
199+
200+ # Encoding Utils
201+ compileContractZK ccip/interfaces/encodingutils/ICCIPEncodingUtils.sol
202+
203+ # Customer contracts
204+ compileContractZK ccip/pools/USDC/USDCTokenPool.sol
205+
206+ compileContractZK tests/MockV3Aggregator.sol
207+
208+
209+ SOLC_VERSION=" 0.8.19"
210+ solc-select install $SOLC_VERSION
211+ solc-select use $SOLC_VERSION
212+ export SOLC_VERSION=$SOLC_VERSION
213+
214+ compileContractShared () {
215+ local contract
216+ contract=$( basename " $1 " " .sol" )
217+
218+ solc --overwrite --optimize --optimize-runs $OPTIMIZE_RUNS --metadata-hash none \
219+ -o " $ROOT " /contracts/solc/v$SOLC_VERSION /" $contract " \
220+ --abi --bin --allow-paths " $ROOT " /contracts/src/v0.8\
221+ " $ROOT " /contracts/src/v0.8/" $1 "
222+ }
223+
224+ compileContractSharedZK () {
225+ local contract
226+ contract=$( basename " $1 " " .sol" )
227+
228+ zksolc --overwrite -O3 \
229+ -o " $ROOT " /contracts/zksolc/v$SOLC_VERSION /" $contract " \
230+ --bin --allow-paths " $ROOT " /contracts/src/v0.8 \
231+ " $ROOT " /contracts/src/v0.8/" $1 "
232+ }
233+
234+ compileContractShared shared/token/ERC677/LinkToken.sol
235+ compileContractSharedZK shared/token/ERC677/LinkToken.sol
0 commit comments