After studying about solidity events, my understanding is that receiving an event doesn’t guarantees that the transaction is final. Transaction may yet to be included into the block. And even if it gets included in the block, it can get removed later on because of an uncle block.
I also read that Exchanges usually use some N block confirmation or even more, to make sure transaction is irreversible.
My questions are :
How can I implement a N block confirmation in dapp design and make it foolproof.
Consider a case wherein we need to add/update data in an off-chain base based on events, then how and when should we decide that transaction has been written to the blockchain and we can commit data to the off-chain database ?
How to handle case if the block containing the transaction has become an Uncle Block? Again how and when to update the off chain data.
I am curios to know how production grade dapps which run on main net handle these scenarios and maintain data integrity in case they have any logic which depends on events.