cli: show max vote credits in vote-account based on TVC activation epoch (#3776)
(cherry picked from commit b543f25b4df91f0622614fb369fb9f1ec088443a)
Co-authored-by: Ashwin Sekar <ashwin@anza.xyz>
#### Problem
Similar to the other PRs like #2710, we should simulate transactions to
find out the CUs consumed before sending them out.
#### Summary of changes
Similar to #2710, use `Simulated` compute units and perform the
simulation before sending out the transaction. Also, add a test.
* cli: Add simulated compute units to vote interactions
#### Problem
The CLI can simulate to get the compute budget used by a transaction,
but vote interactions are still using the default compute unit limit.
#### Summary of changes
Add tests for setting a compute unit price with `test_case`, and then
change the compute unit limit to `Simulated`.
* Use simulated compute units
* Fix rebase issues
* cli: Use simulated compute unit limit in stake interactions
#### Problem
The CLI has the ability to simulate transactions before sending to use
the correct number of compute units, but stake commands are still using
the default compute unit limit.
#### Summary of changes
Update tests to use a compute unit limit, and then update the stake
commands to use the simulated compute unit limit.
* Simulate for compute units in stake commands
* Pass compute unit limit enum to `simulate_and_update...`
* Splits transfer authority and finalize into two instructions.
* Adds next-version-forwarding to finalization.
* Makes loader-v4 a program runtime v1 loader.
* cli: Use simulated compute units in ping
#### Problem
The CLI has the ability to simulate transactions before sending to use
the correct number of compute units, but `solana ping` is still using
the default compute unit limit.
#### Summary of changes
Simulate once to get the compute unit limit and then re-use the
simulated number for every ping.
* Refactor per review
* Only get compute unit limit if simulation needed, add test
* cli: Use simulated compute unit limit for nonces
#### Problem
The CLI can simulate to get the compute budget used by a transaction,
but nonce interactions are still using the default compute unit limit.
#### Summary of changes
Refactor the tests into `test_case`s, add tests for setting a compute
unit price, and then change compute unit limit to `Simulated`.
* Add compute unit price test case
* Change to using simulated compute units everywhere
* Run simulations where it isn't done normally
* Fix clippy issues
* 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
* cli: Plumb down `ComputeUnitLimit` to resolve tx
* Use simulated compute units in transaction
* wallet: Use simulated compute units for non-nonce transactions
* Modify transfer test
refactor: move process_compute_budget_instructions from solana_compute_budget to solana_runtime_transaction, to break circular dependencies. Issue #2169
* stake: Remove redelegate code and tests
* Mark stake flags as deprecated
* Remove usage of feature gate
* Add a changelog entry for the removal
* Remove repeated #[allow(deprecated)]s
* Re-add "redelegate-stake" command
* Remove feature
* Make CI happy -> `hidden_unless_forced()`
* Move binaries from solana-net-utils to examples
* Put clap under feature (rpc-client-nonce-utils)
* Disable clap by default for `solana-rpc-client-nonce-utils`
* Apply suggestions
* Add separate features for each binary dependency for net-utils
* Put all dependencies for binaries under clap feature
* `./scripts/cargo-for-all-lock-files.sh tree`
* Sort rpc-client-nonce-utils dependencies
* Fix banking-bench
* move deps to dev-dependencies where possible
* remove unused deps
* put solana-program behind target.'cfg(target_os = "solana")' in curve25519
* update lock files
* cli: Add `ComputeUnitConfig` and use it, no functional changes
* Use Option<u64> directly instead of ref
* Correct default compute unit limit comment
* rpc-client: Print transaction logs in preflight error
* Address feedback
* Update expected error message in program deploy test
* Use a semicolon before the data
`do_process_program_upgrade()` is already huge. It is better to put
sufficiently self-contained chunks of logic into individual functions.
Also, restructured the "staircase" pattern using early exits. It seems
to be more readable this way.
`unwrap_err()` does not contain a descriptive message for the case when
it succeeds. It may help someone debugging the test, in particular they
will see a short explanation without looking at the failed test.
Also, in a number of cases, `unwrap_err()` result was not checked,
creating a possibility for false positives. As the generated error
might be different from the one expected by the test author.
```
error: assigning the result of `Clone::clone()` may be inefficient
--> bucket_map/src/bucket.rs:979:17
|
979 | hashed = hashed_raw.clone();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `clone_from()`: `hashed.clone_from(&hashed_raw)`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#assigning_clones
= note: `-D clippy::assigning-clones` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::assigning_clones)]`
```
* Flip no_extend to auto_extend
* Apply suggestions from code review
Co-authored-by: Joe C <joecaulfield29@yahoo.com>
---------
Co-authored-by: Joe C <joecaulfield29@yahoo.com>
* add checks for program data account overflow during upgrade and add --auto-extend-program flag to solana program deploy command
* remove logs
* cleanup tests
* automatically extend program data account and add a --no-auto-extend-program falg
* change comments in do_process_program_upgrade
* simplify comments in do_process_program_upgrade
* resolve comments
* cleanup
* change error messages
* resolve comments
* Fix after rebase
* Fix after rebase
* fix cargo clippy
* cli: add tests for auto-extend
---------
Co-authored-by: Joe Caulfield <joe.caulfield@anza.xyz>