mirror of
https://github.com/logos-storage/logos-storage-proofs-circuits.git
synced 2026-01-07 16:03:08 +00:00
solve the nodejs heap allocation issue (appears around 100 samples)
This commit is contained in:
parent
bd0a5e968c
commit
c03b43221d
@ -14,6 +14,29 @@ To run the full workflow:
|
|||||||
NOTE: the examples below assume `bash`. In particular, it won't work with `zsh`
|
NOTE: the examples below assume `bash`. In particular, it won't work with `zsh`
|
||||||
(which is the dafault on newer macOS)! Because, you know, reasons...
|
(which is the dafault on newer macOS)! Because, you know, reasons...
|
||||||
|
|
||||||
|
### Some measurements
|
||||||
|
|
||||||
|
Approximate time to run this on an M2 (8+4 cores), with 10 samples:
|
||||||
|
|
||||||
|
- compiling the circuit: 8 seconds
|
||||||
|
- circuit-specific setup (with 1 contributor): 85 seconds
|
||||||
|
- size of the `.zkey` file (only 1 contributor): 110 megabytes
|
||||||
|
- proving with `snarkjs` (slow): 7.7 seconds
|
||||||
|
|
||||||
|
Same with 50 samples:
|
||||||
|
|
||||||
|
- compiling: 37 seconds
|
||||||
|
- circuit-specific setup: ~420 seconds
|
||||||
|
- `.zkey` file: 525 megabytes
|
||||||
|
- snarkjs prove: 34 seconds
|
||||||
|
|
||||||
|
And with 100 samples:
|
||||||
|
- compiling: 76 seconds
|
||||||
|
- circuit-specific setup: ~1000 seconds
|
||||||
|
- `.zkey` file
|
||||||
|
- snarkjs prove: 76 seconds
|
||||||
|
|
||||||
|
|
||||||
### Preliminaries
|
### Preliminaries
|
||||||
|
|
||||||
- install `circom`, `snarkjs`, `rapidsnark`: <https://docs.circom.io/getting-started/installation>
|
- install `circom`, `snarkjs`, `rapidsnark`: <https://docs.circom.io/getting-started/installation>
|
||||||
@ -71,6 +94,11 @@ the whole process.
|
|||||||
$ snarkjs groth16 setup proof_main.r1cs ../../ceremony/powersOfTau28_hez_final_21.ptau proof_main_0000.zkey
|
$ snarkjs groth16 setup proof_main.r1cs ../../ceremony/powersOfTau28_hez_final_21.ptau proof_main_0000.zkey
|
||||||
$ snarkjs zkey contribute proof_main_0000.zkey proof_main_0001.zkey --name="1st Contributor Name"
|
$ snarkjs zkey contribute proof_main_0000.zkey proof_main_0001.zkey --name="1st Contributor Name"
|
||||||
|
|
||||||
|
NOTE: with large circuits, javascript can run out of heap. You can increase the
|
||||||
|
heap limit with:
|
||||||
|
|
||||||
|
$ NODE_OPTIONS="--max-old-space-size=8192" snarkjs groth16 setup <...>
|
||||||
|
|
||||||
You can add more contributors here if you want.
|
You can add more contributors here if you want.
|
||||||
|
|
||||||
Finally rename the last contributions result and export the verification key:
|
Finally rename the last contributions result and export the verification key:
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
MAXDEPTH=16 # maximum depth of the slot tree
|
MAXDEPTH=32 # maximum depth of the slot tree
|
||||||
MAXSLOTS=256 # maximum number of slots
|
MAXSLOTS=256 # maximum number of slots
|
||||||
CELLSIZE=2048 # cell size in bytes
|
CELLSIZE=2048 # cell size in bytes
|
||||||
BLOCKSIZE=65536 # block size in bytes
|
BLOCKSIZE=65536 # block size in bytes
|
||||||
|
|||||||
@ -14,19 +14,23 @@ ${NIMCLI_DIR}/cli $CLI_ARGS -v --circom=${CIRCUIT_MAIN}.circom
|
|||||||
|
|
||||||
# --- compile the circuit ---
|
# --- compile the circuit ---
|
||||||
|
|
||||||
circom --r1cs --wasm --O2 -l${CIRCUIT_DIR} ${CIRCUIT_MAIN}.circom
|
time circom --r1cs --wasm --O2 -l${CIRCUIT_DIR} ${CIRCUIT_MAIN}.circom
|
||||||
|
|
||||||
# --- circuit specific setup ---
|
# --- circuit specific setup ---
|
||||||
|
|
||||||
snarkjs groth16 setup ${CIRCUIT_MAIN}.r1cs $PTAU_PATH ${CIRCUIT_MAIN}_0000.zkey
|
start=`date +%s`
|
||||||
|
|
||||||
|
NODE_OPTIONS="--max-old-space-size=8192" snarkjs groth16 setup ${CIRCUIT_MAIN}.r1cs $PTAU_PATH ${CIRCUIT_MAIN}_0000.zkey
|
||||||
echo "some_entropy_75289v3b7rcawcsyiur" | \
|
echo "some_entropy_75289v3b7rcawcsyiur" | \
|
||||||
snarkjs zkey contribute ${CIRCUIT_MAIN}_0000.zkey ${CIRCUIT_MAIN}_0001.zkey --name="1st Contributor Name"
|
NODE_OPTIONS="--max-old-space-size=8192" snarkjs zkey contribute ${CIRCUIT_MAIN}_0000.zkey ${CIRCUIT_MAIN}_0001.zkey --name="1st Contributor Name"
|
||||||
|
|
||||||
rm ${CIRCUIT_MAIN}_0000.zkey
|
rm ${CIRCUIT_MAIN}_0000.zkey
|
||||||
mv ${CIRCUIT_MAIN}_0001.zkey ${CIRCUIT_MAIN}.zkey
|
mv ${CIRCUIT_MAIN}_0001.zkey ${CIRCUIT_MAIN}.zkey
|
||||||
snarkjs zkey export verificationkey ${CIRCUIT_MAIN}.zkey ${CIRCUIT_MAIN}_verification_key.json
|
snarkjs zkey export verificationkey ${CIRCUIT_MAIN}.zkey ${CIRCUIT_MAIN}_verification_key.json
|
||||||
|
|
||||||
|
end=`date +%s`
|
||||||
|
echo "The circuit specific setup took `expr $end - $start` seconds."
|
||||||
|
|
||||||
# --- finish the setup ---
|
# --- finish the setup ---
|
||||||
|
|
||||||
cd $ORIG
|
cd $ORIG
|
||||||
Loading…
x
Reference in New Issue
Block a user