3

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

1 Answer 1

1

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:

https://github.com/solana-labs/solana/blob/090e11210aa7222d8295610a6ccac4acda711bb9/program-runtime/src/compute_budget.rs#L26-L87

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.