Skip to content

Commit

Permalink
Merge pull request #1266 from o1-labs/fix/lookup-tables
Browse files Browse the repository at this point in the history
Fix lookup tables
  • Loading branch information
mitschabaude authored Nov 27, 2023
2 parents b96bb13 + cbe6131 commit 61e164d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/bindings
14 changes: 12 additions & 2 deletions src/lib/proof_system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,10 @@ function ZkProgram<
}
): {
name: string;
compile: (options?: { cache: Cache }) => Promise<{ verificationKey: string }>;
compile: (options?: {
cache?: Cache;
forceRecompile?: boolean;
}) => Promise<{ verificationKey: string }>;
verify: (
proof: Proof<
InferProvableOrUndefined<Get<StatementType, 'publicInput'>>,
Expand Down Expand Up @@ -338,7 +341,10 @@ function ZkProgram<
}
| undefined;

async function compile({ cache = Cache.FileSystemDefault } = {}) {
async function compile({
cache = Cache.FileSystemDefault,
forceRecompile = false,
} = {}) {
let methodsMeta = methodIntfs.map((methodEntry, i) =>
analyzeMethod(publicInputType, methodEntry, methodFunctions[i])
);
Expand All @@ -351,6 +357,7 @@ function ZkProgram<
gates,
proofSystemTag: selfTag,
cache,
forceRecompile,
overrideWrapDomain: config.overrideWrapDomain,
});
compileOutput = { provers, verify };
Expand Down Expand Up @@ -603,6 +610,7 @@ async function compileProgram({
gates,
proofSystemTag,
cache,
forceRecompile,
overrideWrapDomain,
}: {
publicInputType: ProvablePure<any>;
Expand All @@ -612,6 +620,7 @@ async function compileProgram({
gates: Gate[][];
proofSystemTag: { name: string };
cache: Cache;
forceRecompile: boolean;
overrideWrapDomain?: 0 | 1 | 2;
}) {
let rules = methodIntfs.map((methodEntry, i) =>
Expand All @@ -630,6 +639,7 @@ async function compileProgram({
let picklesCache: Pickles.Cache = [
0,
function read_(mlHeader) {
if (forceRecompile) return MlResult.unitError();
let header = parseHeader(proofSystemTag.name, methodIntfs, mlHeader);
let result = readCache(cache, header, (bytes) =>
decodeProverKey(mlHeader, bytes)
Expand Down
6 changes: 5 additions & 1 deletion src/lib/zkapp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,10 @@ class SmartContract {
* it so that proofs end up in the original finite field). These are fairly expensive operations, so **expect compiling to take at least 20 seconds**,
* up to several minutes if your circuit is large or your hardware is not optimal for these operations.
*/
static async compile({ cache = Cache.FileSystemDefault } = {}) {
static async compile({
cache = Cache.FileSystemDefault,
forceRecompile = false,
} = {}) {
let methodIntfs = this._methods ?? [];
let methods = methodIntfs.map(({ methodName }) => {
return (
Expand Down Expand Up @@ -690,6 +693,7 @@ class SmartContract {
gates,
proofSystemTag: this,
cache,
forceRecompile,
});
let verificationKey = {
data: verificationKey_.data,
Expand Down

0 comments on commit 61e164d

Please sign in to comment.