Skip to content

Commit

Permalink
Merge pull request #705 from Chia-Network/fixup_clippy_warnings
Browse files Browse the repository at this point in the history
fixup clippy warnings
  • Loading branch information
altendky committed Sep 9, 2024
2 parents ed7ece8 + fe7707d commit 5eeeda6
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions crates/chia-consensus/src/spendbundle_conditions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ pub fn get_conditions_from_spendbundle(
height: u32,
constants: &ConsensusConstants,
) -> Result<SpendBundleConditions, ValidationErr> {
const QUOTE_BYTES_COST: usize = 2;

let flags = get_flags_for_height_and_constants(height, constants) | MEMPOOL_MODE;

// below is an adapted version of the code from run_block_generators::run_block_generator2()
Expand All @@ -40,8 +42,7 @@ pub fn get_conditions_from_spendbundle(
});
// We don't pay the size cost (nor execution cost) of being wrapped by a
// quote (in solution_generator).
const QUOTE_BYTES: usize = 2;
let generator_length_without_quote = solution_generator(spends_info)?.len() - QUOTE_BYTES;
let generator_length_without_quote = solution_generator(spends_info)?.len() - QUOTE_BYTES_COST;
let byte_cost = generator_length_without_quote as u64 * constants.cost_per_byte;
subtract_cost(a, &mut cost_left, byte_cost)?;

Expand Down Expand Up @@ -102,6 +103,9 @@ mod tests {
#[values(0, 1, 1_000_000, 5_000_000)] height: u32,
#[case] cost: u64,
) {
const QUOTE_EXECUTION_COST: u64 = 20;
const QUOTE_BYTE_COST: u64 = 2 * TEST_CONSTANTS.cost_per_byte;

let bundle = SpendBundle::from_bytes(
&read(format!("../../test-bundles/{filename}.bundle")).expect("read file"),
)
Expand Down Expand Up @@ -140,8 +144,6 @@ mod tests {
.expect("run_block_generator2 failed");
// The cost difference here is because get_conditions_from_spendbundle
// does not include the overhead to make a block.
const QUOTE_EXECUTION_COST: u64 = 20;
const QUOTE_BYTE_COST: u64 = 2 * TEST_CONSTANTS.cost_per_byte;
assert_eq!(
conditions.cost,
block_conds.cost - QUOTE_EXECUTION_COST - QUOTE_BYTE_COST
Expand Down

0 comments on commit 5eeeda6

Please sign in to comment.