perf(e2e): overlap and batch setup txs in e2e harnesses#24569
Open
spalladino wants to merge 3 commits into
Open
perf(e2e): overlap and batch setup txs in e2e harnesses#24569spalladino wants to merge 3 commits into
spalladino wants to merge 3 commits into
Conversation
The BananaFPC deploy, SponsoredFPC registration, and Alice's banana mints each depend only on the BananaCoin deployed during FeesTest.setup, so the fees suites now run them concurrently instead of paying one production slot per step. Likewise the cross-chain harness deploys the L2 token and its bridge concurrently: the bridge takes the token address as a constructor arg, but that address is deterministic before the deploy tx mines, and the bridge constructor does not call into the token.
applyFundAliceWithBananas sent Alice's private and public banana mints back-to-back, paying one production slot each. The two mints touch disjoint balances, so they are now sent concurrently and share a slot. Each mint keeps its own tx:mint span, so the overlap shows up as busyMs < totalMs in the timing data.
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.
Stacked on #24564; retarget to
merge-train/spartan-v5after it merges. (Unifies former #24584 into this PR — the two touched the same mint path infees_test.ts, so they now land together.)Restructures the serial setup-tx chains in the fees and cross-chain e2e harnesses so independent setup transactions stop paying one production slot each: independent txs run concurrently, and same-sender calls are batched into a single tx (one proof, one tx, one slot). Part of the round-4/5 e2e speedup effort.
Commits
FeesTest.setupdeploys BananaCoin, the BananaFPC deploy, the SponsoredFPC registration (a PXE registration, no L2 tx), and Alice's banana mints each depend only on the token, so the fees suites (account_init,gas_estimation,private_payments) now run them under aPromise.all. The cross-chain harness (deployAndInitializeTokenAndBridgeContracts) deploys the L2 token and its bridge concurrently: the bridge takes the token address as a constructor arg, but that address is deterministic before the deploy tx mines (the deploy is now constructed with an explicitdeployer, same address derivation as the previous send-time lock), and the bridge constructor only stores it without calling into the token.applyFundAliceWithBananassent Alice's private and public banana mints back-to-back (measured 100% serial:tx:mintbusyMs == totalMs on the base). The first commit made them concurrent; the second replaces the concurrency with a singleBatchCall([mint_to_private, mint_to_public])tx, because measurement showed concurrent same-sender txs still pay consecutive slots: the PXE serializessimulateTx/proveTxon a single queue, so the second tx is only proven after the first and misses the first's slot. Overlapping cannot remove whole slots — only batching can. Both mints are Alice sends onBananaCointouching disjoint balances; the private-balance before/after assertion is preserved, and the public mint's effect is checked by the downstream tests that spend Alice's public bananas. Precedent for the pattern already lives in this tree (mintNotesinfixtures/token_utils.ts).Dependency analysis
Promise.all.{token, portal}in its own storage and never calls the token, so the bridge deploy does not need the token to be mined first.BANANA_COIN_SALT/BANANA_FPC_SALT+deployer: aliceare untouched, and the genesis-funded-address assertion inapplyFPCSetupstill runs (and passed locally).Same-sender concurrency
Concurrent
.send()calls from the same sender through the same TestWallet are safe: the PXE serializessimulateTx/proveTxthrough aSerialQueue(#putInJobQueue), so simulations never interleave and only the block-inclusion waits overlap. The setup txs pay fees from Alice's public fee-juice balance (PREEXISTING_FEE_JUICE) with random tx nonces, so there are no nullifier or note conflicts between the concurrent txs. Verified locally with fullPromise.allof the send+wait calls; no NO_WAIT fallback or cross-sender split was needed.Surveyed and skipped
DeployMethod.request()already merges class publication, instance publication, and the constructor call into a single execution payload sent as one tx. Measured locally,deploy:tokenis a single ~12s (1 slot) occurrence; the ~24s occurrences in CI span data are inclusion latency at CI cadence, not a second tx.applyFPCSetup: a singledeploy:fpctx — no same-sender pair inside the phase. Folding the FPC deploy into the mint batch (one class publication + app calls is within the class-log limit) would remove the remaining consecutive slot, but it merges two harness phases that four test files compose differently viaPromise.all, and deploy-inside-BatchCall is not a proven pattern here — a restructure, not a mechanical merge. Left as a possible follow-up.applySponsoredFPCSetup: no on-chain tx — it only callswallet.registerContractlocally; the sponsored FPC is genesis-funded and its class preloaded. Nothing to batch.MAX_CONTRACT_CLASS_LOGS_PER_TX = 1), which rules out any two-deploy batch (e.g. cross-chain token+bridge) — those stay concurrent rather than batched.Local verification (12s slots; CI runs at its own cadence)
Overlap commits (fees + cross-chain):
account_init, spans on): 5/5 passed; beforeAll 83.5s =setup:auth-registry32.0s +deploy:token12.0s +tx:mint23.9s (busyMs == totalMs, fully serial) +deploy:fpc11.8s.deploy:fpcfully overlapped with the mint window.gas_estimation: 3/3 passed;private_payments: 8/8 passed;token_bridge(cross-chain overlap): 7/7 passed —deploy:token12.1s anddeploy:bridge23.7s ran concurrently (union ≈ 23.7s vs ~48s serial on the CI baseline);l2_to_l1: 6/6 passed (regression check on the untouched path).Batch commit (
account_init, 5/5 green on all runs):The mint phase drops from two consecutive slots (~23.6s) to one (~11.8s), one proof and one tx fewer per shard. No intermittent failures across any run.
Measured impact
Measured on CI in two steps (each commit group had its own PR run before unification).
Overlap (PR run 1783394912998666 vs #24564's run 1783375878950264): −162s summed across shards. Per-suite beforeHooks: private_payments.parallel −16.0s (×8), gas_estimation.parallel −15.5s (×3), token_bridge −12.0s, fee_juice_payments −12.0s, account_init −11.5s. The overlap is real but partial:
tx:mintbusyMs/totalMs = 0.68 run-wide — concurrent txs land in consecutive slots because the PXE serializes proving (the finding that motivated the batch commit). Cross-chaintoken_bridgecollapses its deploy phase from serial 35.9s to concurrent ~23.4s (union ≈ max, as designed).Batch (PR run 1783432285938536 vs 1783394912998666):
tx:mint42 → 29 occurrences (one merged per fees shard); busyMs 523s → 431s (−92s of tx/proving work; busyMs == totalMs in the PR run — no overlapping mint txs left to union). Wall-clock lands where the mint is the setup critical path:failures−12.0s,fee_juice_payments−11.5s (≈ one 12s slot each). Suites where the mint overlapsapplyFPCSetupare flat (account_init−0.4s,private_payments.parallel+2s,gas_estimation.parallel+3s):deploy:fpcis unchanged (13 occurrences, ~2 slots each) and remains their critical path, so removing a slot from the mint branch of thePromise.alldoesn't move the union. Run-wide sum over common suites: −8s; noise envelope on untouched suites ±20–37s.Net vs #24564's baseline: roughly −185s summed across shards, plus 13 fewer txs/proofs per run (less proving contention through the sequencer). The remaining ~12s/shard lever on the overlapped fees suites is folding the FPC deploy into the same batch, noted above as a follow-up.
Fixes A-1406
Fixes A-1409