Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
409b775
--wip-- [skip ci]
ryardley Jun 24, 2025
e7ae80f
--wip-- [skip ci]
ryardley Jun 25, 2025
209c428
--wip-- [skip ci]
ryardley Jun 25, 2025
8caf82b
Build sdk package so that hardhat uses a separate tsconfig
ryardley Jun 25, 2025
c4ef4b8
Linting
ryardley Jun 25, 2025
a44158e
Linting
ryardley Jun 25, 2025
d50eafe
--wip-- [skip ci]
ryardley Jun 26, 2025
da9f11e
Update moduleResolution
ryardley Jun 26, 2025
3cdc8ef
Update packages
ryardley Jun 26, 2025
37c6702
Merge branch 'hacknet' into ry/518-integration-test
ryardley Jun 26, 2025
9203763
Ensure that LSP can respect the correct tsconfig
ryardley Jun 26, 2025
997cd8b
Tidy up eslint
ryardley Jun 26, 2025
1149cf5
Tidy up eslint
ryardley Jun 26, 2025
8daad4d
Add package to Dockerfile
ryardley Jun 26, 2025
72f25cc
Fix up issues with docker build for ciphernodes
ryardley Jun 26, 2025
7b3ae5e
Update Dockerfile
ryardley Jun 27, 2025
839d0da
Fix up warnings
ryardley Jun 27, 2025
6eeed76
Linting
ryardley Jun 27, 2025
2549f38
Merge branch 'hacknet' into ry/518-integration-test
ryardley Jun 27, 2025
3104237
Fix warnings
ryardley Jun 27, 2025
c454a06
Update viem dependency
ryardley Jun 27, 2025
e2908d1
Get test to pass
ryardley Jun 27, 2025
1d7e90d
Add rust to workflow
ryardley Jun 27, 2025
58083b6
Add compiling sdk and lwasm to be part of the build process
ryardley Jun 27, 2025
a0d6a39
Add wasm-pack
ryardley Jun 28, 2025
abbf778
Install with wasm
ryardley Jun 28, 2025
08bf698
Rename
ryardley Jun 28, 2025
81ed6c3
Fix pnpm version
ryardley Jun 28, 2025
ba0e9e8
Test template integration
ryardley Jun 28, 2025
333c6b8
update names
ryardley Jun 28, 2025
2329cfb
Lowercase
ryardley Jun 28, 2025
3382f3c
Actually fail when failing
ryardley Jun 29, 2025
2641a86
Use lines
ryardley Jun 29, 2025
31f9182
Build sdk before testing
ryardley Jun 29, 2025
b42dedd
linting
ryardley Jun 29, 2025
75140d1
linting
ryardley Jun 29, 2025
71f536d
Add submodules to template
ryardley Jun 29, 2025
a5b294b
Add submodules recursive to template
ryardley Jun 29, 2025
e633f9c
Add permissions to folders
ryardley Jun 30, 2025
2dec685
Ensure ImageID.sol is writable
ryardley Jun 30, 2025
cf61d01
Attempt to open up permissions on ImageID.sol
ryardley Jun 30, 2025
4a73eaf
Attempt to open up permissions on ImageID.sol
ryardley Jun 30, 2025
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
11 changes: 11 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,17 @@ jobs:
- name: "Check out the repo"
uses: "actions/checkout@v4"

- name: Install Rust 1.85.0
uses: actions-rs/toolchain@v1
with:
toolchain: 1.85.0
target: wasm32-unknown-unknown

# required so that we can compile wasm within the sdk
- uses: jetli/wasm-pack-action@v0.4.0
with:
version: "latest"

- name: "Setup node"
uses: actions/setup-node@v3
with:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build Support Dockerfile
name: TEMPLATE
on:
workflow_dispatch:
pull_request:
Expand All @@ -17,7 +17,7 @@ permissions:
packages: write
jobs:
build:
name: Build & Push Image
name: Compile and push Support Dockerfile
runs-on: ubuntu-latest
outputs:
image_tag: ${{ steps.version.outputs.version }}
Expand Down Expand Up @@ -63,3 +63,41 @@ jobs:
type=gha,mode=max,scope=cargo-git
type=gha,mode=max,scope=cargo-target
type=gha,mode=max,scope=buildcache

template_integration:
name: Template Integration
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "22"

- name: Install pnpm
uses: pnpm/action-setup@v4

- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
targets: wasm32-unknown-unknown

- name: Install wasm-pack
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh

- name: Install enclave CLI
run: cargo install --path crates/cli --bin enclave

- name: Install node dependencies
run: pnpm install

- name: Build the sdk
run: pnpm build

- name: Test Template
run: cd templates/default && chmod 777 contracts && chmod 777 tests && chmod 777 contracts/ImageID.sol && pnpm test:integration
13 changes: 13 additions & 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 Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ members = [
"crates/support-scripts",
"crates/test-helpers",
"crates/tests",
"crates/wasm",
]
exclude = [
"examples/CRISP/apps/server",
Expand Down
20 changes: 12 additions & 8 deletions crates/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
FROM node:22 AS evm-builder

WORKDIR /build/packages/evm
COPY ./packages/evm ./
WORKDIR /build
COPY crates/wasm/package.json ./crates/wasm/package.json
COPY packages/enclave-react ./packages/enclave-react
COPY packages/evm ./packages/evm
COPY pnpm-workspace.yaml .
COPY pnpm-lock.yaml .

RUN npm install -g corepack
RUN corepack enable

RUN pnpm install && pnpm compile
# We just need the contracts to be compiled here
RUN cd packages/evm && pnpm install && pnpm compile:contracts

# Build stage
FROM rust:1.81 AS ciphernode-builder
FROM rust:1.85 AS ciphernode-builder

# Force incremental
ENV CARGO_INCREMENTAL=1
Expand All @@ -33,14 +38,14 @@ COPY crates/aggregator/Cargo.toml ./aggregator/Cargo.toml
COPY crates/bfv-helpers/Cargo.toml ./bfv-helpers/Cargo.toml
COPY crates/cli/Cargo.toml ./cli/Cargo.toml
COPY crates/compute-provider/Cargo.toml ./compute-provider/Cargo.toml
COPY crates/enclaveup/Cargo.toml ./enclaveup/Cargo.toml
COPY crates/config/Cargo.toml ./config/Cargo.toml
COPY crates/crypto/Cargo.toml ./crypto/Cargo.toml
COPY crates/data/Cargo.toml ./data/Cargo.toml
COPY crates/enclaveup/Cargo.toml ./enclaveup/Cargo.toml
COPY crates/entrypoint/Cargo.toml ./entrypoint/Cargo.toml
COPY crates/events/Cargo.toml ./events/Cargo.toml
COPY crates/evm/Cargo.toml ./evm/Cargo.toml
COPY crates/evm-helpers/Cargo.toml ./evm-helpers/Cargo.toml
COPY crates/evm/Cargo.toml ./evm/Cargo.toml
COPY crates/fhe/Cargo.toml ./fhe/Cargo.toml
COPY crates/fs/Cargo.toml ./fs/Cargo.toml
COPY crates/indexer/Cargo.toml ./indexer/Cargo.toml
Expand All @@ -54,9 +59,8 @@ COPY crates/sortition/Cargo.toml ./sortition/Cargo.toml
COPY crates/support-scripts/Cargo.toml ./support-scripts/Cargo.toml
COPY crates/test-helpers/Cargo.toml ./test-helpers/Cargo.toml
COPY crates/tests/Cargo.toml ./tests/Cargo.toml
COPY crates/wasm/Cargo.toml ./wasm/Cargo.toml


# COPY ./crates/entrypoint/build.rs ./entrypoint/build.rs
RUN echo 'fn main() { println!("cargo:warning=dependency cache build"); }' > ./entrypoint/build.rs
RUN echo 'fn main() { println!("cargo:warning=dependency cache build"); }' > ./cli/build.rs
RUN for d in ./*/ ; do \
Expand Down
3 changes: 2 additions & 1 deletion crates/bfv-helpers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ alloy-dyn-abi = { workspace = true }
alloy-primitives = { workspace = true }
fhe-traits.workspace = true
fhe_rs.workspace = true
rand.workspace = true
anyhow.workspace = true

[dev-dependencies]
hex.workspace = true
anyhow.workspace = true
31 changes: 31 additions & 0 deletions crates/bfv-helpers/src/client.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
use crate::{build_bfv_params_arc, params::SET_2048_1032193_1};
use anyhow::anyhow;
use anyhow::Result;
use fhe_rs::bfv::Encoding;
use fhe_rs::bfv::Plaintext;
use fhe_rs::bfv::PublicKey;
use fhe_traits::{DeserializeParametrized, FheEncoder, FheEncrypter, Serialize};
use rand::CryptoRng;
use rand::RngCore;

pub fn bfv_encrypt_u64<R>(data: u64, public_key: Vec<u8>, mut rng: R) -> Result<Vec<u8>>
where
R: RngCore + CryptoRng,
{
let (degree, plaintext_modulus, moduli) = SET_2048_1032193_1;
let params = build_bfv_params_arc(degree, plaintext_modulus, &moduli);

let pk = PublicKey::from_bytes(&public_key, &params)
.map_err(|e| anyhow!("Error deserializing public key:{e}"))?;

let input = vec![data];
let pt = Plaintext::try_encode(&input, Encoding::poly(), &params)
.map_err(|e| anyhow!("Error encoding plaintext: {e}"))?;

let ct = pk
.try_encrypt(&pt, &mut rng)
.map_err(|e| anyhow!("Error encrypting data: {e}"))?;

let encrypted_data = ct.to_bytes();
Ok(encrypted_data)
}
3 changes: 3 additions & 0 deletions crates/bfv-helpers/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
pub mod client;

use alloy_dyn_abi::{DynSolType, DynSolValue};
use alloy_primitives::U256;
use fhe_rs::bfv::{BfvParameters, BfvParametersBuilder};
use std::sync::Arc;

/// Predefined BFV parameters for common use cases
pub mod params {
/// Standard BFV parameters sets
Expand Down
2 changes: 1 addition & 1 deletion crates/cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::nodes::{self, NodeCommands};
use crate::password::PasswordCommands;
use crate::program::{self, ProgramCommands};
use crate::wallet::WalletCommands;
use crate::{config_set, init, net, nodes_purge, password, purge_all, rev, wallet};
use crate::{config_set, init, net, password, purge_all, rev, wallet};
use crate::{print_env, start};
use anyhow::{bail, Result};
use clap::{command, ArgAction, Parser, Subcommand};
Expand Down
6 changes: 0 additions & 6 deletions crates/config/src/app_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,12 +241,6 @@ impl AppConfig {
self.node_def().quic_port
}

/// Depricated
#[deprecated]
pub fn enable_mdns(&self) -> bool {
false
}

/// Get the config file path
pub fn config_file(&self) -> PathBuf {
self.paths.config_file()
Expand Down
1 change: 0 additions & 1 deletion crates/entrypoint/src/start/aggregator_start.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ pub async fn execute(
config.peers(),
&cipher,
config.quic_port(),
config.enable_mdns(),
repositories.libp2p_keypair(),
)
.await?;
Expand Down
1 change: 0 additions & 1 deletion crates/entrypoint/src/start/start.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ pub async fn execute(
config.peers(),
&cipher,
config.quic_port(),
config.enable_mdns(),
repositories.libp2p_keypair(),
)
.await?;
Expand Down
2 changes: 1 addition & 1 deletion crates/events/src/eventbus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ impl<E: Event> Actor for HistoryCollector<E> {

impl<E: Event> Handler<E> for HistoryCollector<E> {
type Result = E::Result;
fn handle(&mut self, msg: E, ctx: &mut Self::Context) -> Self::Result {
fn handle(&mut self, msg: E, _ctx: &mut Self::Context) -> Self::Result {
self.history.push(msg);
}
}
Expand Down
5 changes: 2 additions & 3 deletions crates/evm-helpers/src/contracts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ use alloy::{
providers::fillers::{
ChainIdFiller, FillProvider, GasFiller, JoinFill, NonceFiller, WalletFiller,
},
providers::{Identity, Provider, ProviderBuilder, RootProvider, WalletProvider},
rpc::types::{BlockNumberOrTag, TransactionReceipt},
providers::{Identity, Provider, ProviderBuilder, RootProvider},
rpc::types::TransactionReceipt,
signers::local::PrivateKeySigner,
sol,
transports::BoxTransport,
};
use async_trait::async_trait;
use eyre::Result;
Expand Down
2 changes: 1 addition & 1 deletion crates/evm-helpers/src/listener.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ impl EventListener {
}

pub async fn create_contract_listener(ws_url: &str, contract_address: &str) -> Result<Self> {
let provider = Arc::new(ProviderBuilder::new().on_builtin(ws_url).await?);
let provider = Arc::new(ProviderBuilder::new().connect(ws_url).await?);
let address = contract_address.parse::<Address>()?;
let filter = Filter::new()
.address(address)
Expand Down
4 changes: 1 addition & 3 deletions crates/indexer/src/traits.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
use std::fmt::Display;

use async_trait::async_trait;
use serde::{de::DeserializeOwned, Serialize};
use tokio::task::JoinHandle;
use std::fmt::Display;

/// Trait for injectable DataStore. Note the implementor must manage interior mutability
#[async_trait]
Expand Down
2 changes: 2 additions & 0 deletions crates/init/src/package_json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use anyhow::Result;
use serde_json::{Map, Value};
use tokio::fs;

#[allow(dead_code)]
#[derive(Debug, Clone)]
pub enum DependencyType {
Dependencies,
Expand Down Expand Up @@ -32,6 +33,7 @@ pub async fn get_version_from_package_json(file_path: &PathBuf) -> Result<String
.ok_or_else(|| anyhow::anyhow!("version field not found or not a string"))
}

#[allow(dead_code)]
fn validate_dependency_type(dep_type: &str) -> Result<()> {
match dep_type {
"dependencies" | "devDependencies" | "peerDependencies" => Ok(()),
Expand Down
2 changes: 2 additions & 0 deletions crates/init/src/pkgman.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ pub struct PkgMan {
cwd: PathBuf,
}

#[allow(dead_code)]
pub enum PkgManKind {
NPM,
PNPM,
Expand All @@ -87,6 +88,7 @@ impl PkgMan {
self
}

#[allow(dead_code)]
pub async fn available(&self) -> bool {
self.strategy.available().await
}
Expand Down
7 changes: 1 addition & 6 deletions crates/net/src/bin/p2p_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,10 @@ async fn main() -> Result<()> {
.ok()
.and_then(|p| p.parse::<String>().ok());

let enable_mdns = env::var("ENABLE_MDNS")
.unwrap_or("false".to_string())
.parse::<bool>()
.unwrap();

let peers: Vec<String> = dial_to.iter().cloned().collect();

let id = libp2p::identity::Keypair::generate_ed25519();
let mut peer = NetworkPeer::new(&id, peers, udp_port, "test-topic", enable_mdns)?;
let mut peer = NetworkPeer::new(&id, peers, udp_port, "test-topic")?;

// Extract input and outputs
let tx = peer.tx();
Expand Down
3 changes: 2 additions & 1 deletion crates/net/src/dialer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,8 @@ fn resolve_ipv4(domain: &str) -> Result<String> {
Ok(addr.ip().to_string())
}

fn resolve_ipv6(domain: &str) -> Result<String> {
// For if we wish to resolve ipv6 as well (currently disabled)
fn _resolve_ipv6(domain: &str) -> Result<String> {
let addr = format!("{}:0", domain)
.to_socket_addrs()?
.find(|addr| addr.ip().is_ipv6())
Expand Down
3 changes: 1 addition & 2 deletions crates/net/src/network_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ impl NetworkManager {
peers: Vec<String>,
cipher: &Arc<Cipher>,
quic_port: u16,
enable_mdns: bool,
repository: Repository<Vec<u8>>,
) -> Result<(Addr<Self>, tokio::task::JoinHandle<Result<()>>, String)> {
let topic = "tmp-enclave-gossip-topic";
Expand All @@ -101,7 +100,7 @@ impl NetworkManager {
// Create peer from keypair
let keypair: libp2p::identity::Keypair =
ed25519::Keypair::try_from_bytes(&mut bytes)?.try_into()?;
let mut peer = NetworkPeer::new(&keypair, peers, Some(quic_port), topic, enable_mdns)?;
let mut peer = NetworkPeer::new(&keypair, peers, Some(quic_port), topic)?;

// Setup and start network manager
let rx = peer.rx();
Expand Down
Loading
Loading