diff --git a/spartan/environments/devnet.env b/spartan/environments/devnet.env index 07479bd312b9..a1a1020ea41c 100644 --- a/spartan/environments/devnet.env +++ b/spartan/environments/devnet.env @@ -54,7 +54,7 @@ VALIDATOR_MNEMONIC_START_INDEX=$((1 + MNEMONIC_INDEX_OFFSET)) VALIDATOR_INDICES=$(seq -s ',' $VALIDATOR_MNEMONIC_START_INDEX $((VALIDATOR_MNEMONIC_START_INDEX + TOTAL_VALIDATORS - 1))) VALIDATOR_PUBLISHER_MNEMONIC_START_INDEX=$((5000 + MNEMONIC_INDEX_OFFSET)) PUBLISHERS_PER_VALIDATOR_KEY=1 -SEQ_MIN_TX_PER_BLOCK=0 +SEQ_MIN_TX_PER_BLOCK=1 SEQ_MAX_TX_PER_BLOCK=32 PROVER_PUBLISHER_MNEMONIC_START_INDEX=$((8000 + MNEMONIC_INDEX_OFFSET)) diff --git a/spartan/environments/five-tps-long-epoch.env b/spartan/environments/five-tps-long-epoch.env index b5944eb481af..470d2c0c9478 100644 --- a/spartan/environments/five-tps-long-epoch.env +++ b/spartan/environments/five-tps-long-epoch.env @@ -56,7 +56,7 @@ AZTEC_SLASHING_OFFSET_IN_ROUNDS=1 AZTEC_LOCAL_EJECTION_THRESHOLD=90000000000000000000 SEQ_MAX_TX_PER_CHECKPOINT=180 -SEQ_MIN_TX_PER_BLOCK=0 +SEQ_MIN_TX_PER_BLOCK=1 # Override L1 tx utils bump percentages for scenario tests VALIDATOR_L1_PRIORITY_FEE_BUMP_PERCENTAGE=0 diff --git a/spartan/environments/five-tps-short-epoch.env b/spartan/environments/five-tps-short-epoch.env index 503f4d1b0856..36cdaa7a6cfd 100644 --- a/spartan/environments/five-tps-short-epoch.env +++ b/spartan/environments/five-tps-short-epoch.env @@ -56,7 +56,7 @@ AZTEC_SLASHING_OFFSET_IN_ROUNDS=1 AZTEC_LOCAL_EJECTION_THRESHOLD=90000000000000000000 SEQ_MAX_TX_PER_CHECKPOINT=180 -SEQ_MIN_TX_PER_BLOCK=0 +SEQ_MIN_TX_PER_BLOCK=1 # Override L1 tx utils bump percentages for scenario tests VALIDATOR_L1_PRIORITY_FEE_BUMP_PERCENTAGE=0 diff --git a/spartan/environments/network-defaults.yml b/spartan/environments/network-defaults.yml index 04202b0fbeec..ffaa61ab4f97 100644 --- a/spartan/environments/network-defaults.yml +++ b/spartan/environments/network-defaults.yml @@ -170,7 +170,7 @@ _prodlike: &prodlike # Sequencer Configuration #--------------------------------------------------------------------------- # Minimum transactions to include in a block. - SEQ_MIN_TX_PER_BLOCK: 0 + SEQ_MIN_TX_PER_BLOCK: 1 # Maximum transactions to include in a block # Build checkpoint even if block is empty. SEQ_BUILD_CHECKPOINT_IF_EMPTY: true diff --git a/spartan/environments/next-net.env b/spartan/environments/next-net.env index 214785578995..98a8c1941d4b 100644 --- a/spartan/environments/next-net.env +++ b/spartan/environments/next-net.env @@ -28,7 +28,7 @@ L1_TX_FAILED_STORE=gs://aztec-develop/next-net/failed-l1-txs TEST_ACCOUNTS=true SPONSORED_FPC=true -SEQ_MIN_TX_PER_BLOCK=0 +SEQ_MIN_TX_PER_BLOCK=1 SEQ_MAX_TX_PER_CHECKPOINT=7 diff --git a/spartan/environments/prove-n-tps-fake.env b/spartan/environments/prove-n-tps-fake.env index f181263e4b36..773a500db927 100644 --- a/spartan/environments/prove-n-tps-fake.env +++ b/spartan/environments/prove-n-tps-fake.env @@ -42,10 +42,10 @@ PROVER_TEST_DELAY_TYPE=realistic PROVER_TEST_VERIFICATION_DELAY_MS=250 SEQ_MAX_TX_PER_CHECKPOINT=80 -SEQ_MIN_TX_PER_BLOCK=0 SEQ_BLOCK_DURATION_MS=6000 SEQ_L1_PUBLISHING_TIME_ALLOWANCE_IN_SLOT=36 SEQ_BUILD_CHECKPOINT_IF_EMPTY=true +SEQ_MIN_TX_PER_BLOCK=1 P2P_MAX_TX_POOL_SIZE=1000000000 DEBUG_P2P_INSTRUMENT_MESSAGES=true diff --git a/spartan/environments/prove-n-tps-real.env b/spartan/environments/prove-n-tps-real.env index 95092d394ab7..57dcdbf6a057 100644 --- a/spartan/environments/prove-n-tps-real.env +++ b/spartan/environments/prove-n-tps-real.env @@ -39,7 +39,7 @@ PROVER_AGENT_POLL_INTERVAL_MS=10000 PUBLISHERS_PER_PROVER=1 SEQ_MAX_TX_PER_CHECKPOINT=72 -SEQ_MIN_TX_PER_BLOCK=0 +SEQ_MIN_TX_PER_BLOCK=1 SEQ_BLOCK_DURATION_MS=6000 SEQ_L1_PUBLISHING_TIME_ALLOWANCE_IN_SLOT=36 SEQ_BUILD_CHECKPOINT_IF_EMPTY=true diff --git a/spartan/environments/staging-public.env b/spartan/environments/staging-public.env index 9bbdd78887b6..fd3c5b52df47 100644 --- a/spartan/environments/staging-public.env +++ b/spartan/environments/staging-public.env @@ -25,7 +25,7 @@ R2_SECRET_ACCESS_KEY=REPLACE_WITH_GCP_SECRET TEST_ACCOUNTS=false SPONSORED_FPC=true -SEQ_MIN_TX_PER_BLOCK=0 +SEQ_MIN_TX_PER_BLOCK=1 SEQ_MAX_TX_PER_CHECKPOINT=7 # 0.1 TPS # Build checkpoint even if block is empty. diff --git a/spartan/environments/ten-tps-long-epoch.env b/spartan/environments/ten-tps-long-epoch.env index 372883eb8e71..c2e9526e3812 100644 --- a/spartan/environments/ten-tps-long-epoch.env +++ b/spartan/environments/ten-tps-long-epoch.env @@ -57,7 +57,7 @@ AZTEC_SLASHING_OFFSET_IN_ROUNDS=1 AZTEC_LOCAL_EJECTION_THRESHOLD=90000000000000000000 SEQ_MAX_TX_PER_CHECKPOINT=360 -SEQ_MIN_TX_PER_BLOCK=0 +SEQ_MIN_TX_PER_BLOCK=1 # Override L1 tx utils bump percentages for scenario tests VALIDATOR_L1_PRIORITY_FEE_BUMP_PERCENTAGE=0 diff --git a/spartan/environments/ten-tps-short-epoch.env b/spartan/environments/ten-tps-short-epoch.env index 2607cc8ddcc2..8b2cae135c58 100644 --- a/spartan/environments/ten-tps-short-epoch.env +++ b/spartan/environments/ten-tps-short-epoch.env @@ -57,7 +57,7 @@ AZTEC_SLASHING_OFFSET_IN_ROUNDS=1 AZTEC_LOCAL_EJECTION_THRESHOLD=90000000000000000000 SEQ_MAX_TX_PER_CHECKPOINT=360 -SEQ_MIN_TX_PER_BLOCK=0 +SEQ_MIN_TX_PER_BLOCK=1 # Override L1 tx utils bump percentages for scenario tests VALIDATOR_L1_PRIORITY_FEE_BUMP_PERCENTAGE=0 diff --git a/spartan/environments/tps-scenario.env b/spartan/environments/tps-scenario.env index 8996a5670dff..2708bc78ce82 100644 --- a/spartan/environments/tps-scenario.env +++ b/spartan/environments/tps-scenario.env @@ -69,7 +69,7 @@ AZTEC_SLASHING_OFFSET_IN_ROUNDS=1 AZTEC_LOCAL_EJECTION_THRESHOLD=90000000000000000000 SEQ_MAX_TX_PER_CHECKPOINT=15 # approx 0.2 TPS -SEQ_MIN_TX_PER_BLOCK=0 +SEQ_MIN_TX_PER_BLOCK=1 # Override L1 tx utils bump percentages for scenario tests VALIDATOR_L1_PRIORITY_FEE_BUMP_PERCENTAGE=0 diff --git a/spartan/scripts/deploy_network.sh b/spartan/scripts/deploy_network.sh index 974a7739011b..5524f8040573 100755 --- a/spartan/scripts/deploy_network.sh +++ b/spartan/scripts/deploy_network.sh @@ -104,9 +104,10 @@ else fi PROVER_FAILED_PROOF_STORE=${PROVER_FAILED_PROOF_STORE:-} -SEQ_MIN_TX_PER_BLOCK=${SEQ_MIN_TX_PER_BLOCK:-0} +SEQ_MIN_TX_PER_BLOCK=${SEQ_MIN_TX_PER_BLOCK:-1} SEQ_MAX_TX_PER_BLOCK=${SEQ_MAX_TX_PER_BLOCK:-null} SEQ_MAX_TX_PER_CHECKPOINT=${SEQ_MAX_TX_PER_CHECKPOINT:-8} +SEQ_PER_BLOCK_ALLOCATION_MULTIPLIER=${SEQ_PER_BLOCK_ALLOCATION_MULTIPLIER:-2} SEQ_BLOCK_DURATION_MS=${SEQ_BLOCK_DURATION_MS:-} SEQ_L1_PUBLISHING_TIME_ALLOWANCE_IN_SLOT=${SEQ_L1_PUBLISHING_TIME_ALLOWANCE_IN_SLOT:-} SEQ_BUILD_CHECKPOINT_IF_EMPTY=${SEQ_BUILD_CHECKPOINT_IF_EMPTY:-} @@ -520,6 +521,7 @@ VALIDATOR_HA_REPLICAS = ${VALIDATOR_HA_REPLICAS} SEQ_MIN_TX_PER_BLOCK = ${SEQ_MIN_TX_PER_BLOCK} SEQ_MAX_TX_PER_BLOCK = ${SEQ_MAX_TX_PER_BLOCK} SEQ_MAX_TX_PER_CHECKPOINT = ${SEQ_MAX_TX_PER_CHECKPOINT} +SEQ_PER_BLOCK_ALLOCATION_MULTIPLIER = ${SEQ_PER_BLOCK_ALLOCATION_MULTIPLIER} SEQ_BLOCK_DURATION_MS = ${SEQ_BLOCK_DURATION_MS:-null} SEQ_L1_PUBLISHING_TIME_ALLOWANCE_IN_SLOT = ${SEQ_L1_PUBLISHING_TIME_ALLOWANCE_IN_SLOT:-null} SEQ_BUILD_CHECKPOINT_IF_EMPTY = ${SEQ_BUILD_CHECKPOINT_IF_EMPTY:-null} diff --git a/spartan/terraform/deploy-aztec-infra/main.tf b/spartan/terraform/deploy-aztec-infra/main.tf index 9b06ef870bed..ef06a6a7245c 100644 --- a/spartan/terraform/deploy-aztec-infra/main.tf +++ b/spartan/terraform/deploy-aztec-infra/main.tf @@ -213,6 +213,7 @@ locals { "validator.node.env.SEQ_MIN_TX_PER_BLOCK" = var.SEQ_MIN_TX_PER_BLOCK "validator.node.env.SEQ_MAX_TX_PER_BLOCK" = var.SEQ_MAX_TX_PER_BLOCK "validator.node.env.SEQ_MAX_TX_PER_CHECKPOINT" = var.SEQ_MAX_TX_PER_CHECKPOINT + "validator.node.env.SEQ_PER_BLOCK_ALLOCATION_MULTIPLIER" = var.SEQ_PER_BLOCK_ALLOCATION_MULTIPLIER "validator.node.env.SEQ_BLOCK_DURATION_MS" = var.SEQ_BLOCK_DURATION_MS "validator.node.env.SEQ_L1_PUBLISHING_TIME_ALLOWANCE_IN_SLOT" = var.SEQ_L1_PUBLISHING_TIME_ALLOWANCE_IN_SLOT "validator.node.env.SEQ_BUILD_CHECKPOINT_IF_EMPTY" = var.SEQ_BUILD_CHECKPOINT_IF_EMPTY diff --git a/spartan/terraform/deploy-aztec-infra/variables.tf b/spartan/terraform/deploy-aztec-infra/variables.tf index ecf14df0976b..274704d12356 100644 --- a/spartan/terraform/deploy-aztec-infra/variables.tf +++ b/spartan/terraform/deploy-aztec-infra/variables.tf @@ -334,7 +334,7 @@ variable "TEST_ACCOUNTS" { variable "SEQ_MIN_TX_PER_BLOCK" { description = "Minimum number of sequencer transactions per block" type = string - default = "0" + default = "1" } variable "SEQ_MAX_TX_PER_BLOCK" { @@ -383,6 +383,12 @@ variable "SEQ_BUILD_CHECKPOINT_IF_EMPTY" { default = null } +variable "SEQ_PER_BLOCK_ALLOCATION_MULTIPLIER" { + description = "Per-block gas budget multiplier for both L2 and DA gas." + type = string + default = null +} + variable "SENTINEL_ENABLED" { description = "Whether to enable sentinel" type = string @@ -765,7 +771,7 @@ variable "FISHERMAN_MODE" { variable "P2P_GOSSIPSUB_D" { description = "The P2P Gossipsub D parameter" type = string - default = "6" + default = "8" } variable "P2P_GOSSIPSUB_DLO" { diff --git a/yarn-project/end-to-end/src/spartan/n_tps.test.ts b/yarn-project/end-to-end/src/spartan/n_tps.test.ts index 27aeba4b54d6..e9dd610fe610 100644 --- a/yarn-project/end-to-end/src/spartan/n_tps.test.ts +++ b/yarn-project/end-to-end/src/spartan/n_tps.test.ts @@ -10,7 +10,7 @@ import { RunningPromise } from '@aztec/foundation/promise'; import { retryUntil } from '@aztec/foundation/retry'; import { sleep } from '@aztec/foundation/sleep'; import { BenchmarkingContract } from '@aztec/noir-test-contracts.js/Benchmarking'; -import { GasFees } from '@aztec/stdlib/gas'; +import { type Gas, GasFees } from '@aztec/stdlib/gas'; import { TopicType } from '@aztec/stdlib/p2p'; import { Tx, TxHash } from '@aztec/stdlib/tx'; @@ -293,7 +293,7 @@ describe('sustained N TPS test', () => { // this function creates n + 1 accounts. We only want one for each wallet const localTestAccounts = await Promise.all( - testWallets.map(lw => deploySponsoredTestAccounts(lw.wallet, aztecNode, logger, 0)), + testWallets.map(lw => deploySponsoredTestAccounts(lw.wallet, aztecNode, logger, 0, { estimateGas: true })), ); lowValueWallets = localTestAccounts.slice(0, lowValueAccounts).map(({ wallet }) => wallet); @@ -306,23 +306,44 @@ describe('sustained N TPS test', () => { logger.info('Deploying benchmark contract...'); const sponsor = new SponsoredFeePaymentMethod(await getSponsoredFPCAddress()); - ({ contract: benchmarkContract } = await BenchmarkingContract.deploy(localTestAccounts[0].wallet).send({ + const deployInteraction = BenchmarkingContract.deploy(localTestAccounts[0].wallet); + const deploySim = await deployInteraction.simulate({ from: localTestAccounts[0].recipientAddress, fee: { paymentMethod: sponsor }, + }); + logger.info('Benchmark contract deploy estimated gas', { gasLimits: deploySim.estimatedGas?.gasLimits }); + ({ contract: benchmarkContract } = await deployInteraction.send({ + from: localTestAccounts[0].recipientAddress, + fee: { paymentMethod: sponsor, gasSettings: deploySim.estimatedGas }, })); logger.info('Benchmark contract deployed', { address: benchmarkContract.address.toString() }); logger.info(`Test setup complete`); }); + let benchmarkGasEstimate: { gasLimits: Gas; teardownGasLimits: Gas } | undefined; + const submitProven = async ( wallet: TestWallet, maxPriorityFeesPerGas: GasFees = GasFees.empty(), ): Promise => { const sponsor = new SponsoredFeePaymentMethod(await getSponsoredFPCAddress()); + + if (!benchmarkGasEstimate) { + const sim = await benchmarkContract.methods.sha256_hash_1024(Array(1024).fill(42)).simulate({ + from: (await benchmarkContract.wallet.getAccounts())[0].item, + fee: { paymentMethod: sponsor, estimateGas: true }, + }); + benchmarkGasEstimate = sim.estimatedGas; + logger.info('Benchmark tx estimated gas', { gasLimits: benchmarkGasEstimate?.gasLimits }); + } + const tx = await proveInteraction(wallet, benchmarkContract.methods.sha256_hash_1024(Array(1024).fill(42)), { from: (await wallet.getAccounts())[0].item, - fee: { paymentMethod: sponsor, gasSettings: { maxPriorityFeesPerGas } }, + fee: { + paymentMethod: sponsor, + gasSettings: { maxPriorityFeesPerGas, ...benchmarkGasEstimate }, + }, }); return tx; diff --git a/yarn-project/end-to-end/src/spartan/setup_test_wallets.ts b/yarn-project/end-to-end/src/spartan/setup_test_wallets.ts index 0f0a63458835..d2a0908c62a8 100644 --- a/yarn-project/end-to-end/src/spartan/setup_test_wallets.ts +++ b/yarn-project/end-to-end/src/spartan/setup_test_wallets.ts @@ -121,16 +121,27 @@ export async function deploySponsoredTestAccountsWithTokens( } async function deployAccountWithDiagnostics( - account: { getDeployMethod: () => Promise<{ send: (opts: any) => any }>; address: any }, + account: { getDeployMethod: () => Promise<{ simulate: (opts: any) => any; send: (opts: any) => any }>; address: any }, paymentMethod: SponsoredFeePaymentMethod, aztecNode: AztecNode, logger: Logger, accountLabel: string, + estimateGas?: boolean, ): Promise { const deployMethod = await account.getDeployMethod(); let txHash; try { - const deployResult = await deployMethod.send({ from: AztecAddress.ZERO, fee: { paymentMethod }, wait: NO_WAIT }); + let gasSettings; + if (estimateGas) { + const sim = await deployMethod.simulate({ from: AztecAddress.ZERO, fee: { paymentMethod } }); + gasSettings = sim.estimatedGas; + logger.info(`${accountLabel} estimated gas: DA=${gasSettings.gasLimits.daGas} L2=${gasSettings.gasLimits.l2Gas}`); + } + const deployResult = await deployMethod.send({ + from: AztecAddress.ZERO, + fee: { paymentMethod, gasSettings }, + wait: NO_WAIT, + }); txHash = deployResult.txHash; await waitForTx(aztecNode, txHash, { timeout: 2400 }); logger.info(`${accountLabel} deployed at ${account.address}`); @@ -153,18 +164,29 @@ async function deployAccountWithDiagnostics( } async function deployAccountsInBatches( - accounts: { getDeployMethod: () => Promise<{ send: (opts: any) => any }>; address: any }[], + accounts: { + getDeployMethod: () => Promise<{ simulate: (opts: any) => any; send: (opts: any) => any }>; + address: any; + }[], paymentMethod: SponsoredFeePaymentMethod, aztecNode: AztecNode, logger: Logger, labelPrefix: string, batchSize = 2, + estimateGas?: boolean, ): Promise { for (let i = 0; i < accounts.length; i += batchSize) { const batch = accounts.slice(i, i + batchSize); await Promise.all( batch.map((account, idx) => - deployAccountWithDiagnostics(account, paymentMethod, aztecNode, logger, `${labelPrefix}${i + idx + 1}`), + deployAccountWithDiagnostics( + account, + paymentMethod, + aztecNode, + logger, + `${labelPrefix}${i + idx + 1}`, + estimateGas, + ), ), ); } @@ -175,6 +197,7 @@ export async function deploySponsoredTestAccounts( aztecNode: AztecNode, logger: Logger, numberOfFundedWallets = 1, + opts?: { estimateGas?: boolean }, ): Promise { const [recipient, ...funded] = await generateSchnorrAccounts(numberOfFundedWallets + 1); const recipientAccount = await wallet.createSchnorrAccount(recipient.secret, recipient.salt); @@ -184,8 +207,23 @@ export async function deploySponsoredTestAccounts( const paymentMethod = new SponsoredFeePaymentMethod(await getSponsoredFPCAddress()); - await deployAccountWithDiagnostics(recipientAccount, paymentMethod, aztecNode, logger, 'Recipient account'); - await deployAccountsInBatches(fundedAccounts, paymentMethod, aztecNode, logger, 'Funded account ', 2); + await deployAccountWithDiagnostics( + recipientAccount, + paymentMethod, + aztecNode, + logger, + 'Recipient account', + opts?.estimateGas, + ); + await deployAccountsInBatches( + fundedAccounts, + paymentMethod, + aztecNode, + logger, + 'Funded account ', + 2, + opts?.estimateGas, + ); return { aztecNode,