Skip to content

Commit

Permalink
Rename gas.reduce to gas.computeFee
Browse files Browse the repository at this point in the history
  • Loading branch information
spalladino committed Apr 24, 2024
1 parent 0d4acef commit c10a66c
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ impl PublicKernelTeardownCircuitPrivateInputs {
// TODO(palla/gas): Load gas fees from a PublicConstantData struct that's currently missing
let block_gas_fees = GasFees::default();
let inclusion_fee = self.previous_kernel.public_inputs.constants.tx_context.gas_settings.inclusion_fee;
let computed_transaction_fee = total_gas_used.reduce(block_gas_fees) + inclusion_fee;
let computed_transaction_fee = total_gas_used.compute_fee(block_gas_fees) + inclusion_fee;

// dep::types::debug_log::debug_log_format(
// "Validating tx fee: total_gas_used.da={0} total_gas_used.l1={1} total_gas_used.l2={2} block_fee_per_gas.da={3} block_fee_per_gas.l1={4} block_fee_per_gas.l2={5} inclusion_fee={6} computed={7} actual={8}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl Gas {
)
}

pub fn reduce(self, fees: GasFees) -> Field {
pub fn compute_fee(self, fees: GasFees) -> Field {
(self.da_gas as Field) * fees.fee_per_da_gas
+ (self.l1_gas as Field) * fees.fee_per_l1_gas
+ (self.l2_gas as Field) * fees.fee_per_l2_gas
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/circuits.js/src/structs/gas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export class Gas {
return new Gas(Math.ceil(this.daGas * scalar), Math.ceil(this.l1Gas * scalar), Math.ceil(this.l2Gas * scalar));
}

reduce(gasFees: GasFees) {
computeFee(gasFees: GasFees) {
return GasDimensions.reduce(
(acc, dimension) => acc.add(gasFees.get(dimension).mul(new Fr(this.get(dimension)))),
Fr.ZERO,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export class TeardownPhaseManager extends AbstractPhaseManager {
const gasFees = this.globalVariables.gasFees;
// No need to add teardown limits since they are already included in end.gasUsed
const gasUsed = previousPublicKernelOutput.end.gasUsed.add(previousPublicKernelOutput.endNonRevertibleData.gasUsed);
const txFee = gasSettings.inclusionFee.add(gasUsed.reduce(gasFees));
const txFee = gasSettings.inclusionFee.add(gasUsed.computeFee(gasFees));
this.log.debug(`Computed tx fee`, { txFee, gasUsed: inspect(gasUsed), gasFees: inspect(gasFees) });
return txFee;
}
Expand Down

0 comments on commit c10a66c

Please sign in to comment.