diff --git a/.github/workflows/blockifier_ci.yml b/.github/workflows/blockifier_ci.yml index 58048dfa09..52a1062e92 100644 --- a/.github/workflows/blockifier_ci.yml +++ b/.github/workflows/blockifier_ci.yml @@ -9,7 +9,9 @@ on: - v[0-9].** paths: - 'crates/blockifier/**' - - 'crates/native_blockifier/.cargo/config.toml' + - 'crates/native_blockifier/**' + - 'build_native_blockifier_in_docker.sh' + - 'scripts/build_native_blockifier.sh' pull_request: types: @@ -20,7 +22,9 @@ on: - edited paths: - 'crates/blockifier/**' - - 'crates/native_blockifier/.cargo/config.toml' + - 'crates/native_blockifier/**' + - 'build_native_blockifier_in_docker.sh' + - 'scripts/build_native_blockifier.sh' jobs: featureless-build: @@ -45,7 +49,7 @@ jobs: prefix-key: "v1-rust-ubuntu-20.04" - name: Build native blockifier - run: ./build_native_blockifier.sh + run: ./build_native_blockifier_in_docker.sh # Commit hash on pull request event would be the head commit of the branch. - name: Get commit hash prefix for PR update diff --git a/.github/workflows/papyrus_docker-publish.yml b/.github/workflows/papyrus_docker-publish.yml index 53c54d3047..70026edd4f 100644 --- a/.github/workflows/papyrus_docker-publish.yml +++ b/.github/workflows/papyrus_docker-publish.yml @@ -37,8 +37,8 @@ jobs: uses: docker/login-action@v2.1.0 with: registry: ${{ env.REGISTRY }} - username: ${{ secrets.GHCR_USERNAME }} - password: ${{ secrets.GHCR_TOKEN }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} logout: true # Extract metadata (tags, labels) for Docker @@ -47,7 +47,7 @@ jobs: id: meta uses: docker/metadata-action@v4.1.1 with: - images: ${{ env.REGISTRY }}/${{ env.REPO_NAME }} + images: ${{ env.REGISTRY }}/${{ env.REPO_NAME }}/papyrus tags: | type=semver,pattern={{raw}} type=semver,pattern={{version}} diff --git a/.gitignore b/.gitignore index 2778bb95de..bc8e9a4262 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,6 @@ tmp_venv/* /.vscode # Git hooks /.husky + +# Python artifacts. +scripts/__pycache__ diff --git a/build_native_blockifier.sh b/build_native_blockifier_in_docker.sh similarity index 82% rename from build_native_blockifier.sh rename to build_native_blockifier_in_docker.sh index 8274992eda..a1989ad64b 100755 --- a/build_native_blockifier.sh +++ b/build_native_blockifier_in_docker.sh @@ -13,4 +13,4 @@ docker run \ -v "${HOME}:${HOME}" \ --workdir ${PWD} \ ${docker_image_name} \ - cargo build --release -p native_blockifier --features "testing" + scripts/build_native_blockifier.sh diff --git a/scripts/build_native_blockifier.sh b/scripts/build_native_blockifier.sh new file mode 100755 index 0000000000..db56e326c7 --- /dev/null +++ b/scripts/build_native_blockifier.sh @@ -0,0 +1,21 @@ +#!/bin/env bash +set -e + +function clean() { + echo "Cleaning up..." + deactivate || true + rm -rf venv || true +} + + +function build() { + echo "Building..." + pushd crates/native_blockifier + pypy3.9 -m venv venv + source venv/bin/activate + cargo build --release -p native_blockifier --features "testing" || clean + clean + popd +} + +build diff --git a/scripts/committer/generate_committer_flamegraph.sh b/scripts/committer/generate_committer_flamegraph.sh new file mode 100644 index 0000000000..d1d680595c --- /dev/null +++ b/scripts/committer/generate_committer_flamegraph.sh @@ -0,0 +1,27 @@ +set -e + +if [ "$GITHUB_ACTIONS" = true ]; then + echo "This script is not meant to be run in GitHub Actions." + exit 1 +fi + +# Restore security level in perf_event_paranoid at the end. +ORIGINAL_PARANOID=$(echo $(sysctl kernel.perf_event_paranoid) | grep -o '[0-9]$') +trap 'sudo sysctl kernel.perf_event_paranoid=$ORIGINAL_PARANOID' EXIT SIGINT SIGTERM + +if ! command -v jq; then + cargo install jq +fi +if ! command -v flamegraph; then + cargo install flamegraph +fi +if ! command -v perf; then + sudo apt-get install linux-tools-common linux-tools-generic linux-tools-`uname -r` +fi + +ROOT_DIR=$(git rev-parse --show-toplevel) +BENCH_INPUT_FILES_PREFIX=$(cat ${ROOT_DIR}/crates/committer_cli/src/tests/flow_test_files_prefix) +# Lower security level in perf_event_paranoid to 2 to allow cargo to use perf without running on root. +sudo sysctl kernel.perf_event_paranoid=2 + +gcloud storage cat gs://committer-testing-artifacts/${BENCH_INPUT_FILES_PREFIX}/committer_flow_inputs.json | jq -r .committer_input | CARGO_PROFILE_RELEASE_DEBUG=true cargo flamegraph -p committer_cli -- commit