How are the Lamports related to compute units? For example, for one ED25529 signature verification, it costs 5000 lamports, so if we verify an ED25519 signature in a contract using: Program id: Ed25519SigVerify111111111111111111111111111 and Instructions: new_ed25519_instruction How many compute units will it take, and what will be the transaction fee?
1 Answer
In a program you can log the compute units and calculate so what costs how much compute.
sol_log_compute_units();
or you can use a macro like this:
/// Total extra compute units used per compute_fn! call 409 CU
#[macro_export]
macro_rules! compute_fn {
($msg:expr=> $($tt:tt)*) => {
::solana_program::msg!(concat!($msg, " {"));
::solana_program::log::sol_log_compute_units();
let res = { $($tt)* };
::solana_program::log::sol_log_compute_units();
::solana_program::msg!(concat!(" } // ", $msg));
res
};
}
The transaction cost does only change when you set priority fees like this:
const computePriceIx = ComputeBudgetProgram.setComputeUnitPrice({
microLamports: 1,
});
otherwise every transaction signature will just cost 5000 lamports.
here are more infos on compute budget: