Skip to content

Commit 9a92155

Browse files
authored
feat(common): keygen (#937)
* feat(common): support keygen via gateway contracts
1 parent ff4fd71 commit 9a92155

File tree

201 files changed

+24079
-27533
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

201 files changed

+24079
-27533
lines changed

.github/workflows/coprocessor-cargo-clippy.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ jobs:
8282
run: |
8383
# For now, only specify the `bench latency throughput` features as the
8484
# other ones require specific dependencies (e.g. GPU, etc.).
85+
SQLX_OFFLINE=true cargo clippy -p host-listener --all-targets \
86+
-- -W clippy::perf -W clippy::suspicious -W clippy::style -D warnings
8587
SQLX_OFFLINE=true cargo clippy --all-targets --features "bench latency throughput" \
8688
-- -W clippy::perf -W clippy::suspicious -W clippy::style -D warnings
8789
working-directory: coprocessor/fhevm-engine

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

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,34 @@ jobs:
9595
echo "Host chain registration completed successfully with expected completion message"
9696
fi
9797
98+
## Check key generation triggering
99+
timeout 300s bash -c 'while docker ps --filter "name=trigger-keygen" --format "{{.Status}}" | grep -q "Up"; do sleep 5; done'
100+
docker compose logs trigger-keygen > keygen_logs.txt
101+
EXIT_CODE_KEYGEN=$(docker inspect --format='{{.State.ExitCode}}' trigger-keygen)
102+
if [ "$EXIT_CODE_KEYGEN" -ne 0 ]; then
103+
echo "Key generation triggering failed with exit code $EXIT_CODE_KEYGEN"
104+
exit 1
105+
elif ! grep -q "Keygen triggering done!" keygen_logs.txt; then
106+
echo "Key generation triggering did not complete successfully - 'Keygen triggering done!' message not found in logs"
107+
exit 1
108+
else
109+
echo "Key generation triggering completed successfully with expected completion message"
110+
fi
111+
112+
## Check CRS generation triggering
113+
timeout 300s bash -c 'while docker ps --filter "name=trigger-crsgen" --format "{{.Status}}" | grep -q "Up"; do sleep 5; done'
114+
docker compose logs trigger-crsgen > crsgen_logs.txt
115+
EXIT_CODE_CRSGEN=$(docker inspect --format='{{.State.ExitCode}}' trigger-crsgen)
116+
if [ "$EXIT_CODE_CRSGEN" -ne 0 ]; then
117+
echo "CRS generation triggering failed with exit code $EXIT_CODE_CRSGEN"
118+
exit 1
119+
elif ! grep -q "Crsgen triggering done!" crsgen_logs.txt; then
120+
echo "CRS generation triggering did not complete successfully - 'Crsgen triggering done!' message not found in logs"
121+
exit 1
122+
else
123+
echo "CRS generation triggering completed successfully with expected completion message"
124+
fi
125+
98126
- name: Clean up
99127
working-directory: gateway-contracts
100128
if: always()

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

Lines changed: 69 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ jobs:
4848
with:
4949
# This version should be updated whenever we release new contract versions or
5050
# touch a contract upgrade path.
51-
ref: v0.8.0-4
51+
ref: v0.8.0-6
5252
path: previous-fhevm
5353
persist-credentials: 'false'
5454

@@ -127,36 +127,38 @@ jobs:
127127
128128
# TODO: We should instead automatically detect if the contract needs to be upgraded
129129
# See https://github.com/zama-ai/fhevm-internal/issues/379
130-
# - name: Upgrade GatewayConfig contract
131-
# working-directory: current-fhevm/gateway-contracts
132-
# env:
133-
# DOTENV_CONFIG_PATH: .env
134-
# HARDHAT_NETWORK: staging
135-
# CHAIN_ID_GATEWAY: 54321
136-
# RPC_URL: http://localhost:8546
137-
# run: |
138-
# npx hardhat task:upgradeGatewayConfig \
139-
# --current-implementation previous-contracts/GatewayConfig.sol:GatewayConfig \
140-
# --new-implementation contracts/GatewayConfig.sol:GatewayConfig \
141-
# --use-internal-proxy-address true \
142-
# --verify-contract false
130+
- name: Upgrade GatewayConfig contract
131+
working-directory: current-fhevm/gateway-contracts
132+
env:
133+
DOTENV_CONFIG_PATH: .env
134+
HARDHAT_NETWORK: staging
135+
CHAIN_ID_GATEWAY: 54321
136+
RPC_URL: http://localhost:8546
137+
run: |
138+
npx hardhat task:upgradeGatewayConfig \
139+
--current-implementation previous-contracts/GatewayConfig.sol:GatewayConfig \
140+
--new-implementation contracts/GatewayConfig.sol:GatewayConfig \
141+
--use-internal-proxy-address true \
142+
--verify-contract false
143143
144144
# TODO: We should instead automatically detect if the contract needs to be upgraded
145145
# See https://github.com/zama-ai/fhevm-internal/issues/379
146-
# - name: Upgrade Decryption contract
147-
# working-directory: current-fhevm/gateway-contracts
148-
# env:
149-
# DOTENV_CONFIG_PATH: .env
150-
# HARDHAT_NETWORK: staging
151-
# CHAIN_ID_GATEWAY: 54321
152-
# RPC_URL: http://localhost:8546
153-
# run: |
154-
# npx hardhat task:upgradeDecryption \
155-
# --current-implementation previous-contracts/Decryption.sol:Decryption \
156-
# --new-implementation contracts/Decryption.sol:Decryption \
157-
# --use-internal-proxy-address true \
158-
# --verify-contract false
146+
- name: Upgrade Decryption contract
147+
working-directory: current-fhevm/gateway-contracts
148+
env:
149+
DOTENV_CONFIG_PATH: .env
150+
HARDHAT_NETWORK: staging
151+
CHAIN_ID_GATEWAY: 54321
152+
RPC_URL: http://localhost:8546
153+
run: |
154+
npx hardhat task:upgradeDecryption \
155+
--current-implementation previous-contracts/Decryption.sol:Decryption \
156+
--new-implementation contracts/Decryption.sol:Decryption \
157+
--use-internal-proxy-address true \
158+
--verify-contract false
159159
160+
# TODO: We should instead automatically detect if the contract needs to be upgraded
161+
# See https://github.com/zama-ai/fhevm-internal/issues/379
160162
- name: Upgrade CiphertextCommits contract
161163
working-directory: current-fhevm/gateway-contracts
162164
env:
@@ -173,51 +175,51 @@ jobs:
173175
174176
# TODO: We should instead automatically detect if the contract needs to be upgraded
175177
# See https://github.com/zama-ai/fhevm-internal/issues/379
176-
# - name: Upgrade InputVerification contract
177-
# working-directory: current-fhevm/gateway-contracts
178-
# env:
179-
# DOTENV_CONFIG_PATH: .env
180-
# HARDHAT_NETWORK: staging
181-
# CHAIN_ID_GATEWAY: 54321
182-
# RPC_URL: http://localhost:8546
183-
# run: |
184-
# npx hardhat task:upgradeInputVerification \
185-
# --current-implementation previous-contracts/InputVerification.sol:InputVerification \
186-
# --new-implementation contracts/InputVerification.sol:InputVerification \
187-
# --use-internal-proxy-address true \
188-
# --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
189191
190192
# TODO: We should instead automatically detect if the contract needs to be upgraded
191193
# See https://github.com/zama-ai/fhevm-internal/issues/379
192-
# - name: Upgrade MultichainACL contract
193-
# working-directory: current-fhevm/gateway-contracts
194-
# env:
195-
# DOTENV_CONFIG_PATH: .env
196-
# HARDHAT_NETWORK: staging
197-
# CHAIN_ID_GATEWAY: 54321
198-
# RPC_URL: http://localhost:8546
199-
# run: |
200-
# npx hardhat task:upgradeMultichainACL \
201-
# --current-implementation previous-contracts/MultichainACL.sol:MultichainACL \
202-
# --new-implementation contracts/MultichainACL.sol:MultichainACL \
203-
# --use-internal-proxy-address true \
204-
# --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
205207
206208
# TODO: We should instead automatically detect if the contract needs to be upgraded
207-
# See https://github.com/zama-ai/fhevm-internal/issues/379
208-
# - name: Upgrade KmsManagement contract
209-
# working-directory: current-fhevm/gateway-contracts
210-
# env:
211-
# DOTENV_CONFIG_PATH: .env
212-
# HARDHAT_NETWORK: staging
213-
# CHAIN_ID_GATEWAY: 54321
214-
# RPC_URL: http://localhost:8546
215-
# run: |
216-
# npx hardhat task:upgradeKmsManagement \
217-
# --current-implementation previous-contracts/KmsManagement.sol:KmsManagement \
218-
# --new-implementation contracts/KmsManagement.sol:KmsManagement \
219-
# --use-internal-proxy-address true \
220-
# --verify-contract false
209+
# See https://github.com/zama-ai/fhevm-internal/issues/379
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
221223
222224
- name: Clean up
223225
working-directory: previous-fhevm/gateway-contracts

.github/workflows/test-suite-e2e-tests.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,16 +186,19 @@ jobs:
186186
if: always()
187187
run: |
188188
echo "::group::Relayer Logs"
189-
./fhevm-cli logs relayer
189+
./fhevm-cli logs fhevm-relayer
190190
echo "::endgroup::"
191191
echo "::group::SNS Worker Logs"
192-
./fhevm-cli logs sns-worker | grep -v "Selected 0 rows to process"
192+
./fhevm-cli logs coprocessor-sns-worker | grep -v "Selected 0 rows to process"
193193
echo "::endgroup::"
194194
echo "::group::Transaction Sender Logs (filtered)"
195-
./fhevm-cli logs transaction-sender | grep -v "Selected 0 rows to process"
195+
./fhevm-cli logs coprocessor-transaction-sender | grep -v "Selected 0 rows to process"
196196
echo "::endgroup::"
197197
echo "::group::Host Listener"
198-
./fhevm-cli logs host-listener
198+
./fhevm-cli logs coprocessor-host-listener
199+
echo "::endgroup::"
200+
echo "::group::Gateway Listener"
201+
./fhevm-cli logs coprocessor-gw-listener
199202
echo "::endgroup::"
200203
201204
- name: Cleanup

charts/kms-connector/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: kms-connector
22
description: A helm chart to distribute and deploy the Zama KMS Connector services
3-
version: 1.0.0
3+
version: 1.0.1
44
apiVersion: v2
55
keywords:
66
- fhevm

charts/kms-connector/templates/kms-connector-gw-listener-deployment.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ spec:
6666
value: {{ .Values.commonConfig.gatewayContractAddresses.decryption | quote }}
6767
- name: KMS_CONNECTOR_GATEWAY_CONFIG_CONTRACT__ADDRESS
6868
value: {{ .Values.commonConfig.gatewayContractAddresses.gatewayConfig | quote }}
69-
- name: KMS_CONNECTOR_KMS_MANAGEMENT_CONTRACT__ADDRESS
70-
value: {{ .Values.commonConfig.gatewayContractAddresses.kmsManagement | quote }}
69+
- name: KMS_CONNECTOR_KMS_GENERATION_CONTRACT__ADDRESS
70+
value: {{ .Values.commonConfig.gatewayContractAddresses.kmsGeneration | quote }}
7171
{{- if default .Values.commonConfig.tracing.enabled .Values.kmsConnectorGwListener.tracing.enabled }}
7272
- name: OTEL_EXPORTER_OTLP_ENDPOINT
7373
value: {{ .Values.commonConfig.tracing.endpoint }}

charts/kms-connector/templates/kms-connector-kms-worker-deployment.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ spec:
6666
value: {{ .Values.commonConfig.gatewayContractAddresses.decryption | quote }}
6767
- name: KMS_CONNECTOR_GATEWAY_CONFIG_CONTRACT__ADDRESS
6868
value: {{ .Values.commonConfig.gatewayContractAddresses.gatewayConfig | quote }}
69-
- name: KMS_CONNECTOR_KMS_MANAGEMENT_CONTRACT__ADDRESS
70-
value: {{ .Values.commonConfig.gatewayContractAddresses.kmsManagement | quote }}
69+
- name: KMS_CONNECTOR_KMS_GENERATION_CONTRACT__ADDRESS
70+
value: {{ .Values.commonConfig.gatewayContractAddresses.kmsGeneration | quote }}
7171
{{- if default .Values.commonConfig.tracing.enabled .Values.kmsConnectorKmsWorker.tracing.enabled }}
7272
- name: OTEL_EXPORTER_OTLP_ENDPOINT
7373
value: {{ .Values.commonConfig.tracing.endpoint }}

charts/kms-connector/templates/kms-connector-tx-sender-deployment.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ spec:
6666
value: {{ .Values.commonConfig.gatewayContractAddresses.decryption | quote }}
6767
- name: KMS_CONNECTOR_GATEWAY_CONFIG_CONTRACT__ADDRESS
6868
value: {{ .Values.commonConfig.gatewayContractAddresses.gatewayConfig | quote }}
69-
- name: KMS_CONNECTOR_KMS_MANAGEMENT_CONTRACT__ADDRESS
70-
value: {{ .Values.commonConfig.gatewayContractAddresses.kmsManagement | quote }}
69+
- name: KMS_CONNECTOR_KMS_GENERATION_CONTRACT__ADDRESS
70+
value: {{ .Values.commonConfig.gatewayContractAddresses.kmsGeneration | quote }}
7171
- name: KMS_CONNECTOR_PRIVATE_KEY
7272
valueFrom:
7373
secretKeyRef:

charts/kms-connector/values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ commonConfig:
55
gatewayContractAddresses:
66
decryption: "0xc9bAE822fE6793e3B456144AdB776D5A318CB71e"
77
gatewayConfig: "0xeAC2EfFA07844aB326D92d1De29E136a6793DFFA"
8-
kmsManagement: "0xF0bFB159C7381F7CB332586004d8247252C5b816"
8+
kmsGeneration: "0xF0bFB159C7381F7CB332586004d8247252C5b816"
99
tracing:
1010
enabled: false
1111
endpoint: "http://otel-deployment-opentelemetry-collector.observability.svc.cluster.local:4317"

coprocessor/README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,19 +145,17 @@ Options:
145145

146146
```bash
147147
$ gw_listener --help
148-
Usage: gw_listener [OPTIONS] --gw-url <GW_URL> --input-verification-address <INPUT_VERIFICATION_ADDRESS>
148+
Usage: gw_listener [OPTIONS] --gw-url <GW_URL> --input-verification-address <INPUT_VERIFICATION_ADDRESS> --kms-management-address <KMS_MANAGEMENT_ADDRESS>
149149

150150
Options:
151151
--database-url <DATABASE_URL>
152-
153152
--database-pool-size <DATABASE_POOL_SIZE>
154153
[default: 16]
155154
--verify-proof-req-database-channel <VERIFY_PROOF_REQ_DATABASE_CHANNEL>
156155
[default: verify_proof_requests]
157156
--gw-url <GW_URL>
158-
159157
-i, --input-verification-address <INPUT_VERIFICATION_ADDRESS>
160-
158+
--kms-management-address <KMS_MANAGEMENT_ADDRESS>
161159
--error-sleep-initial-secs <ERROR_SLEEP_INITIAL_SECS>
162160
[default: 1]
163161
--error-sleep-max-secs <ERROR_SLEEP_MAX_SECS>

0 commit comments

Comments
 (0)