Skip to content

Latest commit

 

History

History
739 lines (545 loc) · 22.1 KB

CONTRIBUTING.md

File metadata and controls

739 lines (545 loc) · 22.1 KB

Contributing to Acton

Thanks for contributing to Acton.

Acton core is a Rust project, but the repository also includes UI components that are built and checked with Bun.

This guide covers local setup, build steps, and contributor workflows used in this repository.

Useful references

Workspace map

This repository is a Cargo workspace for the CLI and Rust libraries, plus a few non-Cargo surfaces such as docs and UI packages.

  • Root acton crate (src/, root Cargo.toml): the CLI entrypoint and most end-user commands.
  • Tolk language/compiler stack: tolk-compiler, tolk-*, tree-sitter-*, and the matching *-syntax crates.
  • Native/runtime bridge: ton-objs, ton-executor, ton-emulator, and tvm-ffi.
  • Services and tooling: ton-api, ton-localnet, ton-indexer, ton-retrace, the ton-language-server-* crates, and acton-debug.
  • Repo tooling: xtask for release/schema/artifact maintenance workflows.
  • Non-Cargo surfaces: docs/ (Next.js + Fumadocs), the Bun-built UI crates, and template/package-manager assets under src/commands/new/templates/.

The tree-sitter-* crates own grammar source of truth. The matching *-syntax crates are typed AST/parser wrappers around those grammars rather than independent grammar implementations.

Command conventions

  • Unless stated otherwise, run commands from the repository root.
  • Prefer just targets over ad-hoc commands when both exist.
  • Some targets intentionally modify files (just check-ui, just fmt-ui, just test-update).

Prerequisites

For the minimal local build/test flow, install:

  1. Rust toolchain (rustup, cargo)
  2. just (task runner)
    cargo install just --version 1.58.0 --locked
  3. cargo-nextest (required Rust test runner for non-doc tests)
    cargo install cargo-nextest --version 0.9.143 --locked
  4. Bun (required for UI packages; version pinned in package.json)
    curl -fsSL https://bun.sh/install | bash
  5. Git LFS (required for files tracked through LFS)
    # macOS
    brew install git-lfs
    
    # Linux (Debian/Ubuntu)
    sudo apt install git-lfs
    
    git lfs install
  6. Playwright Chromium (required for Test UI E2E; just test-ui-e2e also installs it automatically)
    bun ci
    just install-test-ui-e2e-browsers
  7. GitHub CLI (gh) (used by just sync-artifacts)
  • macOS:
    brew install gh
  • Linux (Debian/Ubuntu):
    sudo apt install gh

Optional CLI tools:

Install the full set with:

just install-tools

Or install individual tools as needed:

  • cargo-shear (unused dependency linter for just check-deps, also needed by just check / just check-ci)
    cargo install cargo-shear --version 1.13.4 --locked
  • cargo-deny (dependency policy checks for just check, also used by just check-security)
    cargo install cargo-deny --version 0.20.2 --locked
  • cargo-audit (RustSec advisory checks for just check-audit / just check-security)
    cargo install cargo-audit --version 0.22.2 --locked
  • typos-cli (spell checker for just typos, also needed by just check / just check-ci)
    cargo install typos-cli --version 1.49.0 --locked
  • cargo-llvm-cov (optional, for coverage)
    cargo install cargo-llvm-cov --locked
    rustup component add llvm-tools-preview
  • wasm-pack (optional, for rebuilding the source trace WASM package)
    cargo install wasm-pack --version 0.15.0 --locked

System dependencies:

  • macOS:
    brew install libsodium libmicrohttpd pkg-config
  • Linux (Debian/Ubuntu):
    sudo apt install libsodium-dev libmicrohttpd-dev pkg-config

For Linux Test UI E2E runs, Playwright may require extra browser libraries. If Chromium fails to start, run:

bun run playwright install --with-deps chromium

For first-time Linux TON artifact builds (closer to CI), install the extended toolchain set:

sudo apt-get update
sudo apt-get install -y \
  build-essential cmake ninja-build pkg-config autoconf automake \
  libssl-dev libtool zlib1g-dev libsecp256k1-dev libmicrohttpd-dev \
  libsodium-dev liblz4-dev libjemalloc-dev ccache \
  clang-16 llvm-16 libc++-16-dev libc++abi-16-dev

Start working locally

For a fresh checkout, the shortest path to a working contributor setup is:

just sync-artifacts
just build-ui
just build-dev
./target/debug/acton --help

What this does:

  1. just sync-artifacts syncs crates/ton-objs/artifacts_manifest.toml from the release-objs release and refreshes the matching prebuilt objs/ archive plus bundled stdlib assets for your current platform.
  2. just build-ui installs UI dependencies and builds the bundled UI assets.
  3. just build-dev builds the debug CLI against the synced TON archives.
  4. ./target/debug/acton --help confirms that the binary starts.

Building from source

Acton links static TON artifacts (libemulator.a, libtolk.a) from the upstream ton-blockchain/ton repository branch acton.

Artifact ownership and verification

For normal contributor setup, treat the published release-objs assets as the source of truth.

  • just sync-artifacts / cargo xtask sync-artifacts owns crates/ton-objs/artifacts_manifest.toml, objs/, and the bundled stdlib assets under crates/tolk-compiler/assets/.
  • crates/ton-objs/build.rs verifies libemulator.a and libtolk.a against the SHA-256 values recorded in that manifest.
  • Only use the manual rebuild path when you are intentionally updating the native artifact set itself; otherwise prefer re-syncing from release-objs.

The verification bypass TON_OBJS_DISABLE_ARCHIVE_SHA_VERIFY exists as an escape hatch, but it should stay unset for normal contributor builds. When set to anything other than 0 / false, build-time archive verification is disabled.

Bundled mainnet config

Acton embeds a default mainnet blockchain config for local emulation in crates/ton-executor/src/default_config.boc64. Refresh it from TON Center with:

cargo xtask update-default-config

The task fetches getConfigAll, validates that result.config.bytes is a valid BOC, and writes the base64 string into the bundled config file. The ton-executor test suite also checks the bundled value against TON Center when the endpoint is available; network, HTTP, or invalid-response failures are reported as a skipped check rather than a failing test.

Option 1: sync prebuilt objs with xtask

Use the built-in sync task instead of downloading release assets manually:

just sync-artifacts
just build-ui
just build-dev
./target/debug/acton --help

This command:

  • downloads the current artifacts_manifest.toml from the release-objs release;
  • overwrites crates/ton-objs/artifacts_manifest.toml with the released manifest;
  • downloads and unpacks the matching ton-objs-<target>.tar.gz archive into objs/;
  • downloads a temporary ton-stdlib.tar.gz, replaces crates/tolk-compiler/assets/tolk-stdlib/ and crates/tolk-compiler/assets/fift-stdlib/ from its tolk-stdlib/ directory and fift-stdlib/Asm.fif plus fift-stdlib/Fift.fif, then removes the temporary archive.

After syncing, validate with:

just build-dev
./target/debug/acton doctor

Option 2: build TON artifacts manually

Clone the TON repository from the Acton repo root:

git clone --branch acton https://github.com/ton-blockchain/ton.git ton-repo --recurse-submodules

Build the static artifacts with the script for your platform.

Ubuntu/Debian-like Linux:

cd ton-repo
sh ./assembly/native/build-ubuntu-static.sh -a -c
cd ..

macOS:

cd ton-repo
sh ./assembly/native/build-macos-static.sh -a -c
cd ..

Then copy the generated archives into Acton and build the project:

mkdir -p objs
cp ton-repo/artifacts/libemulator.a objs/
cp ton-repo/artifacts/libtolk.a objs/
# only when intentionally updating the native artifact set, edit crates/ton-objs/artifacts_manifest.toml:
# - increment `artifact_set_revision`
# - update `sha256.libemulator` / `sha256.libtolk`

just build-ui

just build-dev
./target/debug/acton --help

Running Acton locally

./target/debug/acton --help
./target/debug/acton test

Test Workflows

Default test command:

just test

Update snapshots:

just test-update

Equivalent explicit form (with env):

SNAPSHOTS=overwrite just test

Test UI E2E

Run browser E2E tests against a real acton test --ui server:

just test-ui-e2e

This target builds UI bundles, builds the debug Acton binary with those fresh assets embedded, installs Playwright Chromium, type-checks the E2E test files, creates a temporary Jetton template project under /tmp, starts acton test --ui --coverage, and checks the Test UI in headless Chromium.

When an intentional visual change requires new screenshots:

just test-ui-e2e-update

Commit the updated files under packages/test-ui/e2e/__image_snapshots__/.

Useful E2E environment variables:

  • ACTON_E2E_BIN: override the Acton binary used by the fixture.
  • ACTON_E2E_TMPDIR: override the parent directory for temporary projects.
  • ACTON_E2E_KEEP_TEMP=1: keep the generated project for debugging.

CI runs these visual E2E tests on macOS so the committed *-darwin.png snapshots are compared on the same OS family. Linux local runs still check the browser workflows, but skip visual snapshot assertions.

Run specific suites:

# Integration tests
cargo nextest run --test integration_test

# Debugger tests (sequential due to shared debug port)
cargo nextest run --test debug_test --test-threads 1

Keep temp test artifacts:

DISABLE_TMP_DIR_CLEANUP_IN_TESTS=1 just test

Notes:

  • just test uses cargo nextest run for Rust test targets and cargo test --workspace --doc for doctests.
  • ton-retrace tests stay inside the shared workspace run, but the repo's nextest config assigns package(ton-retrace) to the retrace-serial group, so those tests still run one at a time.
  • CI test behavior is slightly different: the ci nextest profile and only_ci feature are enabled in CI. For parity, run:
    CI=1 just test

Formatting and Linting

Rust:

just fmt
just fmt-check
just clippy
just check-deps
just typos

UI:

just fmt-ui
just check-ui

just check-ui-ci matches the non-mutating UI check used in CI. just check-ui runs lint:fix and may modify files. Run it until no further changes are produced, then stage updated files.

just typos checks the repository from the root using _typos.toml. It skips docs/ and selected generated or imported trees with high false-positive rates.

Security checks

Run repository-wide dependency and supply-chain audits with:

just check-security

just check-security stops on the first failure and currently checks:

  • Rust dependencies with cargo deny check
  • RustSec advisories for Cargo.lock with cargo audit
  • root workspace dependencies, including the VS Code extension, with bun audit
  • crates/tree-sitter-* with npm audit

Run this check when your PR changes lockfiles, dependency manifests, or package versions for the Rust, root/UI, tree-sitter, or VS Code extension dependency surfaces listed above.

Coverage

Generate LCOV:

just coverage

Generate HTML report:

just coverage-html

UI Build

Build UI bundles used by Acton:

just build-ui

Source Trace WASM

When changing crates/acton-source-trace or crates/acton-source-trace-wasm, generate the wasm-bindgen package with:

just build-source-trace-wasm

The generated package is written to /tmp/acton-source-trace-wasm by default. Override it with:

ACTON_SOURCE_TRACE_WASM_OUT=/tmp/my-source-trace-wasm just build-source-trace-wasm

Copying the generated JS/WASM into the package that embeds it is a manual step. Use the files from that output directory as the source for the downstream retracer-core update.

Documentation workflows

Documentation site (Next.js in docs/, package manager: Bun):

cd docs
bun ci
bun run dev

Validate docs from the repository root:

just check-docs

This runs the docs dependency install, Fumadocs generated-source refresh, format check, internal link validation, navigation validation, and static export build.

Regenerate auto-generated MDX documentation from Acton sources:

./target/debug/acton docgen
# or
cargo run --bin acton -- docgen
# check mode (fails with exit code 1 and prints diff if docs are stale)
cargo run --bin acton -- docgen --check

Do not hand-edit generated outputs. Edit the source-of-truth inputs instead, then rerun acton docgen.

Source-of-truth map:

  • src/doc/man/*.md -> command reference docs under docs/content/docs/commands, terminal help text under src/doc/man/generated_txt, and installed manpages under src/etc/man
  • lib/ -> docs/content/docs/standard_library
  • crates/tolk-compiler/assets/tolk-stdlib/ -> docs/content/docs/tolk_standard_library
  • linter rule metadata in crates/tolk-linter/ and related macros -> docs/content/docs/rules

acton docgen updates generated trees under:

  • docs/content/docs/commands
  • docs/content/docs/standard_library
  • docs/content/docs/tolk_standard_library
  • docs/content/docs/rules
  • src/etc/man
  • src/doc/man/generated_txt

The Simulator control API uses a separate generator: docs/public/openapi/acton-simulator-control.openapi.json -> docs/content/docs/simulator/control-api.mdx through bun run generated-source in docs/.

acton docgen --check renders into a temporary output tree and fails if any tracked generated file is stale.

If your PR changes any docgen inputs, running acton docgen and committing generated documentation changes is required. This includes:

  • lib/
  • crates/tolk-compiler/assets/tolk-stdlib/
  • linter rule metadata and mappings (for example crates/tolk-linter/, crates/tolk-macros/)

Changes to man pages can change the acton help snapshots. After regeneration, run the help tests:

cargo nextest run --test integration_test -E 'test(test_acton_help_)'

Changes to lib/ comments can shift source line numbers in debugger snapshots. Run the debugger tests that cover the changed modules. For example:

cargo nextest run --test integration_test -E 'test(test_real_counter_contract_step_in)'

Review each snapshot diff. For an intended change, rerun the affected test with SNAPSHOTS=overwrite and commit the updated snapshot.

For docs-site-only pages under docs/content/docs/ that are not generated, edit them directly and keep nearby meta.json in sync.

After doc updates (manual or generated), validate docs from the repository root:

just check-docs

Schema workflow

crates/acton-config/schemas/acton.schema.json is generated, not hand-maintained.

Useful commands:

cargo xtask schema
cargo xtask schema --check
just check-schema

When to rerun schema generation:

  • any change to ActonConfig or related config structs
  • schema-shaping serde/schemars changes
  • changes to linter rule names, descriptions, or explanation comments in crates/tolk-linter/, which the schema includes
  • docs or editor work that depends on new config fields

Current consumers include:

  • repo editor settings such as .vscode/settings.json
  • ton-language-server-core, which embeds the schema for TOML hover/completion help

A stale schema usually shows up as just check-schema failure, missing hover docs, or editor completion that does not know about new config fields.

Tree-sitter workflows

Grammar source of truth lives in crates/tree-sitter-*. The matching crates/*-syntax crates wrap those grammars with typed AST helpers.

If your PR changes any crates/tree-sitter-* grammar/parser artifacts:

just test-tree-sitter-all

For quick Tolk-only iteration:

just test-tree-sitter-tolk

When grammar snapshots need refresh:

just update-test-tree-sitter-tolk

xtask map

cargo xtask contains both contributor-facing and maintainer-only workflows.

Common contributor-facing tasks:

  • cargo xtask sync-artifacts
  • cargo xtask schema
  • cargo xtask schema --check

Mostly maintainer-facing tasks:

  • cargo xtask release
  • cargo xtask retag
  • cargo xtask dist ...
  • cargo xtask update-abi-catalog
  • cargo xtask github-cleanup
  • cargo xtask ubicloud-cleanup

RELEASING.md documents numbered release flows in detail. The cleanup tasks are cache-pruning helpers and should not be used casually.

Change-based checklist

Use this as a quick local matrix before pushing:

Change type Required local checks
Rust-only code just check
UI code (packages/, root package.json) just check + just build-ui + just check-ui; for Test UI behavior/screenshots also run just test-ui-e2e
Dependency or lockfile changes (Cargo.lock, root bun.lock, tree-sitter/code extension package manifests) just check-security
Standard library / docgen inputs (lib/, crates/tolk-compiler/assets/tolk-stdlib, linter rule metadata) just check + acton docgen and commit generated docs
Docs site content/config/dependencies (docs/) just check-docs
Tree-sitter grammar (crates/tree-sitter-*) just check + just test-tree-sitter-all (and the matching just update-test-tree-sitter-* recipe when snapshots change)
Release preparation (maintainers) Follow RELEASING.md

PR requirements

Every pull request must pass all checks from:

just check

This command runs Rust formatting, docgen, dependency, dependency-policy, lint, schema, and test checks. It needs cargo-shear, cargo-deny, cargo-audit, and typos-cli locally; just install-tools installs them together with the optional coverage and WASM tools. typos uses _typos.toml excludes for docs/ and selected generated or imported trees.

If your PR touches UI code (packages/test-ui, packages/localnet-ui, packages/transaction-ui, or root UI config in package.json), you must also run:

just build-ui
just check-ui

If your PR changes Test UI behavior or visuals, also run:

just test-ui-e2e

Use just test-ui-e2e-update only when the visual change is intentional and commit the regenerated screenshots.

Recommended extended local validation before opening a PR:

just precommit

just precommit additionally runs UI formatting/lint and full build steps.

Commit message style

Project follows Conventional Commits with scope.

Recommended format:

<type>(<scope>): <short imperative summary>

Examples:

  • feat(check): add inspection for duplicate condition in if-else
  • fix(stdlib): fix external message body serialization
  • chore(docs): update linting docs

Rules:

  • Use one of: feat, fix, chore, refactor (and docs/test/ci when appropriate).
  • Keep scope specific (check, localnet, stdlib, wallet, test-runner, docs, etc.).
  • Use present tense in the subject (for example: add, fix, update, not added, fixed, updated).
  • Write concise imperative subject in lowercase.
  • Keep the subject short (recommended: up to ~72 characters).
  • Do not end the subject with a period.
  • Optional issue/PR reference at the end is common: (#123).

Useful environment variables

  • TONCENTER_MAINNET_API_KEY: API key for TON Center mainnet requests.
  • TONCENTER_TESTNET_API_KEY: API key for TON Center testnet requests.
  • ACTON_STUDIO_TONCENTER_MAINNET_API_KEY and ACTON_STUDIO_TONCENTER_TESTNET_API_KEY: build-time application keys embedded in the Rust binary for Studio's public-network requests. Runtime TONCENTER_MAINNET_API_KEY and TONCENTER_TESTNET_API_KEY values override them.
  • VITE_LOCALNET_TONCENTER_API_KEY: API key sent by the localnet UI to TON Center-compatible /api/v2 and /api/v3 endpoints.
  • DISABLE_TMP_DIR_CLEANUP_IN_TESTS=1: preserve temp test directories.
  • ACTON_LOG_DIR: custom directory for Acton debug logs.

In generated projects, .env is usually the simplest place to set the TON Center keys because Acton loads that file automatically.

Release and published trunk builds require the TONCENTER_MAINNET_API_KEY and TONCENTER_TESTNET_API_KEY GitHub Actions secrets. The build workflows pass them to Rust through the ACTON_STUDIO_ variables. Pull-request builds do not receive these keys. Local builds can set the same build-time variables explicitly; Cargo does not load .env files automatically.

Embedded application keys can be extracted from distributed binaries. Use keys intended for distribution. Studio adds them to upstream requests on the server; it does not expose them through its browser configuration.

AI Policy

Do what you want and how it is convenient for you.