ord icon indicating copy to clipboard operation
ord copied to clipboard

Handle reorgs

Open casey opened this issue 4 years ago β€’ 30 comments

Currently we detect and error on reorgs, but we should actually handle them.

We should implement this by adding checkpoints and rollbacks to redb, which would make this trivial:

https://github.com/cberner/redb/issues/341

So this issue actually requires adding checkpoints and rollbacks to redb.

casey avatar Feb 20 '22 08:02 casey

Think will be fixed soon @casey ? It impacts ord-dogecoin more because dogecoin has shorter blocks. I could give this a shot if you haven't started and want to leave a few notes.

apezord avatar Mar 12 '23 17:03 apezord

ord-litecoin just got stuck on reorgs as well // error: reorg detected at or before 2438403

decentraliser avatar Mar 14 '23 06:03 decentraliser

Eventually it will affect BTC too, and the impact will be wider. Best to fix before that happens.

apezord avatar Mar 16 '23 05:03 apezord

I got the following error message (on BTC): ERROR ord::index::updater Values channel closed unexpectedly error: reorg detected at or before 78XXXX

Now ord no longer works. When I try to inscribe something, it says error: reorg detected at or before 78XXXX

What can I do?

DanielHook15 avatar Mar 18 '23 02:03 DanielHook15

Not sure of the exact configuration of your setup but could setting your bitcoin nodes confirmation block to a higher limit could prevent you to be too much affected by this issue @apezord @decentraliser ?

Magicking avatar Mar 18 '23 02:03 Magicking

I am just using Bitcoin Core in its standard form, no virtual machine or other fancy things. Thank you very much for the fast help, but what do you mean by "setting your bitcoin nodes confirmation block to a higher limit"?

DanielHook15 avatar Mar 18 '23 02:03 DanielHook15

Do I have to delete the index file and reconstruct it? If yes, can I somehow delete the information about the last few blocks from index.redb so that ord only reconstructs the last entries? I want to avoid that it has to restart from block 1, which would take several days.

DanielHook15 avatar Mar 18 '23 02:03 DanielHook15

So reorg just happened on BTC

https://twitter.com/CynicusUnum/status/1636913796714299392

and as expected everything breaks

https://twitter.com/ordswap/status/1636942287602081792

Guys, is this a serious project? You did know that reorgs were going to happen eventually right? And you said nothing in any documentation about making manual backups?

Not a good look.

apezord avatar Mar 18 '23 05:03 apezord

If yes, can I somehow delete the information about the last few blocks from index.redb so that ord only reconstructs the last entries?

It should be possible to write code to roll back the chain, which would be faster than a reindex, but someone needs to write that code.

apezord avatar Mar 18 '23 05:03 apezord

This might even lead to users losing artifacts depending on how wallets are implemented.

Raising priority on this PR https://github.com/casey/ord/pull/1938

apezord avatar Mar 18 '23 06:03 apezord

Can this loss also happen with the normal ord wallets that one has if following the ord handbook or only with other wallets like sparrow?

DanielHook15 avatar Mar 18 '23 13:03 DanielHook15

wow wow wow this is really bad. so everything is completely broken with no solution idea or even anyone saying work is being done. not to be rude at all but given how unresponsive the repo owner and collaborators are, can anyone quickly release a fork with a fix? otherwise who knows how long it will take. that could be the best way to resolve this mess...

0attack avatar Mar 18 '23 15:03 0attack

so the stated solution is for everyone to reindex from scratch and to expect to need to manually do that multiple times a year... https://github.com/casey/ord/issues/1945#issuecomment-1474887671

0attack avatar Mar 18 '23 16:03 0attack

Recreating the index would be a bit waste of time, but not a big issue. However, is this really the full solution? apezord mentioned further above that we might loose artifacts. Is it really safe to use ord further (with a new index.redb file) or should I wait for a new version of ord that is safe?

DanielHook15 avatar Mar 18 '23 17:03 DanielHook15

@apezord: Thank you for your warning! It would be great if you could explain in more detail how we could lose our nfts and what we can do to avoid that.

DanielHook15 avatar Mar 18 '23 17:03 DanielHook15

Recreating the index would be a bit waste of time, but not a big issue. However, is this really the full solution? apezord mentioned further above that we might loose artifacts. Is it really safe to use ord further (with a new index.redb file) or should I wait for a new version of ord that is safe?

yes, a waste of time but also huge waste of limited writes on a storage device since the software has an unaddressed bug causing extreme disk usage. being forced to accept needless reindexing multiple times a year will add up quickly. a noticeable and significant decrease in disk life expectancy will be the result.

@apezord: Thank you for your warning! It would be great if you could explain in more detail how we could lose our nfts and what we can do to avoid that.

iiuc, it would be a possible issue with third-party wallets but additional clarification would be nice to get.

0attack avatar Mar 18 '23 18:03 0attack

started a discussion on changes to make the indexer handle re-orgs: https://github.com/casey/ord/discussions/1951

rot13maxi avatar Mar 19 '23 12:03 rot13maxi

so the stated solution is for everyone to reindex from scratch and to expect to need to manually do that multiple times a year... #1945 (comment)

in our case 1 out of 2 VMs recovered by re-indexing but looks like even re-indexing is not a sure fix.

ordinalsbot avatar Mar 19 '23 15:03 ordinalsbot

how to reindex

lglove avatar Mar 20 '23 11:03 lglove

how to reindex

https://github.com/casey/ord/issues/1946#issuecomment-1480408163

nammaki avatar Mar 23 '23 17:03 nammaki

ord-litecoinδΉŸθ’«ε‘εœ¨ι‡η»„δΈ­ // ι”™θ――οΌšεœ¨2438403ζˆ–δΉ‹ε‰ζ£€ζ΅‹εˆ°ι‡η»„

Litecoin is not ok now

yangmingming avatar Mar 28 '23 23:03 yangmingming

Is there any update @casey?

https://github.com/hirosystems/gh-action-testing/blob/e06e254620d903a9709a1ccbdcd9ba141d73ff6f/src/burnchains/bitcoin/indexer.rs

They somehow handle reorg, can't you implement that also?

77656233 avatar Apr 04 '23 11:04 77656233

another un-handled reorg occurred at 783830... https://github.com/casey/ord/issues/1945#issuecomment-1495341510

0attack avatar Apr 04 '23 14:04 0attack

How's this issue going on? Still got an error today.

image

V01dZer0 avatar May 09 '23 17:05 V01dZer0

same here. any solutions?

onbermejo avatar May 11 '23 13:05 onbermejo

same

dylan1951 avatar May 17 '23 22:05 dylan1951

ord doesn't handle reorgs so it breaks if there's a reorg which there always are. you need to delete the index.redb file then run ord index again which will reindex from scratch.

0attack avatar May 25 '23 18:05 0attack

where tf is the index.redb file???

dylan1951 avatar May 26 '23 01:05 dylan1951

where tf is the index.redb file???

linux should be ~/.local/share/ord/index.redb, mac should be ~/Library/Application\ Support/ord/ and windows should be ~\AppData\Roaming\ord

https://github.com/casey/ord/issues/1623, https://github.com/casey/ord/discussions/1627 for more info

0attack avatar May 27 '23 21:05 0attack

well thank goodness i made a backup of index.redb after the database format change introduced by 0.5.0. I really did not want to go through that again. I hope i remember to make another backup after this new sync finishes.

donnlee avatar May 28 '23 06:05 donnlee