Skip to content
Merged
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
1 change: 1 addition & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions crates/program-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ e3-compute-provider.workspace = true
reqwest.workspace = true
anyhow.workspace = true
hex.workspace = true
derivative.workspace = true
6 changes: 5 additions & 1 deletion crates/program-server/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// or FITNESS FOR A PARTICULAR PURPOSE.

use anyhow::Result;
use derivative::Derivative;
use serde::{Deserialize, Deserializer, Serialize, Serializer};

#[derive(Serialize, Deserialize, Debug)]
Expand All @@ -23,12 +24,15 @@ pub struct ComputeRequest {
pub callback_url: Option<String>,
}

#[derive(Serialize, Debug)]
#[derive(Derivative, Serialize)]
#[derivative(Debug)]
pub struct WebhookPayload {
pub e3_id: u64,
#[serde(serialize_with = "serialize_as_hex")]
#[derivative(Debug = "ignore")]
pub ciphertext: Vec<u8>,
#[serde(serialize_with = "serialize_as_hex")]
#[derivative(Debug = "ignore")]
pub proof: Vec<u8>,
}

Expand Down
1 change: 1 addition & 0 deletions examples/CRISP/Cargo.lock

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

1 change: 1 addition & 0 deletions examples/CRISP/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ anyhow = { version = "=1.0.98" }
actix-web = "=4.11.0"
bincode = { version = "=1.3.3" }
bytemuck = { version = "=1.23.1" }
derivative = "=2.2.0"
eyre = "=0.6.12"
env_logger = "=0.11.8"
hex = { version = "=0.4.3" }
Expand Down
1 change: 1 addition & 0 deletions examples/CRISP/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"scripts": {
"cli": "pnpm sh ./scripts/cli.sh",
"dev": "vite --no-open --host",
"dev-static": "NO_HOT=1 vite --no-open --host",
"build": "tsc && vite build",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview",
Expand Down
3 changes: 2 additions & 1 deletion examples/CRISP/client/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import topLevelAwait from 'vite-plugin-top-level-await'
import path from 'path'
import { nodePolyfills } from 'vite-plugin-node-polyfills'

process.env.NO_HOT && console.log('Running without HMR')
// const development: boolean = !process.env.NODE_ENV || process.env.NODE_ENV === 'development'

export default defineConfig({
base: '/',
define: {
Expand Down Expand Up @@ -52,5 +52,6 @@ export default defineConfig({
open: true,
// this sets a default port to 3000
port: 3000,
hmr: !process.env.NO_HOT,
},
})
6 changes: 4 additions & 2 deletions examples/CRISP/scripts/dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@ cleanup() {

trap cleanup INT TERM

echo "DEV SCRIPT STARTING..."

pnpm concurrently \
-ks first \
--names "ANVIL,DEPLOY,NODES" \
--prefix-colors "blue,green,yellow" \
--names "HARDHAT,DEPLOY" \
--prefix-colors "blue,green" \
"cd packages/crisp-contracts && pnpm hardhat node" \
"./scripts/crisp_deploy.sh && ./scripts/dev_services.sh"

4 changes: 2 additions & 2 deletions examples/CRISP/scripts/dev_client.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

set -euo pipefail

sleep 4
echo "CLIENT SCRIPT RUNNING..."

(cd ./client && pnpm dev)
(cd ./client && pnpm dev-static)
2 changes: 1 addition & 1 deletion examples/CRISP/scripts/dev_services.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ set -euo pipefail
concurrently -kr \
"./scripts/dev_cipher.sh" \
"./scripts/dev_program.sh" \
"sleep 3 && ./scripts/dev_server.sh" \
"wait-on tcp:13151 && ./scripts/dev_server.sh" \
"wait-on tcp:4000 && ./scripts/dev_client.sh"
3 changes: 2 additions & 1 deletion examples/CRISP/scripts/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ set -e

export CARGO_INCREMENTAL=1

echo "SETUP..."
echo "pnpm install"
(cd ../../ && pnpm install --frozen-lockfile)
echo "evm"
Expand All @@ -19,4 +20,4 @@ if [[ ! -f ~/.cargo/bin/enclave ]]; then
else
echo "enclave CLI already installed, skipping build"
fi
echo "Skipping circuit compilation - using pre-compiled circuits"
echo "Skipping circuit compilation - using pre-compiled circuits"
5 changes: 3 additions & 2 deletions examples/CRISP/scripts/test_e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ if [ "$1" == "--ui" ]; then
else
# Use xvfb-run only on Linux systems
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
PLAYWRIGHT_CMD="pnpm synpress --headless && xvfb-run pnpm playwright test"
PLAYWRIGHT_CMD="pnpm synpress --headless && xvfb-run --auto-servernum --server-args=\"-screen 0 1280x960x24\" pnpm playwright test"
else
PLAYWRIGHT_CMD="pnpm synpress --headless && pnpm playwright test"
fi
fi

concurrently -krs first "./scripts/setup.sh && ./scripts/dev.sh" "wait-on http://localhost:3000 && ${PLAYWRIGHT_CMD} && sleep 3"
echo "TEST E2E SCRIPT STARTING..."
pnpm concurrently -krs first "./scripts/setup.sh && ./scripts/dev.sh" "wait-on tcp:3000 && sleep 20 && ${PLAYWRIGHT_CMD} && sleep 3"
1 change: 1 addition & 0 deletions examples/CRISP/server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ bincode.workspace = true
serde.workspace = true
serde_json.workspace = true
eyre.workspace = true
derivative.workspace = true

# Utility libraries
bigdecimal = "=0.4.3"
Expand Down
7 changes: 5 additions & 2 deletions examples/CRISP/server/src/server/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,18 @@
// or FITNESS FOR A PARTICULAR PURPOSE.

use anyhow::Result;
use derivative::Derivative;
use serde::{Deserialize, Deserializer, Serialize};

#[derive(Deserialize, Debug)]
#[derive(Derivative, Deserialize)]
#[derivative(Debug)]
pub struct WebhookPayload {
pub e3_id: u64,
#[serde(deserialize_with = "deserialize_hex_string")]
#[derivative(Debug = "ignore")]
pub ciphertext: Vec<u8>,
#[serde(deserialize_with = "deserialize_hex_string")]
#[derivative(Debug = "ignore")]
pub proof: Vec<u8>,
}

Expand Down Expand Up @@ -132,7 +136,6 @@ pub struct E3StateLite {
pub balance_threshold: String,
}


#[derive(Debug, Deserialize, Serialize)]
pub struct E3 {
// Identifiers
Expand Down
10 changes: 5 additions & 5 deletions examples/CRISP/test/crisp.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ async function runCliInit() {
// Execute the command and wait for it to complete
const output = execSync(
"pnpm cli init --token-address 0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512 --balance-threshold 1000",
{ encoding: "utf-8" }
{ encoding: "utf-8" },
);
console.log("Command output:", output);
return output;
Expand All @@ -30,7 +30,7 @@ const { expect } = test;

async function ensureHomePageLoaded(page: Page) {
return await expect(page.locator("h4")).toHaveText(
"Coercion-Resistant Impartial Selection Protocol"
"Coercion-Resistant Impartial Selection Protocol",
);
}

Expand All @@ -44,7 +44,7 @@ test("CRISP smoke test", async ({
context,
metamaskPage,
basicSetup.walletPassword,
extensionId
extensionId,
);

await runCliInit();
Expand All @@ -62,9 +62,9 @@ test("CRISP smoke test", async ({
await page.locator('a:has-text("Historic polls")').click();
await expect(page.locator("h1")).toHaveText("Historic polls");
await expect(
page.locator("[data-test-id='poll-0-0'] [data-test-id='poll-result-0'] h3")
page.locator("[data-test-id='poll-0-0'] [data-test-id='poll-result-0'] h3"),
).toHaveText("100%");
await expect(
page.locator("[data-test-id='poll-0-0'] [data-test-id='poll-result-1'] h3")
page.locator("[data-test-id='poll-0-0'] [data-test-id='poll-result-1'] h3"),
).toHaveText("0%");
});
9 changes: 9 additions & 0 deletions scripts/run-crisp-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

echo "This helper script will clean your repository and run end-to-end tests for CRISP."
echo "WARNING: This will reset your current workspace. Ensure all changes are committed before proceeding."
echo "Press any key to continue or Ctrl+C to cancel..."

read

rm -rf * && git reset --hard HEAD && git submodule update --init --recursive && pnpm install && cd examples/CRISP && pnpm test:e2e "$@"
Loading