daimo-eth / daimo

Dollars, anywhere in the world
https://daimo.com
GNU General Public License v3.0
368 stars 32 forks source link

Index Supply integration #93

Open dcposch opened 1 year ago

dcposch commented 1 year ago

Goal

Fast, scalable access to Daimo account history.

Stopgap

Currently, daimo-api implements an in-memory indexer. Every time the server starts, it loads history using getLogs() with retry and pagination. This should work fine while we have relatively few users and a short activity history.

Index Supply hosted E2PG (chain events to Postgres)

Ryan proposed following 3 options:

  1. Daimo provisions a database and gives Index Supply tightly scoped user access to the database so that we can insert into a predetermined set of tables.
  2. Daimo provisions a database and we configure logical replication so that Index Supply logically replicates data to Daimo’s database. Logical replication is really neat and would allow you to create your own pg indexes on the replicated tables and additionally you can also add columns to the replicated tables so that your app can do app specific things with the data.
  3. Index Supply provisions a (potentially shared) database in your app’s region and provides a read only connection URL. The indexed data will be available < 100ms after the block is added to the chain. I’ve also seen really great performance from our EL/CL stack such that it receives blocks quicker than most public websites on the web.

Option 2 seems clean, so we're trying that first.

For evaluation, we'll just index testUSDC transfers via the standard erc20 integration.

Next steps

dcposch commented 11 months ago

Project scope

From call on 2023-11-20:

--