diff --git a/yarn-project/aztec.js/src/fee/fee_juice_payment_method_with_claim.ts b/yarn-project/aztec.js/src/fee/fee_juice_payment_method_with_claim.ts index 8d88c54999df..565825c66ef2 100644 --- a/yarn-project/aztec.js/src/fee/fee_juice_payment_method_with_claim.ts +++ b/yarn-project/aztec.js/src/fee/fee_juice_payment_method_with_claim.ts @@ -1,6 +1,6 @@ import { type FunctionCall } from '@aztec/circuit-types'; import { type AztecAddress, Fr, FunctionSelector } from '@aztec/circuits.js'; -import { FunctionType } from '@aztec/foundation/abi'; +import { FunctionType, U128 } from '@aztec/foundation/abi'; import { ProtocolContractAddress } from '@aztec/protocol-contracts'; import { getCanonicalFeeJuice } from '@aztec/protocol-contracts/fee-juice'; @@ -35,7 +35,7 @@ export class FeeJuicePaymentMethodWithClaim extends FeeJuicePaymentMethod { isStatic: false, args: [ this.sender.toField(), - new Fr(this.claim.claimAmount), + ...new U128(this.claim.claimAmount).toFields(), this.claim.claimSecret, new Fr(this.claim.messageLeafIndex), ], diff --git a/yarn-project/sequencer-client/src/tx_validator/gas_validator.ts b/yarn-project/sequencer-client/src/tx_validator/gas_validator.ts index d02f4c0638f3..a7dcfa4c5e37 100644 --- a/yarn-project/sequencer-client/src/tx_validator/gas_validator.ts +++ b/yarn-project/sequencer-client/src/tx_validator/gas_validator.ts @@ -1,5 +1,6 @@ import { type Tx, TxExecutionPhase, type TxValidationResult, type TxValidator } from '@aztec/circuit-types'; -import { type AztecAddress, type Fr, FunctionSelector, type GasFees } from '@aztec/circuits.js'; +import { type AztecAddress, Fr, FunctionSelector, type GasFees } from '@aztec/circuits.js'; +import { U128 } from '@aztec/foundation/abi'; import { createLogger } from '@aztec/foundation/log'; import { computeFeePayerBalanceStorageSlot, getExecutionRequestsByPhase } from '@aztec/simulator/server'; @@ -65,10 +66,26 @@ export class GasTxValidator implements TxValidator { const feeLimit = tx.data.constants.txContext.gasSettings.getFeeLimit(); // Read current balance of the feePayer - const initialBalance = await this.#publicDataSource.storageRead( + // TODO(#11285): Remove the 2 reads below with the commented out code. + // Uncomment below ###################### + // const initialBalance = await this.#publicDataSource.storageRead( + // this.#feeJuiceAddress, + // computeFeePayerBalanceStorageSlot(feePayer), + // ); + // Uncomment above ###################### + // Remove the following ###################### + const initialBalanceLowLimb = await this.#publicDataSource.storageRead( this.#feeJuiceAddress, computeFeePayerBalanceStorageSlot(feePayer), ); + const initialBalanceHighLimb = await this.#publicDataSource.storageRead( + this.#feeJuiceAddress, + new Fr(computeFeePayerBalanceStorageSlot(feePayer).toBigInt() + 1n), + ); + const initialBalance = new Fr( + U128.fromU64sLE(initialBalanceLowLimb.toBigInt(), initialBalanceHighLimb.toBigInt()).toInteger(), + ); + // Remove the above ###################### // If there is a claim in this tx that increases the fee payer balance in Fee Juice, add it to balance const setupFns = getExecutionRequestsByPhase(tx, TxExecutionPhase.SETUP); @@ -85,7 +102,9 @@ export class GasTxValidator implements TxValidator { !fn.callContext.isStaticCall, ); - const balance = claimFunctionCall ? initialBalance.add(claimFunctionCall.args[2]) : initialBalance; + const balance = claimFunctionCall + ? initialBalance.add(new Fr(U128.fromFields(claimFunctionCall.args.slice(2, 4)).toInteger())) + : initialBalance; if (balance.lt(feeLimit)) { this.#log.warn(`Rejecting transaction due to not enough fee payer balance`, { feePayer, diff --git a/yarn-project/simulator/src/client/client_execution_context.ts b/yarn-project/simulator/src/client/client_execution_context.ts index 342fe8fdc651..0aec42dd945b 100644 --- a/yarn-project/simulator/src/client/client_execution_context.ts +++ b/yarn-project/simulator/src/client/client_execution_context.ts @@ -95,7 +95,7 @@ export class ClientExecutionContext extends ViewDataOracle { const args = this.executionCache.getPreimage(this.argsHash); if (args.length !== argumentsSize) { - throw new Error('Invalid arguments size'); + throw new Error(`Invalid arguments size: expected ${argumentsSize}, got ${args.length}`); } const privateContextInputs = new PrivateContextInputs(