Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: patch foundry template to main branch #34

Merged
merged 1 commit into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# EditorConfig http://EditorConfig.org

# top-most EditorConfig file
root = true

# All files
[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[*.sol]
indent_size = 4

[*.tree]
indent_size = 1
8 changes: 5 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
ETHERSCAN_API_KEY=<YOUR_ETHERSCAN_KEY>
SEPOLIA_URL=https://eth-sepolia.alchemyapi.io/v2/<YOUR ALCHEMY KEY>
PRIVATE_KEY=<YOUR_PRIVATE_KEY>
export PRIVATE_KEY="0x"
export POLYGONSCAN_ZKEVM_TESTNET_API_KEY=""
export SEPOLIA_ETHERSCAN_API_KEY=""
export SEPOLIA_RPC_URL=""
export POLYGON_ZKEVM_TESTNET_RPC_URL=""
15 changes: 15 additions & 0 deletions .gas-snapshot
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
RlnTest:test__Constants() (gas: 7921)
RlnTest:test__InvalidRegistration__DuplicateCommitment(uint256) (runs: 1000, μ: 120248, ~: 120248)
RlnTest:test__InvalidRegistration__FullSet() (gas: 1242442)
RlnTest:test__InvalidRegistration__InsufficientDeposit(uint256) (runs: 1000, μ: 17189, ~: 17189)
RlnTest:test__InvalidRegistration__InvalidIdCommitment(uint256) (runs: 1000, μ: 16963, ~: 16968)
RlnTest:test__InvalidSlash__InvalidProof() (gas: 958986)
RlnTest:test__InvalidSlash__MemberNotRegistered(uint256) (runs: 1000, μ: 30287, ~: 30287)
RlnTest:test__InvalidSlash__NoStake(uint256,address) (runs: 1000, μ: 301136, ~: 301143)
RlnTest:test__InvalidSlash__ToRlnAddress() (gas: 128396)
RlnTest:test__InvalidSlash__ToZeroAddress() (gas: 128301)
RlnTest:test__InvalidWithdraw__InsufficientContractBalance() (gas: 126872)
RlnTest:test__InvalidWithdraw__InsufficientWithdrawalBalance() (gas: 10494)
RlnTest:test__ValidRegistration(uint256) (runs: 1000, μ: 112053, ~: 112053)
RlnTest:test__ValidSlash(uint256,address) (runs: 1000, μ: 184955, ~: 184966)
RlnTest:test__ValidWithdraw(address) (runs: 1000, μ: 183699, ~: 183687)
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lib/** linguist-vendored
13 changes: 13 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
## Description

Describe the changes made in your pull request here.

## Checklist

Ensure you completed **all of the steps** below before submitting your pull request:

- [ ] Added natspec comments?
- [ ] Ran `forge snapshot`?
- [ ] Ran `pnpm lint`?
- [ ] Ran `forge test`?
- [ ] Ran `pnpm verify`?
235 changes: 193 additions & 42 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,60 +1,211 @@
name: CI
name: "CI"

on:
push:
branches: [main]
paths:
- "**.sol"
- "scripts/**.ts"
- "test/**.ts"
- "hardhat.config.ts"
- "package.json"
- ".github/workflows/ci.yml"
env:
API_KEY_ALCHEMY: ${{ secrets.API_KEY_ALCHEMY }}
FOUNDRY_PROFILE: "ci"

on:
workflow_dispatch:
pull_request:
branches: [main]
paths:
- "**.sol"
- "scripts/**.ts"
- "test/**.ts"
- "hardhat.config.ts"
- "package.json"
- ".github/workflows/ci.yml"
push:
branches:
- "main"

jobs:
lint:
runs-on: "ubuntu-latest"
steps:
- name: "Check out the repo"
uses: "actions/checkout@v3"
with:
submodules: "recursive"

- name: "Install Foundry"
uses: "foundry-rs/foundry-toolchain@v1"

- name: "Install Pnpm"
uses: "pnpm/action-setup@v2"
with:
version: "8"

- name: "Install Node.js"
uses: "actions/setup-node@v3"
with:
cache: "pnpm"
node-version: "lts/*"

- name: "Install the Node.js dependencies"
run: "pnpm install"

- name: "Lint the contracts"
run: "pnpm lint"

- name: "Add lint summary"
run: |
echo "## Lint result" >> $GITHUB_STEP_SUMMARY
echo "✅ Passed" >> $GITHUB_STEP_SUMMARY

build:
runs-on: "ubuntu-latest"
steps:
- name: "Check out the repo"
uses: "actions/checkout@v3"
with:
submodules: "recursive"

- name: "Install Foundry"
uses: "foundry-rs/foundry-toolchain@v1"

- name: "Install Pnpm"
uses: "pnpm/action-setup@v2"
with:
version: "8"

- name: "Install Node.js"
uses: "actions/setup-node@v3"
with:
cache: "pnpm"
node-version: "lts/*"

- name: "Install the Node.js dependencies"
run: "pnpm install"

- name: "Build the contracts and print their size"
run: "forge build --sizes"

- name: "Add build summary"
run: |
echo "## Build result" >> $GITHUB_STEP_SUMMARY
echo "✅ Passed" >> $GITHUB_STEP_SUMMARY

test:
needs: ["lint", "build"]
runs-on: "ubuntu-latest"
steps:
- name: "Check out the repo"
uses: "actions/checkout@v3"
with:
submodules: "recursive"

- name: "Install Foundry"
uses: "foundry-rs/foundry-toolchain@v1"

- name: "Install Pnpm"
uses: "pnpm/action-setup@v2"
with:
version: "8"

- name: "Install Node.js"
uses: "actions/setup-node@v3"
with:
cache: "pnpm"
node-version: "lts/*"

- name: "Install the Node.js dependencies"
run: "pnpm install"

- name: "Show the Foundry config"
run: "forge config"

- name: "Generate a fuzz seed that changes weekly to avoid burning through RPC allowance"
run: >
echo "FOUNDRY_FUZZ_SEED=$(
echo $(($EPOCHSECONDS - $EPOCHSECONDS % 604800))
)" >> $GITHUB_ENV

- name: "Run the tests"
run: "forge test"

- name: "Add test summary"
run: |
echo "## Tests result" >> $GITHUB_STEP_SUMMARY
echo "✅ Passed" >> $GITHUB_STEP_SUMMARY

coverage:
needs: ["lint", "build"]
runs-on: "ubuntu-latest"
steps:
- name: "Check out the repo"
uses: "actions/checkout@v3"
with:
submodules: "recursive"

- name: "Install Pnpm"
uses: "pnpm/action-setup@v2"
with:
version: "8"

- name: "Install Node.js"
uses: "actions/setup-node@v3"
with:
cache: "pnpm"
node-version: "lts/*"

- name: "Install the Node.js dependencies"
run: "pnpm install"

- name: "Install Foundry"
uses: "foundry-rs/foundry-toolchain@v1"

- name: "Generate the coverage report using the unit and the integration tests"
run: 'forge coverage --match-path "test/**/*.sol" --report lcov'

- name: "Upload coverage report to Codecov"
uses: "codecov/codecov-action@v3"
with:
files: "./lcov.info"

- name: "Add coverage summary"
run: |
echo "## Coverage result" >> $GITHUB_STEP_SUMMARY
echo "✅ Uploaded to Codecov" >> $GITHUB_STEP_SUMMARY
verify:
# TODO: Write Rln certora spec
if: false
needs: ["lint", "build"]
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
submodules: recursive

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
- name: Install Python
uses: actions/setup-python@v2
with: { python-version: 3.9 }

- uses: actions/setup-node@v3
with:
node-version: 16
cache: "yarn"
- id: dependencies
run: yarn install
- name: Install Java
uses: actions/setup-java@v1
with: { java-version: "11", java-package: jre }

- id: lint
run: yarn lint
- name: Install Certora CLI
run: pip3 install certora-cli==5.0.5

- id: test
run: yarn test:verbose
- name: Install Solidity
run: |
wget https://github.com/ethereum/solidity/releases/download/v0.8.20/solc-static-linux
chmod +x solc-static-linux
sudo mv solc-static-linux /usr/local/bin/solc

- id: coverage
run: yarn coverage
- name: "Install Pnpm"
uses: "pnpm/action-setup@v2"
with:
version: "8"

- id: upload-coverage
# run only in pull requests
if: github.event_name == 'pull_request'
uses: zgosalvez/github-actions-report-lcov@v1
- name: "Install Node.js"
uses: "actions/setup-node@v3"
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
coverage-files: lcov.info
artifact-name: code-coverage-report
cache: "pnpm"
node-version: "lts/*"

- name: "Install the Node.js dependencies"
run: "pnpm install"

- name: Verify rules
run: "pnpm verify"
env:
CERTORAKEY: ${{ secrets.CERTORAKEY }}

strategy:
fail-fast: false
max-parallel: 16
27 changes: 16 additions & 11 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
node_modules
.env
coverage
coverage.json
typechain

#Hardhat files
# directories
cache
artifacts

#Foundry files
cache_forge
node_modules
out

# files
*.env
*.log
.DS_Store
.pnp.*
lcov.info
yarn.lock

# broadcasts
!broadcast
broadcast/*
broadcast/*/31337/

.certora_internal
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[submodule "lib/forge-std"]
branch = "v1"
path = lib/forge-std
url = https://github.com/foundry-rs/forge-std
branch = v1.6.0
22 changes: 18 additions & 4 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
node_modules
artifacts
# directories
broadcast
cache
coverage*
gasReporterOutput.json
lib
deployments
node_modules
out

# files
*.env
*.log
.DS_Store
.pnp.*
lcov.info
package-lock.json
pnpm-lock.yaml
yarn.lock

slither.config.json
7 changes: 7 additions & 0 deletions .prettierrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
bracketSpacing: true
printWidth: 120
proseWrap: "always"
singleQuote: false
tabWidth: 2
trailingComma: "all"
useTabs: false
Loading