File tree Expand file tree Collapse file tree
yarn-project/simulator/src/public/public_tx_simulator Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -247,8 +247,12 @@ export class PublicTxContext {
247247 }
248248
249249 /**
250- * The gasUsed by public and private,
251- * as if the entire teardown gas limit was consumed.
250+ * The gasUsed by public and private, as if the entire teardown gas limit was consumed.
251+ *
252+ * This is intentional: teardown is used for gas accounting and refunds, so the transaction
253+ * fee must be deterministic _before_ teardown executes. If fees depended on teardown's actual
254+ * consumption there would be a circular dependency. Billing the full teardown gas limit
255+ * (set by the user) makes the fee known in advance and available to the teardown function.
252256 */
253257 getTotalGasUsed ( ) : Gas {
254258 return this . gasUsedByPrivate . add ( this . gasUsedByPublic ) ;
You can’t perform that action at this time.
0 commit comments