cleanup feature code after mainnet-beta activation of DdLwVYuvDz26JohmgSbA7mjpJFgX5zP2dkp8qsF2C33V (#34089)
cleanup feature code after mainnet-beta activation
This commit is contained in:
parent
501458a7da
commit
2dfcdce630
|
@ -416,8 +416,7 @@ fn load_transaction_accounts(
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// If feature `cap_transaction_accounts_data_size` is active, total accounts data a
|
/// Total accounts data a transaction can load is limited to
|
||||||
/// transaction can load is limited to
|
|
||||||
/// if `set_tx_loaded_accounts_data_size` instruction is not activated or not used, then
|
/// if `set_tx_loaded_accounts_data_size` instruction is not activated or not used, then
|
||||||
/// default value of 64MiB to not break anyone in Mainnet-beta today
|
/// default value of 64MiB to not break anyone in Mainnet-beta today
|
||||||
/// else
|
/// else
|
||||||
|
@ -427,24 +426,17 @@ fn get_requested_loaded_accounts_data_size_limit(
|
||||||
tx: &SanitizedTransaction,
|
tx: &SanitizedTransaction,
|
||||||
feature_set: &FeatureSet,
|
feature_set: &FeatureSet,
|
||||||
) -> Result<Option<NonZeroUsize>> {
|
) -> Result<Option<NonZeroUsize>> {
|
||||||
if feature_set.is_active(&feature_set::cap_transaction_accounts_data_size::id()) {
|
let compute_budget_limits =
|
||||||
let compute_budget_limits = process_compute_budget_instructions(
|
process_compute_budget_instructions(tx.message().program_instructions_iter(), feature_set)
|
||||||
tx.message().program_instructions_iter(),
|
.unwrap_or_default();
|
||||||
feature_set,
|
// sanitize against setting size limit to zero
|
||||||
)
|
NonZeroUsize::new(
|
||||||
.unwrap_or_default();
|
usize::try_from(compute_budget_limits.loaded_accounts_bytes).unwrap_or_default(),
|
||||||
// sanitize against setting size limit to zero
|
)
|
||||||
NonZeroUsize::new(
|
.map_or(
|
||||||
usize::try_from(compute_budget_limits.loaded_accounts_bytes).unwrap_or_default(),
|
Err(TransactionError::InvalidLoadedAccountsDataSizeLimit),
|
||||||
)
|
|v| Ok(Some(v)),
|
||||||
.map_or(
|
)
|
||||||
Err(TransactionError::InvalidLoadedAccountsDataSizeLimit),
|
|
||||||
|v| Ok(Some(v)),
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
// feature not activated, no loaded accounts data limit imposed.
|
|
||||||
Ok(None)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn account_shared_data_from_program(
|
fn account_shared_data_from_program(
|
||||||
|
@ -1549,7 +1541,6 @@ mod tests {
|
||||||
solana_sdk::instruction::Instruction::new_with_bincode(Pubkey::new_unique(), &0_u8, vec![]),
|
solana_sdk::instruction::Instruction::new_with_bincode(Pubkey::new_unique(), &0_u8, vec![]),
|
||||||
];
|
];
|
||||||
|
|
||||||
let result_no_limit = Ok(None);
|
|
||||||
let result_default_limit = Ok(Some(
|
let result_default_limit = Ok(Some(
|
||||||
NonZeroUsize::new(
|
NonZeroUsize::new(
|
||||||
usize::try_from(compute_budget_processor::MAX_LOADED_ACCOUNTS_DATA_SIZE_BYTES)
|
usize::try_from(compute_budget_processor::MAX_LOADED_ACCOUNTS_DATA_SIZE_BYTES)
|
||||||
|
@ -1563,22 +1554,13 @@ mod tests {
|
||||||
|
|
||||||
let mut feature_set = FeatureSet::default();
|
let mut feature_set = FeatureSet::default();
|
||||||
|
|
||||||
// if `cap_transaction_accounts_data_size feature` is disable,
|
// if `add_set_tx_loaded_accounts_data_size_instruction` is disabled,
|
||||||
// the result will always be no limit
|
|
||||||
test(tx_not_set_limit, &feature_set, &result_no_limit);
|
|
||||||
test(tx_set_limit_99, &feature_set, &result_no_limit);
|
|
||||||
test(tx_set_limit_0, &feature_set, &result_no_limit);
|
|
||||||
|
|
||||||
// if `cap_transaction_accounts_data_size` is enabled, and
|
|
||||||
// `add_set_tx_loaded_accounts_data_size_instruction` is disabled,
|
|
||||||
// the result will always be default limit (64MiB)
|
// the result will always be default limit (64MiB)
|
||||||
feature_set.activate(&feature_set::cap_transaction_accounts_data_size::id(), 0);
|
|
||||||
test(tx_not_set_limit, &feature_set, &result_default_limit);
|
test(tx_not_set_limit, &feature_set, &result_default_limit);
|
||||||
test(tx_set_limit_99, &feature_set, &result_default_limit);
|
test(tx_set_limit_99, &feature_set, &result_default_limit);
|
||||||
test(tx_set_limit_0, &feature_set, &result_default_limit);
|
test(tx_set_limit_0, &feature_set, &result_default_limit);
|
||||||
|
|
||||||
// if `cap_transaction_accounts_data_size` and
|
// if `add_set_tx_loaded_accounts_data_size_instruction` is enabled,
|
||||||
// `add_set_tx_loaded_accounts_data_size_instruction` are both enabled,
|
|
||||||
// the results are:
|
// the results are:
|
||||||
// if tx doesn't set limit, then default limit (64MiB)
|
// if tx doesn't set limit, then default limit (64MiB)
|
||||||
// if tx sets limit, then requested limit
|
// if tx sets limit, then requested limit
|
||||||
|
|
Loading…
Reference in New Issue