Use this file to discover all available pages before exploring further.
The evmRpcLatencyWatcher subscribes to RPC endpoints via WebSocket and measures when blocks arrive at the Portal versus when they appear at the RPC endpoints.
The measured values include client-side network data freshness. For RPC endpoints, only the arrival time of blocks is measured—this does not capture the node’s internal processing or response latency if queried directly. Results represent end-to-end delays as experienced by the client, not pure Portal or RPC processing performance.
import { formatBlock } from "@subsquid/pipes";import { evmPortalSource, evmRpcLatencyWatcher } from "@subsquid/pipes/evm";import { metricsServer } from "@subsquid/pipes/metrics/node";async function main() { const stream = evmPortalSource({ portal: "https://portal.sqd.dev/datasets/base-mainnet", outputs: evmDecoder({ range: { from: 'latest' }, events: {} }), metrics: metricsServer({ port: 9090 }), }).pipe( evmRpcLatencyWatcher({ rpcUrl: ["https://base.drpc.org", "https://base-rpc.publicnode.com"], }).pipe((data, { metrics }) => { if (!data) return; // Update Prometheus metrics for each RPC endpoint for (const rpc of data.rpc) { metrics .gauge({ name: "rpc_latency_ms", help: "RPC Latency in ms", labelNames: ["url"], }) .set({ url: rpc.url }, rpc.portalDelayMs); } return data; }) ); for await (const { data } of stream) { if (!data) continue; console.log(`Block: ${formatBlock(data.number)} / ${data.timestamp}`); console.table(data.rpc); }}void main()