Skip to content

Commit

Permalink
Add validate_and_check_DA_ID job to checks.yml (#1177)
Browse files Browse the repository at this point in the history
* Add validate_and_check_DA_ID job

* Try share build

* Fix path

* Use smaller instance
  • Loading branch information
jfldde authored Sep 16, 2024
1 parent af6584d commit b2a29b8
Showing 1 changed file with 171 additions and 43 deletions.
214 changes: 171 additions & 43 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,48 @@ concurrency:
cancel-in-progress: ${{ (github.ref != 'refs/heads/nightly') && (github.ref != 'refs/heads/devnet-freeze') && (github.ref != 'refs/heads/main') }}

jobs:
build:
name: build
runs-on: ubicloud-standard-16
timeout-minutes: 60
if: github.event.pull_request.draft == false
steps:
- uses: actions/checkout@v4
- uses: rui314/setup-mold@v1
- name: Install Protoc
uses: arduino/setup-protoc@v2
with:
version: "23.2"
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Toolchain
uses: dtolnay/rust-toolchain@nightly
with:
override: true
components: rustfmt, clippy
- name: Rust Cache
uses: Swatinem/rust-cache@v2
- name: Install cargo-risczero
uses: taiki-e/install-action@v2
with:
tool: [email protected]
- name: Install risc0-zkvm toolchain
run: cargo risczero install --version r0.1.79.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Build citrea
run: make build-release
env:
REPR_GUEST_BUILD: 1

- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: citrea-build
path: |
target/release/citrea
target/release/**/methods.rs
retention-days: 1

check:
name: check
runs-on: ubicloud-standard-16
Expand Down Expand Up @@ -184,34 +226,29 @@ jobs:

uniswap:
runs-on: ubicloud-standard-16
needs: build
if: github.event.pull_request.draft == false
steps:
- uses: actions/checkout@v4
- uses: dtolnay/[email protected]
- uses: actions/setup-node@v4
with:
node-version: 18
- name: Rust Cache
uses: Swatinem/rust-cache@v2
- uses: dcarbone/install-jq-action@v2
- name: Install cargo-risczero
uses: taiki-e/install-action@v2
- name: Download artifact
uses: actions/download-artifact@v3
with:
tool: [email protected]
- name: Install risc0-zkvm toolchain
run: cargo risczero install --version r0.1.79.0-2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Build citrea
run: make build
name: citrea-build
path: target/release
- name: Make citrea executable
run: chmod +x target/release/citrea
- name: Install node dependencies
working-directory: ./bin/citrea/tests/evm/uniswap
run: npm install
- name: Run uniswap tests
run: |
RUST_LOG=off ./target/debug/citrea --da-layer mock --rollup-config-path resources/configs/mock/sequencer_rollup_config.toml --sequencer-config-path resources/configs/mock/sequencer_config.toml --genesis-paths resources/genesis/mock/ &
RUST_LOG=off ./target/release/citrea --da-layer mock --rollup-config-path resources/configs/mock/sequencer_rollup_config.toml --sequencer-config-path resources/configs/mock/sequencer_config.toml --genesis-paths resources/genesis/mock/ &
sleep 2
RUST_LOG=off ./target/debug/citrea --rollup-config-path resources/configs/mock/rollup_config.toml --genesis-paths resources/genesis/mock/ &
RUST_LOG=off ./target/release/citrea --rollup-config-path resources/configs/mock/rollup_config.toml --genesis-paths resources/genesis/mock/ &
sleep 2
./resources/configs/mock-dockerized/publish_da_block.sh &
cd ./bin/citrea/tests/evm/uniswap
Expand All @@ -233,69 +270,58 @@ jobs:
web3_py:
runs-on: ubicloud-standard-16
needs: build
if: github.event.pull_request.draft == false
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
- uses: dtolnay/[email protected]
- uses: dcarbone/install-jq-action@v2
- name: Install cargo-risczero
uses: taiki-e/install-action@v2
with:
tool: [email protected]
- name: Install risc0-zkvm toolchain
run: cargo risczero install --version r0.1.79.0-2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/cache@v3
- name: Download artifact
uses: actions/download-artifact@v3
with:
key: ${{ runner.os }}-${{ github.job }}-${{ github.head_ref }}
path: ./target
- name: Build citrea
run: make build
name: citrea-build
path: target/release
- name: Make citrea executable
run: chmod +x target/release/citrea
- name: Install dependencies
working-directory: ./bin/citrea/tests/evm/web3_py
run: pip install -r requirements.txt
- name: Run web3.py tests
run: |
RUST_LOG=off ./target/debug/citrea --da-layer mock --rollup-config-path resources/configs/mock/sequencer_rollup_config.toml --sequencer-config-path resources/configs/mock/sequencer_config.toml --genesis-paths resources/genesis/mock/ &
RUST_LOG=off ./target/release/citrea --da-layer mock --rollup-config-path resources/configs/mock/sequencer_rollup_config.toml --sequencer-config-path resources/configs/mock/sequencer_config.toml --genesis-paths resources/genesis/mock/ &
sleep 2
RUST_LOG=off ./target/debug/citrea --da-layer mock --rollup-config-path resources/configs/mock/rollup_config.toml --genesis-paths resources/genesis/mock/ &
RUST_LOG=off ./target/release/citrea --da-layer mock --rollup-config-path resources/configs/mock/rollup_config.toml --genesis-paths resources/genesis/mock/ &
sleep 2
# ./resources/configs/mock-dockerized/publish_da_block.sh &
cd ./bin/citrea/tests/evm/web3_py
python test.py
ethers_js:
runs-on: ubicloud-standard-16
needs: build
if: github.event.pull_request.draft == false
steps:
- uses: actions/checkout@v4
- uses: dtolnay/[email protected]
- uses: actions/setup-node@v4
with:
node-version: 18
- name: Rust Cache
uses: Swatinem/rust-cache@v2
- uses: dcarbone/install-jq-action@v2
- name: Install cargo-risczero
uses: taiki-e/install-action@v2
- name: Download artifact
uses: actions/download-artifact@v3
with:
tool: [email protected]
- name: Install risc0-zkvm toolchain
run: cargo risczero install --version r0.1.79.0-2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Build citrea
run: make build
name: citrea-build
path: target/release
- name: Make citrea executable
run: chmod +x target/release/citrea
- name: Install node dependencies
working-directory: ./bin/citrea/tests/evm/ethers_js
run: npm install
- name: Run ethers_js tests
run: |
RUST_LOG=off ./target/debug/citrea --da-layer mock --rollup-config-path resources/configs/mock/sequencer_rollup_config.toml --sequencer-config-path resources/configs/mock/sequencer_config.toml --genesis-paths resources/genesis/mock/ &
RUST_LOG=off ./target/release/citrea --da-layer mock --rollup-config-path resources/configs/mock/sequencer_rollup_config.toml --sequencer-config-path resources/configs/mock/sequencer_config.toml --genesis-paths resources/genesis/mock/ &
sleep 2
RUST_LOG=off ./target/debug/citrea --da-layer mock --rollup-config-path resources/configs/mock/rollup_config.toml --genesis-paths resources/genesis/mock/ &
RUST_LOG=off ./target/release/citrea --da-layer mock --rollup-config-path resources/configs/mock/rollup_config.toml --genesis-paths resources/genesis/mock/ &
sleep 2
./resources/configs/mock-dockerized/publish_da_block.sh &
cd ./bin/citrea/tests/evm/ethers_js
Expand Down Expand Up @@ -424,3 +450,105 @@ jobs:
- name: Run check_genesis.sh
run: ./.github/scripts/check_genesis.sh
shell: bash

validate_and_check_DA_ID:
runs-on: ubicloud-standard-2
needs: build
env:
EXPECTED_BITCOIN_DA_ID: ${{ vars.EXPECTED_BITCOIN_DA_ID }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Validate EXPECTED_BITCOIN_DA_ID format
run: |
echo "Raw EXPECTED_BITCOIN_DA_ID value:"
echo "$EXPECTED_BITCOIN_DA_ID"
echo "Length of EXPECTED_BITCOIN_DA_ID: ${#EXPECTED_BITCOIN_DA_ID}"
if [ -z "${EXPECTED_BITCOIN_DA_ID// }" ]; then
echo "Error: EXPECTED_BITCOIN_DA_ID is not set, empty, or contains only spaces"
exit 1
fi
# Remove any trailing newline or carriage return
EXPECTED_BITCOIN_DA_ID=$(echo "$EXPECTED_BITCOIN_DA_ID" | tr -d '\n\r')
# Count commas and spaces
comma_count=$(echo "$EXPECTED_BITCOIN_DA_ID" | tr -cd ',' | wc -c)
space_count=$(echo "$EXPECTED_BITCOIN_DA_ID" | tr -cd ' ' | wc -c)
echo "Number of commas: $comma_count"
echo "Number of spaces: $space_count"
# Split the string into an array and trim each element
IFS=', ' read -ra raw_numbers <<< "$EXPECTED_BITCOIN_DA_ID"
numbers=()
for num in "${raw_numbers[@]}"; do
trimmed_num=$(echo "$num" | tr -d '[:space:]') # Remove all whitespace
numbers+=("$trimmed_num")
done
echo "Number of elements after splitting and trimming: ${#numbers[@]}"
# Check if there are exactly 8 numbers
if [ ${#numbers[@]} -ne 8 ]; then
echo "Error: EXPECTED_BITCOIN_DA_ID should contain exactly 8 numbers"
echo "Actual number of elements: ${#numbers[@]}"
exit 1
fi
# Check if all numbers are valid u32
for i in "${!numbers[@]}"; do
num=${numbers[$i]}
echo "Checking number $((i+1)): '$num'"
echo "Hex representation: $(echo -n "$num" | xxd -p)"
if ! [[ $num =~ ^[0-9]+$ ]]; then
echo "Error: '$num' is not composed of digits only"
exit 1
fi
if [ $num -gt 4294967295 ]; then
echo "Error: '$num' is greater than 4294967295"
exit 1
fi
done
# Reconstruct the trimmed DA_ID
trimmed_da_id=$(IFS=', '; echo "${numbers[*]}")
# Final check
if [ $comma_count -eq 7 ] && [ $space_count -eq 7 ] && [ ${#numbers[@]} -eq 8 ]; then
echo "EXPECTED_BITCOIN_DA_ID is valid:"
echo "- Contains 7 commas"
echo "- Contains 7 spaces"
echo "- Contains 8 valid u32 numbers"
echo "Original value: $EXPECTED_BITCOIN_DA_ID"
echo "Trimmed value: $trimmed_da_id"
else
echo "Error: EXPECTED_BITCOIN_DA_ID format is incorrect"
echo "- Comma count: $comma_count (should be 7)"
echo "- Space count: $space_count (should be 7)"
echo "- Number count: ${#numbers[@]} (should be 8)"
exit 1
fi
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: citrea-build
path: target/release

- name: Check BITCOIN_DA_ID
id: check-id
run: |
RESULT=$(grep -R "BITCOIN_DA_ID" target/ || echo "Grep failed")
EXPECTED_BITCOIN_DA_ID=$(echo "${{ env.EXPECTED_BITCOIN_DA_ID }}" | tr -d '\n\r')
if echo "$RESULT" | grep -q "$EXPECTED_BITCOIN_DA_ID"; then
echo "Check passed successfully."
echo "Expected: BITCOIN_DA_ID ${{ env.EXPECTED_BITCOIN_DA_ID }} "
echo "Actual: $RESULT"
else
echo "Check failed. Expected: BITCOIN_DA_ID ${{ env.EXPECTED_BITCOIN_DA_ID }} "
echo "Actual: $RESULT"
exit 1
fi

0 comments on commit b2a29b8

Please sign in to comment.