LPsLux Proposals
EVM & Execution
LP-1300

Graph VM

Final

The G-Chain indexing VM — subgraph manifests deployed as transactions, WASM mapping handlers fed by Warp-delivered events, and a GraphQL endpoint per subgraph, with no external indexing infrastructure

Category
Core
Created
2021-03-01

Normative topology + fee model: LP-5210. G-Chain (graphvm) is a service VM, not one of the ten canonical primary chains. It MAY exist as a domain state machine but MUST NOT hold canonical UTXO asset supply, and MUST fund its fee balance from X.

Abstract

The Graph VM runs the G-Chain, a chain built for indexing and querying on-chain data across every Lux chain. Developers deploy subgraph manifests as G-Chain transactions. The VM ingests events from source chains as Warp messages, runs WASM mapping handlers over them to produce entity updates, stores the entities in its own key-value store, and answers GraphQL queries against that store. The G-Chain is the native indexing layer — no external indexing service is required.

Specification

Subgraph deployment

A subgraph manifest is deployed as a G-Chain transaction:

SubgraphManifest {
    name            string
    version         string
    sourceChainIDs  [][32]byte   // chains to index
    dataSources     []DataSource
    schema          string       // GraphQL SDL schema
    mappings        []byte       // WASM mapping handlers (AssemblyScript compiled)
}

DataSource {
    chainID     [32]byte
    address     address         // contract address to watch
    startBlock  uint64
    eventABI    []byte          // ABI of events to index
}

Indexing pipeline

  1. Event ingestion — Warp messages from source chains deliver event logs to the G-Chain.
  2. Mapping execution — WASM handlers process events and produce entity updates.
  3. Storage — entities land in the G-Chain's native key-value store.
  4. Query — GraphQL queries resolve against the entity store.

The VM executes WASM handlers in a sandbox with metered gas. Handlers may read entity state; they may not make external calls.

Query interface

Each subgraph exposes a GraphQL endpoint:

POST /v1/chain/{gchain-blockchain-id}/subgraphs/name/{subgraph-name}/graphql
{
    "query": "{ tokens(first: 10, orderBy: totalSupply) { id name totalSupply } }"
}

Queries are read-only and consume no gas. Rate limiting is enforced per client IP.

Cross-chain indexing

The G-Chain indexes all Lux chains at once:

  • C-Chain EVM events (Transfer, Swap, and the rest)
  • L1 / L2 chain events (Zoo, Hanzo, Pars, and any network spawned per LP-1020)
  • P-Chain staking events
  • X-Chain asset operations

Source-chain events arrive as Warp messages with guaranteed ordering per source chain.

Subgraph governance

  • Deployment fee — 10 LUX per subgraph deployment, which prices out spam.
  • Curation — users stake LUX on subgraphs they find useful and earn a share of that subgraph's query fees.
  • Deprecation — a subgraph owner can deprecate, which stops indexing and frees resources.

Security Considerations

  1. WASM sandboxing. Mapping handlers run in a metered WASM VM with no host access. Infinite loops die on the gas limit.
  2. Query denial of service. Complex queries are bounded by a query complexity limit — at most 1,000 entity fetches per query.
  3. Data integrity. Indexed data is derived deterministically from source chain events, so any G-Chain validator can verify it by re-executing the mappings.

Reference

ResourceLocation
Graph VMgithub.com/luxfi/node/vms/graphvm/
WASM runtimegithub.com/luxfi/node/vms/graphvm/wasm/
On-chain query precompileLP-1230
Embedded GraphDB and query engineLP-0098

Copyright and related rights waived via CC0.