@aztec/stdlib 5.0.0-nightly.20260324 → 5.0.0-nightly.20260331
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/decoder.d.ts +5 -44
- package/dest/abi/decoder.d.ts.map +1 -1
- package/dest/abi/decoder.js +12 -67
- package/dest/abi/function_selector.js +1 -1
- package/dest/abi/function_signature_decoder.d.ts +43 -0
- package/dest/abi/function_signature_decoder.d.ts.map +1 -0
- package/dest/abi/function_signature_decoder.js +66 -0
- package/dest/abi/index.d.ts +2 -1
- package/dest/abi/index.d.ts.map +1 -1
- package/dest/abi/index.js +1 -0
- package/dest/block/l2_block_source.d.ts +80 -3
- package/dest/block/l2_block_source.d.ts.map +1 -1
- package/dest/block/l2_block_source.js +1 -0
- package/dest/block/l2_block_stream/l2_tips_store_base.d.ts +1 -1
- 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 +17 -4
- 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 +3 -2
- package/dest/checkpoint/checkpoint.d.ts +7 -1
- package/dest/checkpoint/checkpoint.d.ts.map +1 -1
- package/dest/checkpoint/checkpoint.js +9 -1
- package/dest/checkpoint/checkpoint_data.d.ts +71 -5
- package/dest/checkpoint/checkpoint_data.d.ts.map +1 -1
- package/dest/checkpoint/checkpoint_data.js +10 -0
- package/dest/epoch-helpers/index.d.ts +5 -1
- package/dest/epoch-helpers/index.d.ts.map +1 -1
- package/dest/epoch-helpers/index.js +6 -0
- package/dest/file-store/factory.d.ts +4 -3
- package/dest/file-store/factory.d.ts.map +1 -1
- package/dest/file-store/factory.js +2 -2
- package/dest/file-store/http.d.ts +9 -2
- package/dest/file-store/http.d.ts.map +1 -1
- package/dest/file-store/http.js +20 -9
- package/dest/file-store/index.d.ts +2 -1
- package/dest/file-store/index.d.ts.map +1 -1
- package/dest/hash/hash.d.ts +4 -1
- package/dest/hash/hash.d.ts.map +1 -1
- package/dest/hash/hash.js +5 -0
- package/dest/interfaces/archiver.d.ts +1 -1
- package/dest/interfaces/archiver.d.ts.map +1 -1
- package/dest/interfaces/archiver.js +3 -1
- package/dest/interfaces/aztec-node-admin.d.ts +1 -4
- package/dest/interfaces/aztec-node-admin.d.ts.map +1 -1
- package/dest/interfaces/validator.d.ts +2 -10
- package/dest/interfaces/validator.d.ts.map +1 -1
- package/dest/interfaces/validator.js +0 -1
- package/dest/logs/message_context.d.ts +4 -7
- package/dest/logs/message_context.d.ts.map +1 -1
- package/dest/logs/message_context.js +23 -9
- package/dest/logs/pending_tagged_log.d.ts +2 -3
- package/dest/logs/pending_tagged_log.d.ts.map +1 -1
- package/dest/logs/pending_tagged_log.js +2 -2
- package/dest/logs/shared_secret_derivation.d.ts +11 -10
- package/dest/logs/shared_secret_derivation.d.ts.map +1 -1
- package/dest/logs/shared_secret_derivation.js +15 -9
- package/dest/logs/siloed_tag.d.ts +4 -1
- package/dest/logs/siloed_tag.d.ts.map +1 -1
- package/dest/logs/siloed_tag.js +7 -3
- package/dest/messaging/l1_to_l2_message.d.ts +3 -2
- package/dest/messaging/l1_to_l2_message.d.ts.map +1 -1
- package/dest/messaging/l1_to_l2_message.js +11 -13
- package/dest/note/note_dao.d.ts +1 -1
- package/dest/note/note_dao.d.ts.map +1 -1
- package/dest/note/note_dao.js +1 -4
- package/dest/proofs/chonk_proof.d.ts +46 -2
- package/dest/proofs/chonk_proof.d.ts.map +1 -1
- package/dest/proofs/chonk_proof.js +85 -10
- package/dest/tests/factories.d.ts +1 -1
- package/dest/tests/factories.d.ts.map +1 -1
- package/dest/tests/factories.js +10 -0
- package/dest/tx/capsule.d.ts +6 -2
- package/dest/tx/capsule.d.ts.map +1 -1
- package/dest/tx/capsule.js +9 -3
- package/dest/tx/global_variable_builder.d.ts +14 -2
- package/dest/tx/global_variable_builder.d.ts.map +1 -1
- package/package.json +8 -8
- package/src/abi/decoder.ts +23 -78
- package/src/abi/function_selector.ts +1 -1
- package/src/abi/function_signature_decoder.ts +77 -0
- package/src/abi/index.ts +1 -0
- package/src/block/l2_block_source.ts +10 -2
- package/src/block/l2_block_stream/l2_tips_store_base.ts +24 -12
- package/src/block/test/l2_tips_store_test_suite.ts +8 -1
- package/src/checkpoint/checkpoint.ts +11 -1
- package/src/checkpoint/checkpoint_data.ts +40 -4
- package/src/epoch-helpers/index.ts +13 -0
- package/src/file-store/factory.ts +13 -4
- package/src/file-store/http.ts +29 -10
- package/src/file-store/index.ts +1 -0
- package/src/hash/hash.ts +5 -0
- package/src/interfaces/archiver.ts +3 -1
- package/src/interfaces/validator.ts +1 -5
- package/src/logs/message_context.ts +17 -7
- package/src/logs/pending_tagged_log.ts +1 -3
- package/src/logs/shared_secret_derivation.ts +21 -10
- package/src/logs/siloed_tag.ts +7 -2
- package/src/messaging/l1_to_l2_message.ts +12 -9
- package/src/note/note_dao.ts +1 -4
- package/src/proofs/chonk_proof.ts +91 -5
- package/src/tests/factories.ts +4 -0
- package/src/tx/capsule.ts +10 -2
- package/src/tx/global_variable_builder.ts +15 -0
|
@@ -13,7 +13,7 @@ import type { TypedEventEmitter } from '@aztec/foundation/types';
|
|
|
13
13
|
import { z } from 'zod';
|
|
14
14
|
|
|
15
15
|
import type { Checkpoint } from '../checkpoint/checkpoint.js';
|
|
16
|
-
import type { CheckpointData } from '../checkpoint/checkpoint_data.js';
|
|
16
|
+
import type { CheckpointData, CommonCheckpointData, ProposedCheckpointData } from '../checkpoint/checkpoint_data.js';
|
|
17
17
|
import type { PublishedCheckpoint } from '../checkpoint/published_checkpoint.js';
|
|
18
18
|
import type { L1RollupConstants } from '../epoch-helpers/index.js';
|
|
19
19
|
import { CheckpointHeader } from '../rollup/checkpoint_header.js';
|
|
@@ -229,6 +229,12 @@ export interface L2BlockSource {
|
|
|
229
229
|
*/
|
|
230
230
|
getPendingChainValidationStatus(): Promise<ValidateCheckpointResult>;
|
|
231
231
|
|
|
232
|
+
/** Returns the checkpoint at the proposed chain tip. */
|
|
233
|
+
getProposedCheckpoint(): Promise<CommonCheckpointData | undefined>;
|
|
234
|
+
|
|
235
|
+
/** Returns proposed checkpoint, if set, undefined if not*/
|
|
236
|
+
getProposedCheckpointOnly(): Promise<ProposedCheckpointData | undefined>;
|
|
237
|
+
|
|
232
238
|
/** Force a sync. */
|
|
233
239
|
syncImmediate(): Promise<void>;
|
|
234
240
|
|
|
@@ -312,12 +318,13 @@ export interface L2BlockSourceEventEmitter extends L2BlockSource {
|
|
|
312
318
|
* - proven: Proven block on L1.
|
|
313
319
|
* - finalized: Proven block on a finalized L1 block (not implemented, set to proven for now).
|
|
314
320
|
*/
|
|
315
|
-
export type L2BlockTag = 'proposed' | 'checkpointed' | 'proven' | 'finalized';
|
|
321
|
+
export type L2BlockTag = 'proposed' | 'proposedCheckpoint' | 'checkpointed' | 'proven' | 'finalized';
|
|
316
322
|
|
|
317
323
|
/** Tips of the L2 chain. */
|
|
318
324
|
export type L2Tips = {
|
|
319
325
|
proposed: L2BlockId;
|
|
320
326
|
checkpointed: L2TipId;
|
|
327
|
+
proposedCheckpoint: L2TipId;
|
|
321
328
|
proven: L2TipId;
|
|
322
329
|
finalized: L2TipId;
|
|
323
330
|
};
|
|
@@ -362,6 +369,7 @@ const L2TipIdSchema = z.object({
|
|
|
362
369
|
export const L2TipsSchema = z.object({
|
|
363
370
|
proposed: L2BlockIdSchema,
|
|
364
371
|
checkpointed: L2TipIdSchema,
|
|
372
|
+
proposedCheckpoint: L2TipIdSchema,
|
|
365
373
|
proven: L2TipIdSchema,
|
|
366
374
|
finalized: L2TipIdSchema,
|
|
367
375
|
});
|
|
@@ -66,24 +66,29 @@ export abstract class L2TipsStoreBase implements L2BlockStreamEventHandler, L2Bl
|
|
|
66
66
|
|
|
67
67
|
public getL2Tips(): Promise<L2Tips> {
|
|
68
68
|
return this.runInTransaction(async () => {
|
|
69
|
-
const [proposedBlockId, finalizedBlockId, provenBlockId, checkpointedBlockId] =
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
69
|
+
const [proposedBlockId, finalizedBlockId, provenBlockId, checkpointedBlockId, proposedCheckpointBlockId] =
|
|
70
|
+
await Promise.all([
|
|
71
|
+
this.getBlockId('proposed'),
|
|
72
|
+
this.getBlockId('finalized'),
|
|
73
|
+
this.getBlockId('proven'),
|
|
74
|
+
this.getBlockId('checkpointed'),
|
|
75
|
+
this.getBlockId('proposedCheckpoint'),
|
|
76
|
+
]);
|
|
77
|
+
|
|
78
|
+
const [finalizedCheckpointId, provenCheckpointId, checkpointedCheckpointId, proposedCheckpointId] =
|
|
79
|
+
await Promise.all([
|
|
80
|
+
this.getCheckpointId('finalized'),
|
|
81
|
+
this.getCheckpointId('proven'),
|
|
82
|
+
this.getCheckpointId('checkpointed'),
|
|
83
|
+
this.getCheckpointId('proposedCheckpoint'),
|
|
84
|
+
]);
|
|
81
85
|
|
|
82
86
|
return {
|
|
83
87
|
proposed: proposedBlockId,
|
|
84
88
|
finalized: { block: finalizedBlockId, checkpoint: finalizedCheckpointId },
|
|
85
89
|
proven: { block: provenBlockId, checkpoint: provenCheckpointId },
|
|
86
90
|
checkpointed: { block: checkpointedBlockId, checkpoint: checkpointedCheckpointId },
|
|
91
|
+
proposedCheckpoint: { block: proposedCheckpointBlockId, checkpoint: proposedCheckpointId },
|
|
87
92
|
};
|
|
88
93
|
});
|
|
89
94
|
}
|
|
@@ -164,6 +169,12 @@ export abstract class L2TipsStoreBase implements L2BlockStreamEventHandler, L2Bl
|
|
|
164
169
|
await this.runInTransaction(async () => {
|
|
165
170
|
await this.saveTag('checkpointed', event.block);
|
|
166
171
|
await this.saveCheckpoint(event.checkpoint);
|
|
172
|
+
// proposedCheckpoint is always >= checkpointed. If checkpointed has caught up
|
|
173
|
+
// or surpassed it, advance proposedCheckpoint to match.
|
|
174
|
+
const proposedCheckpointBlock = await this.getBlockId('proposedCheckpoint');
|
|
175
|
+
if (event.block.number > proposedCheckpointBlock.number) {
|
|
176
|
+
await this.saveTag('proposedCheckpoint', event.block);
|
|
177
|
+
}
|
|
167
178
|
});
|
|
168
179
|
}
|
|
169
180
|
|
|
@@ -174,6 +185,7 @@ export abstract class L2TipsStoreBase implements L2BlockStreamEventHandler, L2Bl
|
|
|
174
185
|
await this.runInTransaction(async () => {
|
|
175
186
|
await this.saveTag('proposed', event.block);
|
|
176
187
|
await this.saveTag('checkpointed', event.block);
|
|
188
|
+
await this.saveTag('proposedCheckpoint', event.block);
|
|
177
189
|
const storeProven = await this.getBlockId('proven');
|
|
178
190
|
if (storeProven.number > event.block.number) {
|
|
179
191
|
await this.saveTag('proven', event.block);
|
|
@@ -67,11 +67,18 @@ export function testL2TipsStore(makeTipsStore: () => Promise<L2TipsStore>) {
|
|
|
67
67
|
checkpoint: makeCheckpointIdForBlock(blockNumber),
|
|
68
68
|
});
|
|
69
69
|
|
|
70
|
-
const makeTips = (
|
|
70
|
+
const makeTips = (
|
|
71
|
+
proposed: number,
|
|
72
|
+
proven: number,
|
|
73
|
+
finalized: number,
|
|
74
|
+
checkpointed: number = 0,
|
|
75
|
+
proposedCheckpoint: number = 0,
|
|
76
|
+
) => ({
|
|
71
77
|
proposed: makeTip(proposed),
|
|
72
78
|
proven: makeTipId(proven),
|
|
73
79
|
finalized: makeTipId(finalized),
|
|
74
80
|
checkpointed: makeTipId(checkpointed),
|
|
81
|
+
proposedCheckpoint: makeTipId(proposedCheckpoint),
|
|
75
82
|
});
|
|
76
83
|
|
|
77
84
|
const makeCheckpoint = async (checkpointNumber: number, blocks: L2Block[]): Promise<PublishedCheckpoint> => {
|
|
@@ -100,7 +100,16 @@ export class Checkpoint {
|
|
|
100
100
|
* checkpoints up to and including this one in the epoch.
|
|
101
101
|
*/
|
|
102
102
|
public getCheckpointOutHash(): Fr {
|
|
103
|
-
|
|
103
|
+
return Checkpoint.getCheckpointOutHash(this.blocks);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Returns the out hash computed from all l2-to-l1 messages in this checkpoint.
|
|
108
|
+
* Note: This value is different from the out hash in the header, which is the **accumulated** out hash over all
|
|
109
|
+
* checkpoints up to and including this one in the epoch.
|
|
110
|
+
*/
|
|
111
|
+
static getCheckpointOutHash(blocks: L2Block[]): Fr {
|
|
112
|
+
const msgs = blocks.map(block => block.body.txEffects.map(txEffect => txEffect.l2ToL1Msgs));
|
|
104
113
|
return computeCheckpointOutHash(msgs);
|
|
105
114
|
}
|
|
106
115
|
|
|
@@ -165,6 +174,7 @@ export class Checkpoint {
|
|
|
165
174
|
let lastArchive = previousArchive;
|
|
166
175
|
for (let i = 0; i < numBlocks; i++) {
|
|
167
176
|
const block = await L2Block.random(BlockNumber(startBlockNumber + i), {
|
|
177
|
+
checkpointNumber,
|
|
168
178
|
indexWithinCheckpoint: IndexWithinCheckpoint(i),
|
|
169
179
|
...options,
|
|
170
180
|
...(lastArchive ? { lastArchive } : {}),
|
|
@@ -14,18 +14,54 @@ import { CheckpointHeader } from '../rollup/checkpoint_header.js';
|
|
|
14
14
|
import { AppendOnlyTreeSnapshot } from '../trees/append_only_tree_snapshot.js';
|
|
15
15
|
import { L1PublishedData } from './published_checkpoint.js';
|
|
16
16
|
|
|
17
|
-
/**
|
|
18
|
-
export type
|
|
17
|
+
/** Base type for checkpoint data */
|
|
18
|
+
export type CommonCheckpointData = {
|
|
19
19
|
checkpointNumber: CheckpointNumber;
|
|
20
20
|
header: CheckpointHeader;
|
|
21
|
-
archive: AppendOnlyTreeSnapshot;
|
|
22
|
-
checkpointOutHash: Fr;
|
|
23
21
|
startBlock: BlockNumber;
|
|
24
22
|
blockCount: number;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/** Data stored with checkpoint data after publishing on l1 */
|
|
26
|
+
export type L1EnrichedCheckpointData = {
|
|
25
27
|
attestations: CommitteeAttestation[];
|
|
26
28
|
l1: L1PublishedData;
|
|
27
29
|
};
|
|
28
30
|
|
|
31
|
+
/** Data stored alongside checkpoint data in storage */
|
|
32
|
+
export type StorageEnrichedCheckpointData = {
|
|
33
|
+
archive: AppendOnlyTreeSnapshot;
|
|
34
|
+
checkpointOutHash: Fr;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/** Data stored only with proposed checkpoint data */
|
|
38
|
+
export type ProposedOnlyCheckpointData = {
|
|
39
|
+
totalManaUsed: bigint;
|
|
40
|
+
feeAssetPriceModifier: bigint;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/** Lightweight checkpoint metadata without full block data. */
|
|
44
|
+
export type CheckpointData = CommonCheckpointData & StorageEnrichedCheckpointData & L1EnrichedCheckpointData;
|
|
45
|
+
|
|
46
|
+
/** Input for setting a proposed checkpoint. The archive and checkpointOutHash are computed
|
|
47
|
+
* internally by the block store from the stored blocks. */
|
|
48
|
+
export type ProposedCheckpointInput = CommonCheckpointData & ProposedOnlyCheckpointData;
|
|
49
|
+
|
|
50
|
+
/** Full data for a proposed checkpoint (proposed but not yet L1-confirmed).
|
|
51
|
+
* Includes fee-relevant fields used during pipelining to compute the fee header override. */
|
|
52
|
+
export type ProposedCheckpointData = ProposedCheckpointInput & StorageEnrichedCheckpointData;
|
|
53
|
+
|
|
54
|
+
export const ProposedCheckpointDataSchema = z.object({
|
|
55
|
+
checkpointNumber: CheckpointNumberSchema,
|
|
56
|
+
header: CheckpointHeader.schema,
|
|
57
|
+
archive: AppendOnlyTreeSnapshot.schema,
|
|
58
|
+
checkpointOutHash: schemas.Fr,
|
|
59
|
+
startBlock: BlockNumberSchema,
|
|
60
|
+
blockCount: z.number(),
|
|
61
|
+
totalManaUsed: schemas.BigInt,
|
|
62
|
+
feeAssetPriceModifier: schemas.BigInt,
|
|
63
|
+
});
|
|
64
|
+
|
|
29
65
|
export const CheckpointDataSchema = z
|
|
30
66
|
.object({
|
|
31
67
|
checkpointNumber: CheckpointNumberSchema,
|
|
@@ -68,6 +68,14 @@ export function getNextL1SlotTimestamp(
|
|
|
68
68
|
return constants.l1GenesisTime + (currentL1Slot + 1n) * BigInt(constants.ethereumSlotDuration);
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
+
/** Returns the timestamp of the last L1 slot within a given L2 slot. */
|
|
72
|
+
export function getLastL1SlotTimestampForL2Slot(
|
|
73
|
+
slot: SlotNumber,
|
|
74
|
+
constants: Pick<L1RollupConstants, 'l1GenesisTime' | 'slotDuration' | 'ethereumSlotDuration'>,
|
|
75
|
+
): bigint {
|
|
76
|
+
return getTimestampForSlot(slot, constants) + BigInt(constants.slotDuration - constants.ethereumSlotDuration);
|
|
77
|
+
}
|
|
78
|
+
|
|
71
79
|
/** Returns the L2 slot number at the next L1 block based on the current timestamp. */
|
|
72
80
|
export function getSlotAtNextL1Block(
|
|
73
81
|
currentL1Timestamp: bigint,
|
|
@@ -154,6 +162,11 @@ export function getProofSubmissionDeadlineTimestamp(
|
|
|
154
162
|
return getTimestampForSlot(deadlineSlot, constants);
|
|
155
163
|
}
|
|
156
164
|
|
|
165
|
+
/** Computes the quorum size required for a committee (⌊2n/3⌋ + 1). */
|
|
166
|
+
export function computeQuorum(committeeSize: number): number {
|
|
167
|
+
return Math.floor((committeeSize * 2) / 3) + 1;
|
|
168
|
+
}
|
|
169
|
+
|
|
157
170
|
/** Returns the timestamp to start building a block for a given L2 slot. Computed as the start timestamp of the slot minus one L1 slot duration. */
|
|
158
171
|
export function getSlotStartBuildTimestamp(
|
|
159
172
|
slotNumber: SlotNumber,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
2
2
|
|
|
3
3
|
import { GoogleCloudFileStore } from './gcs.js';
|
|
4
|
-
import { HttpFileStore } from './http.js';
|
|
4
|
+
import { HttpFileStore, type HttpFileStoreOptions } from './http.js';
|
|
5
5
|
import type { FileStore, ReadOnlyFileStore } from './interface.js';
|
|
6
6
|
import { LocalFileStore } from './local.js';
|
|
7
7
|
import { S3FileStore } from './s3.js';
|
|
@@ -59,17 +59,26 @@ export async function createFileStore(
|
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
export async function createReadOnlyFileStore(
|
|
63
|
-
|
|
62
|
+
export async function createReadOnlyFileStore(
|
|
63
|
+
config: string,
|
|
64
|
+
logger?: Logger,
|
|
65
|
+
options?: HttpFileStoreOptions,
|
|
66
|
+
): Promise<ReadOnlyFileStore>;
|
|
67
|
+
export async function createReadOnlyFileStore(
|
|
68
|
+
config: undefined,
|
|
69
|
+
logger?: Logger,
|
|
70
|
+
options?: HttpFileStoreOptions,
|
|
71
|
+
): Promise<undefined>;
|
|
64
72
|
export async function createReadOnlyFileStore(
|
|
65
73
|
config: string | undefined,
|
|
66
74
|
logger = createLogger('stdlib:file-store'),
|
|
75
|
+
options?: HttpFileStoreOptions,
|
|
67
76
|
): Promise<ReadOnlyFileStore | undefined> {
|
|
68
77
|
if (config === undefined) {
|
|
69
78
|
return undefined;
|
|
70
79
|
} else if (config.startsWith('http://') || config.startsWith('https://')) {
|
|
71
80
|
logger.info(`Creating read-only HTTP file store at ${config}`);
|
|
72
|
-
return new HttpFileStore(config, logger);
|
|
81
|
+
return new HttpFileStore(config, logger, options);
|
|
73
82
|
} else {
|
|
74
83
|
return await createFileStore(config, logger);
|
|
75
84
|
}
|
package/src/file-store/http.ts
CHANGED
|
@@ -10,6 +10,14 @@ import { pipeline } from 'stream/promises';
|
|
|
10
10
|
|
|
11
11
|
import type { ReadOnlyFileStore } from './interface.js';
|
|
12
12
|
|
|
13
|
+
/** Options for configuring HttpFileStore behavior. */
|
|
14
|
+
export interface HttpFileStoreOptions {
|
|
15
|
+
/** Retry backoff intervals in seconds. Empty array disables retries. Default: [1, 1, 3]. */
|
|
16
|
+
retryBackoff?: number[];
|
|
17
|
+
/** Request timeout in milliseconds. Default: no timeout (axios default). */
|
|
18
|
+
timeoutMs?: number;
|
|
19
|
+
}
|
|
20
|
+
|
|
13
21
|
export class HttpFileStore implements ReadOnlyFileStore {
|
|
14
22
|
private readonly axiosInstance: AxiosInstance;
|
|
15
23
|
private readonly fetch: <T>(config: AxiosRequestConfig) => Promise<AxiosResponse<T>>;
|
|
@@ -17,17 +25,28 @@ export class HttpFileStore implements ReadOnlyFileStore {
|
|
|
17
25
|
constructor(
|
|
18
26
|
private readonly baseUrl: string,
|
|
19
27
|
private readonly log: Logger = createLogger('stdlib:http-file-store'),
|
|
28
|
+
options?: HttpFileStoreOptions,
|
|
20
29
|
) {
|
|
21
|
-
this.axiosInstance = axios.create(
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
30
|
+
this.axiosInstance = axios.create({
|
|
31
|
+
...(options?.timeoutMs !== undefined && { timeout: options.timeoutMs }),
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
const retryBackoff = options?.retryBackoff ?? [1, 1, 3];
|
|
35
|
+
if (retryBackoff.length > 0) {
|
|
36
|
+
this.fetch = async <T>(config: AxiosRequestConfig) => {
|
|
37
|
+
return await retry(
|
|
38
|
+
() => this.axiosInstance.request<T>(config),
|
|
39
|
+
`Fetching ${config.url}`,
|
|
40
|
+
makeBackoff(retryBackoff),
|
|
41
|
+
this.log,
|
|
42
|
+
/*failSilently=*/ true,
|
|
43
|
+
);
|
|
44
|
+
};
|
|
45
|
+
} else {
|
|
46
|
+
this.fetch = async <T>(config: AxiosRequestConfig) => {
|
|
47
|
+
return await this.axiosInstance.request<T>(config);
|
|
48
|
+
};
|
|
49
|
+
}
|
|
31
50
|
}
|
|
32
51
|
|
|
33
52
|
public async read(pathOrUrl: string): Promise<Buffer> {
|
package/src/file-store/index.ts
CHANGED
package/src/hash/hash.ts
CHANGED
|
@@ -98,6 +98,11 @@ export function computeProtocolNullifier(txRequestHash: Fr): Promise<Fr> {
|
|
|
98
98
|
return siloNullifier(AztecAddress.fromBigInt(NULL_MSG_SENDER_CONTRACT_ADDRESS), txRequestHash);
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
+
/** Domain-separates a raw log tag with the given domain separator. */
|
|
102
|
+
export function computeLogTag(rawTag: number | bigint | boolean | Fr | Buffer, domSep: DomainSeparator): Promise<Fr> {
|
|
103
|
+
return poseidon2HashWithSeparator([new Fr(rawTag)], domSep);
|
|
104
|
+
}
|
|
105
|
+
|
|
101
106
|
export function computeSiloedPrivateLogFirstField(contract: AztecAddress, field: Fr): Promise<Fr> {
|
|
102
107
|
return poseidon2HashWithSeparator([contract, field], DomainSeparator.PRIVATE_LOG_FIRST_FIELD);
|
|
103
108
|
}
|
|
@@ -11,7 +11,7 @@ import { L2Block } from '../block/l2_block.js';
|
|
|
11
11
|
import { type L2BlockSource, L2TipsSchema } from '../block/l2_block_source.js';
|
|
12
12
|
import { ValidateCheckpointResultSchema } from '../block/validate_block_result.js';
|
|
13
13
|
import { Checkpoint } from '../checkpoint/checkpoint.js';
|
|
14
|
-
import { CheckpointDataSchema } from '../checkpoint/checkpoint_data.js';
|
|
14
|
+
import { CheckpointDataSchema, ProposedCheckpointDataSchema } from '../checkpoint/checkpoint_data.js';
|
|
15
15
|
import { PublishedCheckpoint } from '../checkpoint/published_checkpoint.js';
|
|
16
16
|
import {
|
|
17
17
|
ContractClassPublicSchema,
|
|
@@ -150,6 +150,8 @@ export const ArchiverApiSchema: ApiSchemaFor<ArchiverApi> = {
|
|
|
150
150
|
.args()
|
|
151
151
|
.returns(z.object({ genesisArchiveRoot: schemas.Fr })),
|
|
152
152
|
getL1Timestamp: z.function().args().returns(schemas.BigInt.optional()),
|
|
153
|
+
getProposedCheckpoint: z.function().args().returns(ProposedCheckpointDataSchema.optional()),
|
|
154
|
+
getProposedCheckpointOnly: z.function().args().returns(ProposedCheckpointDataSchema.optional()),
|
|
153
155
|
syncImmediate: z.function().args().returns(z.void()),
|
|
154
156
|
isPendingChainInvalid: z.function().args().returns(z.boolean()),
|
|
155
157
|
getPendingChainValidationStatus: z.function().args().returns(ValidateCheckpointResultSchema),
|
|
@@ -48,10 +48,7 @@ export type ValidatorClientConfig = ValidatorHASignerConfig &
|
|
|
48
48
|
/** Interval between polling for new attestations from peers */
|
|
49
49
|
attestationPollingIntervalMs: number;
|
|
50
50
|
|
|
51
|
-
/** Whether to
|
|
52
|
-
validatorReexecute: boolean;
|
|
53
|
-
|
|
54
|
-
/** Whether to always reexecute block proposals, even for non-validator nodes or when out of the currnet committee */
|
|
51
|
+
/** Whether to always reexecute block proposals, even for non-validator nodes or when out of the current committee */
|
|
55
52
|
alwaysReexecuteBlockProposals?: boolean;
|
|
56
53
|
|
|
57
54
|
/** Whether to run in fisherman mode: validates all proposals and attestations but does not broadcast attestations or participate in consensus */
|
|
@@ -98,7 +95,6 @@ export const ValidatorClientConfigSchema = zodFor<Omit<ValidatorClientConfig, 'v
|
|
|
98
95
|
disableValidator: z.boolean(),
|
|
99
96
|
disabledValidators: z.array(schemas.EthAddress),
|
|
100
97
|
attestationPollingIntervalMs: z.number().min(0),
|
|
101
|
-
validatorReexecute: z.boolean(),
|
|
102
98
|
alwaysReexecuteBlockProposals: z.boolean().optional(),
|
|
103
99
|
fishermanMode: z.boolean().optional(),
|
|
104
100
|
skipCheckpointProposalValidation: z.boolean().optional(),
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { MAX_NOTE_HASHES_PER_TX } from '@aztec/constants';
|
|
2
|
+
import { range } from '@aztec/foundation/array';
|
|
2
3
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
4
|
|
|
4
|
-
import type { AztecAddress } from '../aztec-address/index.js';
|
|
5
|
-
import type { TxEffect } from '../tx/tx_effect.js';
|
|
6
5
|
import type { TxHash } from '../tx/tx_hash.js';
|
|
7
6
|
|
|
8
7
|
/**
|
|
@@ -19,7 +18,6 @@ export class MessageContext {
|
|
|
19
18
|
public txHash: TxHash,
|
|
20
19
|
public uniqueNoteHashesInTx: Fr[],
|
|
21
20
|
public firstNullifierInTx: Fr,
|
|
22
|
-
public recipient: AztecAddress,
|
|
23
21
|
) {}
|
|
24
22
|
|
|
25
23
|
toFields(): Fr[] {
|
|
@@ -27,7 +25,6 @@ export class MessageContext {
|
|
|
27
25
|
this.txHash.hash,
|
|
28
26
|
...serializeBoundedVec(this.uniqueNoteHashesInTx, MAX_NOTE_HASHES_PER_TX),
|
|
29
27
|
this.firstNullifierInTx,
|
|
30
|
-
this.recipient.toField(),
|
|
31
28
|
];
|
|
32
29
|
}
|
|
33
30
|
|
|
@@ -37,13 +34,22 @@ export class MessageContext {
|
|
|
37
34
|
tx_hash: this.txHash.hash,
|
|
38
35
|
unique_note_hashes_in_tx: this.uniqueNoteHashesInTx,
|
|
39
36
|
first_nullifier_in_tx: this.firstNullifierInTx,
|
|
40
|
-
recipient: this.recipient,
|
|
41
37
|
};
|
|
42
38
|
/* eslint-enable camelcase */
|
|
43
39
|
}
|
|
44
40
|
|
|
45
|
-
static
|
|
46
|
-
|
|
41
|
+
static toEmptyFields(): Fr[] {
|
|
42
|
+
const serializationLen =
|
|
43
|
+
1 /* txHash */ + MAX_NOTE_HASHES_PER_TX + 1 /* uniqueNoteHashesInTx BVec */ + 1; /* firstNullifierInTx */
|
|
44
|
+
return range(serializationLen).map(_ => Fr.zero());
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
static toSerializedOption(response: MessageContext | null): Fr[] {
|
|
48
|
+
if (response) {
|
|
49
|
+
return [new Fr(1), ...response.toFields()];
|
|
50
|
+
} else {
|
|
51
|
+
return [new Fr(0), ...MessageContext.toEmptyFields()];
|
|
52
|
+
}
|
|
47
53
|
}
|
|
48
54
|
}
|
|
49
55
|
|
|
@@ -55,6 +61,10 @@ export class MessageContext {
|
|
|
55
61
|
* @dev Copied over from pending_tagged_log.ts.
|
|
56
62
|
*/
|
|
57
63
|
function serializeBoundedVec(values: Fr[], maxLength: number): Fr[] {
|
|
64
|
+
if (values.length > maxLength) {
|
|
65
|
+
throw new Error(`Attempted to serialize ${values} values into a BoundedVec with max length ${maxLength}`);
|
|
66
|
+
}
|
|
67
|
+
|
|
58
68
|
const lengthDiff = maxLength - values.length;
|
|
59
69
|
const zeroPaddingArray = Array(lengthDiff).fill(Fr.ZERO);
|
|
60
70
|
const storage = values.concat(zeroPaddingArray);
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { PRIVATE_LOG_SIZE_IN_FIELDS } from '@aztec/constants';
|
|
2
2
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
3
|
|
|
4
|
-
import type { AztecAddress } from '../aztec-address/index.js';
|
|
5
4
|
import type { TxHash } from '../tx/tx_hash.js';
|
|
6
5
|
import { MessageContext } from './message_context.js';
|
|
7
6
|
|
|
@@ -17,9 +16,8 @@ export class PendingTaggedLog {
|
|
|
17
16
|
txHash: TxHash,
|
|
18
17
|
uniqueNoteHashesInTx: Fr[],
|
|
19
18
|
firstNullifierInTx: Fr,
|
|
20
|
-
recipient: AztecAddress,
|
|
21
19
|
) {
|
|
22
|
-
this.context = new MessageContext(txHash, uniqueNoteHashesInTx, firstNullifierInTx
|
|
20
|
+
this.context = new MessageContext(txHash, uniqueNoteHashesInTx, firstNullifierInTx);
|
|
23
21
|
}
|
|
24
22
|
|
|
25
23
|
toFields(): Fr[] {
|
|
@@ -1,26 +1,37 @@
|
|
|
1
|
+
import { DomainSeparator } from '@aztec/constants';
|
|
1
2
|
import { Grumpkin } from '@aztec/foundation/crypto/grumpkin';
|
|
2
|
-
import
|
|
3
|
+
import { poseidon2HashWithSeparator } from '@aztec/foundation/crypto/poseidon';
|
|
4
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
5
|
+
import type { GrumpkinScalar } from '@aztec/foundation/curves/grumpkin';
|
|
3
6
|
|
|
7
|
+
import type { AztecAddress } from '../aztec-address/index.js';
|
|
4
8
|
import type { PublicKey } from '../keys/public_key.js';
|
|
5
9
|
|
|
6
10
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* the shared secret
|
|
11
|
+
* Derives an app-siloed ECDH shared secret.
|
|
12
|
+
*
|
|
13
|
+
* Computes the raw ECDH shared secret `S = secretKey * publicKey`, then app-silos it:
|
|
14
|
+
* `s_app = h(DOM_SEP__APP_SILOED_ECDH_SHARED_SECRET, S.x, S.y, contractAddress)`
|
|
10
15
|
*
|
|
11
16
|
* @param secretKey - The secret key used to derive shared secret.
|
|
12
17
|
* @param publicKey - The public key used to derive shared secret.
|
|
13
|
-
* @
|
|
18
|
+
* @param contractAddress - The address of the calling contract, used for app-siloing.
|
|
19
|
+
* @returns The app-siloed shared secret as a Field.
|
|
14
20
|
* @throws If the publicKey is zero.
|
|
15
|
-
*
|
|
16
|
-
* TODO(#12656): This function is kept around because of the utilityGetSharedSecret oracle. Nuke this once returning
|
|
17
|
-
* the app-siloed secret.
|
|
18
21
|
*/
|
|
19
|
-
export function
|
|
22
|
+
export async function deriveAppSiloedSharedSecret(
|
|
23
|
+
secretKey: GrumpkinScalar,
|
|
24
|
+
publicKey: PublicKey,
|
|
25
|
+
contractAddress: AztecAddress,
|
|
26
|
+
): Promise<Fr> {
|
|
20
27
|
if (publicKey.isZero()) {
|
|
21
28
|
throw new Error(
|
|
22
29
|
`Attempting to derive a shared secret with a zero public key. You have probably passed a zero public key in your Noir code somewhere thinking that the note won't be broadcast... but it was.`,
|
|
23
30
|
);
|
|
24
31
|
}
|
|
25
|
-
|
|
32
|
+
const rawSharedSecret = await Grumpkin.mul(publicKey, secretKey);
|
|
33
|
+
return poseidon2HashWithSeparator(
|
|
34
|
+
[rawSharedSecret.x, rawSharedSecret.y, contractAddress],
|
|
35
|
+
DomainSeparator.APP_SILOED_ECDH_SHARED_SECRET,
|
|
36
|
+
);
|
|
26
37
|
}
|
package/src/logs/siloed_tag.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { DomainSeparator } from '@aztec/constants';
|
|
1
2
|
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
3
|
import type { ZodFor } from '@aztec/foundation/schemas';
|
|
3
4
|
|
|
4
5
|
import type { AztecAddress } from '../aztec-address/index.js';
|
|
5
|
-
import { computeSiloedPrivateLogFirstField } from '../hash/hash.js';
|
|
6
|
+
import { computeLogTag, computeSiloedPrivateLogFirstField } from '../hash/hash.js';
|
|
6
7
|
import { schemas } from '../schemas/schemas.js';
|
|
7
8
|
import type { PreTag } from './pre_tag.js';
|
|
8
9
|
import { Tag } from './tag.js';
|
|
@@ -24,9 +25,13 @@ export class SiloedTag {
|
|
|
24
25
|
|
|
25
26
|
static async compute(preTag: PreTag): Promise<SiloedTag> {
|
|
26
27
|
const tag = await Tag.compute(preTag);
|
|
27
|
-
|
|
28
|
+
const logTag = await computeLogTag(tag.value, DomainSeparator.UNCONSTRAINED_MSG_LOG_TAG);
|
|
29
|
+
return SiloedTag.computeFromTagAndApp(new Tag(logTag), preTag.extendedSecret.app);
|
|
28
30
|
}
|
|
29
31
|
|
|
32
|
+
/**
|
|
33
|
+
* Unlike `compute`, this expects a tag whose value is already domain-separated.
|
|
34
|
+
*/
|
|
30
35
|
static async computeFromTagAndApp(tag: Tag, app: AztecAddress): Promise<SiloedTag> {
|
|
31
36
|
const siloedTag = await computeSiloedPrivateLogFirstField(app, tag.value);
|
|
32
37
|
return new SiloedTag(siloedTag);
|
|
@@ -6,6 +6,7 @@ import { bufferToHex } from '@aztec/foundation/string';
|
|
|
6
6
|
import { SiblingPath } from '@aztec/foundation/trees';
|
|
7
7
|
|
|
8
8
|
import type { AztecAddress } from '../aztec-address/index.js';
|
|
9
|
+
import type { BlockParameter } from '../block/block_parameter.js';
|
|
9
10
|
import { computeL1ToL2MessageNullifier } from '../hash/hash.js';
|
|
10
11
|
import type { AztecNode } from '../interfaces/aztec-node.js';
|
|
11
12
|
import { MerkleTreeId } from '../trees/merkle_tree_id.js';
|
|
@@ -79,20 +80,22 @@ export async function getNonNullifiedL1ToL2MessageWitness(
|
|
|
79
80
|
contractAddress: AztecAddress,
|
|
80
81
|
messageHash: Fr,
|
|
81
82
|
secret: Fr,
|
|
83
|
+
referenceBlock: BlockParameter = 'latest',
|
|
82
84
|
): Promise<[bigint, SiblingPath<typeof L1_TO_L2_MSG_TREE_HEIGHT>]> {
|
|
83
|
-
const
|
|
84
|
-
if (!response) {
|
|
85
|
-
throw new Error(`No L1 to L2 message found for message hash ${messageHash.toString()}`);
|
|
86
|
-
}
|
|
85
|
+
const messageNullifier = await computeL1ToL2MessageNullifier(contractAddress, messageHash, secret);
|
|
87
86
|
|
|
88
|
-
const [
|
|
87
|
+
const [l1ToL2Response, nullifierResponse] = await Promise.all([
|
|
88
|
+
node.getL1ToL2MessageMembershipWitness(referenceBlock, messageHash),
|
|
89
|
+
node.findLeavesIndexes(referenceBlock, MerkleTreeId.NULLIFIER_TREE, [messageNullifier]),
|
|
90
|
+
]);
|
|
89
91
|
|
|
90
|
-
|
|
92
|
+
if (!l1ToL2Response) {
|
|
93
|
+
throw new Error(`No L1 to L2 message found for message hash ${messageHash.toString()}`);
|
|
94
|
+
}
|
|
91
95
|
|
|
92
|
-
|
|
93
|
-
if (nullifierIndex !== undefined) {
|
|
96
|
+
if (nullifierResponse[0] !== undefined) {
|
|
94
97
|
throw new Error(`No non-nullified L1 to L2 message found for message hash ${messageHash.toString()}`);
|
|
95
98
|
}
|
|
96
99
|
|
|
97
|
-
return
|
|
100
|
+
return l1ToL2Response;
|
|
98
101
|
}
|
package/src/note/note_dao.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
2
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
|
-
import { Point } from '@aztec/foundation/curves/grumpkin';
|
|
4
3
|
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
5
4
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
6
5
|
import { Note } from '@aztec/stdlib/note';
|
|
@@ -148,9 +147,7 @@ export class NoteDao {
|
|
|
148
147
|
* @returns - Its size in bytes.
|
|
149
148
|
*/
|
|
150
149
|
public getSize() {
|
|
151
|
-
|
|
152
|
-
// 2 numbers for txIndexInBlock and noteIndexInTx (4 bytes each)
|
|
153
|
-
return noteSize + AztecAddress.SIZE_IN_BYTES * 2 + Fr.SIZE_IN_BYTES * 4 + TxHash.SIZE + Point.SIZE_IN_BYTES + 8;
|
|
150
|
+
return this.toBuffer().length;
|
|
154
151
|
}
|
|
155
152
|
|
|
156
153
|
static async random({
|