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

Wire Protocols

GasHammer communicates with Nitro and between its own components through four wire protocols. This page documents each protocol’s usage, message format, and configuration.

JSON-RPC (Edge → Nitro)

Standard Ethereum JSON-RPC over HTTP. Used for transaction submission and state queries.

Endpoint: Sequencer (port 8547) or Gateway (port 8547).

Methods Used

MethodDirectionPurpose
eth_sendRawTransactionEdge → SequencerSubmit signed transactions
eth_getTransactionReceiptEdge → GatewayPoll for confirmation
eth_blockNumberEdge → GatewayCurrent L2 block height
eth_chainIdEdge → SequencerHealth check and chain validation
eth_gasPriceEdge → GatewayCurrent gas price
eth_getTransactionCountEdge → GatewayNonce recovery on failure
eth_callEdge → GatewayRead-only contract calls
eth_getLogsMonitor → L1L1 event queries

Request Format

{
  "jsonrpc": "2.0",
  "method": "eth_sendRawTransaction",
  "params": ["0x<signed_tx_rlp>"],
  "id": 1
}

Headers

Every request includes:

HeaderValue
User-AgentGasHammer/<version> (<build_sha>)
X-Powered-ByGasHammer/<version>
X-GasHammer-Version<version>
X-GasHammer-Build<build_sha>

WebSocket Feed (Edge → Feed Relay)

The sequencer feed is a one-way WebSocket stream from the feed relay (port 9642) to the edge. Messages are JSON-encoded BroadcastMessage envelopes.

Message Format

{
  "version": 1,
  "messages": [
    {
      "sequenceNumber": 12345,
      "message": {
        "header": {
          "kind": 3,
          "poster": "0x...",
          "blockNumber": 100,
          "timestamp": 1700000000,
          "requestId": "0x...",
          "l1BaseFeeEstimate": "0x..."
        },
        "l2Msg": "0x..."
      },
      "signature": "0x..."
    }
  ],
  "confirmedSequenceNumberMessage": {
    "sequenceNumber": 12340
  }
}

Reconnection

On disconnect, the feed consumer reconnects with exponential backoff:

AttemptDelay
11s + jitter
22s + jitter
34s + jitter
nmin(2^n, 30)s + jitter

gRPC (Edge ↔ Hive)

Internal communication between edges and the hive uses gRPC with Protocol Buffers. Definitions are in proto/gashammer/v1/.

Service: HiveEdge

RPCDirectionDescription
RegisterEdgeEdge → HiveRegister with capabilities
HeartbeatEdge → HivePeriodic health signal
StreamTelemetryEdge → HiveBidirectional event stream
ControlStreamHive → EdgeRun start/stop commands

Proto Files

FileContents
hive_edge.protoHiveEdge service, RegisterEdgeRequest/Response, ControlMessage
telemetry.protoTelemetryEvent, TelemetryBatch, event payload messages
types.protoShared types: RunId, EdgeId, PhaseConfig, EdgeStatus

Transport

  • Default port: 9090
  • TLS: mTLS recommended for production (configured via tls.cert_path, tls.key_path, tls.ca_path)
  • Keepalive: 30s interval

L1 JSON-RPC (Monitor → L1 Geth)

The L1 monitor polls an Ethereum L1 node for Nitro contract events.

Methods Used

MethodPurpose
eth_blockNumberCurrent L1 block for range queries
eth_getLogsFetch SequencerBatchDelivered and assertion events
eth_callRead batchCount() and latestConfirmed()

Event Signatures

EventSignature Hash
SequencerBatchDelivered(uint256,bytes32,bytes32,bytes32,uint256,(uint64,uint64),uint8)Computed via keccak256
AssertionCreated(bytes32,...)Computed via keccak256
AssertionConfirmed(bytes32,...)Computed via keccak256

All signature hashes are verified non-zero and mutually distinct in unit tests.