Skip to content

Commit

Permalink
Moves serialization from loader-v3 into the program runtime.
Browse files Browse the repository at this point in the history
  • Loading branch information
Lichtso committed Feb 26, 2025
1 parent 9d39a36 commit 4972a63
Show file tree
Hide file tree
Showing 13 changed files with 26 additions and 22 deletions.
4 changes: 3 additions & 1 deletion Cargo.lock

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

4 changes: 2 additions & 2 deletions ledger-tool/src/program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ use {
serde_derive::{Deserialize, Serialize},
serde_json::Result,
solana_bpf_loader_program::{
create_vm, load_program_from_bytes, serialization::serialize_parameters,
syscalls::create_program_runtime_environment_v1,
create_vm, load_program_from_bytes, syscalls::create_program_runtime_environment_v1,
},
solana_cli_output::{OutputFormat, QuietDisplay, VerboseDisplay},
solana_ledger::blockstore_options::AccessType,
Expand All @@ -15,6 +14,7 @@ use {
loaded_programs::{
LoadProgramMetrics, ProgramCacheEntryType, DELAY_VISIBILITY_SLOT_OFFSET,
},
serialization::serialize_parameters,
with_mock_invoke_context,
},
solana_runtime::bank::Bank,
Expand Down
3 changes: 3 additions & 0 deletions program-runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,14 @@ solana-log-collector = { workspace = true }
solana-measure = { workspace = true }
solana-metrics = { workspace = true, optional = true }
solana-precompiles = { workspace = true }
solana-program-entrypoint = { workspace = true }
solana-pubkey = { workspace = true }
solana-rent = { workspace = true }
solana-sbpf = { workspace = true }
solana-sdk-ids = { workspace = true }
solana-slot-hashes = { workspace = true }
solana-stable-layout = { workspace = true }
solana-system-interface = { workspace = true }
solana-sysvar = { workspace = true }
solana-sysvar-id = { workspace = true }
solana-timings = { workspace = true }
Expand All @@ -52,6 +54,7 @@ thiserror = { workspace = true }

[dev-dependencies]
assert_matches = { workspace = true }
solana-account-info = { workspace = true }
solana-compute-budget = { workspace = true, features = ["dev-context-only-utils"] }
solana-instruction = { workspace = true, features = ["bincode"] }
solana-pubkey = { workspace = true, features = ["rand"] }
Expand Down
1 change: 1 addition & 0 deletions program-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ pub use solana_sbpf;
pub mod invoke_context;
pub mod loaded_programs;
pub mod mem_pool;
pub mod serialization;
pub mod stable_log;
pub mod sysvar_cache;
// re-exports for macros
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#![allow(clippy::arithmetic_side_effects)]

use {
crate::invoke_context::SerializedAccountMetadata,
solana_instruction::error::InstructionError,
solana_program_entrypoint::{BPF_ALIGN_OF_U128, MAX_PERMITTED_DATA_INCREASE, NON_DUP_MARKER},
solana_program_runtime::invoke_context::SerializedAccountMetadata,
solana_pubkey::Pubkey,
solana_sbpf::{
aligned_memory::{AlignedMemory, Pod},
Expand Down Expand Up @@ -248,7 +248,7 @@ pub fn serialize_parameters(
}
}

pub(crate) fn deserialize_parameters(
pub fn deserialize_parameters(
transaction_context: &TransactionContext,
instruction_context: &InstructionContext,
copy_account_data: bool,
Expand Down Expand Up @@ -605,7 +605,7 @@ fn deserialize_parameters_aligned<I: IntoIterator<Item = usize>>(
Ok(())
}

pub(crate) fn account_data_region_memory_state(account: &BorrowedAccount<'_>) -> MemoryState {
pub fn account_data_region_memory_state(account: &BorrowedAccount<'_>) -> MemoryState {
if account.can_data_be_changed().is_ok() {
if account.is_shared() {
MemoryState::Cow(account.get_index_in_transaction() as u64)
Expand All @@ -622,10 +622,10 @@ pub(crate) fn account_data_region_memory_state(account: &BorrowedAccount<'_>) ->
mod tests {
use {
super::*,
crate::with_mock_invoke_context,
solana_account::{Account, AccountSharedData, WritableAccount},
solana_account_info::AccountInfo,
solana_program_entrypoint::deserialize,
solana_program_runtime::with_mock_invoke_context,
solana_sdk_ids::bpf_loader,
solana_transaction_context::InstructionAccount,
std::{
Expand Down
1 change: 0 additions & 1 deletion program-test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ solana-accounts-db = { workspace = true }
solana-banks-client = { workspace = true }
solana-banks-interface = { workspace = true }
solana-banks-server = { workspace = true }
solana-bpf-loader-program = { workspace = true }
solana-compute-budget = { workspace = true }
solana-feature-set = { workspace = true }
solana-inline-spl = { workspace = true }
Expand Down
4 changes: 2 additions & 2 deletions program-test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ use {
solana_accounts_db::epoch_accounts_hash::EpochAccountsHash,
solana_banks_client::start_client,
solana_banks_server::banks_server::start_local_server,
solana_bpf_loader_program::serialization::serialize_parameters,
solana_compute_budget::compute_budget::ComputeBudget,
solana_feature_set::FEATURE_NAMES,
solana_instruction::{error::InstructionError, Instruction},
solana_log_collector::ic_msg,
solana_program_runtime::{
invoke_context::BuiltinFunctionWithContext, loaded_programs::ProgramCacheEntry, stable_log,
invoke_context::BuiltinFunctionWithContext, loaded_programs::ProgramCacheEntry,
serialization::serialize_parameters, stable_log,
},
solana_runtime::{
accounts_background_service::{AbsRequestSender, SnapshotRequestKind},
Expand Down
2 changes: 1 addition & 1 deletion programs/bpf_loader/benches/serialization.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use {
criterion::{criterion_group, criterion_main, Criterion},
solana_account::{Account, AccountSharedData},
solana_bpf_loader_program::serialization::serialize_parameters,
solana_program_runtime::serialization::serialize_parameters,
solana_pubkey::Pubkey,
solana_rent::Rent,
solana_sdk_ids::{bpf_loader, bpf_loader_deprecated},
Expand Down
3 changes: 1 addition & 2 deletions programs/bpf_loader/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#![deny(clippy::arithmetic_side_effects)]
#![deny(clippy::indexing_slicing)]

pub mod serialization;
pub mod syscalls;

#[cfg(feature = "svm-internal")]
Expand Down Expand Up @@ -30,7 +29,7 @@ use {
ProgramCacheForTxBatch, ProgramRuntimeEnvironment, DELAY_VISIBILITY_SLOT_OFFSET,
},
mem_pool::VmMemoryPool,
stable_log,
serialization, stable_log,
sysvar_cache::get_sysvar_with_account_check,
},
solana_pubkey::Pubkey,
Expand Down
5 changes: 3 additions & 2 deletions programs/bpf_loader/src/syscalls/cpi.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
use {
super::*,
crate::serialization::account_data_region_memory_state,
scopeguard::defer,
solana_feature_set::{self as feature_set, enable_bpf_loader_set_authority_checked_ix},
solana_loader_v3_interface::instruction as bpf_loader_upgradeable,
solana_measure::measure::Measure,
solana_program_runtime::invoke_context::SerializedAccountMetadata,
solana_program_runtime::{
invoke_context::SerializedAccountMetadata, serialization::account_data_region_memory_state,
},
solana_sbpf::{
ebpf,
memory_region::{MemoryRegion, MemoryState},
Expand Down
3 changes: 2 additions & 1 deletion programs/sbf/Cargo.lock

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

7 changes: 2 additions & 5 deletions programs/sbf/benches/bpf_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,11 @@ extern crate test;

use {
byteorder::{ByteOrder, LittleEndian, WriteBytesExt},
solana_bpf_loader_program::{
create_vm, serialization::serialize_parameters,
syscalls::create_program_runtime_environment_v1,
},
solana_bpf_loader_program::{create_vm, syscalls::create_program_runtime_environment_v1},
solana_compute_budget::compute_budget::ComputeBudget,
solana_feature_set::FeatureSet,
solana_measure::measure::Measure,
solana_program_runtime::invoke_context::InvokeContext,
solana_program_runtime::{invoke_context::InvokeContext, serialization::serialize_parameters},
solana_runtime::{
bank::Bank,
bank_client::BankClient,
Expand Down
3 changes: 2 additions & 1 deletion svm/examples/Cargo.lock

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

0 comments on commit 4972a63

Please sign in to comment.