rialo_risc_v_loader_interface/lib.rs
1// Copyright (c) Subzero Labs, Inc.
2// SPDX-License-Identifier: Apache-2.0
3// This file is either (a) original to Subzero Labs, Inc. or (b) derived from the Anza codebase and modified by Subzero Labs, Inc.
4
5use rialo_s_pubkey::Pubkey;
6
7pub mod instruction;
8pub mod loader_state_format;
9
10pub use loader_state_format::{LoaderStateError, RISC_V_LOADER_STATE_V1};
11
12rialo_s_pubkey::declare_id!("RiscVLoader11111111111111111111111111111111");
13
14#[repr(u64)]
15#[derive(Debug, PartialEq, Eq, Clone, Copy)]
16pub enum RiscVLoaderStatus {
17 /// Program is in maintenance
18 Retracted,
19 /// Program is ready to be executed
20 Deployed,
21 /// Same as `Deployed`, but can not be retracted anymore
22 Finalized,
23}
24
25/// The header of a RiscVLoader program account. Its bytes are the versioned record defined
26/// in [`loader_state_format`].
27#[derive(Debug, PartialEq, Eq, Clone, Copy)]
28pub struct RiscVLoaderState {
29 /// Slot in which the program was last deployed, retracted or initialized.
30 pub slot: u64,
31 /// Address of signer which can send program management instructions when the status is not finalized.
32 /// Otherwise a forwarding to the next version of the finalized program.
33 pub authority_address_or_next_version: Pubkey,
34 /// Deployment status.
35 pub status: RiscVLoaderStatus,
36 // The raw program data follows the record in the account's data.
37}
38
39impl RiscVLoaderState {
40 /// The length of the header record; the program data starts here.
41 pub const fn program_data_offset() -> usize {
42 loader_state_format::RECORD_LEN
43 }
44}