VM Tooling & Test Harness
Source: crates/vm-tooling, crates/vm-test-harness
Overview
Section titled “Overview”Ashen ships two developer utilities for contract work:
vm-tooling: CLI for validation, disassembly, tracing, gas profiling, and tier predecode.vm-test-harness: in-memory host for running Zig/Rust contracts without a full node.
vm-tooling CLI
Section titled “vm-tooling CLI”Binary: vm-tooling (crate: crates/vm-tooling).
Common Commands
Section titled “Common Commands”Deploy manifest
Section titled “Deploy manifest”vm-tooling deploy-manifest --out deploy.jsonELF validation
Section titled “ELF validation”vm-tooling elf-validate --elf contract.elf --manifest deploy.jsonDisassembly
Section titled “Disassembly”vm-tooling disasm --file contract.elf --start 0x0 --len 256Trace execution
Section titled “Trace execution”vm-tooling trace --file contract.elf --entry 0x0 --gas 1000000 --calldata-hex 0x...Gas schedule dump
Section titled “Gas schedule dump”vm-tooling gas --jsonCode cache stats
Section titled “Code cache stats”vm-tooling cache-stats --max-entries 1024 --max-bytes 268435456Predecode to tier
Section titled “Predecode to tier”vm-tooling predecode --elf contract.elf --tier jit --out contract.jitvm-tooling predecode --elf contract.elf --tier aot --out contract.aotGas profiling
Section titled “Gas profiling”vm-tooling gas-profile --file contract.elf --gas 1000000 --trace-out gas.jsonGas budgets
Section titled “Gas budgets”vm-tooling gas-budget-check --config .gas-budgets.toml --contracts-dir contracts/Conformance corpus
Section titled “Conformance corpus”vm-tooling corpus-freeze --out corpus/ --cases 1000vm-tooling corpus-run --dir corpus/ --tier interpretervm-test-harness
Section titled “vm-test-harness”Crate: crates/vm-test-harness.
It provides a lightweight host for executing contracts with deterministic storage, events, and result parsing.
Example
Section titled “Example”use vm_test_harness::{ContractHarness, TestHost, TestAccounts};use vm_test_harness::{assert_call_ok, build_calldata};
let accounts = TestAccounts::default();let mut host = TestHost::new();host.seed_default_balances(&accounts);
let harness = ContractHarness::from_zig_artifact( "contracts/my_token/zig-out/bin/my_token",).expect("artifact exists").expect("load contract");
let calldata = build_calldata(*b"MINT", &accounts.alice);let result = harness.call(&mut host, &accounts.alice, b"my_token", &calldata, 1_000_000);assert_call_ok(&result, "mint should succeed");Assertions and Fixtures
Section titled “Assertions and Fixtures”The harness includes helpers for:
- Event emission checks
- Storage assertions
- Host state fixtures
- ABI-compatible calldata builders
Related Docs
Section titled “Related Docs”docs/design/gas-profiler-flame-graphs.mddocs/design/simulation-mode.mddocs/design/cross-contract-call-tracing.md