evm-gateway is a standalone Ethereum JSON-RPC server for Injective EVM. It runs either in normal online mode (live CometBFT + gRPC, cache-first RPC) or offline RPC-only mode (serve indexed KV data only). It exposes HTTP on :8545, WS on :8546, and a sync status endpoint on /status/sync.
cmd/evm-gateway:mow.clientrypoint. Default action isstart; also hasversionandresync.internal/config: Plain env-file loader withWEB3INJ_prefix.Configis passed through the app without Cosmosserver.Contextor viper.internal/app: Orchestrates lifecycle. Builds live clients unlessWEB3INJ_OFFLINE_RPC_ONLY=true, opens the indexer DB, runs sync/resync, starts JSON-RPC, and handles shutdown.internal/jsonrpc: HTTP + WS server wiring. Registers EVM namespaces, exposes/status/sync, and degrades to polling-only mode if Comet event streams are unavailable.internal/evm/rpc: Port of Injective’s RPC implementation. Cache-first block/tx/receipt/log paths,eth_getBlockReceipts, and trace fallback/caching live here.internal/indexer: KV indexer and syncer. Stores tx mappings, RPC tx payloads, receipts, block metadata, grouped block logs, and cached trace results;resyncrewrites selected heights.internal/blocksync: Parallel block fetcher (ported from coremon) plus pace logging; used by the indexer sync loop.internal/telemetry: OpenTelemetry wiring viagotracer.
- Load indexed ranges from the KV DB (
evmindexerinDATA_DIR/data). - Compute gaps between
EARLIEST_BLOCKand the current chain head. - Fill gaps in order, then switch to forward-only syncing from head+1.
resyncskips forward sync, rewrites only requested ranges, and exits.
All configuration is driven by env vars with the WEB3INJ_ prefix. Defaults are captured in .env.example. Critical inputs:
WEB3INJ_COMET_RPCandWEB3INJ_GRPC_ADDR(ABCI and gRPC endpoints)WEB3INJ_EARLIEST_BLOCK(minimum height to backfill)WEB3INJ_FETCH_JOBS(parallel block fetchers)WEB3INJ_CHAIN_ID(validated online; required for offline RPC-only mode)WEB3INJ_ENABLE_SYNCandWEB3INJ_OFFLINE_RPC_ONLYWEB3INJ_GOTRACER_*for OTEL export
Uses log/slog exclusively (JSON or text), configured via env/flags.