From fafd6a8beee69aaecb7a0c0ad92eb7d4304a3883 Mon Sep 17 00:00:00 2001 From: Hamza Khalid Date: Fri, 21 Nov 2025 03:34:57 +0500 Subject: [PATCH 1/3] fix: risc0 program id contract path --- crates/support-scripts/ctl/container | 4 +++- crates/support/scripts/build.sh | 2 +- crates/support/scripts/dev.sh | 4 ++-- .../generated}/contracts/ImageID.sol | 2 +- examples/CRISP/packages/crisp-contracts/deploy/crisp.ts | 9 ++++++++- .../{ => .enclave/generated}/contracts/ImageID.sol | 0 templates/default/hardhat.config.ts | 3 +++ 7 files changed, 18 insertions(+), 6 deletions(-) rename examples/CRISP/{packages/crisp-contracts => .enclave/generated}/contracts/ImageID.sol (85%) rename templates/default/{ => .enclave/generated}/contracts/ImageID.sol (100%) diff --git a/crates/support-scripts/ctl/container b/crates/support-scripts/ctl/container index 39afba04e7..3df0e08b0b 100755 --- a/crates/support-scripts/ctl/container +++ b/crates/support-scripts/ctl/container @@ -30,7 +30,9 @@ cleanup() { trap cleanup EXIT INT TERM mkdir -p "$(pwd)/.enclave/caches"/{target,registry,git,risc0-cache,risc0-circuits} +mkdir -p "$(pwd)/.enclave/generated"/{contracts,tests} chmod -R 777 "$(pwd)/.enclave/caches" +chmod -R 777 "$(pwd)/.enclave/generated" if [ -t 0 ]; then TTY_FLAGS="-it" @@ -54,7 +56,7 @@ else --platform linux/amd64 \ --add-host=host.local:host-gateway \ -p 13151:13151 \ - -v "$(pwd)/contracts:/app/contracts" \ + -v "$(pwd)/.enclave/generated/contracts:/app/contracts:rw" \ -v "$(pwd)/tests:/app/tests" \ -v "$(pwd)/.enclave/caches/target:/app/target" \ -v "$(pwd)/.enclave/caches/registry:/home/devuser/.cargo/registry" \ diff --git a/crates/support/scripts/build.sh b/crates/support/scripts/build.sh index cfa349100d..da16d4f8f8 100755 --- a/crates/support/scripts/build.sh +++ b/crates/support/scripts/build.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash PKG=ghcr.io/gnosisguild/e3-support -GIT_SHA=$(git rev-parse --short HEAD) +GIT_SHA=$(git rev-parse --short=9 HEAD) # Separate --push from other arguments PUSH=false diff --git a/crates/support/scripts/dev.sh b/crates/support/scripts/dev.sh index 1eb5d1230c..a1ac358fe1 100755 --- a/crates/support/scripts/dev.sh +++ b/crates/support/scripts/dev.sh @@ -8,8 +8,8 @@ docker run -it \ -v $(pwd)/types:/app/types \ -v $(pwd)/program:/app/program \ -v $(pwd)/scripts:/app/scripts \ - -v $(pwd)/contracts:/app/contracts \ - -v $(pwd)/tests:/app/tests \ + -v $(pwd)/.enclave/generated/contracts:/app/contracts \ + -v $(pwd)/.enclave/generated/tests:/app/tests \ -v $(pwd)/Cargo.toml:/app/Cargo.toml \ -v $(pwd)/Cargo.lock:/app/Cargo.lock \ $PKG diff --git a/examples/CRISP/packages/crisp-contracts/contracts/ImageID.sol b/examples/CRISP/.enclave/generated/contracts/ImageID.sol similarity index 85% rename from examples/CRISP/packages/crisp-contracts/contracts/ImageID.sol rename to examples/CRISP/.enclave/generated/contracts/ImageID.sol index 7bff45a61e..a78154c076 100755 --- a/examples/CRISP/packages/crisp-contracts/contracts/ImageID.sol +++ b/examples/CRISP/.enclave/generated/contracts/ImageID.sol @@ -19,5 +19,5 @@ pragma solidity ^0.8.20; library ImageID { - bytes32 public constant PROGRAM_ID = bytes32(0x23734b77b0f76e85623a88d7a82f24c34c94834f2501964ea123b7a2027013a2); + bytes32 public constant PROGRAM_ID = bytes32(0x23734b77b0f76e85623a88d7a82f24c34c94834f2501964ea123b7a2027013a2); } diff --git a/examples/CRISP/packages/crisp-contracts/deploy/crisp.ts b/examples/CRISP/packages/crisp-contracts/deploy/crisp.ts index be0fe2f147..781b1553e4 100644 --- a/examples/CRISP/packages/crisp-contracts/deploy/crisp.ts +++ b/examples/CRISP/packages/crisp-contracts/deploy/crisp.ts @@ -6,11 +6,18 @@ import { readDeploymentArgs, storeDeploymentArgs } from '@enclave-e3/contracts/scripts' import { Enclave__factory as EnclaveFactory } from '@enclave-e3/contracts/types' +import { readFileSync } from 'fs' import { ContractFactory } from 'ethers' import hre from 'hardhat' -const IMAGE_ID = '0x23734b77b0f76e85623a88d7a82f24c34c94834f2501964ea123b7a2027013a2' +const imageIdContent = readFileSync('../../.enclave/generated/contracts/ImageID.sol', 'utf-8') +const match = imageIdContent.match(/bytes32 public constant PROGRAM_ID = bytes32\((0x[a-fA-F0-9]+)\)/) +const IMAGE_ID = match ? match[1] : null + +if (!IMAGE_ID) { + throw new Error('IMAGE_ID not found') +} export const deployCRISPContracts = async () => { const { ethers } = await hre.network.connect() diff --git a/templates/default/contracts/ImageID.sol b/templates/default/.enclave/generated/contracts/ImageID.sol similarity index 100% rename from templates/default/contracts/ImageID.sol rename to templates/default/.enclave/generated/contracts/ImageID.sol diff --git a/templates/default/hardhat.config.ts b/templates/default/hardhat.config.ts index 041c0c0040..a0ac732ceb 100644 --- a/templates/default/hardhat.config.ts +++ b/templates/default/hardhat.config.ts @@ -75,6 +75,9 @@ const config: HardhatUserConfig = { outDir: './types', tsNocheck: false, }, + paths: { + sources: ['./contracts', './.enclave/generated/contracts'], + }, networks: { hardhat: { type: 'edr-simulated', From 5c15bcf7cbf2fe0ab48ec7b871c5b7d63a1fc7d3 Mon Sep 17 00:00:00 2001 From: Hamza Khalid Date: Fri, 21 Nov 2025 03:55:42 +0500 Subject: [PATCH 2/3] fix: update ci --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a732ba6b8c..48a77528b3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -689,8 +689,8 @@ jobs: - name: Test Template run: | cd templates/default - chmod 755 contracts tests - chmod 644 contracts/ImageID.sol + chmod 755 .enclave/generated/contracts .enclave/generated/tests + chmod 644 .enclave/generated/contracts/ImageID.sol pnpm test:integration test_enclave_init: From 54d48d38db7b4ad561aabbc989f504962ec27854 Mon Sep 17 00:00:00 2001 From: Hamza Khalid Date: Fri, 21 Nov 2025 04:04:48 +0500 Subject: [PATCH 3/3] fix: update ci --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 48a77528b3..bcc4e177d0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -689,7 +689,7 @@ jobs: - name: Test Template run: | cd templates/default - chmod 755 .enclave/generated/contracts .enclave/generated/tests + chmod 755 .enclave/generated/contracts tests chmod 644 .enclave/generated/contracts/ImageID.sol pnpm test:integration