Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,17 @@ MN_MNEMONIC=""

# Alternative to MN_MNEMONIC: raw hex seed.
MN_SEED=

# Optional path to an existing private wallet env file. The v2 stagenet
# deployer accepts MN_SEED/MN_MNEMONIC in that file and maps WALLET_SEED to
# MN_SEED. The file is read locally and never copied or printed.
MN_WALLET_ENV_FILE=

# Required by the v2 stagenet deployer: absolute path to a durable private
# maintenance signing-key file. The deployer creates/reuses it at mode 0600
# before wallet startup. Back it up; never commit or print its contents.
MN_MAINTENANCE_KEY_FILE=

# Optional v2 wallet synchronization timeout in milliseconds. The deployer
# defaults to 300000 and accepts values from 30000 through 900000.
MN_WALLET_SYNC_TIMEOUT_MS=
111 changes: 90 additions & 21 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,16 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: read

env:
COMPACT_VERSION: '0.31.1'
COMPACT_V1_VERSION: '0.31.1'
COMPACT_V2_VERSION: '0.34.0'

jobs:
unit:
name: Unit tests (simulator)
unit-v1:
name: Unit tests (v1 simulator)
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
Expand All @@ -30,7 +34,7 @@ jobs:
- name: Setup Compact compiler
uses: midnightntwrk/setup-compact-action@b622629bee2c06d0f8b4db5b62a93f98dcbd41bf
with:
compact-version: ${{ env.COMPACT_VERSION }}
compact-version: ${{ env.COMPACT_V1_VERSION }}

- name: Install dependencies
run: bun install --frozen-lockfile
Expand All @@ -45,6 +49,37 @@ jobs:
- name: Run unit tests
run: bun run test:unit

unit-v2:
name: Unit tests (v2 simulator)
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: '22'

- uses: oven-sh/setup-bun@v2

- name: Setup Compact compiler
uses: midnightntwrk/setup-compact-action@b622629bee2c06d0f8b4db5b62a93f98dcbd41bf
with:
compact-version: ${{ env.COMPACT_V2_VERSION }}

- name: Install v2 dependencies
run: npm ci
working-directory: contracts/v2

- name: Compile v2 contract
run: bun run compact:v2:fast

- name: Typecheck v2 package
run: bun run typecheck:v2

- name: Run v2 unit tests
run: bun run test:v2

frontend:
name: Frontend (typecheck + build)
runs-on: ubuntu-latest
Expand All @@ -58,22 +93,27 @@ jobs:

- uses: oven-sh/setup-bun@v2

# Both installs matter. The frontend imports the compiled contract from
# ../src/managed (outside its package root), so root node_modules is what
# Rollup would resolve the WASM-bearing midnight packages from for those
# files — a second physical copy whose classes fail the app's instanceof
# checks. vite.config.ts `resolve.dedupe` is the fix; installing ONLY the
# frontend deps would remove the second copy and make the build pass
# trivially, testing nothing. Install both to reproduce the real thing.
# Every install matters. The v1/v2 package trees intentionally carry
# separate WASM class identities; vite.config.ts routes each generated
# contract import through its matching profile runtime. Install every
# tree to reproduce that physical layout in CI.
- name: Install root dependencies
run: bun install --frozen-lockfile

- name: Install frontend dependencies
run: bun install --frozen-lockfile
working-directory: frontend

- name: Install v1 browser protocol dependencies
run: npm ci
working-directory: frontend/protocols/v1

- name: Install v2 browser protocol dependencies
run: npm ci
working-directory: frontend/protocols/v2

# No compact compile: src/managed is committed, and vite copies it into
# dist/contract/compiled for FetchZkConfigProvider.
# the matching v1/v2 output trees for FetchZkConfigProvider.
- name: Typecheck
run: bun run typecheck
working-directory: frontend
Expand All @@ -82,8 +122,8 @@ jobs:
run: bun run build
working-directory: frontend

reproducible-build:
name: Byte-exact contract rebuild
reproducible-build-v1:
name: Byte-exact v1 contract rebuild
runs-on: ubuntu-latest
# Full ZK key generation for all 11 circuits measures ~15s; the headroom is
# for a cold compiler install.
Expand All @@ -93,10 +133,10 @@ jobs:

- uses: oven-sh/setup-bun@v2

- name: Setup Compact compiler
- name: Setup Compact v1 compiler
uses: midnightntwrk/setup-compact-action@b622629bee2c06d0f8b4db5b62a93f98dcbd41bf
with:
compact-version: ${{ env.COMPACT_VERSION }}
compact-version: ${{ env.COMPACT_V1_VERSION }}

# Deliberately NOT cached: restoring src/managed would compare the
# committed artifacts against themselves and prove nothing. No `bun
Expand All @@ -108,18 +148,47 @@ jobs:
# files untouched and the diff below would pass while having verified
# nothing — a green run indistinguishable from a real one. Compiling into
# an empty tree makes the assertion mean what it claims.
- name: Recompile contract from source
- name: Recompile v1 contract from source
run: |
rm -rf src/managed
bun run compact

# `--intent-to-add` stages untracked paths so `git diff` reports files the
# compiler ADDED, not just ones it changed or removed.
- name: Assert src/managed is unchanged
- name: Assert v1 artifacts are unchanged
run: |
git add --intent-to-add -A src/managed
if ! git diff --exit-code --stat -- src/managed; then
echo "::error::Recompiling src/shielded-night.compact with compact ${COMPACT_VERSION} did not reproduce the committed src/managed/. The deployed contract's verifiability claim (README 'Verifying the deployment') depends on this being byte-exact — commit the regenerated artifacts or investigate the toolchain difference."
echo "::error::Recompiling src/shielded-night.compact with compact ${COMPACT_V1_VERSION} did not reproduce the committed src/managed/. The deployed contract's verifiability claim (README 'Verifying the deployment') depends on this being byte-exact — commit the regenerated artifacts or investigate the toolchain difference."
exit 1
fi

reproducible-build-v2:
name: Byte-exact v2 contract rebuild
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v4

- uses: oven-sh/setup-bun@v2

- name: Setup Compact v2 compiler
uses: midnightntwrk/setup-compact-action@b622629bee2c06d0f8b4db5b62a93f98dcbd41bf
with:
compact-version: ${{ env.COMPACT_V2_VERSION }}

# Compile into an empty tree so this cannot pass by comparing the
# committed artifacts with themselves. The compiler is standalone.
- name: Recompile v2 contract from source
run: |
rm -rf contracts/v2/managed
bun run compact:v2

- name: Assert v2 artifacts are unchanged
run: |
git add --intent-to-add -A contracts/v2/managed
if ! git diff --exit-code --stat -- contracts/v2/managed; then
echo "::error::Recompiling contracts/v2/shielded-night.compact with compact ${COMPACT_V2_VERSION} did not reproduce the committed contracts/v2/managed/. Commit the regenerated artifacts or investigate the toolchain difference."
exit 1
fi

Expand All @@ -139,7 +208,7 @@ jobs:
- name: Setup Compact compiler
uses: midnightntwrk/setup-compact-action@b622629bee2c06d0f8b4db5b62a93f98dcbd41bf
with:
compact-version: ${{ env.COMPACT_VERSION }}
compact-version: ${{ env.COMPACT_V1_VERSION }}

# docker.io rate-limits anonymous pulls from shared runners; the Google
# mirror serves the same images without the limit (canary's pattern).
Expand All @@ -158,7 +227,7 @@ jobs:
uses: actions/cache@v4
with:
path: src/managed
key: compact-${{ env.COMPACT_VERSION }}-${{ hashFiles('src/shielded-night.compact') }}
key: compact-${{ env.COMPACT_V1_VERSION }}-${{ hashFiles('src/shielded-night.compact') }}

- name: Compile contract
if: steps.compact-cache.outputs.cache-hit != 'true'
Expand Down
Loading
Loading