diff --git a/examples/CRISP/packages/crisp-contracts/contracts/Mocks/RiscZeroGroth16Verifier.sol b/examples/CRISP/packages/crisp-contracts/contracts/Mocks/RiscZeroGroth16Verifier.sol new file mode 100644 index 0000000000..e48247c71a --- /dev/null +++ b/examples/CRISP/packages/crisp-contracts/contracts/Mocks/RiscZeroGroth16Verifier.sol @@ -0,0 +1,16 @@ +// SPDX-License-Identifier: LGPL-3.0-only +// +// This file is provided WITHOUT ANY WARRANTY; +// without even the implied warranty of MERCHANTABILITY +// or FITNESS FOR A PARTICULAR PURPOSE. +pragma solidity >=0.8.27; + +import {RiscZeroGroth16Verifier as RiscZero} from "risc0/groth16/RiscZeroGroth16Verifier.sol"; +import {ControlID} from "risc0/groth16/ControlID.sol"; + +contract RiscZeroGroth16Verifier is RiscZero { + constructor() RiscZero( + ControlID.CONTROL_ROOT, + ControlID.BN254_CONTROL_ID + ) {} +} \ No newline at end of file diff --git a/examples/CRISP/packages/crisp-contracts/deploy/Deploy.s.sol b/examples/CRISP/packages/crisp-contracts/deploy/Deploy.s.sol deleted file mode 100644 index ee5e662335..0000000000 --- a/examples/CRISP/packages/crisp-contracts/deploy/Deploy.s.sol +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright 2024 RISC Zero, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// SPDX-License-Identifier: Apache-2.0 - -pragma solidity ^0.8.28; - -import {RiscZeroGroth16Verifier} from "risc0/groth16/RiscZeroGroth16Verifier.sol"; -import {ControlID} from "risc0/groth16/ControlID.sol"; -import {Script} from "forge-std/Script.sol"; -import "forge-std/Test.sol"; - -contract CRISPProgramDeploy is Script { - function run() external { - // Read and log the chainID - uint256 chainId = block.chainid; - console2.log("Deploying on ChainID %d", chainId); - - setupDeployer(); - setupVerifier(); - - vm.stopBroadcast(); - } - - function setupDeployer() private { - uint256 deployerKey = uint256( - vm.envOr("PRIVATE_KEY", bytes32(0)) - ); - - vm.startBroadcast(deployerKey); - } - - function setupVerifier() private { - RiscZeroGroth16Verifier verifier = new RiscZeroGroth16Verifier( - ControlID.CONTROL_ROOT, - ControlID.BN254_CONTROL_ID - ); - console2.log( - "Deployed RiscZeroGroth16Verifier to", - address(verifier) - ); - } -} \ No newline at end of file diff --git a/examples/CRISP/packages/crisp-contracts/deploy/crisp.ts b/examples/CRISP/packages/crisp-contracts/deploy/crisp.ts index 70abf54fa9..7806ca0d7f 100644 --- a/examples/CRISP/packages/crisp-contracts/deploy/crisp.ts +++ b/examples/CRISP/packages/crisp-contracts/deploy/crisp.ts @@ -107,40 +107,17 @@ export const deployVerifier = async (useMockVerifier: boolean): Promise return existingVerifier.address; } - // use forge to deploy while we work on a way to have hardhat deploy from git submodules artifacts - // Deploy using Foundry - const rpcUrl = chain === "default" || "localhost" ? "http://localhost:8545" : process.env.RPC_URL!; - try { - // Run forge script - const command = `forge script deploy/Deploy.s.sol --rpc-url ${rpcUrl} --broadcast`; - - const output = execSync(command, { - encoding: "utf-8", - env: { - ...process.env, - }, - }); - - // Parse the output to get the deployed address - // Looking for: "Deployed RiscZeroGroth16Verifier to 0x..." - const match = output.match(/Deployed RiscZeroGroth16Verifier to (0x[a-fA-F0-9]{40})/); - - if (!match) { - console.error("Forge output:", output); - throw new Error("Could not parse deployed address from forge output"); - } - - const address = match[1]; - - storeDeploymentArgs({ - address, - }, "RiscZeroGroth16Verifier", chain); - - return address; - } catch (error) { - console.error("Failed to deploy with Foundry:", error); - throw error; - } + const verifierFactory = await ethers.getContractFactory("RiscZeroGroth16Verifier"); + const verifier = await verifierFactory.deploy(); + await verifier.waitForDeployment(); + + const address = await verifier.getAddress(); + + storeDeploymentArgs({ + address, + }, "RiscZeroGroth16Verifier", chain); + + return address; } // Check if mock verifier already deployed diff --git a/examples/CRISP/packages/crisp-contracts/foundry.toml b/examples/CRISP/packages/crisp-contracts/foundry.toml deleted file mode 100644 index 63157ebc5a..0000000000 --- a/examples/CRISP/packages/crisp-contracts/foundry.toml +++ /dev/null @@ -1,12 +0,0 @@ -[profile.default] -src = "contracts" -out = "out" -libs = ["lib"] -test = "tests" -ffi = true -fs_permissions = [{ access = "read-write", path = "./"}] -via_ir = false -optimizer = true -optimizer-runs = 10_000_000 - -# See more config options https://github.com/foundry-rs/foundry/tree/master/config \ No newline at end of file diff --git a/examples/CRISP/packages/crisp-contracts/remappings.txt b/examples/CRISP/packages/crisp-contracts/remappings.txt index 37cecc90f0..7b1a592736 100644 --- a/examples/CRISP/packages/crisp-contracts/remappings.txt +++ b/examples/CRISP/packages/crisp-contracts/remappings.txt @@ -1,9 +1,7 @@ forge-std/=lib/risc0-ethereum/lib/forge-std/src/ risc0/=lib/risc0-ethereum/contracts/src/ @enclave-e3/contracts/=node_modules/@enclave-e3/contracts/ -@excubiae/contracts/=node_modules/@excubiae/contracts/ solady/=node_modules/solady/ @zk-kit/lean-imt.sol=node_modules/@zk-kit/lean-imt.sol poseidon-solidity/=node_modules/poseidon-solidity/ -@openzeppelin/=lib/risc0-ethereum/lib/openzeppelin-contracts/ -openzeppelin/=lib/risc0-ethereum/lib/openzeppelin-contracts/ \ No newline at end of file +@openzeppelin/=node_modules/@openzeppelin/ \ No newline at end of file diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b0244a48f4..87e2c8f851 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -478,7 +478,7 @@ importers: version: 3.0.4(bufferutil@4.0.9)(utf-8-validate@5.0.10) hardhat-gas-reporter: specifier: ^2.2.0 - version: 2.3.0(bufferutil@4.0.9)(hardhat@3.0.4(bufferutil@4.0.9)(utf-8-validate@5.0.10))(typescript@5.8.3)(utf-8-validate@5.0.10) + version: 2.3.0(bufferutil@4.0.9)(hardhat@3.0.4(bufferutil@4.0.9)(utf-8-validate@5.0.10))(typescript@5.8.3)(utf-8-validate@5.0.10)(zod@3.25.76) lodash: specifier: ^4.17.21 version: 4.17.21 @@ -16399,7 +16399,7 @@ snapshots: - debug - utf-8-validate - hardhat-gas-reporter@2.3.0(bufferutil@4.0.9)(hardhat@3.0.4(bufferutil@4.0.9)(utf-8-validate@5.0.10))(typescript@5.8.3)(utf-8-validate@5.0.10): + hardhat-gas-reporter@2.3.0(bufferutil@4.0.9)(hardhat@3.0.4(bufferutil@4.0.9)(utf-8-validate@5.0.10))(typescript@5.8.3)(utf-8-validate@5.0.10)(zod@3.25.76): dependencies: '@ethersproject/abi': 5.8.0 '@ethersproject/bytes': 5.8.0 @@ -16416,7 +16416,7 @@ snapshots: lodash: 4.17.21 markdown-table: 2.0.0 sha1: 1.1.1 - viem: 2.30.6(bufferutil@4.0.9)(typescript@5.8.3)(utf-8-validate@5.0.10) + viem: 2.30.6(bufferutil@4.0.9)(typescript@5.8.3)(utf-8-validate@5.0.10)(zod@3.25.76) transitivePeerDependencies: - bufferutil - debug