Add sol_log_compute_units syscall
This commit is contained in:
@ -133,6 +133,12 @@ void sol_log_(const char *, uint64_t);
|
||||
void sol_log_64_(uint64_t, uint64_t, uint64_t, uint64_t, uint64_t);
|
||||
#define sol_log_64 sol_log_64_
|
||||
|
||||
/**
|
||||
* Prints the current compute unit consumption to stdout
|
||||
*/
|
||||
void sol_log_compute_units_();
|
||||
#define sol_log_compute_units() sol_log_compute_units_()
|
||||
|
||||
/**
|
||||
* Size of Public key in bytes
|
||||
*/
|
||||
|
@ -96,3 +96,19 @@ pub fn sol_log_params(accounts: &[AccountInfo], data: &[u8]) {
|
||||
info!("Instruction data");
|
||||
sol_log_slice(data);
|
||||
}
|
||||
|
||||
/// Logs the current compute unit consumption
|
||||
#[inline]
|
||||
pub fn sol_log_compute_units() {
|
||||
#[cfg(target_arch = "bpf")]
|
||||
unsafe {
|
||||
sol_log_compute_units_();
|
||||
}
|
||||
#[cfg(not(target_arch = "bpf"))]
|
||||
crate::program_stubs::sol_log_compute_units();
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "bpf")]
|
||||
extern "C" {
|
||||
fn sol_log_compute_units_();
|
||||
}
|
||||
|
@ -19,6 +19,9 @@ pub trait SyscallStubs: Sync + Send {
|
||||
fn sol_log(&self, message: &str) {
|
||||
println!("{}", message);
|
||||
}
|
||||
fn sol_log_compute_units(&self) {
|
||||
sol_log("SyscallStubs: sol_log_compute_units() not available");
|
||||
}
|
||||
fn sol_invoke_signed(
|
||||
&self,
|
||||
_instruction: &Instruction,
|
||||
@ -41,6 +44,10 @@ pub(crate) fn sol_log_64(arg1: u64, arg2: u64, arg3: u64, arg4: u64, arg5: u64)
|
||||
sol_log(&format!("{} {} {} {} {}", arg1, arg2, arg3, arg4, arg5));
|
||||
}
|
||||
|
||||
pub(crate) fn sol_log_compute_units() {
|
||||
SYSCALL_STUBS.read().unwrap().sol_log_compute_units();
|
||||
}
|
||||
|
||||
pub(crate) fn sol_invoke_signed(
|
||||
instruction: &Instruction,
|
||||
account_infos: &[AccountInfo],
|
||||
|
@ -66,6 +66,10 @@ pub mod cumulative_rent_related_fixes {
|
||||
solana_sdk::declare_id!("FtjnuAtJTWwX3Kx9m24LduNEhzaGuuPfDW6e14SX2Fy5");
|
||||
}
|
||||
|
||||
pub mod sol_log_compute_units_syscall {
|
||||
solana_sdk::declare_id!("BHuZqHAj7JdZc68wVgZZcy51jZykvgrx4zptR44RyChe");
|
||||
}
|
||||
|
||||
pub mod pubkey_log_syscall_enabled {
|
||||
solana_sdk::declare_id!("MoqiU1vryuCGQSxFKA1SZ316JdLEFFhoAu6cKUNk7dN");
|
||||
}
|
||||
@ -96,6 +100,7 @@ lazy_static! {
|
||||
(max_program_call_depth_64::id(), "max program call depth 64"),
|
||||
(timestamp_correction::id(), "correct bank timestamps"),
|
||||
(cumulative_rent_related_fixes::id(), "rent fixes (#10206, #10468, #11342)"),
|
||||
(sol_log_compute_units_syscall::id(), "sol_log_compute_units syscall (#13243)"),
|
||||
(pubkey_log_syscall_enabled::id(), "pubkey log syscall"),
|
||||
(pull_request_ping_pong_check::id(), "ping-pong packet check #12794"),
|
||||
(bpf_just_in_time_compilation::id(), "bpf just-in-time compilation #12951"),
|
||||
|
Reference in New Issue
Block a user