Skip to content

Commit 11d16f2

Browse files
authored
Move remaining syscall definitions out of solana-program (anza-xyz#3405)
* move remaining syscall definitions out of solana-program and into define-syscall * missing module declaration * move all dep-free syscall definitions to define-syscall * remove unused imoprt
1 parent bb2c926 commit 11d16f2

File tree

11 files changed

+72
-48
lines changed

11 files changed

+72
-48
lines changed

curves/secp256k1-recover/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ impl Secp256k1Pubkey {
8787
}
8888

8989
#[cfg(target_os = "solana")]
90-
solana_define_syscall::define_syscall!(fn sol_secp256k1_recover(hash: *const u8, recovery_id: u64, signature: *const u8, result: *mut u8) -> u64);
90+
pub use solana_define_syscall::definitions::sol_secp256k1_recover;
9191

9292
/// Recover the public key from a [secp256k1] ECDSA signature and
9393
/// cryptographically-hashed message.

poseidon/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ impl PoseidonHash {
170170
}
171171

172172
#[cfg(target_os = "solana")]
173-
solana_define_syscall::define_syscall!(fn sol_poseidon(parameters: u64, endianness: u64, vals: *const u8, val_len: u64, hash_result: *mut u8) -> u64);
173+
pub use solana_define_syscall::definitions::sol_poseidon;
174174

175175
/// Return a Poseidon hash for the given data with the given elliptic curve and
176176
/// endianness.

sdk/cpi/src/syscalls.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/// Syscall definitions used by `solana_cpi`.
2+
pub use solana_define_syscall::definitions::{
3+
sol_invoke_signed_c, sol_invoke_signed_rust, sol_set_return_data,
4+
};
25
use {solana_define_syscall::define_syscall, solana_pubkey::Pubkey};
36

4-
define_syscall!(fn sol_invoke_signed_c(instruction_addr: *const u8, account_infos_addr: *const u8, account_infos_len: u64, signers_seeds_addr: *const u8, signers_seeds_len: u64) -> u64);
5-
define_syscall!(fn sol_invoke_signed_rust(instruction_addr: *const u8, account_infos_addr: *const u8, account_infos_len: u64, signers_seeds_addr: *const u8, signers_seeds_len: u64) -> u64);
6-
define_syscall!(fn sol_set_return_data(data: *const u8, length: u64));
77
define_syscall!(fn sol_get_return_data(data: *mut u8, length: u64, program_id: *mut Pubkey) -> u64);

sdk/define-syscall/src/definitions.rs

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
//! This module is only for syscall definitions that bring in no extra dependencies.
2+
use crate::define_syscall;
3+
4+
define_syscall!(fn sol_secp256k1_recover(hash: *const u8, recovery_id: u64, signature: *const u8, result: *mut u8) -> u64);
5+
define_syscall!(fn sol_poseidon(parameters: u64, endianness: u64, vals: *const u8, val_len: u64, hash_result: *mut u8) -> u64);
6+
define_syscall!(fn sol_invoke_signed_c(instruction_addr: *const u8, account_infos_addr: *const u8, account_infos_len: u64, signers_seeds_addr: *const u8, signers_seeds_len: u64) -> u64);
7+
define_syscall!(fn sol_invoke_signed_rust(instruction_addr: *const u8, account_infos_addr: *const u8, account_infos_len: u64, signers_seeds_addr: *const u8, signers_seeds_len: u64) -> u64);
8+
define_syscall!(fn sol_set_return_data(data: *const u8, length: u64));
9+
define_syscall!(fn sol_get_stack_height() -> u64);
10+
define_syscall!(fn sol_log_(message: *const u8, len: u64));
11+
define_syscall!(fn sol_log_64_(arg1: u64, arg2: u64, arg3: u64, arg4: u64, arg5: u64));
12+
define_syscall!(fn sol_log_compute_units_());
13+
define_syscall!(fn sol_log_data(data: *const u8, data_len: u64));
14+
define_syscall!(fn sol_memcpy_(dst: *mut u8, src: *const u8, n: u64));
15+
define_syscall!(fn sol_memmove_(dst: *mut u8, src: *const u8, n: u64));
16+
define_syscall!(fn sol_memcmp_(s1: *const u8, s2: *const u8, n: u64, result: *mut i32));
17+
define_syscall!(fn sol_memset_(s: *mut u8, c: u8, n: u64));
18+
define_syscall!(fn sol_log_pubkey(pubkey_addr: *const u8));
19+
define_syscall!(fn sol_create_program_address(seeds_addr: *const u8, seeds_len: u64, program_id_addr: *const u8, address_bytes_addr: *const u8) -> u64);
20+
define_syscall!(fn sol_try_find_program_address(seeds_addr: *const u8, seeds_len: u64, program_id_addr: *const u8, address_bytes_addr: *const u8, bump_seed_addr: *const u8) -> u64);
21+
define_syscall!(fn sol_sha256(vals: *const u8, val_len: u64, hash_result: *mut u8) -> u64);
22+
define_syscall!(fn sol_keccak256(vals: *const u8, val_len: u64, hash_result: *mut u8) -> u64);
23+
define_syscall!(fn sol_blake3(vals: *const u8, val_len: u64, hash_result: *mut u8) -> u64);
24+
define_syscall!(fn sol_curve_validate_point(curve_id: u64, point_addr: *const u8, result: *mut u8) -> u64);
25+
define_syscall!(fn sol_curve_group_op(curve_id: u64, group_op: u64, left_input_addr: *const u8, right_input_addr: *const u8, result_point_addr: *mut u8) -> u64);
26+
define_syscall!(fn sol_curve_multiscalar_mul(curve_id: u64, scalars_addr: *const u8, points_addr: *const u8, points_len: u64, result_point_addr: *mut u8) -> u64);
27+
define_syscall!(fn sol_curve_pairing_map(curve_id: u64, point: *const u8, result: *mut u8) -> u64);
28+
define_syscall!(fn sol_alt_bn128_group_op(group_op: u64, input: *const u8, input_size: u64, result: *mut u8) -> u64);
29+
define_syscall!(fn sol_big_mod_exp(params: *const u8, result: *mut u8) -> u64);
30+
define_syscall!(fn sol_remaining_compute_units() -> u64);
31+
define_syscall!(fn sol_alt_bn128_compression(op: u64, input: *const u8, input_size: u64, result: *mut u8) -> u64);
32+
define_syscall!(fn sol_get_sysvar(sysvar_id_addr: *const u8, result: *mut u8, offset: u64, length: u64) -> u64);
33+
define_syscall!(fn sol_get_epoch_stake(vote_address: *const u8) -> u64);
34+
35+
// these are to be deprecated once they are superceded by sol_get_sysvar
36+
define_syscall!(fn sol_get_clock_sysvar(addr: *mut u8) -> u64);
37+
define_syscall!(fn sol_get_epoch_schedule_sysvar(addr: *mut u8) -> u64);
38+
define_syscall!(fn sol_get_rent_sysvar(addr: *mut u8) -> u64);
39+
define_syscall!(fn sol_get_last_restart_slot(addr: *mut u8) -> u64);
40+
define_syscall!(fn sol_get_epoch_rewards_sysvar(addr: *mut u8) -> u64);
41+
42+
// this cannot go through sol_get_sysvar but can be removed once no longer in use
43+
define_syscall!(fn sol_get_fees_sysvar(addr: *mut u8) -> u64);

sdk/define-syscall/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
pub mod definitions;
2+
13
#[cfg(target_feature = "static-syscalls")]
24
#[macro_export]
35
macro_rules! define_syscall {

sdk/instruction/src/syscalls.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
pub use solana_define_syscall::definitions::sol_get_stack_height;
12
use {
23
crate::{AccountMeta, ProcessedSiblingInstruction},
34
solana_define_syscall::define_syscall,
45
solana_pubkey::Pubkey,
56
};
67

78
define_syscall!(fn sol_get_processed_sibling_instruction(index: u64, meta: *mut ProcessedSiblingInstruction, program_id: *mut Pubkey, data: *mut u8, accounts: *mut AccountMeta) -> u64);
8-
define_syscall!(fn sol_get_stack_height() -> u64);

sdk/msg/src/syscalls.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
/// Syscall definitions used by `solana_msg`.
2-
use solana_define_syscall::define_syscall;
3-
4-
define_syscall!(fn sol_log_(message: *const u8, len: u64));
5-
define_syscall!(fn sol_log_64_(arg1: u64, arg2: u64, arg3: u64, arg4: u64, arg5: u64));
6-
define_syscall!(fn sol_log_compute_units_());
7-
define_syscall!(fn sol_log_data(data: *const u8, data_len: u64));
2+
pub use solana_define_syscall::definitions::{
3+
sol_log_, sol_log_64_, sol_log_compute_units_, sol_log_data,
4+
};

sdk/program-memory/src/lib.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@
55
66
#[cfg(target_os = "solana")]
77
pub mod syscalls {
8-
use solana_define_syscall::define_syscall;
9-
define_syscall!(fn sol_memcpy_(dst: *mut u8, src: *const u8, n: u64));
10-
define_syscall!(fn sol_memmove_(dst: *mut u8, src: *const u8, n: u64));
11-
define_syscall!(fn sol_memcmp_(s1: *const u8, s2: *const u8, n: u64, result: *mut i32));
12-
define_syscall!(fn sol_memset_(s: *mut u8, c: u8, n: u64));
8+
pub use solana_define_syscall::definitions::{
9+
sol_memcmp_, sol_memcpy_, sol_memmove_, sol_memset_,
10+
};
1311
}
1412

1513
/// Check that two regions do not overlap.

sdk/program/src/syscalls/definitions.rs

+11-23
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,17 @@
22
pub use solana_cpi::syscalls::{
33
sol_get_return_data, sol_invoke_signed_c, sol_invoke_signed_rust, sol_set_return_data,
44
};
5-
use solana_define_syscall::define_syscall;
5+
#[deprecated(
6+
since = "2.2.0",
7+
note = "Use `solana_define_syscall::definitions` instead"
8+
)]
9+
pub use solana_define_syscall::definitions::{
10+
sol_alt_bn128_compression, sol_alt_bn128_group_op, sol_big_mod_exp, sol_blake3,
11+
sol_curve_group_op, sol_curve_multiscalar_mul, sol_curve_pairing_map, sol_curve_validate_point,
12+
sol_get_clock_sysvar, sol_get_epoch_rewards_sysvar, sol_get_epoch_schedule_sysvar,
13+
sol_get_epoch_stake, sol_get_fees_sysvar, sol_get_last_restart_slot, sol_get_rent_sysvar,
14+
sol_get_sysvar, sol_keccak256, sol_remaining_compute_units,
15+
};
616
#[cfg(target_feature = "static-syscalls")]
717
pub use solana_define_syscall::sys_hash;
818
#[deprecated(since = "2.1.0", note = "Use `solana_instruction::syscalls` instead")]
@@ -27,25 +37,3 @@ pub use solana_pubkey::syscalls::{
2737
pub use solana_secp256k1_recover::sol_secp256k1_recover;
2838
#[deprecated(since = "2.1.0", note = "Use solana_sha256_hasher::sol_sha256 instead")]
2939
pub use solana_sha256_hasher::sol_sha256;
30-
define_syscall!(fn sol_keccak256(vals: *const u8, val_len: u64, hash_result: *mut u8) -> u64);
31-
define_syscall!(fn sol_blake3(vals: *const u8, val_len: u64, hash_result: *mut u8) -> u64);
32-
define_syscall!(fn sol_curve_validate_point(curve_id: u64, point_addr: *const u8, result: *mut u8) -> u64);
33-
define_syscall!(fn sol_curve_group_op(curve_id: u64, group_op: u64, left_input_addr: *const u8, right_input_addr: *const u8, result_point_addr: *mut u8) -> u64);
34-
define_syscall!(fn sol_curve_multiscalar_mul(curve_id: u64, scalars_addr: *const u8, points_addr: *const u8, points_len: u64, result_point_addr: *mut u8) -> u64);
35-
define_syscall!(fn sol_curve_pairing_map(curve_id: u64, point: *const u8, result: *mut u8) -> u64);
36-
define_syscall!(fn sol_alt_bn128_group_op(group_op: u64, input: *const u8, input_size: u64, result: *mut u8) -> u64);
37-
define_syscall!(fn sol_big_mod_exp(params: *const u8, result: *mut u8) -> u64);
38-
define_syscall!(fn sol_remaining_compute_units() -> u64);
39-
define_syscall!(fn sol_alt_bn128_compression(op: u64, input: *const u8, input_size: u64, result: *mut u8) -> u64);
40-
define_syscall!(fn sol_get_sysvar(sysvar_id_addr: *const u8, result: *mut u8, offset: u64, length: u64) -> u64);
41-
define_syscall!(fn sol_get_epoch_stake(vote_address: *const u8) -> u64);
42-
43-
// these are to be deprecated once they are superceded by sol_get_sysvar
44-
define_syscall!(fn sol_get_clock_sysvar(addr: *mut u8) -> u64);
45-
define_syscall!(fn sol_get_epoch_schedule_sysvar(addr: *mut u8) -> u64);
46-
define_syscall!(fn sol_get_rent_sysvar(addr: *mut u8) -> u64);
47-
define_syscall!(fn sol_get_last_restart_slot(addr: *mut u8) -> u64);
48-
define_syscall!(fn sol_get_epoch_rewards_sysvar(addr: *mut u8) -> u64);
49-
50-
// this cannot go through sol_get_sysvar but can be removed once no longer in use
51-
define_syscall!(fn sol_get_fees_sysvar(addr: *mut u8) -> u64);

sdk/pubkey/src/syscalls.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
/// Syscall definitions used by `solana_pubkey`.
2-
use solana_define_syscall::define_syscall;
3-
4-
define_syscall!(fn sol_log_pubkey(pubkey_addr: *const u8));
5-
define_syscall!(fn sol_create_program_address(seeds_addr: *const u8, seeds_len: u64, program_id_addr: *const u8, address_bytes_addr: *const u8) -> u64);
6-
define_syscall!(fn sol_try_find_program_address(seeds_addr: *const u8, seeds_len: u64, program_id_addr: *const u8, address_bytes_addr: *const u8, bump_seed_addr: *const u8) -> u64);
2+
pub use solana_define_syscall::definitions::{
3+
sol_create_program_address, sol_log_pubkey, sol_try_find_program_address,
4+
};

sdk/sha256-hasher/src/lib.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#![no_std]
22
#[cfg(any(feature = "sha2", not(target_os = "solana")))]
33
use sha2::{Digest, Sha256};
4-
#[cfg(target_os = "solana")]
5-
use solana_define_syscall::define_syscall;
64
use solana_hash::Hash;
75

86
#[cfg(any(feature = "sha2", not(target_os = "solana")))]
@@ -28,7 +26,7 @@ impl Hasher {
2826
}
2927

3028
#[cfg(target_os = "solana")]
31-
define_syscall!(fn sol_sha256(vals: *const u8, val_len: u64, hash_result: *mut u8) -> u64);
29+
pub use solana_define_syscall::definitions::sol_sha256;
3230

3331
/// Return a Sha256 hash for the given data.
3432
pub fn hashv(vals: &[&[u8]]) -> Hash {

0 commit comments

Comments
 (0)