evmRpcLatencyWatcher
Subscribe to RPC endpoints via WebSocket and measure when blocks arrive at the Portal versus when they appear at the RPC. Use this transformer to monitor relative latency.
import { evmPortalSource, evmRpcLatencyWatcher } from "@subsquid/pipes/evm";
const stream = evmPortalSource({
portal: "https://portal.sqd.dev/datasets/base-mainnet",
query: { from: "latest" },
}).pipe(
evmRpcLatencyWatcher({
rpcUrl: ["https://base.drpc.org", "https://base-rpc.publicnode.com"],
})
);
for await (const { data } of stream) {
if (!data) continue;
console.table(data.rpc); // url, receivedAt, portalDelayMs
}
Parameters:
rpcUrl: Array of RPC WebSocket or HTTP URLs to compare against Portal
Output: Each batch includes rpc array with url, receivedAt, and portalDelayMs per endpoint.
Measured values include client-side network latency. Results are end-to-end delays as seen by the client, not pure Portal or RPC processing performance.