Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Nitro Integration

GasHammer interacts with Arbitrum Nitro exclusively through wire protocols. No Nitro source code is imported. This boundary is enforced at the dependency level — gashammer-nitro depends only on alloy, tokio-tungstenite, and reqwest, never on Nitro crates.

Ref: RFC-0001.

Integration Surface

┌──────────────────────────────────────────────────────┐
│                   GasHammer Edge                      │
│                                                       │
│  ┌─────────────┐  ┌───────────────┐  ┌─────────────┐ │
│  │ RPC Provider │  │ Feed Consumer │  │ L1 Monitor  │ │
│  └──────┬──────┘  └───────┬───────┘  └──────┬──────┘ │
│         │                 │                  │        │
└─────────┼─────────────────┼──────────────────┼────────┘
          │                 │                  │
    JSON-RPC/HTTP     WebSocket            JSON-RPC/HTTP
    (port 8547)       (port 9642)          (L1 RPC)
          │                 │                  │
    ┌─────┴──────┐   ┌─────┴──────┐    ┌──────┴───────┐
    │ Sequencer  │   │ Feed Relay │    │  L1 (Geth)   │
    │  / Gateway │   │            │    │ SequencerInbox│
    └────────────┘   └────────────┘    │ RollupCore   │
                                       └──────────────┘

JSON-RPC Provider

NitroRpcProvider wraps an alloy HTTP transport with retry logic and health checks.

Configuration (RpcConfig):

FieldDefaultDescription
urlrequiredSequencer or gateway endpoint
timeout_ms5000Per-request timeout
max_retries3Retry count on transient errors
retry_base_delay_ms500Base delay for exponential backoff

Key operations:

  • send_raw_transaction(raw_tx) — submit a signed transaction
  • get_transaction_receipt(hash) — poll for inclusion
  • get_block_number() — current L2 block height
  • health_check() — validates connectivity via eth_chainId

Every outbound HTTP request includes the User-Agent and X-Powered-By headers with GasHammer version metadata (see DNA Provenance).

Sequencer Feed Consumer

FeedConsumer connects to the Nitro feed relay over WebSocket (port 9642) and parses the BroadcastMessage envelope.

Wire format (JSON over WebSocket):

{
  "version": 1,
  "messages": [
    {
      "sequenceNumber": 12345,
      "message": { "header": {...}, "l2Msg": "0x..." },
      "signature": "0x..."
    }
  ],
  "confirmedSequenceNumberMessage": { "sequenceNumber": 12340 }
}

Behavior:

  • Monitors sequence number gaps and emits FeedGap telemetry events.
  • Detects stalls when no message arrives within stall_threshold_ms (default: 30,000).
  • On disconnect, reconnects with exponential backoff (base 1s, max 30s, jitter).
  • Tracks gashammer_feed_messages_total and gashammer_feed_reconnects_total counters.

Configuration (FeedConfig):

FieldDefaultDescription
urlrequiredFeed relay WebSocket URL
channel_buffer4096Internal channel capacity
ping_interval_ms30000WebSocket ping interval
pong_timeout_ms5000Pong deadline
stall_threshold_ms30000Silence before stall detection

L1 Contract Reader

L1ContractReader reads Nitro’s L1 contracts via an Ethereum JSON-RPC provider.

Contracts:

ContractKey Functions / Events
SequencerInboxbatchCount(), event SequencerBatchDelivered(...)
RollupCorelatestConfirmed(), event AssertionCreated(...), event AssertionConfirmed(...)

Decoded event types:

  • BatchDeliveredEvent — batch sequence number, accumulators, time bounds, data location, L1 block/tx
  • AssertionEvent — assertion hash, kind (Created/Confirmed), L1 block/tx

Configuration (L1Config):

FieldDefaultDescription
rpc_urlrequiredL1 Ethereum RPC endpoint
sequencer_inbox_addressrequiredHex address of SequencerInbox
rollup_core_addressrequiredHex address of RollupCore
poll_interval_ms15000Polling interval
lookback_blocks100Blocks to scan on first poll

L1 Monitor

L1Monitor spawns a background tokio task that polls the L1 contracts at the configured interval and emits events via an mpsc channel.

Event types:

VariantPayloadMeaning
BatchDeliveredVec<BatchDeliveredEvent>, blockNew batches posted to L1
AssertionUpdateVec<AssertionEvent>, blockAssertion created or confirmed
PollErrorerror messageNon-fatal poll failure (retries next tick)

Metrics (atomic counters):

CounterDescription
gashammer_l1_pollsTotal poll iterations
gashammer_l1_batches_seenBatch events observed
gashammer_l1_assertions_seenAssertion events observed
gashammer_l1_poll_errorsPoll errors encountered

The monitor exits when the event channel is closed, enabling clean shutdown via dropping the receiver.