add tx_priority_fee argument for program deploy subcommand#144
add tx_priority_fee argument for program deploy subcommand#144Nagaprasadvr wants to merge 11 commits intoanza-xyz:masterfrom Nagaprasadvr:feat-add-tx-priority-fee-and-max-retries-for-program-deploy
Conversation
|
Should we update program_v4 as well ? |
| ) | ||
| }; | ||
|
|
||
| initial_instructions.extend(ixs); |
There was a problem hiding this comment.
It could error out when making ixs above, so maybe more economic to extend ComputeBudgetInstruction::set_compute_unit_price(...) into ixs, instead of allocate set_compute_unit_price then fails on rpc call.
There was a problem hiding this comment.
After reading this https://www.helius.dev/blog/priority-fees-understanding-solanas-transaction-fee-mechanics Section:Best practices , it says set_compute_limit and set_compute_units should always be added to the start of ix Vec.
So a solution for this can be i create set_compute_units and set_compute_limit instructions after ixs is prepared ?
at line no 2318
| ) | ||
| .arg( | ||
| Arg::with_name("compute_unit_price") | ||
| .long("compute-unit-price") | ||
| .takes_value(true) | ||
| .help( | ||
| "Set computeUnitPrice (tx priotity fee) to boost transactions resulting in faster execution speed \ | ||
| [Note: priority fee is added in LAMPORTS, so enter priority fee in terms of LAMPORTS]", | ||
| ), | ||
| ). | ||
| arg( | ||
| Arg::with_name("max_retires") | ||
| .long("max-retries") | ||
| .takes_value(true) | ||
| .help( | ||
| "Specifies the max retry count for failed transactions", | ||
| ), |
There was a problem hiding this comment.
these should be added in separate PRs
There was a problem hiding this comment.
so compute_unit_price is one pr and max_retries is another pr ?
| .arg( | ||
| Arg::with_name("compute_unit_price") | ||
| .long("compute-unit-price") | ||
| .takes_value(true) | ||
| .help( | ||
| "Set computeUnitPrice (tx priotity fee) to boost transactions resulting in faster execution speed \ | ||
| [Note: priority fee is added in LAMPORTS, so enter priority fee in terms of LAMPORTS]", | ||
| ), | ||
| ). |
There was a problem hiding this comment.
we'll want to define this arg somewhere and such that it can be reused on all transaction-bearing subcommands, for consistencies sake. most likely that will be in the clap-utils dir, similarly to the offline_signing module
There was a problem hiding this comment.
can we do this in a diff pr ?
|
FYI this seems to only put priority fees on the initial buffer creation transaction and not on all the subsequent txns (the ones that take the lion's share of the time) |
I have added set compute limit and set compute price ixs to write messages and final messages as well |
| 3 as u32 * 200_000u32, | ||
| )); | ||
| ixs.push(ComputeBudgetInstruction::set_compute_unit_price( | ||
| 0u64.mul((10 as u64).pow(6)), |
There was a problem hiding this comment.
| 0u64.mul((10 as u64).pow(6)), | |
| compute_unit_price.mul((10 as u64).pow(6)), |
There was a problem hiding this comment.
Will always be 0?
Oh my bad , that is wrong it should be compute_unit_price
|
The arg should be in terms of microlamports, otherwise the min you can pay is 0.000605 SOL per write tx. Which gets pricy. |
Will change to micro lamports |
resolved |
| ), | ||
| ) | ||
| .arg( | ||
| Arg::with_name("compute_unit_price") |
There was a problem hiding this comment.
prefer the pre-defined Arg from clap-utils
agave/clap-utils/src/compute_unit_price.rs
Lines 9 to 15 in a2579d4
| ixs_len: usize, | ||
| ) { | ||
| if let Some(compute_unit_price) = compute_unit_price { | ||
| println!("ixs_len: {}", ixs_len); |
| if let Some(compute_unit_price) = compute_unit_price { | ||
| println!("ixs_len: {}", ixs_len); | ||
| ixs.push(ComputeBudgetInstruction::set_compute_unit_limit( | ||
| ((ixs_len + 2) as u32) * 200_000u32, |
There was a problem hiding this comment.
most likely this is a drastic over-reservation which may reduce the likelihood of the transaction being included toward the end of a block
There was a problem hiding this comment.
Can u elaborate what is wrong here exactly is it setting more cu than required?
i have also read that setting compute_unit_limit is optional when setting compute_unit_price wyt?
There was a problem hiding this comment.
It is optional, but it's recommended to set a limit because the default limit is 200k * the number of instructions in the transaction. The transaction priority fee is calculated by multiplying the micro-lamport fee (per compute unit) by the transaction's compute unit limit. So if you set the compute unit too high or if you don't specify one and use the default limit, you will end up overpaying priority fees.. in other words, wasting tokens.
This set_compute_budget_ixs_if_needed should probably accept compute_unit_limit argument explicitly and then each caller can calculate the exact compute unit limit needed for the passed ixs. Then this function can add 300 compute units to the limit for the two additional compute budget program instructions. The default compute units charged per core program instruction are as follows:
- System program: 150
- Compute budget program: 150
- Upgradeable BPF loader program: 2370
There was a problem hiding this comment.
so we need to check each ix in ix vec and calculate compute_units required in this case right?
There was a problem hiding this comment.
Yes each ix has to be counted. I already explained this above and gave my suggestion for how to implement the fix.
|
found a workaround for this i have added 2000 cu when program is neither system_program or bpf_upgradable_loader |
|
please look at #312 ! apologies for closing this pr , please add your comments there |

Issue - #21
Add Transaction priority fee argument in terms of LAMPORTS to solana program deploy subcommand
Problem
usage - solana program deploy --tx-priority-fee 1000000
Summary of Changes
solana/cli/program - added tx_priority_fee logic