@aztec/stdlib 5.0.0-nightly.20260611 → 5.0.0-nightly.20260613

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 (123) hide show
  1. package/dest/block/l2_block_source.d.ts +7 -1
  2. package/dest/block/l2_block_source.d.ts.map +1 -1
  3. package/dest/block/l2_block_stream/interfaces.d.ts +44 -8
  4. package/dest/block/l2_block_stream/interfaces.d.ts.map +1 -1
  5. package/dest/block/l2_block_stream/l2_block_stream.d.ts +1 -1
  6. package/dest/block/l2_block_stream/l2_block_stream.d.ts.map +1 -1
  7. package/dest/block/l2_block_stream/l2_block_stream.js +13 -4
  8. package/dest/block/l2_block_stream/l2_tips_memory_store.d.ts +6 -12
  9. package/dest/block/l2_block_stream/l2_tips_memory_store.d.ts.map +1 -1
  10. package/dest/block/l2_block_stream/l2_tips_memory_store.js +8 -32
  11. package/dest/block/l2_block_stream/l2_tips_store_base.d.ts +9 -18
  12. package/dest/block/l2_block_stream/l2_tips_store_base.d.ts.map +1 -1
  13. package/dest/block/l2_block_stream/l2_tips_store_base.js +52 -58
  14. package/dest/block/test/l2_tips_store_test_suite.d.ts +1 -1
  15. package/dest/block/test/l2_tips_store_test_suite.d.ts.map +1 -1
  16. package/dest/block/test/l2_tips_store_test_suite.js +202 -34
  17. package/dest/config/index.d.ts +2 -1
  18. package/dest/config/index.d.ts.map +1 -1
  19. package/dest/config/index.js +1 -0
  20. package/dest/config/network-consensus-config.d.ts +72 -0
  21. package/dest/config/network-consensus-config.d.ts.map +1 -0
  22. package/dest/config/network-consensus-config.js +231 -0
  23. package/dest/config/sequencer-config.d.ts +3 -1
  24. package/dest/config/sequencer-config.d.ts.map +1 -1
  25. package/dest/config/sequencer-config.js +5 -4
  26. package/dest/contract/interfaces/node-info.d.ts +11 -1
  27. package/dest/contract/interfaces/node-info.d.ts.map +1 -1
  28. package/dest/contract/interfaces/node-info.js +7 -1
  29. package/dest/gas/gas_settings.d.ts +7 -13
  30. package/dest/gas/gas_settings.d.ts.map +1 -1
  31. package/dest/gas/gas_settings.js +9 -16
  32. package/dest/gas/index.d.ts +2 -1
  33. package/dest/gas/index.d.ts.map +1 -1
  34. package/dest/gas/index.js +1 -0
  35. package/dest/gas/tx_gas_limits.d.ts +72 -0
  36. package/dest/gas/tx_gas_limits.d.ts.map +1 -0
  37. package/dest/gas/tx_gas_limits.js +85 -0
  38. package/dest/interfaces/aztec-node-admin.d.ts +18 -17
  39. package/dest/interfaces/aztec-node-admin.d.ts.map +1 -1
  40. package/dest/interfaces/aztec-node-admin.js +1 -1
  41. package/dest/interfaces/aztec-node-debug.d.ts +15 -2
  42. package/dest/interfaces/aztec-node-debug.d.ts.map +1 -1
  43. package/dest/interfaces/aztec-node-debug.js +9 -1
  44. package/dest/interfaces/aztec-node.d.ts +40 -11
  45. package/dest/interfaces/aztec-node.d.ts.map +1 -1
  46. package/dest/interfaces/aztec-node.js +42 -5
  47. package/dest/interfaces/block-builder.d.ts +3 -1
  48. package/dest/interfaces/block-builder.d.ts.map +1 -1
  49. package/dest/interfaces/client.d.ts +2 -1
  50. package/dest/interfaces/client.d.ts.map +1 -1
  51. package/dest/interfaces/configs.d.ts +12 -6
  52. package/dest/interfaces/configs.d.ts.map +1 -1
  53. package/dest/interfaces/configs.js +2 -1
  54. package/dest/interfaces/get_tx_by_hash_options.d.ts +9 -0
  55. package/dest/interfaces/get_tx_by_hash_options.d.ts.map +1 -0
  56. package/dest/interfaces/get_tx_by_hash_options.js +4 -0
  57. package/dest/interfaces/p2p.d.ts +32 -8
  58. package/dest/interfaces/p2p.d.ts.map +1 -1
  59. package/dest/interfaces/p2p.js +12 -2
  60. package/dest/interfaces/proving-job.d.ts +70 -70
  61. package/dest/interfaces/validator.d.ts +3 -3
  62. package/dest/interfaces/validator.d.ts.map +1 -1
  63. package/dest/interfaces/validator.js +1 -1
  64. package/dest/tests/factories.d.ts +1 -1
  65. package/dest/tests/factories.d.ts.map +1 -1
  66. package/dest/tests/factories.js +4 -1
  67. package/dest/tests/mocks.d.ts +1 -1
  68. package/dest/tests/mocks.d.ts.map +1 -1
  69. package/dest/tests/mocks.js +3 -2
  70. package/dest/timetable/budgets.d.ts +4 -2
  71. package/dest/timetable/budgets.d.ts.map +1 -1
  72. package/dest/timetable/budgets.js +2 -1
  73. package/dest/timetable/build_proposer_timetable.d.ts +21 -0
  74. package/dest/timetable/build_proposer_timetable.d.ts.map +1 -0
  75. package/dest/timetable/build_proposer_timetable.js +17 -0
  76. package/dest/timetable/consensus_timetable.d.ts +5 -7
  77. package/dest/timetable/consensus_timetable.d.ts.map +1 -1
  78. package/dest/timetable/consensus_timetable.js +6 -8
  79. package/dest/timetable/index.d.ts +2 -1
  80. package/dest/timetable/index.d.ts.map +1 -1
  81. package/dest/timetable/index.js +1 -0
  82. package/dest/timetable/proposer_timetable.d.ts +18 -24
  83. package/dest/timetable/proposer_timetable.d.ts.map +1 -1
  84. package/dest/timetable/proposer_timetable.js +26 -55
  85. package/dest/tx/fee_provider.d.ts +2 -2
  86. package/dest/tx/fee_provider.d.ts.map +1 -1
  87. package/dest/tx/validator/error_texts.d.ts +2 -2
  88. package/dest/tx/validator/error_texts.d.ts.map +1 -1
  89. package/dest/tx/validator/error_texts.js +1 -1
  90. package/package.json +8 -8
  91. package/src/block/l2_block_source.ts +7 -0
  92. package/src/block/l2_block_stream/interfaces.ts +39 -7
  93. package/src/block/l2_block_stream/l2_block_stream.ts +21 -3
  94. package/src/block/l2_block_stream/l2_tips_memory_store.ts +12 -41
  95. package/src/block/l2_block_stream/l2_tips_store_base.ts +63 -93
  96. package/src/block/test/l2_tips_store_test_suite.ts +197 -24
  97. package/src/config/index.ts +1 -0
  98. package/src/config/network-consensus-config.ts +302 -0
  99. package/src/config/sequencer-config.ts +7 -5
  100. package/src/contract/interfaces/node-info.ts +11 -0
  101. package/src/gas/README.md +92 -0
  102. package/src/gas/gas_settings.ts +11 -21
  103. package/src/gas/index.ts +1 -0
  104. package/src/gas/tx_gas_limits.ts +123 -0
  105. package/src/interfaces/aztec-node-admin.ts +1 -1
  106. package/src/interfaces/aztec-node-debug.ts +17 -2
  107. package/src/interfaces/aztec-node.ts +74 -13
  108. package/src/interfaces/block-builder.ts +2 -0
  109. package/src/interfaces/client.ts +1 -0
  110. package/src/interfaces/configs.ts +10 -6
  111. package/src/interfaces/get_tx_by_hash_options.ts +14 -0
  112. package/src/interfaces/p2p.ts +21 -8
  113. package/src/interfaces/validator.ts +5 -5
  114. package/src/tests/factories.ts +7 -1
  115. package/src/tests/mocks.ts +7 -2
  116. package/src/timetable/README.md +10 -2
  117. package/src/timetable/budgets.ts +5 -2
  118. package/src/timetable/build_proposer_timetable.ts +42 -0
  119. package/src/timetable/consensus_timetable.ts +8 -14
  120. package/src/timetable/index.ts +1 -0
  121. package/src/timetable/proposer_timetable.ts +37 -61
  122. package/src/tx/fee_provider.ts +1 -1
  123. package/src/tx/validator/error_texts.ts +2 -1
@@ -10,13 +10,20 @@ import { ConsensusTimetable } from './consensus_timetable.js';
10
10
  *
11
11
  * The single hard deadline {@link getAttestationDeadline} is inherited from the composed
12
12
  * {@link ConsensusTimetable}, so the proposer uses one object.
13
+ *
14
+ * `maxBlocksPerCheckpoint` is computed from the local operational budgets and then clamped down to the optional
15
+ * network-provided value when that value is lower; a network value at or above the computed count leaves the
16
+ * computed count in effect. When clamping down occurs and a logger is supplied, a warning is emitted.
13
17
  */ export class ProposerTimetable extends ConsensusTimetable {
14
18
  /** Minimum block-building time (`min_block_duration`) in seconds. */ minBlockDuration;
15
19
  /** One-way proposal/attestation propagation budget (`p2p_propagation_time`) in seconds. */ p2pPropagationTime;
16
20
  /** Local checkpoint proposal preparation budget (`checkpoint_proposal_prepare_time`) in seconds. */ checkpointProposalPrepareTime;
17
21
  /** Proposer initialization budget (`checkpoint_proposal_init_time`) reserved before the first sub-slot, in seconds. */ checkpointProposalInitTime;
18
- /** Whether the proposer enforces sub-slot/start deadlines (false keeps the single-mined-block test mode). */ enforce;
19
- /** Maximum number of full-duration block sub-slots derivable from this timing config. */ maxBlocksPerCheckpoint;
22
+ /**
23
+ * Effective maximum number of block sub-slots per checkpoint: the value the local operational budgets compute,
24
+ * clamped down to the explicit network value when that value is lower. A network value above the computed
25
+ * count has no effect (the computed count is used) and is not logged.
26
+ */ maxBlocksPerCheckpoint;
20
27
  constructor(opts){
21
28
  super({
22
29
  l1Constants: opts.l1Constants,
@@ -34,21 +41,26 @@ import { ConsensusTimetable } from './consensus_timetable.js';
34
41
  this.p2pPropagationTime = budgets.p2pPropagationTime;
35
42
  this.checkpointProposalPrepareTime = budgets.checkpointProposalPrepareTime;
36
43
  this.checkpointProposalInitTime = budgets.checkpointProposalInitTime;
37
- this.enforce = opts.enforce;
38
44
  // Clamp min block duration to the block duration so a single sub-slot is always startable.
39
- this.minBlockDuration = this.blockDuration !== undefined ? Math.min(budgets.minBlockDuration, this.blockDuration) : budgets.minBlockDuration;
40
- this.maxBlocksPerCheckpoint = this.computeMaxBlocksPerCheckpoint();
45
+ this.minBlockDuration = Math.min(budgets.minBlockDuration, this.blockDuration);
46
+ const computed = this.computeMaxBlocksPerCheckpoint();
47
+ this.maxBlocksPerCheckpoint = opts.maxBlocksPerCheckpoint !== undefined ? Math.min(computed, opts.maxBlocksPerCheckpoint) : computed;
48
+ if (opts.maxBlocksPerCheckpoint !== undefined && opts.maxBlocksPerCheckpoint < computed) {
49
+ opts.logger?.warn(`Locally computed max blocks per checkpoint clamped down to the network-provided value`, {
50
+ computed,
51
+ maxBlocksPerCheckpoint: opts.maxBlocksPerCheckpoint
52
+ });
53
+ }
54
+ if (this.maxBlocksPerCheckpoint < 1) {
55
+ throw new Error(`Invalid timing configuration: derived ${this.maxBlocksPerCheckpoint} blocks per checkpoint for ` + `slot duration ${this.aztecSlotDuration}s and block duration ${this.blockDuration}s.`);
56
+ }
41
57
  }
42
58
  /**
43
59
  * Computes the maximum number of full-duration block sub-slots in a checkpoint from the already-resolved
44
60
  * budgets. Derived from the spec's `max_blocks_per_checkpoint = floor((last_block_build_time -
45
61
  * first_subslot_start) / D)`, where the first sub-slot starts one `checkpoint_proposal_init_time` (`init`)
46
- * after `build_frame_start`, so it simplifies to `floor((S - init - D - 2P - prepCp) / D)`. Single-block
47
- * mode (`blockDuration` undefined) returns 1.
62
+ * after `build_frame_start`, so it simplifies to `floor((S - init - D - 2P - prepCp) / D)`.
48
63
  */ computeMaxBlocksPerCheckpoint() {
49
- if (this.blockDuration === undefined) {
50
- return 1;
51
- }
52
64
  // last_block_build_time - (build_frame_start + init) = S - init - D - 2P - prepCp.
53
65
  const timeAvailableForBlocks = this.aztecSlotDuration - this.checkpointProposalInitTime - this.blockDuration - 2 * this.p2pPropagationTime - this.checkpointProposalPrepareTime;
54
66
  return Math.floor(timeAvailableForBlocks / this.blockDuration);
@@ -56,10 +68,9 @@ import { ConsensusTimetable } from './consensus_timetable.js';
56
68
  /**
57
69
  * Ideal time the last block must finish building by to make the ideal L1 publish path:
58
70
  * `target_slot_start - E - D - 2P - prepCp` (= `checkpoint_proposal_send_time - prepCp`). Single value;
59
- * the proposer sizes block production around the ideal L1-publish path only. In single-block mode
60
- * (`blockDuration` undefined) the `D` term drops out, since the single block is itself the final block.
71
+ * the proposer sizes block production around the ideal L1-publish path only.
61
72
  */ getLastBlockBuildTime(slot) {
62
- return this.getTargetSlotStart(slot) - this.ethereumSlotDuration - (this.blockDuration ?? 0) - 2 * this.p2pPropagationTime - this.checkpointProposalPrepareTime;
73
+ return this.getTargetSlotStart(slot) - this.ethereumSlotDuration - this.blockDuration - 2 * this.p2pPropagationTime - this.checkpointProposalPrepareTime;
63
74
  }
64
75
  /**
65
76
  * Latest start at which the proposer can still squeeze in a minimum-duration block.
@@ -68,12 +79,8 @@ import { ConsensusTimetable } from './consensus_timetable.js';
68
79
  * intentionally earlier (by `P`) than the consensus receive gate would strictly allow, and
69
80
  * conservatively no later than the final sub-slot's start cutoff in {@link selectNextSubslot}.
70
81
  *
71
- * Single-block mode (`blockDuration` undefined): `attestation_deadline - 2 * min_block_duration`,
72
- * matching {@link selectNextSubslot}'s single-block branch (which needs `min_block_duration` for
73
- * execution and another for re-execution before the attestation deadline). This keeps the build-entry
74
- * start gate from abandoning a slot that {@link selectNextSubslot} would still allow to start.
75
82
  */ getBuildStartDeadline(slot) {
76
- return this.blockDuration === undefined ? this.getAttestationDeadline(slot) - 2 * this.minBlockDuration : this.getLastBlockBuildTime(slot) - this.minBlockDuration;
83
+ return this.getLastBlockBuildTime(slot) - this.minBlockDuration;
77
84
  }
78
85
  /** Ideal L1 publish/send time: `target_slot_start - E`. Also the ideal attestation-receipt target. */ getL1PublishIdealTime(slot) {
79
86
  return this.getTargetSlotStart(slot) - this.ethereumSlotDuration;
@@ -85,7 +92,7 @@ import { ConsensusTimetable } from './consensus_timetable.js';
85
92
  * budget at the start of the build frame, so the first sub-slot still has its full duration once the
86
93
  * prologue finishes rather than being eaten by it.
87
94
  */ getBlockBuildDeadline(slot, blockIndex) {
88
- return this.getBuildFrameStart(slot) + this.checkpointProposalInitTime + (blockIndex + 1) * this.requireBlockDurationForSchedule();
95
+ return this.getBuildFrameStart(slot) + this.checkpointProposalInitTime + (blockIndex + 1) * this.blockDuration;
89
96
  }
90
97
  /** Latest time to keep waiting for txs for sub-slot `k`: `block_build_deadline(k) - min_block_duration`. */ getWaitForTxsDeadline(slot, blockIndex) {
91
98
  return this.getBlockBuildDeadline(slot, blockIndex) - this.minBlockDuration;
@@ -99,39 +106,9 @@ import { ConsensusTimetable } from './consensus_timetable.js';
99
106
  * Scans sub-slots in order and picks the first whose build deadline is at least `min_block_duration`
100
107
  * in the future. Sub-slots with insufficient remaining headroom are skipped.
101
108
  *
102
- * When enforcement is disabled, always allows building a single block with no deadline (test/sandbox
103
- * mode). In single-block mode (`blockDuration === undefined`) enforced, splits the remaining time
104
- * between execution and re-execution against the attestation deadline.
105
- *
106
109
  * @param slot - Target slot the checkpoint commits to.
107
110
  * @param now - Current wall-clock time in seconds.
108
111
  */ selectNextSubslot(slot, now) {
109
- if (!this.enforce) {
110
- return {
111
- canStart: true,
112
- index: 0,
113
- deadline: undefined,
114
- isLastBlock: true
115
- };
116
- }
117
- if (this.blockDuration === undefined) {
118
- // Single-block enforced mode: execution and re-execution run sequentially, so split the time
119
- // remaining until the attestation deadline in half.
120
- const maxAllowed = this.getAttestationDeadline(slot);
121
- const available = (maxAllowed - now) / 2;
122
- const canStart = available >= this.minBlockDuration;
123
- return canStart ? {
124
- canStart: true,
125
- index: 0,
126
- deadline: now + available,
127
- isLastBlock: true
128
- } : {
129
- canStart: false,
130
- index: undefined,
131
- deadline: undefined,
132
- isLastBlock: false
133
- };
134
- }
135
112
  const maxBlocks = this.maxBlocksPerCheckpoint;
136
113
  for(let index = 0; index < maxBlocks; index++){
137
114
  const deadline = this.getBlockBuildDeadline(slot, index);
@@ -152,10 +129,4 @@ import { ConsensusTimetable } from './consensus_timetable.js';
152
129
  isLastBlock: false
153
130
  };
154
131
  }
155
- requireBlockDurationForSchedule() {
156
- if (this.blockDuration === undefined) {
157
- throw new Error('blockDuration is required for sub-slot scheduling');
158
- }
159
- return this.blockDuration;
160
- }
161
132
  }
@@ -4,7 +4,7 @@ import type { GasFees } from '../gas/gas_fees.js';
4
4
  export interface FeeProvider {
5
5
  /** Returns the current minimum fees for inclusion in the next block. */
6
6
  getCurrentMinFees(): Promise<GasFees>;
7
- /** Returns predicted min fees for each slot in the prediction window. */
7
+ /** Returns current min fees first, followed by predicted min fees for each slot in the prediction window. */
8
8
  getPredictedMinFees(manaUsage?: ManaUsageEstimate): Promise<GasFees[]>;
9
9
  }
10
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmVlX3Byb3ZpZGVyLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdHgvZmVlX3Byb3ZpZGVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLGlCQUFpQixFQUFFLE1BQU0sb0JBQW9CLENBQUM7QUFDNUQsT0FBTyxLQUFLLEVBQUUsT0FBTyxFQUFFLE1BQU0sb0JBQW9CLENBQUM7QUFFbEQsOEVBQThFO0FBQzlFLE1BQU0sV0FBVyxXQUFXO0lBQzFCLHdFQUF3RTtJQUN4RSxpQkFBaUIsSUFBSSxPQUFPLENBQUMsT0FBTyxDQUFDLENBQUM7SUFDdEMseUVBQXlFO0lBQ3pFLG1CQUFtQixDQUFDLFNBQVMsQ0FBQyxFQUFFLGlCQUFpQixHQUFHLE9BQU8sQ0FBQyxPQUFPLEVBQUUsQ0FBQyxDQUFDO0NBQ3hFIn0=
10
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmVlX3Byb3ZpZGVyLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdHgvZmVlX3Byb3ZpZGVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLGlCQUFpQixFQUFFLE1BQU0sb0JBQW9CLENBQUM7QUFDNUQsT0FBTyxLQUFLLEVBQUUsT0FBTyxFQUFFLE1BQU0sb0JBQW9CLENBQUM7QUFFbEQsOEVBQThFO0FBQzlFLE1BQU0sV0FBVyxXQUFXO0lBQzFCLHdFQUF3RTtJQUN4RSxpQkFBaUIsSUFBSSxPQUFPLENBQUMsT0FBTyxDQUFDLENBQUM7SUFDdEMsNkdBQTZHO0lBQzdHLG1CQUFtQixDQUFDLFNBQVMsQ0FBQyxFQUFFLGlCQUFpQixHQUFHLE9BQU8sQ0FBQyxPQUFPLEVBQUUsQ0FBQyxDQUFDO0NBQ3hFIn0=
@@ -1 +1 @@
1
- {"version":3,"file":"fee_provider.d.ts","sourceRoot":"","sources":["../../src/tx/fee_provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAElD,8EAA8E;AAC9E,MAAM,WAAW,WAAW;IAC1B,wEAAwE;IACxE,iBAAiB,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IACtC,yEAAyE;IACzE,mBAAmB,CAAC,SAAS,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;CACxE"}
1
+ {"version":3,"file":"fee_provider.d.ts","sourceRoot":"","sources":["../../src/tx/fee_provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAElD,8EAA8E;AAC9E,MAAM,WAAW,WAAW;IAC1B,wEAAwE;IACxE,iBAAiB,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IACtC,6GAA6G;IAC7G,mBAAmB,CAAC,SAAS,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;CACxE"}
@@ -1,7 +1,7 @@
1
1
  export declare const TX_ERROR_INSUFFICIENT_FEE_PER_GAS = "Insufficient fee per gas";
2
2
  export declare const TX_ERROR_INSUFFICIENT_FEE_PAYER_BALANCE = "Insufficient fee payer balance";
3
3
  export declare const TX_ERROR_INSUFFICIENT_GAS_LIMIT = "Gas limit is below the minimum fixed cost";
4
- export declare const TX_ERROR_GAS_LIMIT_TOO_HIGH = "Gas limit is higher than the amount of gas that the AVM can process";
4
+ export declare const TX_ERROR_GAS_LIMIT_TOO_HIGH = "Gas limit is higher than the maximum amount of gas this network allows per tx";
5
5
  export declare const TX_ERROR_SETUP_FUNCTION_NOT_ALLOWED = "Setup function not on allow list";
6
6
  export declare const TX_ERROR_SETUP_FUNCTION_UNKNOWN_CONTRACT = "Setup function targets unknown contract";
7
7
  export declare const TX_ERROR_SETUP_ONLY_SELF_WRONG_SENDER = "Setup only_self function called with incorrect msg_sender";
@@ -30,4 +30,4 @@ export declare const TX_ERROR_MALFORMED_CONTRACT_INSTANCE_LOG = "Failed to parse
30
30
  export declare const TX_ERROR_INCORRECT_CONTRACT_CLASS_ID = "Incorrect contract class id";
31
31
  export declare const TX_ERROR_MALFORMED_CONTRACT_CLASS_LOG = "Failed to parse contract class registration log";
32
32
  export declare const TX_ERROR_DURING_VALIDATION = "Unexpected error during validation";
33
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXJyb3JfdGV4dHMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy90eC92YWxpZGF0b3IvZXJyb3JfdGV4dHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0EsZUFBTyxNQUFNLGlDQUFpQyw2QkFBNkIsQ0FBQztBQUM1RSxlQUFPLE1BQU0sdUNBQXVDLG1DQUFtQyxDQUFDO0FBQ3hGLGVBQU8sTUFBTSwrQkFBK0IsOENBQThDLENBQUM7QUFDM0YsZUFBTyxNQUFNLDJCQUEyQix3RUFBd0UsQ0FBQztBQUdqSCxlQUFPLE1BQU0sbUNBQW1DLHFDQUFxQyxDQUFDO0FBQ3RGLGVBQU8sTUFBTSx3Q0FBd0MsNENBQTRDLENBQUM7QUFDbEcsZUFBTyxNQUFNLHFDQUFxQyw4REFBOEQsQ0FBQztBQUNqSCxlQUFPLE1BQU0sOEJBQThCLCtDQUErQyxDQUFDO0FBQzNGLGVBQU8sTUFBTSxvQ0FBb0MscURBQXFELENBQUM7QUFHdkcsZUFBTyxNQUFNLGtDQUFrQyw4QkFBOEIsQ0FBQztBQUM5RSxlQUFPLE1BQU0sMkJBQTJCLHVCQUF1QixDQUFDO0FBR2hFLGVBQU8sTUFBTSxxQ0FBcUMsaUNBQWlDLENBQUM7QUFDcEYsZUFBTyxNQUFNLDhCQUE4QiwwQkFBMEIsQ0FBQ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oC,qDAAqD,CAAC;AAGvG,eAAO,MAAM,kCAAkC,8BAA8B,CAAC;AAC9E,eAAO,MAAM,2BAA2B,uBAAuB,CAAC;AAGhE,eAAO,MAAM,qCAAqC,iCAAiC,CAAC;AACpF,eAAO,MAAM,8BAA8B,0BAA0B,CAAC;AACtE,eAAO,MAAM,iCAAiC,6BAA6B,CAAC;AAC5E,eAAO,MAAM,+BAA+B,0CAA0C,CAAC;AACvF,eAAO,MAAM,0CAA0C,sCAAsC,CAAC;AAG9F,eAAO,MAAM,sBAAsB,kBAAkB,CAAC;AAGtD,eAAO,MAAM,2BAA2B,uCAAuC,CAAC;AAChF,eAAO,MAAM,gCAAgC,8CAA8C,CAAC;AAC5F,eAAO,MAAM,iCAAiC,uDAAuD,CAAC;AACtG,eAAO,MAAM,iCAAiC,6CAA6C,CAAC;AAC5F,eAAO,MAAM,kCAAkC,yCAAyC,CAAC;AACzF,eAAO,MAAM,4BAA4B,mCAAmC,CAAC;AAC7E,eAAO,MAAM,mCAAmC,2CAA2C,CAAC;AAC5F,eAAO,MAAM,uBAAuB,sBAAsB,CAAC;AAG3D,eAAO,MAAM,yBAAyB,sCAAsC,CAAC;AAG7E,eAAO,MAAM,qBAAqB,2BAA2B,CAAC;AAG9D,eAAO,MAAM,mCAAmC,mDAAmD,CAAC;AACpG,eAAO,MAAM,wCAAwC,qDAAqD,CAAC;AAG3G,eAAO,MAAM,oCAAoC,gCAAgC,CAAC;AAClF,eAAO,MAAM,qCAAqC,oDAAoD,CAAC;AAGvG,eAAO,MAAM,0BAA0B,uCAAuC,CAAC"}
@@ -2,7 +2,7 @@
2
2
  export const TX_ERROR_INSUFFICIENT_FEE_PER_GAS = 'Insufficient fee per gas';
3
3
  export const TX_ERROR_INSUFFICIENT_FEE_PAYER_BALANCE = 'Insufficient fee payer balance';
4
4
  export const TX_ERROR_INSUFFICIENT_GAS_LIMIT = 'Gas limit is below the minimum fixed cost';
5
- export const TX_ERROR_GAS_LIMIT_TOO_HIGH = 'Gas limit is higher than the amount of gas that the AVM can process';
5
+ export const TX_ERROR_GAS_LIMIT_TOO_HIGH = 'Gas limit is higher than the maximum amount of gas this network allows per tx';
6
6
  // Phases
7
7
  export const TX_ERROR_SETUP_FUNCTION_NOT_ALLOWED = 'Setup function not on allow list';
8
8
  export const TX_ERROR_SETUP_FUNCTION_UNKNOWN_CONTRACT = 'Setup function targets unknown contract';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/stdlib",
3
- "version": "5.0.0-nightly.20260611",
3
+ "version": "5.0.0-nightly.20260613",
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": "5.0.0-nightly.20260611",
96
- "@aztec/blob-lib": "5.0.0-nightly.20260611",
97
- "@aztec/constants": "5.0.0-nightly.20260611",
98
- "@aztec/ethereum": "5.0.0-nightly.20260611",
99
- "@aztec/foundation": "5.0.0-nightly.20260611",
100
- "@aztec/l1-artifacts": "5.0.0-nightly.20260611",
101
- "@aztec/noir-noirc_abi": "5.0.0-nightly.20260611",
95
+ "@aztec/bb.js": "5.0.0-nightly.20260613",
96
+ "@aztec/blob-lib": "5.0.0-nightly.20260613",
97
+ "@aztec/constants": "5.0.0-nightly.20260613",
98
+ "@aztec/ethereum": "5.0.0-nightly.20260613",
99
+ "@aztec/foundation": "5.0.0-nightly.20260613",
100
+ "@aztec/l1-artifacts": "5.0.0-nightly.20260613",
101
+ "@aztec/noir-noirc_abi": "5.0.0-nightly.20260613",
102
102
  "@google-cloud/storage": "^7.15.0",
103
103
  "axios": "^1.15.1",
104
104
  "json-stringify-deterministic": "1.0.12",
@@ -351,6 +351,13 @@ export type L2Tips = {
351
351
  finalized: L2TipId;
352
352
  };
353
353
 
354
+ /**
355
+ * Tips of the L2 chain as tracked by a local provider (world-state, l2-tips-store). Omits
356
+ * `proposedCheckpoint`, which is degenerate in local stores (always equal to `checkpointed`) and
357
+ * is only meaningful on the archiver side via {@link L2BlockSource}.
358
+ */
359
+ export type LocalL2Tips = Omit<L2Tips, 'proposedCheckpoint'>;
360
+
354
361
  export const GENESIS_CHECKPOINT_HEADER_HASH = CheckpointHeader.empty().hash();
355
362
 
356
363
  /** Identifies a block by number and hash. */
@@ -1,14 +1,38 @@
1
+ import type { BlockNumber } from '@aztec/foundation/branded-types';
2
+
1
3
  import type { PublishedCheckpoint } from '../../checkpoint/published_checkpoint.js';
2
4
  import type { L2Block } from '../l2_block.js';
3
- import type { CheckpointId, L2BlockId, L2Tips } from '../l2_block_source.js';
5
+ import type { CheckpointId, L2BlockId, L2TipId, LocalL2Tips } from '../l2_block_source.js';
4
6
 
5
7
  /** Provides the current chain tips. Implemented by world-state, l2-tips-store, and AztecNode. */
6
8
  export interface L2TipsProvider {
7
- getL2Tips(): Promise<L2Tips>;
9
+ getL2Tips(): Promise<LocalL2Tips>;
8
10
  }
9
11
 
10
- /** Interface to the local view of the chain. Implemented by world-state and l2-tips-store. */
11
- export interface L2BlockStreamLocalDataProvider extends L2TipsProvider {
12
+ /**
13
+ * A block id reported by a local data provider, whose hash may be unknown when the provider cannot resolve it (e.g.
14
+ * world-state cannot resolve the hash of a proven tip ahead of its synced range).
15
+ */
16
+ export type LocalL2BlockId = { number: BlockNumber; hash?: string };
17
+
18
+ /**
19
+ * Minimal local view of the chain the block stream needs to drive sync. `checkpointed` is only required when the
20
+ * stream emits checkpoint events (i.e. `ignoreCheckpoints` is off).
21
+ */
22
+ export type LocalChainTips = {
23
+ proposed: LocalL2BlockId;
24
+ checkpointed?: { checkpoint: CheckpointId };
25
+ proven: { block: LocalL2BlockId };
26
+ finalized: { block: LocalL2BlockId };
27
+ };
28
+
29
+ /**
30
+ * Interface to the local view of the chain. Implemented by world-state and l2-tips-store. Anything implementing
31
+ * {@link L2TipsProvider} also satisfies this contract structurally, since {@link LocalL2Tips} is assignable to
32
+ * {@link LocalChainTips}.
33
+ */
34
+ export interface L2BlockStreamLocalDataProvider {
35
+ getL2Tips(): Promise<LocalChainTips>;
12
36
  getL2BlockHash(number: number): Promise<string | undefined>;
13
37
  }
14
38
 
@@ -30,19 +54,27 @@ export type L2BlockStreamEvent =
30
54
  | /**
31
55
  * Reports last correct block (new tip of the proposed chain). Note that this is not necessarily the anchor block
32
56
  * that will be used in the transaction - if the chain has already moved past the reorg, we'll also see blocks-added
33
- * events that will push the anchor block forward.
57
+ * events that will push the anchor block forward. `block` is the prune target (the new proposed tip); `checkpointed`
58
+ * and `proven` are the source's confirmed checkpointed and proven tips (each a block and checkpoint id). Each is used
59
+ * to clamp the corresponding local cursor when it leads the source tip, so a cursor never overshoots its own source
60
+ * frontier during a prune (the source guarantees proven <= checkpointed).
34
61
  */ {
35
62
  type: 'chain-pruned';
36
63
  block: L2BlockId;
37
- checkpoint: CheckpointId;
64
+ checkpointed: L2TipId;
65
+ proven: L2TipId;
38
66
  }
39
67
  | /** Reports new proven block. */ {
40
68
  type: 'chain-proven';
41
69
  block: L2BlockId;
70
+ checkpoint: CheckpointId;
42
71
  }
43
72
  | /** Reports new finalized block (proven and finalized on L1). */ {
44
73
  type: 'chain-finalized';
45
74
  block: L2BlockId;
75
+ checkpoint: CheckpointId;
46
76
  };
47
77
 
48
- export type L2TipsStore = L2BlockStreamEventHandler & L2BlockStreamLocalDataProvider;
78
+ export type L2TipsStore = L2BlockStreamEventHandler &
79
+ L2TipsProvider &
80
+ Pick<L2BlockStreamLocalDataProvider, 'getL2BlockHash'>;
@@ -70,6 +70,13 @@ export class L2BlockStream {
70
70
  const localTips = await this.localData.getL2Tips();
71
71
  this.log.trace(`Running L2 block stream`, { sourceTips, localTips });
72
72
 
73
+ if (!this.opts.ignoreCheckpoints && localTips.checkpointed === undefined) {
74
+ throw new Error(
75
+ 'Local data provider does not expose a checkpointed tip; checkpoint events require one ' +
76
+ '(set ignoreCheckpoints or provide checkpointed tips).',
77
+ );
78
+ }
79
+
73
80
  // Check if there was a reorg and emit a chain-pruned event if so.
74
81
  let latestBlockNumber = localTips.proposed.number;
75
82
  const sourceCache = new BlockHashCache([sourceTips.proposed]);
@@ -105,7 +112,8 @@ export class L2BlockStream {
105
112
  await this.emitEvent({
106
113
  type: 'chain-pruned',
107
114
  block: makeL2BlockId(latestBlockNumber, hash),
108
- checkpoint: sourceTips.checkpointed.checkpoint,
115
+ checkpointed: sourceTips.checkpointed,
116
+ proven: sourceTips.proven,
109
117
  });
110
118
  }
111
119
 
@@ -122,7 +130,12 @@ export class L2BlockStream {
122
130
  }
123
131
 
124
132
  let nextBlockNumber = latestBlockNumber + 1;
125
- let nextCheckpointToEmit = CheckpointNumber(localTips.checkpointed.checkpoint.number + 1);
133
+ // When checkpoints are ignored the local provider may omit `checkpointed`; in that case the fallback to
134
+ // CheckpointNumber.ZERO is harmless because `nextCheckpointToEmit` is never consumed for emission (Loop 1 and
135
+ // the startingBlock/skipFinalized adjustments below only feed checkpoint emission, which is gated off).
136
+ let nextCheckpointToEmit = CheckpointNumber(
137
+ (localTips.checkpointed?.checkpoint.number ?? CheckpointNumber.ZERO) + 1,
138
+ );
126
139
 
127
140
  // When startingBlock is set, also skip ahead for checkpoints.
128
141
  if (
@@ -261,10 +274,15 @@ export class L2BlockStream {
261
274
  await this.emitEvent({
262
275
  type: 'chain-proven',
263
276
  block: sourceTips.proven.block,
277
+ checkpoint: sourceTips.proven.checkpoint,
264
278
  });
265
279
  }
266
280
  if (localTips.finalized !== undefined && sourceTips.finalized.block.number !== localTips.finalized.block.number) {
267
- await this.emitEvent({ type: 'chain-finalized', block: sourceTips.finalized.block });
281
+ await this.emitEvent({
282
+ type: 'chain-finalized',
283
+ block: sourceTips.finalized.block,
284
+ checkpoint: sourceTips.finalized.checkpoint,
285
+ });
268
286
  }
269
287
  } catch (err: any) {
270
288
  if (err.name === 'AbortError') {
@@ -1,8 +1,7 @@
1
- import { BlockNumber, CheckpointNumber } from '@aztec/foundation/branded-types';
1
+ import type { BlockNumber } from '@aztec/foundation/branded-types';
2
2
 
3
- import type { PublishedCheckpoint } from '../../checkpoint/published_checkpoint.js';
4
3
  import type { BlockHash } from '../block_hash.js';
5
- import type { L2BlockTag } from '../l2_block_source.js';
4
+ import type { CheckpointId, L2BlockTag } from '../l2_block_source.js';
6
5
  import { L2TipsStoreBase } from './l2_tips_store_base.js';
7
6
 
8
7
  /**
@@ -15,9 +14,8 @@ export class L2TipsMemoryStore extends L2TipsStoreBase {
15
14
  }
16
15
 
17
16
  private readonly tips = new Map<L2BlockTag, BlockNumber>();
17
+ private readonly tipCheckpoints = new Map<L2BlockTag, CheckpointId>();
18
18
  private readonly blockHashes = new Map<number, string>();
19
- private readonly blockToCheckpoint = new Map<number, CheckpointNumber>();
20
- private readonly checkpoints = new Map<number, PublishedCheckpoint>();
21
19
 
22
20
  protected getTip(tag: L2BlockTag): Promise<BlockNumber | undefined> {
23
21
  return Promise.resolve(this.tips.get(tag));
@@ -28,6 +26,15 @@ export class L2TipsMemoryStore extends L2TipsStoreBase {
28
26
  return Promise.resolve();
29
27
  }
30
28
 
29
+ protected getTipCheckpoint(tag: L2BlockTag): Promise<CheckpointId | undefined> {
30
+ return Promise.resolve(this.tipCheckpoints.get(tag));
31
+ }
32
+
33
+ protected setTipCheckpoint(tag: L2BlockTag, checkpoint: CheckpointId): Promise<void> {
34
+ this.tipCheckpoints.set(tag, checkpoint);
35
+ return Promise.resolve();
36
+ }
37
+
31
38
  protected getStoredBlockHash(blockNumber: BlockNumber): Promise<string | undefined> {
32
39
  return Promise.resolve(this.blockHashes.get(blockNumber));
33
40
  }
@@ -46,42 +53,6 @@ export class L2TipsMemoryStore extends L2TipsStoreBase {
46
53
  return Promise.resolve();
47
54
  }
48
55
 
49
- protected getCheckpointNumberForBlock(blockNumber: BlockNumber): Promise<CheckpointNumber | undefined> {
50
- return Promise.resolve(this.blockToCheckpoint.get(blockNumber));
51
- }
52
-
53
- protected setCheckpointNumberForBlock(blockNumber: BlockNumber, checkpointNumber: CheckpointNumber): Promise<void> {
54
- this.blockToCheckpoint.set(blockNumber, checkpointNumber);
55
- return Promise.resolve();
56
- }
57
-
58
- protected deleteBlockToCheckpointBefore(blockNumber: BlockNumber): Promise<void> {
59
- for (const key of this.blockToCheckpoint.keys()) {
60
- if (key < blockNumber) {
61
- this.blockToCheckpoint.delete(key);
62
- }
63
- }
64
- return Promise.resolve();
65
- }
66
-
67
- protected getCheckpoint(checkpointNumber: CheckpointNumber): Promise<PublishedCheckpoint | undefined> {
68
- return Promise.resolve(this.checkpoints.get(checkpointNumber));
69
- }
70
-
71
- protected saveCheckpointData(checkpoint: PublishedCheckpoint): Promise<void> {
72
- this.checkpoints.set(checkpoint.checkpoint.number, checkpoint);
73
- return Promise.resolve();
74
- }
75
-
76
- protected deleteCheckpointsBefore(checkpointNumber: CheckpointNumber): Promise<void> {
77
- for (const key of this.checkpoints.keys()) {
78
- if (key < checkpointNumber) {
79
- this.checkpoints.delete(key);
80
- }
81
- }
82
- return Promise.resolve();
83
- }
84
-
85
56
  protected runInTransaction<T>(fn: () => Promise<T>): Promise<T> {
86
57
  // Memory store doesn't need transactions - just execute immediately
87
58
  return fn();