Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ara/ludicrous-mode-backend #2

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

anthonyra
Copy link

@anthonyra anthonyra commented Nov 16, 2023

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' } on sendTransaction and we use a custom signatureConfirmation based on the same preflightCommitment. If this signatureConfirmation 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 the sendTransaction 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:

  • ensures we don't have our txn processed on a fork
  • 12 second (vs +1min) delay in knowing if txn was processed
  • allows us to attempt to send the txn to different endpoints
  • we can catch errors and gracefully handle the responses
  • profits

Cons:

  • more code
  • could cost user's if setting multiple fallback RPC's

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

@anthonyra anthonyra changed the title Ara/ludicrous mode backend ara/ludicrous mode backend Nov 17, 2023
@anthonyra anthonyra changed the title ara/ludicrous mode backend ara/ludicrous-mode-backend Nov 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant