solana_cost_model/
block_cost_limits.rsuse {
lazy_static::lazy_static,
solana_sdk::{
address_lookup_table, bpf_loader, bpf_loader_deprecated, bpf_loader_upgradeable,
compute_budget, ed25519_program, loader_v4, pubkey::Pubkey, secp256k1_program,
},
std::collections::HashMap,
};
pub const MAX_BLOCK_REPLAY_TIME_US: u64 = 400_000;
pub const MAX_CONCURRENCY: u64 = 4;
pub const COMPUTE_UNIT_TO_US_RATIO: u64 = 30;
pub const SIGNATURE_COST: u64 = COMPUTE_UNIT_TO_US_RATIO * 24;
pub const SECP256K1_VERIFY_COST: u64 = COMPUTE_UNIT_TO_US_RATIO * 223;
pub const ED25519_VERIFY_COST: u64 = COMPUTE_UNIT_TO_US_RATIO * 76;
pub const WRITE_LOCK_UNITS: u64 = COMPUTE_UNIT_TO_US_RATIO * 10;
pub const INSTRUCTION_DATA_BYTES_COST: u64 = 140 / COMPUTE_UNIT_TO_US_RATIO;
lazy_static! {
pub static ref BUILT_IN_INSTRUCTION_COSTS: HashMap<Pubkey, u64> = [
(solana_stake_program::id(), solana_stake_program::stake_instruction::DEFAULT_COMPUTE_UNITS),
(solana_config_program::id(), solana_config_program::config_processor::DEFAULT_COMPUTE_UNITS),
(solana_vote_program::id(), solana_vote_program::vote_processor::DEFAULT_COMPUTE_UNITS),
(solana_system_program::id(), solana_system_program::system_processor::DEFAULT_COMPUTE_UNITS),
(compute_budget::id(), solana_compute_budget_program::DEFAULT_COMPUTE_UNITS),
(address_lookup_table::program::id(), solana_address_lookup_table_program::processor::DEFAULT_COMPUTE_UNITS),
(bpf_loader_upgradeable::id(), solana_bpf_loader_program::UPGRADEABLE_LOADER_COMPUTE_UNITS),
(bpf_loader_deprecated::id(), solana_bpf_loader_program::DEPRECATED_LOADER_COMPUTE_UNITS),
(bpf_loader::id(), solana_bpf_loader_program::DEFAULT_LOADER_COMPUTE_UNITS),
(loader_v4::id(), solana_loader_v4_program::DEFAULT_COMPUTE_UNITS),
(secp256k1_program::id(), 0),
(ed25519_program::id(), 0),
]
.iter()
.cloned()
.collect();
}
pub const MAX_BLOCK_UNITS: u64 =
MAX_BLOCK_REPLAY_TIME_US * COMPUTE_UNIT_TO_US_RATIO * MAX_CONCURRENCY;
#[cfg(test)]
static_assertions::const_assert_eq!(MAX_BLOCK_UNITS, 48_000_000);
pub const MAX_WRITABLE_ACCOUNT_UNITS: u64 = MAX_BLOCK_REPLAY_TIME_US * COMPUTE_UNIT_TO_US_RATIO;
#[cfg(test)]
static_assertions::const_assert_eq!(MAX_WRITABLE_ACCOUNT_UNITS, 12_000_000);
pub const MAX_VOTE_UNITS: u64 = (MAX_BLOCK_UNITS as f64 * 0.75_f64) as u64;
#[cfg(test)]
static_assertions::const_assert_eq!(MAX_VOTE_UNITS, 36_000_000);
pub const MAX_BLOCK_ACCOUNTS_DATA_SIZE_DELTA: u64 = 100_000_000;