Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Adds the backend magic for ludicrous signing mode.
For ludicrous mode (transport RPC) - it utilizes a custom rebroadcast logic for txns. Currently the normal method submits the txn and waits for the response from the
waitForTxConfirmation
which has been known to fail due to the blockhash expiring on block height. This happens after ~150 blocks (1min - 1min 21secs or even longer depending on congestion).. now for ludicrous mode we set{ skipPreflight: false, maxRetries: 0, preflightCommitment: 'confirmed' }
onsendTransaction
and we use a customsignatureConfirmation
based on the same preflightCommitment. If thissignatureConfirmation
fails we gracefully catch the ERROR and simply try and send the txn as long as the blockhash hasn't expired. We could incorporate the ability to set a list of RPC endpoints that it can round robin on each rebroadcast attempt as well. If we fail thesendTransaction
due to the preflight checks or blockhash expiration we simply rebuild then sign and repeat. This is the quickest while being the safest approach I've seen based on the Solana documents about how transactions are handled by the blockchain.Pros:
Cons:
References
https://docs.solana.com/integrations/retrying-transactions
https://solanacookbook.com/guides/retrying-transactions.html#customizing-rebroadcast-logic
Where the 150 blocks expiration comes from;
https://github.com/solana-labs/solana/blob/53c723ae3f6b3013b9bfe275ea683ef2088737b3/sdk/program/src/clock.rs#L129