forked from noir-lang/noir
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: kevaundray <[email protected]>
- Loading branch information
Showing
251 changed files
with
29,939 additions
and
442 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: 'Get build status' | ||
description: 'Gets the build status of a Netlify site' | ||
inputs: | ||
branch-name: | ||
description: 'Branch name' | ||
required: true | ||
site-id: | ||
description: Netlify site id | ||
required: true | ||
outputs: | ||
deploy_status: | ||
description: "The deploy status" | ||
value: ${{ steps.check_deploy_status.outputs.deploy_status }} | ||
runs: | ||
using: "composite" | ||
steps: | ||
- run: ${{ github.action_path }}/script.sh | ||
shell: bash | ||
id: check_deploy_status | ||
env: | ||
BRANCH_NAME: ${{ inputs.branch-name }} | ||
SITE_ID: ${{ inputs.site-id }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/bin/bash | ||
|
||
BRANCH_NAME=$(echo "$BRANCH_NAME" | sed -e "s#refs/[^/]*/##") | ||
DEPLOY_STATUS=$(curl -X GET "https://api.netlify.com/api/v1/sites/$SITE_ID/deploys?branch=$BRANCH_NAME" | jq -r '.[] | select(.created_at != null) | .state' | head -1) | ||
|
||
echo "$SITE_ID" | ||
MAX_RETRIES=10 | ||
COUNT=0 | ||
while [[ "$DEPLOY_STATUS" != "ready" && $COUNT -lt $MAX_RETRIES ]]; do | ||
sleep 20 | ||
DEPLOY_STATUS=$(curl -X GET "https://api.netlify.com/api/v1/sites/$SITE_ID/deploys?branch=$BRANCH_NAME" | jq -r '.[] | select(.created_at != null) | .state' | head -1) | ||
COUNT=$((COUNT+1)) | ||
|
||
echo "Deploy status: $DEPLOY_STATUS" | ||
# If deploy status is ready, set the output and exit successfully | ||
if [[ "$DEPLOY_STATUS" == "ready" ]]; then | ||
echo "deploy_status=success" >> $GITHUB_OUTPUT | ||
exit 0 | ||
elif [[ "$DEPLOY_STATUS" == "error" ]]; then | ||
echo "deploy_status=failure" >> $GITHUB_OUTPUT | ||
exit 0 | ||
fi | ||
|
||
echo "Deploy still running. Retrying..." | ||
done | ||
|
||
echo "deploy_status=failure" >> $GITHUB_OUTPUT | ||
exit 0 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
name: Build docs | ||
|
||
on: | ||
pull_request: | ||
paths: | ||
- 'docs/**' | ||
types: | ||
- opened | ||
- synchronize | ||
- labeled | ||
push: | ||
paths: | ||
- 'docs/**' | ||
|
||
jobs: | ||
|
||
build_and_deploy: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
pull-requests: write | ||
if: contains(github.event.pull_request.labels.*.name, 'documentation') | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Netlify deploy | ||
run: | | ||
BRANCH_NAME=$(echo "${{ github.head_ref || github.ref }}" | sed -e "s#refs/[^/]*/##") | ||
curl -X POST -d {} "https://api.netlify.com/build_hooks/${{ secrets.NETLIFY_BUILD_HOOK }}?trigger_branch=$BRANCH_NAME" | ||
- name: Get deploy preview | ||
id: get_deploy_preview | ||
run: | | ||
BRANCH_NAME=$(echo "${{ github.head_ref || github.ref }}" | sed -e "s#refs/[^/]*/##") | ||
curl -X GET "https://api.netlify.com/api/v1/sites/${{ secrets.NETLIFY_SITE_ID }}/deploys?branch=$BRANCH_NAME" > deploy.json | ||
echo "::set-output name=deploy_url::$(cat deploy.json | jq -r '.[0].deploy_ssl_url')" | ||
- name: Add PR Comment | ||
uses: mshick/add-pr-comment@v2 | ||
with: | ||
message: | | ||
Hey @${{ github.event.pull_request.user.login }}! 🙌 | ||
I'm the deployment bot for Noir Docs, and I've got some updates for you: | ||
## Deployment Status | ||
Your latest changes are being deployed for preview! 🚀 | ||
Click the badge to see logs 🧐 | ||
[![Netlify Status](https://api.netlify.com/api/v1/badges/${{ secrets.NETLIFY_SITE_ID }}/deploy-status?branch=${{ github.head_ref || github.ref }})](https://app.netlify.com/sites/noir-docs-v2/deploys) | ||
If you have any questions about this process, refer to our contribution guide or feel free to ask around. | ||
- name: Check on deploy status | ||
uses: ./.github/actions/docs/build-status | ||
id: check_deploy_status | ||
with: | ||
branch-name: ${{ github.head_ref || github.ref }} | ||
site-id: ${{ secrets.NETLIFY_SITE_ID }} | ||
continue-on-error: true | ||
|
||
- name: Debugging - print deploy_status | ||
run: echo "${{ steps.check_deploy_status.outputs.deploy_status }}" | ||
|
||
- name: Change PR Comment for Successful Deployment | ||
if: steps.check_deploy_status.outputs.deploy_status == 'success' | ||
uses: mshick/add-pr-comment@v2 | ||
with: | ||
message-success: | | ||
![It's Alive!](https://i.imgflip.com/82hw5n.jpg) | ||
I'm a bot, beep boop 🤖 | ||
## Deployment Status: Success! | ||
[![Netlify Status](https://api.netlify.com/api/v1/badges/${{ secrets.NETLIFY_SITE_ID }}/deploy-status?branch=${{ github.head_ref || github.ref }})](https://app.netlify.com/sites/noir-docs-v2/deploys) | ||
## Preview | ||
🌐 [View Deployment Preview](${{ steps.get_deploy_preview.outputs.deploy_url }}) | ||
- name: Change PR Comment for Failed Deployment | ||
if: steps.check_deploy_status.outputs.deploy_status == 'failure' | ||
uses: mshick/add-pr-comment@v2 | ||
with: | ||
message: | | ||
![docs CI troll](https://i.imgflip.com/82ht8f.jpg) | ||
I'm a bot, beep boop 🤖 | ||
## Deployment Status: Failed ❌ | ||
Deployment didn't succeed. Please check logs below and resolve the issue 🧐 | ||
[![Netlify Status](https://api.netlify.com/api/v1/badges/${{ secrets.NETLIFY_SITE_ID }}/deploy-status?branch=${{ github.head_ref || github.ref }})](https://app.netlify.com/sites/noir-docs-v2/deploys) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Dependencies | ||
/node_modules | ||
|
||
# Production | ||
/build | ||
|
||
# Generated files | ||
.docusaurus | ||
.cache-loader | ||
|
||
# Misc | ||
.DS_Store | ||
.env.local | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
.yarn | ||
|
||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
package-lock.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"arrowParens": "avoid", | ||
"singleQuote": true, | ||
"trailingComma": "all", | ||
"printWidth": 100 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
nodeLinker: node-modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# Contributing to Noir | ||
|
||
Thank you for your interest in contributing to Noir documentation! We value your contributions in making Noir better. | ||
|
||
This guide will discuss how the Noir team handles [Commits](#commits), [Pull Requests](#pull-requests), [Merging](#merging), and [Versioning](#versioning). | ||
|
||
__Note:__ We won't force external contributors to follow this verbatim, but following these guidelines definitely helps us in accepting your contributions. | ||
|
||
## Commits | ||
|
||
We want to keep our commits small and focused. This allows for easily reviewing individual commits and/or splitting up pull requests when they grow too big. Additionally, this allows us to merge smaller changes quicker and release more often. | ||
|
||
When committing, it's often useful to use the `git add -p` workflow to decide on what parts of the changeset to stage for commit. | ||
|
||
We don't currently enforce any commit standard, however that may change at any time. Mind that the [Noir](https://github.com/noir-lang/noir) repo does enforce the [Conventional Commit](https://www.conventionalcommits.org/en/v1.0.0/) standard. | ||
|
||
## Pull Requests | ||
|
||
Before you create a pull request, search for any issues related to the change you are making. If none exist already, create an issue that thoroughly describes the problem that you are trying to solve. These are used to inform reviewers of the original intent and should be referenced via the pull request template. | ||
|
||
Pull Requests should be focused on the specific change they are working towards. If prerequisite work is required to complete the original pull request, that work should be submitted as a separate pull request. | ||
|
||
This strategy avoids scenarios where pull requests grow too large/out-of-scope and don't get proper reviews—we want to avoid "LGTM, I trust you" reviews. | ||
|
||
The easiest way to do this is to have multiple commits while you work and then you can cherry-pick the smaller changes into separate branches for pull requesting. | ||
|
||
### Reviews | ||
|
||
For any repository in the noir-lang organization, we require code review & approval by __one__ Noir team member before the changes are merged. However, while the docs repository is still getting up-to-speed with the current Noir fetures, we do allow for non-breaking pull requests to be merged at any time. Breaking pull requests should only be merged when the team has general agreement of the changes. | ||
|
||
The CI/CD workflow at Netlify should provide you with a preview of the website once merged. Use this preview to thoroughly test the changes before requesting reviews or merging. | ||
|
||
## Merging | ||
|
||
Once approved by the required number of team members, the pull request can be merged into the `master` branch. Sometimes, especially for external contributions, the final approver may merge the pull request instead of the submitter. | ||
|
||
### Merge Checklist | ||
|
||
Before merging, you should mentally review these questions: | ||
|
||
- Is continuous integration passing? | ||
- Do you have the required amount of approvals? | ||
- Does anyone else need to be pinged for thoughts? | ||
|
||
## Versioning | ||
|
||
The Noir documentation is versioned according to the [Docusaurus documentation](https://docusaurus.io/docs/versioning). In the `versioned_docs` and `versioned_sidebar` folders you will find the docs and configs for the previous versions. If any change needs to be made to older versions, please do it in this folder. | ||
|
||
In the `docs` folder, you'll find the current, unreleased version, which we call `dev`. Any change in this folder will be reflected in the next version, once the Noir team decides to release. | ||
|
||
We aim to have every version matching the versions of [Noir](https://github.com/noir-lang/noir). However, we would only cut a new version of the docs if there are breaking or otherwise significant changes, to avoid unecessary build time and size to the existent documentation. | ||
|
||
While the versioning is intended to be managed by the core maintainers, we feel it's important for external contributors to understand why and how is it maintained. To bump to a new version, run the following command, replacing with the intended version: | ||
|
||
`npm run docusaurus docs:version <new_version_tag>` | ||
|
||
This should create a new version by copying the `docs` folder and the `sidebars.js` file to the relevant folders, as well as adding this version to `versions.json`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Noir Docs | ||
|
||
This is the source code for the Noir documentation site at [noir-lang.org](https://noir-lang.org). | ||
|
||
This website is built using [Docusaurus 2](https://docusaurus.io/), a modern static website | ||
generator. | ||
|
||
## Contributing | ||
|
||
Interested in contributing to the docs? | ||
|
||
Check out the contributing guide [here](./CONTRIBUTING.md). | ||
|
||
## Development | ||
|
||
### Installation | ||
|
||
``` | ||
$ yarn | ||
``` | ||
|
||
### Local Development | ||
|
||
``` | ||
$ yarn start | ||
``` | ||
|
||
This command starts a local development server and opens up a browser window. Most changes are | ||
reflected live without having to restart the server. | ||
|
||
### Build | ||
|
||
``` | ||
$ yarn build | ||
``` | ||
|
||
This command generates static content into the `build` directory and can be served using any static | ||
contents hosting service. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
presets: [require.resolve('@docusaurus/core/lib/babel/preset')], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
--- | ||
title: Merkle Proof Membership | ||
description: | ||
Learn how to use merkle membership proof in Noir to prove that a given leaf is a member of a | ||
merkle tree with a specified root, at a given index. | ||
keywords: | ||
[merkle proof, merkle membership proof, Noir, rust, hash function, Pedersen, sha256, merkle tree] | ||
--- | ||
|
||
Let's walk through an example of a merkle membership proof in Noir that proves that a given leaf is | ||
in a merkle tree. | ||
|
||
```rust | ||
use dep::std; | ||
|
||
fn main(message : [Field; 62], index : Field, hashpath : [Field; 40], root : Field) { | ||
let leaf = std::hash::hash_to_field(message); | ||
let merkle_root = std::merkle::compute_merkle_root(leaf, index, hashpath); | ||
assert(merkle_root == root); | ||
} | ||
|
||
``` | ||
|
||
The message is hashed using `hash_to_field`. The specific hash function that is being used is chosen | ||
by the backend. The only requirement is that this hash function can heuristically be used as a | ||
random oracle. If only collision resistance is needed, then one can call `std::hash::pedersen` | ||
instead. | ||
|
||
```rust | ||
let leaf = std::hash::hash_to_field(message); | ||
``` | ||
|
||
The leaf is then passed to a compute_merkle_root function with the root, index and hashpath. The returned root can then be asserted to be the same as the provided root. | ||
|
||
```rust | ||
let merkle_root = std::merkle::compute_merkle_root(leaf, index, hashpath); | ||
assert (merkle_root == root); | ||
``` | ||
|
||
> **Note:** It is possible to re-implement the merkle tree implementation without standard library. | ||
> However, for most usecases, it is enough. In general, the standard library will always opt to be | ||
> as conservative as possible, while striking a balance with efficiency. | ||
An example, the merkle membership proof, only requires a hash function that has collision | ||
resistance, hence a hash function like Pedersen is allowed, which in most cases is more efficient | ||
than the even more conservative sha256. | ||
|
||
[View an example on the starter repo](https://github.com/noir-lang/noir-examples/blob/3ea09545cabfa464124ec2f3ea8e60c608abe6df/stealthdrop/circuits/src/main.nr#L20) |
Oops, something went wrong.