Skip to content

Commit

Permalink
Merge branch 'main' into tf/more-robust-parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
TomAFrench authored Jan 5, 2025
2 parents 84ada11 + 60c57a6 commit 865d87b
Show file tree
Hide file tree
Showing 6 changed files with 179 additions and 15 deletions.
2 changes: 1 addition & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ const report_1 = __nccwpck_require__(4909);
const token = process.env.GITHUB_TOKEN || core.getInput("token");
const report = core.getInput("report");
const header = core.getInput("header");
const brillig_report = core.getInput("brillig_report");
const brillig_report = core.getInput("brillig_report") === "true";
const brillig_report_bytes = core.getInput("brillig_report_bytes");
const summaryQuantile = parseFloat(core.getInput("summaryQuantile"));
// const sortCriteria = core.getInput("sortCriteria").split(",");
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { DiffBrillig, DiffCircuit, WorkspaceReport } from "./types";
const token = process.env.GITHUB_TOKEN || core.getInput("token");
const report = core.getInput("report");
const header = core.getInput("header");
const brillig_report = core.getInput("brillig_report");
const brillig_report: boolean = core.getInput("brillig_report") === "true";
const brillig_report_bytes = core.getInput("brillig_report_bytes");
const summaryQuantile = parseFloat(core.getInput("summaryQuantile"));
// const sortCriteria = core.getInput("sortCriteria").split(",");
Expand Down
17 changes: 12 additions & 5 deletions tests/mocks/1-2-program-acir.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@

| Program | ACIR opcodes (+/-) | % | Circuit size (+/-) | % |
|:-|-:|-:|-:|-:|
| **c** | +2 ❌ | **+100.00%** | +6 ❌ | **+300.00%** |
| **d** | +1 ❌ | **+33.33%** | +3 ❌ | **+60.00%** |
| **private_kernel_tail_to_public** | +439 ❌ | **+2.76%** | +589 ❌ | **+1.39%** |
| **rollup_base_public** | -1,108,638 ✅ | **-28.79%** | -2,082,811 ✅ | **-16.51%** |
| **rollup_base_private** | -1,108,827 ✅ | **-30.63%** | -2,083,047 ✅ | **-18.56%** |
---

<details>
Expand All @@ -16,7 +17,13 @@

| Program | ACIR opcodes (+/-) | % | Circuit size (+/-) | % |
|:-|-:|-:|-:|-:|
| **c** | 4&nbsp;(+2) | **+100.00%** | 8&nbsp;(+6) | **+300.00%** |
| **d** | 4&nbsp;(+1) | **+33.33%** | 8&nbsp;(+3) | **+60.00%** |
| **b** | 4&nbsp;(-1) | **-20.00%** | 8&nbsp;(-2) | **-20.00%** |
| **private_kernel_tail_to_public** | 16,335&nbsp;(+439) | **+2.76%** | 42,934&nbsp;(+589) | **+1.39%** |
| **rollup_block_root** | 719,198&nbsp;(+36,872) | **+5.40%** | 4,324,095&nbsp;(+30,738) | **+0.72%** |
| **rollup_root** | 38,438&nbsp;(+6,048) | **+18.67%** | 1,907,311&nbsp;(+6,552) | **+0.34%** |
| **rollup_block_merge** | 38,454&nbsp;(+6,048) | **+18.66%** | 1,907,325&nbsp;(+6,552) | **+0.34%** |
| **private_kernel_inner** | 46,279&nbsp;(+19) | **+0.04%** | 89,062&nbsp;(+26) | **+0.03%** |
| **private_kernel_tail** | 5,348&nbsp;(+6) | **+0.11%** | 27,501&nbsp;(+8) | **+0.03%** |
| **private_kernel_init** | 27,955&nbsp;(+2) | **+0.01%** | 48,562&nbsp;(+3) | **+0.01%** |
| **rollup_base_public** | 2,742,614&nbsp;(-1,108,638) | **-28.79%** | 10,534,892&nbsp;(-2,082,811) | **-16.51%** |
| **rollup_base_private** | 2,510,946&nbsp;(-1,108,827) | **-30.63%** | 9,141,878&nbsp;(-2,083,047) | **-18.56%** |
</details>
3 changes: 1 addition & 2 deletions tests/mocks/full_gas_report_after.json
Original file line number Diff line number Diff line change
Expand Up @@ -236,5 +236,4 @@
{ "package_name": "witness_compression", "functions": [ { "name": "main", "acir_opcodes": 6, "opcodes": 6, "circuit_size": 21 } ] },
{ "package_name": "wrapping_operations", "functions": [ { "name": "main", "acir_opcodes": 34, "opcodes": 34, "circuit_size": 2945 } ] },
{ "package_name": "xor", "functions": [ { "name": "main", "acir_opcodes": 8, "opcodes": 8, "circuit_size": 3147 } ] }
]}

]}
1 change: 0 additions & 1 deletion tests/mocks/full_gas_report_before.json
Original file line number Diff line number Diff line change
Expand Up @@ -237,4 +237,3 @@
{ "package_name": "wrapping_operations", "functions": [ { "name": "main", "acir_opcodes": 34, "opcodes": 34, "circuit_size": 2945 } ] },
{ "package_name": "xor", "functions": [ { "name": "main", "acir_opcodes": 8, "opcodes": 8, "circuit_size": 3147 } ] }
]}

169 changes: 164 additions & 5 deletions tests/real_world_data.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as fs from "fs";

import { computeProgramDiffs, parseReport } from "../src/report";


Check failure on line 5 in tests/real_world_data.test.ts

View workflow job for this annotation

GitHub Actions / eslint

Delete `⏎`
const brilligReport = fs.readFileSync("tests/mocks/brillig_report.json", "utf8");
const referenceRealWorldContent = fs.readFileSync(
"tests/mocks/full_gas_report_before.json",
Expand All @@ -27,12 +28,170 @@ describe("Program diffs", () => {
expect(computeProgramDiffs(report.programs, report.programs)).toStrictEqual([[], []]);
});

it("should return zero diff against itself", () => {
it("should return expected diff against reference report", () => {
const referenceReport = parseReport(referenceRealWorldContent);
const compareReport = parseReport(compareRealWorldContent);
expect(computeProgramDiffs(referenceReport.programs, compareReport.programs)).toStrictEqual([
[],
[],
]);
const expectedCircuitDiffs: DiffCircuit[] = [
{
circuit_size: {
current: 42934,
delta: 589,
percentage: 1.3909552485535481,
previous: 42345,
},
name: "private_kernel_tail_to_public",
opcodes: {
current: 16335,
delta: 439,
percentage: 2.761701056869653,
previous: 15896,
},
},
{
circuit_size: {
current: 4324095,
delta: 30738,
percentage: 0.7159432583873179,
previous: 4293357,
},
name: "rollup_block_root",
opcodes: {
current: 719198,
delta: 36872,
percentage: 5.403868532050662,
previous: 682326,
},
},
{
circuit_size: {
current: 1907311,
delta: 6552,
percentage: 0.34470440492455906,
previous: 1900759,
},
name: "rollup_root",
opcodes: {
current: 38438,
delta: 6048,
percentage: 18.672429762272305,
previous: 32390,
},
},
{
circuit_size: {
current: 1907325,
delta: 6552,
percentage: 0.344701866030294,
previous: 1900773,
},
name: "rollup_block_merge",
opcodes: {
current: 38454,
delta: 6048,
percentage: 18.663210516571006,
previous: 32406,
},
},
{
circuit_size: {
current: 89062,
delta: 26,
percentage: 0.02920167123410755,
previous: 89036,
},
name: "private_kernel_inner",
opcodes: {
current: 46279,
delta: 19,
percentage: 0.041072200605274535,
previous: 46260,
},
},
{
circuit_size: {
current: 27501,
delta: 8,
percentage: 0.029098315934965265,
previous: 27493,
},
name: "private_kernel_tail",
opcodes: {
current: 5348,
delta: 6,
percentage: 0.11231748408835641,
previous: 5342,
},
},
{
circuit_size: {
current: 48562,
delta: 3,
percentage: 0.006178051442575012,
previous: 48559,
},
name: "private_kernel_init",
opcodes: {
current: 27955,
delta: 2,
percentage: 0.007154867098343648,
previous: 27953,
},
},
{
circuit_size: {
current: 10534892,
delta: -2082811,
percentage: -16.507053621407955,
previous: 12617703,
},
name: "rollup_base_public",
opcodes: {
current: 2742614,
delta: -1108638,
percentage: -28.786431009967668,
previous: 3851252,
},
},
{
circuit_size: {
current: 9141878,
delta: -2083047,
percentage: -18.557335572398035,
previous: 11224925,
},
name: "rollup_base_private",
opcodes: {
current: 2510946,
delta: -1108827,
percentage: -30.63250098832164,
previous: 3619773,
},
},
];
const expectedBrilligsDiff: DiffBrillig[] = [];

const [actualCircuitsDiff, actualBrilligsDiff] = computeProgramDiffs(
referenceReport.programs,
compareReport.programs
);

expect(actualCircuitsDiff).toStrictEqual(expectedCircuitDiffs);
expect(actualBrilligsDiff).toStrictEqual(expectedBrilligsDiff);

const [summaryRows, fullReportRows] = formatCircuitRows(expectedCircuitDiffs, 0.8);
fs.writeFileSync(
"tests/mocks/1-2-program-acir.md",
formatMarkdownDiff(
"# Changes to gas cost",
"Rubilmax/foundry-gas-diff",
"d62d23148ca73df77cd4378ee1b3c17f1f303dbf",
summaryRows,
fullReportRows,
true,
false,
undefined,
0.8
)
);
});
});

0 comments on commit 865d87b

Please sign in to comment.