diff --git a/.github/workflows/circuits_profile.yaml b/.github/workflows/circuits_profile.yaml new file mode 100644 index 000000000..dd7510d0a --- /dev/null +++ b/.github/workflows/circuits_profile.yaml @@ -0,0 +1,27 @@ +name: circuit profiling + +on: [push] + +jobs: + test: + name: nargo info + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install Nargo + uses: noir-lang/noirup@v0.1.3 + with: + toolchain: nightly-2024-01-11 # Pin at 0.23.0 when it's released. We need nightly now as 0.22.0 doesn't have the oracles + + - name: Run nargo info + run: nargo info --workspace --silence-warnings | tee profiling_info.txt + + - name: Archive profiling artifacts + uses: actions/upload-artifact@v4 + with: + name: profiling_info + path: | + profiling_info.txt diff --git a/.github/workflows/circuit_test.yaml b/.github/workflows/circuits_test.yaml similarity index 87% rename from .github/workflows/circuit_test.yaml rename to .github/workflows/circuits_test.yaml index b334b41ad..6224f0a09 100644 --- a/.github/workflows/circuit_test.yaml +++ b/.github/workflows/circuits_test.yaml @@ -15,7 +15,6 @@ jobs: uses: noir-lang/noirup@v0.1.3 with: toolchain: nightly-2024-01-11 # Pin at 0.23.0 when it's released. We need nightly now as 0.22.0 doesn't have the oracles + - name: Run nargo test - run: | - cd circuit - nargo test + run: nargo test --workspace diff --git a/.github/workflows/contract_test.yml b/.github/workflows/contract_test.yml index effd039a3..9a8b4f157 100644 --- a/.github/workflows/contract_test.yml +++ b/.github/workflows/contract_test.yml @@ -28,9 +28,7 @@ jobs: toolchain: nightly-2024-01-11 # Pin at 0.23.0 when it's released. We need nightly now as 0.22.0 doesn't have the oracles - name: Run nargo codegen-verifier - run: | - cd circuit - nargo codegen-verifier + run: nargo codegen-verifier --package main - name: Run Forge build run: | diff --git a/.github/workflows/ts_lint.yaml b/.github/workflows/ts_lint.yaml index 856c9047e..48d4ac802 100644 --- a/.github/workflows/ts_lint.yaml +++ b/.github/workflows/ts_lint.yaml @@ -33,10 +33,10 @@ jobs: # We don't store circuit compilation artefacts in the repo, # but typecheck fails on import without them so we just create a fake file here - name: Create fake circuit compilation artefacts - working-directory: circuit + working-directory: . run: | mkdir target - touch target/noir_ethereum_history_api.json + touch target/main.json - name: Run TypeScript Typecheck run: yarn typecheck diff --git a/.github/workflows/ts_test.yaml b/.github/workflows/ts_test.yaml index 45b327b56..df45f8b94 100644 --- a/.github/workflows/ts_test.yaml +++ b/.github/workflows/ts_test.yaml @@ -39,16 +39,14 @@ jobs: toolchain: nightly-2024-01-11 # Pin at 0.23.0 when it's released. We need nightly now as 0.22.0 doesn't have the oracles - name: Compile Circuit - run: nargo compile - working-directory: circuit + run: nargo compile --package main - name: Start Oracle Server run: | yarn oracle-server & - name: Generate Proof - run: nargo prove --oracle-resolver=http://localhost:5555 - working-directory: circuit + run: nargo prove --package main --oracle-resolver=http://localhost:5555 - name: Run e2e Tests run: yarn test:e2e diff --git a/.gitignore b/.gitignore index 3c3629e64..b02bbfd09 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,4 @@ node_modules +target +proofs +contract \ No newline at end of file diff --git a/.yarn/install-state.gz b/.yarn/install-state.gz index 5ea939063..4e00ce312 100644 Binary files a/.yarn/install-state.gz and b/.yarn/install-state.gz differ diff --git a/Nargo.toml b/Nargo.toml new file mode 100644 index 000000000..8fec931ce --- /dev/null +++ b/Nargo.toml @@ -0,0 +1,5 @@ +[workspace] +members = [ + "circuits/main" +] +default-member = "circuits/main" \ No newline at end of file diff --git a/circuit/.gitignore b/circuits/main/.gitignore similarity index 100% rename from circuit/.gitignore rename to circuits/main/.gitignore diff --git a/circuit/Nargo.toml b/circuits/main/Nargo.toml similarity index 86% rename from circuit/Nargo.toml rename to circuits/main/Nargo.toml index 41ffac18b..218e59b59 100644 --- a/circuit/Nargo.toml +++ b/circuits/main/Nargo.toml @@ -1,5 +1,5 @@ [package] -name = "noir_ethereum_history_api" +name = "main" type = "bin" authors = ["Arkadiusz Konior, Marek Kirejczyk"] compiler_version = "0.22.0" diff --git a/circuit/Prover.toml b/circuits/main/Prover.toml similarity index 100% rename from circuit/Prover.toml rename to circuits/main/Prover.toml diff --git a/circuit/README.md b/circuits/main/README.md similarity index 100% rename from circuit/README.md rename to circuits/main/README.md diff --git a/circuit/Verifier.toml b/circuits/main/Verifier.toml similarity index 100% rename from circuit/Verifier.toml rename to circuits/main/Verifier.toml diff --git a/circuit/src/arrays.nr b/circuits/main/src/arrays.nr similarity index 100% rename from circuit/src/arrays.nr rename to circuits/main/src/arrays.nr diff --git a/circuit/src/get_account.nr b/circuits/main/src/get_account.nr similarity index 100% rename from circuit/src/get_account.nr rename to circuits/main/src/get_account.nr diff --git a/circuit/src/get_header.nr b/circuits/main/src/get_header.nr similarity index 100% rename from circuit/src/get_header.nr rename to circuits/main/src/get_header.nr diff --git a/circuit/src/main.nr b/circuits/main/src/main.nr similarity index 100% rename from circuit/src/main.nr rename to circuits/main/src/main.nr diff --git a/contracts/src/generated-verifier/UltraVerifier.sol b/contracts/src/generated-verifier/UltraVerifier.sol index 3225826da..4e29b08aa 120000 --- a/contracts/src/generated-verifier/UltraVerifier.sol +++ b/contracts/src/generated-verifier/UltraVerifier.sol @@ -1 +1 @@ -../../../circuit/contract/noir_ethereum_history_api/plonk_vk.sol \ No newline at end of file +../../../contract/main/plonk_vk.sol \ No newline at end of file diff --git a/packages/noir-ethereum-api/src/main.ts b/packages/noir-ethereum-api/src/main.ts index 446b1d01a..82dfae9fc 100644 --- a/packages/noir-ethereum-api/src/main.ts +++ b/packages/noir-ethereum-api/src/main.ts @@ -2,12 +2,15 @@ import { BarretenbergBackend, ProofData, type CompiledCircuit } from '@noir-lang import { Noir, WitnessMap } from '@noir-lang/noir_js'; import { promises as fs } from 'fs'; import toml from 'toml'; -import noir_ethereum_history_api from '../../../circuit/target/noir_ethereum_history_api.json'; +import os from 'os'; +import noir_ethereum_history_api from '../../../target/main.json'; import { type Oracles, defaultOracles } from './noir/oracles/oracles.js'; import { decodeHexString, encodeHexString } from './noir/noir_js/encode.js'; import { abiEncode, type InputMap } from '@noir-lang/noirc_abi'; export const circuit = noir_ethereum_history_api as unknown as CompiledCircuit; +const backend = new BarretenbergBackend(circuit, { threads: os.cpus().length }); +const noir = new Noir(circuit, backend); export interface MainInputs extends InputMap { block_no: number; @@ -21,8 +24,6 @@ export async function recordStorageProof( oracles: Oracles = defaultOracles, name: string ): Promise { - const backend = new BarretenbergBackend(circuit); - const noir = new Noir(circuit, backend); const proof = await noir.generateFinalProof(input, oracles); const proofHex = decodeHexString(proof.proof); @@ -36,8 +37,6 @@ export async function recordStorageProof( } export async function verifyStorageProof(proof: ProofData): Promise { - const backend = new BarretenbergBackend(circuit); - const noir = new Noir(circuit, backend); return await noir.verifyFinalProof(proof); } diff --git a/packages/noir-ethereum-api/test/e2e.test.ts b/packages/noir-ethereum-api/test/e2e.test.ts index 2216ea1a9..c1d4fa86c 100644 --- a/packages/noir-ethereum-api/test/e2e.test.ts +++ b/packages/noir-ethereum-api/test/e2e.test.ts @@ -4,8 +4,8 @@ import { verifyStorageProof, readProof, readWitnessMap, readInputMap, circuit } import { updateNestedField } from '../src/util/object.js'; import { InputMap, WitnessMap, abiEncode } from '@noir-lang/noirc_abi'; -const PROOF_PATH = '../../circuit/proofs/noir_ethereum_history_api.proof'; -const INPUT_MAP_PATH = '../../circuit/Verifier.toml'; +const PROOF_PATH = '../../proofs/main.proof'; +const INPUT_MAP_PATH = '../../circuits/main/Verifier.toml'; describe.concurrent( 'e2e',