Getting Started
Development Guide
Section titled “Development Guide”Prerequisites
Section titled “Prerequisites”Required
Section titled “Required”-
Java Development Kit (JDK) 17 or higher
Terminal window # Check Java versionjava -version# Install via SDKMAN (recommended)curl -s "https://get.sdkman.io" | bashsdk install java 17.0.9-tem -
Scala Build Tool (sbt) 1.9+
Terminal window # macOSbrew install sbt# Linuxcurl -fL https://github.com/sbt/sbt/releases/download/v1.9.7/sbt-1.9.7.tgz | tar xz# Check versionsbt --version -
Rust toolchain (for native libraries)
Terminal window # Install Rustcurl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh# Check installationcargo --versionrustc --version
Getting Started
Section titled “Getting Started”Clone the Repository
Section titled “Clone the Repository”# Clone with submodules (includes graypaper and jamtestvectors)cd /jamgit submodule update --init --recursiveInitial Build
Section titled “Initial Build”The first build will:
- Download Scala compiler and dependencies
- Build native Rust libraries (Bandersnatch VRF, Ed25519, Erasure Coding)
- Compile all Scala modules
# Full buildsbt compile
# Build and run all testssbt testProject Structure
Section titled “Project Structure”jam/├── build.sbt # Main build configuration├── project/ # sbt build definitions│ ├── build.properties # sbt version│ └── plugins.sbt # sbt plugins├── modules/│ ├── core/ # Core types and encoding│ │ └── src/│ │ ├── main/scala/ # Source code│ │ └── test/scala/ # Tests│ ├── crypto/ # Cryptography│ │ ├── src/│ │ └── native/ # Rust native libraries│ │ ├── bandersnatch-vrfs-wrapper/│ │ ├── ed25519-zebra-wrapper/│ │ └── erasure-coding-wrapper/│ ├── pvm/ # PolkaVM virtual machine│ ├── protocol/ # State transition functions│ └── conformance/ # Conformance testing├── graypaper/ # Gray Paper (submodule)├── jamtestvectors/ # Official test vectors (submodule)└── jam-conformance/ # Conformance testing tools (submodule)Development Workflow
Section titled “Development Workflow”Code Style
Section titled “Code Style”The project uses Scalafmt for code formatting:
# Format all source filessbt scalafmtAll
# Check formatting without modifyingsbt scalafmtCheckAllConfiguration in .scalafmt.conf:
- 2-space indentation
- 100-character line width
- Scala 3 syntax
Running Specific Tests
Section titled “Running Specific Tests”# Run all testssbt test
# Run tests for a specific modulesbt "core/test"
# Run a single test classsbt "core/testOnly io.forge.jam.core.codec.BlockCodecTest"
# Run tests matching a patternsbt "protocol/testOnly *SafroleTest"
# Run with increased loggingsbt "set Test / logLevel := Level.Debug" testWorking with Native Libraries
Section titled “Working with Native Libraries”Rebuilding Native Libraries
Section titled “Rebuilding Native Libraries”Native libraries are automatically rebuilt if missing. To force a rebuild:
# Remove existing librariesrm -rf modules/crypto/native/build/
# Rebuildsbt crypto/compileDebugging Native Library Issues
Section titled “Debugging Native Library Issues”# Build manually with debug outputcd modules/crypto/native/bandersnatch-vrfs-wrappercargo cleancargo build --release --verbose
# Check library is loadable (macOS)otool -L target/release/libbandersnatch_vrfs_wrapper.dylib
# Check library is loadable (Linux)ldd target/release/libbandersnatch_vrfs_wrapper.soSet RUST_LOG environment variable for Rust library debug output:
RUST_LOG=debug sbt testUpdating Test Vectors
Section titled “Updating Test Vectors”Test vectors are in the jamtestvectors submodule:
# Update to latest test vectorscd jamtestvectorsgit pull origin maincd ..
# Run tests with new vectorssbt testBenchmarking
Section titled “Benchmarking”Run performance benchmarks:
# Run benchmark suitesbt benchmark
# The benchmark runs TracesBenchmark which measures STF performanceBuilding for Production
Section titled “Building for Production”Conformance Server
Section titled “Conformance Server”Create a standalone JAR with all dependencies:
# Build fat JARsbt "conformance/assembly"
# Run the serverjava -jar modules/conformance/target/scala-3.3.7/jam-conformance.jarDocker Build
Section titled “Docker Build”# Build Docker imagedocker build -t jam-scala:latest .
# Run containerdocker run -v /path/to/socket:/var/run/jam jam-scala:latestTesting Against Conformance Server
Section titled “Testing Against Conformance Server”Running Local Conformance Tests
Section titled “Running Local Conformance Tests”# Start the conformance serversbt "conformance/run"
# In another terminal, run fuzzing testscd jam-conformancepython3 scripts/fuzz-workflow.py --target jam-forge --mode exploratoryDebugging
Section titled “Debugging”Enable Debug Logging
Section titled “Enable Debug Logging”Set log level in src/main/resources/logback.xml or via environment:
# Run with debug loggingLOG_LEVEL=debug sbt test
# Or set in test codeSystem.setProperty("org.slf4j.simpleLogger.defaultLogLevel", "debug")