@aztec/stdlib 6.0.0-nightly.20260810 → 6.0.0-nightly.20260821
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/abi/abi.d.ts +4 -3
- package/dest/abi/abi.d.ts.map +1 -1
- package/dest/abi/abi.js +5 -1
- package/dest/abi/contract_artifact.d.ts +7 -2
- package/dest/abi/contract_artifact.d.ts.map +1 -1
- package/dest/abi/contract_artifact.js +18 -19
- package/dest/avm/avm.d.ts +3 -2
- package/dest/avm/avm.d.ts.map +1 -1
- package/dest/avm/avm.js +9 -3
- package/dest/avm/avm_proving_request.d.ts +70 -70
- package/dest/block/l2_block.d.ts +1 -2
- package/dest/block/l2_block.d.ts.map +1 -1
- package/dest/block/l2_block.js +2 -3
- package/dest/block/l2_block_source.d.ts +3 -6
- package/dest/block/l2_block_source.d.ts.map +1 -1
- package/dest/block/l2_block_stream/event_driven_l2_block_stream.d.ts +11 -20
- package/dest/block/l2_block_stream/event_driven_l2_block_stream.d.ts.map +1 -1
- package/dest/block/l2_block_stream/event_driven_l2_block_stream.js +12 -116
- package/dest/checkpoint/checkpoint_data.d.ts +14 -2
- package/dest/checkpoint/checkpoint_data.d.ts.map +1 -1
- package/dest/checkpoint/checkpoint_data.js +2 -1
- package/dest/checkpoint/index.d.ts +2 -1
- package/dest/checkpoint/index.d.ts.map +1 -1
- package/dest/checkpoint/index.js +1 -0
- package/dest/checkpoint/previous_checkpoint_inbox_rolling_hash.d.ts +21 -0
- package/dest/checkpoint/previous_checkpoint_inbox_rolling_hash.d.ts.map +1 -0
- package/dest/checkpoint/previous_checkpoint_inbox_rolling_hash.js +34 -0
- package/dest/checkpoint/simulation_overrides.d.ts +2 -2
- package/dest/checkpoint/simulation_overrides.d.ts.map +1 -1
- package/dest/checkpoint/simulation_overrides.js +11 -8
- package/dest/config/network-consensus-config.d.ts +4 -3
- package/dest/config/network-consensus-config.d.ts.map +1 -1
- package/dest/config/network-consensus-config.js +9 -4
- package/dest/config/node-rpc-config.d.ts +13 -1
- package/dest/config/node-rpc-config.d.ts.map +1 -1
- package/dest/config/node-rpc-config.js +34 -1
- package/dest/deserialization/index.d.ts +17 -17
- package/dest/deserialization/index.d.ts.map +1 -1
- package/dest/deserialization/index.js +18 -18
- package/dest/gas/gas_settings.d.ts +17 -5
- package/dest/gas/gas_settings.d.ts.map +1 -1
- package/dest/gas/gas_settings.js +4 -4
- package/dest/gas/tx_gas_limits.d.ts +3 -4
- package/dest/gas/tx_gas_limits.d.ts.map +1 -1
- package/dest/gas/tx_gas_limits.js +4 -5
- package/dest/interfaces/archiver.d.ts +2 -2
- package/dest/interfaces/archiver.d.ts.map +1 -1
- package/dest/interfaces/archiver.js +32 -5
- package/dest/interfaces/aztec-node-admin.d.ts +2 -1
- package/dest/interfaces/aztec-node-admin.d.ts.map +1 -1
- package/dest/interfaces/aztec-node.d.ts +22 -4
- package/dest/interfaces/aztec-node.d.ts.map +1 -1
- package/dest/interfaces/aztec-node.js +11 -9
- package/dest/interfaces/block-builder.d.ts +11 -2
- package/dest/interfaces/block-builder.d.ts.map +1 -1
- package/dest/interfaces/configs.d.ts +7 -1
- package/dest/interfaces/configs.d.ts.map +1 -1
- package/dest/interfaces/configs.js +2 -1
- package/dest/interfaces/p2p.d.ts +18 -1
- package/dest/interfaces/p2p.d.ts.map +1 -1
- package/dest/interfaces/p2p.js +8 -0
- package/dest/interfaces/proving-job.d.ts +17 -42
- package/dest/interfaces/proving-job.d.ts.map +1 -1
- package/dest/interfaces/proving-job.js +16 -47
- package/dest/interfaces/server_circuit_prover.d.ts +8 -15
- package/dest/interfaces/server_circuit_prover.d.ts.map +1 -1
- package/dest/interfaces/validator.d.ts +7 -7
- package/dest/interfaces/validator.d.ts.map +1 -1
- package/dest/messaging/append_l1_to_l2_messages.d.ts +5 -5
- package/dest/messaging/append_l1_to_l2_messages.d.ts.map +1 -1
- package/dest/messaging/append_l1_to_l2_messages.js +4 -8
- package/dest/messaging/inbox_bucket.d.ts +77 -0
- package/dest/messaging/inbox_bucket.d.ts.map +1 -0
- package/dest/messaging/inbox_bucket.js +73 -0
- package/dest/messaging/inbox_consumption.d.ts +55 -0
- package/dest/messaging/inbox_consumption.d.ts.map +1 -0
- package/dest/messaging/inbox_consumption.js +53 -0
- package/dest/messaging/inbox_rolling_hash.d.ts +16 -0
- package/dest/messaging/inbox_rolling_hash.d.ts.map +1 -0
- package/dest/messaging/inbox_rolling_hash.js +23 -0
- package/dest/messaging/index.d.ts +6 -3
- package/dest/messaging/index.d.ts.map +1 -1
- package/dest/messaging/index.js +5 -2
- package/dest/messaging/l1_to_l2_message_bundle.d.ts +31 -0
- package/dest/messaging/l1_to_l2_message_bundle.d.ts.map +1 -0
- package/dest/messaging/l1_to_l2_message_bundle.js +51 -0
- package/dest/messaging/l1_to_l2_message_source.d.ts +44 -10
- package/dest/messaging/l1_to_l2_message_source.d.ts.map +1 -1
- package/dest/messaging/l1_to_l2_message_sponge.d.ts +40 -0
- package/dest/messaging/l1_to_l2_message_sponge.d.ts.map +1 -0
- package/dest/messaging/l1_to_l2_message_sponge.js +56 -0
- package/dest/noir/index.d.ts +3 -3
- package/dest/noir/index.d.ts.map +1 -1
- package/dest/p2p/block_proposal.d.ts +24 -9
- package/dest/p2p/block_proposal.d.ts.map +1 -1
- package/dest/p2p/block_proposal.js +42 -20
- package/dest/p2p/checkpoint_attestation.d.ts +1 -1
- package/dest/p2p/checkpoint_proposal.d.ts +13 -3
- package/dest/p2p/checkpoint_proposal.d.ts.map +1 -1
- package/dest/p2p/checkpoint_proposal.js +26 -8
- package/dest/p2p/consensus_payload.d.ts +1 -1
- package/dest/p2p/index.d.ts +2 -1
- package/dest/p2p/index.d.ts.map +1 -1
- package/dest/p2p/index.js +1 -0
- package/dest/p2p/validated_proposal.d.ts +35 -0
- package/dest/p2p/validated_proposal.d.ts.map +1 -0
- package/dest/p2p/validated_proposal.js +17 -0
- package/dest/p2p/wire_compat_fixtures.d.ts +7 -0
- package/dest/p2p/wire_compat_fixtures.d.ts.map +1 -0
- package/dest/p2p/wire_compat_fixtures.js +14 -0
- package/dest/parity/inbox_parity_private_inputs.d.ts +61 -0
- package/dest/parity/inbox_parity_private_inputs.d.ts.map +1 -0
- package/dest/parity/inbox_parity_private_inputs.js +79 -0
- package/dest/parity/index.d.ts +2 -3
- package/dest/parity/index.d.ts.map +1 -1
- package/dest/parity/index.js +1 -2
- package/dest/parity/parity_public_inputs.d.ts +15 -14
- package/dest/parity/parity_public_inputs.d.ts.map +1 -1
- package/dest/parity/parity_public_inputs.js +13 -15
- package/dest/proofs/proving_request_type.d.ts +11 -14
- package/dest/proofs/proving_request_type.d.ts.map +1 -1
- package/dest/proofs/proving_request_type.js +10 -13
- package/dest/rollup/block_constant_data.d.ts +8 -8
- package/dest/rollup/block_constant_data.js +4 -4
- package/dest/rollup/block_rollup_public_inputs.d.ts +18 -6
- package/dest/rollup/block_rollup_public_inputs.d.ts.map +1 -1
- package/dest/rollup/block_rollup_public_inputs.js +14 -7
- package/dest/rollup/block_root_rollup_private_inputs.d.ts +109 -113
- package/dest/rollup/block_root_rollup_private_inputs.d.ts.map +1 -1
- package/dest/rollup/block_root_rollup_private_inputs.js +79 -130
- package/dest/rollup/checkpoint_header.d.ts +14 -6
- package/dest/rollup/checkpoint_header.d.ts.map +1 -1
- package/dest/rollup/checkpoint_header.js +18 -14
- package/dest/rollup/checkpoint_rollup_public_inputs.d.ts +22 -2
- package/dest/rollup/checkpoint_rollup_public_inputs.d.ts.map +1 -1
- package/dest/rollup/checkpoint_rollup_public_inputs.js +14 -3
- package/dest/rollup/checkpoint_root_rollup_private_inputs.d.ts +27 -6
- package/dest/rollup/checkpoint_root_rollup_private_inputs.d.ts.map +1 -1
- package/dest/rollup/checkpoint_root_rollup_private_inputs.js +17 -4
- package/dest/rollup/root_rollup_public_inputs.d.ts +10 -2
- package/dest/rollup/root_rollup_public_inputs.d.ts.map +1 -1
- package/dest/rollup/root_rollup_public_inputs.js +9 -3
- package/dest/stats/stats.d.ts +2 -2
- package/dest/stats/stats.d.ts.map +1 -1
- package/dest/tests/factories.d.ts +7 -7
- package/dest/tests/factories.d.ts.map +1 -1
- package/dest/tests/factories.js +26 -22
- package/dest/tests/fixtures.d.ts +1 -1
- package/dest/tests/fixtures.d.ts.map +1 -1
- package/dest/tests/fixtures.js +2 -0
- package/dest/tests/mocks.d.ts +4 -2
- package/dest/tests/mocks.d.ts.map +1 -1
- package/dest/tests/mocks.js +4 -7
- package/dest/tx/state_reference.d.ts +5 -2
- package/dest/tx/state_reference.d.ts.map +1 -1
- package/dest/tx/state_reference.js +5 -5
- package/package.json +8 -8
- package/src/abi/abi.ts +7 -2
- package/src/abi/contract_artifact.ts +20 -23
- package/src/avm/avm.ts +11 -1
- package/src/block/l2_block.ts +2 -3
- package/src/block/l2_block_source.ts +2 -5
- package/src/block/l2_block_stream/event_driven_l2_block_stream.ts +17 -143
- package/src/checkpoint/checkpoint_data.ts +14 -1
- package/src/checkpoint/index.ts +1 -0
- package/src/checkpoint/previous_checkpoint_inbox_rolling_hash.ts +46 -0
- package/src/checkpoint/simulation_overrides.ts +11 -8
- package/src/config/network-consensus-config.ts +17 -4
- package/src/config/node-rpc-config.ts +51 -1
- package/src/deserialization/index.ts +18 -18
- package/src/gas/README.md +4 -3
- package/src/gas/gas_settings.ts +7 -3
- package/src/gas/tx_gas_limits.ts +4 -12
- package/src/interfaces/archiver.ts +19 -2
- package/src/interfaces/aztec-node.ts +33 -12
- package/src/interfaces/block-builder.ts +10 -1
- package/src/interfaces/configs.ts +6 -0
- package/src/interfaces/p2p.ts +21 -0
- package/src/interfaces/proving-job.ts +19 -70
- package/src/interfaces/server_circuit_prover.ts +13 -37
- package/src/interfaces/validator.ts +6 -5
- package/src/kernel/private_kernel_reset_dimensions.ts +1 -1
- package/src/messaging/append_l1_to_l2_messages.ts +5 -13
- package/src/messaging/inbox_bucket.ts +125 -0
- package/src/messaging/inbox_consumption.ts +74 -0
- package/src/messaging/inbox_rolling_hash.ts +24 -0
- package/src/messaging/index.ts +5 -2
- package/src/messaging/l1_to_l2_message_bundle.ts +65 -0
- package/src/messaging/l1_to_l2_message_source.ts +48 -10
- package/src/messaging/l1_to_l2_message_sponge.ts +69 -0
- package/src/noir/index.ts +1 -2
- package/src/p2p/block_proposal.ts +41 -28
- package/src/p2p/checkpoint_proposal.ts +31 -6
- package/src/p2p/index.ts +1 -0
- package/src/p2p/validated_proposal.ts +43 -0
- package/src/p2p/wire_compat_fixtures.ts +23 -0
- package/src/parity/inbox_parity_private_inputs.ts +116 -0
- package/src/parity/index.ts +1 -2
- package/src/parity/parity_public_inputs.ts +12 -14
- package/src/proofs/proving_request_type.ts +2 -5
- package/src/rollup/block_constant_data.ts +4 -4
- package/src/rollup/block_rollup_public_inputs.ts +14 -5
- package/src/rollup/block_root_rollup_private_inputs.ts +117 -153
- package/src/rollup/checkpoint_header.ts +17 -13
- package/src/rollup/checkpoint_rollup_public_inputs.ts +15 -0
- package/src/rollup/checkpoint_root_rollup_private_inputs.ts +16 -3
- package/src/rollup/root_rollup_public_inputs.ts +10 -0
- package/src/stats/stats.ts +4 -5
- package/src/tests/factories.ts +38 -32
- package/src/tests/fixtures.ts +3 -0
- package/src/tests/mocks.ts +6 -7
- package/src/tx/state_reference.ts +5 -12
- package/dest/messaging/in_hash.d.ts +0 -6
- package/dest/messaging/in_hash.d.ts.map +0 -1
- package/dest/messaging/in_hash.js +0 -10
- package/dest/messaging/inbox_leaf.d.ts +0 -25
- package/dest/messaging/inbox_leaf.d.ts.map +0 -1
- package/dest/messaging/inbox_leaf.js +0 -42
- package/dest/parity/parity_base_private_inputs.d.ts +0 -39
- package/dest/parity/parity_base_private_inputs.d.ts.map +0 -1
- package/dest/parity/parity_base_private_inputs.js +0 -51
- package/dest/parity/parity_root_private_inputs.d.ts +0 -39
- package/dest/parity/parity_root_private_inputs.d.ts.map +0 -1
- package/dest/parity/parity_root_private_inputs.js +0 -46
- package/src/messaging/in_hash.ts +0 -12
- package/src/messaging/inbox_leaf.ts +0 -44
- package/src/parity/parity_base_private_inputs.ts +0 -71
- package/src/parity/parity_root_private_inputs.ts +0 -64
|
@@ -18,6 +18,7 @@ import type { L2Block } from '../block/l2_block.js';
|
|
|
18
18
|
import type { L2BlockInfo } from '../block/l2_block_info.js';
|
|
19
19
|
import { MAX_TXS_PER_BLOCK } from '../deserialization/index.js';
|
|
20
20
|
import { DutyType, type SigningContext } from '../ha-signing/index.js';
|
|
21
|
+
import { InboxBucketRef } from '../messaging/inbox_bucket.js';
|
|
21
22
|
import { BlockHeader } from '../tx/block_header.js';
|
|
22
23
|
import { TxHash } from '../tx/index.js';
|
|
23
24
|
import type { Tx } from '../tx/tx.js';
|
|
@@ -70,9 +71,6 @@ export class BlockProposal extends Gossipable implements Signable {
|
|
|
70
71
|
/** Index of this block within the checkpoint (0-indexed) */
|
|
71
72
|
public readonly indexWithinCheckpoint: IndexWithinCheckpoint,
|
|
72
73
|
|
|
73
|
-
/** Hash of L1 to L2 messages for this checkpoint (constant across all blocks in checkpoint) */
|
|
74
|
-
public readonly inHash: Fr,
|
|
75
|
-
|
|
76
74
|
/** Archive root after this block is applied */
|
|
77
75
|
public readonly archiveRoot: Fr,
|
|
78
76
|
|
|
@@ -87,6 +85,13 @@ export class BlockProposal extends Gossipable implements Signable {
|
|
|
87
85
|
|
|
88
86
|
/** The signed transactions in the block (optional, for DA guarantees) */
|
|
89
87
|
public readonly signedTxs?: SignedTxs,
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Reference to the Inbox bucket this block proposes to consume, when the proposer commits to one. Validators
|
|
91
|
+
* resolve it against their own Inbox view and derive the consumed message bundle from it rather than trusting a
|
|
92
|
+
* proposer-supplied message list. Covered by the proposal signature (part of `getPayloadToSign`).
|
|
93
|
+
*/
|
|
94
|
+
public readonly bucketRef?: InboxBucketRef,
|
|
90
95
|
) {
|
|
91
96
|
super();
|
|
92
97
|
}
|
|
@@ -124,16 +129,18 @@ export class BlockProposal extends Gossipable implements Signable {
|
|
|
124
129
|
|
|
125
130
|
/**
|
|
126
131
|
* Get the payload to sign for this block proposal.
|
|
127
|
-
* The signature is over: blockHeader + indexWithinCheckpoint +
|
|
132
|
+
* The signature is over: blockHeader + indexWithinCheckpoint + archiveRoot + txHashes, plus the bucket reference
|
|
133
|
+
* when set. Appending only when set binds the reference to the signature so a relay cannot strip or inject it
|
|
134
|
+
* without breaking recovery.
|
|
128
135
|
*/
|
|
129
136
|
getPayloadToSign(): Buffer {
|
|
130
137
|
return serializeToBuffer([
|
|
131
138
|
this.blockHeader,
|
|
132
139
|
this.indexWithinCheckpoint,
|
|
133
|
-
this.inHash,
|
|
134
140
|
this.archiveRoot,
|
|
135
141
|
this.txHashes.length,
|
|
136
142
|
this.txHashes,
|
|
143
|
+
...(this.bucketRef ? [this.bucketRef] : []),
|
|
137
144
|
]);
|
|
138
145
|
}
|
|
139
146
|
|
|
@@ -156,23 +163,24 @@ export class BlockProposal extends Gossipable implements Signable {
|
|
|
156
163
|
blockHeader: BlockHeader,
|
|
157
164
|
checkpointNumber: CheckpointNumber,
|
|
158
165
|
indexWithinCheckpoint: IndexWithinCheckpoint,
|
|
159
|
-
inHash: Fr,
|
|
160
166
|
archiveRoot: Fr,
|
|
161
167
|
txHashes: TxHash[],
|
|
162
168
|
txs: Tx[] | undefined,
|
|
163
169
|
signatureContext: CoordinationSignatureContext,
|
|
164
170
|
proposalSigner: (typedData: TypedDataDefinition, context: SigningContext) => Promise<Signature>,
|
|
165
171
|
txsSigner?: (typedData: TypedDataDefinition, context: SigningContext) => Promise<Signature>,
|
|
172
|
+
bucketRef?: InboxBucketRef,
|
|
166
173
|
): Promise<BlockProposal> {
|
|
167
174
|
// Create a temporary proposal to get the payload to sign
|
|
168
175
|
const tempProposal = new BlockProposal(
|
|
169
176
|
blockHeader,
|
|
170
177
|
indexWithinCheckpoint,
|
|
171
|
-
inHash,
|
|
172
178
|
archiveRoot,
|
|
173
179
|
txHashes,
|
|
174
180
|
Signature.empty(),
|
|
175
181
|
signatureContext,
|
|
182
|
+
undefined,
|
|
183
|
+
bucketRef,
|
|
176
184
|
);
|
|
177
185
|
|
|
178
186
|
// Create the block signing context
|
|
@@ -202,12 +210,12 @@ export class BlockProposal extends Gossipable implements Signable {
|
|
|
202
210
|
return new BlockProposal(
|
|
203
211
|
blockHeader,
|
|
204
212
|
indexWithinCheckpoint,
|
|
205
|
-
inHash,
|
|
206
213
|
archiveRoot,
|
|
207
214
|
txHashes,
|
|
208
215
|
sig,
|
|
209
216
|
signatureContext,
|
|
210
217
|
signedTxs,
|
|
218
|
+
bucketRef,
|
|
211
219
|
);
|
|
212
220
|
}
|
|
213
221
|
|
|
@@ -248,7 +256,6 @@ export class BlockProposal extends Gossipable implements Signable {
|
|
|
248
256
|
const buffer: any[] = [
|
|
249
257
|
this.blockHeader,
|
|
250
258
|
this.indexWithinCheckpoint,
|
|
251
|
-
this.inHash,
|
|
252
259
|
this.archiveRoot,
|
|
253
260
|
this.signature,
|
|
254
261
|
serializeCoordinationSignatureContext(this.signatureContext),
|
|
@@ -261,6 +268,12 @@ export class BlockProposal extends Gossipable implements Signable {
|
|
|
261
268
|
} else {
|
|
262
269
|
buffer.push(0); // hasSignedTxs = false
|
|
263
270
|
}
|
|
271
|
+
// Optional bucket-reference tail. Appended only when set, so a proposal without a reference
|
|
272
|
+
// serializes without the tail and a decoder that reaches EOF reads it as unset.
|
|
273
|
+
if (this.bucketRef) {
|
|
274
|
+
buffer.push(1); // hasBucketRef = true
|
|
275
|
+
buffer.push(this.bucketRef.toBuffer());
|
|
276
|
+
}
|
|
264
277
|
return serializeToBuffer(buffer);
|
|
265
278
|
}
|
|
266
279
|
|
|
@@ -269,7 +282,6 @@ export class BlockProposal extends Gossipable implements Signable {
|
|
|
269
282
|
|
|
270
283
|
const blockHeader = reader.readObject(BlockHeader);
|
|
271
284
|
const indexWithinCheckpoint = IndexWithinCheckpoint(reader.readNumber());
|
|
272
|
-
const inHash = reader.readObject(Fr);
|
|
273
285
|
const archiveRoot = reader.readObject(Fr);
|
|
274
286
|
const signature = reader.readObject(Signature);
|
|
275
287
|
const signatureContext = readCoordinationSignatureContext(reader);
|
|
@@ -279,31 +291,33 @@ export class BlockProposal extends Gossipable implements Signable {
|
|
|
279
291
|
}
|
|
280
292
|
const txHashes = reader.readArray(txHashCount, TxHash);
|
|
281
293
|
|
|
294
|
+
let signedTxs: SignedTxs | undefined;
|
|
282
295
|
if (!reader.isEmpty()) {
|
|
283
296
|
const hasSignedTxs = reader.readNumber();
|
|
284
297
|
if (hasSignedTxs) {
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
);
|
|
298
|
+
signedTxs = SignedTxs.fromBuffer(reader);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
// Optional bucket-reference tail. A buffer that ends after the signedTxs flag decodes as
|
|
303
|
+
// "no reference", so proposals written without the tail round-trip cleanly.
|
|
304
|
+
let bucketRef: InboxBucketRef | undefined;
|
|
305
|
+
if (!reader.isEmpty()) {
|
|
306
|
+
const hasBucketRef = reader.readNumber();
|
|
307
|
+
if (hasBucketRef) {
|
|
308
|
+
bucketRef = InboxBucketRef.fromBuffer(reader);
|
|
296
309
|
}
|
|
297
310
|
}
|
|
298
311
|
|
|
299
312
|
return new BlockProposal(
|
|
300
313
|
blockHeader,
|
|
301
314
|
indexWithinCheckpoint,
|
|
302
|
-
inHash,
|
|
303
315
|
archiveRoot,
|
|
304
316
|
txHashes,
|
|
305
317
|
signature,
|
|
306
318
|
signatureContext,
|
|
319
|
+
signedTxs,
|
|
320
|
+
bucketRef,
|
|
307
321
|
);
|
|
308
322
|
}
|
|
309
323
|
|
|
@@ -311,7 +325,6 @@ export class BlockProposal extends Gossipable implements Signable {
|
|
|
311
325
|
return (
|
|
312
326
|
this.blockHeader.getSize() +
|
|
313
327
|
4 /* indexWithinCheckpoint */ +
|
|
314
|
-
this.inHash.size +
|
|
315
328
|
this.archiveRoot.size +
|
|
316
329
|
this.signature.getSize() +
|
|
317
330
|
4 /* chainId */ +
|
|
@@ -319,7 +332,8 @@ export class BlockProposal extends Gossipable implements Signable {
|
|
|
319
332
|
4 /* txHashes.length */ +
|
|
320
333
|
this.txHashes.length * TxHash.SIZE +
|
|
321
334
|
4 /* hasSignedTxs flag */ +
|
|
322
|
-
(this.signedTxs ? this.signedTxs.getSize() : 0)
|
|
335
|
+
(this.signedTxs ? this.signedTxs.getSize() : 0) +
|
|
336
|
+
(this.bucketRef ? 4 /* hasBucketRef flag */ + this.bucketRef.getSize() : 0)
|
|
323
337
|
);
|
|
324
338
|
}
|
|
325
339
|
|
|
@@ -328,7 +342,6 @@ export class BlockProposal extends Gossipable implements Signable {
|
|
|
328
342
|
BlockHeader.empty(),
|
|
329
343
|
IndexWithinCheckpoint(0),
|
|
330
344
|
Fr.ZERO,
|
|
331
|
-
Fr.ZERO,
|
|
332
345
|
[],
|
|
333
346
|
Signature.empty(),
|
|
334
347
|
EMPTY_COORDINATION_SIGNATURE_CONTEXT,
|
|
@@ -340,7 +353,6 @@ export class BlockProposal extends Gossipable implements Signable {
|
|
|
340
353
|
BlockHeader.random(),
|
|
341
354
|
IndexWithinCheckpoint(Math.floor(Math.random() * 5)),
|
|
342
355
|
Fr.random(),
|
|
343
|
-
Fr.random(),
|
|
344
356
|
[TxHash.random(), TxHash.random()],
|
|
345
357
|
Signature.random(),
|
|
346
358
|
EMPTY_COORDINATION_SIGNATURE_CONTEXT,
|
|
@@ -351,12 +363,12 @@ export class BlockProposal extends Gossipable implements Signable {
|
|
|
351
363
|
return {
|
|
352
364
|
blockHeader: this.blockHeader.toInspect(),
|
|
353
365
|
indexWithinCheckpoint: this.indexWithinCheckpoint,
|
|
354
|
-
inHash: this.inHash.toString(),
|
|
355
366
|
archiveRoot: this.archiveRoot.toString(),
|
|
356
367
|
signature: this.signature.toString(),
|
|
357
368
|
txHashes: this.txHashes.map(h => h.toString()),
|
|
358
369
|
chainId: this.signatureContext.chainId,
|
|
359
370
|
rollupAddress: this.signatureContext.rollupAddress.toString(),
|
|
371
|
+
bucketRef: this.bucketRef?.toInspect(),
|
|
360
372
|
};
|
|
361
373
|
}
|
|
362
374
|
|
|
@@ -378,11 +390,12 @@ export class BlockProposal extends Gossipable implements Signable {
|
|
|
378
390
|
return new BlockProposal(
|
|
379
391
|
this.blockHeader,
|
|
380
392
|
this.indexWithinCheckpoint,
|
|
381
|
-
this.inHash,
|
|
382
393
|
this.archiveRoot,
|
|
383
394
|
this.txHashes,
|
|
384
395
|
this.signature,
|
|
385
396
|
this.signatureContext,
|
|
397
|
+
undefined,
|
|
398
|
+
this.bucketRef,
|
|
386
399
|
);
|
|
387
400
|
}
|
|
388
401
|
}
|
|
@@ -15,6 +15,7 @@ import type { TypedDataDefinition } from 'viem';
|
|
|
15
15
|
import type { L2BlockInfo } from '../block/l2_block_info.js';
|
|
16
16
|
import { MAX_TXS_PER_BLOCK } from '../deserialization/index.js';
|
|
17
17
|
import { DutyType, type SigningContext } from '../ha-signing/index.js';
|
|
18
|
+
import { InboxBucketRef } from '../messaging/inbox_bucket.js';
|
|
18
19
|
import { CheckpointHeader } from '../rollup/checkpoint_header.js';
|
|
19
20
|
import { BlockHeader } from '../tx/block_header.js';
|
|
20
21
|
import { TxHash } from '../tx/index.js';
|
|
@@ -69,6 +70,11 @@ export type CheckpointLastBlock = Omit<CheckpointLastBlockData, 'txs'> & {
|
|
|
69
70
|
signature: Signature;
|
|
70
71
|
/** The signed transactions in the last block (optional, for DA guarantees) */
|
|
71
72
|
signedTxs?: SignedTxs;
|
|
73
|
+
/**
|
|
74
|
+
* Reference to the Inbox bucket the last block proposes to consume. When set, its rolling hash must equal the
|
|
75
|
+
* checkpoint header's `inboxRollingHash` (enforced at construction).
|
|
76
|
+
*/
|
|
77
|
+
bucketRef?: InboxBucketRef;
|
|
72
78
|
};
|
|
73
79
|
|
|
74
80
|
/**
|
|
@@ -104,10 +110,11 @@ export class CheckpointProposal extends Gossipable implements Signable {
|
|
|
104
110
|
) {
|
|
105
111
|
super();
|
|
106
112
|
|
|
107
|
-
// Check that last block properties match those of the checkpoint.
|
|
108
|
-
|
|
113
|
+
// Check that last block properties match those of the checkpoint. The last block's bucket reference
|
|
114
|
+
// commits to the same rolling hash as the checkpoint header. Only enforced when the reference is set.
|
|
115
|
+
if (lastBlock?.bucketRef && !lastBlock.bucketRef.inboxRollingHash.equals(checkpointHeader.inboxRollingHash)) {
|
|
109
116
|
throw new Error(
|
|
110
|
-
`CheckpointProposal lastBlock
|
|
117
|
+
`CheckpointProposal lastBlock bucketRef rolling hash ${lastBlock.bucketRef.inboxRollingHash} does not match checkpoint inboxRollingHash ${checkpointHeader.inboxRollingHash}`,
|
|
111
118
|
);
|
|
112
119
|
}
|
|
113
120
|
if (lastBlock && 'archiveRoot' in lastBlock && !lastBlock.archiveRoot.equals(archive)) {
|
|
@@ -134,7 +141,6 @@ export class CheckpointProposal extends Gossipable implements Signable {
|
|
|
134
141
|
|
|
135
142
|
/**
|
|
136
143
|
* Extract a BlockProposal from the last block info.
|
|
137
|
-
* Uses inHash from checkpointHeader.contentCommitment.inHash
|
|
138
144
|
*/
|
|
139
145
|
getBlockProposal(): BlockProposal | undefined {
|
|
140
146
|
if (!this.lastBlock) {
|
|
@@ -144,12 +150,12 @@ export class CheckpointProposal extends Gossipable implements Signable {
|
|
|
144
150
|
return new BlockProposal(
|
|
145
151
|
this.lastBlock.blockHeader,
|
|
146
152
|
this.lastBlock.indexWithinCheckpoint,
|
|
147
|
-
this.checkpointHeader.inHash,
|
|
148
153
|
this.archive,
|
|
149
154
|
this.lastBlock.txHashes,
|
|
150
155
|
this.lastBlock.signature,
|
|
151
156
|
this.signatureContext,
|
|
152
157
|
this.lastBlock.signedTxs,
|
|
158
|
+
this.lastBlock.bucketRef,
|
|
153
159
|
);
|
|
154
160
|
}
|
|
155
161
|
|
|
@@ -288,6 +294,12 @@ export class CheckpointProposal extends Gossipable implements Signable {
|
|
|
288
294
|
} else {
|
|
289
295
|
buffer.push(0); // hasSignedTxs = false
|
|
290
296
|
}
|
|
297
|
+
// Optional bucket-reference tail. Appended only when set, so a proposal without a reference
|
|
298
|
+
// serializes without the tail and a decoder that reaches EOF reads it as unset.
|
|
299
|
+
if (this.lastBlock.bucketRef) {
|
|
300
|
+
buffer.push(1); // hasBucketRef = true
|
|
301
|
+
buffer.push(this.lastBlock.bucketRef.toBuffer());
|
|
302
|
+
}
|
|
291
303
|
} else {
|
|
292
304
|
buffer.push(0); // hasLastBlock = false
|
|
293
305
|
}
|
|
@@ -324,12 +336,23 @@ export class CheckpointProposal extends Gossipable implements Signable {
|
|
|
324
336
|
}
|
|
325
337
|
}
|
|
326
338
|
|
|
339
|
+
// Optional bucket-reference tail. A buffer that ends after the signedTxs flag decodes as
|
|
340
|
+
// "no reference", so proposals written without the tail round-trip cleanly.
|
|
341
|
+
let bucketRef: InboxBucketRef | undefined;
|
|
342
|
+
if (!reader.isEmpty()) {
|
|
343
|
+
const hasBucketRef = reader.readNumber();
|
|
344
|
+
if (hasBucketRef) {
|
|
345
|
+
bucketRef = InboxBucketRef.fromBuffer(reader);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
|
|
327
349
|
return new CheckpointProposal(checkpointHeader, archive, feeAssetPriceModifier, signature, signatureContext, {
|
|
328
350
|
blockHeader,
|
|
329
351
|
indexWithinCheckpoint,
|
|
330
352
|
txHashes,
|
|
331
353
|
signature: blockSignature,
|
|
332
354
|
signedTxs,
|
|
355
|
+
bucketRef,
|
|
333
356
|
});
|
|
334
357
|
}
|
|
335
358
|
|
|
@@ -354,7 +377,8 @@ export class CheckpointProposal extends Gossipable implements Signable {
|
|
|
354
377
|
4 /* txHashes.length */ +
|
|
355
378
|
this.lastBlock.txHashes.length * TxHash.SIZE +
|
|
356
379
|
4 /* hasSignedTxs flag */ +
|
|
357
|
-
(this.lastBlock.signedTxs ? this.lastBlock.signedTxs.getSize() : 0)
|
|
380
|
+
(this.lastBlock.signedTxs ? this.lastBlock.signedTxs.getSize() : 0) +
|
|
381
|
+
(this.lastBlock.bucketRef ? 4 /* hasBucketRef flag */ + this.lastBlock.bucketRef.getSize() : 0);
|
|
358
382
|
}
|
|
359
383
|
|
|
360
384
|
return size;
|
|
@@ -400,6 +424,7 @@ export class CheckpointProposal extends Gossipable implements Signable {
|
|
|
400
424
|
indexWithinCheckpoint: this.lastBlock.indexWithinCheckpoint,
|
|
401
425
|
txHashes: this.lastBlock.txHashes.map(h => h.toString()),
|
|
402
426
|
signature: this.lastBlock.signature.toString(),
|
|
427
|
+
bucketRef: this.lastBlock.bucketRef?.toInspect(),
|
|
403
428
|
}
|
|
404
429
|
: undefined,
|
|
405
430
|
};
|
package/src/p2p/index.ts
CHANGED
|
@@ -7,6 +7,7 @@ export * from './gossipable.js';
|
|
|
7
7
|
export * from './signature_utils.js';
|
|
8
8
|
export * from './signed_txs.js';
|
|
9
9
|
export * from './topic_type.js';
|
|
10
|
+
export * from './validated_proposal.js';
|
|
10
11
|
export * from './message_validator.js';
|
|
11
12
|
export * from './peer_error.js';
|
|
12
13
|
export * from './constants.js';
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { Branded } from '@aztec/foundation/branded-types';
|
|
2
|
+
|
|
3
|
+
import type { BlockProposal } from './block_proposal.js';
|
|
4
|
+
import type { CheckpointProposalCore } from './checkpoint_proposal.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A block proposal that has passed p2p ingress validation.
|
|
8
|
+
*
|
|
9
|
+
* Downstream consumers (the validator client's proposal handlers) rely on that validation having already
|
|
10
|
+
* happened and do not repeat it, so this brand marks the proposals they are allowed to receive. It is a
|
|
11
|
+
* compile-time marker only: at runtime a `ValidatedBlockProposal` is just a `BlockProposal`.
|
|
12
|
+
*/
|
|
13
|
+
export type ValidatedBlockProposal = Branded<BlockProposal, 'ValidatedBlockProposal'>;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Marks a block proposal as having passed p2p ingress validation.
|
|
17
|
+
*
|
|
18
|
+
* May only be called at a point where the gossipsub topic validator has accepted the proposal, which covers
|
|
19
|
+
* the signature context, the signature itself, the expected proposer for the slot, the index within the
|
|
20
|
+
* checkpoint, the tx field checks, and the receive-window timeliness check.
|
|
21
|
+
*/
|
|
22
|
+
export function ValidatedBlockProposal(proposal: BlockProposal): ValidatedBlockProposal {
|
|
23
|
+
return proposal as ValidatedBlockProposal;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* A checkpoint proposal (without its last block) that has passed p2p ingress validation.
|
|
28
|
+
*
|
|
29
|
+
* Downstream consumers (the validator client's proposal handlers) rely on that validation having already
|
|
30
|
+
* happened and do not repeat it, so this brand marks the proposals they are allowed to receive. It is a
|
|
31
|
+
* compile-time marker only: at runtime a `ValidatedCheckpointProposalCore` is just a `CheckpointProposalCore`.
|
|
32
|
+
*/
|
|
33
|
+
export type ValidatedCheckpointProposalCore = Branded<CheckpointProposalCore, 'ValidatedCheckpointProposalCore'>;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Marks a checkpoint proposal as having passed p2p ingress validation.
|
|
37
|
+
*
|
|
38
|
+
* May only be called at a point where the gossipsub topic validator has accepted the proposal, which covers
|
|
39
|
+
* the expected proposer for the slot and the receive-window timeliness check.
|
|
40
|
+
*/
|
|
41
|
+
export function ValidatedCheckpointProposalCore(proposal: CheckpointProposalCore): ValidatedCheckpointProposalCore {
|
|
42
|
+
return proposal as ValidatedCheckpointProposalCore;
|
|
43
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// Golden wire fixtures that pin the exact bytes a peer produces and consumes, so the optional bucket-reference tail
|
|
2
|
+
// added to proposals stays wire compatible: an unset proposal must serialize to these bytes, and decoding these bytes
|
|
3
|
+
// must yield no bucket reference. The block-proposal fixtures were refreshed for the removal of the legacy `inHash`
|
|
4
|
+
// field; the checkpoint-proposal fixture was refreshed for the checkpoint-header format change.
|
|
5
|
+
//
|
|
6
|
+
// Both fixtures come from a deterministic proposal built with:
|
|
7
|
+
// BlockHeader.empty(), IndexWithinCheckpoint(3), archiveRoot=Fr(99),
|
|
8
|
+
// txHashes=[TxHash.fromField(Fr(7)), TxHash.fromField(Fr(8))], Signature.empty(), EMPTY_COORDINATION_SIGNATURE_CONTEXT
|
|
9
|
+
// (checkpoint: CheckpointHeader.empty(), archive=Fr(123), feeAssetPriceModifier=0, empty signature/context, and a
|
|
10
|
+
// lastBlock with BlockHeader.empty(), IndexWithinCheckpoint(4), txHashes=[TxHash.fromField(Fr(7))], empty signature).
|
|
11
|
+
// Regenerate the checkpoint fixture only when the checkpoint serialization format changes on purpose.
|
|
12
|
+
|
|
13
|
+
/** Legacy `BlockProposal.toBuffer()` bytes (no signedTxs, no bucket reference). */
|
|
14
|
+
export const LEGACY_BLOCK_PROPOSAL_HEX =
|
|
15
|
+
'0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000630000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000007000000000000000000000000000000000000000000000000000000000000000800000000';
|
|
16
|
+
|
|
17
|
+
/** Legacy `CheckpointProposal.toBuffer()` bytes (lastBlock without signedTxs or bucket reference). */
|
|
18
|
+
export const LEGACY_CHECKPOINT_PROPOSAL_HEX =
|
|
19
|
+
'0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000700000000';
|
|
20
|
+
|
|
21
|
+
/** Legacy `BlockProposal.getPayloadToSign()` bytes (no bucket reference). */
|
|
22
|
+
export const LEGACY_BLOCK_PROPOSAL_PAYLOAD_HEX =
|
|
23
|
+
'0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000630000000200000000000000000000000000000000000000000000000000000000000000070000000000000000000000000000000000000000000000000000000000000008';
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { INBOX_PARITY_SIZE_LARGE, INBOX_PARITY_SIZE_MEDIUM, INBOX_PARITY_SIZE_SMALL } from '@aztec/constants';
|
|
2
|
+
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
3
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
|
+
import { bufferSchemaFor } from '@aztec/foundation/schemas';
|
|
5
|
+
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
6
|
+
import { bufferToHex, hexToBuffer } from '@aztec/foundation/string';
|
|
7
|
+
|
|
8
|
+
/** The InboxParity size ladder, ascending. One VK per size; the prover proves the smallest that fits. */
|
|
9
|
+
export const INBOX_PARITY_SIZES = [INBOX_PARITY_SIZE_SMALL, INBOX_PARITY_SIZE_MEDIUM, INBOX_PARITY_SIZE_LARGE] as const;
|
|
10
|
+
|
|
11
|
+
/** A valid InboxParity ladder size. */
|
|
12
|
+
export type InboxParitySize = (typeof INBOX_PARITY_SIZES)[number];
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Picks the smallest ladder size that can hold `numMessages` messages.
|
|
16
|
+
* @throws if `numMessages` exceeds the largest rung.
|
|
17
|
+
*/
|
|
18
|
+
export function pickInboxParitySize(numMessages: number): InboxParitySize {
|
|
19
|
+
const size = INBOX_PARITY_SIZES.find(s => numMessages <= s);
|
|
20
|
+
if (size === undefined) {
|
|
21
|
+
throw new Error(
|
|
22
|
+
`Cannot fit ${numMessages} L1-to-L2 messages into any InboxParity size (max ${INBOX_PARITY_SIZE_LARGE})`,
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
return size;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Private inputs for one `InboxParity<S>` proof (S = `size`). The prover produces exactly one per checkpoint, sized
|
|
30
|
+
* by the checkpoint's message count via {@link pickInboxParitySize}.
|
|
31
|
+
*/
|
|
32
|
+
export class InboxParityPrivateInputs {
|
|
33
|
+
constructor(
|
|
34
|
+
/** Ladder size S: the length of `messages` and the circuit variant to prove ({@link INBOX_PARITY_SIZES}). */
|
|
35
|
+
public readonly size: InboxParitySize,
|
|
36
|
+
/** The checkpoint's L1-to-L2 messages, padded with zeros to `size`; the first `numMessages` are real. */
|
|
37
|
+
public readonly messages: Fr[],
|
|
38
|
+
/** Number of real (non-padding) messages in `messages`. */
|
|
39
|
+
public readonly numMessages: number,
|
|
40
|
+
/** Inbox rolling hash before this checkpoint's messages (the previous checkpoint's end; genesis is zero). */
|
|
41
|
+
public readonly startRollingHash: Fr,
|
|
42
|
+
/** Prover identity committed to by the circuit, for sybil protection. */
|
|
43
|
+
public readonly proverId: Fr,
|
|
44
|
+
) {
|
|
45
|
+
if (messages.length !== size) {
|
|
46
|
+
throw new Error(`InboxParity messages length (${messages.length}) must equal size (${size})`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Builds the inputs from a checkpoint's real messages, sizing the circuit by the message count and padding the
|
|
52
|
+
* message array out to that size.
|
|
53
|
+
*/
|
|
54
|
+
static fromMessages(messages: Fr[], startRollingHash: Fr, proverId: Fr): InboxParityPrivateInputs {
|
|
55
|
+
const size = pickInboxParitySize(messages.length);
|
|
56
|
+
// Explicit `<Fr, number>` keeps the result `Fr[]`; padding to the union-literal `size` would infer a deep tuple.
|
|
57
|
+
return new InboxParityPrivateInputs(
|
|
58
|
+
size,
|
|
59
|
+
padArrayEnd<Fr, number>(messages, Fr.ZERO, size),
|
|
60
|
+
messages.length,
|
|
61
|
+
startRollingHash,
|
|
62
|
+
proverId,
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** Serializes the inputs to a buffer. */
|
|
67
|
+
toBuffer() {
|
|
68
|
+
return serializeToBuffer(
|
|
69
|
+
new Fr(this.size),
|
|
70
|
+
this.messages,
|
|
71
|
+
new Fr(this.numMessages),
|
|
72
|
+
this.startRollingHash,
|
|
73
|
+
this.proverId,
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** Serializes the inputs to a hex string. */
|
|
78
|
+
toString() {
|
|
79
|
+
return bufferToHex(this.toBuffer());
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Deserializes the inputs from a buffer.
|
|
84
|
+
* @param buffer - The buffer to deserialize from.
|
|
85
|
+
*/
|
|
86
|
+
static fromBuffer(buffer: Buffer | BufferReader) {
|
|
87
|
+
const reader = BufferReader.asReader(buffer);
|
|
88
|
+
const size = Fr.fromBuffer(reader).toNumber() as InboxParitySize;
|
|
89
|
+
// Array.from keeps the type `Fr[]`; readArray with the union-literal `size` would infer a deep tuple.
|
|
90
|
+
const messages = Array.from({ length: size }, () => Fr.fromBuffer(reader));
|
|
91
|
+
return new InboxParityPrivateInputs(
|
|
92
|
+
size,
|
|
93
|
+
messages,
|
|
94
|
+
Fr.fromBuffer(reader).toNumber(),
|
|
95
|
+
Fr.fromBuffer(reader),
|
|
96
|
+
Fr.fromBuffer(reader),
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Deserializes the inputs from a hex string.
|
|
102
|
+
* @param str - The hex string to deserialize from.
|
|
103
|
+
*/
|
|
104
|
+
static fromString(str: string) {
|
|
105
|
+
return InboxParityPrivateInputs.fromBuffer(hexToBuffer(str));
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/** Returns a buffer representation for JSON serialization. */
|
|
109
|
+
toJSON() {
|
|
110
|
+
return this.toBuffer();
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
static get schema() {
|
|
114
|
+
return bufferSchemaFor(InboxParityPrivateInputs);
|
|
115
|
+
}
|
|
116
|
+
}
|
package/src/parity/index.ts
CHANGED
|
@@ -4,28 +4,26 @@ import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
|
4
4
|
import { bufferToHex, hexToBuffer } from '@aztec/foundation/string';
|
|
5
5
|
import type { FieldsOf } from '@aztec/foundation/types';
|
|
6
6
|
|
|
7
|
+
import { L1ToL2MessageSponge } from '../messaging/l1_to_l2_message_sponge.js';
|
|
8
|
+
|
|
7
9
|
export class ParityPublicInputs {
|
|
8
10
|
constructor(
|
|
9
|
-
/**
|
|
10
|
-
public
|
|
11
|
-
/**
|
|
12
|
-
public
|
|
13
|
-
/**
|
|
14
|
-
public
|
|
11
|
+
/** Inbox rolling hash before absorbing this checkpoint's messages. */
|
|
12
|
+
public startRollingHash: Fr,
|
|
13
|
+
/** Inbox rolling hash after absorbing the checkpoint's real messages. */
|
|
14
|
+
public endRollingHash: Fr,
|
|
15
|
+
/** Message-bundle sponge after absorbing the same real messages into the empty per-checkpoint sponge. */
|
|
16
|
+
public endSponge: L1ToL2MessageSponge,
|
|
15
17
|
/** Prover identity committed to by the circuit, for sybil protection. */
|
|
16
18
|
public proverId: Fr,
|
|
17
|
-
) {
|
|
18
|
-
if (shaRoot.toBuffer()[0] != 0) {
|
|
19
|
-
throw new Error(`shaRoot buffer must be 31 bytes. Got 32 bytes`);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
19
|
+
) {}
|
|
22
20
|
|
|
23
21
|
/**
|
|
24
22
|
* Serializes the inputs to a buffer.
|
|
25
23
|
* @returns The inputs serialized to a buffer.
|
|
26
24
|
*/
|
|
27
25
|
toBuffer() {
|
|
28
|
-
return serializeToBuffer(
|
|
26
|
+
return serializeToBuffer(this.startRollingHash, this.endRollingHash, this.endSponge, this.proverId);
|
|
29
27
|
}
|
|
30
28
|
|
|
31
29
|
/**
|
|
@@ -56,7 +54,7 @@ export class ParityPublicInputs {
|
|
|
56
54
|
* @returns The instance fields.
|
|
57
55
|
*/
|
|
58
56
|
static getFields(fields: FieldsOf<ParityPublicInputs>) {
|
|
59
|
-
return [fields.
|
|
57
|
+
return [fields.startRollingHash, fields.endRollingHash, fields.endSponge, fields.proverId] as const;
|
|
60
58
|
}
|
|
61
59
|
|
|
62
60
|
/**
|
|
@@ -69,7 +67,7 @@ export class ParityPublicInputs {
|
|
|
69
67
|
return new ParityPublicInputs(
|
|
70
68
|
reader.readObject(Fr),
|
|
71
69
|
reader.readObject(Fr),
|
|
72
|
-
|
|
70
|
+
reader.readObject(L1ToL2MessageSponge),
|
|
73
71
|
Fr.fromBuffer(reader),
|
|
74
72
|
);
|
|
75
73
|
}
|
|
@@ -5,11 +5,9 @@ export enum ProvingRequestType {
|
|
|
5
5
|
PRIVATE_TX_BASE_ROLLUP,
|
|
6
6
|
PUBLIC_TX_BASE_ROLLUP,
|
|
7
7
|
TX_MERGE_ROLLUP,
|
|
8
|
-
BLOCK_ROOT_FIRST_ROLLUP,
|
|
9
|
-
BLOCK_ROOT_SINGLE_TX_FIRST_ROLLUP,
|
|
10
|
-
BLOCK_ROOT_EMPTY_TX_FIRST_ROLLUP,
|
|
11
8
|
BLOCK_ROOT_ROLLUP,
|
|
12
9
|
BLOCK_ROOT_SINGLE_TX_ROLLUP,
|
|
10
|
+
BLOCK_ROOT_NO_TXS_ROLLUP,
|
|
13
11
|
BLOCK_MERGE_ROLLUP,
|
|
14
12
|
CHECKPOINT_ROOT_ROLLUP,
|
|
15
13
|
CHECKPOINT_ROOT_SINGLE_BLOCK_ROLLUP,
|
|
@@ -17,6 +15,5 @@ export enum ProvingRequestType {
|
|
|
17
15
|
CHECKPOINT_MERGE_ROLLUP,
|
|
18
16
|
ROOT_ROLLUP,
|
|
19
17
|
|
|
20
|
-
|
|
21
|
-
PARITY_ROOT,
|
|
18
|
+
INBOX_PARITY,
|
|
22
19
|
}
|
|
@@ -13,10 +13,10 @@ export class BlockConstantData {
|
|
|
13
13
|
/** Archive tree snapshot at the very beginning of the entire rollup. */
|
|
14
14
|
public lastArchive: AppendOnlyTreeSnapshot,
|
|
15
15
|
/**
|
|
16
|
-
* L1-to-L2 message tree snapshot after this block
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
16
|
+
* L1-to-L2 message tree snapshot after this block's own message bundle has been inserted. The AVM validates this
|
|
17
|
+
* block's l1-to-l2 message read requests against it, so a tx in this block can read the messages this block
|
|
18
|
+
* inserts (same-block consumption). Every block-root variant that carries txs asserts this equals its computed
|
|
19
|
+
* post-bundle root, whether or not the block is the first in its checkpoint.
|
|
20
20
|
*/
|
|
21
21
|
public l1ToL2TreeSnapshot: AppendOnlyTreeSnapshot,
|
|
22
22
|
/** Root of the verification key tree. */
|