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

DevEx/CI improvements #30

Merged
merged 16 commits into from
Jan 17, 2024
19 changes: 3 additions & 16 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,22 +48,9 @@ jobs:
with:
node-version: 18.x

- 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
# run: |
# export PROVIDER_URI_GOERLI=${{ secrets.PROVIDER_URI_GOERLI }}
# ANVIL_PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
# export PRIVATE_KEY=$ANVIL_PRIVATE_KEY # just needs to be in the correct format, no tx is sent in unit tests
# export PRIVATE_KEY_GOERLI=$ANVIL_PRIVATE_KEY
# npm run test test/unit/goerli.test.ts
- name: Set all packages to local and build
working-directory: ./
run: npm run local ci

- name: Run Integration Tests (Sepolia)
working-directory: ./harness
Expand Down
File renamed without changes.
9 changes: 4 additions & 5 deletions circuit/js/package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"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.",
"main": "js/index.js",
"browser": "web/index.js",
"types": "web/index.d.ts",
"scripts": {
"build": "rm -rf ./dist/* && tsc && ts-node scripts/postTsc.js && $npm_execpath run build:docs",
"build": "rm -rf ./dist/* && tsc && tsx scripts/postTsc.js && $npm_execpath run build:docs",
"build:docs": "./scripts/buildDocs.sh",
"test": "jest"
},
Expand All @@ -24,10 +24,9 @@
"crypto"
],
"dependencies": {
"@axiom-crypto/core": "2.3.0-rc2.2",
"@axiom-crypto/core": "2.3.0-rc2.3",
"@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/tools": "2.0.0",
"commander": "^11.1.0",
"ethers": "^6.8.1",
"viem": "^1.19.9"
Expand Down
40 changes: 16 additions & 24 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;
};
};
3 changes: 3 additions & 0 deletions client/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# @axiom-crypto/client

Main developer interface for developers who are writing node.js scripts to interact with Axiom.
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": "0.2.2-rc2.2",
"@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.

1 change: 0 additions & 1 deletion client/readme.md

This file was deleted.

2 changes: 1 addition & 1 deletion client/scripts/postTsc.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function copyPackageJson() {
}

function copyReadme() {
fs.copyFileSync("./readme.md", "./dist/readme.md");
fs.copyFileSync("./README.md", "./dist/README.md");
}

function copyTemplates() {
Expand Down
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";
Loading
Loading