From 4bdbcf24973b8f26ab8d3bd0439366e559ed844d Mon Sep 17 00:00:00 2001 From: Justin Starry Date: Wed, 18 May 2022 15:25:33 +0800 Subject: [PATCH] fix conflicts --- runtime/src/cost_model.rs | 11 +----- runtime/src/execute_cost_table.rs | 40 ---------------------- test-validator/src/lib.rs | 34 ------------------ validator/src/bin/solana-test-validator.rs | 23 ------------- 4 files changed, 1 insertion(+), 107 deletions(-) diff --git a/runtime/src/cost_model.rs b/runtime/src/cost_model.rs index e1fdad6fc78cf1..435f25170c393a 100644 --- a/runtime/src/cost_model.rs +++ b/runtime/src/cost_model.rs @@ -420,23 +420,14 @@ mod tests { debug!("many random transaction {:?}", tx); let testee = CostModel::default(); -<<<<<<< HEAD let result = testee.get_transaction_cost(&tx); // expected cost for two random/unknown program is - let expected_cost = testee.instruction_execution_cost_table.get_default_units() * 2; - assert_eq!((0, expected_cost), result); -======= let expected_cost = testee .instruction_execution_cost_table .get_default_compute_unit_limit() * 2; - let mut tx_cost = TransactionCost::default(); - testee.get_transaction_cost(&mut tx_cost, &tx); - assert_eq!(0, tx_cost.builtins_execution_cost); - assert_eq!(expected_cost, tx_cost.bpf_execution_cost); - assert_eq!(0, tx_cost.data_bytes_cost); ->>>>>>> a1522d002 (Use consistent naming for compute unit limit (#25229)) + assert_eq!((0, expected_cost), result); } #[test] diff --git a/runtime/src/execute_cost_table.rs b/runtime/src/execute_cost_table.rs index 7a4bcfe3ad5adb..7925bed99682b4 100644 --- a/runtime/src/execute_cost_table.rs +++ b/runtime/src/execute_cost_table.rs @@ -49,11 +49,7 @@ impl ExecuteCostTable { } /// average cost of all recorded programs -<<<<<<< HEAD - pub fn get_average_units(&self) -> u64 { -======= pub fn get_global_average_program_cost(&self) -> u64 { ->>>>>>> a1522d002 (Use consistent naming for compute unit limit (#25229)) if self.table.is_empty() { self.get_default_compute_unit_limit() } else { @@ -78,14 +74,9 @@ impl ExecuteCostTable { } /// returns None if program doesn't exist in table. In this case, -<<<<<<< HEAD - /// `get_default_units()`, `get_average_units()` or `get_statistical_mode_units()` - /// can be used to assign a value to new program. -======= /// `get_default_compute_unit_limit()`, `get_global_average_program_cost()` /// or `get_statistical_mode_program_cost()` can be used to assign a value /// to new program. ->>>>>>> a1522d002 (Use consistent naming for compute unit limit (#25229)) pub fn get_cost(&self, key: &Pubkey) -> Option<&u64> { self.table.get(key) } @@ -230,28 +221,18 @@ mod tests { // insert one record testee.upsert(&key1, cost1); assert_eq!(1, testee.get_count()); -<<<<<<< HEAD - assert_eq!(cost1, testee.get_average_units()); - assert_eq!(cost1, testee.get_statistical_mode_units()); -======= assert_eq!(cost1, testee.get_global_average_program_cost()); assert_eq!(cost1, testee.get_statistical_mode_program_cost()); ->>>>>>> a1522d002 (Use consistent naming for compute unit limit (#25229)) assert_eq!(&cost1, testee.get_cost(&key1).unwrap()); // insert 2nd record testee.upsert(&key2, cost2); assert_eq!(2, testee.get_count()); -<<<<<<< HEAD - assert_eq!((cost1 + cost2) / 2_u64, testee.get_average_units()); - assert_eq!(cost2, testee.get_statistical_mode_units()); -======= assert_eq!( (cost1 + cost2) / 2_u64, testee.get_global_average_program_cost() ); assert_eq!(cost2, testee.get_statistical_mode_program_cost()); ->>>>>>> a1522d002 (Use consistent naming for compute unit limit (#25229)) assert_eq!(&cost1, testee.get_cost(&key1).unwrap()); assert_eq!(&cost2, testee.get_cost(&key2).unwrap()); @@ -260,16 +241,8 @@ mod tests { assert_eq!(2, testee.get_count()); assert_eq!( ((cost1 + cost2) / 2 + cost2) / 2_u64, -<<<<<<< HEAD - testee.get_average_units() -======= testee.get_global_average_program_cost() ); - assert_eq!( - (cost1 + cost2) / 2, - testee.get_statistical_mode_program_cost() ->>>>>>> a1522d002 (Use consistent naming for compute unit limit (#25229)) - ); assert_eq!(&((cost1 + cost2) / 2), testee.get_cost(&key1).unwrap()); assert_eq!(&cost2, testee.get_cost(&key2).unwrap()); } @@ -303,16 +276,11 @@ mod tests { // insert 3rd record, pushes out the oldest (eg 1st) record testee.upsert(&key3, cost3); assert_eq!(2, testee.get_count()); -<<<<<<< HEAD - assert_eq!((cost2 + cost3) / 2_u64, testee.get_average_units()); - assert_eq!(cost3, testee.get_statistical_mode_units()); -======= assert_eq!( (cost2 + cost3) / 2_u64, testee.get_global_average_program_cost() ); assert_eq!(cost3, testee.get_statistical_mode_program_cost()); ->>>>>>> a1522d002 (Use consistent naming for compute unit limit (#25229)) assert!(testee.get_cost(&key1).is_none()); assert_eq!(&cost2, testee.get_cost(&key2).unwrap()); assert_eq!(&cost3, testee.get_cost(&key3).unwrap()); @@ -323,16 +291,8 @@ mod tests { testee.upsert(&key4, cost4); assert_eq!( ((cost1 + cost2) / 2 + cost4) / 2_u64, -<<<<<<< HEAD - testee.get_average_units() -======= testee.get_global_average_program_cost() ); - assert_eq!( - (cost1 + cost2) / 2, - testee.get_statistical_mode_program_cost() ->>>>>>> a1522d002 (Use consistent naming for compute unit limit (#25229)) - ); assert_eq!(2, testee.get_count()); assert!(testee.get_cost(&key1).is_none()); assert_eq!(&((cost1 + cost2) / 2), testee.get_cost(&key2).unwrap()); diff --git a/test-validator/src/lib.rs b/test-validator/src/lib.rs index 9a32135f170117..c5ede9c3c78649 100644 --- a/test-validator/src/lib.rs +++ b/test-validator/src/lib.rs @@ -111,10 +111,6 @@ pub struct TestValidatorGenesis { pub geyser_plugin_config_files: Option>, pub accounts_db_caching_enabled: bool, deactivate_feature_set: HashSet, -<<<<<<< HEAD -======= - compute_unit_limit: Option, ->>>>>>> a1522d002 (Use consistent naming for compute unit limit (#25229)) } impl Default for TestValidatorGenesis { @@ -142,10 +138,6 @@ impl Default for TestValidatorGenesis { geyser_plugin_config_files: Option::>::default(), accounts_db_caching_enabled: bool::default(), deactivate_feature_set: HashSet::::default(), -<<<<<<< HEAD -======= - compute_unit_limit: Option::::default(), ->>>>>>> a1522d002 (Use consistent naming for compute unit limit (#25229)) } } } @@ -243,19 +235,6 @@ impl TestValidatorGenesis { self } -<<<<<<< HEAD -======= - pub fn compute_unit_limit(&mut self, compute_unit_limit: u64) -> &mut Self { - self.compute_unit_limit = Some(compute_unit_limit); - self - } - - #[deprecated(note = "Please use `compute_unit_limit` instead")] - pub fn max_compute_units(&mut self, max_compute_units: u64) -> &mut Self { - self.compute_unit_limit(max_compute_units) - } - ->>>>>>> a1522d002 (Use consistent naming for compute unit limit (#25229)) /// Add an account to the test environment pub fn add_account(&mut self, address: Pubkey, account: AccountSharedData) -> &mut Self { self.accounts.insert(address, account); @@ -696,19 +675,6 @@ impl TestValidator { ..AccountsDbConfig::default() }); -<<<<<<< HEAD -======= - let runtime_config = RuntimeConfig { - bpf_jit: !config.no_bpf_jit, - compute_budget: config - .compute_unit_limit - .map(|compute_unit_limit| ComputeBudget { - compute_unit_limit, - ..ComputeBudget::default() - }), - }; - ->>>>>>> a1522d002 (Use consistent naming for compute unit limit (#25229)) let mut validator_config = ValidatorConfig { geyser_plugin_config_files: config.geyser_plugin_config_files.clone(), accounts_db_caching_enabled: config.accounts_db_caching_enabled, diff --git a/validator/src/bin/solana-test-validator.rs b/validator/src/bin/solana-test-validator.rs index a1aad240e1903a..89b4f11e4f7dd6 100644 --- a/validator/src/bin/solana-test-validator.rs +++ b/validator/src/bin/solana-test-validator.rs @@ -368,18 +368,6 @@ fn main() { .multiple(true) .help("deactivate this feature in genesis.") ) -<<<<<<< HEAD -======= - .arg( - Arg::with_name("compute_unit_limit") - .long("compute-unit-limit") - .alias("max-compute-units") - .value_name("COMPUTE_UNITS") - .validator(is_parsable::) - .takes_value(true) - .help("Override the runtime's compute unit limit per transaction") - ) ->>>>>>> a1522d002 (Use consistent naming for compute unit limit (#25229)) .get_matches(); let output = if matches.is_present("quiet") { @@ -488,10 +476,6 @@ fn main() { exit(1); }) }); -<<<<<<< HEAD -======= - let compute_unit_limit = value_t!(matches, "compute_unit_limit", u64).ok(); ->>>>>>> a1522d002 (Use consistent naming for compute unit limit (#25229)) let faucet_addr = Some(SocketAddr::new( IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)), @@ -769,13 +753,6 @@ fn main() { ); } -<<<<<<< HEAD -======= - if let Some(compute_unit_limit) = compute_unit_limit { - genesis.compute_unit_limit(compute_unit_limit); - } - ->>>>>>> a1522d002 (Use consistent naming for compute unit limit (#25229)) match genesis.start_with_mint_address(mint_address, socket_addr_space) { Ok(test_validator) => { *admin_service_post_init.write().unwrap() =