From fcf39084f8fbe50ad6e4abcf39ab145239385124 Mon Sep 17 00:00:00 2001 From: Joe Caulfield Date: Thu, 16 May 2024 12:46:21 -0500 Subject: [PATCH] review: syscall naming conventions --- programs/bpf_loader/src/syscalls/mod.rs | 16 ++++++++-------- sdk/program/src/epoch_stake.rs | 4 ++-- sdk/program/src/program_stubs.rs | 6 +++--- sdk/program/src/syscalls/definitions.rs | 2 +- sdk/src/feature_set.rs | 4 ++-- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/programs/bpf_loader/src/syscalls/mod.rs b/programs/bpf_loader/src/syscalls/mod.rs index 93d729853a08fe..b9004b286ba7c7 100644 --- a/programs/bpf_loader/src/syscalls/mod.rs +++ b/programs/bpf_loader/src/syscalls/mod.rs @@ -37,10 +37,10 @@ use { self, abort_on_invalid_curve, blake3_syscall_enabled, curve25519_syscall_enabled, disable_deploy_of_alloc_free_syscall, disable_fees_sysvar, enable_alt_bn128_compression_syscall, enable_alt_bn128_syscall, - enable_big_mod_exp_syscall, enable_partitioned_epoch_reward, enable_poseidon_syscall, - enable_syscall_get_epoch_stake, error_on_syscall_bpf_function_hash_collisions, - last_restart_slot_sysvar, reject_callx_r10, remaining_compute_units_syscall_enabled, - switch_to_new_elf_parser, + enable_big_mod_exp_syscall, enable_get_epoch_stake_syscall, + enable_partitioned_epoch_reward, enable_poseidon_syscall, + error_on_syscall_bpf_function_hash_collisions, last_restart_slot_sysvar, + reject_callx_r10, remaining_compute_units_syscall_enabled, switch_to_new_elf_parser, }, hash::{Hash, Hasher}, instruction::{AccountMeta, InstructionError, ProcessedSiblingInstruction}, @@ -279,8 +279,8 @@ pub fn create_program_runtime_environment_v1<'a>( let enable_poseidon_syscall = feature_set.is_active(&enable_poseidon_syscall::id()); let remaining_compute_units_syscall_enabled = feature_set.is_active(&remaining_compute_units_syscall_enabled::id()); - let enable_syscall_get_epoch_stake = - feature_set.is_active(&enable_syscall_get_epoch_stake::id()); + let enable_get_epoch_stake_syscall = + feature_set.is_active(&enable_get_epoch_stake_syscall::id()); // !!! ATTENTION !!! // When adding new features for RBPF here, // also add them to `Bank::apply_builtin_program_feature_transitions()`. @@ -470,8 +470,8 @@ pub fn create_program_runtime_environment_v1<'a>( // Get Epoch Stake register_feature_gated_function!( result, - enable_syscall_get_epoch_stake, - *b"sol_syscall_get_epoch_stake", + enable_get_epoch_stake_syscall, + *b"sol_get_epoch_stake", SyscallGetEpochStake::vm, )?; diff --git a/sdk/program/src/epoch_stake.rs b/sdk/program/src/epoch_stake.rs index 868230821c6944..0c6ad3c658481b 100644 --- a/sdk/program/src/epoch_stake.rs +++ b/sdk/program/src/epoch_stake.rs @@ -8,10 +8,10 @@ pub fn get_epoch_stake(vote_address: &Pubkey) -> u64 { let vote_address = vote_address as *const _ as *const u8; #[cfg(target_os = "solana")] - let result = unsafe { crate::syscalls::sol_syscall_get_epoch_stake(vote_address) }; + let result = unsafe { crate::syscalls::sol_get_epoch_stake(vote_address) }; #[cfg(not(target_os = "solana"))] - let result = crate::program_stubs::sol_syscall_get_epoch_stake(vote_address); + let result = crate::program_stubs::sol_get_epoch_stake(vote_address); result } diff --git a/sdk/program/src/program_stubs.rs b/sdk/program/src/program_stubs.rs index e3cf3bf3daedc5..0cb7e0094d8ab9 100644 --- a/sdk/program/src/program_stubs.rs +++ b/sdk/program/src/program_stubs.rs @@ -61,7 +61,7 @@ pub trait SyscallStubs: Sync + Send { fn sol_get_last_restart_slot(&self, _var_addr: *mut u8) -> u64 { UNSUPPORTED_SYSVAR } - fn sol_syscall_get_epoch_stake(&self, _vote_address: *const u8) -> u64 { + fn sol_get_epoch_stake(&self, _vote_address: *const u8) -> u64 { 0 } /// # Safety @@ -174,11 +174,11 @@ pub(crate) fn sol_get_last_restart_slot(var_addr: *mut u8) -> u64 { .sol_get_last_restart_slot(var_addr) } -pub(crate) fn sol_syscall_get_epoch_stake(vote_address: *const u8) -> u64 { +pub(crate) fn sol_get_epoch_stake(vote_address: *const u8) -> u64 { SYSCALL_STUBS .read() .unwrap() - .sol_syscall_get_epoch_stake(vote_address) + .sol_get_epoch_stake(vote_address) } pub(crate) fn sol_memcpy(dst: *mut u8, src: *const u8, n: usize) { diff --git a/sdk/program/src/syscalls/definitions.rs b/sdk/program/src/syscalls/definitions.rs index b58887501e8fc2..263b6cf6d6910b 100644 --- a/sdk/program/src/syscalls/definitions.rs +++ b/sdk/program/src/syscalls/definitions.rs @@ -72,7 +72,7 @@ define_syscall!(fn sol_get_epoch_rewards_sysvar(addr: *mut u8) -> u64); define_syscall!(fn sol_poseidon(parameters: u64, endianness: u64, vals: *const u8, val_len: u64, hash_result: *mut u8) -> u64); define_syscall!(fn sol_remaining_compute_units() -> u64); define_syscall!(fn sol_alt_bn128_compression(op: u64, input: *const u8, input_size: u64, result: *mut u8) -> u64); -define_syscall!(fn sol_syscall_get_epoch_stake(vote_address: *const u8) -> u64); +define_syscall!(fn sol_get_epoch_stake(vote_address: *const u8) -> u64); #[cfg(target_feature = "static-syscalls")] pub const fn sys_hash(name: &str) -> usize { diff --git a/sdk/src/feature_set.rs b/sdk/src/feature_set.rs index 221bf3f2b34ccf..e8bc5de897f1a7 100644 --- a/sdk/src/feature_set.rs +++ b/sdk/src/feature_set.rs @@ -801,7 +801,7 @@ pub mod abort_on_invalid_curve { solana_sdk::declare_id!("FuS3FPfJDKSNot99ECLXtp3rueq36hMNStJkPJwWodLh"); } -pub mod enable_syscall_get_epoch_stake { +pub mod enable_get_epoch_stake_syscall { solana_sdk::declare_id!("7mScTYkJXsbdrcwTQRs7oeCSXoJm4WjzBsRyf8bCU3Np"); } @@ -1000,7 +1000,7 @@ lazy_static! { (chained_merkle_conflict_duplicate_proofs::id(), "generate duplicate proofs for chained merkle root conflicts"), (reward_full_priority_fee::id(), "Reward full priority fee to validators #34731"), (abort_on_invalid_curve::id(), "Abort when elliptic curve syscalls invoked on invalid curve id SIMD-0137"), - (enable_syscall_get_epoch_stake::id(), "Enable syscall: sol_get_epoch_stake #884") + (enable_get_epoch_stake_syscall::id(), "Enable syscall: sol_get_epoch_stake #884") /*************** ADD NEW FEATURES HERE ***************/ ] .iter()