We provide two specialized development environments through Nix flakes:
For general node development, building, and testing:
# Clone the repository
git clone https://github.com/airalab/robonomics.git
cd robonomics
# Enter the development shell
nix developThis shell provides:
- Rust toolchain - Complete Rust environment with
cargo,rustc, andrustfmt - Build dependencies -
clang,openssl,protobuf, and other system libraries - Development tools:
taplo- TOML file formattersubxt-cli- Substrate metadata toolsrtool-cli- Deterministic WASM runtime builderpsvm- Polkadot SDK version managerframe-omni-bencher- Benchmarking tooltry-runtime- Dry-run runtime upgrade toolactionlint- GitHub Actions workflow linter
- Environment variables - Pre-configured
LIBCLANG_PATH,PROTOC,RUST_SRC_PATH
Common development tasks:
# Build in release mode
cargo build --release
# Run the node in development mode
./target/release/robonomics --dev
# Run all tests
cargo test --all
# Format code
cargo fmt
# Lint with clippy
cargo clippy --all-targets --all-features
# Format TOML files
taplo fmtFor multi-node testing with Zombienet:
nix develop .#robonetThis shell provides:
robonomics- Your built Robonomics node binarypolkadot- Polkadot relay chain binarypolkadot-parachain- Generic parachain binaryrobonet- ZombienetSDK based local networks orchestration tool
Use this for testing parachain functionality with multiple collators and relay chain nodes:
# Launch a test network
robonet spawn
# Run integration tests
robonet testDetailed robonet documentation available at crate README.
Running a Local Development Node:
The --dev flag starts a single-node development chain:
robonomics --devThis creates:
- A local testnet with pre-funded accounts (Alice, Bob, Charlie, Dave, Eve, Ferdie)
- Temporary storage (cleared on restart)
- WebSocket RPC endpoint at
ws://127.0.0.1:9944 - Block production every 6 seconds
Persisting Chain Data:
# Store chain data in a custom directory
robonomics --dev --base-path ./my-dev-chain
# Clear the chain and start fresh
robonomics --dev --base-path ./my-dev-chain purge-chainTesting Changes:
# Run all tests
cargo test --all
# Run tests for a specific pallet
cargo test -p pallet-robonomics-datalog
# Run integration tests
cargo test --features runtime-benchmarksRuntime benchmarking generates accurate weight functions for all pallets, which are crucial for accurate transaction fee calculation and preventing DoS attacks by ensuring extrinsics don't exceed block computational limits.
The easiest way to run benchmarks is using the dedicated benchmarking shell:
# Enter the benchmarking shell and run all benchmarks
nix develop .#benchmarking -c ./scripts/runtime-benchmarks.shThis single command will:
- Set up the complete benchmarking environment (Rust toolchain, frame-omni-bencher, etc.)
- Build the runtime with
runtime-benchmarksfeature - Run benchmarks for all runtime pallets
- Generate weight files →
runtime/robonomics/src/weights/
Customizing Benchmark Parameters:
You can customize the benchmark steps and repeats using environment variables:
# Use fewer steps/repeats for faster testing (default: steps=50, repeat=20)
BENCHMARK_STEPS=10 BENCHMARK_REPEAT=5 nix develop .#benchmarking -c ./scripts/runtime-benchmarks.sh
# Minimal settings for quick validation
BENCHMARK_STEPS=2 BENCHMARK_REPEAT=1 nix develop .#benchmarking -c ./scripts/runtime-benchmarks.shTo benchmark a specific pallet:
# Enter the benchmarking shell
nix develop .#benchmarking
# Benchmark a specific pallet
frame-omni-bencher v1 benchmark pallet \
--runtime ./target/release/wbuild/robonomics-runtime/robonomics_runtime.compact.compressed.wasm \
--pallet pallet_robonomics_datalog \
--extrinsic "*" \
--output ./weights.rs \
--header ./.github/license-check/HEADER-APACHE2 \
--steps 50 \
--repeat 20If you prefer not to use Nix:
# 1. Install frame-omni-bencher
cargo install --git https://github.com/paritytech/polkadot-sdk frame-omni-bencher
# 2. Run the benchmark script
./scripts/runtime-benchmarks.shBenchmark results are written as weight functions in Rust code. For example, in runtime/robonomics/src/weights/pallet_robonomics_datalog.rs:
// Example pseudocode - actual implementation uses trait methods
impl WeightInfo for WeightInfo<T> {
fn record() -> Weight {
Weight::from_parts(50_000_000, 0)
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(1))
}
}These weights are used by the runtime to:
- Calculate transaction fees accurately
- Prevent block overloading
- Ensure fair resource allocation
Before deploying runtime upgrades to production, you can dry-run them against live chain state using the scripts/try-runtime.sh script. This performs all migration and upgrade checks without modifying the actual chain.
Test against Kusama network (default):
./scripts/try-runtime.sh
# or explicitly
./scripts/try-runtime.sh kusamaTest against Polkadot network:
./scripts/try-runtime.sh polkadotThe script:
- Connects to public RPC endpoints (wss://kusama.rpc.robonomics.network or wss://polkadot.rpc.robonomics.network)
- Automatically builds the runtime with
try-runtimefeatures if not found - Runs
on-runtime-upgradechecks against live chain state - Validates that migrations execute successfully without errors
- Reports any issues before they reach production