Automatic retries of transfers
Overview
A transfer can be automatically retried in Treasury (as of 25.7.2
). If updating from a previous version, please update your default policy around the connector.
To understand what a retry really is, let's go over the possible states of a transfer or transaction:
preparing
The transaction is waiting for inputs from the chain (e.g. gas fees, account sequence).signing
The transaction is waiting to be signed.submitting
The transaction is waiting to be broadcasted.finalizing
The transaction is waiting for confirmations.succeeded
The transaction has received enough confirmations to be considered final.failed
The transaction has failed and is no longer being watched.
A transfer is always associated with a transaction. By retrying a transfer, we create an additional transaction in the preparing
state.
This new transaction will get new inputs and be signed & broadcasted.
We also support "rechecking" a transfer, which moves it from either the succeeded
or failed
state to the finalizing
state.
This will cause Treasury to "recheck" if a transaction is on-chain or not.
Double sending
A transfer should only move funds once, even if it can create multiple transactions. Treasury protects against double sending by checking that every transaction for a transfer spends the same resources. Perhaps they use the same nonce, or spend the same UTXO. Because of this native protection, users can take advantage of retrying transfers worry-free.
Creating an automatic retry policy
While you are welcome to retry transfers automatically based on your own conditions, Treasury can do it autonomously as well.
Retry every 20 minutes for a specific error
A retry policy is global for a specific chain. This will automatically retry SUI transfers once after 20m if the RPC error still contains "Transaction Expired".
- CSL
- CLI
update chain SUI { retry = { attempts = 2, after = "20m", message = "Transaction Expired" } }
treasury chains update SUI --retry-period 20m --retry-attempts 2 --retry-message "Transaction Expired"
Retry for multiple errors
Match on multiple errors for a chain.
update chain SOL { retry = { attempts = 3, after = "20m", message = ["Attempt to debit an account but found no record of a prior credit", "Blockhash not found"] } }
Retry if not succeeded
It's best to be specific about which RPC errors you want to retry on. Otherwise you can omit message
to match anything.
update chain SOL { retry = { attempts = 10, after = "20m" } }