Skip to content

Commit 4861a24

Browse files
spalladinoclaude
andauthored
docs(simulator): clarify teardown gas billing is intentional (#22057)
Fixes A-820 Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent e505b7d commit 4861a24

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

yarn-project/simulator/src/public/public_tx_simulator/public_tx_context.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff 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);

0 commit comments

Comments
 (0)