@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.
- package/dest/block/l2_block_source.d.ts +7 -1
- package/dest/block/l2_block_source.d.ts.map +1 -1
- package/dest/block/l2_block_stream/interfaces.d.ts +44 -8
- package/dest/block/l2_block_stream/interfaces.d.ts.map +1 -1
- package/dest/block/l2_block_stream/l2_block_stream.d.ts +1 -1
- package/dest/block/l2_block_stream/l2_block_stream.d.ts.map +1 -1
- package/dest/block/l2_block_stream/l2_block_stream.js +13 -4
- package/dest/block/l2_block_stream/l2_tips_memory_store.d.ts +6 -12
- package/dest/block/l2_block_stream/l2_tips_memory_store.d.ts.map +1 -1
- package/dest/block/l2_block_stream/l2_tips_memory_store.js +8 -32
- package/dest/block/l2_block_stream/l2_tips_store_base.d.ts +9 -18
- package/dest/block/l2_block_stream/l2_tips_store_base.d.ts.map +1 -1
- package/dest/block/l2_block_stream/l2_tips_store_base.js +52 -58
- package/dest/block/test/l2_tips_store_test_suite.d.ts +1 -1
- package/dest/block/test/l2_tips_store_test_suite.d.ts.map +1 -1
- package/dest/block/test/l2_tips_store_test_suite.js +202 -34
- package/dest/config/index.d.ts +2 -1
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +1 -0
- package/dest/config/network-consensus-config.d.ts +72 -0
- package/dest/config/network-consensus-config.d.ts.map +1 -0
- package/dest/config/network-consensus-config.js +231 -0
- package/dest/config/sequencer-config.d.ts +3 -1
- package/dest/config/sequencer-config.d.ts.map +1 -1
- package/dest/config/sequencer-config.js +5 -4
- package/dest/contract/interfaces/node-info.d.ts +11 -1
- package/dest/contract/interfaces/node-info.d.ts.map +1 -1
- package/dest/contract/interfaces/node-info.js +7 -1
- package/dest/gas/gas_settings.d.ts +7 -13
- package/dest/gas/gas_settings.d.ts.map +1 -1
- package/dest/gas/gas_settings.js +9 -16
- package/dest/gas/index.d.ts +2 -1
- package/dest/gas/index.d.ts.map +1 -1
- package/dest/gas/index.js +1 -0
- package/dest/gas/tx_gas_limits.d.ts +72 -0
- package/dest/gas/tx_gas_limits.d.ts.map +1 -0
- package/dest/gas/tx_gas_limits.js +85 -0
- package/dest/interfaces/aztec-node-admin.d.ts +18 -17
- package/dest/interfaces/aztec-node-admin.d.ts.map +1 -1
- package/dest/interfaces/aztec-node-admin.js +1 -1
- package/dest/interfaces/aztec-node-debug.d.ts +15 -2
- package/dest/interfaces/aztec-node-debug.d.ts.map +1 -1
- package/dest/interfaces/aztec-node-debug.js +9 -1
- package/dest/interfaces/aztec-node.d.ts +40 -11
- package/dest/interfaces/aztec-node.d.ts.map +1 -1
- package/dest/interfaces/aztec-node.js +42 -5
- package/dest/interfaces/block-builder.d.ts +3 -1
- package/dest/interfaces/block-builder.d.ts.map +1 -1
- package/dest/interfaces/client.d.ts +2 -1
- package/dest/interfaces/client.d.ts.map +1 -1
- package/dest/interfaces/configs.d.ts +12 -6
- package/dest/interfaces/configs.d.ts.map +1 -1
- package/dest/interfaces/configs.js +2 -1
- package/dest/interfaces/get_tx_by_hash_options.d.ts +9 -0
- package/dest/interfaces/get_tx_by_hash_options.d.ts.map +1 -0
- package/dest/interfaces/get_tx_by_hash_options.js +4 -0
- package/dest/interfaces/p2p.d.ts +32 -8
- package/dest/interfaces/p2p.d.ts.map +1 -1
- package/dest/interfaces/p2p.js +12 -2
- package/dest/interfaces/proving-job.d.ts +70 -70
- package/dest/interfaces/validator.d.ts +3 -3
- package/dest/interfaces/validator.d.ts.map +1 -1
- package/dest/interfaces/validator.js +1 -1
- package/dest/tests/factories.d.ts +1 -1
- package/dest/tests/factories.d.ts.map +1 -1
- package/dest/tests/factories.js +4 -1
- package/dest/tests/mocks.d.ts +1 -1
- package/dest/tests/mocks.d.ts.map +1 -1
- package/dest/tests/mocks.js +3 -2
- package/dest/timetable/budgets.d.ts +4 -2
- package/dest/timetable/budgets.d.ts.map +1 -1
- package/dest/timetable/budgets.js +2 -1
- package/dest/timetable/build_proposer_timetable.d.ts +21 -0
- package/dest/timetable/build_proposer_timetable.d.ts.map +1 -0
- package/dest/timetable/build_proposer_timetable.js +17 -0
- package/dest/timetable/consensus_timetable.d.ts +5 -7
- package/dest/timetable/consensus_timetable.d.ts.map +1 -1
- package/dest/timetable/consensus_timetable.js +6 -8
- package/dest/timetable/index.d.ts +2 -1
- package/dest/timetable/index.d.ts.map +1 -1
- package/dest/timetable/index.js +1 -0
- package/dest/timetable/proposer_timetable.d.ts +18 -24
- package/dest/timetable/proposer_timetable.d.ts.map +1 -1
- package/dest/timetable/proposer_timetable.js +26 -55
- package/dest/tx/fee_provider.d.ts +2 -2
- package/dest/tx/fee_provider.d.ts.map +1 -1
- package/dest/tx/validator/error_texts.d.ts +2 -2
- package/dest/tx/validator/error_texts.d.ts.map +1 -1
- package/dest/tx/validator/error_texts.js +1 -1
- package/package.json +8 -8
- package/src/block/l2_block_source.ts +7 -0
- package/src/block/l2_block_stream/interfaces.ts +39 -7
- package/src/block/l2_block_stream/l2_block_stream.ts +21 -3
- package/src/block/l2_block_stream/l2_tips_memory_store.ts +12 -41
- package/src/block/l2_block_stream/l2_tips_store_base.ts +63 -93
- package/src/block/test/l2_tips_store_test_suite.ts +197 -24
- package/src/config/index.ts +1 -0
- package/src/config/network-consensus-config.ts +302 -0
- package/src/config/sequencer-config.ts +7 -5
- package/src/contract/interfaces/node-info.ts +11 -0
- package/src/gas/README.md +92 -0
- package/src/gas/gas_settings.ts +11 -21
- package/src/gas/index.ts +1 -0
- package/src/gas/tx_gas_limits.ts +123 -0
- package/src/interfaces/aztec-node-admin.ts +1 -1
- package/src/interfaces/aztec-node-debug.ts +17 -2
- package/src/interfaces/aztec-node.ts +74 -13
- package/src/interfaces/block-builder.ts +2 -0
- package/src/interfaces/client.ts +1 -0
- package/src/interfaces/configs.ts +10 -6
- package/src/interfaces/get_tx_by_hash_options.ts +14 -0
- package/src/interfaces/p2p.ts +21 -8
- package/src/interfaces/validator.ts +5 -5
- package/src/tests/factories.ts +7 -1
- package/src/tests/mocks.ts +7 -2
- package/src/timetable/README.md +10 -2
- package/src/timetable/budgets.ts +5 -2
- package/src/timetable/build_proposer_timetable.ts +42 -0
- package/src/timetable/consensus_timetable.ts +8 -14
- package/src/timetable/index.ts +1 -0
- package/src/timetable/proposer_timetable.ts +37 -61
- package/src/tx/fee_provider.ts +1 -1
- package/src/tx/validator/error_texts.ts +2 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { SlotNumber } from '@aztec/foundation/branded-types';
|
|
2
|
+
import type { Logger } from '@aztec/foundation/log';
|
|
2
3
|
|
|
3
4
|
import { type ResolvedTimingBudgets, getDefaultCheckpointProposalSyncGrace, resolveTimingBudgets } from './budgets.js';
|
|
4
5
|
import { ConsensusTimetable, type SlotTimingConstants } from './consensus_timetable.js';
|
|
5
6
|
|
|
6
7
|
/** Result of selecting the next block sub-slot to build. */
|
|
7
8
|
export type SubslotSelection =
|
|
8
|
-
| { canStart: true; index: number; deadline: undefined; isLastBlock: true }
|
|
9
9
|
| { canStart: false; index: undefined; deadline: undefined; isLastBlock: false }
|
|
10
10
|
| { canStart: true; index: number; deadline: number; isLastBlock: boolean };
|
|
11
11
|
|
|
@@ -19,6 +19,10 @@ export type SubslotSelection =
|
|
|
19
19
|
*
|
|
20
20
|
* The single hard deadline {@link getAttestationDeadline} is inherited from the composed
|
|
21
21
|
* {@link ConsensusTimetable}, so the proposer uses one object.
|
|
22
|
+
*
|
|
23
|
+
* `maxBlocksPerCheckpoint` is computed from the local operational budgets and then clamped down to the optional
|
|
24
|
+
* network-provided value when that value is lower; a network value at or above the computed count leaves the
|
|
25
|
+
* computed count in effect. When clamping down occurs and a logger is supplied, a warning is emitted.
|
|
22
26
|
*/
|
|
23
27
|
export class ProposerTimetable extends ConsensusTimetable {
|
|
24
28
|
/** Minimum block-building time (`min_block_duration`) in seconds. */
|
|
@@ -33,21 +37,25 @@ export class ProposerTimetable extends ConsensusTimetable {
|
|
|
33
37
|
/** Proposer initialization budget (`checkpoint_proposal_init_time`) reserved before the first sub-slot, in seconds. */
|
|
34
38
|
public readonly checkpointProposalInitTime: number;
|
|
35
39
|
|
|
36
|
-
/**
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
+
/**
|
|
41
|
+
* Effective maximum number of block sub-slots per checkpoint: the value the local operational budgets compute,
|
|
42
|
+
* clamped down to the explicit network value when that value is lower. A network value above the computed
|
|
43
|
+
* count has no effect (the computed count is used) and is not logged.
|
|
44
|
+
*/
|
|
40
45
|
public readonly maxBlocksPerCheckpoint: number;
|
|
41
46
|
|
|
42
47
|
constructor(opts: {
|
|
43
48
|
l1Constants: SlotTimingConstants;
|
|
44
|
-
blockDuration: number
|
|
49
|
+
blockDuration: number;
|
|
45
50
|
minBlockDuration: number;
|
|
46
51
|
p2pPropagationTime: number;
|
|
47
52
|
checkpointProposalPrepareTime: number;
|
|
48
53
|
checkpointProposalInitTime: number;
|
|
49
54
|
checkpointProposalSyncGrace?: number;
|
|
50
|
-
|
|
55
|
+
/** Explicit network max blocks per checkpoint; the effective value is clamped down to this when it is lower. */
|
|
56
|
+
maxBlocksPerCheckpoint?: number;
|
|
57
|
+
/** Optional logger; warns when the local budgets compute more blocks than the network value allows. */
|
|
58
|
+
logger?: Logger;
|
|
51
59
|
}) {
|
|
52
60
|
super({
|
|
53
61
|
l1Constants: opts.l1Constants,
|
|
@@ -67,29 +75,34 @@ export class ProposerTimetable extends ConsensusTimetable {
|
|
|
67
75
|
this.p2pPropagationTime = budgets.p2pPropagationTime;
|
|
68
76
|
this.checkpointProposalPrepareTime = budgets.checkpointProposalPrepareTime;
|
|
69
77
|
this.checkpointProposalInitTime = budgets.checkpointProposalInitTime;
|
|
70
|
-
this.enforce = opts.enforce;
|
|
71
78
|
|
|
72
79
|
// Clamp min block duration to the block duration so a single sub-slot is always startable.
|
|
73
|
-
this.minBlockDuration =
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
80
|
+
this.minBlockDuration = Math.min(budgets.minBlockDuration, this.blockDuration);
|
|
81
|
+
|
|
82
|
+
const computed = this.computeMaxBlocksPerCheckpoint();
|
|
83
|
+
this.maxBlocksPerCheckpoint =
|
|
84
|
+
opts.maxBlocksPerCheckpoint !== undefined ? Math.min(computed, opts.maxBlocksPerCheckpoint) : computed;
|
|
85
|
+
if (opts.maxBlocksPerCheckpoint !== undefined && opts.maxBlocksPerCheckpoint < computed) {
|
|
86
|
+
opts.logger?.warn(`Locally computed max blocks per checkpoint clamped down to the network-provided value`, {
|
|
87
|
+
computed,
|
|
88
|
+
maxBlocksPerCheckpoint: opts.maxBlocksPerCheckpoint,
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
if (this.maxBlocksPerCheckpoint < 1) {
|
|
92
|
+
throw new Error(
|
|
93
|
+
`Invalid timing configuration: derived ${this.maxBlocksPerCheckpoint} blocks per checkpoint for ` +
|
|
94
|
+
`slot duration ${this.aztecSlotDuration}s and block duration ${this.blockDuration}s.`,
|
|
95
|
+
);
|
|
96
|
+
}
|
|
79
97
|
}
|
|
80
98
|
|
|
81
99
|
/**
|
|
82
100
|
* Computes the maximum number of full-duration block sub-slots in a checkpoint from the already-resolved
|
|
83
101
|
* budgets. Derived from the spec's `max_blocks_per_checkpoint = floor((last_block_build_time -
|
|
84
102
|
* first_subslot_start) / D)`, where the first sub-slot starts one `checkpoint_proposal_init_time` (`init`)
|
|
85
|
-
* after `build_frame_start`, so it simplifies to `floor((S - init - D - 2P - prepCp) / D)`.
|
|
86
|
-
* mode (`blockDuration` undefined) returns 1.
|
|
103
|
+
* after `build_frame_start`, so it simplifies to `floor((S - init - D - 2P - prepCp) / D)`.
|
|
87
104
|
*/
|
|
88
105
|
private computeMaxBlocksPerCheckpoint(): number {
|
|
89
|
-
if (this.blockDuration === undefined) {
|
|
90
|
-
return 1;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
106
|
// last_block_build_time - (build_frame_start + init) = S - init - D - 2P - prepCp.
|
|
94
107
|
const timeAvailableForBlocks =
|
|
95
108
|
this.aztecSlotDuration -
|
|
@@ -103,14 +116,13 @@ export class ProposerTimetable extends ConsensusTimetable {
|
|
|
103
116
|
/**
|
|
104
117
|
* Ideal time the last block must finish building by to make the ideal L1 publish path:
|
|
105
118
|
* `target_slot_start - E - D - 2P - prepCp` (= `checkpoint_proposal_send_time - prepCp`). Single value;
|
|
106
|
-
* the proposer sizes block production around the ideal L1-publish path only.
|
|
107
|
-
* (`blockDuration` undefined) the `D` term drops out, since the single block is itself the final block.
|
|
119
|
+
* the proposer sizes block production around the ideal L1-publish path only.
|
|
108
120
|
*/
|
|
109
121
|
public getLastBlockBuildTime(slot: SlotNumber): number {
|
|
110
122
|
return (
|
|
111
123
|
this.getTargetSlotStart(slot) -
|
|
112
124
|
this.ethereumSlotDuration -
|
|
113
|
-
|
|
125
|
+
this.blockDuration -
|
|
114
126
|
2 * this.p2pPropagationTime -
|
|
115
127
|
this.checkpointProposalPrepareTime
|
|
116
128
|
);
|
|
@@ -123,15 +135,9 @@ export class ProposerTimetable extends ConsensusTimetable {
|
|
|
123
135
|
* intentionally earlier (by `P`) than the consensus receive gate would strictly allow, and
|
|
124
136
|
* conservatively no later than the final sub-slot's start cutoff in {@link selectNextSubslot}.
|
|
125
137
|
*
|
|
126
|
-
* Single-block mode (`blockDuration` undefined): `attestation_deadline - 2 * min_block_duration`,
|
|
127
|
-
* matching {@link selectNextSubslot}'s single-block branch (which needs `min_block_duration` for
|
|
128
|
-
* execution and another for re-execution before the attestation deadline). This keeps the build-entry
|
|
129
|
-
* start gate from abandoning a slot that {@link selectNextSubslot} would still allow to start.
|
|
130
138
|
*/
|
|
131
139
|
public getBuildStartDeadline(slot: SlotNumber): number {
|
|
132
|
-
return this.
|
|
133
|
-
? this.getAttestationDeadline(slot) - 2 * this.minBlockDuration
|
|
134
|
-
: this.getLastBlockBuildTime(slot) - this.minBlockDuration;
|
|
140
|
+
return this.getLastBlockBuildTime(slot) - this.minBlockDuration;
|
|
135
141
|
}
|
|
136
142
|
|
|
137
143
|
/** Ideal L1 publish/send time: `target_slot_start - E`. Also the ideal attestation-receipt target. */
|
|
@@ -147,11 +153,7 @@ export class ProposerTimetable extends ConsensusTimetable {
|
|
|
147
153
|
* prologue finishes rather than being eaten by it.
|
|
148
154
|
*/
|
|
149
155
|
public getBlockBuildDeadline(slot: SlotNumber, blockIndex: number): number {
|
|
150
|
-
return (
|
|
151
|
-
this.getBuildFrameStart(slot) +
|
|
152
|
-
this.checkpointProposalInitTime +
|
|
153
|
-
(blockIndex + 1) * this.requireBlockDurationForSchedule()
|
|
154
|
-
);
|
|
156
|
+
return this.getBuildFrameStart(slot) + this.checkpointProposalInitTime + (blockIndex + 1) * this.blockDuration;
|
|
155
157
|
}
|
|
156
158
|
|
|
157
159
|
/** Latest time to keep waiting for txs for sub-slot `k`: `block_build_deadline(k) - min_block_duration`. */
|
|
@@ -170,29 +172,10 @@ export class ProposerTimetable extends ConsensusTimetable {
|
|
|
170
172
|
* Scans sub-slots in order and picks the first whose build deadline is at least `min_block_duration`
|
|
171
173
|
* in the future. Sub-slots with insufficient remaining headroom are skipped.
|
|
172
174
|
*
|
|
173
|
-
* When enforcement is disabled, always allows building a single block with no deadline (test/sandbox
|
|
174
|
-
* mode). In single-block mode (`blockDuration === undefined`) enforced, splits the remaining time
|
|
175
|
-
* between execution and re-execution against the attestation deadline.
|
|
176
|
-
*
|
|
177
175
|
* @param slot - Target slot the checkpoint commits to.
|
|
178
176
|
* @param now - Current wall-clock time in seconds.
|
|
179
177
|
*/
|
|
180
178
|
public selectNextSubslot(slot: SlotNumber, now: number): SubslotSelection {
|
|
181
|
-
if (!this.enforce) {
|
|
182
|
-
return { canStart: true, index: 0, deadline: undefined, isLastBlock: true };
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
if (this.blockDuration === undefined) {
|
|
186
|
-
// Single-block enforced mode: execution and re-execution run sequentially, so split the time
|
|
187
|
-
// remaining until the attestation deadline in half.
|
|
188
|
-
const maxAllowed = this.getAttestationDeadline(slot);
|
|
189
|
-
const available = (maxAllowed - now) / 2;
|
|
190
|
-
const canStart = available >= this.minBlockDuration;
|
|
191
|
-
return canStart
|
|
192
|
-
? { canStart: true, index: 0, deadline: now + available, isLastBlock: true }
|
|
193
|
-
: { canStart: false, index: undefined, deadline: undefined, isLastBlock: false };
|
|
194
|
-
}
|
|
195
|
-
|
|
196
179
|
const maxBlocks = this.maxBlocksPerCheckpoint;
|
|
197
180
|
for (let index = 0; index < maxBlocks; index++) {
|
|
198
181
|
const deadline = this.getBlockBuildDeadline(slot, index);
|
|
@@ -204,11 +187,4 @@ export class ProposerTimetable extends ConsensusTimetable {
|
|
|
204
187
|
|
|
205
188
|
return { canStart: false, index: undefined, deadline: undefined, isLastBlock: false };
|
|
206
189
|
}
|
|
207
|
-
|
|
208
|
-
private requireBlockDurationForSchedule(): number {
|
|
209
|
-
if (this.blockDuration === undefined) {
|
|
210
|
-
throw new Error('blockDuration is required for sub-slot scheduling');
|
|
211
|
-
}
|
|
212
|
-
return this.blockDuration;
|
|
213
|
-
}
|
|
214
190
|
}
|
package/src/tx/fee_provider.ts
CHANGED
|
@@ -5,6 +5,6 @@ import type { GasFees } from '../gas/gas_fees.js';
|
|
|
5
5
|
export interface FeeProvider {
|
|
6
6
|
/** Returns the current minimum fees for inclusion in the next block. */
|
|
7
7
|
getCurrentMinFees(): Promise<GasFees>;
|
|
8
|
-
/** Returns predicted min fees for each slot in the prediction window. */
|
|
8
|
+
/** Returns current min fees first, followed by predicted min fees for each slot in the prediction window. */
|
|
9
9
|
getPredictedMinFees(manaUsage?: ManaUsageEstimate): Promise<GasFees[]>;
|
|
10
10
|
}
|
|
@@ -2,7 +2,8 @@
|
|
|
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 =
|
|
5
|
+
export const TX_ERROR_GAS_LIMIT_TOO_HIGH =
|
|
6
|
+
'Gas limit is higher than the maximum amount of gas this network allows per tx';
|
|
6
7
|
|
|
7
8
|
// Phases
|
|
8
9
|
export const TX_ERROR_SETUP_FUNCTION_NOT_ALLOWED = 'Setup function not on allow list';
|