add sha256 syscall (#12569)

This commit is contained in:
Jack May
2020-09-29 23:29:20 -07:00
committed by GitHub
parent 89424b29bf
commit 058bca6632
16 changed files with 321 additions and 6 deletions

View File

@ -33,6 +33,10 @@ pub mod compute_budget_config2 {
solana_sdk::declare_id!("HxvjqDSiF5sYdSYuCXsUnS8UeAoWsMT9iGoFP8pgV1mB");
}
pub mod sha256_syscall_enabled {
solana_sdk::declare_id!("D7KfP7bZxpkYtD4Pc38t9htgs1k5k47Yhxe4rp6WDVi8");
}
lazy_static! {
/// Map of feature identifiers to user-visible description
pub static ref FEATURE_NAMES: HashMap<Pubkey, &'static str> = [
@ -43,6 +47,7 @@ lazy_static! {
(spl_token_v2_multisig_fix::id(), "spl-token multisig fix"),
(bpf_loader2_program::id(), "bpf_loader2 program"),
(compute_budget_config2::id(), "1ms compute budget"),
(sha256_syscall_enabled::id(), "sha256 syscall")
/*************** ADD NEW FEATURES HERE ***************/
]
.iter()

View File

@ -427,6 +427,8 @@ impl MessageProcessor {
create_program_address_units: 0,
invoke_units: 0,
max_invoke_depth: 2,
sha256_base_cost: 0,
sha256_byte_cost: 0,
}
}
}

View File

@ -87,6 +87,10 @@ pub struct ComputeBudget {
pub invoke_units: u64,
/// Maximum cross-program invocation depth allowed including the orignal caller
pub max_invoke_depth: usize,
/// Base number of compute units consumed to call sha256
pub sha256_base_cost: u64,
/// Incremental number of units consumed by sha256 (based on bytes)
pub sha256_byte_cost: u64,
}
impl Default for ComputeBudget {
fn default() -> Self {
@ -98,6 +102,8 @@ impl Default for ComputeBudget {
create_program_address_units: 1500,
invoke_units: 1000,
max_invoke_depth: 2,
sha256_base_cost: 85,
sha256_byte_cost: 1,
}
}
}