Skip to content

Add native ETH JSON-RPC server (replaces meter-gear)#33

Open
simonzg wants to merge 3 commits into
mainnetfrom
merge-gear
Open

Add native ETH JSON-RPC server (replaces meter-gear)#33
simonzg wants to merge 3 commits into
mainnetfrom
merge-gear

Conversation

@simonzg

@simonzg simonzg commented Apr 28, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds a native Go ETH JSON-RPC server inside meter-pov, eliminating the need for the Python meter-gear proxy
  • Implements 33 RPC methods across eth, net, web3, rpc, and evm namespaces using geth's rpc package (already a dependency)
  • New package api/ethapi/ with server setup, method implementations, and Meter→Ethereum type conversion
  • New CLI flag --eth-rpc-addr (default localhost:8545) to configure the listen address

Methods implemented (Phase 1)

Trivial/Static: eth_chainId, eth_gasPrice, eth_maxPriorityFeePerGas, eth_syncing, net_version, net_listening, net_peerCount, web3_clientVersion, rpc_modules, evm_snapshot, evm_revert

Simple: eth_blockNumber, eth_getBalance, eth_getCode, eth_getStorageAt, eth_getTransactionCount, eth_newBlockFilter, eth_uninstallFilter, eth_getFilterChanges

Medium: eth_getBlockByNumber, eth_getBlockByHash, eth_getTransactionByHash, eth_getTransactionReceipt, eth_getTransactionByBlockNumberAndIndex, eth_getTransactionByBlockHashAndIndex, eth_getBlockTransactionCountByNumber, eth_call, eth_estimateGas, eth_sendRawTransaction, eth_getLogs

Complex: eth_getBlockReceipts, eth_feeHistory

Architecture

Ethereum Clients (Remix, Truffle, Web3.js, ethers.js)
         | (JSON-RPC 2.0, port 8545)
    meter-pov (Go, native ETH JSON-RPC)  ← NEW

Calls directly into existing chain, state, txpool, logdb packages — no new external dependencies.

Test plan

  • Send eth_getBlockByNumber("latest", true) and verify full block with expanded txs
  • Send eth_getTransactionReceipt(hash) and verify log indices, status, gas
  • Send eth_getLogs with multiple addresses and verify chunking produces correct results
  • Send eth_call with contract call and verify return data matches gear
  • Send eth_estimateGas and verify estimate is reasonable
  • Send eth_sendRawTransaction with a signed EIP-1559 tx
  • Verify WebSocket connection at /ws endpoint
  • Compare responses against meter-gear for key methods

🤖 Generated with Claude Code

simonzg and others added 3 commits July 10, 2025 09:54
Replaces the Python meter-gear proxy with a native Go implementation
of the Ethereum JSON-RPC API inside meter-pov. This eliminates the
extra process and HTTP hop between gear (port 8545) and meter-pov.

Phase 1 implements 33 RPC methods across eth, net, web3, rpc, and evm
namespaces including: block/tx/receipt queries, eth_call, estimateGas,
sendRawTransaction, getLogs, feeHistory, filters, and subscriptions
via WebSocket.

New package: api/ethapi/ with server.go, api.go, convert.go
New CLI flag: --eth-rpc-addr (default localhost:8545)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Tests cover:
- convert.go: block/tx/receipt/log conversion, hex helpers, constants,
  contract creation, multi-clause, empty blocks, multiple events
- api.go: CallArgs, LogFilterArgs, Net/Web3/RPC/EVM APIs, ChainId,
  filter lifecycle, applyTopics, JSON marshaling
- server.go: getChainID, CORS handler (headers, preflight, methods)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant