This project delivers a production-ready Parallel Order Book that executes trades concurrently on-chain using Arcology’s concurrent programming model. By replacing serial bottlenecks with conflict-free data structures and atomic batch operations, it achieves a measured 3.46× speedup in live demos with a 100% success rate across parallel transactions.
At its core, the contract uses U256Cumulative counters for collision-free order IDs and a dual‑mapping layout for gas‑efficient, parallel‑safe reads and writes. Orders can be placed by many users at once without stepping on each other’s storage, enabling true parallel execution while preserving deterministic results. We validated this with a 1000‑transaction benchmark, per‑batch throughput metrics, and a full test suite.
The system is designed for high-throughput DeFi: DEX order books, AMMs with batched matching, HFT-style flows, and NFT or gaming marketplaces that need scalable, low-latency state updates. It’s deployed on Arcology DevNet and built with Hardhat 3.0 (native node:test + Viem), TypeScript scripting, and Foundry-compatible Solidity tests to offer modern DX and rigorous guarantees.
Key outcomes:
- 3.46× end-to-end speedup vs. theoretical sequential time
- 100% transaction success in parallel placement
- 1000‑tx benchmark with per-batch throughput and timing
- Production-grade deployment with security checks and full coverage
Technologies
- Smart contracts: Solidity 0.8.28
- Framework: Hardhat 3.0 (native node: test runner), Viem for type-safe interactions, Foundry-compatible Solidity tests
- Concurrency: Arcology concurrent primitives (U256Cumulative counters), parallel-safe storage patterns
- Tooling: TypeScript scripts for deployment, benchmarking, and parallel transaction orchestration
- Network: Arcology DevNet (live deployment and measurements)
Architecture and approach
- Parallel-safe order placement: Each new order ID is generated via U256Cumulative, avoiding write conflicts even under bursty, multi-user loads.
- Dual-mapping storage: Separates order metadata and amounts with 256‑bit packing to minimize gas and isolate write paths for concurrent updates.
- Batched execution: Off-chain scripts submit bursts of transactions concurrently, while on-chain logic preserves determinism and atomicity for matching/settlement steps.
- Deterministic outcomes: Parallel writes are made conflict-free by construction, removing dependency on transaction ordering.
Build and testing
- Hardhat 3.0 + node:test: TypeScript integration tests validate parallel flows, RPC interactions, and failure modes.
- Foundry-compatible Solidity tests: Unit‑level checks for counters, storage integrity, events, and error paths.
- Coverage and performance: Gas profiling and end-to-end throughput measurements; demo slide shows batch timings and aggregate metrics.
- Benchmarks: 1000‑tx workload generated and executed via scripts, with JSON summaries checked into the repo.
Notable hacks/engineering wins
- BigInt serialization fixes in deployment/benchmark scripts for Ethers/Viem compatibility.
- Private key and RPC configuration hardening for Arcology DevNet.
- Storage layout tuned to minimize conflict domains and gas on hot paths.
- Resilient batching with retry/backoff to handle transient RPC conditions during high concurrency.
Why it matters
- Removes the serial bottleneck in on-chain order books using pragmatic, verifiable concurrency patterns.
- Demonstrates that parallel execution can deliver real throughput gains without sacrificing determinism or developer ergonomics.
- Ships with production-ready scripts, tests, and a polished demo deck to make adoption and evaluation straightforward for DEX and DeFi teams.