|
@@ -39,9 +39,7 @@ use {
|
|
|
solana_compute_budget::{
|
|
solana_compute_budget::{
|
|
|
compute_budget::ComputeBudget, compute_budget_limits::ComputeBudgetLimits,
|
|
compute_budget::ComputeBudget, compute_budget_limits::ComputeBudgetLimits,
|
|
|
},
|
|
},
|
|
|
- solana_cost_model::block_cost_limits::{
|
|
|
|
|
- MAX_BLOCK_UNITS, MAX_BLOCK_UNITS_SIMD_0207, MAX_BLOCK_UNITS_SIMD_0256,
|
|
|
|
|
- },
|
|
|
|
|
|
|
+ solana_cost_model::block_cost_limits::{MAX_BLOCK_UNITS, MAX_BLOCK_UNITS_SIMD_0256},
|
|
|
solana_logger,
|
|
solana_logger,
|
|
|
solana_program_runtime::{
|
|
solana_program_runtime::{
|
|
|
declare_process_instruction,
|
|
declare_process_instruction,
|
|
@@ -8049,9 +8047,6 @@ fn test_block_limits() {
|
|
|
let mut bank = Bank::new_from_parent(bank0, &Pubkey::default(), 1);
|
|
let mut bank = Bank::new_from_parent(bank0, &Pubkey::default(), 1);
|
|
|
|
|
|
|
|
// Ensure increased block limits features are inactive.
|
|
// Ensure increased block limits features are inactive.
|
|
|
- assert!(!bank
|
|
|
|
|
- .feature_set
|
|
|
|
|
- .is_active(&feature_set::raise_block_limits_to_50m::id()));
|
|
|
|
|
assert!(!bank
|
|
assert!(!bank
|
|
|
.feature_set
|
|
.feature_set
|
|
|
.is_active(&feature_set::raise_block_limits_to_60m::id()));
|
|
.is_active(&feature_set::raise_block_limits_to_60m::id()));
|
|
@@ -8061,35 +8056,6 @@ fn test_block_limits() {
|
|
|
"before activating the feature, bank should have old/default limit"
|
|
"before activating the feature, bank should have old/default limit"
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
- // Activate `raise_block_limits_to_50m` feature
|
|
|
|
|
- bank.store_account(
|
|
|
|
|
- &feature_set::raise_block_limits_to_50m::id(),
|
|
|
|
|
- &feature::create_account(&Feature::default(), 42),
|
|
|
|
|
- );
|
|
|
|
|
- // apply_feature_activations for `FinishInit` will not cause the block limit to be updated
|
|
|
|
|
- bank.apply_feature_activations(ApplyFeatureActivationsCaller::FinishInit, true);
|
|
|
|
|
- assert_eq!(
|
|
|
|
|
- bank.read_cost_tracker().unwrap().get_block_limit(),
|
|
|
|
|
- MAX_BLOCK_UNITS,
|
|
|
|
|
- "before activating the feature, bank should have old/default limit"
|
|
|
|
|
- );
|
|
|
|
|
-
|
|
|
|
|
- // apply_feature_activations for `NewFromParent` will cause feature to be activated
|
|
|
|
|
- bank.apply_feature_activations(ApplyFeatureActivationsCaller::NewFromParent, true);
|
|
|
|
|
- assert_eq!(
|
|
|
|
|
- bank.read_cost_tracker().unwrap().get_block_limit(),
|
|
|
|
|
- MAX_BLOCK_UNITS_SIMD_0207,
|
|
|
|
|
- "after activating the feature, bank should have new limit"
|
|
|
|
|
- );
|
|
|
|
|
-
|
|
|
|
|
- // Make sure the limits propagate to the child-bank.
|
|
|
|
|
- let mut bank = Bank::new_from_parent(Arc::new(bank), &Pubkey::default(), 2);
|
|
|
|
|
- assert_eq!(
|
|
|
|
|
- bank.read_cost_tracker().unwrap().get_block_limit(),
|
|
|
|
|
- MAX_BLOCK_UNITS_SIMD_0207,
|
|
|
|
|
- "child bank should have new limit"
|
|
|
|
|
- );
|
|
|
|
|
-
|
|
|
|
|
// Activate `raise_block_limits_to_60m` feature
|
|
// Activate `raise_block_limits_to_60m` feature
|
|
|
bank.store_account(
|
|
bank.store_account(
|
|
|
&feature_set::raise_block_limits_to_60m::id(),
|
|
&feature_set::raise_block_limits_to_60m::id(),
|
|
@@ -8099,7 +8065,7 @@ fn test_block_limits() {
|
|
|
bank.apply_feature_activations(ApplyFeatureActivationsCaller::FinishInit, true);
|
|
bank.apply_feature_activations(ApplyFeatureActivationsCaller::FinishInit, true);
|
|
|
assert_eq!(
|
|
assert_eq!(
|
|
|
bank.read_cost_tracker().unwrap().get_block_limit(),
|
|
bank.read_cost_tracker().unwrap().get_block_limit(),
|
|
|
- MAX_BLOCK_UNITS_SIMD_0207,
|
|
|
|
|
|
|
+ MAX_BLOCK_UNITS,
|
|
|
"before activating the feature, bank should have old/default limit"
|
|
"before activating the feature, bank should have old/default limit"
|
|
|
);
|
|
);
|
|
|
|
|
|
|
@@ -8112,7 +8078,7 @@ fn test_block_limits() {
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
// Make sure the limits propagate to the child-bank.
|
|
// Make sure the limits propagate to the child-bank.
|
|
|
- let bank = Bank::new_from_parent(Arc::new(bank), &Pubkey::default(), 3);
|
|
|
|
|
|
|
+ let bank = Bank::new_from_parent(Arc::new(bank), &Pubkey::default(), 2);
|
|
|
assert_eq!(
|
|
assert_eq!(
|
|
|
bank.read_cost_tracker().unwrap().get_block_limit(),
|
|
bank.read_cost_tracker().unwrap().get_block_limit(),
|
|
|
MAX_BLOCK_UNITS_SIMD_0256,
|
|
MAX_BLOCK_UNITS_SIMD_0256,
|
|
@@ -8129,20 +8095,6 @@ fn test_block_limits() {
|
|
|
"before activating the feature, bank should have old/default limit"
|
|
"before activating the feature, bank should have old/default limit"
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
- activate_feature(
|
|
|
|
|
- &mut genesis_config,
|
|
|
|
|
- feature_set::raise_block_limits_to_50m::id(),
|
|
|
|
|
- );
|
|
|
|
|
- let bank = Bank::new_for_tests(&genesis_config);
|
|
|
|
|
- assert!(bank
|
|
|
|
|
- .feature_set
|
|
|
|
|
- .is_active(&feature_set::raise_block_limits_to_50m::id()));
|
|
|
|
|
- assert_eq!(
|
|
|
|
|
- bank.read_cost_tracker().unwrap().get_block_limit(),
|
|
|
|
|
- MAX_BLOCK_UNITS_SIMD_0207,
|
|
|
|
|
- "bank created from genesis config should have new limit"
|
|
|
|
|
- );
|
|
|
|
|
-
|
|
|
|
|
activate_feature(
|
|
activate_feature(
|
|
|
&mut genesis_config,
|
|
&mut genesis_config,
|
|
|
feature_set::raise_block_limits_to_60m::id(),
|
|
feature_set::raise_block_limits_to_60m::id(),
|
|
@@ -8158,148 +8110,6 @@ fn test_block_limits() {
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-#[test]
|
|
|
|
|
-fn test_block_limits_feature_dual_activation() {
|
|
|
|
|
- let (bank0, _bank_forks) = create_simple_test_arc_bank(100_000);
|
|
|
|
|
- let mut bank = Bank::new_from_parent(bank0, &Pubkey::default(), 1);
|
|
|
|
|
-
|
|
|
|
|
- // Ensure increased block limits features are inactive.
|
|
|
|
|
- assert!(!bank
|
|
|
|
|
- .feature_set
|
|
|
|
|
- .is_active(&feature_set::raise_block_limits_to_50m::id()));
|
|
|
|
|
- assert!(!bank
|
|
|
|
|
- .feature_set
|
|
|
|
|
- .is_active(&feature_set::raise_block_limits_to_60m::id()));
|
|
|
|
|
- assert_eq!(
|
|
|
|
|
- bank.read_cost_tracker().unwrap().get_block_limit(),
|
|
|
|
|
- MAX_BLOCK_UNITS,
|
|
|
|
|
- "before activating the feature, bank should have old/default limit"
|
|
|
|
|
- );
|
|
|
|
|
-
|
|
|
|
|
- // Activate `raise_block_limits_to_50m` feature
|
|
|
|
|
- bank.store_account(
|
|
|
|
|
- &feature_set::raise_block_limits_to_50m::id(),
|
|
|
|
|
- &feature::create_account(&Feature::default(), 42),
|
|
|
|
|
- );
|
|
|
|
|
-
|
|
|
|
|
- // Activate `raise_block_limits_to_60m` feature
|
|
|
|
|
- bank.store_account(
|
|
|
|
|
- &feature_set::raise_block_limits_to_60m::id(),
|
|
|
|
|
- &feature::create_account(&Feature::default(), 42),
|
|
|
|
|
- );
|
|
|
|
|
-
|
|
|
|
|
- // apply_feature_activations for `NewFromParent` will cause `raise_block_limits_to_60m` to be activated
|
|
|
|
|
- bank.apply_feature_activations(ApplyFeatureActivationsCaller::NewFromParent, true);
|
|
|
|
|
- assert_eq!(
|
|
|
|
|
- bank.read_cost_tracker().unwrap().get_block_limit(),
|
|
|
|
|
- MAX_BLOCK_UNITS_SIMD_0256,
|
|
|
|
|
- "after activating the feature, bank should have newest limit"
|
|
|
|
|
- );
|
|
|
|
|
-
|
|
|
|
|
- // Make sure the limits propagate to the child-bank.
|
|
|
|
|
- let bank = Bank::new_from_parent(Arc::new(bank), &Pubkey::default(), 2);
|
|
|
|
|
- assert_eq!(
|
|
|
|
|
- bank.read_cost_tracker().unwrap().get_block_limit(),
|
|
|
|
|
- MAX_BLOCK_UNITS_SIMD_0256,
|
|
|
|
|
- "child bank should have newest limit"
|
|
|
|
|
- );
|
|
|
|
|
-
|
|
|
|
|
- // Test starting from a genesis config with and without feature account
|
|
|
|
|
- let (mut genesis_config, _keypair) = create_genesis_config(100_000);
|
|
|
|
|
- // Without feature account in genesis, old limits are used.
|
|
|
|
|
- let bank = Bank::new_for_tests(&genesis_config);
|
|
|
|
|
- assert_eq!(
|
|
|
|
|
- bank.read_cost_tracker().unwrap().get_block_limit(),
|
|
|
|
|
- MAX_BLOCK_UNITS,
|
|
|
|
|
- "before activating the feature, bank should have old/default limit"
|
|
|
|
|
- );
|
|
|
|
|
-
|
|
|
|
|
- // Activate `raise_block_limits_to_50m` feature
|
|
|
|
|
- activate_feature(
|
|
|
|
|
- &mut genesis_config,
|
|
|
|
|
- feature_set::raise_block_limits_to_50m::id(),
|
|
|
|
|
- );
|
|
|
|
|
- // Activate `raise_block_limits_to_60m` feature
|
|
|
|
|
- activate_feature(
|
|
|
|
|
- &mut genesis_config,
|
|
|
|
|
- feature_set::raise_block_limits_to_60m::id(),
|
|
|
|
|
- );
|
|
|
|
|
- let bank = Bank::new_for_tests(&genesis_config);
|
|
|
|
|
-
|
|
|
|
|
- // `raise_block_limits_to_60m` feature and block limits should be active.
|
|
|
|
|
- assert!(bank
|
|
|
|
|
- .feature_set
|
|
|
|
|
- .is_active(&feature_set::raise_block_limits_to_60m::id()));
|
|
|
|
|
- assert_eq!(
|
|
|
|
|
- bank.read_cost_tracker().unwrap().get_block_limit(),
|
|
|
|
|
- MAX_BLOCK_UNITS_SIMD_0256,
|
|
|
|
|
- "bank created from genesis config should have newest limit"
|
|
|
|
|
- );
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-#[test]
|
|
|
|
|
-fn test_block_limits_feature_reverse_order() {
|
|
|
|
|
- let (bank0, _bank_forks) = create_simple_test_arc_bank(100_000);
|
|
|
|
|
- let mut bank = Bank::new_from_parent(bank0, &Pubkey::default(), 1);
|
|
|
|
|
-
|
|
|
|
|
- // Ensure increased block limits features are inactive.
|
|
|
|
|
- assert!(!bank
|
|
|
|
|
- .feature_set
|
|
|
|
|
- .is_active(&feature_set::raise_block_limits_to_50m::id()));
|
|
|
|
|
- assert!(!bank
|
|
|
|
|
- .feature_set
|
|
|
|
|
- .is_active(&feature_set::raise_block_limits_to_60m::id()));
|
|
|
|
|
- assert_eq!(
|
|
|
|
|
- bank.read_cost_tracker().unwrap().get_block_limit(),
|
|
|
|
|
- MAX_BLOCK_UNITS,
|
|
|
|
|
- "before activating the feature, bank should have old/default limit"
|
|
|
|
|
- );
|
|
|
|
|
-
|
|
|
|
|
- // Activate `raise_block_limits_to_60m` feature
|
|
|
|
|
- bank.store_account(
|
|
|
|
|
- &feature_set::raise_block_limits_to_60m::id(),
|
|
|
|
|
- &feature::create_account(&Feature::default(), 42),
|
|
|
|
|
- );
|
|
|
|
|
-
|
|
|
|
|
- // apply_feature_activations for `NewFromParent` will cause `raise_block_limits_to_60m` to be activated
|
|
|
|
|
- bank.apply_feature_activations(ApplyFeatureActivationsCaller::NewFromParent, true);
|
|
|
|
|
- assert_eq!(
|
|
|
|
|
- bank.read_cost_tracker().unwrap().get_block_limit(),
|
|
|
|
|
- MAX_BLOCK_UNITS_SIMD_0256,
|
|
|
|
|
- "after activating the feature, bank should have new limit"
|
|
|
|
|
- );
|
|
|
|
|
-
|
|
|
|
|
- // Make sure the limits propagate to the child-bank.
|
|
|
|
|
- let mut bank = Bank::new_from_parent(Arc::new(bank), &Pubkey::default(), 2);
|
|
|
|
|
- assert_eq!(
|
|
|
|
|
- bank.read_cost_tracker().unwrap().get_block_limit(),
|
|
|
|
|
- MAX_BLOCK_UNITS_SIMD_0256,
|
|
|
|
|
- "child bank should have new limit"
|
|
|
|
|
- );
|
|
|
|
|
-
|
|
|
|
|
- // "Activate" `raise_block_limits_to_50m` feature
|
|
|
|
|
- bank.store_account(
|
|
|
|
|
- &feature_set::raise_block_limits_to_50m::id(),
|
|
|
|
|
- &feature::create_account(&Feature::default(), 42),
|
|
|
|
|
- );
|
|
|
|
|
-
|
|
|
|
|
- // apply_feature_activations for `NewFromParent`
|
|
|
|
|
- bank.apply_feature_activations(ApplyFeatureActivationsCaller::NewFromParent, true);
|
|
|
|
|
- assert_eq!(
|
|
|
|
|
- bank.read_cost_tracker().unwrap().get_block_limit(),
|
|
|
|
|
- MAX_BLOCK_UNITS_SIMD_0256,
|
|
|
|
|
- "bank should keep the same limit"
|
|
|
|
|
- );
|
|
|
|
|
-
|
|
|
|
|
- // Make sure the SIMD-0256 limits are still in place as they take precedence over the SIMD-0207 limits.
|
|
|
|
|
- let bank = Bank::new_from_parent(Arc::new(bank), &Pubkey::default(), 3);
|
|
|
|
|
- assert_eq!(
|
|
|
|
|
- bank.read_cost_tracker().unwrap().get_block_limit(),
|
|
|
|
|
- MAX_BLOCK_UNITS_SIMD_0256,
|
|
|
|
|
- "child bank should keep the same limit"
|
|
|
|
|
- );
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
#[test]
|
|
#[test]
|
|
|
fn test_program_replacement() {
|
|
fn test_program_replacement() {
|
|
|
let mut bank = create_simple_test_bank(0);
|
|
let mut bank = create_simple_test_bank(0);
|