@@ -15,6 +15,7 @@ concurrency:
1515# - CHAIN_ID_GATEWAY: Should match the chain ID used in the anvil node in the docker-compose.yml file
1616# - RPC_URL: The port should match the one used in the anvil node in the docker-compose.yml file
1717env :
18+ PREVIOUS_RELEASE_TAG : v0.10.0
1819 DOTENV_CONFIG_PATH : .env.example
1920 HARDHAT_NETWORK : staging
2021 CHAIN_ID_GATEWAY : 54321
5455 - name : Checkout previous release code
5556 uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
5657 with :
57- # This version should be updated whenever we release new contract versions or
58- # touch a contract upgrade path.
59- ref : v0.10.0
58+ ref : ${{ env.PREVIOUS_RELEASE_TAG }}
6059 path : previous-fhevm
6160 persist-credentials : ' false'
6261
@@ -117,89 +116,40 @@ jobs:
117116 cp -r ../../previous-fhevm/gateway-contracts/contracts ./previous-contracts
118117 docker cp deploy-gateway-contracts:/app/addresses ./
119118
120- # TODO: We should instead automatically detect if the contract needs to be upgraded
121- # See https://github.com/zama-ai/fhevm-internal/issues/379
122- - name : Upgrade GatewayConfig contract
119+ - name : Run contract upgrades
123120 working-directory : current-fhevm/gateway-contracts
124- if : false
125121 run : |
126- npx hardhat task:upgradeGatewayConfig \
127- --current-implementation previous-contracts/GatewayConfig.sol:GatewayConfig \
128- --new-implementation contracts/GatewayConfig.sol:GatewayConfig \
129- --use-internal-proxy-address true \
130- --verify-contract false
131-
132- # TODO: We should instead automatically detect if the contract needs to be upgraded
133- # See https://github.com/zama-ai/fhevm-internal/issues/379
134- - name : Upgrade Decryption contract
135- working-directory : current-fhevm/gateway-contracts
136- if : false
137- run : |
138- npx hardhat task:upgradeDecryption \
139- --current-implementation previous-contracts/Decryption.sol:Decryption \
140- --new-implementation contracts/Decryption.sol:Decryption \
141- --use-internal-proxy-address true \
142- --verify-contract false
143-
144- # TODO: We should instead automatically detect if the contract needs to be upgraded
145- # See https://github.com/zama-ai/fhevm-internal/issues/379
146- - name : Upgrade CiphertextCommits contract
147- working-directory : current-fhevm/gateway-contracts
148- if : false
149- run : |
150- npx hardhat task:upgradeCiphertextCommits \
151- --current-implementation previous-contracts/CiphertextCommits.sol:CiphertextCommits \
152- --new-implementation contracts/CiphertextCommits.sol:CiphertextCommits \
153- --use-internal-proxy-address true \
154- --verify-contract false
155-
156- # TODO: We should instead automatically detect if the contract needs to be upgraded
157- # See https://github.com/zama-ai/fhevm-internal/issues/379
158- - name : Upgrade InputVerification contract
159- working-directory : current-fhevm/gateway-contracts
160- if : false
161- run : |
162- npx hardhat task:upgradeInputVerification \
163- --current-implementation previous-contracts/InputVerification.sol:InputVerification \
164- --new-implementation contracts/InputVerification.sol:InputVerification \
165- --use-internal-proxy-address true \
166- --verify-contract false
167-
168- # TODO: We should instead automatically detect if the contract needs to be upgraded
169- # See https://github.com/zama-ai/fhevm-internal/issues/379
170- - name : Upgrade MultichainACL contract
171- working-directory : current-fhevm/gateway-contracts
172- if : false
173- run : |
174- npx hardhat task:upgradeMultichainACL \
175- --current-implementation previous-contracts/MultichainACL.sol:MultichainACL \
176- --new-implementation contracts/MultichainACL.sol:MultichainACL \
177- --use-internal-proxy-address true \
178- --verify-contract false
179-
180- # TODO: We should instead automatically detect if the contract needs to be upgraded
181- # See https://github.com/zama-ai/fhevm-internal/issues/379
182- - name : Upgrade KMSGeneration contract
183- working-directory : current-fhevm/gateway-contracts
184- if : false
185- run : |
186- npx hardhat task:upgradeKMSGeneration \
187- --current-implementation previous-contracts/KMSGeneration.sol:KMSGeneration \
188- --new-implementation contracts/KMSGeneration.sol:KMSGeneration \
189- --use-internal-proxy-address true \
190- --verify-contract false
191-
192- # TODO: We should instead automatically detect if the contract needs to be upgraded
193- # See https://github.com/zama-ai/fhevm-internal/issues/379
194- - name : Upgrade ProtocolPayment contract
195- working-directory : current-fhevm/gateway-contracts
196- if : false
197- run : |
198- npx hardhat task:upgradeProtocolPayment \
199- --current-implementation previous-contracts/ProtocolPayment.sol:ProtocolPayment \
200- --new-implementation contracts/ProtocolPayment.sol:ProtocolPayment \
201- --use-internal-proxy-address true \
202- --verify-contract false
122+ set -euo pipefail
123+ UPGRADED=0
124+ SKIPPED=0
125+
126+ for name in $(jq -r '.[]' upgrade-manifest.json); do
127+ old_ver=$(sed -n 's/.*REINITIALIZER_VERSION[[:space:]]*=[[:space:]]*\([0-9]*\).*/\1/p' \
128+ "previous-contracts/${name}.sol")
129+ new_ver=$(sed -n 's/.*REINITIALIZER_VERSION[[:space:]]*=[[:space:]]*\([0-9]*\).*/\1/p' \
130+ "contracts/${name}.sol")
131+ old_ver=${old_ver:-0}
132+ new_ver=${new_ver:-0}
133+
134+ if [ "$old_ver" != "$new_ver" ]; then
135+ echo "::group::Upgrading $name (reinitializer $old_ver → $new_ver)"
136+ npx hardhat "task:upgrade${name}" \
137+ --current-implementation "previous-contracts/${name}.sol:${name}" \
138+ --new-implementation "contracts/${name}.sol:${name}" \
139+ --use-internal-proxy-address true \
140+ --verify-contract false
141+ echo "::endgroup::"
142+ UPGRADED=$((UPGRADED + 1))
143+ else
144+ echo "Skipping $name (reinitializer unchanged: $old_ver)"
145+ SKIPPED=$((SKIPPED + 1))
146+ fi
147+ done
148+
149+ echo "::notice::Upgrade summary: $UPGRADED upgraded, $SKIPPED skipped"
150+ if [ "$UPGRADED" -eq 0 ]; then
151+ echo "::warning::No contracts needed upgrading — consider bumping PREVIOUS_RELEASE_TAG"
152+ fi
203153
204154 - name : Clean up
205155 working-directory : previous-fhevm/gateway-contracts
0 commit comments