From 972bf791578ccaa6c55b75d34bcfea73eafa52cc Mon Sep 17 00:00:00 2001 From: Santiago Palladino Date: Thu, 2 May 2024 10:58:28 -0300 Subject: [PATCH 1/2] docs: Update fees kernel tracking docs Adds a few lines explaining how global variables are propagated. --- docs/docs/protocol-specs/gas-and-fees/kernel-tracking.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/docs/protocol-specs/gas-and-fees/kernel-tracking.md b/docs/docs/protocol-specs/gas-and-fees/kernel-tracking.md index 58e4a359016..bbc5c980077 100644 --- a/docs/docs/protocol-specs/gas-and-fees/kernel-tracking.md +++ b/docs/docs/protocol-specs/gas-and-fees/kernel-tracking.md @@ -165,6 +165,7 @@ It must: - set the min_revertible_side_effect_counter if it is present in the `PrivateCallData` - set the `fee_payer` if the `is_fee_payer` flag is set in the `PrivateCircuitPublicInputs` - set the `public_teardown_function_hash` if it is present in the `PrivateCircuitPublicInputs` +- set the `combined_constant_data.global_variables` to zero, since these are not yet known during private execution ## Private Kernel Inner @@ -428,6 +429,8 @@ Further, we can trust that the `transaction_fee` the public VM reported is the o The PublicKernelSetup circuit takes in a `PublicKernelData` and a `PublicCallData` and outputs a `PublicKernelCircuitPublicInputs`. +It must set the `constant_data.global_variables` to the `global_variables` from `PublicCircuitPublicInputs`, as a means to initialize them, since they were zero in the previous kernel coming from private. + It must assert that the `revert_code` in the `PublicCircuitPublicInputs` is equal to zero. It must assert that the `public_call.call_stack_item.public_inputs.global_variables.gas_fees` are valid according to the [update rules defined](./published-gas-and-fee-data.md#updating-the-gasfees-object). @@ -541,6 +544,6 @@ The interplay between these two `revert_code`s is as follows: The base rollup kernel circuit takes in a `KernelData`, which contains a `KernelCircuitPublicInputs`, which it uses to compute the `transaction_fee`. -Additionally, it verifies that the max fees per gas specified by the user are greater than the current block's fees per gas. +Additionally, it verifies that the max fees per gas specified by the user are greater than the current block's fees per gas. It also verifies the `constant_data.global_variables.gas_fees` are correct. After the public data writes specific to this transaction have been processed, and a new tree root is produced, the kernel circuit injects an additional public data write based upon that root which deducts the transaction fee from the `fee_payer`'s balance. From ee0adaab65c429b8dedddc832fb29b58e57100d7 Mon Sep 17 00:00:00 2001 From: Santiago Palladino Date: Fri, 3 May 2024 15:55:02 -0300 Subject: [PATCH 2/2] Suggestion from @just-mitch --- docs/docs/protocol-specs/gas-and-fees/kernel-tracking.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/docs/protocol-specs/gas-and-fees/kernel-tracking.md b/docs/docs/protocol-specs/gas-and-fees/kernel-tracking.md index bbc5c980077..ea87c35a6b6 100644 --- a/docs/docs/protocol-specs/gas-and-fees/kernel-tracking.md +++ b/docs/docs/protocol-specs/gas-and-fees/kernel-tracking.md @@ -425,12 +425,12 @@ Therefore, once we verify that the `start_gas_left` which the sequencer provided Further, we can trust that the `transaction_fee` the public VM reported is the one which was made available to the public functions during teardown (though we must verify that the sequencer provided the correct value). +The `PublicCircuitPublicInputs` include the `global_variables` as injected via the `PublicContextInputs`. The first public kernel circuit to run, regardless of whether it is a setup, app, or teardown kernel, is responsible for setting its `constant_data.global_variables` equal to these. All subsequent public kernel circuit runs must verify that the `global_variables` from the `PublicCircuitPublicInputs` match the ones from the previously set `constant_data.global_variables`. + ## Public Kernel Setup The PublicKernelSetup circuit takes in a `PublicKernelData` and a `PublicCallData` and outputs a `PublicKernelCircuitPublicInputs`. -It must set the `constant_data.global_variables` to the `global_variables` from `PublicCircuitPublicInputs`, as a means to initialize them, since they were zero in the previous kernel coming from private. - It must assert that the `revert_code` in the `PublicCircuitPublicInputs` is equal to zero. It must assert that the `public_call.call_stack_item.public_inputs.global_variables.gas_fees` are valid according to the [update rules defined](./published-gas-and-fee-data.md#updating-the-gasfees-object).