Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ solana-instruction = "3.2.0"
solana-rent = "4.1.0"
solana-clock = "3.0.1"
solana-epoch-schedule = "3.0.0"
solana-last-restart-slot = "3.0.0"
sbpf-assembler = { path = "crates/assembler", version = "0.1.8" }
sbpf-disassembler = { path = "crates/disassembler", version = "0.1.8" }
sbpf-debugger = { path = "crates/debugger", version = "0.1.8" }
Expand Down
1 change: 1 addition & 0 deletions crates/common/src/syscalls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pub const REGISTERED_SYSCALLS: &[&str] = &[
"sol_get_epoch_schedule_sysvar",
"sol_get_fees_sysvar",
"sol_get_rent_sysvar",
"sol_get_last_restart_slot_sysvar",
"sol_memcpy_",
"sol_memmove_",
"sol_memcmp_",
Expand Down
1 change: 1 addition & 0 deletions crates/debugger/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ solana-account = { workspace = true }
solana-instruction = { workspace = true }
solana-rent = { workspace = true }
solana-clock = { workspace = true }
solana-last-restart-slot = { workspace = true }
solana-epoch-schedule = { workspace = true }
sbpf-assembler = { workspace = true }
sbpf-disassembler = { workspace = true }
Expand Down
22 changes: 22 additions & 0 deletions crates/debugger/src/syscalls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use {
solana_address::Address,
solana_clock::Clock,
solana_epoch_schedule::EpochSchedule,
solana_last_restart_slot::LastRestartSlot,
solana_rent::Rent,
std::mem::size_of,
};
Expand All @@ -27,6 +28,7 @@ pub struct DebuggerSyscallHandler {
pub clock: Clock,
pub rent: Rent,
pub epoch_schedule: EpochSchedule,
pub last_restart_slot: LastRestartSlot,
}

impl DebuggerSyscallHandler {
Expand All @@ -37,6 +39,7 @@ impl DebuggerSyscallHandler {
clock: Clock::default(),
rent: Rent::default(),
epoch_schedule: EpochSchedule::default(),
last_restart_slot: LastRestartSlot::default(),
}
}

Expand Down Expand Up @@ -445,6 +448,22 @@ impl DebuggerSyscallHandler {
self.write_sysvar_bytes(memory, registers[0], &epoch_schedule)?;
Ok(0)
}

fn sol_get_last_restart_slot_sysvar(
&mut self,
registers: [u64; 5],
memory: &mut Memory,
compute: &ComputeMeter,
) -> SbpfVmResult<u64> {
let cost = self
.costs
.sysvar_base_cost
.saturating_add(size_of::<LastRestartSlot>() as u64);
compute.consume(cost)?;
let last_restart_slot = self.last_restart_slot.clone();
self.write_sysvar_bytes(memory, registers[0], &last_restart_slot)?;
Ok(0)
}
}

impl SyscallHandler for DebuggerSyscallHandler {
Expand Down Expand Up @@ -492,6 +511,9 @@ impl SyscallHandler for DebuggerSyscallHandler {
"sol_get_epoch_schedule_sysvar" => {
self.sol_get_epoch_schedule_sysvar(registers, memory, &compute)
}
"sol_get_last_restart_slot_sysvar" => {
self.sol_get_last_restart_slot_sysvar(registers, memory, &compute)
}

// Unknown syscall
_ => {
Expand Down
Loading