跳到正文
DEV Community· mech.app·· 4 小時前AI 評分29

Keeta 的區塊鏈結算層在 Spanner 上達到每秒 1,100 萬筆交易,揭示智能體金融基建需求

11 Million TPS on Spanner: What Keeta's Blockchain Settlement Layer Reveals About Agent-Driven Financial Infrastructure

AI 導讀

Keeta Network 在 Google Cloud Spanner 上進行公開壓力測試,展示每秒 1,100 萬筆交易的處理能力,並探討智能體交易對金融結算基建的要求。其架構由區塊鏈層負責驗證和排序,Spanner 負責一致、持久化儲存,並以 TrueTime 提供外部一致性時間戳。文章亦分析不同智能體所需的一致性保障,以及高交易量下的監測和故障復原設計。

正文

Keeta Network recently demonstrated 11 million transactions per second on Google Cloud Spanner during a public stress test. The number is striking, but the architecture underneath matters more: this is what settlement infrastructure looks like when autonomous trading agents replace human traders and sub-millisecond consistency becomes a hard requirement.

Keeta is a layer-1 blockchain designed to unify cross-chain transactions and payment systems. It runs on Spanner, Google's globally distributed database, and uses TrueTime to guarantee external consistency across geographically distributed writes. The stress test proves the stack can handle agent-driven financial workloads where settlement happens faster than humans can observe it.

Why Agent Settlement Needs Different Database Primitives

Traditional financial systems batch settlements overnight or hourly. Human traders tolerate latency measured in seconds. Autonomous agents operate differently:

  • State consistency windows shrink: An agent executing a multi-leg arbitrage across three exchanges needs to know the global state within microseconds, not seconds.
  • Transaction ordering becomes non-negotiable: When two agents compete for the same liquidity, the database must provide a single, globally consistent ordering without coordination overhead.
  • Rollback complexity explodes: At 11M TPS, a failed transaction cascade can propagate through millions of dependent operations before any monitoring system notices.

Spanner's TrueTime API solves the ordering problem by providing a global timestamp with bounded uncertainty (typically under 7ms). Every transaction gets a commit timestamp that reflects true causality. If transaction A finishes before transaction B starts anywhere in the world, Spanner guarantees A's timestamp is lower than B's.

This matters for agents because they can trust the transaction log as a source of truth without building their own coordination layer.

Architecture: How Keeta Maps Blockchain Semantics to Spanner

Keeta's architecture separates consensus from storage. The blockchain layer handles validation and ordering, while Spanner provides durable, consistent storage with horizontal scalability.

Key components:

  • Validator nodes: Run consensus protocol, validate transactions, produce ordered blocks
  • Spanner backend: Stores account balances, transaction history, smart contract state
  • TrueTime integration: Provides commit timestamps for external consistency
  • Read replicas: Serve historical queries without impacting write throughput

The validator nodes write to Spanner using strongly consistent transactions. Spanner replicates data across multiple regions with synchronous writes to a quorum. Read replicas serve agent queries for historical data, market snapshots, and audit trails.

Transaction flow:

  1. Agent submits transaction to validator node
  2. Validator runs consensus protocol with other nodes
  3. Consensus produces ordered block
  4. Block writes to Spanner with TrueTime timestamp
  5. Spanner replicates to quorum synchronously
  6. Transaction becomes visible to all agents globally

The separation means Keeta can swap consensus algorithms without touching the storage layer. It also means agents can query Spanner directly for state without waiting for blockchain finality.

State Consistency Guarantees for Autonomous Agents

Agents need different consistency guarantees depending on their execution model:

Agent Type Consistency Requirement Spanner Primitive Latency Impact
Market maker Linearizable reads for order book Strong reads 5-10ms cross-region
Arbitrage bot Snapshot isolation across exchanges Stale reads with timestamp bound <1ms local region
Settlement agent External consistency for multi-party txns TrueTime commit timestamps 7ms uncertainty window
Audit agent Historical consistency for compliance Read-only transactions No write path impact

Market makers need to see the current order book state before placing orders. They use strong reads, which query the most recent committed data. The cost is cross-region latency (5-10ms) because Spanner must confirm the read timestamp with the leader replica.

Arbitrage bots can tolerate slightly stale data if they know the staleness bound. Spanner's bounded-staleness reads let agents specify a maximum age (e.g., "give me data no older than 100ms"). This serves from local replicas without cross-region round trips.

Settlement agents coordinating multi-party transactions need external consistency: if agent A sees agent B's transaction committed, agent A's subsequent transaction must have a higher timestamp. TrueTime guarantees this globally without coordination messages between agents.

Observability at 11 Million Transactions Per Second

Traditional observability breaks at this scale. You cannot log every transaction. You cannot trace every agent decision. The telemetry volume would exceed the transaction volume.

What survives:

  • Sampled traces: Instrument 0.01% of transactions, use consistent hashing to capture full traces for selected transaction IDs
  • Aggregate metrics: Pre-aggregate counters and histograms at the validator node before shipping to monitoring systems
  • Anomaly detection: Run streaming anomaly detection on transaction patterns, only persist outliers
  • Audit checkpoints: Snapshot account balances and merkle roots every N blocks, discard intermediate states

What you sacrifice:

  • Full transaction history for debugging (keep only sampled traces)
  • Real-time dashboards showing per-agent metrics (aggregate to agent cohorts)
  • Detailed error logs for every failed transaction (log error types and counts, not individual failures)

Keeta uses Spanner's change streams to feed a separate analytics pipeline. The pipeline runs aggregations and anomaly detection, then writes summaries back to a different Spanner instance. This keeps observability traffic off the critical write path.

Failure Modes and Recovery Primitives

At 11M TPS, failure recovery cannot involve human operators. The system must detect and recover automatically within milliseconds.

Common failure modes:

  1. Validator node crash: Consensus protocol elects new leader, no transaction loss (Spanner retains committed state)
  2. Spanner region outage: Quorum writes continue in remaining regions, read replicas in failed region go stale
  3. Network partition: TrueTime uncertainty increases, commit latency rises but consistency guarantees hold
  4. Agent logic error: Bad transaction rejected at validation, no state corruption (blockchain validation prevents invalid writes)

The critical primitive is Spanner's atomic schema changes. Keeta can deploy new smart contract logic or fix bugs by updating the schema without downtime. The schema change propagates atomically across all regions.

For agent rollback, Keeta uses compensating transactions rather than database rollback. If an agent's multi-step operation fails partway through, the agent submits offsetting transactions to undo the partial state change. This keeps the transaction log append-only and preserves the audit trail.

Code: Querying Agent State with Bounded Staleness

Agents querying market state can trade consistency for latency using Spanner's bounded-staleness reads:

from google.cloud import spanner

client = spanner.Client()
instance = client.instance('keeta-production')
database = instance.database('settlement-ledger')

# Agent queries order book with 100ms staleness bound
with database.snapshot(exact_staleness=0.1) as snapshot:
    results = snapshot.execute_sql(
        """
        SELECT account_id, asset_type, balance, last_update_time
        FROM account_balances
        WHERE asset_type = 'USDC'
          AND balance > 1000000
        ORDER BY last_update_time DESC
        LIMIT 100
        """
    )

    for row in results:
        # Agent logic: evaluate arbitrage opportunity
        # Knows data is <100ms stale, can factor staleness into risk model
        if is_arbitrage_profitable(row, staleness_ms=100):
            submit_transaction(row['account_id'], row['asset_type'])

The exact_staleness parameter tells Spanner to serve from the nearest replica without checking the leader. The agent gets sub-millisecond query latency and can reason about the staleness bound in its decision logic.

For strongly consistent reads (market makers placing orders), replace snapshot(exact_staleness=0.1) with snapshot() (no arguments). Spanner will query the leader replica and return the most recent committed state.

Security Boundaries in Agent-Driven Settlement

When agents settle transactions autonomously, security boundaries shift from user authentication to agent authorization:

  • Agent identity: Each agent has a cryptographic identity (public/private key pair), transactions are signed
  • Capability tokens: Agents receive time-limited tokens scoping their permissions (e.g., "can trade USDC/ETH pair up to $1M notional")
  • Rate limiting: Per-agent transaction rate limits enforced at validator nodes before Spanner writes
  • Anomaly detection: Statistical models flag agents deviating from historical behavior patterns

Keeta implements KYC and AML at the agent registration layer. When an institution deploys a trading agent, the agent inherits the institution's compliance status. The blockchain validates compliance metadata on every transaction.

Spanner's row-level security policies enforce read isolation between agents. An agent can only query its own account balances and public market data. Cross-agent queries require explicit permission grants stored in Spanner's IAM tables.

Deployment Shape for Multi-Region Agent Networks

Keeta runs validator nodes in three regions (US, EU, Asia) with Spanner replicas in five regions. The deployment shape prioritizes write availability over read latency:

  • Validator nodes: Deployed in regions with low inter-region latency for consensus protocol
  • Spanner leader replicas: Co-located with validator nodes to minimize write latency
  • Spanner read replicas: Deployed in regions with high agent query volume
  • Agent execution nodes: Run in any region, query nearest read replica

This topology means an agent in Singapore queries a local Spanner replica (sub-millisecond latency) but writes go to the nearest validator node, which commits to Spanner's leader replica (10-20ms cross-region latency).

For latency-sensitive agents (market makers), Keeta offers co-location: deploy the agent in the same region as a validator node and Spanner leader replica. This reduces write latency to 5-7ms (dominated by TrueTime uncertainty, not network hops).

Technical Verdict

Use Spanner for agent settlement when:

  • You need external consistency across geographically distributed agents
  • Transaction throughput exceeds 100K TPS with strong consistency requirements
  • Agents require bounded-staleness reads for low-latency queries
  • You want to separate consensus logic from storage layer
  • Compliance and audit trails are non-negotiable

Avoid Spanner when:

  • Your agents tolerate eventual consistency (use Cassandra or DynamoDB)
  • Transaction volume is under 10K TPS (PostgreSQL with replication is simpler)
  • You need sub-millisecond write latency within a single datacenter (use in-memory databases)
  • Cost is the primary constraint (Spanner is expensive at scale)

The Keeta architecture demonstrates that agent-driven financial systems need different database primitives than human-driven systems. TrueTime's global ordering, bounded-staleness reads, and atomic schema changes are purpose-built for autonomous agents making microsecond decisions across continents. The 11M TPS number is impressive, but the consistency guarantees are what make agent settlement possible.

Source Links

來源:DEV Community · dev.to