This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
srtool (Substrate Runtime Toolbox) is a Docker-based tool for building WASM runtimes for the Polkadot Network deterministically. It produces identical WASM runtime builds across different machines via a containerized environment (Ubuntu 22.04 + pinned Rust version).
The Docker image is published to paritytech/srtool on Docker Hub with tags like $RUSTC_VERSION-$SRTOOL_VERSION.
VERSION— srtool version (e.g., 0.18.4)RUSTC_VERSION— Rust toolchain version pinned for deterministic builds (e.g., 1.93.0)Dockerfile— Container image definitionjustfile— Build automation (usesjust, notmake)
All automation uses just (not make):
just build # Build Docker image
just test_quick # Run quick container structure tests
just test_acl # Run ACL/permissions tests
just test_long # Run extended tests
just test_commands # Test command execution
just test_all # Run all test suites
just publish # Build and push to Docker Hub
just scan # Vulnerability scan with trivy
just md # Convert README_src.adoc → README.md via asciidoctor
just info # Show version infoTests use container-structure-test (Google's tool) with YAML test definitions in tests/. These validate the Docker image structure: file existence, user/group IDs, environment variables, volumes, and commands.
The image runs as user builder (UID/GID 1001). Key volumes:
/build— Project source (mounted from host)/home/builder/cargo— Cargo cache/out— Exported runtime artifacts
Entry point is /srtool/build. The scripts/ directory is copied into the image at /srtool/.
build— Main entry point. Builds the WASM runtime, produces JSON output with hashes (proposal hash, IPFS, SHA256).lib.sh— Shared utilities:vercomp()for semver comparison,find_runtimes()for discovering runtimes in a repo,get_runtime_package_version().info— Prints pre-build info (git state, package, rustc version).version— Prints tool versions (srtool, rustc, subwasm, tera, toml).scan— Discovers all runtimes in a repository, outputs JSON matrix for GitHub Actions.getBuildOpts.sh— Determines build features based on package name and version (e.g.,--features on-chain-release-buildfor Kusama/Polkadot v0.8.30+).
PACKAGE— Runtime package name (default:polkadot-runtime)RUNTIME_DIR— Path to runtime cratePROFILE— Build profile (default:release)BUILD_OPTS— Additional cargo build optionsVERBOSE— Enable verbose output
find_runtimes() in lib.sh searches for crates with names ending in -runtime that contain the #[frame_support::runtime] macro in their lib.rs. Output is a JSON matrix suitable for GitHub Actions parallelization.
tests.yml— Builds image and runs all test suites on push to master, PRs, and weeklyquick-test.yml— Subset of tests for fast feedbackrelease.yml— Triggered byv*tags; builds, tests, publishes to Docker Hub, creates GitHub releasemanual*.yml— Manual workflow_dispatch builds for specific chains (polkadot-sdk, moonbeam, acala, shiden, fellowship runtimes)
- srtool-cli — Rust CLI wrapper for running srtool
- srtool-actions — GitHub Actions integration
- subwasm — WASM analysis tool (bundled in the image)