Skip to content

Commit

Permalink
Merge branch 'master' into bank_snapshot_complete_state
Browse files Browse the repository at this point in the history
  • Loading branch information
xiangzhu70 authored Feb 3, 2023
2 parents 28e1116 + 785a6e3 commit 4816456
Show file tree
Hide file tree
Showing 19 changed files with 13,029 additions and 12,572 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/release-artifacts-auto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ on:
tags:
- v[0-9]+.[0-9]+.[0-9]+

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
release-artifacts:
uses: ./.github/workflows/release-artifacts.yml
Expand Down
20 changes: 20 additions & 0 deletions .mergify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,23 @@ pull_request_rules:
- name: label changes from community
conditions:
- author≠@core-contributors
- author≠@monorepo-maintainers
- author≠@monorepo-write
- author≠@monorepo-triage
- author≠mergify[bot]
- author≠dependabot[bot]
- author≠github-actions[bot]
actions:
label:
add:
- community
- need:merge-assist
- name: request review for community changes
conditions:
- author≠@core-contributors
- author≠@monorepo-maintainers
- author≠@monorepo-write
- author≠@monorepo-triage
- author≠mergify[bot]
- author≠dependabot[bot]
- author≠github-actions[bot]
Expand All @@ -31,6 +38,19 @@ pull_request_rules:
request_reviews:
teams:
- "@solana-labs/community-pr-subscribers"
- name: label changes from monorepo-triage
conditions:
- author≠@core-contributors
- author≠mergify[bot]
- author≠dependabot[bot]
- author≠github-actions[bot]
- author≠@monorepo-maintainers
- author≠@monorepo-write
- author=@monorepo-triage
actions:
label:
add:
- need:merge-assist
- name: automatic merge (squash) on CI success
conditions:
- and:
Expand Down
4 changes: 2 additions & 2 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion core/src/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,7 @@ impl Validator {
let connection_cache = ConnectionCache::new_with_client_options(
tpu_connection_pool_size,
None,
Some((&identity_keypair, node.info.gossip.ip())),
Some((&identity_keypair, node.info.tpu.ip())),
Some((&staked_nodes, &identity_keypair.pubkey())),
);
Arc::new(connection_cache)
Expand Down
97 changes: 94 additions & 3 deletions program-runtime/src/compute_budget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ impl ComputeBudget {
instructions: impl Iterator<Item = (&'a Pubkey, &'a CompiledInstruction)>,
default_units_per_instruction: bool,
support_request_units_deprecated: bool,
enable_request_heap_frame_ix: bool,
) -> Result<PrioritizationFeeDetails, TransactionError> {
let mut num_non_compute_budget_instructions: usize = 0;
let mut updated_compute_unit_limit = None;
Expand Down Expand Up @@ -223,7 +224,8 @@ impl ComputeBudget {
}

if let Some((bytes, i)) = requested_heap_size {
if bytes > MAX_HEAP_FRAME_BYTES
if !enable_request_heap_frame_ix
|| bytes > MAX_HEAP_FRAME_BYTES
|| bytes < MIN_HEAP_FRAME_BYTES as u32
|| bytes % 1024 != 0
{
Expand Down Expand Up @@ -270,7 +272,7 @@ mod tests {
};

macro_rules! test {
( $instructions: expr, $expected_result: expr, $expected_budget: expr ) => {
( $instructions: expr, $expected_result: expr, $expected_budget: expr, $enable_request_heap_frame_ix: expr ) => {
let payer_keypair = Keypair::new();
let tx = SanitizedTransaction::from_transaction_for_tests(Transaction::new(
&[&payer_keypair],
Expand All @@ -282,12 +284,13 @@ mod tests {
tx.message().program_instructions_iter(),
true,
false, /*not support request_units_deprecated*/
$enable_request_heap_frame_ix,
);
assert_eq!($expected_result, result);
assert_eq!(compute_budget, $expected_budget);
};
( $instructions: expr, $expected_result: expr, $expected_budget: expr) => {
test!($instructions, $expected_result, $expected_budget);
test!($instructions, $expected_result, $expected_budget, true);
};
}

Expand Down Expand Up @@ -547,4 +550,92 @@ mod tests {
ComputeBudget::default()
);
}

#[test]
fn test_process_instructions_disable_request_heap_frame() {
// assert empty message results default compute budget and fee
test!(
&[],
Ok(PrioritizationFeeDetails::default()),
ComputeBudget {
compute_unit_limit: 0,
..ComputeBudget::default()
},
false
);

// assert requesting heap frame when feature is disable will result instruction error
test!(
&[
ComputeBudgetInstruction::request_heap_frame(40 * 1024),
Instruction::new_with_bincode(Pubkey::new_unique(), &0_u8, vec![]),
],
Err(TransactionError::InstructionError(
0,
InstructionError::InvalidInstructionData
)),
ComputeBudget::default(),
false
);
test!(
&[
Instruction::new_with_bincode(Pubkey::new_unique(), &0_u8, vec![]),
ComputeBudgetInstruction::request_heap_frame(MAX_HEAP_FRAME_BYTES),
],
Err(TransactionError::InstructionError(
1,
InstructionError::InvalidInstructionData,
)),
ComputeBudget::default(),
false
);
test!(
&[
Instruction::new_with_bincode(Pubkey::new_unique(), &0_u8, vec![]),
ComputeBudgetInstruction::request_heap_frame(MAX_HEAP_FRAME_BYTES),
ComputeBudgetInstruction::set_compute_unit_limit(MAX_COMPUTE_UNIT_LIMIT),
ComputeBudgetInstruction::set_compute_unit_price(u64::MAX),
],
Err(TransactionError::InstructionError(
1,
InstructionError::InvalidInstructionData,
)),
ComputeBudget::default(),
false
);
test!(
&[
Instruction::new_with_bincode(Pubkey::new_unique(), &0_u8, vec![]),
ComputeBudgetInstruction::set_compute_unit_limit(1),
ComputeBudgetInstruction::request_heap_frame(MAX_HEAP_FRAME_BYTES),
ComputeBudgetInstruction::set_compute_unit_price(u64::MAX),
],
Err(TransactionError::InstructionError(
2,
InstructionError::InvalidInstructionData,
)),
ComputeBudget::default(),
false
);

// assert normal results when not requesting heap frame when the feature is disabled
test!(
&[
Instruction::new_with_bincode(Pubkey::new_unique(), &0_u8, vec![]),
Instruction::new_with_bincode(Pubkey::new_unique(), &0_u8, vec![]),
Instruction::new_with_bincode(Pubkey::new_unique(), &0_u8, vec![]),
Instruction::new_with_bincode(Pubkey::new_unique(), &0_u8, vec![]),
Instruction::new_with_bincode(Pubkey::new_unique(), &0_u8, vec![]),
Instruction::new_with_bincode(Pubkey::new_unique(), &0_u8, vec![]),
Instruction::new_with_bincode(Pubkey::new_unique(), &0_u8, vec![]),
Instruction::new_with_bincode(Pubkey::new_unique(), &0_u8, vec![]),
],
Ok(PrioritizationFeeDetails::default()),
ComputeBudget {
compute_unit_limit: DEFAULT_INSTRUCTION_COMPUTE_UNIT_LIMIT as u64 * 7,
..ComputeBudget::default()
},
false
);
}
}
2 changes: 2 additions & 0 deletions programs/sbf/tests/programs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3588,6 +3588,7 @@ fn test_program_fees() {
true,
false,
true,
true,
);
bank_client
.send_and_confirm_message(&[&mint_keypair], message)
Expand All @@ -3611,6 +3612,7 @@ fn test_program_fees() {
true,
false,
true,
true,
);
assert!(expected_normal_fee < expected_prioritized_fee);

Expand Down
4 changes: 3 additions & 1 deletion runtime/src/accounts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use {
bpf_loader_upgradeable::{self, UpgradeableLoaderState},
clock::{BankId, Slot},
feature_set::{
self, remove_congestion_multiplier_from_fee_calculation,
self, enable_request_heap_frame_ix, remove_congestion_multiplier_from_fee_calculation,
remove_deprecated_request_unit_ix, use_default_units_in_fee_calculation, FeatureSet,
},
fee::FeeStructure,
Expand Down Expand Up @@ -601,6 +601,7 @@ impl Accounts {
feature_set.is_active(&use_default_units_in_fee_calculation::id()),
!feature_set.is_active(&remove_deprecated_request_unit_ix::id()),
feature_set.is_active(&remove_congestion_multiplier_from_fee_calculation::id()),
feature_set.is_active(&enable_request_heap_frame_ix::id()) || self.accounts_db.expected_cluster_type() != ClusterType::MainnetBeta,
)
} else {
return (Err(TransactionError::BlockhashNotFound), None);
Expand Down Expand Up @@ -1641,6 +1642,7 @@ mod tests {
true,
false,
true,
true,
);
assert_eq!(fee, lamports_per_signature);

Expand Down
Loading

0 comments on commit 4816456

Please sign in to comment.