Skip to content

Enhance gas benchmark gates and dashboard#406

Open
TUPM96 wants to merge 1 commit into
Smartdevs17:mainfrom
TUPM96:codex/gas-benchmarks-350
Open

Enhance gas benchmark gates and dashboard#406
TUPM96 wants to merge 1 commit into
Smartdevs17:mainfrom
TUPM96:codex/gas-benchmarks-350

Conversation

@TUPM96
Copy link
Copy Markdown

@TUPM96 TUPM96 commented May 25, 2026

Closes #350

Summary

  • Adds a coverage manifest for the 82 benchmarked public contract operations across lending, hello-world, AMM, and bridge contracts.
  • Adds scripts/gas_benchmark_report.py to generate a Markdown gas dashboard, track historical trend entries, summarize storage read/write usage, highlight cross-contract/integration calls, enforce hard gas budgets, and fail on >10% regressions against the baseline.
  • Reworks the gas benchmark workflow to publish dashboard/history artifacts and use the unified gate for coverage, budgets, and baseline regressions.
  • Updates the local run-benchmarks.sh runner and benchmark docs so the same gates can be run outside CI.
  • Adds line-ending attributes for scripts/workflows/report inputs.

Validation

  • python -m py_compile scripts/gas_benchmark_report.py
  • bash -n run-benchmarks.sh
  • python scripts/gas_benchmark_report.py --results stellar-lend/benchmarks/gas-baseline.json --dashboard <temp-dashboard> --history stellar-lend/benchmarks/history.jsonl --history-out <temp-history> --max-regression-pct 10
  • Generated a complete 82-operation fixture from public-functions.json and verified coverage/budget/regression gates pass against it.
  • git diff --cached --check

Note

cargo check -p stellarlend-benchmarks currently fails before reaching this patch because the base contract crates do not compile cleanly: lending is missing module exports for interest_rate/risk_monitor, and hello-world has duplicate definitions plus stale test/client references. This PR keeps the scope on the benchmark framework and CI gate requested in #350.

Copilot AI review requested due to automatic review settings May 25, 2026 12:57
@vercel
Copy link
Copy Markdown

vercel Bot commented May 25, 2026

@TUPM96 is attempting to deploy a commit to the smartdevs17's projects Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds a gas benchmark reporting + gating layer (coverage, regression, history) and integrates it into local tooling and CI.

Changes:

  • Introduces a Python report generator that validates results, produces a Markdown dashboard, and appends historical trend data.
  • Adds a required-operations coverage list and a seed history log for long-term trend tracking.
  • Updates the local runner script and GitHub Actions workflow to generate/upload the dashboard and enforce coverage/regression gates.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
stellar-lend/benchmarks/public-functions.json Defines the required benchmark operations (“coverage”) used as a CI gate.
stellar-lend/benchmarks/history.jsonl Seeds an initial historical trend entry.
stellar-lend/benchmarks/README.md Documents coverage + regression gates and new dashboard/history artifacts.
scripts/gas_benchmark_report.py New validator/dashboard generator for coverage/budget/regressions + history output.
run-benchmarks.sh Updates local runner to generate dashboard/history and optionally enforce regression gate.
.github/workflows/gas-benchmarks.yml Updates CI to run the report script, publish dashboard to step summary, and upload new artifacts.
.gitattributes Enforces LF line endings for common repo file types.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +118 to +125
def cross_contract_results(results: list[dict[str, Any]]) -> list[dict[str, Any]]:
markers = ("cross", "bridge", "amm", "flash_loan", "callback", "auto_swap")
selected = []
for item in results:
haystack = " ".join([item["operation"], item["description"], *item["tags"]]).lower()
if any(marker in haystack for marker in markers):
selected.append(item)
return selected
Comment on lines +15 to +19
def load_json(path: Path, default: Any) -> Any:
if not path or not path.exists():
return default
with path.open("r", encoding="utf-8") as handle:
return json.load(handle)
Comment on lines +128 to +135
def history_entry(payload: dict[str, Any], results: list[dict[str, Any]]) -> dict[str, Any]:
instructions = [item["instructions"] for item in results]
return {
"timestamp": payload.get("timestamp") or datetime.now(timezone.utc).isoformat(),
"source": "gas-benchmark-report",
"total_benchmarks": len(results),
"passed": len(results) - len(budget_failures(results)),
"failed": len(budget_failures(results)),
Comment on lines +134 to +135
"passed": len(results) - len(budget_failures(results)),
"failed": len(budget_failures(results)),
Comment on lines +36 to +38
BENCHMARK_RESULTS: stellar-lend/benchmark-results.json
BENCHMARK_DASHBOARD: stellar-lend/benchmark-dashboard.md
BENCHMARK_HISTORY: stellar-lend/benchmark-history.jsonl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add gas benchmarking and optimization suite for contract functions

2 participants