Skip to content

Commit 70ccca7

Browse files
committed
chore(gateway-contracts): clean and rename KmsManagement to KMSGeneration
1 parent 2cbbd1b commit 70ccca7

37 files changed

Lines changed: 802 additions & 807 deletions

.github/workflows/gateway-contracts-upgrade-tests.yml

Lines changed: 52 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -159,67 +159,67 @@ jobs:
159159
160160
# TODO: We should instead automatically detect if the contract needs to be upgraded
161161
# See https://github.com/zama-ai/fhevm-internal/issues/379
162-
# - name: Upgrade CiphertextCommits contract
163-
# working-directory: current-fhevm/gateway-contracts
164-
# env:
165-
# DOTENV_CONFIG_PATH: .env
166-
# HARDHAT_NETWORK: staging
167-
# CHAIN_ID_GATEWAY: 54321
168-
# RPC_URL: http://localhost:8546
169-
# run: |
170-
# npx hardhat task:upgradeCiphertextCommits \
171-
# --current-implementation previous-contracts/CiphertextCommits.sol:CiphertextCommits \
172-
# --new-implementation contracts/CiphertextCommits.sol:CiphertextCommits \
173-
# --use-internal-proxy-address true \
174-
# --verify-contract false
162+
- name: Upgrade CiphertextCommits contract
163+
working-directory: current-fhevm/gateway-contracts
164+
env:
165+
DOTENV_CONFIG_PATH: .env
166+
HARDHAT_NETWORK: staging
167+
CHAIN_ID_GATEWAY: 54321
168+
RPC_URL: http://localhost:8546
169+
run: |
170+
npx hardhat task:upgradeCiphertextCommits \
171+
--current-implementation previous-contracts/CiphertextCommits.sol:CiphertextCommits \
172+
--new-implementation contracts/CiphertextCommits.sol:CiphertextCommits \
173+
--use-internal-proxy-address true \
174+
--verify-contract false
175175
176176
# TODO: We should instead automatically detect if the contract needs to be upgraded
177177
# See https://github.com/zama-ai/fhevm-internal/issues/379
178-
# - name: Upgrade InputVerification contract
179-
# working-directory: current-fhevm/gateway-contracts
180-
# env:
181-
# DOTENV_CONFIG_PATH: .env
182-
# HARDHAT_NETWORK: staging
183-
# CHAIN_ID_GATEWAY: 54321
184-
# RPC_URL: http://localhost:8546
185-
# run: |
186-
# npx hardhat task:upgradeInputVerification \
187-
# --current-implementation previous-contracts/InputVerification.sol:InputVerification \
188-
# --new-implementation contracts/InputVerification.sol:InputVerification \
189-
# --use-internal-proxy-address true \
190-
# --verify-contract false
178+
- name: Upgrade InputVerification contract
179+
working-directory: current-fhevm/gateway-contracts
180+
env:
181+
DOTENV_CONFIG_PATH: .env
182+
HARDHAT_NETWORK: staging
183+
CHAIN_ID_GATEWAY: 54321
184+
RPC_URL: http://localhost:8546
185+
run: |
186+
npx hardhat task:upgradeInputVerification \
187+
--current-implementation previous-contracts/InputVerification.sol:InputVerification \
188+
--new-implementation contracts/InputVerification.sol:InputVerification \
189+
--use-internal-proxy-address true \
190+
--verify-contract false
191191
192192
# TODO: We should instead automatically detect if the contract needs to be upgraded
193193
# See https://github.com/zama-ai/fhevm-internal/issues/379
194-
# - name: Upgrade MultichainACL contract
195-
# working-directory: current-fhevm/gateway-contracts
196-
# env:
197-
# DOTENV_CONFIG_PATH: .env
198-
# HARDHAT_NETWORK: staging
199-
# CHAIN_ID_GATEWAY: 54321
200-
# RPC_URL: http://localhost:8546
201-
# run: |
202-
# npx hardhat task:upgradeMultichainACL \
203-
# --current-implementation previous-contracts/MultichainACL.sol:MultichainACL \
204-
# --new-implementation contracts/MultichainACL.sol:MultichainACL \
205-
# --use-internal-proxy-address true \
206-
# --verify-contract false
194+
- name: Upgrade MultichainACL contract
195+
working-directory: current-fhevm/gateway-contracts
196+
env:
197+
DOTENV_CONFIG_PATH: .env
198+
HARDHAT_NETWORK: staging
199+
CHAIN_ID_GATEWAY: 54321
200+
RPC_URL: http://localhost:8546
201+
run: |
202+
npx hardhat task:upgradeMultichainACL \
203+
--current-implementation previous-contracts/MultichainACL.sol:MultichainACL \
204+
--new-implementation contracts/MultichainACL.sol:MultichainACL \
205+
--use-internal-proxy-address true \
206+
--verify-contract false
207207
208208
# TODO: We should instead automatically detect if the contract needs to be upgraded
209209
# See https://github.com/zama-ai/fhevm-internal/issues/379
210-
# - name: Upgrade KmsManagement contract
211-
# working-directory: current-fhevm/gateway-contracts
212-
# env:
213-
# DOTENV_CONFIG_PATH: .env
214-
# HARDHAT_NETWORK: staging
215-
# CHAIN_ID_GATEWAY: 54321
216-
# RPC_URL: http://localhost:8546
217-
# run: |
218-
# npx hardhat task:upgradeKmsManagement \
219-
# --current-implementation previous-contracts/KmsManagement.sol:KmsManagement \
220-
# --new-implementation contracts/KmsManagement.sol:KmsManagement \
221-
# --use-internal-proxy-address true \
222-
# --verify-contract false
210+
- name: Upgrade KMSGeneration contract
211+
working-directory: current-fhevm/gateway-contracts
212+
env:
213+
DOTENV_CONFIG_PATH: .env
214+
HARDHAT_NETWORK: staging
215+
CHAIN_ID_GATEWAY: 54321
216+
RPC_URL: http://localhost:8546
217+
run: |
218+
npx hardhat task:upgradeKmsGeneration \
219+
--current-implementation previous-contracts/KmsGeneration.sol:KmsGeneration \
220+
--new-implementation contracts/KmsGeneration.sol:KmsGeneration \
221+
--use-internal-proxy-address true \
222+
--verify-contract false
223223
224224
- name: Clean up
225225
working-directory: previous-fhevm/gateway-contracts

gateway-contracts/.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ PAUSER_ADDRESS_1="0xb19e21437c47A541842bB84b018d3955462B35De" # accounts[24] (ad
140140
# is dynamically set after contracts are deployed.
141141
# For tests, this address is read directly from the addresses/.env.gateway file, so the value in this file is ignored.
142142
GATEWAY_CONFIG_ADDRESS="0xa50F5243C70c80a8309e3D39d8c9d958cDa83979" # (address)
143+
KMS_GENERATION_ADDRESS="0x87A5b1152AA51728258dbc1AA54B6a83DCd1d3dd" # (address)
143144

144145
# The first pauser's private key
145146
# This is required for local tests and running the pausing task. It must correspond to one of the pauser's private key

gateway-contracts/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ The **FHEVM Gateway** is a set of smart contracts that enables decrypting FHE ci
1515
| `InputVerification` | Verify an input's zero-knowledge proof of knowledge (ZKPoK) | - Verify a ZKPoK<br>- Reject a ZKPoK |
1616
| `MultichainACL` | Centralize Access Control Lists (ACL) from all host chains | - Grant account access to ciphertexts<br>- Authorize public decryption of ciphertexts<br>- Delegate account access to ciphertexts |
1717
| `CiphertextCommits` | Store ciphertext commitments from all host chains | - Store regular ciphertext commitments<br>- Store Switch and Squash (SNS) ciphertext commitments |
18-
| `KmsManagement` | Orchestrate KMS-related materials | 🚧 _Not in use yet_ 🚧 |
18+
| `KMSGeneration` | Orchestrate KMS-related materials | 🚧 _Not in use yet_ 🚧 |
1919
| `GatewayConfig` | Administer configuration settings | - Register KMS nodes, coprocessors and host chains. <br> - Update KMS nodes, coprocessors and host chains. |
2020

2121
## Getting started

gateway-contracts/contracts/CiphertextCommits.sol

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// SPDX-License-Identifier: BSD-3-Clause-Clear
22
pragma solidity ^0.8.24;
3-
import { gatewayConfigAddress, kmsManagementAddress } from "../addresses/GatewayAddresses.sol";
3+
import { gatewayConfigAddress, kmsGenerationAddress } from "../addresses/GatewayAddresses.sol";
44
import { Strings } from "@openzeppelin/contracts/utils/Strings.sol";
55
import { ICiphertextCommits } from "./interfaces/ICiphertextCommits.sol";
66
import { IGatewayConfig } from "./interfaces/IGatewayConfig.sol";
7-
import { IKMSManagement } from "./interfaces/IKMSManagement.sol";
7+
import { IKMSGeneration } from "./interfaces/IKMSGeneration.sol";
88
import { UUPSUpgradeableEmptyProxy } from "./shared/UUPSUpgradeableEmptyProxy.sol";
99
import { GatewayConfigChecks } from "./shared/GatewayConfigChecks.sol";
1010
import { HandleOps } from "./libraries/HandleOps.sol";
@@ -19,8 +19,8 @@ contract CiphertextCommits is ICiphertextCommits, UUPSUpgradeableEmptyProxy, Gat
1919
/// @notice The address of the GatewayConfig contract, used for fetching information about coprocessors.
2020
IGatewayConfig private constant GATEWAY_CONFIG = IGatewayConfig(gatewayConfigAddress);
2121

22-
/// @notice The address of the KmsManagement contract, used for fetching information about the current key.
23-
IKMSManagement private constant KMS_MANAGEMENT = IKMSManagement(kmsManagementAddress);
22+
/// @notice The address of the KMSGeneration contract, used for fetching information about the current key.
23+
IKMSGeneration private constant KMS_GENERATION = IKMSGeneration(kmsGenerationAddress);
2424

2525
/// @dev The following constants are used for versioning the contract. They are made private
2626
/// @dev in order to force derived contracts to consider a different version. Note that

gateway-contracts/contracts/Decryption.sol

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -313,8 +313,10 @@ contract Decryption is
313313
) external virtual onlyKmsTxSender {
314314
DecryptionStorage storage $ = _getDecryptionStorage();
315315

316-
// Make sure the decryptionId corresponds to a generated decryption request.
317-
if (decryptionId > $.publicDecryptionCounter || decryptionId == 0) {
316+
// Make sure the decryptionId corresponds to a generated public decryption request:
317+
// - it must be greater than the base counter for public decryption requests
318+
// - it must be less than or equal to the current public decryption counter
319+
if (decryptionId <= PUBLIC_DECRYPT_COUNTER_BASE || decryptionId > $.publicDecryptionCounter) {
318320
revert DecryptionNotRequested(decryptionId);
319321
}
320322

@@ -547,8 +549,10 @@ contract Decryption is
547549
) external virtual onlyKmsTxSender {
548550
DecryptionStorage storage $ = _getDecryptionStorage();
549551

550-
// Make sure the decryptionId corresponds to a generated decryption request.
551-
if (decryptionId > $.userDecryptionCounter || decryptionId == 0) {
552+
// Make sure the decryptionId corresponds to a generated user decryption request:
553+
// - it must be greater than the base counter for user decryption requests
554+
// - it must be less than or equal to the current user decryption counter
555+
if (decryptionId <= USER_DECRYPT_COUNTER_BASE || decryptionId > $.userDecryptionCounter) {
552556
revert DecryptionNotRequested(decryptionId);
553557
}
554558

0 commit comments

Comments
 (0)