diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9008231450..99e4a407e3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -34,13 +34,13 @@ jobs: - name: Add Rust Cache uses: Swatinem/rust-cache@v2 with: - shared-key: rust-build + shared-key: rust-release prefix-key: ${{ env.RUST_CACHE_KEY }} save-if: ${{ github.ref == 'refs/heads/next' }} - name: make - build run: make build build-wasm: - name: Build Client for wasm + name: Build Client for Wasm runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v6 @@ -48,11 +48,5 @@ jobs: run: rustup update --no-self-update - name: Add wasm32-unknown-unknown target run: rustup target add wasm32-unknown-unknown - - name: Add Rust Cache - uses: Swatinem/rust-cache@v2 - with: - shared-key: rust-build-wasm - prefix-key: ${{ env.RUST_CACHE_KEY }} - save-if: ${{ github.ref == 'refs/heads/next' }} - name: make - build-wasm run: make build-wasm diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index cdf5c6110b..57f36d03d8 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -12,11 +12,10 @@ concurrency: env: CARGO_PROFILE_DEV_DEBUG: 0 - RUST_CACHE_KEY: rust-cache-2026.02.18 jobs: unused_deps: - name: check for unused dependencies + name: Check for unused dependencies runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v6 @@ -24,7 +23,7 @@ jobs: uses: bnjbvr/cargo-machete@main typos: - name: spellcheck + name: Spellcheck runs-on: ubuntu-24.04 timeout-minutes: 5 steps: @@ -35,7 +34,7 @@ jobs: - run: make typos-check toml: - name: toml formatting + name: Toml formatting runs-on: ubuntu-24.04 timeout-minutes: 5 steps: @@ -46,14 +45,14 @@ jobs: - run: make toml-check eslint: - name: "Typescript eslint checks" + name: Typescript eslint checks runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v6 - run: make rust-client-ts-lint react-sdk-lint: - name: "React SDK lint and typecheck" + name: React SDK lint and typecheck runs-on: ubuntu-24.04 needs: [wasm-bindgen-types] steps: @@ -85,12 +84,6 @@ jobs: run: | rustup update --no-self-update rustup component add clippy - - name: Add Rust Cache - uses: Swatinem/rust-cache@v2 - with: - shared-key: rust-build - prefix-key: ${{ env.RUST_CACHE_KEY }} - save-if: ${{ github.ref == 'refs/heads/next' }} - name: make - clippy run: make clippy @@ -104,17 +97,11 @@ jobs: rustup update --no-self-update rustup target add wasm32-unknown-unknown rustup component add clippy - - name: Add Rust Cache - uses: Swatinem/rust-cache@v2 - with: - shared-key: rust-build-wasm - prefix-key: ${{ env.RUST_CACHE_KEY }} - save-if: ${{ github.ref == 'refs/heads/next' }} - name: make - clippy-wasm run: make clippy-wasm format: - name: format check + name: Format check runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v6 @@ -122,19 +109,13 @@ jobs: run: | rustup update --no-self-update nightly rustup +nightly component add rustfmt - - name: Add Rust Cache - uses: Swatinem/rust-cache@v2 - with: - shared-key: rust-build - prefix-key: ${{ env.RUST_CACHE_KEY }} - save-if: ${{ github.ref == 'refs/heads/next' }} - name: Install prettier run: yarn install - name: make - format-check run: make format-check wasm-bindgen-types: - name: wasm bindgen types + name: Wasm bindgen types runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v6 @@ -150,12 +131,6 @@ jobs: run: | rustup update --no-self-update rustup target add wasm32-unknown-unknown - - name: Add Rust Cache - uses: Swatinem/rust-cache@v2 - with: - shared-key: rust-build-wasm - prefix-key: ${{ env.RUST_CACHE_KEY }} - save-if: ${{ github.ref == 'refs/heads/next' }} - name: Install dependencies working-directory: crates/web-client run: yarn install --frozen-lockfile @@ -172,17 +147,11 @@ jobs: path: ./crates/web-client/dist rustdocs: - name: build rust documentation + name: Build rust documentation runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v6 - name: Install Rust run: rustup update --no-self-update - - name: Add Rust Cache - uses: Swatinem/rust-cache@v2 - with: - shared-key: rust-build - prefix-key: ${{ env.RUST_CACHE_KEY }} - save-if: ${{ github.ref == 'refs/heads/next' }} - name: make - doc run: make doc diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 22689fdb18..892511a13c 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -14,7 +14,7 @@ permissions: jobs: # Run tests on the beta channel to provide feedback for Rust team. beta-test: - name: test on beta channel + name: Test on beta channel runs-on: ubuntu-24.04 timeout-minutes: 30 steps: @@ -32,7 +32,7 @@ jobs: # Check that our MSRV complies with our specified rust version. # Each workspace package is verified independently via a matrix for clear per-package errors. workspace-packages: - name: list packages + name: List packages runs-on: ubuntu-24.04 outputs: packages: ${{ steps.package-matrix.outputs.packages }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1064cc54c0..4902e70318 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -25,7 +25,7 @@ env: jobs: test: - name: Test Rust + name: Unit tests runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v6 @@ -34,9 +34,9 @@ jobs: - name: Add Rust Cache uses: Swatinem/rust-cache@v2 with: - shared-key: rust-build + shared-key: rust-release prefix-key: ${{ env.RUST_CACHE_KEY }} - save-if: ${{ github.ref == 'refs/heads/next' }} + save-if: false - uses: taiki-e/install-action@v2 with: tool: nextest@0.9.122 @@ -44,22 +44,17 @@ jobs: run: make test doc-tests: - name: doc-tests + name: Documentation tests runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v6 - - uses: Swatinem/rust-cache@v2 - with: - shared-key: rust-build - prefix-key: ${{ env.RUST_CACHE_KEY }} - save-if: ${{ github.ref == 'refs/heads/next' }} - name: Install rust run: rustup update --no-self-update - name: Run doc-tests run: make test-docs test-react-sdk: - name: Test React SDK + name: React SDK tests runs-on: ubuntu-24.04 needs: [build-web-client-dist-folder] steps: @@ -120,9 +115,73 @@ jobs: - name: Build React SDK run: cd ./packages/react-sdk && yarn build + build-node-builder: + name: Build node-builder + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v6 + - name: Install Rust + run: rustup update --no-self-update + - name: Add Rust Cache + uses: Swatinem/rust-cache@v2 + with: + shared-key: rust-release + prefix-key: ${{ env.RUST_CACHE_KEY }} + save-if: false + - name: Restore node-builder binary + id: cache-node-builder + uses: actions/cache@v4 + with: + path: target/release/testing-node-builder + key: ${{ runner.os }}-node-builder-${{ hashFiles('Cargo.lock') }} + - name: Build node-builder + if: steps.cache-node-builder.outputs.cache-hit != 'true' + run: cargo build --release --package node-builder --locked + + build-note-transport: + name: Build note-transport + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v6 + - name: Install Rust + run: rustup update --no-self-update + - name: Restore note-transport binary + id: cache-note-transport + uses: actions/cache@v4 + with: + path: ~/.cargo/bin/miden-note-transport-node-bin + key: ${{ runner.os }}-note-transport-${{ hashFiles('Cargo.lock') }} + - name: Install note-transport + if: steps.cache-note-transport.outputs.cache-hit != 'true' + run: cargo install --git https://github.com/0xMiden/miden-note-transport --locked + + build-remote-prover: + name: Build remote-prover + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v6 + - name: Install Rust + run: rustup update --no-self-update + - name: Add Rust Cache + uses: Swatinem/rust-cache@v2 + with: + shared-key: rust-release + prefix-key: ${{ env.RUST_CACHE_KEY }} + save-if: false + - name: Restore remote-prover binary + id: cache-remote-prover + uses: actions/cache@v4 + with: + path: target/release/testing-remote-prover + key: ${{ runner.os }}-prover-${{ hashFiles('Cargo.lock') }} + - name: Build remote-prover + if: steps.cache-remote-prover.outputs.cache-hit != 'true' + run: cargo build --release --package testing-remote-prover --locked + integration-tests: - name: Run integration tests + name: Integration tests runs-on: ubuntu-24.04 + needs: [build-node-builder, build-note-transport] steps: - uses: actions/checkout@v6 - name: Install Rust @@ -133,23 +192,37 @@ jobs: - name: Add Rust Cache uses: Swatinem/rust-cache@v2 with: - shared-key: rust-build + shared-key: rust-release prefix-key: ${{ env.RUST_CACHE_KEY }} - save-if: ${{ github.ref == 'refs/heads/next' }} + save-if: false + - name: Restore node-builder binary + uses: actions/cache/restore@v4 + with: + path: target/release/testing-node-builder + key: ${{ runner.os }}-node-builder-${{ hashFiles('Cargo.lock') }} + - name: Restore note-transport binary + uses: actions/cache/restore@v4 + with: + path: ~/.cargo/bin/miden-note-transport-node-bin + key: ${{ runner.os }}-note-transport-${{ hashFiles('Cargo.lock') }} - name: Start test node - run: make start-node-background + run: | + RUST_LOG=none target/release/testing-node-builder & + sleep 4 + pgrep -f testing-node-builder || (echo "Failed to start node" && exit 1) - name: Start note transport - run: make start-note-transport-background + run: | + RUST_LOG=none miden-note-transport-node-bin & + sleep 4 + pgrep -f miden-note-transport-node-bin || (echo "Failed to start note transport" && exit 1) - name: Run integration tests run: make integration-test-full - name: Stop test node if: always() - run: | - make stop-node + run: make stop-node - name: Stop note transport if: always() - run: | - make stop-note-transport + run: make stop-note-transport build-web-client-dist-folder: name: Build Web Client @@ -160,11 +233,10 @@ jobs: run: | rustup update --no-self-update rustup target add wasm32-unknown-unknown - - name: Add Rust Cache uses: Swatinem/rust-cache@v2 with: - shared-key: rust-build-wasm + shared-key: rust-wasm prefix-key: ${{ env.RUST_CACHE_KEY }} save-if: ${{ github.ref == 'refs/heads/next' }} @@ -191,7 +263,7 @@ jobs: uses: actions/cache/restore@v4 with: path: ./crates/web-client/dist - key: ${{ runner.os }}-dist-${{ hashFiles('**/yarn.lock', './crates/web-client/src/**/*.ts', './crates/web-client/pkg/**/*.wasm') }} + key: ${{ runner.os }}-dist-${{ hashFiles('**/yarn.lock', './crates/web-client/src/**/*.ts', './crates/web-client/src/**/*.rs', 'Cargo.lock') }} restore-keys: ${{ runner.os }}-dist- - name: Build project @@ -214,9 +286,9 @@ jobs: path: ./crates/web-client/dist integration-tests-web-client: - name: Run integration tests for web client + name: Integration tests for web client runs-on: ubuntu-24.04 - needs: [ build-web-client-dist-folder ] + needs: [build-web-client-dist-folder, build-node-builder] strategy: matrix: shard_index: [1, 2, 3, 4, 5, 6] @@ -227,12 +299,18 @@ jobs: run: | rustup update --no-self-update rustup target add wasm32-unknown-unknown + - name: Add Rust Cache + uses: Swatinem/rust-cache@v2 + with: + shared-key: rust-wasm + prefix-key: ${{ env.RUST_CACHE_KEY }} + save-if: false - name: Fetch dist folder uses: actions/download-artifact@v4 with: name: web-client-artifacts - path: ./crates/web-client + path: ./crates/web-client/dist - name: Install Node.js uses: actions/setup-node@v4 @@ -240,14 +318,16 @@ jobs: node-version: "20" - name: Configure setuid sandbox run: . ./scripts/configure-sandbox.sh - - name: Add Rust Cache - uses: Swatinem/rust-cache@v2 + - name: Restore node-builder binary + uses: actions/cache/restore@v4 with: - shared-key: rust-build - prefix-key: ${{ env.RUST_CACHE_KEY }} - save-if: ${{ github.ref == 'refs/heads/next' }} + path: target/release/testing-node-builder + key: ${{ runner.os }}-node-builder-${{ hashFiles('Cargo.lock') }} - name: Start test node - run: make start-node-background + run: | + RUST_LOG=none target/release/testing-node-builder & + sleep 4 + pgrep -f testing-node-builder || (echo "Failed to start node" && exit 1) - name: Run web client tests run: | make integration-test-web-client @@ -258,15 +338,21 @@ jobs: run: make stop-node integration-tests-remote-prover-web-client: - name: Run integration tests for remote prover + name: Integration tests for remote prover runs-on: ubuntu-24.04 - needs: [ build-web-client-dist-folder ] + needs: [build-web-client-dist-folder, build-node-builder, build-remote-prover] steps: - uses: actions/checkout@v6 - name: Install Rust run: | rustup update --no-self-update rustup target add wasm32-unknown-unknown + - name: Add Rust Cache + uses: Swatinem/rust-cache@v2 + with: + shared-key: rust-wasm + prefix-key: ${{ env.RUST_CACHE_KEY }} + save-if: false - name: Install Node.js uses: actions/setup-node@v4 with: @@ -276,20 +362,30 @@ jobs: uses: actions/download-artifact@v4 with: name: web-client-artifacts - path: ./crates/web-client + path: ./crates/web-client/dist - name: Configure setuid sandbox run: . ./scripts/configure-sandbox.sh - - name: Add Rust Cache - uses: Swatinem/rust-cache@v2 + - name: Restore node-builder binary + uses: actions/cache/restore@v4 with: - shared-key: rust-build - prefix-key: ${{ env.RUST_CACHE_KEY }} - save-if: ${{ github.ref == 'refs/heads/next' }} + path: target/release/testing-node-builder + key: ${{ runner.os }}-node-builder-${{ hashFiles('Cargo.lock') }} + - name: Restore remote-prover binary + uses: actions/cache/restore@v4 + with: + path: target/release/testing-remote-prover + key: ${{ runner.os }}-prover-${{ hashFiles('Cargo.lock') }} - name: Start test node - run: make start-node-background + run: | + RUST_LOG=none target/release/testing-node-builder & + sleep 4 + pgrep -f testing-node-builder || (echo "Failed to start node" && exit 1) - name: Start prover - run: make start-prover-background + run: | + RUST_LOG=none target/release/testing-remote-prover & + sleep 4 + pgrep -f testing-remote-prover || (echo "Failed to start prover" && exit 1) - name: Run remote prover tests run: make integration-test-remote-prover-web-client - name: Stop test node diff --git a/.github/workflows/wallet-pages.yml b/.github/workflows/wallet-pages.yml index 0fb269b829..c67424769c 100644 --- a/.github/workflows/wallet-pages.yml +++ b/.github/workflows/wallet-pages.yml @@ -19,7 +19,6 @@ jobs: node-version: "20" cache: yarn cache-dependency-path: | - yarn.lock packages/react-sdk/yarn.lock packages/react-sdk/examples/wallet/yarn.lock - name: Install root dependencies diff --git a/crates/rust-client/src/rpc/domain/account.rs b/crates/rust-client/src/rpc/domain/account.rs index f70ee92944..cc1b609787 100644 --- a/crates/rust-client/src/rpc/domain/account.rs +++ b/crates/rust-client/src/rpc/domain/account.rs @@ -671,8 +671,7 @@ impl From for Vec Vec { - use account_detail_request; - use account_detail_request::storage_map_detail_request; + use account_detail_request::{self, storage_map_detail_request}; let request_map = value.0; let mut requests = Vec::with_capacity(request_map.len()); for (slot_name, _map_keys) in request_map { diff --git a/scripts/start-note-transport-bg.sh b/scripts/start-note-transport-bg.sh index 8d87cfc667..9e812df274 100755 --- a/scripts/start-note-transport-bg.sh +++ b/scripts/start-note-transport-bg.sh @@ -1,43 +1,21 @@ #!/bin/bash -# Starts the external Note Transport service in the background. -# - Default: clones/updates the note transport repo and runs it via cargo +# Starts the Note Transport service in the background. +# Installs it via cargo install if not already available. set -euo pipefail -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" - -# NOTE: This should be in line with `miden-note-transport-proto-build`'s version in Cargo.toml -BRANCH=${TRANSPORT_BRANCH:-main} - -TRANSPORT_DIR=${TRANSPORT_DIR:-.tmp/miden-note-transport} REPO_URL=${REPO_URL:-https://github.com/0xMiden/miden-note-transport} -RUN_CMD=${TRANSPORT_RUN_CMD:-cargo run --release --locked} - -# Shared target directory (important for CI speed: ends up under repo `target/` which is cached) -TRANSPORT_CARGO_TARGET_DIR=${TRANSPORT_CARGO_TARGET_DIR:-"$REPO_ROOT/target/note-transport"} - +BINARY_NAME=miden-note-transport-node-bin PID_FILE=.note-transport.pid -mkdir -p "$(dirname "$TRANSPORT_DIR")" -mkdir -p "$TRANSPORT_CARGO_TARGET_DIR" - -if [ ! -d "$TRANSPORT_DIR/.git" ]; then - echo "Cloning note transport repo (branch: $BRANCH) into $TRANSPORT_DIR"; - git clone --depth=1 -b "$BRANCH" "$REPO_URL" "$TRANSPORT_DIR" -else - echo "Updating note transport repo in $TRANSPORT_DIR (branch: $BRANCH)"; - git -C "$TRANSPORT_DIR" fetch --prune origin "$BRANCH" - git -C "$TRANSPORT_DIR" checkout "$BRANCH" - git -C "$TRANSPORT_DIR" reset --hard "origin/$BRANCH" +if ! command -v "$BINARY_NAME" &>/dev/null; then + echo "Installing note transport service..." + cargo install --git "$REPO_URL" --locked fi -echo "Building note transport service..." -( cd "$TRANSPORT_DIR" && CARGO_TARGET_DIR="$TRANSPORT_CARGO_TARGET_DIR" cargo build --release --locked ) - echo "Starting note transport service in background..." -( cd "$TRANSPORT_DIR" && RUST_LOG=info CARGO_TARGET_DIR="$TRANSPORT_CARGO_TARGET_DIR" $RUN_CMD ) & echo $! > "$PID_FILE" +RUST_LOG=info "$BINARY_NAME" & echo $! > "$PID_FILE" sleep 4 @@ -61,4 +39,3 @@ if ! ps -p "$PID" > /dev/null 2>&1; then fi echo "Note transport service started (pid $PID)" - diff --git a/scripts/start-note-transport.sh b/scripts/start-note-transport.sh index 9b3ddc8e66..33ad305130 100755 --- a/scripts/start-note-transport.sh +++ b/scripts/start-note-transport.sh @@ -1,39 +1,17 @@ #!/bin/bash -# Starts the external Note Transport service in the foreground. -# - Default: clones/updates the note transport repo and runs it via cargo +# Starts the Note Transport service in the foreground. +# Installs it via cargo install if not already available. set -euo pipefail -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" - -# NOTE: This should be in line with `miden-note-transport-proto-build`'s version in Cargo.toml -BRANCH=${TRANSPORT_BRANCH:-main} - -TRANSPORT_DIR=${TRANSPORT_DIR:-.tmp/miden-note-transport} REPO_URL=${REPO_URL:-https://github.com/0xMiden/miden-note-transport} -RUN_CMD=${TRANSPORT_RUN_CMD:-cargo run --release --locked} - -# Shared target directory (important for CI speed: ends up under repo `target/` which is cached) -TRANSPORT_CARGO_TARGET_DIR=${TRANSPORT_CARGO_TARGET_DIR:-"$REPO_ROOT/target/note-transport"} +BINARY_NAME=miden-note-transport-node-bin -mkdir -p "$(dirname "$TRANSPORT_DIR")" -mkdir -p "$TRANSPORT_CARGO_TARGET_DIR" - -if [ ! -d "$TRANSPORT_DIR/.git" ]; then - echo "Cloning note transport repo (branch: $BRANCH) into $TRANSPORT_DIR"; - git clone --depth=1 -b "$BRANCH" "$REPO_URL" "$TRANSPORT_DIR" -else - echo "Updating note transport repo in $TRANSPORT_DIR (branch: $BRANCH)"; - git -C "$TRANSPORT_DIR" fetch --prune origin "$BRANCH" - git -C "$TRANSPORT_DIR" checkout "$BRANCH" - git -C "$TRANSPORT_DIR" reset --hard "origin/$BRANCH" +if ! command -v "$BINARY_NAME" &>/dev/null; then + echo "Installing note transport service..." + cargo install --git "$REPO_URL" --locked fi -echo "Building note transport service..." -( cd "$TRANSPORT_DIR" && CARGO_TARGET_DIR="$TRANSPORT_CARGO_TARGET_DIR" cargo build --release --locked ) - echo "Starting note transport service in foreground..." -cd "$TRANSPORT_DIR" -RUST_LOG=info CARGO_TARGET_DIR="$TRANSPORT_CARGO_TARGET_DIR" exec $RUN_CMD +RUST_LOG=info exec "$BINARY_NAME"