The correct way for exchange to handle withdrawal errors
Hi, according to Tutorial-Exchange-Deposit-Withdraw, quote:
Once the last irreversible block has moved past the expiration time,
you can safely mark your attempted withdrawal as failed and not
worry about it "floating around the ether" to be applied when you least expect.
I don't really understand the condition "once the last irreversible block has moved past the expiration time". Is exchange supposed to keep comparing the current last_irreversible_block's timestamp and the expiration time of the withdrawal? Why not the current timestamp? What if something wrong with the consensus among block producers and the last_irreversible_block stops to increate but the current timestamp is way ahead of the withdrawal's expiration time?
This is a conservative way of knowing a transaction will never be included in the blockchain.
You can use the current timestamp IF you have knowledge of all the producer's blocks even if they are on different temporary forks AND no producer can validly produce a block where the transaction can be included because their next available time slot is past the expiration.
Without those conditions all being met, it means there exists at least one fork that can potentially become the irreversible chain which
- includes the transaction -OR-
- is partitioned from you and may include that transaction
- in this case we cover a chain which is still under construction but delayed from your PoV
As that logic is significantly more complex and requires more knowledge, the recommendation is simply to wait for the irreversible block to grow passed the expiration date of a transaction that is not represented in the chain.
@wanderingbort Thanks for the explanation. The irreversible block is a block number and expiration date is a timestamp, how to compare the irreversible block and expiration date of the transaction? Should I keep fetching the current irreversible block and get the timestamp of it was produced and compare with the expiration of the transaction?