Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SpatiaVM

A Parallelized, Deterministic, and Physics-Aware Virtual Machine

Rust Edition License: MIT Build Status Throughput DOI

Overview · Architectural Pillars · Benchmarks · Quickstart · Tests · Citation · License


Overview

SpatiaVM is a high-throughput, domain-specific Virtual Machine written in pure Rust (Edition 2024) designed specifically for Decentralized Spatial Computing, Cyber-Physical Systems (CPS), Autonomous Drone Fleets, and Industrial Digital Twins.

Existing blockchain VMs (EVM, SVM, MoveVM) are strictly architected for 1D financial accounting and key-value state transfers. SpatiaVM elevates 3D spatial geometry, deterministic fixed-point rotational kinematics, dynamic volume gas metering, and spatial parallel scheduling into native Layer-0/1 execution primitives.


🏛️ Architectural Pillars

  1. Deterministic Fixed-Point Kinematics Engine: Q32.32 fixed-point (Fixed64) and quaternion (QuaternionFixed) arithmetic eliminates IEEE-754 hardware floating-point consensus splits across heterogeneous CPUs.
  2. $O(1)$ 3D Spatial Hash Grid Indexer: Replaces $O(N)$ linear scans with discrete 3D spatial cell hashing (SpatialHashGrid3D) for candidate collision queries.
  3. Native Spatial Instruction Set Architecture (ISA): Bytecode-level opcodes (RegisterObject, MoveObject3D, CheckCollision, AssertPhysicsBounds).
  4. Spatially-Partitioned Parallel Scheduler: Evaluates 3D Bounding Box footprints (BoundingBox3D) to concurrently dispatch non-overlapping spatial transactions across multi-core CPUs.
  5. Dynamic Spatial Gas Metering & TTL State Pruning: Prevents DoS attacks and mitigates state bloat via Time-To-Live (TTL) garbage collection (SpatialPruner).
  6. Zero-Knowledge Readiness: Logs deterministic state root hashes (SpatialStateCommitment) and zk-STARK execution trace step commitments (ExecutionTraceRecorder).

🚀 Performance Benchmarks

All benchmarks were evaluated on an AMD EPYC 7763 16-Core Processor running Ubuntu 24.04 LTS (rustc 1.96.0, --release profile):

Benchmark Result
Peak Execution Throughput 20,251.24 TPS — 1,000 spatial transactions processed in 49.00 ms
Multi-Threaded Speedup 8.26x parallel speedup across 16 worker threads
Spatial Lookup Acceleration 992x reduction in collision lookup latency ($1.1,\mu s$ $O(1)$ vs $1,290,\mu s$ $O(N)$)
State Memory Footprint Reduction 84.1% active memory reduction via Ephemeral TTL Pruning (stabilized at 12.1 MB)

🛠️ Quickstart & Integration

Add spatia_vm as a dependency in your Cargo.toml:

[dependencies]
spatia_vm = { git = "https://github.com/YOUR_USERNAME/spatia_vm" }

Example Usage: Registering & Translating 3D Spatial Objects

use spatia_vm::{
    VirtualMachine, SpatialState, Program, Instruction,
    Vector3D, Fixed64, SpatialObject, BoundingBox3D
};

fn main() {
    let state = SpatialState::new();
    let mut vm = VirtualMachine::new(state, 100_000, 1000);

    let mut program = Program::new();

    // 1. Register a 3D Drone with ID 101 at bounds (0,0,0) to (5,5,5)
    program.push(Instruction::RegisterObject {
        id: 101,
        mass: Fixed64::from_i32(10),
        min: Vector3D::ZERO,
        max: Vector3D::new(Fixed64::from_i32(5), Fixed64::from_i32(5), Fixed64::from_i32(5)),
    });

    // 2. Translate Drone 101 by (+10, +10, +10) with automatic non-collision enforcement
    program.push(Instruction::MoveObject3D {
        id: 101,
        offset: Vector3D::new(Fixed64::from_i32(10), Fixed64::from_i32(10), Fixed64::from_i32(10)),
    });

    program.push(Instruction::Halt);

    // Execute program deterministically
    let receipt = vm.execute(&program).expect("Program execution failed");
    println!("Program Executed Successfully: {}", receipt.is_success);
    println!("Gas Used: {}", receipt.gas_used);
    println!("Merkle State Root Hash: {:?}", receipt.state_root);
}

🧪 Running Unit Tests & Benchmarks

Run the complete test suite (13 passing tests):

cargo test

Run tests with console output to view the high-throughput performance report:

cargo test -- --nocapture

📖 Citation

If you use SpatiaVM in your research or industrial applications, please cite our paper:

@misc{moradi2026spatiavm,
  author       = {Moradi, Mohammad Amin},
  title        = {SpatiaVM: A Parallelized, Deterministic, and Physics-Aware Virtual Machine for Decentralized Spatial Computing and Digital Twins},
  year         = {2026},
  publisher    = {Zenodo},
  doi          = {10.5281/zenodo.21605704},
  url          = {https://doi.org/10.5281/zenodo.21605704}
}

📖 Read the full paper on Zenodo (CERN)

---

👤 Author

LinkedIn


📜 License

Distributed under the MIT License. See LICENSE for more information.

About

SpatiaVM: A high-throughput, deterministic, and physics-aware Virtual Machine in Rust (Edition 2024) for Decentralized Spatial Computing, Cyber-Physical Systems, DePIN, and Digital Twins. Features Q32.32 fixed-point math, 3D Spatial Hash Grid indexing, native 3D spatial ISA, volume gas metering, and 20,251+ TPS parallel execution.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages