Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PR test for coprocessor #47

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .github/workflows/coprocessor-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Run PR test

on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
coprocessor_test:
permissions:
contents: read
runs-on: "large_ubuntu_32"
if: ${{ github.event_name == 'push' || !github.event.pull_request.draft }}
steps:
- name: Check out repo
uses: actions/checkout@v4

- name: Install protobuf compiler
run: sudo apt-get install -y protobuf-compiler

- name: Install sqlx-cli from crates.io
uses: baptiste0928/cargo-install@v3
with:
crate: sqlx-cli
version: '^0.8'

- name: Setup database
working-directory: ./fhevm-engine/coprocessor
run: |
make init_db
# build with --release flag for faster tests
cargo build --release
cargo build --tests --release
DATABASE_URL="postgres://postgres:postgres@localhost/coprocessor" cargo run --release -- --metrics-addr=127.0.0.1:9100 --run-server &
DATABASE_URL="postgres://postgres:postgres@localhost/coprocessor" cargo run --release -- --metrics-addr=127.0.0.1:9101 --run-bg-worker &
# give some time for ports to open etc
sleep 1
COPROCESSOR_TEST_LOCALHOST=true cargo test --release -- --nocapture

4 changes: 4 additions & 0 deletions fhevm-engine/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion fhevm-engine/coprocessor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ tonic-web = "0.12"
tonic-health = "0.12"
tonic-types = "0.12"
tokio-util = "0.7"
sqlx = { version = "0.7", features = ["runtime-tokio", "tls-rustls", "postgres", "uuid"] }
sqlx = { version = "0.7", features = ["runtime-tokio", "tls-rustls", "postgres", "uuid", "time"] }
alloy = { version = "0.3.2", features = ["eip712", "sol-types", "signer-local"] }
serde_json = "1.0"
regex = "1.10.5"
Expand Down
4 changes: 2 additions & 2 deletions fhevm-engine/coprocessor/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ build:

.PHONY: cleanup
cleanup:
docker compose down -v
docker compose -f docker-compose.test.yml down -v

.PHONY: init_db
init_db:
docker compose up -d
docker compose -f docker-compose.test.yml up -d
sleep 3
$(DB_URL) sqlx db create
$(DB_URL) sqlx migrate run
Expand Down
15 changes: 15 additions & 0 deletions fhevm-engine/coprocessor/docker-compose.test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: '3.8'
services:
db:
image: postgres:15.7
restart: always
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
ports:
- '5432:5432'
volumes:
- db:/var/lib/postgresql/data
volumes:
db:
driver: local
14 changes: 13 additions & 1 deletion fhevm-engine/coprocessor/src/tests/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,19 @@ pub async fn wait_until_all_ciphertexts_computed(
println!("All computations completed");
break;
} else {
println!("{current_count} computations remaining, waiting...");
let errors = sqlx::query!("SELECT output_handle, error_message FROM computations WHERE is_error LIMIT 5")
.fetch_all(&pool)
.await?;
if !errors.is_empty() {
println!("errors found inside computations, breaking: {:?}", errors);
break;
} else {
println!("{current_count} computations remaining, waiting...");
let recs = sqlx::query!("SELECT * FROM computations WHERE NOT is_completed LIMIT 5")
.fetch_all(&pool)
.await?;
println!("{:#?}", recs);
}
}
}

Expand Down
7 changes: 5 additions & 2 deletions fhevm-engine/fhevm-engine-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ version = "0.1.0"
edition = "2021"

[target.'cfg(target_arch = "x86_64")'.dependencies]
tfhe = { version = "0.8.3", features = ["boolean", "shortint", "integer", "x86_64-unix", "zk-pok", "experimental-force_fft_algo_dif4", "nightly-avx512"] }
tfhe = { version = "0.8.3", features = ["boolean", "shortint", "integer", "x86_64-unix", "zk-pok", "experimental-force_fft_algo_dif4"] }
[target.'cfg(target_arch = "aarch64")'.dependencies]
tfhe = { version = "0.8.3", features = ["boolean", "shortint", "integer", "aarch64-unix", "zk-pok", "experimental-force_fft_algo_dif4", "nightly-avx512"] }
tfhe = { version = "0.8.3", features = ["boolean", "shortint", "integer", "aarch64-unix", "zk-pok", "experimental-force_fft_algo_dif4"] }

[dependencies]
sha3.workspace = true
Expand All @@ -19,6 +19,9 @@ bigdecimal = "0.4.5"
rand_chacha = "0.3.1"
rand = "0.8.5"

[features]
nightly-avx512 = ["tfhe/nightly-avx512"]

[[bin]]
name = "generate-keys"
path = "src/bin/generate_keys.rs"
Loading