Skip to content

Commit d129e28

Browse files
committed
Merge branch 'shigoto/performance-regression-framework' into shigoto/performance-regression-migrate-tests
2 parents 89e8367 + f58e53f commit d129e28

File tree

12 files changed

+295
-208
lines changed

12 files changed

+295
-208
lines changed

CHANGELOG.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ This project adheres to
2020

2121
### Added
2222

23-
- Added a new internal framework for testing proving and compilation time
24-
regression. https://github.com/o1-labs/o1js/pull/2451
2523
- Internal o1js and protocol constants, hashes and prefixes are now exported via
2624
the `Core´ namespace. https://github.com/o1-labs/o1js/pull/2421
2725
- Support for string type input to `Transaction.fromJSON`

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
"e2e:run-server": "node dist/web/server.js",
8484
"e2e:install": "npx playwright install --with-deps",
8585
"e2e:show-report": "npx playwright show-report tests/report",
86-
"update-changelog": "./update-changelog.sh",
86+
"update-changelog": "./scripts/changelog/update-changelog.sh",
8787
"prepare": "husky"
8888
},
8989
"author": "O(1) Labs",
Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
# Ensure that you have the necessary permissions to commit and push changes to the repository.
2020

2121
# Step 1: Capture the latest version
22-
latest_version=$(grep -oP '\[\K[0-9]+\.[0-9]+\.[0-9]+(?=\])' CHANGELOG.md | head -1)
22+
latest_version=$(grep -o '\[\K[0-9]+\.[0-9]+\.[0-9]+(?=\])' CHANGELOG.md | head -1)
2323
echo "Latest version: $latest_version"
2424

2525
# Step 2: Bump the patch version
@@ -37,11 +37,17 @@ current_date=$(date +%Y-%m-%d)
3737
echo "Current date: $current_date"
3838

3939
# Step 5: Extract the second SHA from the compare URL of the latest version
40-
previous_commit=$(grep -m 1 -oP '\[.*?\]\(https://github.com/o1-labs/o1js/compare/[a-f0-9]+\.\.\.\K[a-f0-9]+(?=\))' CHANGELOG.md)
40+
previous_commit=$(grep -m 1 -o '\[.*?\]\(https://github.com/o1-labs/o1js/compare/[a-f0-9]+\.\.\.\K[a-f0-9]+(?=\))' CHANGELOG.md)
4141
echo "Previous commit: $previous_commit"
4242

4343
# Step 6: Update the CHANGELOG
4444
sed -i "s/\[Unreleased\](.*\.\.\.HEAD)/\[Unreleased\](https:\/\/github.com\/o1-labs\/o1js\/compare\/$current_commit...HEAD)\n\n## \[$new_version\](https:\/\/github.com\/o1-labs\/o1js\/compare\/$previous_commit...$current_commit) - $current_date/" CHANGELOG.md
4545

46-
# Step 7: Auto-fix compare URLs for all past versions
47-
node fix-changelog-links.cjs
46+
# Step 7: Auto-fix compare URLs for all past versions, if -r is set
47+
while getopts "r" opt; do
48+
case $opt in
49+
r)
50+
node scripts/changelog/fix-changelog-links.cjs
51+
;;
52+
esac
53+
done

src/examples/crypto/blake2b/run.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
import { Bytes12, BLAKE2BProgram } from './blake2b.js';
2-
import { perfStart, perfEnd } from '../../../lib/testing/perf-regression.js';
2+
import { Performance } from '../../../lib/testing/perf-regression.js';
33

44
const cs = await BLAKE2BProgram.analyzeMethods();
5-
perfStart('compile', BLAKE2BProgram.name, cs);
5+
const perfBlake2b = Performance.create(BLAKE2BProgram.name, cs);
6+
perfBlake2b.start('compile');
67
await BLAKE2BProgram.compile();
7-
perfEnd();
8+
perfBlake2b.end();
89

910
let preimage = Bytes12.fromString('hello world!');
1011

1112
console.log('blake2b rows:', (await BLAKE2BProgram.analyzeMethods()).blake2b.rows);
1213

13-
perfStart('prove', BLAKE2BProgram.name, cs, 'blake2b');
14+
perfBlake2b.start('prove', 'blake2b');
1415
let { proof } = await BLAKE2BProgram.blake2b(preimage);
15-
perfEnd();
16+
perfBlake2b.end();
1617

1718
let isValid = await BLAKE2BProgram.verify(proof);
1819

src/examples/crypto/ecdsa/run.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Secp256k1, Ecdsa, keccakAndEcdsa, ecdsa, ecdsaEthers, Bytes32 } from './ecdsa.js';
22
import assert from 'assert';
3-
import { perfStart, perfEnd } from '../../../lib/testing/perf-regression.js';
3+
import { Performance } from '../../../lib/testing/perf-regression.js';
4+
45
// create an example ecdsa signature
56

67
let privateKey = Secp256k1.Scalar.random();
@@ -24,13 +25,14 @@ console.log(cs.verifyEcdsa.summary());
2425

2526
// compile and prove
2627

27-
perfStart('compile', keccakAndEcdsa.name, cs);
28+
const perfKeccakEcdsa = Performance.create(keccakAndEcdsa.name, cs);
29+
perfKeccakEcdsa.start('compile');
2830
await keccakAndEcdsa.compile();
29-
perfEnd();
31+
perfKeccakEcdsa.end();
3032

31-
perfStart('prove', keccakAndEcdsa.name, cs, 'verifyEcdsa');
33+
perfKeccakEcdsa.start('prove', 'verifyEcdsa');
3234
let { proof } = await keccakAndEcdsa.verifyEcdsa(message, signature, publicKey);
33-
perfEnd();
35+
perfKeccakEcdsa.end();
3436

3537
proof.publicOutput.assertTrue('signature verifies');
3638
assert(await keccakAndEcdsa.verify(proof), 'proof verifies');
@@ -62,13 +64,14 @@ console.timeEnd('ethers verify only (build constraint system)');
6264
console.log(csEcdsaEthers.verifyEthers.summary());
6365

6466
// compile and prove
65-
perfStart('compile', ecdsaEthers.name, csEcdsaEthers);
67+
const perfEcdsaEthers = Performance.create(ecdsaEthers.name, csEcdsaEthers);
68+
perfEcdsaEthers.start('compile');
6669
await ecdsaEthers.compile();
67-
perfEnd();
70+
perfEcdsaEthers.end();
6871

69-
perfStart('prove', ecdsaEthers.name, csEcdsaEthers, 'verifyEthers');
72+
perfEcdsaEthers.start('prove', 'verifyEthers');
7073
let { proof: proofE } = await ecdsaEthers.verifyEthers(msgBytes, signatureE, publicKeyE);
71-
perfEnd();
74+
perfEcdsaEthers.end();
7275

7376
proofE.publicOutput.assertTrue('signature verifies');
7477
assert(await ecdsaEthers.verify(proofE), 'proof verifies');

src/examples/crypto/rsa/run.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { ZkProgram } from 'o1js';
22
import { Bigint2048, rsaVerify65537 } from './rsa.js';
33
import { sha256Bigint, generateRsaParams, rsaSign } from './utils.js';
4-
import { perfStart, perfEnd } from '../../../lib/testing/perf-regression.js';
4+
import { Performance } from '../../../lib/testing/perf-regression.js';
55

66
let rsaZkProgram = ZkProgram({
77
name: 'rsa-verify',
@@ -23,9 +23,11 @@ console.log(cs.verifyRsa65537.summary());
2323

2424
const forceRecompileEnabled = false;
2525

26-
perfStart('compile', rsaZkProgram.name);
26+
const perfRsa = Performance.create(rsaZkProgram.name, cs);
27+
28+
perfRsa.start('compile');
2729
await rsaZkProgram.compile({ forceRecompile: forceRecompileEnabled });
28-
perfEnd();
30+
perfRsa.end();
2931

3032
console.time('generate RSA parameters and inputs (2048 bits)');
3133
const input = await sha256Bigint('How are you!');
@@ -35,9 +37,9 @@ const signature = Bigint2048.from(rsaSign(input, params.d, params.n));
3537
const modulus = Bigint2048.from(params.n);
3638
console.timeEnd('generate RSA parameters and inputs (2048 bits)');
3739

38-
perfStart('prove', rsaZkProgram.name, cs, 'verifyRsa65537');
40+
perfRsa.start('prove', 'verifyRsa65537');
3941
let { proof } = await rsaZkProgram.verifyRsa65537(message, signature, modulus);
40-
perfEnd();
42+
perfRsa.end();
4143

4244
console.time('verify');
4345
await rsaZkProgram.verify(proof);

src/examples/crypto/sha256/run.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
import { Bytes12, SHA256Program } from './sha256.js';
2-
import { perfStart, perfEnd } from '../../../lib/testing/perf-regression.js';
2+
import { Performance } from '../../../lib/testing/perf-regression.js';
33

44
const cs = await SHA256Program.analyzeMethods();
5-
perfStart('compile', SHA256Program.name, cs);
5+
const perfSha256 = Performance.create(SHA256Program.name, cs);
6+
7+
perfSha256.start('compile');
68
await SHA256Program.compile();
7-
perfEnd();
9+
perfSha256.end();
810

911
let preimage = Bytes12.fromString('hello world!');
1012

1113
console.log('sha256 rows:', (await SHA256Program.analyzeMethods()).sha256.rows);
1214

13-
perfStart('prove', SHA256Program.name, cs, 'sha256');
15+
perfSha256.start('prove', 'sha256');
1416
let { proof } = await SHA256Program.sha256(preimage);
15-
perfEnd();
17+
perfSha256.end();
18+
1619
let isValid = await SHA256Program.verify(proof);
1720

1821
console.log('digest:', proof.publicOutput.toHex());

0 commit comments

Comments
 (0)