add cost to additional built-in programs (#29795)

* add cost to additional built-in programs
* update a test with compute-budget cost
This commit is contained in:
Tao Zhu 2023-01-27 13:47:41 -06:00 committed by GitHub
parent a9287ab4c6
commit 6f4fe37bd2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 3 deletions

View File

@ -3,8 +3,8 @@
use {
lazy_static::lazy_static,
solana_sdk::{
ed25519_program, feature, incinerator, native_loader, pubkey::Pubkey, secp256k1_program,
system_program,
bpf_loader, bpf_loader_deprecated, bpf_loader_upgradeable, compute_budget, ed25519_program,
feature, incinerator, native_loader, pubkey::Pubkey, secp256k1_program, system_program,
},
std::collections::HashMap,
};
@ -42,6 +42,11 @@ lazy_static! {
(secp256k1_program::id(), COMPUTE_UNIT_TO_US_RATIO * 24),
(ed25519_program::id(), COMPUTE_UNIT_TO_US_RATIO * 24),
(system_program::id(), COMPUTE_UNIT_TO_US_RATIO * 5),
(compute_budget::id(), COMPUTE_UNIT_TO_US_RATIO * 5),
(solana_address_lookup_table_program::id(), COMPUTE_UNIT_TO_US_RATIO * 25),
(bpf_loader_upgradeable::id(), COMPUTE_UNIT_TO_US_RATIO * 79),
(bpf_loader_deprecated::id(), COMPUTE_UNIT_TO_US_RATIO * 38),
(bpf_loader::id(), COMPUTE_UNIT_TO_US_RATIO * 19),
]
.iter()
.cloned()

View File

@ -388,7 +388,12 @@ mod tests {
&token_transaction,
&FeatureSet::all_enabled(),
);
assert_eq!(0, tx_cost.builtins_execution_cost);
assert_eq!(
*BUILT_IN_INSTRUCTION_COSTS
.get(&compute_budget::id())
.unwrap(),
tx_cost.builtins_execution_cost
);
assert_eq!(12_345, tx_cost.bpf_execution_cost);
assert_eq!(1, tx_cost.data_bytes_cost);
}