Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pindexer: flesh out dex-explorer indexer #4917

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

cronokirby
Copy link
Contributor

Describe your changes

Closes #4914.

The internal architecture of the app view tries to make use of batch processing to the extent possible, which simplifies a lot of the logic.

The price charts remain unchanged, but I collapsed the two tables into one for performance and simplicity.

I also did not implement insertion of empty candles ; if there are gaps in the events, there will be gaps in the resulting database as well.

The main addition and where I spent most of my time on this is the addition of summaries of information over arbitrary windows. The idea behind the architecture here is that any time a change to liquidity, trade count, or a candle for a directed pair happens in a block, that block then gets a "snapshot" inserted, with the current price, liquidity, volume in that block, etc. At the end of this batch, the current summary is then updated, for each window, using those timed snapshots. And then an aggregate summary, across all pairs, is created from these summaries, for each window.

In order to price values under a common denom, assets are filtered based on having a current USDC price, backed by enough liquidity (the denom and liquidity amount are parameters to the component).

For testing, I'd recommend trying to run the app view against mainnet and testnet, and checking some sanity items like the price not seeming crazy, and matching in the summary across all windows, etc.

I think for testing we'll notice potential issues relatively quickly when dogfooding the explorer.

Checklist before requesting a review

  • I have added guiding text to explain how a reviewer should test these changes.

  • If this code contains consensus-breaking changes, I have added the "consensus-breaking" label. Otherwise, I declare my belief that there are not consensus-breaking changes, for the following reason:

    indexing only

The main addition are all the metrics needed for the summary page, and
the supporting infrastructure therein.

Arbitrary windows are now supported for summaries too.

Performance was also greatly improved by making use of batch processing,
making the supply app view the bottleneck now.
@cronokirby
Copy link
Contributor Author

cronokirby commented Nov 9, 2024

image
image

with these changes seems like it takes 24 minutes or so to sync to block 1.86 million, or about 1300 blocks a second or so.

The dex explorer app view is still a bottleneck for the process though, which we can see more easily now that the app views run in parallel.

@erwanor erwanor self-requested a review November 13, 2024 17:26
@conorsch conorsch self-requested a review November 13, 2024 18:37
Copy link
Contributor

@conorsch conorsch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good. The performance improvements are significant! I've got a small concern about chain-specific logic in the indexing code, in the form of hardcoded asset ids, but willing to follow up on that when we've updated the interfaces like dex-explorer to work with the new schema.

crates/bin/pindexer/src/indexer_ext.rs Show resolved Hide resolved
crates/bin/pindexer/src/dex_ex/schema.sql Show resolved Hide resolved
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.

Dex Public Trading Insights
2 participants