Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various experience improvements #29

Closed
wants to merge 6 commits into from
Closed
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
16 changes: 10 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,17 @@ jobs:
with:
node-version: 18.x

- name: Build Client
working-directory: ./client
run: npm install && npm run build
- name: Set all packages to local and build
working-directory: ./
run: npm run local --ci

- name: Install Harness dependencies
working-directory: ./harness
run: npm install
# - name: Build Client
# working-directory: ./client
# run: npm install && npm run build

# - name: Install Harness dependencies
# working-directory: ./harness
# run: npm install

# - name: Run Integration Tests (Goerli)
# working-directory: ./harness
Expand Down
10 changes: 5 additions & 5 deletions circuit/js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@axiom-crypto/circuit",
"version": "0.2.2-rc2.1",
"version": "0.2.2-rc2.2",
"author": "Intrinsic Technologies",
"license": "MIT",
"description": "Client SDK to write custom queries for Axiom, the ZK Coprocessor for Ethereum.",
Expand All @@ -24,10 +24,10 @@
"crypto"
],
"dependencies": {
"@axiom-crypto/core": "2.3.0-rc2.2",
"@axiom-crypto/halo2-lib-js": "0.2.14-rc.0",
"@axiom-crypto/halo2-wasm": "0.2.11-rc.1",
"@axiom-crypto/tools": "0.3.36-rc2.1",
"@axiom-crypto/core": "2.3.0-rc2.3",
"@axiom-crypto/halo2-lib-js": "link:../../../halo2-browser/halo2-lib-js/dist",
"@axiom-crypto/halo2-wasm": "link:../../../halo2-browser/halo2-wasm/pkg",
"@axiom-crypto/tools": "0.3.36-rc2.3",
"commander": "^11.1.0",
"ethers": "^6.8.1",
"viem": "^1.19.9"
Expand Down
64 changes: 13 additions & 51 deletions circuit/js/pnpm-lock.yaml

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

11 changes: 2 additions & 9 deletions circuit/js/src/cliHandler/compile.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import path from 'path';
import { AxiomBaseCircuit } from "../js";
import { fileExists, getFunctionFromTs, getProvider, readJsonFromFile, saveJsonToFile } from "./utils";
import { fileExists, getFunctionFromTs, getProvider, readInputs, readJsonFromFile, saveJsonToFile } from "./utils";

export const compile = async (
circuitPath: string,
Expand Down Expand Up @@ -31,14 +31,7 @@ export const compile = async (
if (options.inputs !== undefined) {
inputFile = options.inputs;
}
let circuitInputs = f.inputs;
if (fileExists(inputFile)) {
circuitInputs = readJsonFromFile(inputFile);
} else {
if (circuitInputs === undefined) {
throw new Error("No inputs provided. Either export `inputs` from your circuit file or provide a path to a json file with inputs.");
}
}
const circuitInputs = readInputs(inputFile, f.inputs);
try {
const res = await circuit.compile(circuitInputs);
const circuitFn = `const ${f.importName} = AXIOM_CLIENT_IMPORT\n${f.circuit.toString()}`;
Expand Down
16 changes: 4 additions & 12 deletions circuit/js/src/cliHandler/prove.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import path from 'path';
import { AxiomBaseCircuit } from "../js";
import { fileExists, getFunctionFromTs, getProvider, readJsonFromFile, saveJsonToFile } from "./utils";
import { fileExists, getFunctionFromTs, getProvider, readInputs, readJsonFromFile, saveJsonToFile } from "./utils";

export const prove = async (
circuitPath: string,
Expand All @@ -25,6 +25,7 @@ export const prove = async (
if (options.compiled !== undefined) {
compiledFile = options.compiled;
}
console.log(`Reading compiled circuit JSON from: ${compiledFile}`);
const compiledJson = readJsonFromFile(compiledFile);
const circuit = new AxiomBaseCircuit({
f: f.circuit,
Expand All @@ -38,25 +39,16 @@ export const prove = async (
if (options.inputs !== undefined) {
inputFile = options.inputs;
}
let circuitInputs = f.inputs;
if (fileExists(inputFile)) {
circuitInputs = readJsonFromFile(inputFile);
} else {
if (circuitInputs === undefined) {
throw new Error("No inputs provided. Either export `inputs` from your circuit file or provide a path to a json file with inputs.");
}
}
const circuitInputs = readInputs(inputFile, f.inputs);
try {
circuit.loadSaved(compiledJson);
let computeQuery;
let computeResults;
if (options.mock === true) {
computeQuery = await circuit.mockProve(circuitInputs);
computeResults = circuit.getComputeResults();
} else {
computeQuery = await circuit.run(circuitInputs);
computeResults = circuit.getComputeResults();
}
const computeResults = circuit.getComputeResults();
const dataQuery = circuit.getDataQuery();
const res = {
sourceChainId: circuit.getChainId(),
Expand Down
13 changes: 13 additions & 0 deletions circuit/js/src/cliHandler/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,19 @@ export function getProvider(provider: string | undefined): string {
return providerToUse;
}

export function readInputs(inputFile: string, circuitInputs: any) {
if (fileExists(inputFile)) {
circuitInputs = readJsonFromFile(inputFile);
console.log(`Reading JSON inputs from: ${inputFile}`);
return circuitInputs
}
if (circuitInputs === undefined) {
throw new Error("No inputs provided. Either export `inputs` from your circuit file or provide a path to a json file with inputs.");
}
console.log(`Reading inputs from circuit file`);
return circuitInputs;
}

export function saveJsonToFile(json: any, filePath: string) {
const fullPath = path.resolve(filePath);
const filename = path.basename(fullPath);
Expand Down
2 changes: 1 addition & 1 deletion circuit/js/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ export interface AxiomV2CircuitMetadataParams {
numRlcColumns: number;
numFixed: number;
maxOutputs: number;
};
};
6 changes: 3 additions & 3 deletions client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@axiom-crypto/client",
"version": "0.2.2-rc2.1",
"version": "0.2.2-rc2.2",
"author": "Intrinsic Technologies",
"license": "MIT",
"description": "Client SDK to write custom queries for Axiom, the ZK Coprocessor for Ethereum.",
Expand All @@ -24,8 +24,8 @@
"crypto"
],
"dependencies": {
"@axiom-crypto/circuit": "0.2.2-rc2.1",
"@axiom-crypto/core": "2.3.0-rc2.2",
"@axiom-crypto/circuit": "link:../circuit/js/dist",
"@axiom-crypto/core": "2.3.0-rc2.3",
"chalk": "^4.1.2",
"commander": "^11.1.0",
"ethers": "^6.8.1",
Expand Down
74 changes: 9 additions & 65 deletions client/pnpm-lock.yaml

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

7 changes: 4 additions & 3 deletions client/src/cli/queryParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ export const queryParams = async (
if (options.proven !== undefined) {
provenFile = options.proven;
}
const outputsJson = readJsonFromFile(provenFile);
console.log(`Reading proven circuit JSON from: ${provenFile}`)
const provenJson = readJsonFromFile(provenFile);
const provider = getProvider(options.provider);
const axiom = new AxiomSdkCore({
providerUri: provider,
Expand All @@ -42,8 +43,8 @@ export const queryParams = async (
try {
let build = await buildSendQuery({
axiom,
dataQuery: outputsJson.dataQuery,
computeQuery: outputsJson.computeQuery,
dataQuery: provenJson.dataQuery,
computeQuery: provenJson.computeQuery,
callback: {
target: callbackTarget,
extraData: options.callbackExtraData ?? "0x",
Expand Down
1 change: 1 addition & 0 deletions client/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './axiom';
export * from "./sendQuery";
export * from "./types";
export * from "@axiom-crypto/circuit";
7 changes: 7 additions & 0 deletions client/src/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export {
AxiomV2Callback,
AxiomV2ComputeQuery,
AxiomV2DataQuery,
AxiomV2QueryOptions,
AxiomV2FeeData,
} from "@axiom-crypto/core";
Loading
Loading