Add zk_token_sdk_enabled feature to gate Zk Token proof program and sol_zk_token_elgamal_op syscalls

This commit is contained in:
Michael Vines
2022-01-04 22:55:26 -08:00
parent 98e7fada15
commit bb3a1b6b31
17 changed files with 482 additions and 15 deletions

View File

@ -2,7 +2,11 @@ use {
crate::{
hash::Hash,
instruction::{CompiledInstruction, Instruction},
message::{v0::{self, LoadedAddresses}, legacy::Message as LegacyMessage, MessageHeader},
message::{
legacy::Message as LegacyMessage,
v0::{self, LoadedAddresses},
MessageHeader,
},
pubkey::Pubkey,
sanitize::{Sanitize, SanitizeError},
serialize_utils::{append_slice, append_u16, append_u8},

View File

@ -304,9 +304,7 @@ mod tests {
num_readonly_unsigned_accounts: 0,
},
recent_blockhash: Hash::new_unique(),
account_keys: vec![
Pubkey::new_unique(),
],
account_keys: vec![Pubkey::new_unique()],
address_table_lookups: vec![
MessageAddressTableLookup {
account_key: Pubkey::new_unique(),

View File

@ -5,7 +5,7 @@ use {
pubkey::Pubkey,
sysvar,
},
std::{collections::HashSet, ops::Deref, convert::TryFrom},
std::{collections::HashSet, convert::TryFrom, ops::Deref},
};
/// Combination of a version #0 message and its loaded addresses

View File

@ -125,10 +125,7 @@ impl Message {
#[cfg(test)]
mod tests {
use {
super::*,
crate::message::VersionedMessage,
};
use {super::*, crate::message::VersionedMessage};
#[test]
fn test_sanitize() {
@ -251,7 +248,6 @@ mod tests {
.is_err());
}
#[test]
fn test_sanitize_with_max_account_keys() {
assert!(Message {

View File

@ -88,6 +88,8 @@ pub struct ComputeBudget {
pub secp256k1_recover_cost: u64,
/// Number of compute units consumed to do a syscall without any work
pub syscall_base_cost: u64,
/// Number of compute units consumed to call zktoken_crypto_op
pub zk_token_elgamal_op_cost: u64,
/// Optional program heap region size, if `None` then loader default
pub heap_size: Option<usize>,
/// Number of compute units per additional 32k heap above the default (~.5
@ -117,6 +119,7 @@ impl ComputeBudget {
sysvar_base_cost: 100,
secp256k1_recover_cost: 25_000,
syscall_base_cost: 100,
zk_token_elgamal_op_cost: 25_000,
heap_size: None,
heap_cost: 8,
}

View File

@ -161,6 +161,10 @@ pub mod gate_large_block {
solana_sdk::declare_id!("2ry7ygxiYURULZCrypHhveanvP5tzZ4toRwVp89oCNSj");
}
pub mod zk_token_sdk_enabled {
solana_sdk::declare_id!("zk1snxsc6Fh3wsGNbbHAJNHiJoYgF29mMnTSusGx5EJ");
}
pub mod versioned_tx_message_enabled {
solana_sdk::declare_id!("3KZZ6Ks1885aGBQ45fwRcPXVBCtzUvxhUTkwKMR41Tca");
}
@ -326,6 +330,7 @@ lazy_static! {
(disable_fees_sysvar::id(), "disable fees sysvar"),
(stake_merge_with_unmatched_credits_observed::id(), "allow merging active stakes with unmatched credits_observed #18985"),
(gate_large_block::id(), "validator checks block cost against max limit in realtime, reject if exceeds."),
(zk_token_sdk_enabled::id(), "enable Zk Token proof program and syscalls"),
(versioned_tx_message_enabled::id(), "enable versioned transaction message processing"),
(libsecp256k1_fail_on_bad_count::id(), "fail libsec256k1_verify if count appears wrong"),
(instructions_sysvar_owned_by_sysvar::id(), "fix owner for instructions sysvar"),