forked from solana-labs/solana
-
Notifications
You must be signed in to change notification settings - Fork 379
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cli: Use a better amount during transaction simulation (#2709)
* cli: Use a better amount during transaction simulation #### Problem There are issues with the current strategy of simulating a test transaction in the `resolve_spend_message`. If the transaction is creating an account, the test transaction will fail because not enough lamports are sent to the destination. #### Summary of changes It's a tricky situation in which we can't always be correct, since there's a chicken-and-egg situation with calculating the fee for spend variants of `All` and `RentExempt` if the sender and the fee payer are the same account. To get the simulation correct in almost all situations, we simulate with the real transfer amount. But if the fee payer is the sender, we simulate with `0`. But we also add a new variant on `SpendAmount` to cover some minimum amount required that must be transferred. Currently, the only situations in which we have an issue are: * creating a nonce account * creating a stake account * transferring SOL Those first two have a minimum requirement, so use that. The third works fine with a 0 amount, since it's just a SOL transfer. * Address feedback
- Loading branch information
Showing
3 changed files
with
48 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters