浏览代码

Clean up feature: raise_block_limits_to_50m (#6059)

Andrew Fitzgerald 6 月之前
父节点
当前提交
33a75a975b
共有 3 个文件被更改,包括 5 次插入236 次删除
  1. 1 14
      cost-model/src/block_cost_limits.rs
  2. 1 29
      runtime/src/bank.rs
  3. 3 193
      runtime/src/bank/tests.rs

+ 1 - 14
cost-model/src/block_cost_limits.rs

@@ -25,7 +25,7 @@ pub const INSTRUCTION_DATA_BYTES_COST: u64 = 140 /*bytes per us*/ / COMPUTE_UNIT
 /// accumulated by Transactions added to it; A transaction's compute units are
 /// calculated by cost_model, based on transaction's signatures, write locks,
 /// data size and built-in and SBF instructions.
-pub const MAX_BLOCK_UNITS: u64 = 48_000_000;
+pub const MAX_BLOCK_UNITS: u64 = MAX_BLOCK_UNITS_SIMD_0207;
 pub const MAX_BLOCK_UNITS_SIMD_0207: u64 = 50_000_000;
 pub const MAX_BLOCK_UNITS_SIMD_0256: u64 = 60_000_000;
 
@@ -42,19 +42,6 @@ pub const MAX_VOTE_UNITS: u64 = 36_000_000;
 /// This can also be thought of as the maximum size of new allocations per block.
 pub const MAX_BLOCK_ACCOUNTS_DATA_SIZE_DELTA: u64 = 100_000_000;
 
-/// Return the block limits that will be used upon activation of SIMD-0207.
-/// Returns as
-/// (account_limit, block_limit, vote_limit)
-// ^ Above order is used to be consistent with the order of
-//   `CostTracker::set_limits`.
-pub const fn simd_0207_block_limits() -> (u64, u64, u64) {
-    (
-        MAX_WRITABLE_ACCOUNT_UNITS,
-        MAX_BLOCK_UNITS_SIMD_0207,
-        MAX_VOTE_UNITS,
-    )
-}
-
 /// Return the block limits that will be used upon activation of SIMD-0256.
 /// Returns as
 /// (account_limit, block_limit, vote_limit)

+ 1 - 29
runtime/src/bank.rs

@@ -96,10 +96,7 @@ use {
     solana_builtins::{prototype::BuiltinPrototype, BUILTINS, STATELESS_BUILTINS},
     solana_compute_budget::compute_budget::ComputeBudget,
     solana_compute_budget_instruction::instructions_processor::process_compute_budget_instructions,
-    solana_cost_model::{
-        block_cost_limits::{simd_0207_block_limits, simd_0256_block_limits},
-        cost_tracker::CostTracker,
-    },
+    solana_cost_model::{block_cost_limits::simd_0256_block_limits, cost_tracker::CostTracker},
     solana_fee::FeeFeatures,
     solana_lattice_hash::lt_hash::LtHash,
     solana_measure::{meas_dur, measure::Measure, measure_time, measure_us},
@@ -4898,18 +4895,6 @@ impl Bank {
         // We must apply previously activated features related to limits here
         // so that the initial bank state is consistent with the feature set.
         // Cost-tracker limits are propagated through children banks.
-        if self
-            .feature_set
-            .is_active(&feature_set::raise_block_limits_to_50m::id())
-        {
-            let (account_cost_limit, block_cost_limit, vote_cost_limit) = simd_0207_block_limits();
-            self.write_cost_tracker().unwrap().set_limits(
-                account_cost_limit,
-                block_cost_limit,
-                vote_cost_limit,
-            );
-        }
-
         if self
             .feature_set
             .is_active(&feature_set::raise_block_limits_to_60m::id())
@@ -6620,19 +6605,6 @@ impl Bank {
             }
         }
 
-        if new_feature_activations.contains(&feature_set::raise_block_limits_to_50m::id())
-            && !self
-                .feature_set
-                .is_active(&feature_set::raise_block_limits_to_60m::id())
-        {
-            let (account_cost_limit, block_cost_limit, vote_cost_limit) = simd_0207_block_limits();
-            self.write_cost_tracker().unwrap().set_limits(
-                account_cost_limit,
-                block_cost_limit,
-                vote_cost_limit,
-            );
-        }
-
         if new_feature_activations.contains(&feature_set::raise_block_limits_to_60m::id()) {
             let (account_cost_limit, block_cost_limit, vote_cost_limit) = simd_0256_block_limits();
             self.write_cost_tracker().unwrap().set_limits(

+ 3 - 193
runtime/src/bank/tests.rs

@@ -39,9 +39,7 @@ use {
     solana_compute_budget::{
         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_program_runtime::{
         declare_process_instruction,
@@ -8049,9 +8047,6 @@ fn test_block_limits() {
     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()));
@@ -8061,35 +8056,6 @@ fn test_block_limits() {
         "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
     bank.store_account(
         &feature_set::raise_block_limits_to_60m::id(),
@@ -8099,7 +8065,7 @@ fn test_block_limits() {
     bank.apply_feature_activations(ApplyFeatureActivationsCaller::FinishInit, true);
     assert_eq!(
         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"
     );
 
@@ -8112,7 +8078,7 @@ fn test_block_limits() {
     );
 
     // 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!(
         bank.read_cost_tracker().unwrap().get_block_limit(),
         MAX_BLOCK_UNITS_SIMD_0256,
@@ -8129,20 +8095,6 @@ fn test_block_limits() {
         "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(
         &mut genesis_config,
         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]
 fn test_program_replacement() {
     let mut bank = create_simple_test_bank(0);