Return sysvars via syscalls (#16422)
This commit is contained in:
@@ -2,7 +2,10 @@
|
||||
|
||||
#![cfg(not(target_arch = "bpf"))]
|
||||
|
||||
use crate::{account_info::AccountInfo, entrypoint::ProgramResult, instruction::Instruction};
|
||||
use crate::{
|
||||
account_info::AccountInfo, entrypoint::ProgramResult, instruction::Instruction,
|
||||
program_error::UNSUPPORTED_SYSVAR,
|
||||
};
|
||||
use std::sync::{Arc, RwLock};
|
||||
|
||||
lazy_static::lazy_static! {
|
||||
@@ -31,6 +34,19 @@ pub trait SyscallStubs: Sync + Send {
|
||||
sol_log("SyscallStubs: sol_invoke_signed() not available");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn sol_get_clock_sysvar(&self, _var_addr: *mut u8) -> u64 {
|
||||
UNSUPPORTED_SYSVAR
|
||||
}
|
||||
fn sol_get_epoch_schedule_sysvar(&self, _var_addr: *mut u8) -> u64 {
|
||||
UNSUPPORTED_SYSVAR
|
||||
}
|
||||
fn sol_get_fees_sysvar(&self, _var_addr: *mut u8) -> u64 {
|
||||
UNSUPPORTED_SYSVAR
|
||||
}
|
||||
fn sol_get_rent_sysvar(&self, _var_addr: *mut u8) -> u64 {
|
||||
UNSUPPORTED_SYSVAR
|
||||
}
|
||||
}
|
||||
|
||||
struct DefaultSyscallStubs {}
|
||||
@@ -61,3 +77,22 @@ pub(crate) fn sol_invoke_signed(
|
||||
.unwrap()
|
||||
.sol_invoke_signed(instruction, account_infos, signers_seeds)
|
||||
}
|
||||
|
||||
pub(crate) fn sol_get_clock_sysvar(var_addr: *mut u8) -> u64 {
|
||||
SYSCALL_STUBS.read().unwrap().sol_get_clock_sysvar(var_addr)
|
||||
}
|
||||
|
||||
pub(crate) fn sol_get_epoch_schedule_sysvar(var_addr: *mut u8) -> u64 {
|
||||
SYSCALL_STUBS
|
||||
.read()
|
||||
.unwrap()
|
||||
.sol_get_epoch_schedule_sysvar(var_addr)
|
||||
}
|
||||
|
||||
pub(crate) fn sol_get_fees_sysvar(var_addr: *mut u8) -> u64 {
|
||||
SYSCALL_STUBS.read().unwrap().sol_get_fees_sysvar(var_addr)
|
||||
}
|
||||
|
||||
pub(crate) fn sol_get_rent_sysvar(var_addr: *mut u8) -> u64 {
|
||||
SYSCALL_STUBS.read().unwrap().sol_get_rent_sysvar(var_addr)
|
||||
}
|
||||
|
Reference in New Issue
Block a user