terminalAPI Reference

How to interact with Continuum microsecond sequencer [Testnet]

Continuum Sequencer API Reference

This document provides comprehensive reference for both the gRPC and REST APIs of the Continuum Sequencer.

Overview

The Continuum Sequencer provides dual API access:

  • gRPC API: High-performance binary protocol for production integrations

  • REST API: JSON-based API for web applications and debugging

Both APIs provide access to transaction submission, tick querying, and chain state inspection.

Base URLs

  • gRPC: Default 0.0.0.0:9090

  • REST: Default 0.0.0.0:8080 with base path /api/v1

Authentication

Currently, the APIs are unauthenticated. Authentication and authorization will be added in future phases.


gRPC API

Service Definition

The gRPC service is defined in sequencer.proto:

Transaction Submission

SubmitTransaction

Submit a single transaction for ordering.

Request:

Response:

Example (grpcurl):

SubmitBatch

Submit multiple transactions in a single request.

Request:

Response:

Status and Monitoring

GetStatus

Get current sequencer status and metrics.

Request:

Response:

StreamTicks

Stream live ticks as they are produced.

Request:

Response Stream:

Data Queries

GetTransaction

Lookup a transaction by its hash.

Request:

Response:

GetTick

Retrieve a specific tick by number. The sequencer maintains 1 million ticks in memory for fast access. Older ticks are automatically archived to disk and can still be retrieved, though with slightly higher latency.

Request:

Response:

Archive Behavior:

  • Recent ticks (up to 1M) are served from memory

  • Older ticks are automatically archived to disk at data/archive/

  • Archived ticks are organized in subdirectories (10k ticks per directory)

  • Both memory and archived ticks are transparently accessible via the same API

GetChainState

Get chain state summary with recent ticks.

Request:

Response:


REST API

All REST endpoints return JSON responses with appropriate HTTP status codes.

Base Response Format

Success responses follow this structure:

Error responses:

Status Endpoint

GET /api/v1/status

Get sequencer status and metrics.

Response:

Example:

Transaction Submission

Note: Transaction submission via REST API is not yet implemented. Currently, transactions must be submitted through the gRPC API. REST submission will be added in a future release.

To submit transactions, use the gRPC SubmitTransaction or SubmitBatch endpoints as documented in the gRPC API section above.

Transaction Queries

GET /api/v1/tx/{hash}

Lookup transaction by 8-character hex hash.

Parameters:

  • hash: 8-character hexadecimal transaction hash

Response:

Example:

How Transaction Hashes Work:

  • Transaction hashes are 8-character hexadecimal strings (32 bits)

  • They represent the first 4 bytes of the SHA256 hash of the transaction data

  • The hash is computed from the serialized transaction including: tx_id, payload, signature, public_key, nonce, and timestamp

  • Due to the shortened hash, collisions are possible but rare in practice

Tick Queries

GET /api/v1/tick/{number}

Retrieve tick by number. Transparently serves from memory (recent 1M ticks) or disk archive (older ticks).

Parameters:

  • number: Tick number (integer)

Response:

Example:

Archive Notes:

  • Memory buffer: 1,000,000 most recent ticks

  • Older ticks archived to: data/archive/{subdir}/tick_{number}.json

  • Archive lookup adds ~10-50ms latency vs memory access

GET /api/v1/ticks/recent

Get recent ticks with pagination.

Query Parameters:

  • limit (optional): Maximum ticks to return (default: 20, max: 100)

  • offset (optional): Offset for pagination (default: 0)

Response:

Example:

Health Check

GET /api/v1/health

Simple health check endpoint.

Response:

Example:


Error Handling

HTTP Status Codes

  • 200 OK: Request successful

  • 400 Bad Request: Invalid request format or parameters

  • 404 Not Found: Resource not found (transaction, tick)

  • 500 Internal Server Error: Server error

  • 503 Service Unavailable: Service temporarily unavailable

gRPC Status Codes

  • OK: Request successful

  • INVALID_ARGUMENT: Invalid request parameters

  • NOT_FOUND: Resource not found

  • RESOURCE_EXHAUSTED: Queue full or rate limited

  • INTERNAL: Internal server error


Rate Limiting

Current implementation includes basic backpressure:

  • Transaction queue has configurable limits

  • Batch submissions continue processing even if individual transactions fail

  • gRPC streaming has channel-based backpressure


Data Types

Transaction Hash Format

Transaction hashes are 8-character hexadecimal strings representing the first 32 bits of the SHA256 hash of transaction data.

Example: deadbeef

Timestamps

All timestamps are in microseconds since Unix epoch (UTC).

Example: 1672531200000000 = 2023-01-01 00:00:00 UTC

VDF Proofs

VDF proofs contain:

  • input: Hex-encoded input bytes

  • output: Hex-encoded output bytes

  • proof: Hex-encoded proof bytes

  • iterations: Number of iterations performed

Tick Numbering

Ticks are numbered sequentially starting from 1. Tick 0 is reserved for genesis.


Security Considerations

  1. No Authentication: Current APIs are unauthenticated

  2. Input Validation: All inputs are validated for format and size

  3. Rate Limiting: Basic queue-based limiting prevents resource exhaustion

  4. Cryptographic Integrity: VDF proofs ensure tick authenticity


Performance Characteristics

  • Target Tick Time: ≤100 microseconds

  • Transaction Throughput: 100k+ tx/s ingestion capacity

  • VDF Verification: Batch verification provides 10x+ speedup

  • Memory Usage: Configurable tick retention (default: 1,000,000 ticks)


Complete Transaction Flow Example

Here's a complete example of submitting a transaction via gRPC and then querying it via REST:

1. Submit Transaction (gRPC)

2. Query Transaction Status (REST)

3. Verify Inclusion in Tick (REST)


Client Libraries

Rust

The sequencer crate can be used directly as a library:

gRPC Clients

Generate clients from the protobuf definition for any language:

  • Go: protoc-gen-go-grpc

  • Python: grpcio-tools

  • JavaScript: grpc-web

  • Java: protoc-gen-grpc-java

REST Clients

Standard HTTP clients work with the REST API:


Data Storage and Archiving

In-Memory Storage

The sequencer maintains a configurable number of recent ticks in memory for fast access:

  • Default: 1,000,000 ticks

  • Configurable: Via max_ticks parameter in ChainState::new()

  • Access time: Sub-millisecond

Disk Archiving

Older ticks are automatically archived to disk when pruned from memory:

  • Archive location: data/archive/

  • Directory structure: {tick_number / 10000}/tick_{10-digit-number}.json

  • Format: JSON for easy inspection and debugging

  • Automatic: Archiving happens transparently during pruning

  • Access: All APIs (GetTick, GetTransaction) automatically check archives

Archive File Example


Monitoring and Observability

Metrics Endpoints

Currently available through:

  • gRPC GetStatus call

  • REST /api/v1/status endpoint

Future releases will include:

  • Prometheus metrics exposition

  • OpenTelemetry tracing

  • Structured logging

Log Levels

Configure with RUST_LOG environment variable:

Available levels: trace, debug, info, warn, error

Last updated