Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.generalmarket.io/llms.txt

Use this file to discover all available pages before exploring further.

Oracle Nodes

Three machines agree every second. This is more than most committees achieve in a year. Written in Rust (68K LOC), the oracle nodes are the consensus layer of the protocol. They batch orders, coordinate BLS signing across peers, and submit confirmed batches on-chain. One-second cycles. Round-robin leaders. No meetings.

What They Do

Five obligations, repeated every second, without complaint:
  • Collect pending orders from the Index contract
  • Propose batches and coordinate BLS multi-party signing
  • Submit confirmed batches on-chain with aggregated signatures
  • Trigger rebalancing when DTF weights are updated
  • Maintain price consensus for NAV computation

Key Modules

ModuleResponsibility
consensus/BLS signature aggregation, threshold validation, batch agreement protocol
cycle/1-second cycle state machine with 5 phases (200ms each)
p2p/TCP transport with TLS, peer discovery (static config + on-chain registry)
chain/Ethereum/L3 RPC interaction, transaction submission, event monitoring
netting/Order netting engine — matches opposing orders, handles USDT pair routing, computes net exposure
leader/Round-robin leader election, batch proposal construction
price/Price feed aggregation from data node, consensus on prices used in batches
state/Local state management, pending order tracking, batch history

Consensus Flow

Agreement is not optional. The protocol requires it on every batch.
The BLS threshold of ceil(2n/3) ensures Byzantine fault tolerance — the oracle nodes can tolerate up to floor((n-1)/3) malicious or offline oracle nodes while still making progress.

Cycle Timing

One second. Five phases. 200 milliseconds each. The precision is not aspirational — it is enforced.
PhaseDurationAction
COLLECT200msGather new pending orders from chain events and peer gossip
PROPOSE200msLeader constructs and broadcasts the proposed batch
SIGN_SUBMIT200msPeer oracle nodes validate the proposal and return BLS partial signatures
CONFIRM200msLeader aggregates signatures and submits the confirmed batch on-chain
REBALANCE200msProcess any pending DTF rebalance operations (weight updates → new quantities)

Leader Election

Round-robin. Deterministic. Based on the node’s index in OracleRegistry.sol. The leader rotates every second. The leader builds the proposal, aggregates signatures, and submits the batch. If a leader fails, the cycle is lost and the next leader takes over. No negotiation. No second chances.

Peer-to-Peer Transport

PropertyDetail
TransportTCP with TLS
DiscoveryStatic config + on-chain registry via OracleRegistry.sol
MessagesBatch proposals, BLS partial signatures, heartbeats
SerializationBinary, because latency is not negotiable
Persistent connections to all peers. Automatic reconnection. The P2P layer handles the messiness of networks so the consensus layer does not have to.

Netting Engine

A buyer and a seller of the same asset in the same batch cancel each other out. Only the remainder reaches the exchange. This is not clever — it is obvious. But obvious things must still be built.
  • Order netting — buy and sell for the same asset offset, reducing net AP execution
  • USDT pair routing — when direct pairs are unavailable
  • Rebalance deltas — on weight change, computes the minimal trades to move from old quantities to new while preserving NAV

BLS Details

PropertyDetail
CurveBN254 (alt_bn128)
EVM compatibilityUses precompiles at 0x06 (addition), 0x07 (scalar multiplication), 0x08 (pairing)
Key registrationEach oracle node registers the node’s BLS public key in OracleRegistry.sol
AggregationPartial signatures are aggregated into a single signature by the leader
VerificationOn-chain via BLSLib.sol against the stored aggregated public key
BLS verification is never bypassed — not in local development, not in tests, not anywhere. If BLS is blocking development, the correct approach is to fix the BLS pipeline (generate proper test keys, register them in OracleRegistry, compute valid signatures), not to add bypass logic.

Security: AP Isolation (FR13)

The oracles and the AP do not talk. They cannot. This is not a limitation — it is the architecture.
Oracle nodes cannot communicate directly with the AP. The AP discovers confirmed batches exclusively through on-chain TradeRequest events. This boundary exists because if the signers and the executor could coordinate off-chain, the system would have a single point of collusion.
  Oracle Nodes                L3 Chain                AP
  ┌───────────┐         ┌──────────────┐        ┌─────────┐
  │           │────tx──►│  Index.sol   │        │         │
  │  Consensus│         │              │──event─►│ Execute │
  │  + BLS    │         │ confirmBatch │        │  Fills  │
  │           │         │  emits event │        │         │
  └───────────┘         └──────────────┘        └─────────┘
        ▲                                            │
        │              No direct link                │
        └────────────── ✕ ───────────────────────────┘