@aztec/stdlib 3.0.0-nightly.20250916 → 3.0.0-nightly.20250918
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/avm/avm.d.ts +78 -1
- package/dest/avm/avm.d.ts.map +1 -1
- package/dest/avm/avm.js +20 -2
- package/dest/avm/avm_circuit_public_inputs.d.ts +6 -1
- package/dest/avm/avm_circuit_public_inputs.d.ts.map +1 -1
- package/dest/avm/avm_circuit_public_inputs.js +11 -6
- package/dest/avm/avm_proving_request.d.ts +41 -0
- package/dest/avm/avm_proving_request.d.ts.map +1 -1
- package/dest/block/body.d.ts +4 -1
- package/dest/block/body.d.ts.map +1 -1
- package/dest/block/body.js +16 -5
- package/dest/block/index.d.ts +1 -0
- package/dest/block/index.d.ts.map +1 -1
- package/dest/block/index.js +1 -0
- package/dest/block/l2_block.d.ts +8 -5
- package/dest/block/l2_block.d.ts.map +1 -1
- package/dest/block/l2_block.js +14 -7
- package/dest/block/l2_block_code_to_purge.d.ts +3 -14
- package/dest/block/l2_block_code_to_purge.d.ts.map +1 -1
- package/dest/block/l2_block_code_to_purge.js +23 -13
- package/dest/block/l2_block_header.d.ts +100 -0
- package/dest/block/l2_block_header.d.ts.map +1 -0
- package/dest/block/l2_block_header.js +146 -0
- package/dest/block/l2_block_stream/l2_tips_memory_store.js +1 -1
- package/dest/block/published_l2_block.d.ts +2 -2
- package/dest/block/test/l2_tips_store_test_suite.d.ts.map +1 -1
- package/dest/block/test/l2_tips_store_test_suite.js +1 -3
- package/dest/interfaces/aztec-node.d.ts +5 -2
- package/dest/interfaces/aztec-node.d.ts.map +1 -1
- package/dest/interfaces/aztec-node.js +1 -0
- package/dest/interfaces/block-builder.d.ts +1 -2
- package/dest/interfaces/block-builder.d.ts.map +1 -1
- package/dest/interfaces/epoch-prover.d.ts +25 -8
- package/dest/interfaces/epoch-prover.d.ts.map +1 -1
- package/dest/interfaces/proving-job.d.ts +204 -61
- package/dest/interfaces/proving-job.d.ts.map +1 -1
- package/dest/interfaces/proving-job.js +101 -39
- package/dest/interfaces/pxe.d.ts +8 -1
- package/dest/interfaces/pxe.d.ts.map +1 -1
- package/dest/interfaces/pxe.js +1 -0
- package/dest/interfaces/server_circuit_prover.d.ts +19 -16
- package/dest/interfaces/server_circuit_prover.d.ts.map +1 -1
- package/dest/interfaces/validator.d.ts +3 -2
- package/dest/interfaces/validator.d.ts.map +1 -1
- package/dest/kernel/private_circuit_public_inputs.d.ts +4 -4
- package/dest/kernel/private_circuit_public_inputs.d.ts.map +1 -1
- package/dest/kernel/private_circuit_public_inputs.js +7 -7
- package/dest/kernel/private_context_inputs.d.ts +2 -2
- package/dest/kernel/private_context_inputs.d.ts.map +1 -1
- package/dest/kernel/private_context_inputs.js +4 -4
- package/dest/kernel/private_kernel_tail_circuit_public_inputs.js +1 -1
- package/dest/messaging/inbox_leaf.d.ts +2 -0
- package/dest/messaging/inbox_leaf.d.ts.map +1 -1
- package/dest/messaging/inbox_leaf.js +3 -0
- package/dest/p2p/consensus_payload.d.ts +7 -6
- package/dest/p2p/consensus_payload.d.ts.map +1 -1
- package/dest/p2p/consensus_payload.js +7 -6
- package/dest/parity/root_parity_input.d.ts +1 -1
- package/dest/proofs/proof_data.d.ts +1 -1
- package/dest/proofs/proof_data.d.ts.map +1 -1
- package/dest/proofs/proof_data.js +2 -2
- package/dest/proofs/proving_request_type.d.ts +13 -8
- package/dest/proofs/proving_request_type.d.ts.map +1 -1
- package/dest/proofs/proving_request_type.js +13 -8
- package/dest/rollup/base_or_merge_rollup_public_inputs.d.ts +1 -1
- package/dest/rollup/base_or_merge_rollup_public_inputs.d.ts.map +1 -1
- package/dest/rollup/base_or_merge_rollup_public_inputs.js +1 -1
- package/dest/rollup/base_rollup_hints.d.ts +12 -3
- package/dest/rollup/base_rollup_hints.d.ts.map +1 -1
- package/dest/rollup/base_rollup_hints.js +11 -5
- package/dest/rollup/block_constant_data.d.ts +20 -6
- package/dest/rollup/block_constant_data.d.ts.map +1 -1
- package/dest/rollup/block_constant_data.js +15 -7
- package/dest/rollup/block_merge_rollup.d.ts +10 -9
- package/dest/rollup/block_merge_rollup.d.ts.map +1 -1
- package/dest/rollup/block_merge_rollup.js +14 -13
- package/dest/rollup/block_rollup_public_inputs.d.ts +124 -0
- package/dest/rollup/block_rollup_public_inputs.d.ts.map +1 -0
- package/dest/rollup/block_rollup_public_inputs.js +85 -0
- package/dest/rollup/block_root_rollup.d.ts +148 -184
- package/dest/rollup/block_root_rollup.d.ts.map +1 -1
- package/dest/rollup/block_root_rollup.js +211 -260
- package/dest/rollup/checkpoint_constant_data.d.ts +54 -0
- package/dest/rollup/checkpoint_constant_data.d.ts.map +1 -0
- package/dest/rollup/checkpoint_constant_data.js +55 -0
- package/dest/{tx/proposed_block_header.d.ts → rollup/checkpoint_header.d.ts} +11 -12
- package/dest/rollup/checkpoint_header.d.ts.map +1 -0
- package/dest/{tx/proposed_block_header.js → rollup/checkpoint_header.js} +9 -9
- package/dest/rollup/checkpoint_merge_rollup.d.ts +30 -0
- package/dest/rollup/checkpoint_merge_rollup.d.ts.map +1 -0
- package/dest/rollup/checkpoint_merge_rollup.js +37 -0
- package/dest/rollup/checkpoint_rollup_public_inputs.d.ts +105 -0
- package/dest/rollup/checkpoint_rollup_public_inputs.d.ts.map +1 -0
- package/dest/rollup/checkpoint_rollup_public_inputs.js +105 -0
- package/dest/rollup/checkpoint_root_rollup.d.ts +117 -0
- package/dest/rollup/checkpoint_root_rollup.d.ts.map +1 -0
- package/dest/rollup/checkpoint_root_rollup.js +178 -0
- package/dest/rollup/epoch_constant_data.d.ts +19 -2
- package/dest/rollup/epoch_constant_data.d.ts.map +1 -1
- package/dest/rollup/epoch_constant_data.js +20 -7
- package/dest/rollup/index.d.ts +8 -5
- package/dest/rollup/index.d.ts.map +1 -1
- package/dest/rollup/index.js +8 -5
- package/dest/rollup/rollup_proof_data.d.ts +10 -0
- package/dest/rollup/rollup_proof_data.d.ts.map +1 -0
- package/dest/rollup/rollup_proof_data.js +1 -0
- package/dest/rollup/root_rollup.d.ts +26 -23
- package/dest/rollup/root_rollup.d.ts.map +1 -1
- package/dest/rollup/root_rollup.js +28 -39
- package/dest/stats/stats.d.ts +1 -1
- package/dest/stats/stats.d.ts.map +1 -1
- package/dest/tests/factories.d.ts +17 -41
- package/dest/tests/factories.d.ts.map +1 -1
- package/dest/tests/factories.js +76 -80
- package/dest/tests/mocks.d.ts +3 -2
- package/dest/tests/mocks.d.ts.map +1 -1
- package/dest/tests/mocks.js +3 -3
- package/dest/tx/block_header.d.ts +12 -13
- package/dest/tx/block_header.d.ts.map +1 -1
- package/dest/tx/block_header.js +16 -21
- package/dest/tx/global_variables.d.ts.map +1 -1
- package/dest/tx/global_variables.js +0 -1
- package/dest/tx/index.d.ts +0 -1
- package/dest/tx/index.d.ts.map +1 -1
- package/dest/tx/index.js +0 -1
- package/dest/tx/private_execution_result.d.ts +2 -2
- package/dest/tx/private_execution_result.d.ts.map +1 -1
- package/dest/tx/private_execution_result.js +3 -3
- package/dest/tx/tx_constant_data.d.ts +4 -4
- package/dest/tx/tx_constant_data.d.ts.map +1 -1
- package/dest/tx/tx_constant_data.js +6 -6
- package/dest/tx/tx_effect.d.ts +0 -3
- package/dest/tx/tx_effect.d.ts.map +1 -1
- package/dest/tx/tx_effect.js +2 -7
- package/dest/zkpassport/index.d.ts +3 -3
- package/dest/zkpassport/index.d.ts.map +1 -1
- package/dest/zkpassport/index.js +7 -7
- package/package.json +8 -8
- package/src/avm/avm.ts +22 -0
- package/src/avm/avm_circuit_public_inputs.ts +10 -0
- package/src/block/body.ts +23 -6
- package/src/block/index.ts +1 -0
- package/src/block/l2_block.ts +18 -8
- package/src/block/l2_block_code_to_purge.ts +30 -31
- package/src/block/l2_block_header.ts +232 -0
- package/src/block/l2_block_stream/l2_tips_memory_store.ts +1 -1
- package/src/block/test/l2_tips_store_test_suite.ts +1 -2
- package/src/interfaces/aztec-node.ts +8 -2
- package/src/interfaces/block-builder.ts +1 -6
- package/src/interfaces/epoch-prover.ts +34 -10
- package/src/interfaces/proving-job.ts +166 -51
- package/src/interfaces/pxe.ts +10 -1
- package/src/interfaces/server_circuit_prover.ts +65 -29
- package/src/interfaces/validator.ts +3 -2
- package/src/kernel/private_circuit_public_inputs.ts +5 -5
- package/src/kernel/private_context_inputs.ts +2 -2
- package/src/kernel/private_kernel_tail_circuit_public_inputs.ts +1 -1
- package/src/messaging/inbox_leaf.ts +5 -0
- package/src/p2p/consensus_payload.ts +8 -7
- package/src/proofs/proof_data.ts +1 -6
- package/src/proofs/proving_request_type.ts +8 -3
- package/src/rollup/base_or_merge_rollup_public_inputs.ts +1 -1
- package/src/rollup/base_rollup_hints.ts +9 -1
- package/src/rollup/block_constant_data.ts +13 -3
- package/src/rollup/block_merge_rollup.ts +13 -11
- package/src/rollup/block_rollup_public_inputs.ts +123 -0
- package/src/rollup/block_root_rollup.ts +209 -264
- package/src/rollup/checkpoint_constant_data.ts +84 -0
- package/src/{tx/proposed_block_header.ts → rollup/checkpoint_header.ts} +16 -17
- package/src/rollup/checkpoint_merge_rollup.ts +50 -0
- package/src/rollup/{block_root_or_block_merge_public_inputs.ts → checkpoint_rollup_public_inputs.ts} +26 -52
- package/src/rollup/checkpoint_root_rollup.ts +216 -0
- package/src/rollup/epoch_constant_data.ts +32 -8
- package/src/rollup/index.ts +8 -5
- package/src/rollup/rollup_proof_data.ts +12 -0
- package/src/rollup/root_rollup.ts +30 -41
- package/src/stats/stats.ts +8 -3
- package/src/tests/factories.ts +139 -135
- package/src/tests/mocks.ts +6 -13
- package/src/tx/block_header.ts +17 -32
- package/src/tx/global_variables.ts +0 -1
- package/src/tx/index.ts +0 -1
- package/src/tx/private_execution_result.ts +3 -3
- package/src/tx/tx_constant_data.ts +4 -4
- package/src/tx/tx_effect.ts +2 -7
- package/src/zkpassport/index.ts +6 -6
- package/dest/rollup/block_root_or_block_merge_public_inputs.d.ts +0 -134
- package/dest/rollup/block_root_or_block_merge_public_inputs.d.ts.map +0 -1
- package/dest/rollup/block_root_or_block_merge_public_inputs.js +0 -125
- package/dest/rollup/empty_block_root_rollup_inputs.d.ts +0 -51
- package/dest/rollup/empty_block_root_rollup_inputs.d.ts.map +0 -1
- package/dest/rollup/empty_block_root_rollup_inputs.js +0 -65
- package/dest/rollup/padding_block_root_rollup_inputs.d.ts +0 -20
- package/dest/rollup/padding_block_root_rollup_inputs.d.ts.map +0 -1
- package/dest/rollup/padding_block_root_rollup_inputs.js +0 -39
- package/dest/rollup/previous_rollup_block_data.d.ts +0 -47
- package/dest/rollup/previous_rollup_block_data.d.ts.map +0 -1
- package/dest/rollup/previous_rollup_block_data.js +0 -37
- package/dest/tx/proposed_block_header.d.ts.map +0 -1
- package/src/rollup/empty_block_root_rollup_inputs.ts +0 -80
- package/src/rollup/padding_block_root_rollup_inputs.ts +0 -47
- package/src/rollup/previous_rollup_block_data.ts +0 -48
|
@@ -27,6 +27,7 @@ export class AvmCircuitPublicInputs {
|
|
|
27
27
|
///////////////////////////////////
|
|
28
28
|
// Inputs.
|
|
29
29
|
public globalVariables: GlobalVariables,
|
|
30
|
+
public protocolContractTreeRoot: Fr,
|
|
30
31
|
public startTreeSnapshots: TreeSnapshots,
|
|
31
32
|
public startGasUsed: Gas,
|
|
32
33
|
public gasSettings: GasSettings,
|
|
@@ -54,6 +55,7 @@ export class AvmCircuitPublicInputs {
|
|
|
54
55
|
return z
|
|
55
56
|
.object({
|
|
56
57
|
globalVariables: GlobalVariables.schema,
|
|
58
|
+
protocolContractTreeRoot: schemas.Fr,
|
|
57
59
|
startTreeSnapshots: TreeSnapshots.schema,
|
|
58
60
|
startGasUsed: Gas.schema,
|
|
59
61
|
gasSettings: GasSettings.schema,
|
|
@@ -77,6 +79,7 @@ export class AvmCircuitPublicInputs {
|
|
|
77
79
|
.transform(
|
|
78
80
|
({
|
|
79
81
|
globalVariables,
|
|
82
|
+
protocolContractTreeRoot,
|
|
80
83
|
startTreeSnapshots,
|
|
81
84
|
startGasUsed,
|
|
82
85
|
gasSettings,
|
|
@@ -99,6 +102,7 @@ export class AvmCircuitPublicInputs {
|
|
|
99
102
|
}) =>
|
|
100
103
|
new AvmCircuitPublicInputs(
|
|
101
104
|
globalVariables,
|
|
105
|
+
protocolContractTreeRoot,
|
|
102
106
|
startTreeSnapshots,
|
|
103
107
|
startGasUsed,
|
|
104
108
|
gasSettings,
|
|
@@ -126,6 +130,7 @@ export class AvmCircuitPublicInputs {
|
|
|
126
130
|
const reader = BufferReader.asReader(buffer);
|
|
127
131
|
return new AvmCircuitPublicInputs(
|
|
128
132
|
reader.readObject(GlobalVariables),
|
|
133
|
+
reader.readObject(Fr),
|
|
129
134
|
reader.readObject(TreeSnapshots),
|
|
130
135
|
reader.readObject(Gas),
|
|
131
136
|
reader.readObject(GasSettings),
|
|
@@ -151,6 +156,7 @@ export class AvmCircuitPublicInputs {
|
|
|
151
156
|
toBuffer() {
|
|
152
157
|
return serializeToBuffer(
|
|
153
158
|
this.globalVariables,
|
|
159
|
+
this.protocolContractTreeRoot,
|
|
154
160
|
this.startTreeSnapshots,
|
|
155
161
|
this.startGasUsed,
|
|
156
162
|
this.gasSettings,
|
|
@@ -185,6 +191,7 @@ export class AvmCircuitPublicInputs {
|
|
|
185
191
|
const reader = FieldReader.asReader(fields);
|
|
186
192
|
return new AvmCircuitPublicInputs(
|
|
187
193
|
GlobalVariables.fromFields(reader),
|
|
194
|
+
reader.readField(),
|
|
188
195
|
TreeSnapshots.fromFields(reader),
|
|
189
196
|
Gas.fromFields(reader),
|
|
190
197
|
GasSettings.fromFields(reader),
|
|
@@ -210,6 +217,7 @@ export class AvmCircuitPublicInputs {
|
|
|
210
217
|
toFields() {
|
|
211
218
|
return [
|
|
212
219
|
...this.globalVariables.toFields(),
|
|
220
|
+
this.protocolContractTreeRoot,
|
|
213
221
|
...this.startTreeSnapshots.toFields(),
|
|
214
222
|
...this.startGasUsed.toFields(),
|
|
215
223
|
...this.gasSettings.toFields(),
|
|
@@ -235,6 +243,7 @@ export class AvmCircuitPublicInputs {
|
|
|
235
243
|
static empty() {
|
|
236
244
|
return new AvmCircuitPublicInputs(
|
|
237
245
|
GlobalVariables.empty(),
|
|
246
|
+
Fr.zero(),
|
|
238
247
|
TreeSnapshots.empty(),
|
|
239
248
|
Gas.empty(),
|
|
240
249
|
GasSettings.empty(),
|
|
@@ -264,6 +273,7 @@ export class AvmCircuitPublicInputs {
|
|
|
264
273
|
[inspect.custom]() {
|
|
265
274
|
return `AvmCircuitPublicInputs {
|
|
266
275
|
globalVariables: ${inspect(this.globalVariables)},
|
|
276
|
+
protocolContractTreeRoot: ${inspect(this.protocolContractTreeRoot)},
|
|
267
277
|
startTreeSnapshots: ${inspect(this.startTreeSnapshots)},
|
|
268
278
|
startGasUsed: ${inspect(this.startGasUsed)},
|
|
269
279
|
gasSettings: ${inspect(this.gasSettings)},
|
package/src/block/body.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { createBlockEndMarker, getNumTxsFromBlockEndMarker, isBlockEndMarker } from '@aztec/blob-lib/encoding';
|
|
1
2
|
import { BLOBS_PER_BLOCK, FIELDS_PER_BLOB } from '@aztec/constants';
|
|
2
3
|
import { timesParallel } from '@aztec/foundation/collection';
|
|
3
|
-
import
|
|
4
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
4
5
|
import { BufferReader, FieldReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
5
6
|
|
|
6
7
|
import { inspect } from 'util';
|
|
@@ -9,6 +10,14 @@ import { z } from 'zod';
|
|
|
9
10
|
import type { ZodFor } from '../schemas/index.js';
|
|
10
11
|
import { TxEffect } from '../tx/tx_effect.js';
|
|
11
12
|
|
|
13
|
+
export { createBlockEndMarker };
|
|
14
|
+
|
|
15
|
+
export function getBlockBlobFields(txEffects: TxEffect[]) {
|
|
16
|
+
const blobFields = txEffects.flatMap(txEffect => txEffect.toBlobFields());
|
|
17
|
+
blobFields.push(createBlockEndMarker(txEffects.length));
|
|
18
|
+
return blobFields;
|
|
19
|
+
}
|
|
20
|
+
|
|
12
21
|
export class Body {
|
|
13
22
|
constructor(public txEffects: TxEffect[]) {
|
|
14
23
|
txEffects.forEach(txEffect => {
|
|
@@ -54,10 +63,8 @@ export class Body {
|
|
|
54
63
|
* Returns a flat packed array of fields of all tx effects - used for blobs.
|
|
55
64
|
*/
|
|
56
65
|
toBlobFields() {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
flattened = flattened.concat(effect.toBlobFields());
|
|
60
|
-
});
|
|
66
|
+
const flattened = getBlockBlobFields(this.txEffects);
|
|
67
|
+
|
|
61
68
|
if (flattened.length > BLOBS_PER_BLOCK * FIELDS_PER_BLOB) {
|
|
62
69
|
throw new Error(
|
|
63
70
|
`Attempted to overfill block's blobs with ${flattened.length} elements. The maximum is ${
|
|
@@ -74,10 +81,20 @@ export class Body {
|
|
|
74
81
|
*/
|
|
75
82
|
static fromBlobFields(fields: Fr[]) {
|
|
76
83
|
const txEffects: TxEffect[] = [];
|
|
77
|
-
const reader = new FieldReader(fields);
|
|
84
|
+
const reader = new FieldReader(fields.slice(0, -1));
|
|
78
85
|
while (!reader.isFinished()) {
|
|
79
86
|
txEffects.push(TxEffect.fromBlobFields(reader));
|
|
80
87
|
}
|
|
88
|
+
|
|
89
|
+
if (!isBlockEndMarker(fields[fields.length - 1])) {
|
|
90
|
+
throw new Error('Block end marker not found');
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const numTxs = getNumTxsFromBlockEndMarker(fields[fields.length - 1]);
|
|
94
|
+
if (numTxs !== txEffects.length) {
|
|
95
|
+
throw new Error(`Expected ${numTxs} txs, but got ${txEffects.length}`);
|
|
96
|
+
}
|
|
97
|
+
|
|
81
98
|
return new this(txEffects);
|
|
82
99
|
}
|
|
83
100
|
|
package/src/block/index.ts
CHANGED
package/src/block/l2_block.ts
CHANGED
|
@@ -5,9 +5,10 @@ import { bufferToHex, hexToBuffer } from '@aztec/foundation/string';
|
|
|
5
5
|
import { z } from 'zod';
|
|
6
6
|
|
|
7
7
|
import { AppendOnlyTreeSnapshot } from '../trees/append_only_tree_snapshot.js';
|
|
8
|
-
import { BlockHeader } from '../tx/block_header.js';
|
|
8
|
+
import type { BlockHeader } from '../tx/block_header.js';
|
|
9
9
|
import { Body } from './body.js';
|
|
10
|
-
import { makeAppendOnlyTreeSnapshot,
|
|
10
|
+
import { makeAppendOnlyTreeSnapshot, makeL2BlockHeader } from './l2_block_code_to_purge.js';
|
|
11
|
+
import { L2BlockHeader } from './l2_block_header.js';
|
|
11
12
|
import type { L2BlockInfo } from './l2_block_info.js';
|
|
12
13
|
|
|
13
14
|
/**
|
|
@@ -18,7 +19,7 @@ export class L2Block {
|
|
|
18
19
|
/** Snapshot of archive tree after the block is applied. */
|
|
19
20
|
public archive: AppendOnlyTreeSnapshot,
|
|
20
21
|
/** L2 block header. */
|
|
21
|
-
public header:
|
|
22
|
+
public header: L2BlockHeader,
|
|
22
23
|
/** L2 block body. */
|
|
23
24
|
public body: Body,
|
|
24
25
|
private blockHash: Fr | undefined = undefined,
|
|
@@ -28,7 +29,7 @@ export class L2Block {
|
|
|
28
29
|
return z
|
|
29
30
|
.object({
|
|
30
31
|
archive: AppendOnlyTreeSnapshot.schema,
|
|
31
|
-
header:
|
|
32
|
+
header: L2BlockHeader.schema,
|
|
32
33
|
body: Body.schema,
|
|
33
34
|
})
|
|
34
35
|
.transform(({ archive, header, body }) => new L2Block(archive, header, body));
|
|
@@ -40,7 +41,7 @@ export class L2Block {
|
|
|
40
41
|
*/
|
|
41
42
|
static fromBuffer(buf: Buffer | BufferReader) {
|
|
42
43
|
const reader = BufferReader.asReader(buf);
|
|
43
|
-
const header = reader.readObject(
|
|
44
|
+
const header = reader.readObject(L2BlockHeader);
|
|
44
45
|
const archive = reader.readObject(AppendOnlyTreeSnapshot);
|
|
45
46
|
const body = reader.readObject(Body);
|
|
46
47
|
|
|
@@ -94,7 +95,7 @@ export class L2Block {
|
|
|
94
95
|
|
|
95
96
|
return new L2Block(
|
|
96
97
|
makeAppendOnlyTreeSnapshot(l2BlockNum + 1),
|
|
97
|
-
|
|
98
|
+
makeL2BlockHeader(0, l2BlockNum, slotNumber ?? l2BlockNum, {}, inHash),
|
|
98
99
|
body,
|
|
99
100
|
);
|
|
100
101
|
}
|
|
@@ -104,7 +105,7 @@ export class L2Block {
|
|
|
104
105
|
* @returns The L2 block.
|
|
105
106
|
*/
|
|
106
107
|
static empty(): L2Block {
|
|
107
|
-
return new L2Block(AppendOnlyTreeSnapshot.empty(),
|
|
108
|
+
return new L2Block(AppendOnlyTreeSnapshot.empty(), L2BlockHeader.empty(), Body.empty());
|
|
108
109
|
}
|
|
109
110
|
|
|
110
111
|
get number(): number {
|
|
@@ -125,11 +126,20 @@ export class L2Block {
|
|
|
125
126
|
*/
|
|
126
127
|
public async hash(): Promise<Fr> {
|
|
127
128
|
if (this.blockHash === undefined) {
|
|
128
|
-
this.blockHash = await this.
|
|
129
|
+
this.blockHash = await this.getBlockHeader().hash();
|
|
129
130
|
}
|
|
130
131
|
return this.blockHash;
|
|
131
132
|
}
|
|
132
133
|
|
|
134
|
+
public getCheckpointHeader() {
|
|
135
|
+
return this.header.toCheckpointHeader();
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// Temporary helper to get the actual block header.
|
|
139
|
+
public getBlockHeader(): BlockHeader {
|
|
140
|
+
return this.header.toBlockHeader();
|
|
141
|
+
}
|
|
142
|
+
|
|
133
143
|
/**
|
|
134
144
|
* Returns stats used for logging.
|
|
135
145
|
* @returns Stats on tx count, number, and log size and count.
|
|
@@ -1,26 +1,35 @@
|
|
|
1
|
+
import { compact } from '@aztec/foundation/collection';
|
|
1
2
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
3
|
import { Fr } from '@aztec/foundation/fields';
|
|
4
|
+
import type { FieldsOf } from '@aztec/foundation/types';
|
|
3
5
|
|
|
4
6
|
import { AztecAddress } from '../aztec-address/index.js';
|
|
5
7
|
import { GasFees } from '../gas/gas_fees.js';
|
|
6
8
|
import { AppendOnlyTreeSnapshot } from '../trees/append_only_tree_snapshot.js';
|
|
7
|
-
import { BlockHeader } from '../tx/block_header.js';
|
|
8
9
|
import { ContentCommitment } from '../tx/content_commitment.js';
|
|
9
10
|
import { GlobalVariables } from '../tx/global_variables.js';
|
|
10
11
|
import { PartialStateReference } from '../tx/partial_state_reference.js';
|
|
11
12
|
import { StateReference } from '../tx/state_reference.js';
|
|
13
|
+
import { L2BlockHeader } from './l2_block_header.js';
|
|
12
14
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
export function makeL2BlockHeader(
|
|
16
|
+
seed = 0,
|
|
17
|
+
blockNumber?: number,
|
|
18
|
+
slotNumber?: number,
|
|
19
|
+
overrides: Partial<FieldsOf<L2BlockHeader>> = {},
|
|
20
|
+
inHash?: Fr,
|
|
21
|
+
) {
|
|
22
|
+
return new L2BlockHeader(
|
|
18
23
|
makeAppendOnlyTreeSnapshot(seed + 0x100),
|
|
19
|
-
makeContentCommitment(seed + 0x200, inHash),
|
|
20
|
-
makeStateReference(seed + 0x600),
|
|
21
|
-
makeGlobalVariables((seed += 0x700),
|
|
24
|
+
overrides?.contentCommitment ?? makeContentCommitment(seed + 0x200, inHash),
|
|
25
|
+
overrides?.state ?? makeStateReference(seed + 0x600),
|
|
26
|
+
makeGlobalVariables((seed += 0x700), {
|
|
27
|
+
...(blockNumber ? { blockNumber } : {}),
|
|
28
|
+
...(slotNumber ? { slotNumber: new Fr(slotNumber) } : {}),
|
|
29
|
+
}),
|
|
22
30
|
new Fr(seed + 0x800),
|
|
23
31
|
new Fr(seed + 0x900),
|
|
32
|
+
new Fr(seed + 0xa00),
|
|
24
33
|
);
|
|
25
34
|
}
|
|
26
35
|
|
|
@@ -62,26 +71,16 @@ function makePartialStateReference(seed = 0): PartialStateReference {
|
|
|
62
71
|
);
|
|
63
72
|
}
|
|
64
73
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
)
|
|
77
|
-
return new GlobalVariables(
|
|
78
|
-
new Fr(seed),
|
|
79
|
-
new Fr(seed + 1),
|
|
80
|
-
blockNumber ?? seed + 2,
|
|
81
|
-
new Fr(slotNumber ?? seed + 3),
|
|
82
|
-
BigInt(seed + 4),
|
|
83
|
-
EthAddress.fromField(new Fr(seed + 5)),
|
|
84
|
-
AztecAddress.fromField(new Fr(seed + 6)),
|
|
85
|
-
new GasFees(seed + 7, seed + 8),
|
|
86
|
-
);
|
|
74
|
+
function makeGlobalVariables(seed = 1, overrides: Partial<FieldsOf<GlobalVariables>> = {}): GlobalVariables {
|
|
75
|
+
return GlobalVariables.from({
|
|
76
|
+
chainId: new Fr(seed),
|
|
77
|
+
version: new Fr(seed + 1),
|
|
78
|
+
blockNumber: seed + 2,
|
|
79
|
+
slotNumber: new Fr(seed + 3),
|
|
80
|
+
timestamp: BigInt(seed + 4),
|
|
81
|
+
coinbase: EthAddress.fromField(new Fr(seed + 5)),
|
|
82
|
+
feeRecipient: AztecAddress.fromField(new Fr(seed + 6)),
|
|
83
|
+
gasFees: new GasFees(seed + 7, seed + 8),
|
|
84
|
+
...compact(overrides),
|
|
85
|
+
});
|
|
87
86
|
}
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
2
|
+
import { type ZodFor, schemas } from '@aztec/foundation/schemas';
|
|
3
|
+
import { BufferReader, FieldReader, serializeToBuffer, serializeToFields } from '@aztec/foundation/serialize';
|
|
4
|
+
import { bufferToHex, hexToBuffer } from '@aztec/foundation/string';
|
|
5
|
+
import type { FieldsOf } from '@aztec/foundation/types';
|
|
6
|
+
|
|
7
|
+
import { inspect } from 'util';
|
|
8
|
+
import { z } from 'zod';
|
|
9
|
+
|
|
10
|
+
import { CheckpointHeader } from '../rollup/checkpoint_header.js';
|
|
11
|
+
import { AppendOnlyTreeSnapshot } from '../trees/append_only_tree_snapshot.js';
|
|
12
|
+
import { BlockHeader, ContentCommitment, GlobalVariables, StateReference } from '../tx/index.js';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* TO BE DELETED
|
|
16
|
+
*
|
|
17
|
+
* A header of an L2 block combining the block header and the checkpoint header.
|
|
18
|
+
* This is a temporary workaround to avoid changing too many things before building in chunks is properly implemented.
|
|
19
|
+
* This works for now because we only have one block per checkpoint.
|
|
20
|
+
*
|
|
21
|
+
* @deprecated Use BlockHeader or CheckpointHeader instead.
|
|
22
|
+
*/
|
|
23
|
+
export class L2BlockHeader {
|
|
24
|
+
constructor(
|
|
25
|
+
/** Snapshot of archive before the block is applied. */
|
|
26
|
+
public lastArchive: AppendOnlyTreeSnapshot,
|
|
27
|
+
/** Hash of the body of an L2 block. */
|
|
28
|
+
public contentCommitment: ContentCommitment,
|
|
29
|
+
/** State reference. */
|
|
30
|
+
public state: StateReference,
|
|
31
|
+
/** Global variables of an L2 block. */
|
|
32
|
+
public globalVariables: GlobalVariables,
|
|
33
|
+
/** Total fees in the block, computed by the root rollup circuit */
|
|
34
|
+
public totalFees: Fr,
|
|
35
|
+
/** Total mana used in the block, computed by the root rollup circuit */
|
|
36
|
+
public totalManaUsed: Fr,
|
|
37
|
+
/** Hash of the sponge blob of the block. */
|
|
38
|
+
public spongeBlobHash: Fr,
|
|
39
|
+
) {}
|
|
40
|
+
|
|
41
|
+
static get schema(): ZodFor<L2BlockHeader> {
|
|
42
|
+
return z
|
|
43
|
+
.object({
|
|
44
|
+
lastArchive: AppendOnlyTreeSnapshot.schema,
|
|
45
|
+
contentCommitment: ContentCommitment.schema,
|
|
46
|
+
state: StateReference.schema,
|
|
47
|
+
globalVariables: GlobalVariables.schema,
|
|
48
|
+
totalFees: schemas.Fr,
|
|
49
|
+
totalManaUsed: schemas.Fr,
|
|
50
|
+
spongeBlobHash: schemas.Fr,
|
|
51
|
+
})
|
|
52
|
+
.transform(L2BlockHeader.from);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
static getFields(fields: FieldsOf<L2BlockHeader>) {
|
|
56
|
+
return [
|
|
57
|
+
fields.lastArchive,
|
|
58
|
+
fields.contentCommitment,
|
|
59
|
+
fields.state,
|
|
60
|
+
fields.globalVariables,
|
|
61
|
+
fields.totalFees,
|
|
62
|
+
fields.totalManaUsed,
|
|
63
|
+
fields.spongeBlobHash,
|
|
64
|
+
] as const;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
static from(fields: FieldsOf<L2BlockHeader>) {
|
|
68
|
+
return new L2BlockHeader(...L2BlockHeader.getFields(fields));
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
getSlot() {
|
|
72
|
+
return this.globalVariables.slotNumber.toBigInt();
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
getBlockNumber() {
|
|
76
|
+
return this.globalVariables.blockNumber;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
getSize() {
|
|
80
|
+
return (
|
|
81
|
+
this.lastArchive.getSize() +
|
|
82
|
+
this.contentCommitment.getSize() +
|
|
83
|
+
this.state.getSize() +
|
|
84
|
+
this.globalVariables.getSize() +
|
|
85
|
+
this.totalFees.size +
|
|
86
|
+
this.totalManaUsed.size +
|
|
87
|
+
this.spongeBlobHash.size
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
toBuffer() {
|
|
92
|
+
return serializeToBuffer(...L2BlockHeader.getFields(this));
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
toFields(): Fr[] {
|
|
96
|
+
return serializeToFields(...L2BlockHeader.getFields(this));
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
clone() {
|
|
100
|
+
return L2BlockHeader.fromBuffer(this.toBuffer());
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
static fromBuffer(buffer: Buffer | BufferReader) {
|
|
104
|
+
const reader = BufferReader.asReader(buffer);
|
|
105
|
+
|
|
106
|
+
return new L2BlockHeader(
|
|
107
|
+
reader.readObject(AppendOnlyTreeSnapshot),
|
|
108
|
+
reader.readObject(ContentCommitment),
|
|
109
|
+
reader.readObject(StateReference),
|
|
110
|
+
reader.readObject(GlobalVariables),
|
|
111
|
+
reader.readObject(Fr),
|
|
112
|
+
reader.readObject(Fr),
|
|
113
|
+
reader.readObject(Fr),
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
static fromFields(fields: Fr[] | FieldReader) {
|
|
118
|
+
const reader = FieldReader.asReader(fields);
|
|
119
|
+
|
|
120
|
+
return new L2BlockHeader(
|
|
121
|
+
AppendOnlyTreeSnapshot.fromFields(reader),
|
|
122
|
+
ContentCommitment.fromFields(reader),
|
|
123
|
+
StateReference.fromFields(reader),
|
|
124
|
+
GlobalVariables.fromFields(reader),
|
|
125
|
+
reader.readField(),
|
|
126
|
+
reader.readField(),
|
|
127
|
+
reader.readField(),
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
static empty(fields: Partial<FieldsOf<L2BlockHeader>> = {}) {
|
|
132
|
+
return L2BlockHeader.from({
|
|
133
|
+
lastArchive: AppendOnlyTreeSnapshot.empty(),
|
|
134
|
+
contentCommitment: ContentCommitment.empty(),
|
|
135
|
+
state: StateReference.empty(),
|
|
136
|
+
globalVariables: GlobalVariables.empty(),
|
|
137
|
+
totalFees: Fr.ZERO,
|
|
138
|
+
totalManaUsed: Fr.ZERO,
|
|
139
|
+
spongeBlobHash: Fr.ZERO,
|
|
140
|
+
...fields,
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
isEmpty(): boolean {
|
|
145
|
+
return (
|
|
146
|
+
this.lastArchive.isEmpty() &&
|
|
147
|
+
this.contentCommitment.isEmpty() &&
|
|
148
|
+
this.state.isEmpty() &&
|
|
149
|
+
this.globalVariables.isEmpty() &&
|
|
150
|
+
this.totalFees.isZero() &&
|
|
151
|
+
this.totalManaUsed.isZero() &&
|
|
152
|
+
this.spongeBlobHash.isZero()
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Serializes this instance into a string.
|
|
158
|
+
* @returns Encoded string.
|
|
159
|
+
*/
|
|
160
|
+
public toString() {
|
|
161
|
+
return bufferToHex(this.toBuffer());
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
static fromString(str: string) {
|
|
165
|
+
return L2BlockHeader.fromBuffer(hexToBuffer(str));
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
toCheckpointHeader() {
|
|
169
|
+
return new CheckpointHeader(
|
|
170
|
+
this.lastArchive.root,
|
|
171
|
+
this.contentCommitment,
|
|
172
|
+
this.globalVariables.slotNumber,
|
|
173
|
+
this.globalVariables.timestamp,
|
|
174
|
+
this.globalVariables.coinbase,
|
|
175
|
+
this.globalVariables.feeRecipient,
|
|
176
|
+
this.globalVariables.gasFees,
|
|
177
|
+
this.totalManaUsed,
|
|
178
|
+
);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
toBlockHeader() {
|
|
182
|
+
return new BlockHeader(
|
|
183
|
+
this.lastArchive,
|
|
184
|
+
this.state,
|
|
185
|
+
this.spongeBlobHash,
|
|
186
|
+
this.globalVariables,
|
|
187
|
+
this.totalFees,
|
|
188
|
+
this.totalManaUsed,
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
toInspect() {
|
|
193
|
+
return {
|
|
194
|
+
lastArchive: this.lastArchive.root.toString(),
|
|
195
|
+
contentCommitment: this.contentCommitment.toInspect(),
|
|
196
|
+
state: this.state.toInspect(),
|
|
197
|
+
globalVariables: this.globalVariables.toInspect(),
|
|
198
|
+
totalFees: this.totalFees.toBigInt(),
|
|
199
|
+
totalManaUsed: this.totalManaUsed.toBigInt(),
|
|
200
|
+
spongeBlobHash: this.spongeBlobHash.toString(),
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
[inspect.custom]() {
|
|
205
|
+
return `L2BlockHeader {
|
|
206
|
+
lastArchive: ${inspect(this.lastArchive)},
|
|
207
|
+
contentCommitment.blobsHash: ${inspect(this.contentCommitment.blobsHash)},
|
|
208
|
+
contentCommitment.inHash: ${inspect(this.contentCommitment.inHash)},
|
|
209
|
+
contentCommitment.outHash: ${inspect(this.contentCommitment.outHash)},
|
|
210
|
+
state.l1ToL2MessageTree: ${inspect(this.state.l1ToL2MessageTree)},
|
|
211
|
+
state.noteHashTree: ${inspect(this.state.partial.noteHashTree)},
|
|
212
|
+
state.nullifierTree: ${inspect(this.state.partial.nullifierTree)},
|
|
213
|
+
state.publicDataTree: ${inspect(this.state.partial.publicDataTree)},
|
|
214
|
+
globalVariables: ${inspect(this.globalVariables)},
|
|
215
|
+
totalFees: ${this.totalFees},
|
|
216
|
+
totalManaUsed: ${this.totalManaUsed},
|
|
217
|
+
spongeBlobHash: ${this.spongeBlobHash},
|
|
218
|
+
}`;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
public equals(other: this): boolean {
|
|
222
|
+
return (
|
|
223
|
+
this.contentCommitment.equals(other.contentCommitment) &&
|
|
224
|
+
this.state.equals(other.state) &&
|
|
225
|
+
this.globalVariables.equals(other.globalVariables) &&
|
|
226
|
+
this.totalFees.equals(other.totalFees) &&
|
|
227
|
+
this.totalManaUsed.equals(other.totalManaUsed) &&
|
|
228
|
+
this.lastArchive.equals(other.lastArchive) &&
|
|
229
|
+
this.spongeBlobHash.equals(other.spongeBlobHash)
|
|
230
|
+
);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { times } from '@aztec/foundation/collection';
|
|
2
2
|
import { Fr } from '@aztec/foundation/fields';
|
|
3
3
|
import { type L2Block, type L2BlockId, PublishedL2Block } from '@aztec/stdlib/block';
|
|
4
|
-
import type { BlockHeader } from '@aztec/stdlib/tx';
|
|
5
4
|
|
|
6
5
|
import { jestExpect as expect } from '@jest/expect';
|
|
7
6
|
|
|
@@ -16,7 +15,7 @@ export function testL2TipsStore(makeTipsStore: () => Promise<L2TipsStore>) {
|
|
|
16
15
|
|
|
17
16
|
const makeBlock = (number: number): PublishedL2Block =>
|
|
18
17
|
PublishedL2Block.fromFields({
|
|
19
|
-
block: { number,
|
|
18
|
+
block: { number, hash: () => Promise.resolve(new Fr(number)) } as L2Block,
|
|
20
19
|
l1: { blockNumber: BigInt(number), blockHash: `0x${number}`, timestamp: BigInt(number) },
|
|
21
20
|
attestations: [],
|
|
22
21
|
});
|
|
@@ -199,10 +199,14 @@ export interface AztecNode
|
|
|
199
199
|
l1ToL2Message: Fr,
|
|
200
200
|
): Promise<[bigint, SiblingPath<typeof L1_TO_L2_MSG_TREE_HEIGHT>] | undefined>;
|
|
201
201
|
|
|
202
|
+
/** Returns the L2 block number in which this L1 to L2 message becomes available, or undefined if not found. */
|
|
203
|
+
getL1ToL2MessageBlock(l1ToL2Message: Fr): Promise<number | undefined>;
|
|
204
|
+
|
|
202
205
|
/**
|
|
203
|
-
* Returns whether an L1 to L2 message is synced by archiver
|
|
206
|
+
* Returns whether an L1 to L2 message is synced by archiver.
|
|
204
207
|
* @param l1ToL2Message - The L1 to L2 message to check.
|
|
205
|
-
* @returns Whether the message is synced
|
|
208
|
+
* @returns Whether the message is synced.
|
|
209
|
+
* @deprecated Use `getL1ToL2MessageBlock` instead. This method may return true even if the message is not ready to use.
|
|
206
210
|
*/
|
|
207
211
|
isL1ToL2MessageSynced(l1ToL2Message: Fr): Promise<boolean>;
|
|
208
212
|
|
|
@@ -501,6 +505,8 @@ export const AztecNodeApiSchema: ApiSchemaFor<AztecNode> = {
|
|
|
501
505
|
.args(L2BlockNumberSchema, schemas.Fr)
|
|
502
506
|
.returns(z.tuple([schemas.BigInt, SiblingPath.schemaFor(L1_TO_L2_MSG_TREE_HEIGHT)]).optional()),
|
|
503
507
|
|
|
508
|
+
getL1ToL2MessageBlock: z.function().args(schemas.Fr).returns(z.number().optional()),
|
|
509
|
+
|
|
504
510
|
isL1ToL2MessageSynced: z.function().args(schemas.Fr).returns(z.boolean()),
|
|
505
511
|
|
|
506
512
|
getL2ToL1Messages: z
|
|
@@ -19,13 +19,8 @@ export interface IBlockFactory extends ProcessedTxHandler {
|
|
|
19
19
|
* Prepares to build a new block. Updates the L1 to L2 message tree.
|
|
20
20
|
* @param globalVariables - The global variables for this block.
|
|
21
21
|
* @param l1ToL2Messages - The set of L1 to L2 messages to be included in this block.
|
|
22
|
-
* @param previousBlockHeader - The header of the previous block.
|
|
23
22
|
*/
|
|
24
|
-
startNewBlock(
|
|
25
|
-
globalVariables: GlobalVariables,
|
|
26
|
-
l1ToL2Messages: Fr[],
|
|
27
|
-
previousBlockHeader: BlockHeader,
|
|
28
|
-
): Promise<void>;
|
|
23
|
+
startNewBlock(globalVariables: GlobalVariables, l1ToL2Messages: Fr[]): Promise<void>;
|
|
29
24
|
|
|
30
25
|
/**
|
|
31
26
|
* Adds all processed txs to the block. Updates world state with the effects from this tx.
|