-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:Cardinal-Cryptography/zkOS-monorepo…
… into sync-tests
- Loading branch information
Showing
100 changed files
with
4,003 additions
and
6,176 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,2 @@ | ||
# required by oz-foundry-upgrades. See https://github.com/OpenZeppelin/openzeppelin-foundry-upgrades/tree/main?tab=readme-ov-file#optional-custom-output-directory | ||
FOUNDRY_OUT=artifacts |
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
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,49 @@ | ||
import re | ||
|
||
def parse_report(file_path): | ||
data = {} | ||
with open(file_path, 'r') as file: | ||
for line in file: | ||
match = re.match(r'(\w+):\s*(\d+)', line) | ||
if match: | ||
name, value = match.groups() | ||
data[name] = int(value) | ||
return data | ||
|
||
def calculate_differences(main_data, current_data): | ||
differences = [] | ||
for name in main_data: | ||
main_value = main_data[name] | ||
current_value = current_data.get(name, 0) | ||
if main_value > 0: | ||
difference = ((current_value - main_value) / main_value) * 100 | ||
else: | ||
difference = 0 # handle case where main value is zero | ||
differences.append((name, main_value, current_value, difference)) | ||
return differences | ||
|
||
def generate_html_report(differences): | ||
# Generate single-line HTML content without formatting | ||
html_content = "<table><tr><th>Transaction Name</th><th>Main</th><th>Current</th><th>Difference (%)</th></tr>" | ||
for name, main, current, diff in differences: | ||
sign = '+' if diff > 0 else '-' if diff < 0 else '' | ||
diff_value = f"{sign}{abs(diff):.5f}%" | ||
html_content += f"<tr><td>{name}</td><td>{main}</td><td>{current}</td><td>{diff_value}</td></tr>" | ||
html_content += "</table>" | ||
return html_content | ||
|
||
def main(): | ||
main_report_path = 'main-report.txt' | ||
current_report_path = 'current-report.txt' | ||
|
||
main_data = parse_report(main_report_path) | ||
current_data = parse_report(current_report_path) | ||
differences = calculate_differences(main_data, current_data) | ||
|
||
html_report = generate_html_report(differences) | ||
|
||
with open('report.html', 'w') as report_file: | ||
report_file.write(html_report) | ||
|
||
if __name__ == "__main__": | ||
main() |
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
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
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
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,100 @@ | ||
--- | ||
name: Measure gas | ||
|
||
on: | ||
workflow_dispatch: | ||
workflow_call: | ||
|
||
jobs: | ||
main: | ||
name: Measure circuits | ||
runs-on: [self-hosted, Linux, X64, large] | ||
timeout-minutes: 20 | ||
steps: | ||
|
||
- name: Checkout code (from the current branch) | ||
uses: actions/checkout@v4 | ||
|
||
- name: Prepare Rust env | ||
uses: ./.github/actions/prepare-rust-env | ||
with: | ||
poseidon-gadget-private-key: ${{ secrets.SSH_PRIVATE_KEY }} | ||
zkos-circuits-private-key: ${{ secrets.ZKOS_CIRCUITS_SSH_PRIVATE_KEY }} | ||
|
||
- name: Setup node | ||
uses: asdf-vm/actions/install@v3 | ||
|
||
- name: Install solc compiler | ||
uses: ./.github/actions/install-solc | ||
with: | ||
solc-version: 0.8.26 | ||
|
||
- name: Build binary | ||
run: cargo build -p integration-tests --bin gas-consumption --release | ||
|
||
#################### Run measurements on the current branch #################### | ||
|
||
- name: Install dependencies | ||
run: make deps | ||
|
||
- name: Generate all contracts | ||
run: make generate-contracts | ||
|
||
- name: Run measure-circuits binary on the current branch | ||
run: | | ||
export CONTRACTS_DIR="contracts" | ||
export CARGO_MANIFEST_DIR=./Cargo.toml | ||
./target/release/gas-consumption current-report.txt | ||
- name: Print gas measured on the current branch | ||
run: cat current-report.txt | ||
|
||
#################### Run measurements on the main branch #################### | ||
|
||
- name: Checkout repository from `main` | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: main | ||
path: main | ||
|
||
- name: Install dependencies | ||
run: | | ||
cd main | ||
make deps | ||
- name: Generate all contracts | ||
run: | | ||
cd main | ||
make generate-contracts | ||
- name: Run measure-circuits on the `main` branch | ||
run: | | ||
export CONTRACTS_DIR="main/contracts" | ||
export CARGO_MANIFEST_DIR=./main/Cargo.toml | ||
./target/release/gas-consumption main-report.txt | ||
- name: Print gas measured on the `main` branch | ||
run: cat main-report.txt | ||
|
||
#################### Generate report #################### | ||
|
||
- name: Install Python 3.10 | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.10' | ||
|
||
- name: Install python deps | ||
run: pip install prettytable | ||
|
||
- name: Run metrics-diff-presenter script | ||
run: python3 .github/scripts/gas_diff.py > report.html | ||
|
||
- name: Print gas report with diff | ||
run: cat report.html | ||
|
||
- name: Post measurements difference | ||
uses: thollander/actions-comment-pull-request@v3 | ||
with: | ||
file-path: report.html | ||
comment-tag: hashFiles('report.html') | ||
|
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
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
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
59 changes: 59 additions & 0 deletions
59
.github/workflows/mainnet-prod-build-and-deploy-shielder-relayer.yml
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,59 @@ | ||
--- | ||
name: "[PROD] Build and deploy shielder-relayer" | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
overwrite-shielder-address: | ||
type: string | ||
required: false | ||
default: '' | ||
description: Overwrite shielder address - if empty it's not changed | ||
|
||
jobs: | ||
build-and-push: | ||
name: Build and push shielder-relayer | ||
runs-on: [self-hosted, Linux, X64, medium] | ||
steps: | ||
- name: GIT | Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Prepare Rust env | ||
uses: ./.github/actions/prepare-rust-env | ||
with: | ||
poseidon-gadget-private-key: ${{ secrets.SSH_PRIVATE_KEY }} | ||
zkos-circuits-private-key: ${{ secrets.ZKOS_CIRCUITS_SSH_PRIVATE_KEY }} | ||
|
||
- name: Build relayer | ||
run: cd crates/shielder-relayer && make build | ||
|
||
- name: DOCKER | Build and push | ||
uses: ./.github/actions/shielder-relayer/build-and-push | ||
id: build_shielder_relayer | ||
with: | ||
aws-mainnet-ecr-access-key-id: ${{ secrets.AWS_MAINNET_ECR_ACCESS_KEY_ID }} | ||
aws-mainnet-ecr-access-key: ${{ secrets.AWS_MAINNET_ECR_ACCESS_KEY }} | ||
ecr-private-host: ${{ secrets.ECR_PRIVATE_HOST }} | ||
outputs: | ||
image_tag: ${{ steps.build_shielder_relayer.outputs.image_tag }} | ||
|
||
deploy: | ||
name: Deploy shielder-relayer | ||
needs: [build-and-push] | ||
runs-on: [self-hosted, Linux, X64, medium] | ||
steps: | ||
- name: GIT | Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: KUSTOMIZE | Deploy | ||
uses: ./.github/actions/shielder-relayer/deploy | ||
id: deploy_shielder_relayer | ||
with: | ||
environment: prod | ||
image-tag: ${{ needs.build-and-push.outputs.image_tag }} | ||
autocommit-author: ${{ secrets.AUTOCOMMIT_AUTHOR }} | ||
autocommit-email: ${{ secrets.AUTOCOMMIT_EMAIL }} | ||
github-token: ${{ secrets.CI_GH_TOKEN }} | ||
kustomize-version: ${{ vars.KUSTOMIZE_VERSION }} | ||
ecr-private-host: ${{ secrets.ECR_PRIVATE_HOST }} | ||
overwrite-shielder-address: ${{ inputs.overwrite-shielder-address }} |
Oops, something went wrong.