Understanding Firestore DB changes when Reorgs Happen

Hi,
I am using moralis streams integration with firebase. Want to understand when a reorg happens before the number of confirmations time, does that specific transaction which got replaced still exist in Firestore DB or moralis removes it automatically from my Firestore DB.
@cryptokid can you help me on this

Hello, I donโ€™t expect for a transaction to be removed from the database. A new one will be added. If you use confirmed true flag then the chances of a reorg should be close to 0.

Hey @cryptokid

Say, I write a trigger in Firestore DB which says if documents have the same block number but different block hash then delete the records which donโ€™t have confirmed: true among them.
Ideally, will this implementation get rid of any block data not in the blockchain, or are there any edge cases I might still need to cover

do you have access to the block hash value?

a reorg could also make that a transaction hash is in another block number after the reorg

@cryptokid

Basically, when I index the event data into Firestore db, it also gives me the block hash rt along with tx Hash. I am not worried about my tx appearing in another block. I just want to clear my db with irrelevant block hash data i.e clear blocks which are no longer part of the chain

ok, then your method should work if you only want to delete old irrelevant data, you could also delete all the data with confirmed false

1 Like

@cryptokid
One other query is, some time back polygon had a 157 block reorg, greater than moralis confirmed blocks count, so in cases of that extremes does the service still send confirmed : true after 100 blocks and once reorg happens switches back to false? How are these cases handled?

Iโ€™ll ask the team for more details on this one, when was that reorg with 157 blocks?

Hey @cryptokid

Here are the details of the forked blocks with confirmations greater than 100


at this moment you will not receive a new webhook request if more than 100 blocks have passed and a reorg happens after those 100 blocks