pendulum-chain / spacewalk

Apache License 2.0
34 stars 7 forks source link

Make vault retry Stellar transaction submission for `tx_insufficient_fee` error #499

Closed ebma closed 5 months ago

ebma commented 5 months ago

When the vault client submits a Stellar payment transaction to fulfill a redeem request, it might encounter a tx_insufficient_fee error because the fee prices surged from one ledger to another. This means the transaction is rejected and the vault needs to create a new payment with a higher fee. This retry is currently not done and the submission is only retried when the vault performs its periodic restart ie. every 3 hours.

TODO

We need to change the logic so that the payment is retried with a new transaction and a higher fee when the tx_insufficient_fee response is returned by Stellar horizon.

vadaynujra commented 5 months ago

@ebma Not fully aware of the factor by which fees on Stellar could sometimes increase up to, but do we need to consider a max here such that if the transaction fee is higher than that, the transaction would still fail? Also, what would be the new expected time for a redemption request to be executed?

ebma commented 5 months ago

but do we need to consider a max here such that if the transaction fee is higher than that, the transaction would still fail?

Good question. I changed the implementation so that the vault will try to resubmit the same payment with a larger fee but never exceeding the maximum fee of 1 XLM ($0.11). Are you okay with this value? Generally, the fee charged should end up lower but we of course also want to be able to bridge during higher load on the Stellar network. If the payment still fails with 1 XLM, the vault will keep retrying with that value until the submission succeeds without further increasing this value.

Also, what would be the new expected time for a redemption request to be executed?

This change doesn't improve the execution time of redeem requests in the happy cases ie. with fast block times on Pendulum and low load on Stellar. However, this change should prevent users from waiting more than a couple of minutes.

vadaynujra commented 5 months ago

Sounds like a sensible approach @ebma with the 1 XLM max.

vadaynujra commented 5 months ago

So this change would make it highly probable for the redeem requests to be completed within a few minutes. @annatekl for Portal wording.

ebma commented 5 months ago

Yes 👍 there is one more problem that sometimes happens during very heavy loads on Stellar mainnet and we are still looking into this but this change should already improve the likelihood a lot.