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

[torii] Indexing optimization #1583

Closed
notV4l opened this issue Feb 26, 2024 · 6 comments · Fixed by #1631
Closed

[torii] Indexing optimization #1583

notV4l opened this issue Feb 26, 2024 · 6 comments · Fixed by #1631
Labels
enhancement New feature or request help wanted Extra attention is needed torii

Comments

@notV4l
Copy link
Collaborator

notV4l commented Feb 26, 2024

Is your feature request related to a problem? Please describe.
I'm curious so i ran a torii on mainnet, indexing a block could take around 10s on laptop.

The current indexing process is :
torii calls starknet_getBlockWithTxs to retrieve alls tx hash of a block
torii calls starknet_getTransactionReceipt for EACH TX

Describe the solution you'd like
It should be possible to do it in 1 call using starknet_getEvents, filtering on world address

@notV4l notV4l added the torii label Feb 26, 2024
@notV4l notV4l added enhancement New feature or request help wanted Extra attention is needed labels Mar 1, 2024
Copy link
Collaborator

Larkooo commented Mar 6, 2024

I think it's because we need the block information on top of that (to process blocks). Which the events page doesn't contain. Should we care about blocks apart from their block number?

Copy link
Collaborator

Larkooo commented Mar 6, 2024

It also seems we need the txn information, we store each transaction and its receipt @Tarrence

torii/processors/store_transaction.rs

Copy link
Contributor

hmm yeah. perhaps we should parallelize things. we can do a map -> reduce, creating all the db queries in map then applying them sequentially in reduce

@notV4l
Copy link
Collaborator Author

notV4l commented Mar 6, 2024

then maybe use starknet_getEvents then query only txs we are interested in

@tarrencev
Copy link
Contributor

yeah that is a good optimization too. we will need to keep a registry of all world's contract address to filter txns by (i think we have this already in the db)

@Larkooo
Copy link
Collaborator

Larkooo commented Mar 6, 2024

then maybe use starknet_getEvents then query only txs we are interested in

Wouldn't it be basically the same thing? Because I think we'd sitll do the same thing for blocks. As we have a block processsor that takes in the block data

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed torii
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants