npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

noir-gates-diff

v0.0.2

Published

Github Action reporting gates diff from Nargo info reports

Downloads

41

Readme

Noir Gates Diff Reporter

  • Easily compare gates reports generated by Nargo automatically on each of your Pull Requests!

Getting started

Automatically generate a gas report diff on every PR

Add a workflow (.github/workflows/noir-gas-diff.yml):

name: Report gates diff

on:
  push:
    branches:
      - main
  pull_request:

jobs:
  compare_gas_reports:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
        with:
          submodules: recursive

      - name: Install Nargo
        uses: noir-lang/[email protected]
        with:
          toolchain: 0.11.0

      # Add any step generating a gas report to a temporary file named gasreport.ansi. For example:
      - name: Generate gates report
        run: nargo info --json > gasreport.json # <- this file name should be unique in your repository!
       
      - name: Compare gates reports
        uses: TomAFrench/[email protected]
        with:
          summaryQuantile: 0.9 # only display the 10% most significant gas diffs in the summary (defaults to 20%)
          id: gates_diff

      - name: Add gates diff to sticky comment
        if: github.event_name == 'pull_request' || github.event_name == 'pull_request_target'
        uses: marocchino/sticky-pull-request-comment@v2
        with:
          # delete the comment in case changes no longer impact gas costs
          delete: ${{ !steps.gas_diff.outputs.markdown }}
          message: ${{ steps.gas_diff.outputs.markdown }}

:information_source: An error will appear at first run! 🔴 Error: No workflow run found with an artifact named "main.gasreport.json" As the action is expecting a comparative file stored on the base branch and cannot find it (because the action never ran on the target branch and thus has never uploaded any gas report)


How it works

Everytime somebody opens a Pull Request, the action expects Noir's nargo to generate a gates report to a temporary file (named gatereport.json by default).

Once generated, the action will fetch the comparative gates report stored as an artifact from previous runs; parse & compare them, storing the results in the action's outputs as shell and as markdown.

You can then do whatever you want with the results!

Our recommandation: Automatically submit a sticky comment displaying the gas diff!


Options

report {string}

This should correspond to the path of a file where the output of forge's gas report has been logged. Only necessary when generating multiple gas reports on the same repository.

⚠️ Make sure this file uniquely identifies a gas report, to avoid messing up with a gas report of another workflow on the same repository!

Defaults to: gasreport.ansi

base {string}

The gas diff reference branch name, used to fetch the previous gas report to compare the freshly generated gas report to.

Defaults to: ${{ github.base_ref || github.ref_name }}

head {string}

The gas diff target branch name, used to upload the freshly generated gas report.

Defaults to: ${{ github.head_ref || github.ref_name }}

token {string}

The github token allowing the action to upload and download gas reports generated by foundry. You should not need to customize this, as the action already has access to the default Github Action token.

Defaults to: ${{ github.token }}

header {string}

The top section displayed in the markdown output. Can be used to identify multiple gas diffs in the same PR or add metadata/information to the markdown output.

Defaults to:

# Changes to circuit sizes

summaryQuantile {number}

The quantile threshold to filter avg gas cost diffs to display in the summary top section.

Defaults to: 0.8

⚠️ Known limitations

Library gates reports Nargo does not generate library gates reports. You need to wrap their usage in a contract calling the library to be able to compare gas costs of calling the library.

This repository is maintained independently from Nargo and may not work as expected with all versions of nargo.