Skip to content

Commit

Permalink
chore: monorepo (#1456)
Browse files Browse the repository at this point in the history
<!--- Please provide a general summary of your changes in the title
above -->

<!-- Give an estimate of the time you spent on this PR in terms of work
days.
Did you spend 0.5 days on this PR or rather 2 days?  -->

Time spent on this PR:

## Pull request type

<!-- Please try to limit your pull request to one type,
submit multiple pull requests if needed. -->

Please check the type of change your PR introduces:

- [ ] Bugfix
- [ ] Feature
- [ ] Code style update (formatting, renaming)
- [ ] Refactoring (no functional changes, no api changes)
- [ ] Build related changes
- [ ] Documentation content changes
- [x] Other (please describe):

## What is the current behavior?

<!-- Please describe the current behavior that you are modifying,
or link to a relevant issue. -->

Resolves #1394

## What is the new behavior?

<!-- Please describe the behavior or changes that are being added by
this PR. -->

- Monorepo with kakarot0 and SSJ

<!-- Reviewable:start -->
- - -
This change is [<img src="https://reviewable.io/review_button.svg"
height="34" align="absmiddle"
alt="Reviewable"/>](https://reviewable.io/reviews/kkrt-labs/kakarot/1456)
<!-- Reviewable:end -->
  • Loading branch information
obatirou authored Oct 7, 2024
1 parent 038b3a3 commit 6496ee1
Show file tree
Hide file tree
Showing 312 changed files with 46,660 additions and 91 deletions.
3 changes: 0 additions & 3 deletions .codespellignore

This file was deleted.

9 changes: 5 additions & 4 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,24 @@
"python.formatting.blackPath": "/usr/local/py-utils/bin/black",
"python.formatting.yapfPath": "/usr/local/py-utils/bin/yapf",
"editor.defaultFormatter": "trunk.io",
"cairols.sourceDir": "src",
"cairols.cairoPath": ["src", "tests"]
"cairols.sourceDir": "cairo_zero",
"cairols.cairoPath": ["cairo_zero", "tests"]
},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"ms-python.python",
"ms-python.vscode-pylance",
"starkware.cairo",
"ericglau.cairo-ls",
"trunk.io"
"trunk.io",
"starkware.cairo1"
]
}
},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && curl -L https://foundry.paradigm.xyz | bash && /home/vscode/.foundry/bin/foundryup && make setup",
"postCreateCommand": "curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && curl -L https://foundry.paradigm.xyz | bash && /home/vscode/.foundry/bin/foundryup && curl -LsSf https://astral.sh/uv/install.sh | sh && . $HOME/.cargo/env && uv venv && make setup && curl --proto '=https' --tlsv1.2 -sSf https://docs.swmansion.com/scarb/install.sh | sh",
// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode",
"features": {
Expand Down
4 changes: 4 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,7 @@ HYPOTHESIS_PROFILE=dev

VOYAGER_API_URL=
VOYAGER_API_KEY=

# Private key to sign transactions for RLP scripts/compute_rlp_encoding.ts
# Warning: Do not use this key in production systems
PRIVATE_KEY_RLP_SCRIPT=0x6be0067ba259624aa28f796b703e7d095925a470b17786767bd09aaa3fc2ceea
12 changes: 7 additions & 5 deletions .github/workflows/ci.yml → .github/workflows/cairo-zero-ci.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
name: CI
name: cairo-zero-CI

on:
push:
branches:
- main
pull_request: {}
pull_request:
paths:
- cairo_zero/**

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
group: cairo-zero-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions: read-all
Expand All @@ -32,7 +34,7 @@ jobs:
with:
filters: |
src:
- 'src/**'
- 'cairo_zero/**'
kakarot_scripts:
- 'kakarot_scripts/**'
solidity:
Expand Down Expand Up @@ -96,7 +98,7 @@ jobs:
- name: Run tests
env:
HYPOTHESIS_PROFILE: ci
run: make test-unit
run: make test-unit-cairo-zero
- name: Upload coverage report to codecov
uses: codecov/codecov-action@v3
with:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: NIGHTLY-FUZZING
name: cairo-zero-NIGHTLY-FUZZING

on:
schedule:
Expand Down Expand Up @@ -30,7 +30,7 @@ jobs:
- name: Run tests
env:
HYPOTHESIS_PROFILE: nightly
run: make test-unit
run: make test-unit-cairo-zero
- name: Upload coverage report to codecov
uses: codecov/codecov-action@v3
with:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# trunk-ignore-all(checkov/CKV2_GHA_1)
name: Release
name: cairo-zero-Release

on:
release:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Update Submodule
name: cairo-zero Update Submodule

on:
release:
Expand Down
34 changes: 34 additions & 0 deletions .github/workflows/ssj-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Reusable Build Workflow

on:
workflow_call:
inputs:
artifact-name:
required: true
type: string

permissions: read-all

jobs:
ssj-build:
runs-on: ubuntu-latest
env:
CI_COMMIT_MESSAGE: CI Formatting Auto Commit
CI_COMMIT_AUTHOR: ${{ github.event.repository.name }} CI
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Scarb
uses: software-mansion/setup-scarb@v1
with:
tool-versions: ./cairo/kakarot-ssj/.tool-versions

- name: Build contracts
run: cd cairo/kakarot-ssj/ && scarb build -p contracts

- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ inputs.artifact-name }}
path: cairo/kakarot-ssj/target/dev
84 changes: 84 additions & 0 deletions .github/workflows/ssj-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: SSJ-CI

on:
push:
branches:
- main
paths:
- cairo/kakarot-ssj/**

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

concurrency:
group: ssj-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions: read-all

jobs:
ssj-build:
uses: ./.github/workflows/ssj-build.yml
with:
artifact-name: ssj-build

ssj-tests-unit:
uses: ./.github/workflows/ssj-tests-unit.yml
with:
run-fmt-check: false

ssj-ef-tests:
uses: ./.github/workflows/ssj-ef-tests.yml
needs: [ssj-build]
with:
artifact-name: ssj-build

ssj-resources:
runs-on: ubuntu-latest
needs: [ssj-ef-tests]
steps:
- uses: actions/checkout@v4

- name: Set up Python 3.10.14
uses: actions/setup-python@v4
with:
python-version: 3.10.14

- name: Load cached Poetry installation
id: cached-poetry
uses: actions/cache@v4
with:
path: ~/.local
key: poetry-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}

- name: Install Poetry
if: steps.cached-poetry.outputs.cache-hit != 'true'
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true

- run: poetry config installer.modern-installation false

- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v4
with:
path: .venv
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}

- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: make setup

- name: Load performance artifacts
uses: actions/download-artifact@v3
with:
path: resources
name: resources

- name: Check resources evolution
run: |
result=$(GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} make check-resources 2>&1)
echo "$result" >> "$GITHUB_STEP_SUMMARY"
129 changes: 129 additions & 0 deletions .github/workflows/ssj-ef-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
name: SSJ-EF-Tests

on:
workflow_call:
inputs:
artifact-name:
required: true
type: string

permissions: read-all

jobs:
ef-tests:
# trunk-ignore(actionlint/runner-label)
runs-on: ubuntu-latest-16-cores
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Cache cairo-native setup
id: cache-cairo-native
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
cairo/kakarot-ssj/target/
./libcairo_native_runtime.a
key:
${{ runner.os }}-cairo-native-${{ hashFiles('**/Cargo.lock',
'scripts/setup_cairo_native.sh') }}

- name: Make setup script executable
run: chmod +x ./cairo/kakarot-ssj/scripts/setup_cairo_native.sh

- name: Setup Cairo Native
run: |
if [[ "${{ steps.cache-cairo-native.outputs.cache-hit }}" == 'true' ]]; then
sudo ./cairo/kakarot-ssj/scripts/setup_cairo_native.sh -s
else
sudo ./cairo/kakarot-ssj/scripts/setup_cairo_native.sh
fi
- name: Set Environment Variables
run: |
echo "MLIR_SYS_190_PREFIX=/usr/lib/llvm-19/" >> $GITHUB_ENV
echo "LLVM_SYS_191_PREFIX=/usr/lib/llvm-19/" >> $GITHUB_ENV
echo "TABLEGEN_190_PREFIX=/usr/lib/llvm-19/" >> $GITHUB_ENV
echo "CAIRO_NATIVE_RUNTIME_LIBRARY=$(pwd)/libcairo_native_runtime.a" >> $GITHUB_ENV
- name: Checkout ef-tests
uses: actions/checkout@v4
with:
repository: kkrt-labs/ef-tests
ref: feat/cairo-native
path: ef-tests # Check out to a subdirectory to avoid cleaning the kakarot-ssj directory

- name: Checkout local skip file
uses: actions/checkout@v4
with:
sparse-checkout: |
cairo/kakarot-ssj/
sparse-checkout-cone-mode: false
path: skip-file

- name: Setup ef-tests
run: |
mv skip-file/cairo/kakarot-ssj/blockchain-tests-skip.yml ef-tests/blockchain-tests-skip.yml
cd ef-tests
mkdir -p build/common
make setup setup-kakarot-v0
- name: Install nextest
uses: taiki-e/install-action@nextest

- name: Download Kakarot-SSJ build artifacts in v1
uses: actions/download-artifact@v3
with:
name: ${{ inputs.artifact-name }}
path: ef-tests/build/v1

- name: Move Cairo1Helpers
run: |
mv ef-tests/build/v1/contracts_Cairo1Helpers.compiled_contract_class.json \
ef-tests/build/common/cairo1_helpers.json
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.10.14

# Add this step to verify the file exists
- name: Verify libcairo_native_runtime.a
run: |
echo $CAIRO_NATIVE_RUNTIME_LIBRARY
ls -l $CAIRO_NATIVE_RUNTIME_LIBRARY
- name: Run tests
working-directory: ef-tests
run: |
set -o pipefail
RUST_MIN_STACK=1342177280 make ef-test-v1-native | tee test_v1.out
set +o pipefail
- name: Retrieve ef-tests execution resources
working-directory: ef-tests
run: python scripts/compute_resources.py
env:
KAKAROT_VERSION: v1

- name: Upload resources
uses: actions/upload-artifact@v3
with:
path: ef-tests/resources
name: resources

- name: Generate blockchain-tests-skip.yml file
if: github.event_name == 'workflow_dispatch'
working-directory: ef-tests
run: make generate-skip-file

- name: Upload skip file
if: github.event_name == 'workflow_dispatch'
uses: actions/upload-artifact@v3
with:
path: ef-tests/blockchain-tests-skip.yml
name: blockchain-tests-skip
30 changes: 30 additions & 0 deletions .github/workflows/ssj-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# trunk-ignore-all(checkov/CKV2_GHA_1)
name: SSJ-Release

on:
release:
types: [published]

jobs:
build-and-upload:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Scarb
uses: software-mansion/setup-scarb@v1
with:
tool-versions: ./cairo/kakarot-ssj/.tool-versions
- name: Build contracts
run: |
cd cairo/kakarot-ssj && scarb build -p contracts
- name: Zip dev artifacts
run: zip -rj kakarot-ssj-build.zip cairo/kakarot-ssj/target/dev
- name: Upload artifacts to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: kakarot-ssj-build.zip
asset_name: kakarot-ssj-build.zip
tag: ${{ github.ref_name }}
overwrite: true
Loading

0 comments on commit 6496ee1

Please sign in to comment.