INTMAX2 is a stateless Layer 2 protocol on Ethereum, combining privacy, speed, and true self-custody.
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source $HOME/.cargo/env
curl -L https://foundry.paradigm.xyz | bash
foundryup
# SQL migration tool
cargo install sqlx-cli
# WebAssembly build tool
cargo install wasm-pack
# Development tools
rustup component add rustfmt clippy
# Install lefthook for git hooks
brew install lefthook
lefthook install
# Install typos-cli for spell checking
brew install typos-cli
Copy the example environment files in each service directory:
# Copy all .env.example files to .env
find . -name ".env.example" -exec sh -c 'cp "$1" "${1%.example}"' _ {} \;
# Start local blockchain network
anvil
# Start PostgreSQL and Redis using Docker
docker compose up -d
cd tests
cargo test -r -p tests deploy_contracts -- --nocapture --ignored
cd ..
Start each service in a separate terminal window:
# 1. Legacy Store Vault Server (Port: 9000)
cd legacy-store-vault-server && sqlx database setup && cargo run -r
# 2. Balance Prover (Port: 9001)
cd balance-prover && cargo run -r
# 3. Validity Prover (Port: 9002)
cd validity-prover && sqlx database setup && cargo run -r
# 4. Validity Prover Worker
cd validity-prover-worker && cargo run -r
# 5. Withdrawal Server (Port: 9003)
cd withdrawal-server && sqlx database setup && cargo run -r
# 6. Block Builder (Port: 9004)
cd block-builder && cargo run -r
- Purpose: Stores backups of user's local states and acts as a mailbox for transfers
- Port: 9000
- Database: Required
- Purpose: Generates client-side zero-knowledge proofs on behalf of users
- Port: 9001
- State: Stateless service
- Purpose: Generates ZKPs related to on-chain information
- Port: 9002
- Database: Required
- Worker: Requires validity-prover-worker for processing
- Purpose: Receives transactions from users and generates blocks
- Port: 9004
- Integration: Connects to blockchain network
- Purpose: Processes withdrawal requests from users
- Port: 9003
- Database: Required
For detailed CLI examples and usage, see the CLI documentation.
# Reset all service databases
(cd store-vault-server && sqlx database reset -y && \
cd ../legacy-store-vault-server && sqlx database reset -y && sqlx database setup && \
cd ../validity-prover && sqlx database reset -y && sqlx database setup && \
cd ../withdrawal-server && sqlx database reset -y && sqlx database setup)
When modifying SQL queries, regenerate the query metadata:
cargo sqlx prepare --workspace -- --all-targets --all-features
The project uses automated code quality tools:
- rustfmt: Code formatting
- clippy: Linting
- typos: Spell checking
- lefthook: Git hooks for pre-commit checks
Run checks manually:
# Format code
cargo fmt --all
# Run linter
cargo clippy --all-targets --all-features
# Check for typos
typos
See the tests directory for load testing documentation.