Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

Commit

Permalink
fix conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
jstarry committed May 18, 2022
1 parent 680c5dd commit 4bdbcf2
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 107 deletions.
11 changes: 1 addition & 10 deletions runtime/src/cost_model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
40 changes: 0 additions & 40 deletions runtime/src/execute_cost_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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)
}
Expand Down Expand Up @@ -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());

Expand All @@ -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());
}
Expand Down Expand Up @@ -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());
Expand All @@ -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());
Expand Down
34 changes: 0 additions & 34 deletions test-validator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,6 @@ pub struct TestValidatorGenesis {
pub geyser_plugin_config_files: Option<Vec<PathBuf>>,
pub accounts_db_caching_enabled: bool,
deactivate_feature_set: HashSet<Pubkey>,
<<<<<<< HEAD
=======
compute_unit_limit: Option<u64>,
>>>>>>> a1522d002 (Use consistent naming for compute unit limit (#25229))
}

impl Default for TestValidatorGenesis {
Expand Down Expand Up @@ -142,10 +138,6 @@ impl Default for TestValidatorGenesis {
geyser_plugin_config_files: Option::<Vec<PathBuf>>::default(),
accounts_db_caching_enabled: bool::default(),
deactivate_feature_set: HashSet::<Pubkey>::default(),
<<<<<<< HEAD
=======
compute_unit_limit: Option::<u64>::default(),
>>>>>>> a1522d002 (Use consistent naming for compute unit limit (#25229))
}
}
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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,
Expand Down
23 changes: 0 additions & 23 deletions validator/src/bin/solana-test-validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<u64>)
.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") {
Expand Down Expand Up @@ -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)),
Expand Down Expand Up @@ -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() =
Expand Down

0 comments on commit 4bdbcf2

Please sign in to comment.