reth icon indicating copy to clipboard operation
reth copied to clipboard

Additional indexes for block explorers

Open paulmillr opened this issue 7 months ago • 3 comments
trafficstars

I've built esplr - private eth explorer. It's getting more popular, but still can't be ran on reth. The functionality of fetching account data from a node can be useful to wallets and other apps. Especially if we make it cross-chain.

What's needed

  • A way to get a full list of historical token transfers for an account.
  • A way to get current token balances for an account

How it currently works

While reth has ots_ namespace, and #14925 enabled proper trace_filter limits, apparently there are some indexes present in Erigon which Reth doesn't have. It makes Reth less useful for explorers which use trace_filter. Initial thoughts on how this can be solved:

a. Add additional indexes. Perhaps target next major version if that requires DB change / resync. b. Implement additional APIs to get list of token balances and token tx histories. c. Utilize existing ots_ namespace to replace trace_filter calls d. Something else? I don't know Reth architecture, the team prob knows better

Esplr uses logic from micro-eth-signer archive.ts to implement exploring:

const res = await this.call('trace_filter', {
fromBlock: undefined,
toBlock: undefined,
toAddress: [address],
fromAddress: [address],
});

// tokenTransfers
this.ethLogs(ERC_TRANSFER.topics({ from: address, to: null, value: null }), opts), // From
this.ethLogs(ERC_TRANSFER.topics({ from: null, to: address, value: null }), opts), // To

// erc1155Transfers
this.ethLogs(
  ERC1155_SINGLE.topics({ operator: null, from: address, to: null, id: null, value: null }),
  opts
),
this.ethLogs(
  ERC1155_SINGLE.topics({ operator: null, from: null, to: address, id: null, value: null }),
  opts
),
// Batch
this.ethLogs(
  ERC1155_BATCH.topics({ operator: null, from: address, to: null, ids: null, values: null }),
  opts
),
this.ethLogs(
  ERC1155_BATCH.topics({ operator: null, from: null, to: address, ids: null, values: null }),
  opts
),

Steps to reproduce

Try using esplr (purely client-side web app) with reth

https://paulmillr.com/apps/esplr/

Code of Conduct

  • [x] I agree to follow the Code of Conduct

paulmillr avatar Mar 30 '25 06:03 paulmillr