-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #994 from o1-labs/feature/revive-snarkyjs-ci
Blocking SnarkyJS CI tests (main)
- Loading branch information
Showing
12 changed files
with
322 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ tests/report/ | |
tests/test-artifacts/ | ||
profiling.md | ||
snarkyjs-reference | ||
*.tmp.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
./run src/tests/inductive-proofs-small.ts --bundle |
Submodule bindings
updated
from fe3b5e to e32513
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// copy compiled jsoo/wasm artifacts from a folder in the source tree to the folder where they are imported from | ||
// (these are not the same folders so that we don't automatically pollute the source tree when rebuilding artifacts) | ||
import { copyFromTo } from './utils.js'; | ||
|
||
await copyFromTo( | ||
['src/bindings/compiled/node_bindings/'], | ||
'node_bindings', | ||
'_node_bindings' | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// copy some files from /src to /dist/node that tsc doesn't copy because we have .d.ts files for them | ||
import { copyFromTo } from './utils.js'; | ||
|
||
await copyFromTo( | ||
['src/snarky.d.ts', 'src/bindings/compiled/_node_bindings'], | ||
'src/', | ||
'dist/node/' | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import fse from 'fs-extra'; | ||
|
||
export { copyFromTo }; | ||
|
||
function copyFromTo(files, srcDir = undefined, targetDir = undefined) { | ||
return Promise.all( | ||
files.map((source) => { | ||
let target = source.replace(srcDir, targetDir); | ||
return fse.copy(source, target, { | ||
recursive: true, | ||
overwrite: true, | ||
dereference: true, | ||
}); | ||
}) | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import { | ||
SelfProof, | ||
Field, | ||
Experimental, | ||
isReady, | ||
shutdown, | ||
Proof, | ||
} from '../index.js'; | ||
import { tic, toc } from '../examples/zkapps/tictoc.js'; | ||
|
||
await isReady; | ||
|
||
let MaxProofsVerifiedOne = Experimental.ZkProgram({ | ||
publicInput: Field, | ||
|
||
methods: { | ||
baseCase: { | ||
privateInputs: [], | ||
|
||
method(publicInput: Field) { | ||
publicInput.assertEquals(Field(0)); | ||
}, | ||
}, | ||
|
||
mergeOne: { | ||
privateInputs: [SelfProof], | ||
|
||
method(publicInput: Field, earlierProof: SelfProof<Field, undefined>) { | ||
earlierProof.verify(); | ||
earlierProof.publicInput.add(1).assertEquals(publicInput); | ||
}, | ||
}, | ||
}, | ||
}); | ||
|
||
tic('compiling program'); | ||
await MaxProofsVerifiedOne.compile(); | ||
toc(); | ||
|
||
await testRecursion(MaxProofsVerifiedOne, 1); | ||
|
||
async function testRecursion( | ||
Program: typeof MaxProofsVerifiedOne, | ||
maxProofsVerified: number | ||
) { | ||
console.log(`testing maxProofsVerified = ${maxProofsVerified}`); | ||
|
||
let ProofClass = Experimental.ZkProgram.Proof(Program); | ||
|
||
tic('executing base case'); | ||
let initialProof = await Program.baseCase(Field(0)); | ||
toc(); | ||
initialProof = testJsonRoundtrip(ProofClass, initialProof); | ||
initialProof.verify(); | ||
initialProof.publicInput.assertEquals(Field(0)); | ||
|
||
if (initialProof.maxProofsVerified != maxProofsVerified) { | ||
throw Error( | ||
`Expected initialProof to have maxProofsVerified = ${maxProofsVerified} but has ${initialProof.maxProofsVerified}` | ||
); | ||
} | ||
|
||
let p1; | ||
if (initialProof.maxProofsVerified === 0) return; | ||
|
||
tic('executing mergeOne'); | ||
p1 = await Program.mergeOne(Field(1), initialProof); | ||
toc(); | ||
p1 = testJsonRoundtrip(ProofClass, p1); | ||
p1.verify(); | ||
p1.publicInput.assertEquals(Field(1)); | ||
if (p1.maxProofsVerified != maxProofsVerified) { | ||
throw Error( | ||
`Expected p1 to have maxProofsVerified = ${maxProofsVerified} but has ${p1.maxProofsVerified}` | ||
); | ||
} | ||
} | ||
|
||
function testJsonRoundtrip(ProofClass: any, proof: Proof<Field, void>) { | ||
let jsonProof = proof.toJSON(); | ||
console.log( | ||
'json roundtrip', | ||
JSON.stringify({ ...jsonProof, proof: jsonProof.proof.slice(0, 10) + '..' }) | ||
); | ||
return ProofClass.fromJSON(jsonProof); | ||
} | ||
|
||
shutdown(); |
Oops, something went wrong.