Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Commit

Permalink
chore(fee): small fixes (#1484)
Browse files Browse the repository at this point in the history
  • Loading branch information
avi-starkware authored Feb 12, 2024
1 parent 35793a0 commit 06ceabe
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 14 deletions.
10 changes: 1 addition & 9 deletions crates/blockifier/src/execution/syscalls/syscalls_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,56 +270,48 @@ fn verify_compiler_version(contract: FeatureContract, expected_version: &str) {

#[test_case(
ExecutionMode::Validate,
contract_address!(StarkFelt::ZERO),
TransactionVersion::ONE,
false,
false;
"Validate execution mode: block info fields should be zeroed. Transaction V1.")]
#[test_case(
ExecutionMode::Execute,
contract_address!(StarkFelt::try_from(TEST_SEQUENCER_ADDRESS).unwrap()),
TransactionVersion::ONE,
false,
false;
"Execute execution mode: block info should be as usual. Transaction V1.")]
#[test_case(
ExecutionMode::Validate,
contract_address!(StarkFelt::ZERO),
TransactionVersion::THREE,
false,
false;
"Validate execution mode: block info fields should be zeroed. Transaction V3.")]
#[test_case(
ExecutionMode::Execute,
contract_address!(StarkFelt::try_from(TEST_SEQUENCER_ADDRESS).unwrap()),
TransactionVersion::THREE,
false,
false;
"Execute execution mode: block info should be as usual. Transaction V3.")]
#[test_case(
ExecutionMode::Execute,
contract_address!(StarkFelt::try_from(TEST_SEQUENCER_ADDRESS).unwrap()),
TransactionVersion::ONE,
true,
false;
"Legacy contract. Execute execution mode: block info should be as usual. Transaction V1.")]
#[test_case(
ExecutionMode::Execute,
contract_address!(StarkFelt::try_from(TEST_SEQUENCER_ADDRESS).unwrap()),
TransactionVersion::THREE,
true,
false;
"Legacy contract. Execute execution mode: block info should be as usual. Transaction V3.")]
#[test_case(
ExecutionMode::Execute,
contract_address!(StarkFelt::try_from(TEST_SEQUENCER_ADDRESS).unwrap()),
TransactionVersion::THREE,
false,
true;
"Execute execution mode: block info should be as usual. Transaction V3. Query.")]
fn test_get_execution_info(
execution_mode: ExecutionMode,
sequencer_address: ContractAddress,
mut version: TransactionVersion,
is_legacy: bool,
only_query: bool,
Expand All @@ -342,7 +334,7 @@ fn test_get_execution_info(
ExecutionMode::Execute => [
stark_felt!(CURRENT_BLOCK_NUMBER), // Block number.
stark_felt!(CURRENT_BLOCK_TIMESTAMP), // Block timestamp.
*sequencer_address.0.key(),
StarkFelt::try_from(TEST_SEQUENCER_ADDRESS).unwrap(),
],
};

Expand Down
7 changes: 4 additions & 3 deletions crates/blockifier/src/fee/gas_usage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ pub mod test;
/// * L1 data gas, for publishing data availability.
/// * L2 resources cost, e.g., for storing transaction calldata.
// TODO(barak, 18/03/2024): Move to ActualCostBuilder impl block.
// TODO(Avi, 01/03/2024): Resolve the clippy error cleanly.
#[allow(clippy::too_many_arguments)]
pub fn calculate_tx_gas_usage_vector<'a>(
versioned_constants: &VersionedConstants,
Expand Down Expand Up @@ -118,7 +119,7 @@ pub fn get_messages_gas_cost<'a>(
Ok(starknet_gas_usage + sharp_gas_usage)
}

// Return the gas cost for transaction calldata and transaction signature. Each felt costs a fixed
// Returns the gas cost for transaction calldata and transaction signature. Each felt costs a fixed
// and configurable amount of gas. This cost represents the cost of storing the calldata and the
// signature on L2.
pub fn get_calldata_and_signature_gas_cost(
Expand All @@ -136,8 +137,8 @@ pub fn get_calldata_and_signature_gas_cost(
GasVector { l1_gas: l1_milligas / 1000, l1_data_gas: 0 }
}

// Returns the gas cost of class information added to L2 via a Declare transaction. Each code felt
// costs a fixed and configurable amount of gas. The cost is 0 for non-Declare transactions.
// Returns the gas cost of declared class codes (Sierra, Casm and ABI). Each code felt costs a fixed
// and configurable amount of gas. The cost is 0 for non-Declare transactions.
pub fn get_code_gas_cost(
class_info: Option<ClassInfo>,
versioned_constants: &VersionedConstants,
Expand Down
2 changes: 1 addition & 1 deletion crates/blockifier/src/fee/gas_usage_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ fn test_get_da_gas_cost_basic(#[case] state_changes_count: StateChangesCount) {
);
}

/// This test goes over six cases. In each case, we calculate the gas usage given the parameters.
/// This test goes over seven cases. In each case, we calculate the gas usage given the parameters.
/// We then perform the same calculation manually, each time using only the relevant parameters.
/// The seven cases are:
/// 1. An empty transaction.
Expand Down
2 changes: 1 addition & 1 deletion crates/blockifier/src/transaction/transactions_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1143,7 +1143,7 @@ fn test_declare_tx(
);

let da_gas = declare_expected_gas_vector(tx_version, use_kzg_da);
let code_gas: GasVector = get_code_gas_cost(Some(class_info.clone()), versioned_constants);
let code_gas = get_code_gas_cost(Some(class_info.clone()), versioned_constants);
let gas_usage = code_gas + da_gas;

let expected_execution_info = TransactionExecutionInfo {
Expand Down

0 comments on commit 06ceabe

Please sign in to comment.