Skip to content

Commit

Permalink
review: syscall naming conventions
Browse files Browse the repository at this point in the history
  • Loading branch information
buffalojoec committed May 16, 2024
1 parent c92350e commit fcf3908
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
16 changes: 8 additions & 8 deletions programs/bpf_loader/src/syscalls/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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()`.
Expand Down Expand Up @@ -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,
)?;

Expand Down
4 changes: 2 additions & 2 deletions sdk/program/src/epoch_stake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
6 changes: 3 additions & 3 deletions sdk/program/src/program_stubs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion sdk/program/src/syscalls/definitions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions sdk/src/feature_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}

Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit fcf3908

Please sign in to comment.