-
Notifications
You must be signed in to change notification settings - Fork 392
@subql/node-ethereum init fails on Polkadot Hub RPCs (earliest -> 0x0 -> null) #3012
Description
Summary
@subql/node-ethereum fails during init() on Polkadot Hub RPCs with:
Getting genesis block returned null from tag: earliest
This blocks indexer startup before indexing begins.
Why this happens
In subql-ethereum/packages/node/src/ethereum/api.ethereum.ts, init() calls getGenesisBlock(chainId).
For most chains, getGenesisBlock() uses this.client.getBlock('earliest').
With ethers v5, getBlock('earliest') is normalized to eth_getBlockByNumber('0x0', false).
On Polkadot Hub RPCs, 0x0 returns null, so SubQuery throws and exits.
Affected networks (verified)
- Polkadot Hub mainnet (
chainId: 420420419) — fails - Polkadot Hub testnet (
chainId: 420420417) — fails
Not affected (verified)
- Moonbeam (
1284) — passes - Moonriver (
1285) — passes - Moonbase Alpha (
1287) — passes
Additional observed behavior on Polkadot Hub RPCs
eth_getBlockByNumber('earliest', false)returns non-nulleth_getBlockByNumber('0x0', false)returns nullethers.getBlock('earliest')returns null (because it requests0x0)
First existing substrate heights that return EVM block number 0x0:
- Mainnet:
11405258 - Testnet:
4367913
Minimal repro
import { providers } from 'ethers';
const p = new providers.JsonRpcProvider('https://services.polkadothub-rpc.com/mainnet');
await p.getNetwork();
const block = await p.getBlock('earliest');
console.log(block); // nullEquivalent SubQuery init check behavior:
const b = await provider.getBlock('earliest');
if (b === null) throw new Error('Getting genesis block returned null from tag: earliest');Request
Could @subql/node-ethereum make genesis init robust for chains where 0x0 is not directly available via EVM RPC adapter (e.g. Polkadot Hub)?
Potential approaches:
- Avoid strict dependency on
getBlock('earliest' -> 0x0)for startup validation. - Add chain-specific non-zero genesis tag mapping (similar to existing BEVM Canary special-case).
- Fallback logic when
'earliest'resolves tonullbut the endpoint is otherwise healthy.
Thanks — happy to run additional tests if needed.