@aztec/stdlib 0.0.1-commit.3895657bc → 0.0.1-commit.3e3d0c9cd

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/dest/block/l2_block_source.d.ts +9 -8
  2. package/dest/block/l2_block_source.d.ts.map +1 -1
  3. package/dest/epoch-helpers/index.d.ts +5 -1
  4. package/dest/epoch-helpers/index.d.ts.map +1 -1
  5. package/dest/epoch-helpers/index.js +4 -2
  6. package/dest/interfaces/archiver.js +2 -2
  7. package/dest/interfaces/aztec-node-admin.d.ts +10 -1
  8. package/dest/interfaces/aztec-node-admin.d.ts.map +1 -1
  9. package/dest/interfaces/aztec-node.d.ts +3 -2
  10. package/dest/interfaces/aztec-node.d.ts.map +1 -1
  11. package/dest/interfaces/aztec-node.js +2 -0
  12. package/dest/interfaces/block-builder.d.ts +11 -9
  13. package/dest/interfaces/block-builder.d.ts.map +1 -1
  14. package/dest/interfaces/block-builder.js +10 -5
  15. package/dest/interfaces/configs.d.ts +12 -2
  16. package/dest/interfaces/configs.d.ts.map +1 -1
  17. package/dest/interfaces/configs.js +2 -0
  18. package/dest/interfaces/l2_logs_source.d.ts +5 -3
  19. package/dest/interfaces/l2_logs_source.d.ts.map +1 -1
  20. package/dest/interfaces/merkle_tree_operations.d.ts +9 -19
  21. package/dest/interfaces/merkle_tree_operations.d.ts.map +1 -1
  22. package/dest/interfaces/prover-client.d.ts +6 -1
  23. package/dest/interfaces/prover-client.d.ts.map +1 -1
  24. package/dest/interfaces/prover-client.js +7 -1
  25. package/dest/interfaces/world_state.d.ts +5 -4
  26. package/dest/interfaces/world_state.d.ts.map +1 -1
  27. package/dest/logs/index.d.ts +2 -1
  28. package/dest/logs/index.d.ts.map +1 -1
  29. package/dest/logs/index.js +1 -0
  30. package/dest/logs/log_filter.d.ts +4 -1
  31. package/dest/logs/log_filter.d.ts.map +1 -1
  32. package/dest/logs/log_filter.js +2 -1
  33. package/dest/logs/tagging_index_range.d.ts +40 -0
  34. package/dest/logs/tagging_index_range.d.ts.map +1 -0
  35. package/dest/logs/tagging_index_range.js +8 -0
  36. package/dest/messaging/l1_to_l2_message_source.d.ts +4 -2
  37. package/dest/messaging/l1_to_l2_message_source.d.ts.map +1 -1
  38. package/dest/messaging/l2_to_l1_membership.d.ts +32 -6
  39. package/dest/messaging/l2_to_l1_membership.d.ts.map +1 -1
  40. package/dest/messaging/l2_to_l1_membership.js +69 -26
  41. package/dest/tx/private_execution_result.d.ts +6 -6
  42. package/dest/tx/private_execution_result.d.ts.map +1 -1
  43. package/dest/tx/private_execution_result.js +6 -6
  44. package/dest/tx/profiling.d.ts +14 -2
  45. package/dest/tx/profiling.d.ts.map +1 -1
  46. package/dest/tx/profiling.js +13 -3
  47. package/dest/tx/tx_receipt.d.ts +7 -2
  48. package/dest/tx/tx_receipt.d.ts.map +1 -1
  49. package/dest/tx/tx_receipt.js +6 -3
  50. package/dest/update-checker/package_version.d.ts +2 -2
  51. package/dest/update-checker/package_version.d.ts.map +1 -1
  52. package/dest/update-checker/package_version.js +16 -3
  53. package/dest/validators/errors.d.ts +6 -1
  54. package/dest/validators/errors.d.ts.map +1 -1
  55. package/dest/validators/errors.js +7 -0
  56. package/dest/versioning/versioning.d.ts +4 -2
  57. package/dest/versioning/versioning.d.ts.map +1 -1
  58. package/dest/versioning/versioning.js +4 -1
  59. package/package.json +8 -8
  60. package/src/block/l2_block_source.ts +8 -7
  61. package/src/epoch-helpers/index.ts +3 -0
  62. package/src/gas/README.md +123 -0
  63. package/src/interfaces/archiver.ts +2 -2
  64. package/src/interfaces/aztec-node.ts +10 -1
  65. package/src/interfaces/block-builder.ts +19 -11
  66. package/src/interfaces/configs.ts +9 -1
  67. package/src/interfaces/l2_logs_source.ts +4 -1
  68. package/src/interfaces/merkle_tree_operations.ts +8 -18
  69. package/src/interfaces/prover-client.ts +8 -0
  70. package/src/interfaces/world_state.ts +4 -3
  71. package/src/logs/index.ts +1 -0
  72. package/src/logs/log_filter.ts +5 -0
  73. package/src/logs/tagging_index_range.ts +24 -0
  74. package/src/messaging/l1_to_l2_message_source.ts +3 -1
  75. package/src/messaging/l2_to_l1_membership.ts +98 -33
  76. package/src/tx/private_execution_result.ts +5 -5
  77. package/src/tx/profiling.ts +11 -2
  78. package/src/tx/tx_receipt.ts +7 -2
  79. package/src/update-checker/package_version.ts +19 -6
  80. package/src/validators/errors.ts +9 -0
  81. package/src/versioning/versioning.ts +4 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/stdlib",
3
- "version": "0.0.1-commit.3895657bc",
3
+ "version": "0.0.1-commit.3e3d0c9cd",
4
4
  "type": "module",
5
5
  "inherits": [
6
6
  "../package.common.json",
@@ -92,13 +92,13 @@
92
92
  },
93
93
  "dependencies": {
94
94
  "@aws-sdk/client-s3": "^3.892.0",
95
- "@aztec/bb.js": "0.0.1-commit.3895657bc",
96
- "@aztec/blob-lib": "0.0.1-commit.3895657bc",
97
- "@aztec/constants": "0.0.1-commit.3895657bc",
98
- "@aztec/ethereum": "0.0.1-commit.3895657bc",
99
- "@aztec/foundation": "0.0.1-commit.3895657bc",
100
- "@aztec/l1-artifacts": "0.0.1-commit.3895657bc",
101
- "@aztec/noir-noirc_abi": "0.0.1-commit.3895657bc",
95
+ "@aztec/bb.js": "0.0.1-commit.3e3d0c9cd",
96
+ "@aztec/blob-lib": "0.0.1-commit.3e3d0c9cd",
97
+ "@aztec/constants": "0.0.1-commit.3e3d0c9cd",
98
+ "@aztec/ethereum": "0.0.1-commit.3e3d0c9cd",
99
+ "@aztec/foundation": "0.0.1-commit.3e3d0c9cd",
100
+ "@aztec/l1-artifacts": "0.0.1-commit.3e3d0c9cd",
101
+ "@aztec/noir-noirc_abi": "0.0.1-commit.3e3d0c9cd",
102
102
  "@google-cloud/storage": "^7.15.0",
103
103
  "axios": "^1.13.5",
104
104
  "json-stringify-deterministic": "1.0.12",
@@ -68,9 +68,8 @@ export interface L2BlockSource {
68
68
  getCheckpointedL2BlockNumber(): Promise<BlockNumber>;
69
69
 
70
70
  /**
71
- * Computes the finalized block number based on the proven block number.
72
- * A block is considered finalized when it's 2 epochs behind the proven block.
73
- * TODO(#13569): Compute proper finalized block number based on L1 finalized block.
71
+ * Returns the finalized L2 block number. A block is finalized when it was proven
72
+ * in an L1 block that has itself been finalized on Ethereum.
74
73
  * @returns The finalized block number.
75
74
  */
76
75
  getFinalizedL2BlockNumber(): Promise<BlockNumber>;
@@ -176,14 +175,16 @@ export interface L2BlockSource {
176
175
  getSettledTxReceipt(txHash: TxHash): Promise<TxReceipt | undefined>;
177
176
 
178
177
  /**
179
- * Returns the current L2 slot number based on the currently synced L1 timestamp.
178
+ * Returns the last L2 slot number that has been fully synchronized from L1.
179
+ * An L2 slot is fully synced when all L1 blocks that fall within its time range have been processed.
180
180
  */
181
- getL2SlotNumber(): Promise<SlotNumber | undefined>;
181
+ getSyncedL2SlotNumber(): Promise<SlotNumber | undefined>;
182
182
 
183
183
  /**
184
- * Returns the current L2 epoch number based on the currently synced L1 timestamp.
184
+ * Returns the last L2 epoch number that has been fully synchronized from L1.
185
+ * An epoch is fully synced when all its L2 slots have been fully synced.
185
186
  */
186
- getL2EpochNumber(): Promise<EpochNumber | undefined>;
187
+ getSyncedL2EpochNumber(): Promise<EpochNumber | undefined>;
187
188
 
188
189
  /**
189
190
  * Returns all checkpointed block headers for a given epoch.
@@ -12,6 +12,7 @@ export type L1RollupConstants = {
12
12
  ethereumSlotDuration: number;
13
13
  proofSubmissionEpochs: number;
14
14
  targetCommitteeSize: number;
15
+ rollupManaLimit: number;
15
16
  };
16
17
 
17
18
  export const EmptyL1RollupConstants: L1RollupConstants = {
@@ -22,6 +23,7 @@ export const EmptyL1RollupConstants: L1RollupConstants = {
22
23
  ethereumSlotDuration: 1,
23
24
  proofSubmissionEpochs: 1,
24
25
  targetCommitteeSize: 48,
26
+ rollupManaLimit: Number.MAX_SAFE_INTEGER,
25
27
  };
26
28
 
27
29
  export const L1RollupConstantsSchema = zodFor<L1RollupConstants>()(
@@ -33,6 +35,7 @@ export const L1RollupConstantsSchema = zodFor<L1RollupConstants>()(
33
35
  ethereumSlotDuration: z.number(),
34
36
  proofSubmissionEpochs: z.number(),
35
37
  targetCommitteeSize: z.number(),
38
+ rollupManaLimit: z.number(),
36
39
  }),
37
40
  );
38
41
 
@@ -0,0 +1,123 @@
1
+ # Aztec Gas and Fee Model
2
+
3
+ The minimum fee per mana and its components are computed on L1 in
4
+ `l1-contracts/src/core/libraries/rollup/FeeLib.sol`. This document describes the
5
+ formulas, the oracle lag/lifetime mechanism, and the TypeScript types in this directory.
6
+
7
+ ## Mana
8
+
9
+ Aztec uses **mana** as its unit of work (analogous to Ethereum gas). Transactions consume
10
+ mana in two dimensions: **DA** (data availability) and **L2** (execution). The total fee
11
+ is `gasUsed * feePerMana` summed across both dimensions.
12
+
13
+ ## Fee Components
14
+
15
+ The minimum fee per mana has four components:
16
+
17
+ ### Sequencer Cost
18
+
19
+ L1 cost to propose a checkpoint (calldata gas + blob data), amortized over `manaTarget`:
20
+
21
+ ```
22
+ sequencerCost = ((L1_GAS_PER_CHECKPOINT_PROPOSED * baseFee)
23
+ + (BLOBS_PER_CHECKPOINT * BLOB_GAS_PER_BLOB * blobFee))
24
+ / manaTarget
25
+ ```
26
+
27
+ ### Prover Cost
28
+
29
+ L1 cost to verify an epoch proof, amortized over epoch duration and `manaTarget`, plus a
30
+ governance-set proving cost that compensates for off-chain proof generation:
31
+
32
+ ```
33
+ proverCost = (L1_GAS_PER_EPOCH_VERIFIED * baseFee / epochDuration) / manaTarget
34
+ + provingCostPerMana
35
+ ```
36
+
37
+ ### Congestion Cost
38
+
39
+ An exponential surcharge when the network is congested (inspired by EIP-1559; the
40
+ implementation uses the `fakeExponential` Taylor series approximation from EIP-4844):
41
+
42
+ ```
43
+ baseCost = sequencerCost + proverCost
44
+ congestionCost = baseCost * congestionMultiplier / MINIMUM_CONGESTION_MULTIPLIER - baseCost
45
+ ```
46
+
47
+ When there is no congestion the multiplier equals `MINIMUM_CONGESTION_MULTIPLIER` (1e9)
48
+ and congestion cost is zero.
49
+
50
+ ### Congestion Multiplier
51
+
52
+ ```
53
+ excessMana = max(0, prevExcessMana + prevManaUsed - manaTarget)
54
+ congestionMultiplier = fakeExponential(MINIMUM_CONGESTION_MULTIPLIER, excessMana, denominator)
55
+ ```
56
+
57
+ Each additional `manaTarget` of excess mana increases the multiplier by ~12.5%.
58
+
59
+ ### Total
60
+
61
+ ```
62
+ minFeePerMana = sequencerCost + proverCost + congestionCost
63
+ ```
64
+
65
+ ## L1 Gas Oracle: Lag and Lifetime
66
+
67
+ The oracle feeds Ethereum's `baseFee` and `blobFee` into the fee model using a two-phase
68
+ (`pre` / `post`) system that smooths out L1 fee volatility.
69
+
70
+ - **LAG = 2 slots** — when new L1 fees are observed, they activate `LAG` slots later
71
+ (`slotOfChange = currentSlot + LAG`). This gives mempool transactions time to land
72
+ before fees change.
73
+ - **LIFETIME = 5 slots** — after an oracle update, the next update is rejected until
74
+ `slotOfChange + (LIFETIME - LAG)` = 3 more slots have passed. This rate-limits how
75
+ frequently L1 fee data can change.
76
+
77
+ Fee resolution at a given timestamp:
78
+
79
+ ```
80
+ if slot < slotOfChange → use pre (old fees)
81
+ else → use post (new fees)
82
+ ```
83
+
84
+ **Net effect**: L1 fee changes reach L2 with a 2-slot delay and can update at most once
85
+ every 5 slots.
86
+
87
+ ## Fee Asset Price
88
+
89
+ Fees are computed in ETH internally but converted to the fee asset (Fee Juice) via
90
+ `ethPerFeeAsset` (1e12 precision). The price updates at most ±1% (±100 bps) per
91
+ checkpoint:
92
+
93
+ ```
94
+ newPrice = currentPrice * (10000 + modifierBps) / 10000
95
+ ```
96
+
97
+ ## Maximum Fee Change Rate
98
+
99
+ | Component | Bound |
100
+ | ---------------------- | ------------------------------------------------------- |
101
+ | L1 base fee / blob fee | At most once every 5 slots (oracle LIFETIME) |
102
+ | Fee asset price | ±1% per checkpoint |
103
+ | Congestion multiplier | Depends on excess mana accumulation/drain per checkpoint |
104
+ | Sequencer/prover costs | Scale linearly with L1 fees |
105
+
106
+ ## Key Constants
107
+
108
+ | Constant | Value |
109
+ | ------------------------------ | -------------- |
110
+ | `L1_GAS_PER_CHECKPOINT_PROPOSED` | 300,000 |
111
+ | `L1_GAS_PER_EPOCH_VERIFIED` | 3,600,000 |
112
+ | `BLOBS_PER_CHECKPOINT` | 3 |
113
+ | `BLOB_GAS_PER_BLOB` | 2^17 |
114
+ | `MINIMUM_CONGESTION_MULTIPLIER` | 1e9 |
115
+ | `LAG` | 2 slots |
116
+ | `LIFETIME` | 5 slots |
117
+
118
+ ## TypeScript Types
119
+
120
+ - **`Gas`** — mana quantity in two dimensions (`daGas`, `l2Gas`).
121
+ - **`GasFees`** — per-unit price in each dimension (`feePerDaGas`, `feePerL2Gas`).
122
+ - **`GasSettings`** — sender-chosen fee parameters: gas limits, teardown limits, max fees, priority fees.
123
+ - **`GasUsed`** — actual consumption after execution. Note: `billedGas` uses the teardown gas *limit*, not actual usage.
@@ -114,8 +114,8 @@ export const ArchiverApiSchema: ApiSchemaFor<ArchiverApi> = {
114
114
  getL2BlockByArchive: z.function().args(schemas.Fr).returns(L2Block.schema.optional()),
115
115
  getTxEffect: z.function().args(TxHash.schema).returns(indexedTxSchema().optional()),
116
116
  getSettledTxReceipt: z.function().args(TxHash.schema).returns(TxReceipt.schema.optional()),
117
- getL2SlotNumber: z.function().args().returns(schemas.SlotNumber.optional()),
118
- getL2EpochNumber: z.function().args().returns(EpochNumberSchema.optional()),
117
+ getSyncedL2SlotNumber: z.function().args().returns(schemas.SlotNumber.optional()),
118
+ getSyncedL2EpochNumber: z.function().args().returns(EpochNumberSchema.optional()),
119
119
  getCheckpointsForEpoch: z.function().args(EpochNumberSchema).returns(z.array(Checkpoint.schema)),
120
120
  getCheckpointsDataForEpoch: z.function().args(EpochNumberSchema).returns(z.array(CheckpointDataSchema)),
121
121
  getCheckpointedBlocksForEpoch: z.function().args(EpochNumberSchema).returns(z.array(CheckpointedL2Block.schema)),
@@ -25,6 +25,7 @@ import { CheckpointedL2Block } from '../block/checkpointed_l2_block.js';
25
25
  import { type DataInBlock, dataInBlockSchemaFor } from '../block/in_block.js';
26
26
  import { L2Block } from '../block/l2_block.js';
27
27
  import { type L2BlockSource, type L2Tips, L2TipsSchema } from '../block/l2_block_source.js';
28
+ import { CheckpointDataSchema } from '../checkpoint/checkpoint_data.js';
28
29
  import { PublishedCheckpoint } from '../checkpoint/published_checkpoint.js';
29
30
  import {
30
31
  type ContractClassPublic,
@@ -74,7 +75,12 @@ import { type WorldStateSyncStatus, WorldStateSyncStatusSchema } from './world_s
74
75
  export interface AztecNode
75
76
  extends Pick<
76
77
  L2BlockSource,
77
- 'getBlocks' | 'getCheckpoints' | 'getBlockHeader' | 'getL2Tips' | 'getCheckpointedBlocks'
78
+ | 'getBlocks'
79
+ | 'getCheckpoints'
80
+ | 'getBlockHeader'
81
+ | 'getL2Tips'
82
+ | 'getCheckpointedBlocks'
83
+ | 'getCheckpointsDataForEpoch'
78
84
  > {
79
85
  /**
80
86
  * Returns the tips of the L2 chain.
@@ -116,6 +122,7 @@ export interface AztecNode
116
122
  * @param referenceBlock - The block parameter (block number, block hash, or 'latest') at which to get the data.
117
123
  * @param nullifier - Nullifier we try to find the low nullifier witness for.
118
124
  * @returns The low nullifier membership witness (if found).
125
+ * @throws If the nullifier already exists in the tree, since non-inclusion cannot be proven.
119
126
  * @remarks Low nullifier witness can be used to perform a nullifier non-inclusion proof by leveraging the "linked
120
127
  * list structure" of leaves and proving that a lower nullifier is pointing to a bigger next value than the nullifier
121
128
  * we are trying to prove non-inclusion for.
@@ -567,6 +574,8 @@ export const AztecNodeApiSchema: ApiSchemaFor<AztecNode> = {
567
574
  .args(BlockNumberPositiveSchema, z.number().gt(0).lte(MAX_RPC_BLOCKS_LEN))
568
575
  .returns(z.array(CheckpointedL2Block.schema)),
569
576
 
577
+ getCheckpointsDataForEpoch: z.function().args(EpochNumberSchema).returns(z.array(CheckpointDataSchema)),
578
+
570
579
  getCurrentMinFees: z.function().returns(GasFees.schema),
571
580
 
572
581
  getMaxPriorityFees: z.function().returns(GasFees.schema),
@@ -53,7 +53,7 @@ export interface PublicProcessorValidator {
53
53
  nullifierCache?: { addNullifiers: (nullifiers: Buffer[]) => void };
54
54
  }
55
55
 
56
- export type FullNodeBlockBuilderConfig = Pick<L1RollupConstants, 'l1GenesisTime' | 'slotDuration'> &
56
+ export type FullNodeBlockBuilderConfig = Pick<L1RollupConstants, 'l1GenesisTime' | 'slotDuration' | 'rollupManaLimit'> &
57
57
  Pick<ChainConfig, 'l1ChainId' | 'rollupVersion'> &
58
58
  Pick<
59
59
  SequencerConfig,
@@ -64,10 +64,10 @@ export type FullNodeBlockBuilderConfig = Pick<L1RollupConstants, 'l1GenesisTime'
64
64
  | 'maxTxsPerCheckpoint'
65
65
  | 'maxL2BlockGas'
66
66
  | 'maxDABlockGas'
67
- > & {
68
- /** Total L2 gas (mana) allowed per checkpoint. Fetched from L1 getManaLimit(). */
69
- rollupManaLimit: number;
70
- };
67
+ | 'redistributeCheckpointBudget'
68
+ | 'perBlockAllocationMultiplier'
69
+ | 'maxBlocksPerCheckpoint'
70
+ >;
71
71
 
72
72
  export const FullNodeBlockBuilderConfigKeys: (keyof FullNodeBlockBuilderConfig)[] = [
73
73
  'l1GenesisTime',
@@ -82,13 +82,20 @@ export const FullNodeBlockBuilderConfigKeys: (keyof FullNodeBlockBuilderConfig)[
82
82
  'maxL2BlockGas',
83
83
  'maxDABlockGas',
84
84
  'rollupManaLimit',
85
+ 'redistributeCheckpointBudget',
86
+ 'perBlockAllocationMultiplier',
87
+ 'maxBlocksPerCheckpoint',
85
88
  ] as const;
86
89
 
87
- /** Thrown when no valid transactions are available to include in a block after processing, and this is not the first block in a checkpoint. */
88
- export class NoValidTxsError extends Error {
89
- constructor(public readonly failedTxs: FailedTx[]) {
90
- super('No valid transactions to include in block');
91
- this.name = 'NoValidTxsError';
90
+ /** Thrown when the number of successfully processed transactions is below the required minimum. */
91
+ export class InsufficientValidTxsError extends Error {
92
+ constructor(
93
+ public readonly processedCount: number,
94
+ public readonly minRequired: number,
95
+ public readonly failedTxs: FailedTx[],
96
+ ) {
97
+ super(`Insufficient valid txs: got ${processedCount} but need ${minRequired}`);
98
+ this.name = 'InsufficientValidTxsError';
92
99
  }
93
100
  }
94
101
 
@@ -103,11 +110,12 @@ export type BuildBlockInCheckpointResult = {
103
110
 
104
111
  /** Interface for building blocks within a checkpoint context. */
105
112
  export interface ICheckpointBlockBuilder {
113
+ /** Builds a single block within this checkpoint. Throws InsufficientValidTxsError if fewer than minValidTxs succeed. */
106
114
  buildBlock(
107
115
  pendingTxs: Iterable<Tx> | AsyncIterable<Tx>,
108
116
  blockNumber: BlockNumber,
109
117
  timestamp: bigint,
110
- opts: PublicProcessorLimits,
118
+ opts: PublicProcessorLimits & { minValidTxs?: number },
111
119
  ): Promise<BuildBlockInCheckpointResult>;
112
120
  }
113
121
 
@@ -27,6 +27,10 @@ export interface SequencerConfig {
27
27
  maxDABlockGas?: number;
28
28
  /** Per-block gas budget multiplier for both L2 and DA gas. Budget = (checkpointLimit / maxBlocks) * multiplier. */
29
29
  perBlockAllocationMultiplier?: number;
30
+ /** Redistribute remaining checkpoint budget evenly across remaining blocks instead of allowing a single block to consume the entire remaining budget. */
31
+ redistributeCheckpointBudget?: boolean;
32
+ /** Computed max number of blocks per checkpoint from timetable. */
33
+ maxBlocksPerCheckpoint?: number;
30
34
  /** Recipient of block reward. */
31
35
  coinbase?: EthAddress;
32
36
  /** Address to receive fees. */
@@ -94,6 +98,8 @@ export const SequencerConfigSchema = zodFor<SequencerConfig>()(
94
98
  publishTxsWithProposals: z.boolean().optional(),
95
99
  maxDABlockGas: z.number().optional(),
96
100
  perBlockAllocationMultiplier: z.number().optional(),
101
+ redistributeCheckpointBudget: z.boolean().optional(),
102
+ maxBlocksPerCheckpoint: z.number().optional(),
97
103
  coinbase: schemas.EthAddress.optional(),
98
104
  feeRecipient: schemas.AztecAddress.optional(),
99
105
  acvmWorkingDirectory: z.string().optional(),
@@ -142,7 +148,9 @@ type SequencerConfigOptionalKeys =
142
148
  | 'maxTxsPerCheckpoint'
143
149
  | 'maxL2BlockGas'
144
150
  | 'maxDABlockGas'
145
- | 'perBlockAllocationMultiplier';
151
+ | 'perBlockAllocationMultiplier'
152
+ | 'redistributeCheckpointBudget'
153
+ | 'maxBlocksPerCheckpoint';
146
154
 
147
155
  export type ResolvedSequencerConfig = Prettify<
148
156
  Required<Omit<SequencerConfig, SequencerConfigOptionalKeys>> & Pick<SequencerConfig, SequencerConfigOptionalKeys>
@@ -16,10 +16,11 @@ export interface L2LogsSource {
16
16
  * array implies no logs match that tag.
17
17
  * @param tags - The tags to search for.
18
18
  * @param page - The page number (0-indexed) for pagination.
19
+ * @param upToBlockNumber - If set, only return logs from blocks up to and including this block number.
19
20
  * @returns An array of log arrays, one per tag. Returns at most 10 logs per tag per page. If 10 logs are returned
20
21
  * for a tag, the caller should fetch the next page to check for more logs.
21
22
  */
22
- getPrivateLogsByTags(tags: SiloedTag[], page?: number): Promise<TxScopedL2Log[][]>;
23
+ getPrivateLogsByTags(tags: SiloedTag[], page?: number, upToBlockNumber?: BlockNumber): Promise<TxScopedL2Log[][]>;
23
24
 
24
25
  /**
25
26
  * Gets public logs that match any of the `tags` from the specified contract. For each tag, an array of matching
@@ -27,6 +28,7 @@ export interface L2LogsSource {
27
28
  * @param contractAddress - The contract address to search logs for.
28
29
  * @param tags - The tags to search for.
29
30
  * @param page - The page number (0-indexed) for pagination.
31
+ * @param upToBlockNumber - If set, only return logs from blocks up to and including this block number.
30
32
  * @returns An array of log arrays, one per tag. Returns at most 10 logs per tag per page. If 10 logs are returned
31
33
  * for a tag, the caller should fetch the next page to check for more logs.
32
34
  */
@@ -34,6 +36,7 @@ export interface L2LogsSource {
34
36
  contractAddress: AztecAddress,
35
37
  tags: Tag[],
36
38
  page?: number,
39
+ upToBlockNumber?: BlockNumber,
37
40
  ): Promise<TxScopedL2Log[][]>;
38
41
 
39
42
  /**
@@ -225,30 +225,20 @@ export interface MerkleTreeReadOperations {
225
225
  }
226
226
 
227
227
  export interface MerkleTreeCheckpointOperations {
228
- /**
229
- * Checkpoints the current fork state
230
- */
231
- createCheckpoint(): Promise<void>;
228
+ /** Checkpoints the current fork state. Returns the depth of the new checkpoint. */
229
+ createCheckpoint(): Promise<number>;
232
230
 
233
- /**
234
- * Commits the current checkpoint
235
- */
231
+ /** Commits the current checkpoint. */
236
232
  commitCheckpoint(): Promise<void>;
237
233
 
238
- /**
239
- * Reverts the current checkpoint
240
- */
234
+ /** Reverts the current checkpoint. */
241
235
  revertCheckpoint(): Promise<void>;
242
236
 
243
- /**
244
- * Commits all checkpoints
245
- */
246
- commitAllCheckpoints(): Promise<void>;
237
+ /** Commits all checkpoints above the given depth, leaving checkpoint depth at the given value. */
238
+ commitAllCheckpointsTo(depth: number): Promise<void>;
247
239
 
248
- /**
249
- * Reverts all checkpoints
250
- */
251
- revertAllCheckpoints(): Promise<void>;
240
+ /** Reverts all checkpoints above the given depth, leaving checkpoint depth at the given value. */
241
+ revertAllCheckpointsTo(depth: number): Promise<void>;
252
242
  }
253
243
 
254
244
  export interface MerkleTreeWriteOperations
@@ -23,6 +23,8 @@ export type ActualProverConfig = {
23
23
  * When true, jobs are explicitly cancelled with the broker, which prevents reuse.
24
24
  */
25
25
  cancelJobsOnStop: boolean;
26
+ /** Max concurrent jobs the orchestrator serializes and enqueues to the broker. */
27
+ enqueueConcurrency: number;
26
28
  };
27
29
 
28
30
  /**
@@ -53,6 +55,7 @@ export const ProverConfigSchema = zodFor<ProverConfig>()(
53
55
  proofStore: z.string().optional(),
54
56
  failedProofStore: z.string().optional(),
55
57
  cancelJobsOnStop: z.boolean(),
58
+ enqueueConcurrency: z.number(),
56
59
  }),
57
60
  );
58
61
 
@@ -107,6 +110,11 @@ export const proverConfigMappings: ConfigMappingsType<ProverConfig> = {
107
110
  'When true, jobs are explicitly cancelled with the broker, which prevents reuse.',
108
111
  ...booleanConfigHelper(false),
109
112
  },
113
+ enqueueConcurrency: {
114
+ env: 'PROVER_ENQUEUE_CONCURRENCY',
115
+ description: 'Max concurrent jobs the orchestrator serializes and enqueues to the broker.',
116
+ ...numberConfigHelper(50),
117
+ },
110
118
  };
111
119
 
112
120
  function parseProverId(str?: string) {
@@ -3,6 +3,7 @@ import type { PromiseWithResolvers } from '@aztec/foundation/promise';
3
3
 
4
4
  import { z } from 'zod';
5
5
 
6
+ import type { BlockHash } from '../block/block_hash.js';
6
7
  import type { SnapshotDataKeys } from '../snapshots/types.js';
7
8
  import type { MerkleTreeReadOperations, MerkleTreeWriteOperations } from './merkle_tree_operations.js';
8
9
 
@@ -80,12 +81,12 @@ export interface WorldStateSynchronizer extends ReadonlyWorldStateAccess, ForkMe
80
81
  resumeSync(): void;
81
82
 
82
83
  /**
83
- * Forces an immediate sync to an optionally provided minimum block number
84
+ * Forces an immediate sync to an optionally provided minimum block number.
84
85
  * @param targetBlockNumber - The target block number that we must sync to. Will download unproven blocks if needed to reach it.
85
- * @param skipThrowIfTargetNotReached - Whether to skip throwing if the target block number is not reached.
86
+ * @param blockHash - If provided, verifies the block at targetBlockNumber matches this hash. On mismatch, triggers a resync (reorg detection).
86
87
  * @returns A promise that resolves with the block number the world state was synced to
87
88
  */
88
- syncImmediate(minBlockNumber?: BlockNumber, skipThrowIfTargetNotReached?: boolean): Promise<BlockNumber>;
89
+ syncImmediate(minBlockNumber?: BlockNumber, blockHash?: BlockHash): Promise<BlockNumber>;
89
90
 
90
91
  /** Deletes the db */
91
92
  clear(): Promise<void>;
package/src/logs/index.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export * from './extended_directional_app_tagging_secret.js';
2
2
  export * from './pre_tag.js';
3
+ export * from './tagging_index_range.js';
3
4
  export * from './contract_class_log.js';
4
5
  export * from './public_log.js';
5
6
  export * from './private_log.js';
@@ -1,3 +1,5 @@
1
+ import type { Fr } from '@aztec/foundation/curves/bn254';
2
+
1
3
  import { z } from 'zod';
2
4
 
3
5
  import type { AztecAddress } from '../aztec-address/index.js';
@@ -20,6 +22,8 @@ export type LogFilter = {
20
22
  afterLog?: LogId;
21
23
  /** The contract address to filter logs by. */
22
24
  contractAddress?: AztecAddress;
25
+ /** The tag (first field of the log) to filter logs by. */
26
+ tag?: Fr;
23
27
  };
24
28
 
25
29
  export const LogFilterSchema: ZodFor<LogFilter> = z.object({
@@ -28,4 +32,5 @@ export const LogFilterSchema: ZodFor<LogFilter> = z.object({
28
32
  toBlock: schemas.Integer.optional(),
29
33
  afterLog: LogId.schema.optional(),
30
34
  contractAddress: schemas.AztecAddress.optional(),
35
+ tag: schemas.Fr.optional(),
31
36
  });
@@ -0,0 +1,24 @@
1
+ import { schemas } from '@aztec/foundation/schemas';
2
+
3
+ import { z } from 'zod';
4
+
5
+ import {
6
+ type ExtendedDirectionalAppTaggingSecret,
7
+ ExtendedDirectionalAppTaggingSecretSchema,
8
+ } from './extended_directional_app_tagging_secret.js';
9
+
10
+ /**
11
+ * Represents a range of tagging indexes for a given extended directional app tagging secret. Used to track the lowest
12
+ * and highest indexes used in a transaction for a given (sender, recipient, app/contract) tuple.
13
+ */
14
+ export type TaggingIndexRange = {
15
+ extendedSecret: ExtendedDirectionalAppTaggingSecret;
16
+ lowestIndex: number;
17
+ highestIndex: number;
18
+ };
19
+
20
+ export const TaggingIndexRangeSchema = z.object({
21
+ extendedSecret: ExtendedDirectionalAppTaggingSecretSchema,
22
+ lowestIndex: schemas.Integer,
23
+ highestIndex: schemas.Integer,
24
+ });
@@ -10,7 +10,9 @@ export interface L1ToL2MessageSource {
10
10
  /**
11
11
  * Gets new L1 to L2 message (to be) included in a given checkpoint.
12
12
  * @param checkpointNumber - Checkpoint number to get messages for.
13
- * @returns The L1 to L2 messages/leaves of the messages subtree (throws if not found).
13
+ * @returns The L1 to L2 messages/leaves of the messages subtree.
14
+ * @throws If the message tree for the given checkpoint has not yet been sealed on L1
15
+ * (i.e., checkpointNumber >= inbox treeInProgress).
14
16
  */
15
17
  getL1ToL2Messages(checkpointNumber: CheckpointNumber): Promise<Fr[]>;
16
18