Skip to content

Commit

Permalink
feat: Use gas fees from historical header for computing tx fee
Browse files Browse the repository at this point in the history
  • Loading branch information
spalladino committed Apr 25, 2024
1 parent 4b563cd commit 34792a6
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ impl PublicKernelTeardownCircuitPrivateInputs {
let transaction_fee = self.public_call.call_stack_item.public_inputs.transaction_fee;
// Note that teardown_gas is already included in end.gas_used as it was injected by the private kernel
let total_gas_used = self.previous_kernel.public_inputs.end.gas_used.add(self.previous_kernel.public_inputs.end_non_revertible.gas_used);
// TODO(palla/gas): Load gas fees from a PublicConstantData struct that's currently missing
let block_gas_fees = GasFees::default();
let block_gas_fees = self.previous_kernel.public_inputs.constants.historical_header.global_variables.gas_fees;
let inclusion_fee = self.previous_kernel.public_inputs.constants.tx_context.gas_settings.inclusion_fee;
let computed_transaction_fee = total_gas_used.compute_fee(block_gas_fees) + inclusion_fee;

Expand Down
1 change: 1 addition & 0 deletions yarn-project/simulator/src/public/public_processor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ describe('public_processor', () => {
);

const header = Header.empty();
header.globalVariables.gasFees = GasFees.default();
const stateReference = new StateReference(
header.state.l1ToL2MessageTree,
new PartialStateReference(header.state.partial.noteHashTree, header.state.partial.nullifierTree, snap),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export class TeardownPhaseManager extends AbstractPhaseManager {

protected override getTransactionFee(tx: Tx, previousPublicKernelOutput: PublicKernelCircuitPublicInputs): Fr {
const gasSettings = tx.data.constants.txContext.gasSettings;
const gasFees = this.globalVariables.gasFees;
const gasFees = this.historicalHeader.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.computeFee(gasFees));
Expand Down

0 comments on commit 34792a6

Please sign in to comment.