Skip to content

Commit

Permalink
Add inputs support for coprocessor
Browse files Browse the repository at this point in the history
  • Loading branch information
david-zk committed Aug 23, 2024
1 parent 98d587c commit 916f55e
Show file tree
Hide file tree
Showing 15 changed files with 736 additions and 88 deletions.
204 changes: 204 additions & 0 deletions fhevm-engine/Cargo.lock

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

3 changes: 2 additions & 1 deletion fhevm-engine/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ resolver = "2"
members = ["coprocessor", "executor", "fhevm-engine-common"]

[workspace.dependencies]
tfhe = { version = "0.8.0-alpha.2", features = ["boolean", "shortint", "integer", "aarch64-unix"] }
tfhe = { version = "0.8.0-alpha.2", features = ["boolean", "shortint", "integer", "aarch64-unix", "zk-pok"] }
tfhe-zk-pok = "0.2.1"
clap = { version = "4.5", features = ["derive"] }
1 change: 1 addition & 0 deletions fhevm-engine/coprocessor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ bigdecimal = "0.4"
fhevm-engine-common = { path = "../fhevm-engine-common" }
strum = { version = "0.26", features = ["derive"] }
bincode = "1.3.3"
keccak-asm = "0.1.3"

[dev-dependencies]
testcontainers = "0.21"
Expand Down
14 changes: 14 additions & 0 deletions fhevm-engine/coprocessor/migrations/20240722111257_coprocessor.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
CREATE TABLE IF NOT EXISTS computations (
tenant_id INT NOT NULL,
output_handle BYTEA NOT NULL,
output_type SMALLINT NOT NULL,
-- can be handle or scalar, depends on is_scalar field
-- only second dependency can ever be scalar
dependencies BYTEA[] NOT NULL,
Expand All @@ -21,10 +22,23 @@ CREATE TABLE IF NOT EXISTS ciphertexts (
ciphertext BYTEA NOT NULL,
ciphertext_version SMALLINT NOT NULL,
ciphertext_type SMALLINT NOT NULL,
-- if ciphertext came from blob we have its reference
input_blob_hash BYTEA,
input_blob_index INT NOT NULL DEFAULT 0,
created_at TIMESTAMP DEFAULT NOW(),
PRIMARY KEY (tenant_id, handle, ciphertext_version)
);

-- store for audits and historical reference
CREATE TABLE IF NOT EXISTS input_blobs (
tenant_id INT NOT NULL,
blob_hash BYTEA NOT NULL,
blob_data BYTEA NOT NULL,
blob_ciphertext_count INT NOT NULL,
created_at TIMESTAMP DEFAULT NOW(),
PRIMARY KEY (tenant_id, blob_hash)
);

CREATE TABLE IF NOT EXISTS tenants (
tenant_id SERIAL PRIMARY KEY,
tenant_api_key UUID NOT NULL DEFAULT gen_random_uuid(),
Expand Down
8 changes: 8 additions & 0 deletions fhevm-engine/coprocessor/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ pub struct Args {
#[arg(long, default_value_t = 32)]
pub tenant_key_cache_size: i32,

/// Maximum compact inputs to upload
#[arg(long, default_value_t = 8)]
pub maximimum_compact_inputs_upload: usize,

/// Maximum compact inputs to upload
#[arg(long, default_value_t = 255)]
pub maximum_handles_per_input: u8,

/// Coprocessor FHE processing threads
#[arg(long, default_value_t = 8)]
pub coprocessor_fhe_threads: usize,
Expand Down
Loading

0 comments on commit 916f55e

Please sign in to comment.