LPsLux Proposals
Consensus Systems
LP-140

QuasarSTM Ordered MVCC Fabric

Draft

The GPU-native, lane-aware ordered MVCC execution fabric beneath Lux's Nova (linear) and Nebula (DAG) modes — lanes, three-tier validation, semantic reducers, checkpoint repair, commit horizons, multi-GPU sharding.

Category
Core
Created
2025-03-01

Abstract

QuasarSTM is the GPU-native ordered MVCC execution fabric underneath Lux's Nova (linear) and Nebula (DAG) modes. It is not "a parallel executor with repairs". It is the serializability fabric beneath Prism frontiers, EVM fibers, DEX precompiles, and Quasar-certified roots.

The load-bearing property: QuasarSTM is not a retroactive conflict detector but a scheduler-aware fabric that continuously feeds contention telemetry back into Prism partitioning. When the fabric is constantly repairing, the design has failed; QuasarSTM keeps repair amplification below 1% under realistic exchange-style workloads.

Module layout

lib/consensus/quasar/gpu/stm/
  quasar_stm_layout.hpp
  quasar_stm_engine.hpp
  quasar_stm_validate.metal     // tier 1+2+3 validation
  quasar_stm_repair.metal        // checkpoint rollback + full re-exec
  quasar_stm_commit.metal        // horizon detection + root material
  quasar_stm_gc.metal            // version arena reclamation

Public symbols:

QuasarSTM, QuasarSTMWorkspace
StmTxn, StmKeyHeader, StmVersion
StmLane, StmLaneClock, StmLaneHint
StmFrontier, StmConflict, StmRepair, StmCommitHorizon
StmTelemetry

Pipeline

Quasar round
  ↓
Nova order  /  Nebula DAG
  ↓
Prism frontier
  ↓
lane refraction         ← prevents conflicts before STM sees them
  ↓
EVM fiber execution
  ↓
ordered MVCC writes
  ↓
lane-clock fast validation        ← Tier 1
  ↓
key-level visible-version validation  ← Tier 2
  ↓
semantic commutativity validation     ← Tier 3
  ↓
checkpoint rollback / repair          ← incremental
  ↓
commit horizon                        ← prefix/cut, not per-tx
  ↓
root material
  ↓
QuasarRoundResult

Scientific foundations

QuasarSTM borrows from three concurrency-control families and discards their failure modes for GPU + ordered-output settings.

From Block-STM (Gelashvili et al., 2022)

Keep: deterministic ordered execution model. Transactions execute in parallel; validation guarantees the final result matches the canonical order; conflicts trigger re-execution. Block-STM's central contribution is treating a known transaction order as useful validation structure rather than a serialization bottleneck.

From TicToc (SIGMOD 2016, Yu et al.)

Borrow: per-data-item read/write timestamps avoid a centralized timestamp counter. Adapt: timestamps are used to reduce false aborts, not to alter canonical consensus order. TicToc cannot reorder Nova/Nebula commit order — it only proves that an observed version is still serializable under the canonical order.

From TL2 (DISC 2006, Dice/Shalev/Shavit)

Borrow: commit-time locking + version-clock validation. Adapt: no single global TL2 clock. Lane clocks replace it. Fast path validates by lane-clock invariance; fallback drops to exact key-version check.

From the GPU-STM literature (Cederman et al., Holey et al.)

Discard: nondeterministic contention managers, unbounded retry loops, SIMT livelock under hot-key contention. Replace with deterministic conflict policies (§"Deterministic contention manager") and commit horizons that amortize finalization across whole prefixes/cuts.

Lanes — the primary abstraction

A lane is the smallest independently schedulable state domain.

lane_id = H(domain, contract, account, asset, market, nonce_lane,
            storage_prefix)

Examples:

LaneDefinition
sender nonce laneH("nonce", account_id, nonce_idx)
account balance laneH("acct", account_id)
ERC-20 holder laneH("erc20", token, holder)
order book price-level laneH("ob", market_id, price_level)
margin account laneH("margin", account_id)
pool reserve laneH("pool", pool_id)
audit append laneH("audit", chain_id, epoch)
fee accumulator laneH("fee", token)

Each transaction declares lane hints:

struct StmLaneHint {
    Hash lane_id;
    uint8_t access_kind;   // Read, Write, Append, Reduce, Unknown
    uint8_t confidence;    // predictor confidence 0..255
};

Lanes are used for:

  • frontier partitioning (Prism refraction)
  • fast validation (lane-clock check)
  • hot-key detection (hotness counter per lane)
  • semantic reduction (per-lane reducer registration)
  • repair priority (hot-lane repairs preempt cold ones)
  • multi-GPU sharding (gpu_id = H(lane_id) % num_gpus)

Without lanes, an STM discovers contention too late. With lanes, QuasarSTM becomes a safety net and Prism becomes the primary scheduler.

Ordered MVCC layout

Key header

struct StmKeyHeader {
    Hash     key;
    uint32_t head_version;             // newest speculative or committed
    uint32_t latest_committed_version;
    uint32_t lane_id;
    uint32_t hotness_score;
    uint64_t read_ts;                  // TicToc max reader timestamp
    uint64_t write_ts;                 // latest writer timestamp
    uint32_t flags;
};

Version record

struct StmVersion {
    Hash     key;
    uint32_t tx_index;     // Nova linear or Nebula topo index
    uint16_t incarnation;
    uint16_t flags;
    uint64_t read_ts;
    uint64_t write_ts;
    uint32_t value_offset;
    uint32_t value_len;
    uint32_t prev_version;
    uint32_t next_version;
};

Canonical version order: (key, tx_index, incarnation). Two GPU threads writing speculative versions for the same key MUST produce a deterministically sorted visible chain. No race-dependent visibility.

Transaction state machine

enum class StmTxnState : uint8_t {
    New,
    Predicted,
    Refracted,
    Executing,
    SuspendedState,        // waiting on cold-state page
    Executed,
    LaneValidated,         // tier 1 OK
    KeyValidated,          // tier 2 OK
    SemanticallyValidated, // tier 3 OK
    RepairPending,
    Repairing,
    Committable,
    Committed,
    Aborted,
    Faulted,
};

Per-tx record:

struct StmTxn {
    uint32_t  tx_id;
    uint32_t  tx_index;          // canonical position
    uint32_t  incarnation;
    uint32_t  lane_hint_offset;
    uint16_t  lane_hint_count;
    uint32_t  read_set_offset;
    uint32_t  read_set_count;
    uint32_t  write_set_offset;
    uint32_t  write_set_count;
    uint32_t  checkpoint_offset;
    uint16_t  checkpoint_count;
    uint16_t  conflict_score;
    uint16_t  hotness_score;
    StmTxnState state;
};

Visibility rule

Nova (linear):

visible_version(tx_i, key) =
    newest valid version written by tx_j where j < i

Nebula (DAG):

visible_version(v_i, key) =
    newest valid version written by a causally visible predecessor,
    using deterministic tie-breaks within the Prism cut

The STM engine takes a mode-specific ordering oracle:

struct StmOrderOracle {
    QuasarMode mode;
    bool happens_before(VertexId a, VertexId b);   // Nebula
    bool ordered_before(TxId a, TxId b);            // Nova
    uint32_t canonical_index(TxId tx);
};

Three-tier validation

Tier 1 — lane-clock fast validation

Each lane has a clock:

struct StmLaneClock {
    uint64_t version;
    uint64_t hotness;
    uint64_t conflict_count;
};

At execution start, the transaction snapshots touched lane clocks:

struct LaneSnapshot {
    uint32_t lane_id;
    uint64_t observed_clock;
};

Fast validation:

if all touched lane clocks unchanged:
    transaction is lane-valid → Committable
else:
    fall back to Tier 2

This is the TL2 validation idea adapted to per-lane clocks instead of a global version clock.

Tier 2 — key-level MVCC validation

For every read entry:

struct StmRead {
    uint32_t tx_id;
    Hash     key;
    uint32_t version_id;
    uint64_t observed_write_ts;
    uint64_t observed_lane_clock;
};

Check: the read's version_id is still the visible version under the canonical order. If not, it's a conflict and the transaction goes to Tier 3 for semantic check or directly to Repair.

Tier 3 — semantic validation (commutative reducers)

Many writes commute deterministically. Validate them semantically:

enum class StmWriteOp : uint8_t {
    Set,
    Add,
    Sub,
    Min,
    Max,
    Append,
    BitOr,
    BalanceDelta,
    OrderAppend,
    FeeAccumulate,
};
Op pairCommutes?
Append + AppendYes (deterministic ordering by tx_index)
Add + AddYes (reduce sum)
FeeAccumulateYes (reduce sum)
BalanceDelta + BalanceDeltaYes if no overdraft and canonical netting passes
OrderAppendYes inside a batch-auction lane
Set + anythingNo

Semantic validation is the difference between "fast blockchain" and "fast exchange". It is mandatory for the order book / fee / balance lanes that dominate exchange workloads.

TicToc-style timestamps (without breaking determinism)

Per key:

  • read_ts = max timestamp of all readers
  • write_ts = timestamp of latest writer

Per transaction:

  • tx.read_ts_min = max(write_ts of versions read)
  • tx.write_ts = max(read_ts of keys written) + 1

A transaction can validate if there exists a timestamp compatible with all read versions, all write targets, and the canonical Nova/Nebula ordering constraint. This admits more commits than strict "anything changed means abort" while preserving deterministic output.

Hard rule: TicToc timestamps cannot reorder consensus. They only prove that an observed version is still serializable under the canonical order.

Prism refraction

For Nebula, the frontier is a ready antichain — but ready ≠ conflict-free. Refraction partitions the frontier so the STM rarely sees the same hot conflict twice:

1. Take ready frontier.
2. Hash lane hints.
3. Build lane conflict matrix.
4. Partition into slices:
     - disjoint write lanes together
     - read-only lanes together
     - hot write lanes isolated (one slice per hot lane)
5. Submit slices to EVM fibers.

Refraction is the most important performance feature. The STM should not constantly repair the same hot conflicts. Prism refracts them first. The frontier/cut primitives are LP-0116.

Incremental repair (fiber checkpoints)

Full transaction re-execution is too expensive for complex EVM flows (routers, multi-hop swaps, compliance precompiles).

Add checkpoints at:

  • CALL boundaries
  • SLOAD / SSTORE boundaries
  • precompile boundaries
  • basic-block budget boundaries
  • DEX semantic-operation boundaries
  • cold-state resume boundaries
struct EvmFiberCheckpoint {
    uint32_t tx_id;
    uint32_t pc;
    uint32_t frame_offset;
    uint32_t stack_offset;
    uint32_t memory_offset;
    uint32_t journal_offset;
    uint32_t read_set_count;
    uint64_t gas_used;
};

Repair policy:

if invalid read occurred after checkpoint K:
    rollback to K
    keep decoded bytecode, calldata, warm state, earlier valid reads
    resume fiber with new visible version
else:
    full re-exec

Telemetry:

  • checkpoint_rollback_count
  • full_reexec_count
  • rollback_saved_gas
  • rollback_saved_wave_ticks

For routers, DEX settlement, and compliance precompiles, incremental repair routinely cuts repair cost by 5–30×.

Deterministic contention manager

The GPU-STM literature flags scalability and SIMT livelock as the two hardest issues. QuasarSTM's contention manager is always deterministic:

enum class StmConflictPolicy : uint8_t {
    EarlierWins,
    HotLaneSerialize,
    RefractionSplit,
    IncarnationBackoff,
    SemanticReducer,
    ColdQueueDemotion,
};

Policy order:

  1. Earlier canonical tx wins.
  2. Later tx repairs.
  3. If same lane conflicts repeatedly → lane becomes hot.
  4. Hot lane is serialized or replaced by semantic reducer.
  5. If frontier conflict rate is high → split future Prism cuts.
  6. If incarnation count exceeds threshold → demote to cold repair queue.

No nondeterministic victim selection. No spinlocks. No retry-until- success loops.

Hot-lane handling

Detect hot lanes:

hotness = reads + 4·writes + 8·conflicts + 16·repairs

When hotness exceeds threshold:

enum class HotLaneMode : uint8_t {
    Serialize,    // process strictly in canonical order
    Reduce,       // collapse via semantic reducer
    Precompile,   // route to a custom precompile
    Defer,        // demote to next round if non-critical
};
Hot laneMode
ERC-20 totalSupplyReduce or Serialize
AMM reservesPrecompile / batch auction
order book price levelAppend + deterministic match
fee counterAdd reducer
sender nonceSerialize per sender
compliance identitySerialize or snapshot

Hot lanes are not bugs; they are where app-specific economics live. QuasarSTM makes them explicit primitives.

Commit horizon

Don't commit transaction-by-transaction if a whole prefix/cut is stable:

struct StmCommitHorizon {
    uint32_t start_index;
    uint32_t end_index;
    Hash     horizon_root;
    uint32_t tx_count;
};

A commit horizon is valid when:

  • all transactions in prefix/cut are valid
  • no unresolved earlier dependency exists
  • no suspended state request blocks visibility
  • all hot-lane reducers finalized
ModeHorizon shape
Novacontiguous valid prefix of linear order
Nebulavalid causal cut (Horizon + Flare)

Root construction consumes horizon material in batches, slashing per-tx cert overhead.

MVCC garbage collection

Speculative versions destroy memory if not aggressively reclaimed. Epoch/horizon GC:

safe_gc_point = min(
    lowest active tx index,
    lowest repair dependency,
    current commit horizon,
    lowest live checkpoint reference)

GC reclaims:

  • invalid incarnations older than safe_gc_point
  • superseded speculative versions
  • checkpoint memory not referenced by any active repair
  • read records for committed transactions

A dedicated ServiceId::StmGC workgroup runs the reclaimer concurrently with execution.

Telemetry:

  • versions_allocated
  • versions_reclaimed
  • checkpoint_bytes_live
  • mvcc_arena_pressure

Multi-GPU sharding

QuasarSTM is multi-GPU-ready from the data model.

Shard by lane:

gpu_id = H(lane_id) % num_gpus

Cross-lane transactions:

  • local if all touched lanes map to one GPU
  • distributed if lanes span GPUs

Distributed-tx protocol:

  1. execute local read/write fragments
  2. produce per-GPU fragment roots
  3. validate lane clocks on owning GPUs
  4. aggregate validation result
  5. commit only if all fragments valid

Implementation status: PARTIAL — the data structures support the distributed path; the single-GPU path remains the production default.

Service layout

QuasarSTM splits monolithic Validate/Repair into purpose-built services:

enum class ServiceId : uint16_t {
    StmPredict          = 0x0410,
    StmRefract          = 0x0411,
    EvmFiberExec        = 0x0420,
    StmLaneValidate     = 0x0430,
    StmKeyValidate      = 0x0431,
    StmSemanticValidate = 0x0432,
    StmRepairSelect     = 0x0440,
    StmRepairExec       = 0x0441,
    StmCommitHorizon    = 0x0450,
    StmGC               = 0x0451,
};

Each stage has different GPU behavior — separating them lets the wave-tick scheduler tune per-stage budget and lane priority independently.

Telemetry

struct QuasarStmTelemetry {
    uint32_t tx_count;
    uint32_t committed_count;
    uint32_t conflict_count;
    uint32_t repair_count;
    uint32_t full_reexec_count;
    uint32_t checkpoint_rollback_count;
    uint32_t lane_fast_valid_count;       // tier 1 hits
    uint32_t key_valid_count;              // tier 2 hits
    uint32_t semantic_valid_count;         // tier 3 hits
    uint32_t hot_lane_count;
    uint32_t hot_lane_serialized_count;
    uint32_t semantic_reduce_count;
    uint32_t max_incarnation;
    uint32_t p99_incarnation;
    uint32_t fibers_suspended;
    uint32_t fibers_resumed;
    uint32_t mvcc_versions_allocated;
    uint32_t mvcc_versions_reclaimed;
    uint32_t commit_horizon_count;
};

The single most important metric:

repair_amplification = repair_count / committed_count

Targets:

  • normal DEX workload: < 1.01
  • heavy contention: controlled degradation, not repair explosion

If repair_amplification > 1.05 for sustained periods, the design intent is being violated and Prism refraction needs tuning.

Correctness invariants (test-enforced)

  1. Deterministic output — same input + same parent state + same mode → same roots.
  2. Serializability — committed result equals canonical Nova order or deterministic Nebula causal order.
  3. No host authority — host cannot choose validate / repair / commit order. Host is doorbell + I/O only.
  4. MVCC visibility — every read observes the correct visible version for its position in the canonical order.
  5. Repair monotonicity — each repair increments incarnation; invalid incarnations cannot commit.
  6. Horizon safety — no transaction beyond unresolved dependencies may enter a commit horizon.
  7. Cross-backend equivalence — Metal == CUDA == CPU reference for state_root, receipts_root, execution_root, mode_root, and conflict/repair behavior wherever deterministic.

Benchmark ladder (conformance suite)

BenchWorkloadTarget
A. Zero conflict1M / 10M / 100M disjoint lane transferslane-fast validation > 95%
B. Zipfian contentionZipf-sampled keyshot-lane detection + bounded repair amplification
C. AMM hotspotmany swaps against same poolgeneric STM degrades; semantic / precompile path survives
D. Order-book appendmany appends to same marketappend reducer + deterministic batch matching
E. Router workloadlong EVM fibers with late SLOAD conflictcheckpoint rollback beats full re-exec
F. Cold-state suspensionforced page missessuspended fibers do not stall the wave scheduler
G. Nebula frontierDAG antichains of varying conflict densityPrism refraction reduces repair_count

Forbidden patterns

QuasarSTM must not use:

  • one global STM clock
  • one global version map lock
  • retry-until-success GPU loops
  • nondeterministic conflict victim choice
  • opcode-level STM (it's tx-level)
  • CPU conflict manager
  • host-side repair scheduler
  • per-version malloc (use the arena)
  • global hot-key spinlocks

These either break determinism or kill GPU throughput.

Design statement

QuasarSTM is a GPU-native ordered MVCC fabric for EVM execution. Prism exposes causal frontiers, lanes predict state independence, EVM fibers execute speculatively, lane clocks validate the fast path, ordered MVCC validates exact visibility, semantic reducers preserve commutative throughput, deterministic contention management prevents repair storms, checkpoints make repair incremental, and commit horizons feed Quasar-certified roots.

One sentence: QuasarSTM turns an STM from a repair loop into a GPU-native serializability fabric.

Implementations

ImplementationLanguageGPU support
evmgpu (Lux)Govia CGo bridge
cevm (Lux)C++native Metal + CUDA

The Go reference (evmgpu) tracks the CPU contract for cross-checking determinism. The GPU fabric ships in cevm/lib/consensus/quasar/gpu/stm/. The production execution profile — full EVM opcode coverage, real cryptographic verifiers, ConflictSpec ABI, LaneClass, dynamic per-lane versioning — is LP-1040.

References

  • Block-STM: Gelashvili et al., 2022
  • TicToc: Yu, Pavlo, Sanchez, Devadas, SIGMOD 2016
  • TL2: Dice, Shalev, Shavit, DISC 2006
  • GPU-STM scalability: Cederman, Gidenstam, Tsigas; Holey, Zhai
  • LP-5607 — GPU acceleration framework
  • LP-0110 — Quasar consensus
  • LP-0116 — Prism DAG geometry (frontiers and cuts)
  • LP-1040 — QuasarSTM production profile
  • LP-9999 — DEX V4 receipt-settlement precompile (0x9999), a primary QuasarSTM consumer. It declares a fine-grained access set (consumedReceipt[receiptID], balance[acct][asset], sharded feeBucket[asset][epoch % N]) with no global hot write slots, so thousands of independent fill settlements commit in parallel and only genuine account/asset/receipt/pool conflicts serialize.

Copyright and related rights waived via CC0.