Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

Refactor - Moves the system program into its own crate #31244

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
15 changes: 15 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ members = [
"programs/ed25519-tests",
"programs/loader-v3",
"programs/stake",
"programs/system",
"programs/vote",
"programs/zk-token-proof",
"programs/zk-token-proof-tests",
Expand Down Expand Up @@ -348,6 +349,7 @@ solana-storage-bigtable = { path = "storage-bigtable", version = "=1.16.0" }
solana-storage-proto = { path = "storage-proto", version = "=1.16.0" }
solana-streamer = { path = "streamer", version = "=1.16.0" }
solana-sys-tuner = { path = "sys-tuner", version = "=1.16.0" }
solana-system-program = { path = "programs/system", version = "=1.16.0" }
solana-test-validator = { path = "test-validator", version = "=1.16.0" }
solana-thin-client = { path = "thin-client", version = "=1.16.0" }
solana-tpu-client = { path = "tpu-client", version = "=1.16.0", default-features = false }
Expand Down
13 changes: 13 additions & 0 deletions programs/sbf/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions programs/system/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[package]
name = "solana-system-program"
description = "Solana System program"
documentation = "https://docs.rs/solana-system-program"
version = { workspace = true }
authors = { workspace = true }
repository = { workspace = true }
homepage = { workspace = true }
license = { workspace = true }
edition = { workspace = true }

[dependencies]
bincode = { workspace = true }
log = { workspace = true }
serde = { workspace = true }
serde_derive = { workspace = true }
solana-program-runtime = { workspace = true }
solana-sdk = { workspace = true }

[dev-dependencies]
assert_matches = { workspace = true }
solana-logger = { workspace = true }

[lib]
crate-type = ["lib"]
name = "solana_system_program"

[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
34 changes: 34 additions & 0 deletions programs/system/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#![allow(clippy::integer_arithmetic)]
pub mod system_instruction;
pub mod system_processor;

use solana_sdk::{
account::{AccountSharedData, ReadableAccount},
account_utils::StateMut,
nonce, system_program,
};
pub use system_program::id;

#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum SystemAccountKind {
System,
Nonce,
}

pub fn get_system_account_kind(account: &AccountSharedData) -> Option<SystemAccountKind> {
if system_program::check_id(account.owner()) {
if account.data().is_empty() {
Some(SystemAccountKind::System)
} else if account.data().len() == nonce::State::size() {
let nonce_versions: nonce::state::Versions = account.state().ok()?;
match nonce_versions.state() {
nonce::State::Uninitialized => None,
nonce::State::Initialized(_) => Some(SystemAccountKind::Nonce),
}
} else {
None
}
} else {
None
}
}
Loading