bestinslot-xyz / OPI

Open Protocol Indexer, OPI, is the best-in-slot open-source indexing client for meta-protocols on Bitcoin.
Apache License 2.0
202 stars 110 forks source link

restore.py backups for Testnet? #54

Closed bombnp closed 3 weeks ago

bombnp commented 3 weeks ago

Hi @samedcildir , thank you for your work.

I see that there is a restore.py file for restoring backups (both redb and postgres), but it seems to only work with mainnet? Are there backups for testnet as well, or do I need to start from genesis?

samedcildir commented 3 weeks ago

Hello @bombnp, thank you

Unfortunately we do not support testnet3 since it has more than 10 blocks reorg constantly.

For testnet4, there is an experimental branch of OPI that you can use and since it only has around 50k blocks, it syncs very fast.

bombnp commented 3 weeks ago

Do you mean you do not provide backups for testnet3, or OPI does not support testnet3 at all? The code seems to allow setting network as testnet.

samedcildir commented 3 weeks ago

It did support testnet3 at first, before the difficulty bug is used widely. However currently it gets stuck a lot since the ord version that OPI relies on does not support more than 10 blocks reorgs.

bombnp commented 3 weeks ago

I see. If I decide to run OPI on testnet3 anyways, and problems occur, are those problems recoverable? Or will it be a pain to resolve (from your experience)? Asking for advice.

I'm testing out some brc20 apps and testnet3 is the only option for me right now.

samedcildir commented 3 weeks ago

If a reorg occurs, index.redb will not be able to rollback so you have to start syncing from the beginning. However you can change the rollback height limit parameter in ord and rebuild it

bombnp commented 3 weeks ago

You mean SAVEPOINT_INTERVAL and CHAIN_TIP_DISTANCE variable in this file? Do I need to change anything else? https://github.com/bestinslot-xyz/OPI/blob/main/ord/src/index/reorg.rs#L23

samedcildir commented 3 weeks ago

yes, you should also edit https://github.com/bestinslot-xyz/OPI/blob/5b96207e1e84cc23594c41a71d47c1d475288000/modules/brc20_index/brc20_index.py#L680 this line and increase the limit in the query, otherwise brc20_index will stop after a reorg.

bombnp commented 3 weeks ago

Awesome, thank you so much, @samedcildir !