-
Notifications
You must be signed in to change notification settings - Fork 44
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
Add daily block execution #888
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
74316dd
Add install linux deps action
JulianGCalderon f07eff6
Add daily workflow
JulianGCalderon cc6a9ce
Remove fail-fast from workflow
JulianGCalderon b9b4f7d
Remove cargo update
JulianGCalderon cd2e9ff
Update comment
JulianGCalderon 4171eff
Patch sequencer also
JulianGCalderon d1bc941
Fix patch
JulianGCalderon 1f6e59c
Remove match message
JulianGCalderon a6ff096
Increase range size
JulianGCalderon 845a53a
Fix patch (remove sequencer)
JulianGCalderon 98d0f7d
Have native in another directory
JulianGCalderon 22a73e8
Path sequencer
JulianGCalderon 0962e04
Fix path
JulianGCalderon c6fae89
Rename comment
JulianGCalderon 2bffa15
Add continue on error
JulianGCalderon 5c66346
Prepare for merge
JulianGCalderon 30e8024
Merge branch 'main' into add-green-check
JulianGCalderon 6bfa6c5
Merge branch 'main' into add-green-check
JulianGCalderon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,36 @@ | ||
name: 'Install Linux Dependencies' | ||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Free HDD space | ||
shell: bash | ||
run: | | ||
echo "Listing 20 largest packages" | ||
dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -n | tail -n 20 | ||
df -h | ||
sudo apt-get update | ||
sudo apt-get remove -y '^llvm-.*' | ||
sudo apt-get remove -y 'php.*' | ||
sudo apt-get remove -y '^dotnet-.*' | ||
sudo apt-get remove -y '^temurin-.*' | ||
sudo apt-get remove -y azure-cli google-cloud-cli microsoft-edge-stable google-chrome-stable firefox powershell mono-devel | ||
sudo apt-get autoremove -y | ||
sudo apt-get clean | ||
df -h | ||
echo "Removing large directories" | ||
# deleting 15GB | ||
sudo rm -rf /usr/share/dotnet/ | ||
sudo rm -rf /usr/local/lib/android | ||
df -h | ||
- name: Add LLVM Debian repository | ||
uses: myci-actions/add-deb-repo@11 | ||
with: | ||
repo: deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-19 main | ||
repo-name: llvm-repo | ||
keys-asc: https://apt.llvm.org/llvm-snapshot.gpg.key | ||
- name: Update and upgrade APT | ||
shell: bash | ||
run: sudo apt-get update && sudo apt-get upgrade -y | ||
- name: Install LLVM | ||
shell: bash | ||
run: sudo apt-get install llvm-19 llvm-19-dev llvm-19-runtime clang-19 clang-tools-19 lld-19 libpolly-19-dev libmlir-19-dev mlir-19-tools |
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,95 @@ | ||
name: Daily Block Run | ||
|
||
on: | ||
schedule: | ||
# At the end of every day | ||
- cron: "0 0 * * *" | ||
|
||
env: | ||
RANGE_SIZE: 50 | ||
SEQUENCER_REV: 1b1b95cae7ae07b9bc778443ca75ee18008a6bc8 | ||
|
||
jobs: | ||
run-and-compare: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 1440 | ||
env: | ||
LLVM_SYS_191_PREFIX: /usr/lib/llvm-19/ | ||
MLIR_SYS_190_PREFIX: /usr/lib/llvm-19/ | ||
TABLEGEN_190_PREFIX: /usr/lib/llvm-19/ | ||
RPC_ENDPOINT_TESTNET: ${{ secrets.RPC_ENDPOINT_TESTNET }} | ||
RPC_ENDPOINT_MAINNET: ${{ secrets.RPC_ENDPOINT_MAINNET }} | ||
strategy: | ||
matrix: | ||
block: | ||
- 740000 | ||
- 741000 | ||
- 742000 | ||
- 743000 | ||
- 744000 | ||
- 745000 | ||
- 746000 | ||
- 747000 | ||
- 748000 | ||
- 749000 | ||
fail-fast: false | ||
defaults: | ||
run: | ||
shell: bash | ||
working-directory: ./starknet-replay | ||
|
||
steps: | ||
# We checkout replay first, as it's the main repository for this workflow | ||
- name: Checkout Replay | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: lambdaclass/starknet-replay | ||
path: starknet-replay | ||
# We need native for building the runtime | ||
- name: Checkout Native | ||
uses: actions/checkout@v4 | ||
with: | ||
path: cairo_native | ||
|
||
# Install dependencies | ||
- uses: ./cairo_native/.github/actions/install-linux-deps | ||
- name: Setup rust env | ||
uses: dtolnay/[email protected] | ||
- name: Retreive cached dependecies | ||
uses: Swatinem/rust-cache@v2 | ||
- name: Build Cairo Native Runtime Library | ||
shell: bash | ||
run: | | ||
cd ../cairo_native | ||
make runtime | ||
echo "CAIRO_NATIVE_RUNTIME_LIBRARY=$(pwd)/libcairo_native_runtime.a" > $GITHUB_ENV | ||
|
||
- name: Patch dependencies | ||
run: | | ||
# Patches native dependency to local path, to use current cairo native version | ||
DEPENDENCY="cairo-native" | ||
NEW_PATH="../cairo_native" | ||
sed -Ei "s#^($DEPENDENCY *=).*#\1 { path = '$NEW_PATH' }#" Cargo.toml | ||
grep $DEPENDENCY Cargo.toml | ||
|
||
# Patches sequencer dependency to specified rev | ||
GIT="https://github.com/lambdaclass/sequencer" | ||
NEW_REV="$SEQUENCER_REV" | ||
sed -Ei "s#(\"$GIT\" *, *rev *= *\").?*(\".*)#\1$NEW_REV\2#" Cargo.toml | ||
grep $GIT Cargo.toml | ||
|
||
- name: Run with Native | ||
run: | | ||
BLOCK_START=${{ matrix.block }} | ||
BLOCK_END=$(($BLOCK_START + $RANGE_SIZE - 1)) | ||
cargo run --release --features state_dump block-range $BLOCK_START $BLOCK_END mainnet | ||
continue-on-error: true | ||
- name: Run with VM | ||
run: | | ||
BLOCK_START=${{ matrix.block }} | ||
BLOCK_END=$(($BLOCK_START + $RANGE_SIZE - 1)) | ||
cargo run --release --features state_dump,only_cairo_vm block-range $BLOCK_START $BLOCK_END mainnet | ||
continue-on-error: true | ||
|
||
- name: Compare states | ||
run: ../cairo_native/scripts/cmp_state_dumps.sh |
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 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Compares state dump files between two directories: 'state_dumps/vm' and 'state_dumps/native'. | ||
# It iterates over all JSON files in the 'state_dumps/vm' directory and checks if the corresponding | ||
# file exists in 'state_dumps/native'. | ||
# If the corresponding file does not exist, it skips the comparison and counts the missing files. | ||
# For existing pairs, it compares the contents, ignoring the lines containing the "reverted" field, because of error message diference in Native and VM. | ||
# It counts and displays the number of matching, differing, and missing state dumps. | ||
|
||
matching=0 | ||
diffing=0 | ||
missing=0 | ||
|
||
# Iterate over state_dumps/vm dumps | ||
for vm_dump in state_dumps/vm/*/*.json; do | ||
[ -f "$vm_dump" ] || continue | ||
|
||
native_dump="${vm_dump//vm/native}" | ||
|
||
# Check if the corresponding native_dump file exists, if not, skip | ||
if [ ! -f "$native_dump" ]; then | ||
echo "Missing: $native_dump (file not found)" | ||
missing=$((missing+1)) | ||
continue | ||
fi | ||
|
||
base=$(basename "$vm_dump") | ||
|
||
if ! cmp -s \ | ||
<(sed '/"reverted": /d' "$native_dump") \ | ||
<(sed '/"reverted": /d' "$vm_dump") | ||
then | ||
echo "diff: $base" | ||
diffing=$((diffing+1)) | ||
else | ||
matching=$((matching+1)) | ||
fi | ||
done | ||
|
||
echo | ||
echo "Finished comparison" | ||
echo "- Matching: $matching" | ||
echo "- Diffing: $diffing" | ||
echo "- Missing: $missing" | ||
|
||
if ! [[ $diffing -eq 0 && $missing -eq 0 ]] ; then | ||
exit 1 | ||
fi |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is meant to be run during night, I don't really know if this could make a significant impact on the time it takes to complete the ci once we increased the amount of blocks to execute. But it might be a good idea to run both native and the vm at the same time to reduce the execution time, right?.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I considered it, but I think is not that simple. As I understand it, we have two possible approaches:
The first approach (used in the
starknet-blocks
workflow) is to have two separate jobs, one uses a matrix to execute different blocks with native and VM, then uploads an artifact with the state dumps. Another job depends on the first one, retreives the artifact, and compares the states.The downside with this approach is that if one of the executions fails, then the
compare
job is never ran. This is not desirable, as an RPC error is pretty common when running so many blocks, and would cancel the whole daily execution. There might be a way to work around this, but I don't know how.This is why I opted for a different approach. Use a matrix, but each job in the matrix is complete and independent from the other ones. A failure in one execution would not cancel the other ones, as they are completely separate. The comparison would not have to wait for the whole execution, as each subcomparison could start as soon as the corresponding execution finishes.
The downside of this is that we cannot run VM and Native at the same time, but I don't think that it matters to much, as we can always increase the amount of jobs in the matrix if we want more parallelism.