Skip to content
Draft
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
8 changes: 8 additions & 0 deletions .github/workflows/test-suite-e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,14 @@ jobs:
run: |
./fhevm-cli deploy

- name: Public Decryption test
working-directory: test-suite/fhevm
run: |
timeout 5m ./fhevm-cli test delegate-public-decryption
./fhevm-cli logs coprocessor-host-listener
./fhevm-cli logs coprocessor-gw-listener
exit 1

- name: Input proof test (uint64)
working-directory: test-suite/fhevm
run: |
Expand Down

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

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

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

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

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

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

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

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
CREATE TABLE IF NOT EXISTS delegate_user_decrypt (
delegator BYTEA NOT NULL,
delegate BYTEA NOT NULL,
contract_address BYTEA NOT NULL,
delegation_counter BIGINT NOT NULL,
old_expiry_date BIGINT NOT NULL, -- 0 = first time delegation
expiry_date BIGINT NOT NULL, -- 0 = revoke
host_chain_id BIGINT NOT NULL,
block_number BIGINT NOT NULL,
block_hash BYTEA NOT NULL, -- to check finality
transaction_id BYTEA,
UNIQUE(delegator, delegate, contract_address, delegation_counter, old_expiry_date, expiry_date, block_number, block_hash, transaction_id)
);
1 change: 1 addition & 0 deletions coprocessor/fhevm-engine/gw-listener/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ WORKDIR /app
COPY coprocessor/fhevm-engine ./coprocessor/fhevm-engine
COPY coprocessor/proto ./coprocessor/proto
COPY gateway-contracts/contracts/ ./gateway-contracts/contracts/
COPY gateway-contracts/rust_bindings/ ./gateway-contracts/rust_bindings
COPY --from=contract_builder /app/gateway-contracts/artifacts/contracts /app/gateway-contracts/artifacts/contracts
COPY .git/HEAD ./coprocessor/fhevm-engine/BUILD_ID

Expand Down
1 change: 1 addition & 0 deletions coprocessor/fhevm-engine/host-listener/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ COPY coprocessor/fhevm-engine ./coprocessor/fhevm-engine
COPY coprocessor/proto ./coprocessor/proto
COPY host-contracts/contracts/ ./host-contracts/contracts/
COPY --from=contract_builder /app/host-contracts/artifacts/contracts /app/host-contracts/artifacts/contracts
COPY gateway-contracts/rust_bindings ./gateway-contracts/rust_bindings
COPY .git/HEAD ./coprocessor/fhevm-engine/BUILD_ID

WORKDIR /app/coprocessor/fhevm-engine
Expand Down
5 changes: 4 additions & 1 deletion coprocessor/fhevm-engine/host-listener/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ use semver::Version;
use std::{env, fs, path::Path, process::Command};

fn build_contracts() {
println!("cargo:rerun-if-changed=../../../host-contracts/contracts");
println!(
"cargo:rerun-if-changed=../../../host-contracts/contracts/ACL.sol"
);
println!("cargo:rerun-if-changed=../../../host-contracts/contracts/FHEVMExecutor.sol");
// Step 1: Copy ../../contracts/.env.example to ../../contracts/.env
let env_example = Path::new("../../../host-contracts/.env.example");
let env_dest = Path::new("../../../host-contracts/.env");
Expand Down
17 changes: 17 additions & 0 deletions coprocessor/fhevm-engine/host-listener/contracts/ACLTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,21 @@ contract ACLTest is ACLEvents {
emit Allowed(msg.sender, account, handle);
}


function delegateForUserDecryption(
address delegate,
address contractAddress,
uint64 delegationCounter,
uint64 oldExpiryDate,
uint64 newExpiryDate
) public virtual {
emit DelegatedForUserDecryption(
msg.sender,
delegate,
contractAddress,
delegationCounter,
oldExpiryDate,
newExpiryDate
);
}
}
21 changes: 19 additions & 2 deletions coprocessor/fhevm-engine/host-listener/src/cmd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,7 @@ impl InfiniteLogIter {
}

async fn db_insert_block(
chain_id: u64,
db: &mut Database,
block_logs: &BlockLogs<Log>,
acl_contract_address: &Option<Address>,
Expand All @@ -794,13 +795,23 @@ async fn db_insert_block(
let mut retries = 10;
loop {
let res = db_insert_block_no_retry(
chain_id,
db,
block_logs,
acl_contract_address,
tfhe_contract_address,
)
.await;
let Err(err) = res else {
// Notify the database of the new block
// Delayed delegation rely on this signal to reconsider ready delegation
if !block_logs.catchup {
if let Err(err) =
db.block_notification(block_logs.summary.number).await
{
error!(error = %err, "Error notifying listener for new block");
};
}
return Ok(());
};
if retries == 0 {
Expand All @@ -820,6 +831,7 @@ async fn db_insert_block(
}

async fn db_insert_block_no_retry(
chain_id: u64,
db: &mut Database,
block_logs: &BlockLogs<Log>,
acl_contract_address: &Option<Address>,
Expand All @@ -828,6 +840,8 @@ async fn db_insert_block_no_retry(
let mut tx = db.new_transaction().await?;
let mut is_allowed = HashSet::<Handle>::new();
let mut tfhe_event_log = vec![];
let block_hash = block_logs.summary.hash;
let block_number = block_logs.summary.number;
for log in &block_logs.logs {
let current_address = Some(log.inner.address);
let is_acl_address = &current_address == acl_contract_address;
Expand All @@ -844,7 +858,9 @@ async fn db_insert_block_no_retry(
&mut tx,
&event,
&log.transaction_hash,
&log.block_number,
chain_id,
block_hash.as_ref(),
block_number,
)
.await?;
continue;
Expand All @@ -859,7 +875,7 @@ async fn db_insert_block_no_retry(
event,
transaction_hash: log.transaction_hash,
is_allowed: false, // updated in the next loop
block_number: log.block_number,
block_number,
};
tfhe_event_log.push(log);
continue;
Expand Down Expand Up @@ -993,6 +1009,7 @@ pub async fn main(args: Args) -> anyhow::Result<()> {

while let Some(block_logs) = log_iter.next().await {
let _ = db_insert_block(
chain_id,
&mut db,
&block_logs,
&acl_contract_address,
Expand Down
Loading
Loading