fix(aztec.js): honor fee payment method in BatchCall.simulate#24801
Open
Thunkar wants to merge 1 commit into
Open
Conversation
BatchCall.simulate() silently discarded options.fee.paymentMethod and
dropped the merged payload's feePayer, so batches simulated with a
sponsored/deferred fee method ran with the wallet's fallback handling
(PREEXISTING_FEE_JUICE) instead of the caller's method.
Merge the payment method's execution payload ahead of the batch (as
request() already does) and preserve combinedPayload.feePayer when
rebuilding the ExecutionPayload. Since the wallet's app-call offset only
counts the wallet's own fee payment method, offset each batched call's
private/public return-value index by the fee payload's own call counts of
each type; otherwise a call-contributing fee method (e.g.
SponsoredFeePaymentMethod) shifts the indices and the fee call's return
values decode as the first app call's.
Apply the same index offset to ContractFunctionInteraction.simulate(),
which had the same latent off-by-one under a call-contributing fee method.
Revert the phase_check late-election e2e test to the plain
batch.simulate({ from, fee }) form now that the option is honored.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
BatchCall.simulate()silently discardedoptions.fee.paymentMethodand dropped the merged payload'sfeePayer, so batches simulated with a sponsored/deferred fee method ran with the wallet's fallback handling (PREEXISTING_FEE_JUICE) instead of the caller's method. The wallet's account entrypoint then self-elected as fee payer and ended setup up front — a different phase structure than the caller asked for.Resolves F-785. Surfaced while landing #24479.
Changes
batch_call.ts: fetchoptions.fee.paymentMethod.getExecutionPayload(), merge it ahead of the batch (mirroringrequest()), and preservecombinedPayload.feePayerwhen rebuilding theExecutionPayload.options.fee. So each batched call's private/public return-value index is offset by the fee payload's own call counts of each type; otherwise a call-contributing method (e.g.SponsoredFeePaymentMethod) shifts the indices and the fee call's return values decode as the first app call's.contract_function_interaction.ts: fixed the same latent off-by-one under a call-contributing fee method. The single app call is the last of its type in the payload, so its index is derived from the merged payload (avoiding a secondgetExecutionPayload()call).phase_check.parallel.test.ts: reverted the feat: assert non revertible phase when setting fee payer #24479 workaround back to the plainbatch.simulate({ from, fee })form now that the option is honored.Testing
batch_callunit tests: return-value index offset (asserting on actual decoded values, not just absence of errors),feePayerfrom the payment method, andfeePayercarried by a batched payload. Verified red/green — the offset test fails without the fix.phase_checke2e tests pass, including the reverted late-election test.fee.paymentMethod(offsets are 0).