Skip to content

Commit

Permalink
rebase master, fix merge
Browse files Browse the repository at this point in the history
  • Loading branch information
tao-stones committed Jun 28, 2024
1 parent 7ba56f4 commit 8f9ea1e
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 17 deletions.
1 change: 1 addition & 0 deletions compute-budget/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ solana-sdk = { workspace = true }
rustc_version = { workspace = true }

[features]
dev-context-only-utils = []
frozen-abi = [
"dep:solana-frozen-abi",
"solana-sdk/frozen-abi",
Expand Down
19 changes: 8 additions & 11 deletions compute-budget/src/compute_budget_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ pub struct ComputeBudgetLimits {
pub loaded_accounts_bytes: u32,
}

// Default is only usable from dev context (ie. tests, benches etc)
#[cfg(any(test, feature = "dev-context-only-utils"))]
impl Default for ComputeBudgetLimits {
fn default() -> Self {
Self::new_with(false)
}
}

impl ComputeBudgetLimits {
// default constructor with feature gate
pub fn new_with(use_default_loaded_accounts_data_size: bool) -> Self {
Expand Down Expand Up @@ -189,17 +197,6 @@ mod tests {
},
};

impl Default for ComputeBudgetLimits {
fn default() -> Self {
ComputeBudgetLimits {
updated_heap_bytes: u32::try_from(MIN_HEAP_FRAME_BYTES).unwrap(),
compute_unit_limit: MAX_COMPUTE_UNIT_LIMIT,
compute_unit_price: 0,
loaded_accounts_bytes: DEFAULT_LOADED_ACCOUNTS_DATA_SIZE_BYTES,
}
}
}

macro_rules! test {
( $instructions: expr, $expected_result: expr, $use_default_loaded_accounts_data_szie: expr) => {
let payer_keypair = Keypair::new();
Expand Down
2 changes: 1 addition & 1 deletion runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ use {
solana_bpf_loader_program::syscalls::create_program_runtime_environment_v1,
solana_compute_budget::{
compute_budget::ComputeBudget,
compute_budget_processor::process_compute_budget_instructions,
compute_budget_processor::{process_compute_budget_instructions, ComputeBudgetLimits},
},
solana_cost_model::cost_tracker::CostTracker,
solana_loader_v4_program::create_program_runtime_environment_v2,
Expand Down
1 change: 1 addition & 0 deletions svm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ prost = { workspace = true }
prost-types = { workspace = true }
rand = { workspace = true }
solana-bpf-loader-program = { workspace = true }
solana-compute-budget = { workspace = true, features = ["dev-context-only-utils"] }
solana-compute-budget-program = { workspace = true }
solana-logger = { workspace = true }
solana-sdk = { workspace = true, features = ["dev-context-only-utils"] }
Expand Down
2 changes: 1 addition & 1 deletion svm/src/account_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ fn load_transaction_accounts<CB: TransactionProcessingCallback>(

let requested_loaded_accounts_data_size_limit = get_requested_loaded_accounts_data_size_limit(
message,
feature_set.is_active(&default_loaded_accounts_data_size_limit::id()),
feature_set.is_active(&feature_set::default_loaded_accounts_data_size_limit::id()),
)?;
let mut accumulated_accounts_data_size: usize = 0;

Expand Down
9 changes: 5 additions & 4 deletions svm/src/transaction_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ use {
account::{AccountSharedData, ReadableAccount, PROGRAM_OWNERS},
clock::{Epoch, Slot},
feature_set::{
default_loaded_accounts_data_size_limit,
include_loaded_accounts_data_size_in_fee_calculation,
remove_rounding_in_fee_calculation, FeatureSet,
},
Expand Down Expand Up @@ -422,7 +423,7 @@ impl<FG: ForkGraph> TransactionBatchProcessor<FG> {
) -> transaction::Result<ValidatedTransactionDetails> {
let compute_budget_limits = process_compute_budget_instructions(
message.program_instructions_iter(),
feature_set.is_active(&feature_set::default_loaded_accounts_data_size_limit::id()),
feature_set.is_active(&default_loaded_accounts_data_size_limit::id()),
)
.map_err(|err| {
error_counters.invalid_compute_budget += 1;
Expand Down Expand Up @@ -1958,7 +1959,7 @@ mod tests {
&Hash::new_unique(),
));
let compute_budget_limits =
process_compute_budget_instructions(message.program_instructions_iter()).unwrap();
process_compute_budget_instructions(message.program_instructions_iter(), true).unwrap();
let fee_payer_address = message.fee_payer();
let current_epoch = 42;
let rent_collector = RentCollector {
Expand Down Expand Up @@ -2038,7 +2039,7 @@ mod tests {
&Hash::new_unique(),
));
let compute_budget_limits =
process_compute_budget_instructions(message.program_instructions_iter()).unwrap();
process_compute_budget_instructions(message.program_instructions_iter(), true).unwrap();
let fee_payer_address = message.fee_payer();
let mut rent_collector = RentCollector::default();
rent_collector.rent.lamports_per_byte_year = 1_000_000;
Expand Down Expand Up @@ -2275,7 +2276,7 @@ mod tests {
&Hash::new_unique(),
));
let compute_budget_limits =
process_compute_budget_instructions(message.program_instructions_iter()).unwrap();
process_compute_budget_instructions(message.program_instructions_iter(), true).unwrap();
let fee_payer_address = message.fee_payer();
let min_balance = Rent::default().minimum_balance(nonce::State::size());
let transaction_fee = lamports_per_signature;
Expand Down

0 comments on commit 8f9ea1e

Please sign in to comment.