Skip to content
Closed
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
24 changes: 24 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,30 @@ runs:
node-version-file: ".nvmrc"
cache: "yarn"

- name: Build compact-tools submodule
shell: bash
run: |
echo "📦 Building compact-tools submodule..."
cd compact-tools
yarn install --immutable
yarn build
echo "✅ compact-tools built successfully"

- name: Validate compact-tools artifacts
shell: bash
run: |
REQUIRED_FILES=(
"compact-tools/packages/cli/dist/runCompiler.js"
"compact-tools/packages/cli/dist/runBuilder.js"
)
for file in "${REQUIRED_FILES[@]}"; do
if [ ! -f "$file" ]; then
echo "::error::❌ Missing required file: $file"
exit 1
fi
done
echo "✅ compact-tools artifacts validated"

- name: Install dependencies
shell: bash
run: yarn install --immutable
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ jobs:
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
fetch-depth: 2 # Recommended by turbo team
submodules: true

- name: Setup Environment
uses: ./.github/actions/setup
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ jobs:
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
fetch-depth: 2 # Recommended by turbo team
submodules: true

- name: Setup Environment
uses: ./.github/actions/setup
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/prepare-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ jobs:

- name: Checkout repository
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
submodules: true

- name: Enable Corepack
run: corepack enable
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ jobs:

- name: Checkout
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
submodules: true

- name: Setup Environment
uses: ./.github/actions/setup
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ jobs:
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
fetch-depth: 2 # Recommended by turbo team
submodules: true

- name: Setup Environment
uses: ./.github/actions/setup
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.env
.act.env
.turbo
*.log
*.tsbuildinfo
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "compact-tools"]
path = compact-tools
url = https://github.com/OpenZeppelin/compact-tools
10 changes: 5 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- @tsconfig/node24 to @openzeppelin-compact/contracts, @openzeppelin-compact/compact, @openzeppelin-compact/contracts-simulator (#278)
- @tsconfig/node24 to @openzeppelin/compact-/contracts, @openzeppelin/compact-/compact, @openzeppelin/compact-/contracts-simulator (#278)
- OpenZeppelin Compact Simulator (#247)

### Changed

- Bump compact compiler to v0.25.0 (#233)
- Bump .nvmrc to v24.9.0 (#278)
- Upgrade @types/node 22.18.0 -> 24.9.0 in openzeppelin-compact, @openzeppelin-compact/contracts, @openzeppelin-compact/compact, @openzeppelin-compact/contracts-simulator (#278)
- Bump node version requirement to >=22 in @openzeppelin-compact/contracts and @openzeppelin-compact/contracts-simulator (#278)
- Upgrade @types/node 22.18.0 -> 24.9.0 in openzeppelin/compact-, @openzeppelin/compact-/contracts, @openzeppelin/compact-/compact, @openzeppelin/compact-/contracts-simulator (#278)
- Bump node version requirement to >=22 in @openzeppelin/compact-/contracts and @openzeppelin/compact-/contracts-simulator (#278)

### Removed

- @tsconfig/node22 from @openzeppelin-compact/contracts, @openzeppelin-compact/compact, @openzeppelin-compact/contracts-simulator (#278)
- @tsconfig/node22 from @openzeppelin/compact-/contracts, @openzeppelin/compact-/compact, @openzeppelin/compact-/contracts-simulator (#278)
- Bump compact compiler to v0.26.0 (#279)
- Upgrade @midnight-ntwrk/compact-runtime ^0.8.1 -> ^0.9.0 (#279)
- Move @openzeppelin-compact/compact to its own package in the package/compact dir (#247)
- Move @openzeppelin/compact-/compact to its own package in the package/compact dir (#247)
Comment on lines +14 to +29
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Fix malformed package scope in changelog entries.

Several entries read @openzeppelin/compact-/..., which appears to be a typo and could confuse users.

✍️ Suggested corrections (example)
-- `@tsconfig/node24` to `@openzeppelin/compact-/contracts`, `@openzeppelin/compact-/compact`, `@openzeppelin/compact-/contracts-simulator` (`#278`)
+- `@tsconfig/node24` to `@openzeppelin/compact-contracts`, `@openzeppelin/compact-compact`, `@openzeppelin/compact-contracts-simulator` (`#278`)

-- Upgrade `@types/node` 22.18.0 -> 24.9.0 in openzeppelin/compact-, `@openzeppelin/compact-/contracts`, `@openzeppelin/compact-/compact`, `@openzeppelin/compact-/contracts-simulator` (`#278`)
+- Upgrade `@types/node` 22.18.0 -> 24.9.0 in `@openzeppelin/compact-contracts`, `@openzeppelin/compact-compact`, `@openzeppelin/compact-contracts-simulator` (`#278`)

-- Bump node version requirement to >=22 in `@openzeppelin/compact-/contracts` and `@openzeppelin/compact-/contracts-simulator` (`#278`)
+- Bump node version requirement to >=22 in `@openzeppelin/compact-contracts` and `@openzeppelin/compact-contracts-simulator` (`#278`)

-- `@tsconfig/node22` from `@openzeppelin/compact-/contracts`, `@openzeppelin/compact-/compact`, `@openzeppelin/compact-/contracts-simulator` (`#278`)
+- `@tsconfig/node22` from `@openzeppelin/compact-contracts`, `@openzeppelin/compact-compact`, `@openzeppelin/compact-contracts-simulator` (`#278`)

-- Move `@openzeppelin/compact-/compact` to its own package in the package/compact dir (`#247`)
+- Move `@openzeppelin/compact-compact` to its own package in the package/compact dir (`#247`)
🤖 Prompt for AI Agents
In `@CHANGELOG.md` around lines 14 - 29, Fix the malformed package scopes in
CHANGELOG.md by replacing occurrences of the incorrect token
"@openzeppelin/compact-/" with the correct package scopes (e.g.,
"@openzeppelin/compact" or the intended scoped package names) so entries like
"@openzeppelin/compact-/contracts", "@openzeppelin/compact-/compact", and
"@openzeppelin/compact-/contracts-simulator" are corrected to their proper
scoped package identifiers; ensure all similar entries (including the three
instances shown and any other "@openzeppelin/compact-/" matches) are updated
consistently and run a quick grep/search to verify no remaining malformed scopes
exist.

29 changes: 29 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
.PHONY: help setup install build-submodule submodule-init submodule-update

help: ## Show this help message
@echo "Available targets:"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-20s\033[0m %s\n", $$1, $$2}'

setup: submodule-init build-submodule install ## Complete setup: init submodules, build compact-tools, and install dependencies
@echo "✅ Setup complete!"

install: ## Install dependencies for the main project
@echo "📦 Installing dependencies..."
@yarn install

build-submodule: ## Build the compact-tools submodule
@echo "🔨 Building compact-tools submodule..."
@cd compact-tools && yarn && yarn build

submodule-init: ## Initialize git submodules
@echo "📥 Initializing submodules..."
@git submodule update --init --recursive

submodule-update: ## Update submodules to latest commits and rebuild
@echo "🔄 Updating submodules..."
@git submodule update --remote
@echo "🔨 Rebuilding compact-tools..."
@$(MAKE) build-submodule
@echo "📦 Updating lockfile..."
@yarn install
@echo "✅ Submodules updated!"
51 changes: 45 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,21 @@ git init && \
git submodule add https://github.com/OpenZeppelin/compact-contracts.git
```

`cd` into it and then install dependencies and prepare the environment.
`cd` into it and run the setup command:

```bash
nvm install && \
yarn && \
cd compact-contracts && \
make setup && \
SKIP_ZK=true turbo compact
```

Or manually:

```bash
cd compact-contracts && \
git submodule update --init --recursive && \
cd compact-tools && yarn && yarn build && cd .. && \
nvm install && yarn && \
SKIP_ZK=true yarn compact
```

Expand Down Expand Up @@ -137,15 +147,44 @@ make sure to check out the [contribution guide](CONTRIBUTING.md) in advance.

### Set up the project

Clone the OpenZeppelin Contracts for Compact library.
Clone the OpenZeppelin Contracts for Compact library with submodules (this repository uses the `compact-tools` submodule).

```bash
git clone --recursive git@github.com:OpenZeppelin/compact-contracts.git
cd compact-contracts
```

#### Recommended: Using Makefile

Run the setup command to initialize submodules, build `compact-tools`, and install dependencies:

```bash
git clone git@github.com:OpenZeppelin/compact-contracts.git
make setup
```

`cd` into it and then install dependencies and prepare the environment.
Then build the main project using turbo:

```bash
turbo compact
```

> **Tip:** Run `make help` to see all available commands.

#### Alternative: Manual setup

If you prefer to run commands manually or don't have `make` available:

```bash
# Initialize submodules (if you cloned without --recursive)
git submodule update --init --recursive

# Build the compact-tools submodule
cd compact-tools && \
yarn && \
yarn build && \
cd ..

# Install dependencies and build the main project
nvm install && \
yarn && \
turbo compact
Expand Down
1 change: 1 addition & 0 deletions biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
},
"files": {
"ignoreUnknown": true,
"experimentalScannerIgnores": ["compact-tools/**"],
"includes": [
Comment on lines 10 to 12
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🌐 Web query:

Biome 2.3.8 experimentalScannerIgnores configuration documentation

💡 Result:

In Biome v2.3.8, experimentalScannerIgnores is documented under the configuration reference as:

  • Config key: files.experimentalScannerIgnores
  • Type: array of literal path segments / basenames
  • Behavior: tells Biome’s scanner to skip indexing those paths during crawling (so they won’t be part of the module graph and won’t contribute to type inference)
  • Limitations: no glob patterns; only basenames are matched; recommended only as a last resort for performance. [1]

Example:

{
  "files": {
    "experimentalScannerIgnores": ["lodash", "dist", "RedisCommander.d.ts"]
  }
}
``` [1]

Note: In the newer docs (post‑2.3.8), this option is marked **deprecated**, with guidance to use the **force-ignore syntax via `files.includes`** (notably `!!` to fully exclude from indexing). [2][3]

**Sources:** Biome configuration reference (includes `files.experimentalScannerIgnores`) [1][2], Biome v2.3 blog (explains `!` vs `!!` and the deprecation) [3].

---



</details>

**Move `experimentalScannerIgnores` under `files` and use basename matching instead of glob patterns.**

The correct config path is `files.experimentalScannerIgnores`, not at the root level. Additionally, this option only accepts literal basenames or path segments—not glob patterns. `"compact-tools/**"` will not work as intended. Either use `"compact-tools"` as a basename, or switch to `files.includes` with the `!!` force-ignore syntax (the recommended approach in current Biome versions).

<details>
<summary>🤖 Prompt for AI Agents</summary>

In @biome.json around lines 10 - 12, Move the experimentalScannerIgnores entry
from the root to the files section by creating files.experimentalScannerIgnores
and removing the root-level experimentalScannerIgnores; replace the glob
"compact-tools/**" with a literal basename "compact-tools" because
experimentalScannerIgnores only accepts basenames/path segments, or
alternatively remove it and add a files.includes entry using the !! force-ignore
syntax (e.g., files.includes with an !! pattern) if you need glob-like behavior.
Ensure you update the key name exactly as files.experimentalScannerIgnores
and/or use files.includes for force-ignore patterns.


</details>

<!-- fingerprinting:phantom:poseidon:eagle -->

<!-- This is an auto-generated comment by CodeRabbit -->

"**",
"!**/tsconfig.base.json",
Expand Down
1 change: 1 addition & 0 deletions compact-tools
Submodule compact-tools added at 1301ca
21 changes: 10 additions & 11 deletions contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,24 @@
"homepage": "https://docs.openzeppelin.com/contracts-compact/",
"type": "module",
"scripts": {
"compact": "compact-compiler",
"compact:access": "compact-compiler --dir access",
"compact:archive": "compact-compiler --dir archive",
"compact:security": "compact-compiler --dir security",
"compact:token": "compact-compiler --dir token",
"compact:utils": "compact-compiler --dir utils",
"compact": "compact-compiler +0.26.0 --hierarchical",
"compact:fast": "compact-compiler +0.26.0 --hierarchical --skip-zk",
"compact:access": "compact-compiler +0.26.0 --dir access --hierarchical",
"compact:archive": "compact-compiler +0.26.0 --dir archive --hierarchical",
"compact:security": "compact-compiler +0.26.0 --dir security --hierarchical",
"compact:token": "compact-compiler +0.26.0 --dir token --hierarchical",
"compact:utils": "compact-compiler +0.26.0 --dir utils --hierarchical",
Comment on lines +24 to +30
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of the imports expect a flattened structure

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh scratch that, the test script compiles without the flag. Nit: would consistency be better with compiling vs compile + testing? Right now, my artifacts dir is including both flattened + hierarchical

"build": "compact-builder",
"test": "compact-compiler --skip-zk && vitest run",
"test": "compact-compiler +0.26.0 --skip-zk && vitest run",
Comment on lines +24 to +32
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🌐 Web query:

compact-compiler 0.26.0 --hierarchical --skip-zk flags documentation

💡 Result:

For Compact compiler (compactc) / toolchain 0.26.0, the official flag docs list --skip-zk but do not list any --hierarchical flag.

  • --skip-zk: “causes the compiler to skip the generation of proving keys” (useful because proving key generation can be time-consuming; it’s also skipped if zkir can’t be found). (docs.midnight.network)
  • The same manual page enumerates the supported flags (--help, --version, --language-version, --vscode, --skip-zk, --no-communications-commitment, --sourceRoot ..., --trace-passes) and --hierarchical is not among them. (docs.midnight.network)

If you’re seeing --hierarchical accepted somewhere, it’s likely coming from a different command/binary (or an older/internal build). The docs recommend checking the tool’s built-in help for the exact options your installed version supports (e.g., compact compile --help). (docs.midnight.network)

Citations:


Remove unsupported --hierarchical flag from compact-compiler commands.
The flag is not documented in the official compact-compiler 0.26.0 documentation. The supported flags are: --help, --version, --language-version, --vscode, --skip-zk, --no-communications-commitment, --sourceRoot, and --trace-passes. Lines 24–31 use --hierarchical across seven npm scripts, which will cause these commands to fail at runtime. The --skip-zk flag (line 32) is valid and properly used.

🤖 Prompt for AI Agents
In `@contracts/package.json` around lines 24 - 32, The npm scripts "compact",
"compact:fast", "compact:access", "compact:archive", "compact:security",
"compact:token", and "compact:utils" include the unsupported --hierarchical
flag; update each script in package.json to remove --hierarchical (preserve the
compiler version "+0.26.0" and any other valid flags like --skip-zk or --dir),
leaving "compact:fast" and the "test" script's --skip-zk intact; verify the
"build" and "test" scripts remain unchanged aside from this removal so
compact-compiler invocations use only supported flags.

"types": "tsc -p tsconfig.json --noEmit",
"clean": "git clean -fXd"
},
"engines": {
"node": ">=22"
},
"dependencies": {
"@openzeppelin-compact/compact": "workspace:^"
},
"devDependencies": {
"@openzeppelin-compact/contracts-simulator": "workspace:^",
"@openzeppelin/compact-tools-cli": "file:../compact-tools/packages/cli",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CLI is required to build the package for the compiled artifacts. I think this should be a regular dep

"@openzeppelin/compact-tools-simulator": "file:../compact-tools/packages/simulator",
Comment on lines +40 to +41
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

# Check if .gitmodules exists and shows submodule configuration
cat .gitmodules 2>/dev/null || echo "No .gitmodules found"

Repository: OpenZeppelin/compact-contracts

Length of output: 176


🏁 Script executed:

# Check the current state of compact-tools directory
ls -la compact-tools 2>/dev/null || echo "compact-tools directory not found"

Repository: OpenZeppelin/compact-contracts

Length of output: 182


🏁 Script executed:

# Check git config for submodule configuration
git config --file=.gitmodules --get-regexp path 2>/dev/null || echo "No submodule paths in config"

Repository: OpenZeppelin/compact-contracts

Length of output: 116


🏁 Script executed:

# Check if the paths referenced in package.json actually exist
echo "Checking cli package..."
test -f compact-tools/packages/cli/package.json && echo "✓ cli/package.json exists" || echo "✗ cli/package.json not found"

echo "Checking simulator package..."
test -f compact-tools/packages/simulator/package.json && echo "✓ simulator/package.json exists" || echo "✗ simulator/package.json not found"

Repository: OpenZeppelin/compact-contracts

Length of output: 191


🏁 Script executed:

# Look for any documentation about setup/initialization
find . -maxdepth 2 -type f \( -name "README*" -o -name "SETUP*" -o -name ".github" \) -exec echo "Found: {}" \;

Repository: OpenZeppelin/compact-contracts

Length of output: 92


🏁 Script executed:

# Check contracts/package.json to see the exact dependencies
head -50 contracts/package.json | tail -15

Repository: OpenZeppelin/compact-contracts

Length of output: 485


🏁 Script executed:

# Check README for setup instructions
cat README.md | head -100

Repository: OpenZeppelin/compact-contracts

Length of output: 3034


Submodule initialization is required before install; already documented in README but worth reinforcing.

The file:../compact-tools/packages/... dependencies require the compact-tools submodule to be initialized first. The README correctly documents the sequence (git submodule update --init --recursive before yarn), but developers following a standard npm install or yarn without the submodule step will encounter failures when resolving these local package references.

Consider adding a setup validation script or preinstall hook to ensure the submodule is initialized before dependency resolution.

🤖 Prompt for AI Agents
In `@contracts/package.json` around lines 40 - 41, The package.json currently
depends on local submodule packages "@openzeppelin/compact-tools-cli" and
"@openzeppelin/compact-tools-simulator" which fail if the compact-tools
submodule isn't initialized; add a preinstall script in contracts' package.json
that checks whether the submodule is initialized (e.g., verify existence of
../compact-tools/packages or run a lightweight git submodule status check) and
either runs git submodule update --init --recursive or fails with a clear
message instructing the developer to run that command; update the "scripts"
section to include this "preinstall" hook so npm/yarn will validate/init the
submodule before resolving the file:../compact-tools/* dependencies.

"@tsconfig/node24": "^24.0.3",
"@types/node": "24.10.0",
"ts-node": "^10.9.2",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
type BaseSimulatorOptions,
createSimulator,
} from '@openzeppelin-compact/contracts-simulator';
} from '@openzeppelin/compact-tools-simulator';
import {
type ContractAddress,
type Either,
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
"packages/*"
],
"scripts": {
"compact": "turbo run compact --filter=@openzeppelin-compact/contracts --log-prefix=none",
"compact": "turbo run compact --filter=@openzeppelin/compact-contracts --log-prefix=none",
"build": "turbo run build --log-prefix=none",
"test": "turbo run test --filter=@openzeppelin-compact/contracts --log-prefix=none",
"fmt-and-lint": "biome check . --changed",
"fmt-and-lint:fix": "biome check . --changed --write",
"fmt-and-lint:ci": "biome ci . --changed --no-errors-on-unmatched",
"test": "turbo run test --filter=@openzeppelin/compact-contracts --log-prefix=none",
"fmt-and-lint": "cd contracts && biome check . --changed",
"fmt-and-lint:fix": "cd contracts && biome check . --changed --write",
"fmt-and-lint:ci": "cd contracts && biome ci . --changed --no-errors-on-unmatched",
Comment on lines +14 to +16
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to add this because I couldn't find any workaround to ignore the biome.json config inside the root of the compact-tools submodule.

yarn fmt-and-lint                                                          1 ✘  22.18.0  
~/compact-contracts/compact-tools/biome.json configuration ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  ✖ Found a nested root configuration, but there's already a root configuration.
  
  ℹ The other configuration was found in ~/compact-contracts.
  
  ℹ Use the migration command from the root of the project to update the configuration.
  
  $ biome migrate --write

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

biome does not play well with submodules 🥲

"types": "turbo run types",
"clean": "turbo run clean"
},
Expand Down
38 changes: 0 additions & 38 deletions packages/compact/package.json

This file was deleted.

Loading
Loading