Skip to content

Commit

Permalink
Split runtime-transaction crate and reduce SVM dependency (#3983)
Browse files Browse the repository at this point in the history
  • Loading branch information
pgarg66 authored Dec 10, 2024
1 parent d7e8a87 commit 395db14
Show file tree
Hide file tree
Showing 29 changed files with 145 additions and 48 deletions.
5 changes: 2 additions & 3 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@
# repo and would like to avoid introducing dependencies in the meantime.
/builtins-default-costs/ @anza-xyz/svm
/compute-budget/ @anza-xyz/svm
/compute-budget-instruction/ @anza-xyz/svm
/fee/ @anza-xyz/svm
/log-collector/ @anza-xyz/svm
/program-runtime/ @anza-xyz/svm
/programs/bpf_loader/ @anza-xyz/svm
/programs/compute-budget/ @anza-xyz/svm
/programs/loader-v4/ @anza-xyz/svm
/programs/system/ @anza-xyz/svm
/runtime-transaction/ @anza-xyz/svm
/svm-conformance/ @anza-xyz/svm
/svm-rent-collector/ @anza-xyz/svm
/svm-transaction/ @anza-xyz/svm
/svm/ @anza-xyz/svm
/svm/examples/Cargo.lock
/transaction-view/ @anza-xyz/svm
/svm/examples/Cargo.lock
26 changes: 23 additions & 3 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 @@ -36,6 +36,7 @@ members = [
"client",
"client-test",
"compute-budget",
"compute-budget-instruction",
"connection-cache",
"core",
"cost-model",
Expand Down Expand Up @@ -457,6 +458,7 @@ solana-clock = { path = "sdk/clock", version = "=2.2.0" }
solana-cluster-type = { path = "sdk/cluster-type", version = "=2.2.0" }
solana-commitment-config = { path = "sdk/commitment-config", version = "=2.2.0" }
solana-compute-budget = { path = "compute-budget", version = "=2.2.0" }
solana-compute-budget-instruction = { path = "compute-budget-instruction", version = "=2.2.0" }
solana-compute-budget-interface = { path = "sdk/compute-budget-interface", version = "=2.2.0" }
solana-compute-budget-program = { path = "programs/compute-budget", version = "=2.2.0" }
solana-config-program = { path = "programs/config", version = "=2.2.0" }
Expand Down
42 changes: 42 additions & 0 deletions compute-budget-instruction/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
[package]
name = "solana-compute-budget-instruction"
description = "Solana Compute Budget Instruction"
documentation = "https://docs.rs/solana-compute-budget-instruction"
version = { workspace = true }
authors = { workspace = true }
repository = { workspace = true }
homepage = { workspace = true }
license = { workspace = true }
edition = { workspace = true }

[dependencies]
log = { workspace = true }
solana-builtins-default-costs = { workspace = true }
solana-compute-budget = { workspace = true }
solana-pubkey = { workspace = true }
solana-sdk = { workspace = true }
solana-svm-transaction = { workspace = true }
thiserror = { workspace = true }

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

[dev-dependencies]
bincode = { workspace = true }
criterion = { workspace = true }
rand = { workspace = true }
solana-program = { workspace = true }

[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]

[features]
dev-context-only-utils = []

[[bench]]
name = "process_compute_budget_instructions"
harness = false

[lints]
workspace = true
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use {
criterion::{black_box, criterion_group, criterion_main, Criterion, Throughput},
solana_runtime_transaction::instructions_processor::process_compute_budget_instructions,
solana_compute_budget_instruction::instructions_processor::process_compute_budget_instructions,
solana_sdk::{
compute_budget::ComputeBudgetInstruction,
feature_set::FeatureSet,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
use {
agave_transaction_view::static_account_keys_frame::MAX_STATIC_ACCOUNTS_PER_PACKET as FILTER_SIZE,
solana_builtins_default_costs::{is_builtin_program, MAYBE_BUILTIN_KEY},
solana_sdk::pubkey::Pubkey,
solana_sdk::{packet::PACKET_DATA_SIZE, pubkey::Pubkey},
};

// The maximum number of pubkeys that a packet can contain.
pub const FILTER_SIZE: u8 = (PACKET_DATA_SIZE / core::mem::size_of::<Pubkey>()) as u8;

#[derive(Clone, Copy, Debug, PartialEq)]
pub(crate) enum ProgramKind {
NotBuiltin,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// static account keys has max
use {
agave_transaction_view::static_account_keys_frame::MAX_STATIC_ACCOUNTS_PER_PACKET as FILTER_SIZE,
solana_builtins_default_costs::MAYBE_BUILTIN_KEY, solana_sdk::pubkey::Pubkey,
crate::builtin_programs_filter::FILTER_SIZE, solana_builtins_default_costs::MAYBE_BUILTIN_KEY,
solana_sdk::pubkey::Pubkey,
};

pub(crate) struct ComputeBudgetProgramIdFilter {
Expand Down
6 changes: 6 additions & 0 deletions compute-budget-instruction/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#![allow(clippy::arithmetic_side_effects)]

mod builtin_programs_filter;
pub mod compute_budget_instruction_details;
mod compute_budget_program_id_filter;
pub mod instructions_processor;
1 change: 1 addition & 0 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ solana-bloom = { workspace = true }
solana-builtins-default-costs = { workspace = true }
solana-client = { workspace = true }
solana-compute-budget = { workspace = true }
solana-compute-budget-instruction = { workspace = true }
solana-connection-cache = { workspace = true }
solana-cost-model = { workspace = true }
solana-entry = { workspace = true }
Expand Down
6 changes: 2 additions & 4 deletions core/src/banking_stage/consumer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use {
BankingStageStats,
},
itertools::Itertools,
solana_compute_budget_instruction::instructions_processor::process_compute_budget_instructions,
solana_feature_set as feature_set,
solana_ledger::token_balances::collect_token_balances,
solana_measure::{measure::Measure, measure_us},
Expand All @@ -24,10 +25,7 @@ use {
transaction_batch::TransactionBatch,
verify_precompiles::verify_precompiles,
},
solana_runtime_transaction::{
instructions_processor::process_compute_budget_instructions,
transaction_with_meta::TransactionWithMeta,
},
solana_runtime_transaction::transaction_with_meta::TransactionWithMeta,
solana_sdk::{
clock::{FORWARD_TRANSACTIONS_TO_LEADER_AT_SLOT_OFFSET, MAX_PROCESSING_AGE},
fee::FeeBudgetLimits,
Expand Down
6 changes: 2 additions & 4 deletions core/src/banking_stage/immutable_deserialized_packet.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
use {
super::packet_filter::PacketFilterFailure,
solana_compute_budget::compute_budget_limits::ComputeBudgetLimits,
solana_compute_budget_instruction::instructions_processor::process_compute_budget_instructions,
solana_perf::packet::Packet,
solana_runtime::bank::Bank,
solana_runtime_transaction::{
instructions_processor::process_compute_budget_instructions,
runtime_transaction::RuntimeTransaction,
},
solana_runtime_transaction::runtime_transaction::RuntimeTransaction,
solana_sanitize::SanitizeError,
solana_sdk::{
clock::Slot,
Expand Down
2 changes: 2 additions & 0 deletions cost-model/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ lazy_static = { workspace = true }
log = { workspace = true }
solana-builtins-default-costs = { workspace = true }
solana-compute-budget = { workspace = true }
solana-compute-budget-instruction = { workspace = true }
solana-feature-set = { workspace = true }
solana-frozen-abi = { workspace = true, optional = true, features = [
"frozen-abi",
Expand All @@ -36,6 +37,7 @@ name = "solana_cost_model"
itertools = { workspace = true }
rand = "0.8.5"
# See order-crates-for-publishing.py for using this unusual `path = "."`
solana-compute-budget-instruction = { workspace = true, features = ["dev-context-only-utils"] }
solana-compute-budget-program = { workspace = true }
solana-cost-model = { path = ".", features = ["dev-context-only-utils"] }
solana-logger = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion cost-model/src/transaction_cost.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#[cfg(feature = "dev-context-only-utils")]
use solana_runtime_transaction::compute_budget_instruction_details::ComputeBudgetInstructionDetails;
use solana_compute_budget_instruction::compute_budget_instruction_details::ComputeBudgetInstructionDetails;
use {
crate::block_cost_limits,
solana_runtime_transaction::transaction_with_meta::TransactionWithMeta,
Expand Down
2 changes: 1 addition & 1 deletion programs/compute-budget-bench/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ edition = { workspace = true }
[dependencies]
criterion = { workspace = true }
solana-compute-budget = { workspace = true }
solana-compute-budget-instruction = { workspace = true }
solana-compute-budget-program = { workspace = true }
solana-runtime-transaction = { workspace = true }
solana-sdk = { workspace = true }
solana-svm-transaction = { workspace = true }

Expand Down
2 changes: 1 addition & 1 deletion programs/compute-budget-bench/benches/compute_budget.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use {
criterion::{black_box, criterion_group, criterion_main, Criterion},
solana_compute_budget::compute_budget_limits::ComputeBudgetLimits,
solana_runtime_transaction::instructions_processor::process_compute_budget_instructions,
solana_compute_budget_instruction::instructions_processor::process_compute_budget_instructions,
solana_sdk::{
compute_budget::ComputeBudgetInstruction, feature_set::FeatureSet,
instruction::CompiledInstruction,
Expand Down
21 changes: 19 additions & 2 deletions programs/sbf/Cargo.lock

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

4 changes: 4 additions & 0 deletions programs/sbf/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ solana-bn254 = { path = "../../curves/bn254", version = "=2.2.0" }
solana-bpf-loader-program = { path = "../bpf_loader", version = "=2.2.0" }
solana-cli-output = { path = "../../cli-output", version = "=2.2.0" }
solana-compute-budget = { path = "../../compute-budget", version = "=2.2.0" }
solana-compute-budget-instruction = { path = "../../compute-budget-instruction", version = "=2.2.0" }
solana-curve25519 = { path = "../../curves/curve25519", version = "=2.2.0" }
solana-decode-error = { path = "../../sdk/decode-error", version = "=2.2.0" }
solana-feature-set = { path = "../../sdk/feature-set", version = "=2.2.0" }
Expand Down Expand Up @@ -111,6 +112,9 @@ solana-accounts-db = { workspace = true }
solana-bpf-loader-program = { workspace = true }
solana-cli-output = { workspace = true }
solana-compute-budget = { workspace = true }
solana-compute-budget-instruction = { workspace = true, features = [
"dev-context-only-utils",
] }
solana-feature-set = { workspace = true }
solana-fee = { workspace = true }
solana-ledger = { workspace = true }
Expand Down
Loading

0 comments on commit 395db14

Please sign in to comment.