Skip to content

Commit cebc88d

Browse files
authored
Merge branch 'main' into ci/update
2 parents bfb5706 + d1369ae commit cebc88d

File tree

95 files changed

+2940
-1739
lines changed

Some content is hidden

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

95 files changed

+2940
-1739
lines changed

.github/actions/gpu_setup/action.yml

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Setup Cuda
2+
description: Setup Cuda on Hyperstack or GitHub instance
3+
4+
inputs:
5+
cuda-version:
6+
description: Version of Cuda to use
7+
required: true
8+
gcc-version:
9+
description: Version of GCC to use
10+
required: true
11+
cmake-version:
12+
description: Version of cmake to use
13+
default: 3.29.6
14+
github-instance:
15+
description: Instance is hosted on GitHub
16+
default: 'false'
17+
18+
runs:
19+
using: "composite"
20+
steps:
21+
# Mandatory on hyperstack since a bootable volume is not re-usable yet.
22+
- name: Install dependencies
23+
shell: bash
24+
run: |
25+
sudo apt update
26+
curl -fsSL https://apt.kitware.com/keys/kitware-archive-latest.asc | sudo gpg --dearmour -o /etc/apt/trusted.gpg.d/kitware.gpg
27+
sudo chmod 644 /etc/apt/trusted.gpg.d/kitware.gpg
28+
echo 'deb [signed-by=/etc/apt/trusted.gpg.d/kitware.gpg] https://apt.kitware.com/ubuntu/ jammy main' | sudo tee /etc/apt/sources.list.d/kitware.list >/dev/null
29+
sudo apt update
30+
sudo apt install -y cmake cmake-format libclang-dev
31+
32+
- name: Install CUDA
33+
if: inputs.github-instance == 'true'
34+
shell: bash
35+
run: |
36+
TOOLKIT_VERSION="$(echo ${{ inputs.cuda-version }} | sed 's/\(.*\)\.\(.*\)/\1-\2/')"
37+
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1_all.deb
38+
sudo dpkg -i cuda-keyring_1.1-1_all.deb
39+
sudo apt update
40+
sudo apt -y install cuda-toolkit-${TOOLKIT_VERSION}
41+
42+
- name: Export CUDA variables
43+
shell: bash
44+
run: |
45+
CUDA_PATH=/usr/local/cuda-${{ inputs.cuda-version }}
46+
echo "CUDA_PATH=$CUDA_PATH" >> "${GITHUB_ENV}"
47+
echo "PATH=$PATH:$CUDA_PATH/bin" >> "${GITHUB_PATH}"
48+
echo "LD_LIBRARY_PATH=$CUDA_PATH/lib64:$LD_LIBRARY_PATH" >> "${GITHUB_ENV}"
49+
echo "CUDA_MODULE_LOADER=EAGER" >> "${GITHUB_ENV}"
50+
51+
# Specify the correct host compilers
52+
- name: Export gcc and g++ variables
53+
shell: bash
54+
run: |
55+
{
56+
echo "CC=/usr/bin/gcc-${{ inputs.gcc-version }}";
57+
echo "CXX=/usr/bin/g++-${{ inputs.gcc-version }}";
58+
echo "CUDAHOSTCXX=/usr/bin/g++-${{ inputs.gcc-version }}";
59+
} >> "${GITHUB_ENV}"
60+
61+
- name: Check device is detected
62+
shell: bash
63+
run: nvidia-smi

.github/workflows/gpu-tests.yml

+197
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
1+
# Compile and test fhevm-backend on a single L40 GPU, on hyperstack
2+
name: GPU backend tests (L40)
3+
4+
env:
5+
CARGO_TERM_COLOR: always
6+
ACTION_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
7+
RUSTFLAGS: "-C target-cpu=native"
8+
RUST_BACKTRACE: "full"
9+
RUST_MIN_STACK: "8388608"
10+
IS_PULL_REQUEST: ${{ github.event_name == 'pull_request' }}
11+
CHECKOUT_TOKEN: ${{ secrets.REPO_CHECKOUT_TOKEN || secrets.GITHUB_TOKEN }}
12+
# Secrets will be available only to zama-ai organization members
13+
SECRETS_AVAILABLE: ${{ secrets.JOB_SECRET != '' }}
14+
15+
on:
16+
# Allows you to run this workflow manually from the Actions tab as an alternative.
17+
workflow_dispatch:
18+
pull_request:
19+
paths:
20+
- fhevm-engine/Cargo.toml
21+
- fhevm-engine/coprocessor/Cargo.toml
22+
- fhevm-engine/coprocessor/build.rs
23+
- fhevm-engine/coprocessor/src/**
24+
- fhevm-engine/executor/Cargo.toml
25+
- fhevm-engine/executor/build.rs
26+
- fhevm-engine/executor/src/**
27+
- fhevm-engine/scheduler/src/**
28+
- fhevm-engine/scheduler/Cargo.toml
29+
- fhevm-engine/scheduler/build.rs
30+
- proto/**
31+
- '.github/workflows/gpu-tests.yml'
32+
- ci/slab.toml
33+
push:
34+
branches:
35+
- main
36+
paths:
37+
- fhevm-engine/Cargo.toml
38+
- fhevm-engine/coprocessor/Cargo.toml
39+
- fhevm-engine/coprocessor/build.rs
40+
- fhevm-engine/coprocessor/src/**
41+
- fhevm-engine/executor/Cargo.toml
42+
- fhevm-engine/executor/build.rs
43+
- fhevm-engine/executor/src/**
44+
- fhevm-engine/scheduler/src/**
45+
- fhevm-engine/scheduler/Cargo.toml
46+
- fhevm-engine/scheduler/build.rs
47+
- proto/**
48+
- '.github/workflows/gpu-tests.yml'
49+
- ci/slab.toml
50+
51+
jobs:
52+
should-run:
53+
runs-on: ubuntu-latest
54+
permissions:
55+
pull-requests: read
56+
outputs:
57+
gpu_test: ${{ env.IS_PULL_REQUEST == 'false' || steps.changed-files.outputs.gpu_any_changed }}
58+
steps:
59+
- name: Checkout fhevm-backend
60+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
61+
with:
62+
fetch-depth: 0
63+
persist-credentials: 'false'
64+
token: ${{ env.CHECKOUT_TOKEN }}
65+
66+
- name: Check for file changes
67+
id: changed-files
68+
uses: tj-actions/changed-files@dcc7a0cba800f454d79fff4b993e8c3555bcc0a8
69+
with:
70+
files_yaml: |
71+
gpu:
72+
- fhevm-engine/Cargo.toml
73+
- fhevm-engine/coprocessor/Cargo.toml
74+
- fhevm-engine/coprocessor/build.rs
75+
- fhevm-engine/coprocessor/src/**
76+
- fhevm-engine/executor/Cargo.toml
77+
- fhevm-engine/executor/build.rs
78+
- fhevm-engine/executor/src/**
79+
- fhevm-engine/scheduler/src/**
80+
- fhevm-engine/scheduler/Cargo.toml
81+
- fhevm-engine/scheduler/build.rs
82+
- proto/**
83+
- '.github/workflows/gpu-tests.yml'
84+
- ci/slab.toml
85+
86+
setup-instance:
87+
name: Setup instance (fhevm-backend GPU tests - L40)
88+
needs: should-run
89+
if: github.event_name == 'workflow_dispatch' ||
90+
needs.should-run.outputs.gpu_test == 'true'
91+
runs-on: ubuntu-latest
92+
permissions:
93+
contents: read
94+
outputs:
95+
runner-name: ${{ steps.start-remote-instance.outputs.label }}
96+
steps:
97+
- name: Start remote instance
98+
id: start-remote-instance
99+
if: env.SECRETS_AVAILABLE == 'true'
100+
uses: zama-ai/slab-github-runner@79939325c3c429837c10d6041e4fd8589d328bac
101+
with:
102+
mode: start
103+
github-token: ${{ secrets.SLAB_ACTION_TOKEN }}
104+
slab-url: ${{ secrets.SLAB_BASE_URL }}
105+
job-secret: ${{ secrets.JOB_SECRET }}
106+
backend: hyperstack
107+
profile: l40
108+
109+
fhevm-backend-gpu:
110+
name: fhevm-backend GPU tests - L40
111+
needs: [ should-run, setup-instance ]
112+
if: github.event_name != 'pull_request' ||
113+
(github.event_name == 'pull_request' && needs.setup-instance.result != 'skipped')
114+
concurrency:
115+
group: ${{ github.workflow }}_${{ github.head_ref || github.ref }}
116+
cancel-in-progress: true
117+
runs-on: ${{ needs.setup-instance.outputs.runner-name }}
118+
permissions:
119+
contents: read
120+
strategy:
121+
fail-fast: false
122+
# explicit include-based build matrix, of known valid options
123+
matrix:
124+
include:
125+
- os: ubuntu-22.04
126+
cuda: "12.2"
127+
gcc: 11
128+
steps:
129+
- name: Checkout fhevm-backend
130+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
131+
with:
132+
persist-credentials: 'false'
133+
token: ${{ env.CHECKOUT_TOKEN }}
134+
lfs: true
135+
136+
- name: Checkout LFS objects
137+
run: git lfs checkout
138+
139+
- name: Setup Hyperstack dependencies
140+
uses: ./.github/actions/gpu_setup
141+
with:
142+
cuda-version: ${{ matrix.cuda }}
143+
gcc-version: ${{ matrix.gcc }}
144+
github-instance: ${{ env.SECRETS_AVAILABLE == 'false' }}
145+
146+
- name: Install latest stable
147+
uses: dtolnay/rust-toolchain@a54c7afa936fefeb4456b2dd8068152669aa8203
148+
with:
149+
toolchain: stable
150+
151+
- name: Install cargo dependencies
152+
run: |
153+
sudo apt-get install -y protobuf-compiler && \
154+
cargo install sqlx-cli
155+
156+
- name: Install foundry
157+
uses: foundry-rs/foundry-toolchain@de808b1eea699e761c404bda44ba8f21aba30b2c
158+
159+
- name: Cache cargo
160+
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
161+
with:
162+
path: |
163+
~/.cargo/registry
164+
~/.cargo/git
165+
target
166+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
167+
restore-keys: ${{ runner.os }}-cargo-
168+
169+
- name: Init database
170+
run: make init_db
171+
working-directory: fhevm-engine/coprocessor
172+
173+
- name: Run tests on GPU
174+
run: |
175+
date
176+
#DATABASE_URL=postgresql://postgres:postgres@localhost:5432/coprocessor cargo test --release --features=gpu -- --test-threads=1
177+
working-directory: fhevm-engine
178+
179+
180+
teardown-instance:
181+
name: Teardown instance (fhevm-backend-gpu L40 test)
182+
if: ${{ always() && needs.setup-instance.result == 'success' }}
183+
needs: [ setup-instance, fhevm-backend-gpu ]
184+
runs-on: ubuntu-latest
185+
permissions:
186+
contents: read
187+
steps:
188+
- name: Stop remote instance
189+
id: stop-instance
190+
if: env.SECRETS_AVAILABLE == 'true'
191+
uses: zama-ai/slab-github-runner@79939325c3c429837c10d6041e4fd8589d328bac
192+
with:
193+
mode: stop
194+
github-token: ${{ secrets.SLAB_ACTION_TOKEN }}
195+
slab-url: ${{ secrets.SLAB_BASE_URL }}
196+
job-secret: ${{ secrets.JOB_SECRET }}
197+
label: ${{ needs.setup-instance.outputs.runner-name }}

.github/workflows/slither.yml

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Slither Analysis
2+
on:
3+
pull_request:
4+
branches:
5+
- main
6+
push:
7+
branches:
8+
- main
9+
jobs:
10+
analyze:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v4
15+
- run: cp ./contracts/.env.example ./contracts/.env
16+
- run: npm --prefix ./contracts ci --include=optional
17+
- run: npm --prefix ./contracts install
18+
- run: npm --prefix ./contracts run compile
19+
- name: Run Slither
20+
uses: crytic/[email protected]
21+
with:
22+
node-version: 20
23+
ignore-compile: false
24+
solc-version: "0.8.24"
25+
slither-config: ".slither.config.json"
26+
sarif: results.sarif
27+
fail-on: none
28+
target: "./contracts/"
29+
- name: Upload SARIF file
30+
uses: github/codeql-action/upload-sarif@v3
31+
with:
32+
sarif_file: results.sarif

.slither.config.json

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"solc_remaps": ["@openzeppelin/=node_modules/@openzeppelin/"],
3+
"filter_paths": "contracts/node_modules/|contracts/lib/|contracts/test/"
4+
}

ci/slab.toml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[backend.hyperstack.single-h100]
2+
environment_name = "canada"
3+
image_name = "Ubuntu Server 22.04 LTS R535 CUDA 12.2"
4+
flavor_name = "n3-H100x1"
5+
user = "ubuntu"
6+
7+
[backend.hyperstack.l40]
8+
environment_name = "canada"
9+
image_name = "Ubuntu Server 22.04 LTS R535 CUDA 12.2"
10+
flavor_name = "n3-L40x1"
11+
user = "ubuntu"

contracts/.env.example

+5-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ export PRIVATE_KEY_KMS_SIGNER_0="388b7680e4e1afa06efbfd45cdd1fe39f3c6af381df6555
77
export PRIVATE_KEY_KMS_SIGNER_1="bbaed91514fa4b7c86aa4f73becbabcf4bce0ae130240f0d6ac3f87e06812440"
88
export PRIVATE_KEY_KMS_SIGNER_2="1bfa3e2233b0103ad67954a728b246c528916791f7fab4894ff361e3937b47e1"
99
export PRIVATE_KEY_KMS_SIGNER_3="7a604eed8cf4a43277d192aa0c7894d368577a4021e52bf45420f256e34c7dd7"
10-
export PRIVATE_KEY_COPROCESSOR_ACCOUNT="7ec8ada6642fc4ccfb7729bc29c17cf8d21b61abd5642d1db992c0b8672ab901"
11-
export IS_COPROCESSOR="true"
12-
10+
export NUM_COPROCESSOR_SIGNERS="1"
11+
export PRIVATE_KEY_COPROCESSOR_ACCOUNT_0="c2454775cca95e6d17d70b68105f48009fc4bf661f025e6a7911a6b4acf2a2f3"
12+
export PRIVATE_KEY_COPROCESSOR_ACCOUNT_1="8cd5feab038d5e3aceaa7ba4825cc046bb6b6144ff6468463c6d2a20428c0a9f"
13+
export PRIVATE_KEY_COPROCESSOR_ACCOUNT_2="bbfec2330ec03c0936ace29ab484560619c549edf745639e1bc7a96ed4a240b0"
14+
export PRIVATE_KEY_COPROCESSOR_ACCOUNT_3="699013f478c4e22e08de83c0cd44d70dbb265eebfd2ae991ca24ceff57e18f31"
1315
export SEPOLIA_RPC_URL="https://sepolia.infura.io/v3/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
1416
export ETHERSCAN_API_KEY="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
1517
export STAGING_RPC_URL="http://layer1-node:8545"

contracts/.env.example.deployment

+9-11
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
1-
export MNEMONIC="adapt mosquito move limb mobile illegal tree voyage juice mosquito burger raise father hope layer"
2-
export CHAIN_ID_GATEWAY="654321"
31
export PRIVATE_KEY_FHEVM_DEPLOYER="0c66d8cde71d2faa29d0cb6e3a567d31279b6eace67b0a9d9ba869c119843a5e"
4-
export PRIVATE_KEY_DECRYPTION_ORACLE_RELAYER="7ec931411ad75a7c201469a385d6f18a325d4923f9f213bd882bbea87e160b67"
5-
export NUM_KMS_SIGNERS="1"
6-
export PRIVATE_KEY_KMS_SIGNER_0="388b7680e4e1afa06efbfd45cdd1fe39f3c6af381df6555a19661f283b97de91"
7-
export PRIVATE_KEY_KMS_SIGNER_1="bbaed91514fa4b7c86aa4f73becbabcf4bce0ae130240f0d6ac3f87e06812440"
8-
export PRIVATE_KEY_KMS_SIGNER_2="1bfa3e2233b0103ad67954a728b246c528916791f7fab4894ff361e3937b47e1"
9-
export PRIVATE_KEY_KMS_SIGNER_3="7a604eed8cf4a43277d192aa0c7894d368577a4021e52bf45420f256e34c7dd7"
10-
export PRIVATE_KEY_COPROCESSOR_ACCOUNT="7ec8ada6642fc4ccfb7729bc29c17cf8d21b61abd5642d1db992c0b8672ab901"
11-
export IS_COPROCESSOR="true"
12-
2+
export CHAIN_ID_GATEWAY="654321"
3+
export NUM_KMS_SIGNERS="4"
4+
export ADDRESS_KMS_SIGNER_0="0x0971C80fF03B428fD2094dd5354600ab103201C5"
5+
export ADDRESS_KMS_SIGNER_1="0xB68deCb047B5e6Cc82280502A7E2318c6b3E5eC6"
6+
export ADDRESS_KMS_SIGNER_2="0xfe0fB0BCceb872ee7a6ef6c455e6E127Aef55DD7"
7+
export ADDRESS_KMS_SIGNER_3="0x2dac5193bE0AB0eD8871399E6Ae61EAe6cc8cAE1"
8+
export NUM_COPROCESSOR_SIGNERS="1"
9+
export ADDRESS_COPROCESSOR_ACCOUNT_0="0x3C0033584da3A0f61AA5C7bde50eAF3642875a21"
1310
export SEPOLIA_RPC_URL="https://sepolia.infura.io/v3/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
11+
export MAINNET_RPC_URL="https://mainnet.infura.io/v3/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
1412
export ETHERSCAN_API_KEY="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
1513
export STAGING_RPC_URL="http://layer1-node:8545"

contracts/.npmignore

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
*
22
!/artifacts/contracts/ACL.sol/ACL.json
33
!/artifacts/contracts/FHEGasLimit.sol/FHEGasLimit.json
4-
!/artifacts/contracts/InputVerifier.coprocessor.sol/InputVerifier.json
5-
!/artifacts/contracts/InputVerifier.native.sol/InputVerifier.json
4+
!/artifacts/contracts/InputVerifier.sol/InputVerifier.json
65
!/artifacts/contracts/KMSVerifier.sol/KMSVerifier.json
76
!/artifacts/contracts/TFHEExecutor.sol/TFHEExecutor.json
87
!/artifacts/contracts/TFHEExecutorWithEvents.sol/TFHEExecutorWithEvents.json

contracts/.solcover.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
mocha: {
3+
fgrep: "[skip-on-coverage]",
4+
invert: true,
5+
},
6+
};

contracts/addresses/.env.acl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
ACL_CONTRACT_ADDRESS=0xFee8407e2f5e3Ee68ad77cAE98c434e637f516e5
1+
ACL_CONTRACT_ADDRESS=0x339EcE85B9E11a3A3AA557582784a15d7F82AAf2

contracts/addresses/.env.coprocessor

-1
This file was deleted.
+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
DECRYPTION_ORACLE_ADDRESS=0x33347831500F1e73f0ccCBb95c9f86B94d7b1123
1+
DECRYPTION_ORACLE_ADDRESS=0x3d39707abEa4f23229E5109C83c155F27029B7A9

contracts/addresses/.env.exec

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
TFHE_EXECUTOR_CONTRACT_ADDRESS=0x687408aB54661ba0b4aeF3a44156c616c6955E07
1+
TFHE_EXECUTOR_CONTRACT_ADDRESS=0xB4A8CBDed90998c564dF33679143e7A41c5259fE

contracts/addresses/.env.fhegaslimit

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
FHE_GASLIMIT_CONTRACT_ADDRESS=0xFb03BE574d14C256D56F09a198B586bdfc0A9de2
1+
FHE_GASLIMIT_CONTRACT_ADDRESS=0x208De73316E44722e16f6dDFF40881A3e4F86104
+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
INPUT_VERIFIER_CONTRACT_ADDRESS=0x3a2DA6f1daE9eF988B48d9CF27523FA31a8eBE50
1+
INPUT_VERIFIER_CONTRACT_ADDRESS=0x4862Ca9360e9131AfD04cD1217b94Df15CC1aEEC

contracts/addresses/.env.kmsverifier

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
KMS_VERIFIER_CONTRACT_ADDRESS=0x9D6891A6240D6130c54ae243d8005063D05fE14b
1+
KMS_VERIFIER_CONTRACT_ADDRESS=0x596E6682c72946AF006B27C131793F2b62527A4b

contracts/addresses/ACLAddress.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
pragma solidity ^0.8.24;
44

5-
address constant aclAdd = 0xFee8407e2f5e3Ee68ad77cAE98c434e637f516e5;
5+
address constant aclAdd = 0x339EcE85B9E11a3A3AA557582784a15d7F82AAf2;

0 commit comments

Comments
 (0)