Skip to content

Commit f50abe3

Browse files
committed
fix(pxe): restore fee-payer public data write DA charge in kernelless gas metering
Block #24580's mechanical re-graft (99cbb5d) pulled contract_function_simulator.ts from the v5 tip, which predates next's 5ca883c (add fixed gas cost for updating fee payer balance to private-only tx). The Noir private-kernel gas meter (gas_meter.nr) charges PUBLIC_DATA_WRITE_LENGTH DA fields for the fee-payer balance write on private-only txs, so kernelless estimates under-counted DA gas by 64 on every private-only tx (kernelless_simulation 128 vs 192 squashing case, 768 vs 832 account deployments; same drift behind the bot/amm/sponsored "gas used exceeds the gas limits" failures for private-only txs). Restore the isPrivateOnlyTx block in meterGasUsed to match next and the kernels. Complements d526c2d (protocol nullifier injection), which fixed the other half of the kernelless DA drift. Verified locally: kernelless_simulation 7/7 (was 4/7), private_payments.parallel 8/8, txe unit tests 17/17.
1 parent d526c2d commit f50abe3

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

yarn-project/pxe/src/contract_function_simulator/contract_function_simulator.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
MAX_PRIVATE_LOGS_PER_TX,
2121
MAX_TX_LIFETIME,
2222
PRIVATE_TX_L2_GAS_OVERHEAD,
23+
PUBLIC_DATA_WRITE_LENGTH,
2324
PUBLIC_TX_L2_GAS_OVERHEAD,
2425
TX_DA_GAS_OVERHEAD,
2526
} from '@aztec/constants';
@@ -924,6 +925,11 @@ function meterGasUsed(data: PrivateToRollupAccumulatedData | PrivateToPublicAccu
924925
);
925926
meteredL2Gas += numContractClassLogs * L2_GAS_PER_CONTRACT_CLASS_LOG;
926927

928+
if (isPrivateOnlyTx) {
929+
// The public data write that the private tx base rollup always performs to update the fee payer's balance.
930+
meteredDAFields += PUBLIC_DATA_WRITE_LENGTH;
931+
}
932+
927933
const meteredDAGas = meteredDAFields * DA_GAS_PER_FIELD;
928934

929935
if ((data as PrivateToPublicAccumulatedData).publicCallRequests) {

0 commit comments

Comments
 (0)