@aztec/stdlib 0.0.1-commit.cb6bed7c2 → 0.0.1-commit.cbf2c2d5d
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 +138 -1
- package/dest/abi/abi.d.ts.map +1 -1
- package/dest/abi/abi.js +10 -2
- package/dest/abi/buffer.d.ts +14 -4
- package/dest/abi/buffer.d.ts.map +1 -1
- package/dest/abi/buffer.js +25 -4
- package/dest/avm/avm.d.ts +300 -300
- package/dest/block/l2_block_source.d.ts +11 -8
- package/dest/block/l2_block_source.d.ts.map +1 -1
- package/dest/checkpoint/validate.js +2 -2
- package/dest/config/index.d.ts +2 -1
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +1 -0
- package/dest/config/pipelining-config.d.ts +19 -0
- package/dest/config/pipelining-config.d.ts.map +1 -0
- package/dest/config/pipelining-config.js +18 -0
- package/dest/contract/contract_address.d.ts +3 -3
- package/dest/contract/contract_address.js +3 -3
- package/dest/contract/contract_class_id.d.ts +2 -2
- package/dest/contract/contract_class_id.js +2 -2
- package/dest/contract/index.d.ts +1 -3
- package/dest/contract/index.d.ts.map +1 -1
- package/dest/contract/index.js +0 -2
- package/dest/contract/interfaces/contract_class.d.ts +3 -156
- package/dest/contract/interfaces/contract_class.d.ts.map +1 -1
- package/dest/contract/interfaces/contract_class.js +1 -28
- package/dest/epoch-helpers/index.d.ts +7 -1
- package/dest/epoch-helpers/index.d.ts.map +1 -1
- package/dest/epoch-helpers/index.js +10 -2
- package/dest/hash/hash.d.ts +16 -1
- package/dest/hash/hash.d.ts.map +1 -1
- package/dest/hash/hash.js +24 -0
- package/dest/interfaces/archiver.js +2 -2
- package/dest/interfaces/aztec-node-admin.d.ts +7 -1
- package/dest/interfaces/aztec-node-admin.d.ts.map +1 -1
- package/dest/interfaces/aztec-node.d.ts +3 -2
- package/dest/interfaces/aztec-node.d.ts.map +1 -1
- package/dest/interfaces/aztec-node.js +2 -0
- package/dest/interfaces/block-builder.d.ts +32 -11
- package/dest/interfaces/block-builder.d.ts.map +1 -1
- package/dest/interfaces/block-builder.js +6 -4
- package/dest/interfaces/configs.d.ts +7 -2
- package/dest/interfaces/configs.d.ts.map +1 -1
- package/dest/interfaces/configs.js +1 -0
- package/dest/interfaces/l2_logs_source.d.ts +5 -3
- package/dest/interfaces/l2_logs_source.d.ts.map +1 -1
- package/dest/interfaces/merkle_tree_operations.d.ts +9 -19
- package/dest/interfaces/merkle_tree_operations.d.ts.map +1 -1
- package/dest/interfaces/prover-client.d.ts +6 -1
- package/dest/interfaces/prover-client.d.ts.map +1 -1
- package/dest/interfaces/prover-client.js +7 -1
- package/dest/interfaces/proving-job.d.ts +200 -200
- package/dest/interfaces/world_state.d.ts +5 -4
- package/dest/interfaces/world_state.d.ts.map +1 -1
- package/dest/logs/index.d.ts +2 -1
- package/dest/logs/index.d.ts.map +1 -1
- package/dest/logs/index.js +1 -0
- package/dest/logs/log_filter.d.ts +4 -1
- package/dest/logs/log_filter.d.ts.map +1 -1
- package/dest/logs/log_filter.js +2 -1
- package/dest/logs/tagging_index_range.d.ts +40 -0
- package/dest/logs/tagging_index_range.d.ts.map +1 -0
- package/dest/logs/tagging_index_range.js +8 -0
- package/dest/logs/tx_scoped_l2_log.d.ts +3 -1
- package/dest/logs/tx_scoped_l2_log.d.ts.map +1 -1
- package/dest/logs/tx_scoped_l2_log.js +7 -0
- package/dest/messaging/l1_to_l2_message_source.d.ts +4 -2
- package/dest/messaging/l1_to_l2_message_source.d.ts.map +1 -1
- package/dest/messaging/l2_to_l1_membership.d.ts +32 -6
- package/dest/messaging/l2_to_l1_membership.d.ts.map +1 -1
- package/dest/messaging/l2_to_l1_membership.js +69 -26
- package/dest/noir/index.d.ts +3 -3
- package/dest/noir/index.d.ts.map +1 -1
- package/dest/p2p/checkpoint_proposal.d.ts +1 -1
- package/dest/p2p/checkpoint_proposal.d.ts.map +1 -1
- package/dest/p2p/checkpoint_proposal.js +13 -11
- package/dest/tests/factories.d.ts +2 -4
- package/dest/tests/factories.d.ts.map +1 -1
- package/dest/tests/factories.js +0 -27
- package/dest/tx/private_execution_result.d.ts +6 -6
- package/dest/tx/private_execution_result.d.ts.map +1 -1
- package/dest/tx/private_execution_result.js +6 -6
- package/dest/tx/profiling.d.ts +14 -2
- package/dest/tx/profiling.d.ts.map +1 -1
- package/dest/tx/profiling.js +13 -3
- package/dest/tx/simulated_tx.d.ts +109 -1
- package/dest/tx/simulated_tx.d.ts.map +1 -1
- package/dest/tx/tx_receipt.d.ts +7 -2
- package/dest/tx/tx_receipt.d.ts.map +1 -1
- package/dest/tx/tx_receipt.js +6 -3
- package/dest/tx/validator/error_texts.d.ts +5 -1
- package/dest/tx/validator/error_texts.d.ts.map +1 -1
- package/dest/tx/validator/error_texts.js +6 -0
- package/dest/update-checker/package_version.d.ts +2 -2
- package/dest/update-checker/package_version.d.ts.map +1 -1
- package/dest/update-checker/package_version.js +16 -3
- package/dest/validators/errors.d.ts +6 -1
- package/dest/validators/errors.d.ts.map +1 -1
- package/dest/validators/errors.js +7 -0
- package/dest/versioning/versioning.d.ts +4 -2
- package/dest/versioning/versioning.d.ts.map +1 -1
- package/dest/versioning/versioning.js +4 -1
- package/package.json +8 -8
- package/src/abi/abi.ts +25 -2
- package/src/abi/buffer.ts +25 -4
- package/src/block/l2_block_source.ts +10 -7
- package/src/checkpoint/validate.ts +2 -2
- package/src/config/index.ts +1 -0
- package/src/config/pipelining-config.ts +31 -0
- package/src/contract/contract_address.ts +3 -3
- package/src/contract/contract_class_id.ts +2 -2
- package/src/contract/index.ts +0 -2
- package/src/contract/interfaces/contract_class.ts +2 -82
- package/src/epoch-helpers/index.ts +14 -0
- package/src/gas/README.md +123 -0
- package/src/hash/hash.ts +29 -0
- package/src/interfaces/archiver.ts +2 -2
- package/src/interfaces/aztec-node.ts +10 -1
- package/src/interfaces/block-builder.ts +39 -13
- package/src/interfaces/configs.ts +4 -1
- package/src/interfaces/l2_logs_source.ts +4 -1
- package/src/interfaces/merkle_tree_operations.ts +8 -18
- package/src/interfaces/prover-client.ts +8 -0
- package/src/interfaces/world_state.ts +4 -3
- package/src/logs/index.ts +1 -0
- package/src/logs/log_filter.ts +5 -0
- package/src/logs/tagging_index_range.ts +24 -0
- package/src/logs/tx_scoped_l2_log.ts +16 -0
- package/src/messaging/l1_to_l2_message_source.ts +3 -1
- package/src/messaging/l2_to_l1_membership.ts +98 -33
- package/src/noir/index.ts +2 -2
- package/src/p2p/checkpoint_proposal.ts +23 -20
- package/src/tests/factories.ts +0 -33
- package/src/tx/private_execution_result.ts +5 -5
- package/src/tx/profiling.ts +11 -2
- package/src/tx/tx_receipt.ts +7 -2
- package/src/tx/validator/error_texts.ts +8 -0
- package/src/update-checker/package_version.ts +19 -6
- package/src/validators/errors.ts +9 -0
- package/src/versioning/versioning.ts +4 -1
- package/dest/contract/private_function_membership_proof.d.ts +0 -32
- package/dest/contract/private_function_membership_proof.d.ts.map +0 -1
- package/dest/contract/private_function_membership_proof.js +0 -124
- package/dest/contract/utility_function_membership_proof.d.ts +0 -27
- package/dest/contract/utility_function_membership_proof.d.ts.map +0 -1
- package/dest/contract/utility_function_membership_proof.js +0 -87
- package/src/contract/private_function_membership_proof.ts +0 -167
- package/src/contract/utility_function_membership_proof.ts +0 -118
|
@@ -35,7 +35,8 @@ export interface IBlockFactory extends ProcessedTxHandler {
|
|
|
35
35
|
setBlockCompleted(expectedBlockHeader?: BlockHeader): Promise<L2Block>;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
/** Limits passed to the public processor for tx processing within a block. */
|
|
39
|
+
export type PublicProcessorLimits = {
|
|
39
40
|
/** Maximum number of txs to process. */
|
|
40
41
|
maxTransactions?: number;
|
|
41
42
|
/** L2 and DA gas limits. */
|
|
@@ -46,14 +47,37 @@ export interface PublicProcessorLimits {
|
|
|
46
47
|
deadline?: Date;
|
|
47
48
|
/** Whether this processor is building a proposal (as opposed to re-executing one). Skipping txs due to gas or blob limits is only done during proposal building. */
|
|
48
49
|
isBuildingProposal?: boolean;
|
|
49
|
-
}
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/** Base fields shared by both proposer and validator block builder options. */
|
|
53
|
+
type BlockBuilderOptionsBase = PublicProcessorLimits & {
|
|
54
|
+
/** Minimum number of successfully processed txs required. Block is rejected if fewer succeed. */
|
|
55
|
+
minValidTxs: number;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
/** Proposer mode: redistribution params are required. */
|
|
59
|
+
type ProposerBlockBuilderOptions = BlockBuilderOptionsBase & {
|
|
60
|
+
isBuildingProposal: true;
|
|
61
|
+
/** Maximum number of blocks per checkpoint, derived from the timetable. */
|
|
62
|
+
maxBlocksPerCheckpoint: number;
|
|
63
|
+
/** Per-block gas budget multiplier. Budget = (remaining / remainingBlocks) * multiplier. */
|
|
64
|
+
perBlockAllocationMultiplier: number;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
/** Validator mode: no redistribution params needed. */
|
|
68
|
+
type ValidatorBlockBuilderOptions = BlockBuilderOptionsBase & {
|
|
69
|
+
isBuildingProposal: false;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
/** Options for building a block within a checkpoint. When proposing, redistribution params are required. */
|
|
73
|
+
export type BlockBuilderOptions = ProposerBlockBuilderOptions | ValidatorBlockBuilderOptions;
|
|
50
74
|
|
|
51
75
|
export interface PublicProcessorValidator {
|
|
52
76
|
preprocessValidator?: TxValidator<Tx>;
|
|
53
77
|
nullifierCache?: { addNullifiers: (nullifiers: Buffer[]) => void };
|
|
54
78
|
}
|
|
55
79
|
|
|
56
|
-
export type FullNodeBlockBuilderConfig = Pick<L1RollupConstants, 'l1GenesisTime' | 'slotDuration'> &
|
|
80
|
+
export type FullNodeBlockBuilderConfig = Pick<L1RollupConstants, 'l1GenesisTime' | 'slotDuration' | 'rollupManaLimit'> &
|
|
57
81
|
Pick<ChainConfig, 'l1ChainId' | 'rollupVersion'> &
|
|
58
82
|
Pick<
|
|
59
83
|
SequencerConfig,
|
|
@@ -64,10 +88,7 @@ export type FullNodeBlockBuilderConfig = Pick<L1RollupConstants, 'l1GenesisTime'
|
|
|
64
88
|
| 'maxTxsPerCheckpoint'
|
|
65
89
|
| 'maxL2BlockGas'
|
|
66
90
|
| 'maxDABlockGas'
|
|
67
|
-
|
|
68
|
-
/** Total L2 gas (mana) allowed per checkpoint. Fetched from L1 getManaLimit(). */
|
|
69
|
-
rollupManaLimit: number;
|
|
70
|
-
};
|
|
91
|
+
>;
|
|
71
92
|
|
|
72
93
|
export const FullNodeBlockBuilderConfigKeys: (keyof FullNodeBlockBuilderConfig)[] = [
|
|
73
94
|
'l1GenesisTime',
|
|
@@ -84,11 +105,15 @@ export const FullNodeBlockBuilderConfigKeys: (keyof FullNodeBlockBuilderConfig)[
|
|
|
84
105
|
'rollupManaLimit',
|
|
85
106
|
] as const;
|
|
86
107
|
|
|
87
|
-
/** Thrown when
|
|
88
|
-
export class
|
|
89
|
-
constructor(
|
|
90
|
-
|
|
91
|
-
|
|
108
|
+
/** Thrown when the number of successfully processed transactions is below the required minimum. */
|
|
109
|
+
export class InsufficientValidTxsError extends Error {
|
|
110
|
+
constructor(
|
|
111
|
+
public readonly processedCount: number,
|
|
112
|
+
public readonly minRequired: number,
|
|
113
|
+
public readonly failedTxs: FailedTx[],
|
|
114
|
+
) {
|
|
115
|
+
super(`Insufficient valid txs: got ${processedCount} but need ${minRequired}`);
|
|
116
|
+
this.name = 'InsufficientValidTxsError';
|
|
92
117
|
}
|
|
93
118
|
}
|
|
94
119
|
|
|
@@ -103,11 +128,12 @@ export type BuildBlockInCheckpointResult = {
|
|
|
103
128
|
|
|
104
129
|
/** Interface for building blocks within a checkpoint context. */
|
|
105
130
|
export interface ICheckpointBlockBuilder {
|
|
131
|
+
/** Builds a single block within this checkpoint. Throws InsufficientValidTxsError if fewer than minValidTxs succeed. */
|
|
106
132
|
buildBlock(
|
|
107
133
|
pendingTxs: Iterable<Tx> | AsyncIterable<Tx>,
|
|
108
134
|
blockNumber: BlockNumber,
|
|
109
135
|
timestamp: bigint,
|
|
110
|
-
opts:
|
|
136
|
+
opts: BlockBuilderOptions,
|
|
111
137
|
): Promise<BuildBlockInCheckpointResult>;
|
|
112
138
|
}
|
|
113
139
|
|
|
@@ -27,6 +27,8 @@ export interface SequencerConfig {
|
|
|
27
27
|
maxDABlockGas?: number;
|
|
28
28
|
/** Per-block gas budget multiplier for both L2 and DA gas. Budget = (checkpointLimit / maxBlocks) * multiplier. */
|
|
29
29
|
perBlockAllocationMultiplier?: number;
|
|
30
|
+
/** Redistribute remaining checkpoint budget evenly across remaining blocks instead of allowing a single block to consume the entire remaining budget. */
|
|
31
|
+
redistributeCheckpointBudget?: boolean;
|
|
30
32
|
/** Recipient of block reward. */
|
|
31
33
|
coinbase?: EthAddress;
|
|
32
34
|
/** Address to receive fees. */
|
|
@@ -94,6 +96,7 @@ export const SequencerConfigSchema = zodFor<SequencerConfig>()(
|
|
|
94
96
|
publishTxsWithProposals: z.boolean().optional(),
|
|
95
97
|
maxDABlockGas: z.number().optional(),
|
|
96
98
|
perBlockAllocationMultiplier: z.number().optional(),
|
|
99
|
+
redistributeCheckpointBudget: z.boolean().optional(),
|
|
97
100
|
coinbase: schemas.EthAddress.optional(),
|
|
98
101
|
feeRecipient: schemas.AztecAddress.optional(),
|
|
99
102
|
acvmWorkingDirectory: z.string().optional(),
|
|
@@ -142,7 +145,7 @@ type SequencerConfigOptionalKeys =
|
|
|
142
145
|
| 'maxTxsPerCheckpoint'
|
|
143
146
|
| 'maxL2BlockGas'
|
|
144
147
|
| 'maxDABlockGas'
|
|
145
|
-
| '
|
|
148
|
+
| 'redistributeCheckpointBudget';
|
|
146
149
|
|
|
147
150
|
export type ResolvedSequencerConfig = Prettify<
|
|
148
151
|
Required<Omit<SequencerConfig, SequencerConfigOptionalKeys>> & Pick<SequencerConfig, SequencerConfigOptionalKeys>
|
|
@@ -16,10 +16,11 @@ export interface L2LogsSource {
|
|
|
16
16
|
* array implies no logs match that tag.
|
|
17
17
|
* @param tags - The tags to search for.
|
|
18
18
|
* @param page - The page number (0-indexed) for pagination.
|
|
19
|
+
* @param upToBlockNumber - If set, only return logs from blocks up to and including this block number.
|
|
19
20
|
* @returns An array of log arrays, one per tag. Returns at most 10 logs per tag per page. If 10 logs are returned
|
|
20
21
|
* for a tag, the caller should fetch the next page to check for more logs.
|
|
21
22
|
*/
|
|
22
|
-
getPrivateLogsByTags(tags: SiloedTag[], page?: number): Promise<TxScopedL2Log[][]>;
|
|
23
|
+
getPrivateLogsByTags(tags: SiloedTag[], page?: number, upToBlockNumber?: BlockNumber): Promise<TxScopedL2Log[][]>;
|
|
23
24
|
|
|
24
25
|
/**
|
|
25
26
|
* Gets public logs that match any of the `tags` from the specified contract. For each tag, an array of matching
|
|
@@ -27,6 +28,7 @@ export interface L2LogsSource {
|
|
|
27
28
|
* @param contractAddress - The contract address to search logs for.
|
|
28
29
|
* @param tags - The tags to search for.
|
|
29
30
|
* @param page - The page number (0-indexed) for pagination.
|
|
31
|
+
* @param upToBlockNumber - If set, only return logs from blocks up to and including this block number.
|
|
30
32
|
* @returns An array of log arrays, one per tag. Returns at most 10 logs per tag per page. If 10 logs are returned
|
|
31
33
|
* for a tag, the caller should fetch the next page to check for more logs.
|
|
32
34
|
*/
|
|
@@ -34,6 +36,7 @@ export interface L2LogsSource {
|
|
|
34
36
|
contractAddress: AztecAddress,
|
|
35
37
|
tags: Tag[],
|
|
36
38
|
page?: number,
|
|
39
|
+
upToBlockNumber?: BlockNumber,
|
|
37
40
|
): Promise<TxScopedL2Log[][]>;
|
|
38
41
|
|
|
39
42
|
/**
|
|
@@ -225,30 +225,20 @@ export interface MerkleTreeReadOperations {
|
|
|
225
225
|
}
|
|
226
226
|
|
|
227
227
|
export interface MerkleTreeCheckpointOperations {
|
|
228
|
-
/**
|
|
229
|
-
|
|
230
|
-
*/
|
|
231
|
-
createCheckpoint(): Promise<void>;
|
|
228
|
+
/** Checkpoints the current fork state. Returns the depth of the new checkpoint. */
|
|
229
|
+
createCheckpoint(): Promise<number>;
|
|
232
230
|
|
|
233
|
-
/**
|
|
234
|
-
* Commits the current checkpoint
|
|
235
|
-
*/
|
|
231
|
+
/** Commits the current checkpoint. */
|
|
236
232
|
commitCheckpoint(): Promise<void>;
|
|
237
233
|
|
|
238
|
-
/**
|
|
239
|
-
* Reverts the current checkpoint
|
|
240
|
-
*/
|
|
234
|
+
/** Reverts the current checkpoint. */
|
|
241
235
|
revertCheckpoint(): Promise<void>;
|
|
242
236
|
|
|
243
|
-
/**
|
|
244
|
-
|
|
245
|
-
*/
|
|
246
|
-
commitAllCheckpoints(): Promise<void>;
|
|
237
|
+
/** Commits all checkpoints above the given depth, leaving checkpoint depth at the given value. */
|
|
238
|
+
commitAllCheckpointsTo(depth: number): Promise<void>;
|
|
247
239
|
|
|
248
|
-
/**
|
|
249
|
-
|
|
250
|
-
*/
|
|
251
|
-
revertAllCheckpoints(): Promise<void>;
|
|
240
|
+
/** Reverts all checkpoints above the given depth, leaving checkpoint depth at the given value. */
|
|
241
|
+
revertAllCheckpointsTo(depth: number): Promise<void>;
|
|
252
242
|
}
|
|
253
243
|
|
|
254
244
|
export interface MerkleTreeWriteOperations
|
|
@@ -23,6 +23,8 @@ export type ActualProverConfig = {
|
|
|
23
23
|
* When true, jobs are explicitly cancelled with the broker, which prevents reuse.
|
|
24
24
|
*/
|
|
25
25
|
cancelJobsOnStop: boolean;
|
|
26
|
+
/** Max concurrent jobs the orchestrator serializes and enqueues to the broker. */
|
|
27
|
+
enqueueConcurrency: number;
|
|
26
28
|
};
|
|
27
29
|
|
|
28
30
|
/**
|
|
@@ -53,6 +55,7 @@ export const ProverConfigSchema = zodFor<ProverConfig>()(
|
|
|
53
55
|
proofStore: z.string().optional(),
|
|
54
56
|
failedProofStore: z.string().optional(),
|
|
55
57
|
cancelJobsOnStop: z.boolean(),
|
|
58
|
+
enqueueConcurrency: z.number(),
|
|
56
59
|
}),
|
|
57
60
|
);
|
|
58
61
|
|
|
@@ -107,6 +110,11 @@ export const proverConfigMappings: ConfigMappingsType<ProverConfig> = {
|
|
|
107
110
|
'When true, jobs are explicitly cancelled with the broker, which prevents reuse.',
|
|
108
111
|
...booleanConfigHelper(false),
|
|
109
112
|
},
|
|
113
|
+
enqueueConcurrency: {
|
|
114
|
+
env: 'PROVER_ENQUEUE_CONCURRENCY',
|
|
115
|
+
description: 'Max concurrent jobs the orchestrator serializes and enqueues to the broker.',
|
|
116
|
+
...numberConfigHelper(50),
|
|
117
|
+
},
|
|
110
118
|
};
|
|
111
119
|
|
|
112
120
|
function parseProverId(str?: string) {
|
|
@@ -3,6 +3,7 @@ import type { PromiseWithResolvers } from '@aztec/foundation/promise';
|
|
|
3
3
|
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
|
|
6
|
+
import type { BlockHash } from '../block/block_hash.js';
|
|
6
7
|
import type { SnapshotDataKeys } from '../snapshots/types.js';
|
|
7
8
|
import type { MerkleTreeReadOperations, MerkleTreeWriteOperations } from './merkle_tree_operations.js';
|
|
8
9
|
|
|
@@ -80,12 +81,12 @@ export interface WorldStateSynchronizer extends ReadonlyWorldStateAccess, ForkMe
|
|
|
80
81
|
resumeSync(): void;
|
|
81
82
|
|
|
82
83
|
/**
|
|
83
|
-
* Forces an immediate sync to an optionally provided minimum block number
|
|
84
|
+
* Forces an immediate sync to an optionally provided minimum block number.
|
|
84
85
|
* @param targetBlockNumber - The target block number that we must sync to. Will download unproven blocks if needed to reach it.
|
|
85
|
-
* @param
|
|
86
|
+
* @param blockHash - If provided, verifies the block at targetBlockNumber matches this hash. On mismatch, triggers a resync (reorg detection).
|
|
86
87
|
* @returns A promise that resolves with the block number the world state was synced to
|
|
87
88
|
*/
|
|
88
|
-
syncImmediate(minBlockNumber?: BlockNumber,
|
|
89
|
+
syncImmediate(minBlockNumber?: BlockNumber, blockHash?: BlockHash): Promise<BlockNumber>;
|
|
89
90
|
|
|
90
91
|
/** Deletes the db */
|
|
91
92
|
clear(): Promise<void>;
|
package/src/logs/index.ts
CHANGED
package/src/logs/log_filter.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
+
|
|
1
3
|
import { z } from 'zod';
|
|
2
4
|
|
|
3
5
|
import type { AztecAddress } from '../aztec-address/index.js';
|
|
@@ -20,6 +22,8 @@ export type LogFilter = {
|
|
|
20
22
|
afterLog?: LogId;
|
|
21
23
|
/** The contract address to filter logs by. */
|
|
22
24
|
contractAddress?: AztecAddress;
|
|
25
|
+
/** The tag (first field of the log) to filter logs by. */
|
|
26
|
+
tag?: Fr;
|
|
23
27
|
};
|
|
24
28
|
|
|
25
29
|
export const LogFilterSchema: ZodFor<LogFilter> = z.object({
|
|
@@ -28,4 +32,5 @@ export const LogFilterSchema: ZodFor<LogFilter> = z.object({
|
|
|
28
32
|
toBlock: schemas.Integer.optional(),
|
|
29
33
|
afterLog: LogId.schema.optional(),
|
|
30
34
|
contractAddress: schemas.AztecAddress.optional(),
|
|
35
|
+
tag: schemas.Fr.optional(),
|
|
31
36
|
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { schemas } from '@aztec/foundation/schemas';
|
|
2
|
+
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
type ExtendedDirectionalAppTaggingSecret,
|
|
7
|
+
ExtendedDirectionalAppTaggingSecretSchema,
|
|
8
|
+
} from './extended_directional_app_tagging_secret.js';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Represents a range of tagging indexes for a given extended directional app tagging secret. Used to track the lowest
|
|
12
|
+
* and highest indexes used in a transaction for a given (sender, recipient, app/contract) tuple.
|
|
13
|
+
*/
|
|
14
|
+
export type TaggingIndexRange = {
|
|
15
|
+
extendedSecret: ExtendedDirectionalAppTaggingSecret;
|
|
16
|
+
lowestIndex: number;
|
|
17
|
+
highestIndex: number;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const TaggingIndexRangeSchema = z.object({
|
|
21
|
+
extendedSecret: ExtendedDirectionalAppTaggingSecretSchema,
|
|
22
|
+
lowestIndex: schemas.Integer,
|
|
23
|
+
highestIndex: schemas.Integer,
|
|
24
|
+
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { BlockNumber, BlockNumberSchema } from '@aztec/foundation/branded-types';
|
|
2
|
+
import { times } from '@aztec/foundation/collection';
|
|
2
3
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
4
|
import { schemas as foundationSchemas } from '@aztec/foundation/schemas';
|
|
4
5
|
import {
|
|
@@ -83,6 +84,21 @@ export class TxScopedL2Log {
|
|
|
83
84
|
return new TxScopedL2Log(txHash, blockNumber, blockTimestamp, logData, noteHashes, firstNullifier);
|
|
84
85
|
}
|
|
85
86
|
|
|
87
|
+
static getBlockNumberFromBuffer(buffer: Buffer) {
|
|
88
|
+
return BlockNumber(buffer.readUint32BE(Fr.SIZE_IN_BYTES));
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
static random() {
|
|
92
|
+
return new TxScopedL2Log(
|
|
93
|
+
TxHash.fromField(Fr.random()),
|
|
94
|
+
BlockNumber(Math.floor(Math.random() * 100000) + 1),
|
|
95
|
+
BigInt(Math.floor(Date.now() / 1000)),
|
|
96
|
+
times(3, Fr.random),
|
|
97
|
+
times(3, Fr.random),
|
|
98
|
+
Fr.random(),
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
|
|
86
102
|
equals(other: TxScopedL2Log) {
|
|
87
103
|
return (
|
|
88
104
|
this.txHash.equals(other.txHash) &&
|
|
@@ -10,7 +10,9 @@ export interface L1ToL2MessageSource {
|
|
|
10
10
|
/**
|
|
11
11
|
* Gets new L1 to L2 message (to be) included in a given checkpoint.
|
|
12
12
|
* @param checkpointNumber - Checkpoint number to get messages for.
|
|
13
|
-
* @returns The L1 to L2 messages/leaves of the messages subtree
|
|
13
|
+
* @returns The L1 to L2 messages/leaves of the messages subtree.
|
|
14
|
+
* @throws If the message tree for the given checkpoint has not yet been sealed on L1
|
|
15
|
+
* (i.e., checkpointNumber >= inbox treeInProgress).
|
|
14
16
|
*/
|
|
15
17
|
getL1ToL2Messages(checkpointNumber: CheckpointNumber): Promise<Fr[]>;
|
|
16
18
|
|
|
@@ -3,6 +3,9 @@ import type { EpochNumber } from '@aztec/foundation/branded-types';
|
|
|
3
3
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
4
|
import { SiblingPath, UnbalancedMerkleTreeCalculator, computeUnbalancedShaRoot } from '@aztec/foundation/trees';
|
|
5
5
|
|
|
6
|
+
import type { AztecNode } from '../interfaces/aztec-node.js';
|
|
7
|
+
import { TxHash } from '../tx/tx_hash.js';
|
|
8
|
+
|
|
6
9
|
/**
|
|
7
10
|
* # L2-to-L1 Message Tree Structure and Leaf IDs
|
|
8
11
|
*
|
|
@@ -92,59 +95,94 @@ export function getL2ToL1MessageLeafId(
|
|
|
92
95
|
return 2n ** BigInt(membershipWitness.siblingPath.pathSize) + membershipWitness.leafIndex;
|
|
93
96
|
}
|
|
94
97
|
|
|
95
|
-
export interface MessageRetrieval {
|
|
96
|
-
getL2ToL1Messages(epoch: EpochNumber): Promise<Fr[][][][]>;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
98
|
export type L2ToL1MembershipWitness = {
|
|
100
99
|
root: Fr;
|
|
101
100
|
leafIndex: bigint;
|
|
102
101
|
siblingPath: SiblingPath<number>;
|
|
102
|
+
epochNumber: EpochNumber;
|
|
103
103
|
};
|
|
104
104
|
|
|
105
|
+
/**
|
|
106
|
+
* Computes the L2 to L1 membership witness for a given message in a transaction.
|
|
107
|
+
*
|
|
108
|
+
* @param node - The Aztec node to query for block/tx/epoch data.
|
|
109
|
+
* @param message - The L2 to L1 message hash to prove membership of.
|
|
110
|
+
* @param txHash - The hash of the transaction that emitted the message.
|
|
111
|
+
* @param messageIndexInTx - Optional index of the message within the transaction's L2-to-L1 messages.
|
|
112
|
+
* If not provided, the message is found by scanning the tx's messages (throws if duplicates exist).
|
|
113
|
+
* @returns The membership witness and epoch number, or undefined if the tx is not yet in a block/epoch.
|
|
114
|
+
*/
|
|
105
115
|
export async function computeL2ToL1MembershipWitness(
|
|
106
|
-
|
|
107
|
-
|
|
116
|
+
node: Pick<
|
|
117
|
+
AztecNode,
|
|
118
|
+
'getL2ToL1Messages' | 'getTxReceipt' | 'getTxEffect' | 'getBlock' | 'getCheckpointsDataForEpoch'
|
|
119
|
+
>,
|
|
108
120
|
message: Fr,
|
|
121
|
+
txHash: TxHash,
|
|
122
|
+
messageIndexInTx?: number,
|
|
109
123
|
): Promise<L2ToL1MembershipWitness | undefined> {
|
|
110
|
-
const
|
|
111
|
-
if (
|
|
124
|
+
const { epochNumber, blockNumber } = await node.getTxReceipt(txHash);
|
|
125
|
+
if (epochNumber === undefined || blockNumber === undefined) {
|
|
126
|
+
return undefined;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
const [messagesInEpoch, block, txEffect, checkpointsData] = await Promise.all([
|
|
130
|
+
node.getL2ToL1Messages(epochNumber),
|
|
131
|
+
node.getBlock(blockNumber),
|
|
132
|
+
node.getTxEffect(txHash),
|
|
133
|
+
node.getCheckpointsDataForEpoch(epochNumber),
|
|
134
|
+
]);
|
|
135
|
+
|
|
136
|
+
if (messagesInEpoch.length === 0 || !block || !txEffect) {
|
|
137
|
+
return undefined;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const checkpointIndex = checkpointsData.findIndex(c => c.checkpointNumber === block.checkpointNumber);
|
|
141
|
+
if (checkpointIndex === -1) {
|
|
112
142
|
return undefined;
|
|
113
143
|
}
|
|
114
144
|
|
|
115
|
-
|
|
145
|
+
const blockIndex = block.indexWithinCheckpoint;
|
|
146
|
+
const txIndex = txEffect.txIndexInBlock;
|
|
147
|
+
|
|
148
|
+
const { root, leafIndex, siblingPath } = computeL2ToL1MembershipWitnessFromMessagesInEpoch(
|
|
149
|
+
messagesInEpoch,
|
|
150
|
+
message,
|
|
151
|
+
checkpointIndex,
|
|
152
|
+
blockIndex,
|
|
153
|
+
txIndex,
|
|
154
|
+
messageIndexInTx,
|
|
155
|
+
);
|
|
156
|
+
return { epochNumber, root, leafIndex, siblingPath };
|
|
116
157
|
}
|
|
117
158
|
|
|
118
|
-
|
|
119
|
-
|
|
159
|
+
/**
|
|
160
|
+
* Computes a membership witness for a message in the epoch's L2-to-L1 message tree, given explicit position indices.
|
|
161
|
+
*
|
|
162
|
+
* @param messagesInEpoch - All L2-to-L1 messages in the epoch, organized as checkpoints → blocks → txs → messages.
|
|
163
|
+
* @param message - The message hash to prove membership of.
|
|
164
|
+
* @param checkpointIndex - Index of the checkpoint within the epoch's message array.
|
|
165
|
+
* @param blockIndex - Index of the block within the checkpoint.
|
|
166
|
+
* @param txIndex - Index of the transaction within the block.
|
|
167
|
+
* @param messageIndexInTx - Optional index of the message within the transaction's messages.
|
|
168
|
+
* If not provided, the message is found by scanning (throws if duplicates exist within the tx).
|
|
169
|
+
*/
|
|
170
|
+
/** @internal Exported for testing only. */
|
|
120
171
|
export function computeL2ToL1MembershipWitnessFromMessagesInEpoch(
|
|
121
172
|
messagesInEpoch: Fr[][][][],
|
|
122
173
|
message: Fr,
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
const
|
|
129
|
-
|
|
130
|
-
txIndex = messagesInBlock.findIndex(messagesInTx => {
|
|
131
|
-
messageIndexInTx = messagesInTx.findIndex(msg => msg.equals(message));
|
|
132
|
-
return messageIndexInTx !== -1;
|
|
133
|
-
});
|
|
134
|
-
return txIndex !== -1;
|
|
135
|
-
});
|
|
136
|
-
return blockIndex !== -1;
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
if (checkpointIndex === -1) {
|
|
140
|
-
throw new Error('The L2ToL1Message you are trying to prove inclusion of does not exist');
|
|
141
|
-
}
|
|
174
|
+
checkpointIndex: number,
|
|
175
|
+
blockIndex: number,
|
|
176
|
+
txIndex: number,
|
|
177
|
+
messageIndexInTx?: number,
|
|
178
|
+
): { root: Fr; leafIndex: bigint; siblingPath: SiblingPath<number> } {
|
|
179
|
+
const messagesInTx = messagesInEpoch[checkpointIndex][blockIndex][txIndex];
|
|
180
|
+
const resolvedMessageIndex = resolveMessageIndex(messagesInTx, message, messageIndexInTx);
|
|
142
181
|
|
|
143
182
|
// Build the tx tree.
|
|
144
|
-
const messagesInTx = messagesInEpoch[checkpointIndex][blockIndex][txIndex];
|
|
145
183
|
const txTree = UnbalancedMerkleTreeCalculator.create(messagesInTx.map(msg => msg.toBuffer()));
|
|
146
184
|
// Get the sibling path of the target message in the tx tree.
|
|
147
|
-
const pathToMessageInTxSubtree = txTree.getSiblingPathByLeafIndex(
|
|
185
|
+
const pathToMessageInTxSubtree = txTree.getSiblingPathByLeafIndex(resolvedMessageIndex);
|
|
148
186
|
|
|
149
187
|
// Build the tree of the block containing the target message.
|
|
150
188
|
const blockTree = buildBlockTree(messagesInEpoch[checkpointIndex][blockIndex]);
|
|
@@ -189,7 +227,7 @@ export function computeL2ToL1MembershipWitnessFromMessagesInEpoch(
|
|
|
189
227
|
// Compute the combined index.
|
|
190
228
|
// It is the index of the message in the balanced tree (by filling up the wonky tree with empty nodes) at its current
|
|
191
229
|
// height. It's used to validate the membership proof.
|
|
192
|
-
const messageLeafPosition = txTree.getLeafLocation(
|
|
230
|
+
const messageLeafPosition = txTree.getLeafLocation(resolvedMessageIndex);
|
|
193
231
|
const txLeafPosition = blockTree.getLeafLocation(txIndex);
|
|
194
232
|
const blockLeafPosition = checkpointTree.getLeafLocation(blockIndex);
|
|
195
233
|
const checkpointLeafPosition = epochTree.getLeafLocation(checkpointIndex);
|
|
@@ -207,6 +245,33 @@ export function computeL2ToL1MembershipWitnessFromMessagesInEpoch(
|
|
|
207
245
|
};
|
|
208
246
|
}
|
|
209
247
|
|
|
248
|
+
function resolveMessageIndex(messagesInTx: Fr[], message: Fr, messageIndexInTx?: number): number {
|
|
249
|
+
if (messageIndexInTx !== undefined) {
|
|
250
|
+
if (!messagesInTx[messageIndexInTx]?.equals(message)) {
|
|
251
|
+
throw new Error(`Message at index ${messageIndexInTx} in tx does not match the expected message ${message}`);
|
|
252
|
+
}
|
|
253
|
+
return messageIndexInTx;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
const indices = messagesInTx.reduce<number[]>((acc, msg, i) => {
|
|
257
|
+
if (msg.equals(message)) {
|
|
258
|
+
acc.push(i);
|
|
259
|
+
}
|
|
260
|
+
return acc;
|
|
261
|
+
}, []);
|
|
262
|
+
|
|
263
|
+
if (indices.length === 0) {
|
|
264
|
+
throw new Error('The L2ToL1Message you are trying to prove inclusion of does not exist');
|
|
265
|
+
}
|
|
266
|
+
if (indices.length > 1) {
|
|
267
|
+
throw new Error(
|
|
268
|
+
`Multiple messages with the same value ${message} found in tx (indices: ${indices.join(', ')}). ` +
|
|
269
|
+
`Provide messageIndexInTx to disambiguate.`,
|
|
270
|
+
);
|
|
271
|
+
}
|
|
272
|
+
return indices[0];
|
|
273
|
+
}
|
|
274
|
+
|
|
210
275
|
function buildCheckpointTree(messagesInCheckpoint: Fr[][][]) {
|
|
211
276
|
const blockOutHashes = messagesInCheckpoint.map(messagesInBlock => buildBlockTree(messagesInBlock).getRoot());
|
|
212
277
|
return buildCompressedTree(blockOutHashes);
|
package/src/noir/index.ts
CHANGED
|
@@ -19,7 +19,7 @@ export const AZTEC_VIEW_ATTRIBUTE = 'abi_view';
|
|
|
19
19
|
export interface NoirFunctionAbi {
|
|
20
20
|
/** The parameters of the function. */
|
|
21
21
|
parameters: ABIParameter[];
|
|
22
|
-
/** The return type of the function. */
|
|
22
|
+
/** The return type of the function, or null for void functions. */
|
|
23
23
|
return_type: {
|
|
24
24
|
/**
|
|
25
25
|
* The type of the return value.
|
|
@@ -29,7 +29,7 @@ export interface NoirFunctionAbi {
|
|
|
29
29
|
* The visibility of the return value.
|
|
30
30
|
*/
|
|
31
31
|
visibility: ABIParameterVisibility;
|
|
32
|
-
};
|
|
32
|
+
} | null;
|
|
33
33
|
/** Mapping of error selector => error type */
|
|
34
34
|
error_types: Partial<Record<string, AbiErrorType>>;
|
|
35
35
|
}
|
|
@@ -178,29 +178,32 @@ export class CheckpointProposal extends Gossipable {
|
|
|
178
178
|
blockNumber: lastBlockInfo?.blockHeader?.globalVariables.blockNumber ?? BlockNumber(0),
|
|
179
179
|
dutyType: DutyType.CHECKPOINT_PROPOSAL,
|
|
180
180
|
};
|
|
181
|
-
const checkpointSignature = await payloadSigner(checkpointHash, checkpointContext);
|
|
182
181
|
|
|
183
|
-
if (
|
|
184
|
-
|
|
182
|
+
if (lastBlockInfo) {
|
|
183
|
+
// Sign block proposal before signing checkpoint proposal to ensure HA protection
|
|
184
|
+
const lastBlockProposal = await BlockProposal.createProposalFromSigner(
|
|
185
|
+
lastBlockInfo.blockHeader,
|
|
186
|
+
lastBlockInfo.indexWithinCheckpoint,
|
|
187
|
+
checkpointHeader.inHash,
|
|
188
|
+
archiveRoot,
|
|
189
|
+
lastBlockInfo.txHashes,
|
|
190
|
+
lastBlockInfo.txs,
|
|
191
|
+
payloadSigner,
|
|
192
|
+
);
|
|
193
|
+
|
|
194
|
+
const checkpointSignature = await payloadSigner(checkpointHash, checkpointContext);
|
|
195
|
+
|
|
196
|
+
return new CheckpointProposal(checkpointHeader, archiveRoot, feeAssetPriceModifier, checkpointSignature, {
|
|
197
|
+
blockHeader: lastBlockInfo.blockHeader,
|
|
198
|
+
indexWithinCheckpoint: lastBlockInfo.indexWithinCheckpoint,
|
|
199
|
+
txHashes: lastBlockInfo.txHashes,
|
|
200
|
+
signature: lastBlockProposal.signature,
|
|
201
|
+
signedTxs: lastBlockProposal.signedTxs,
|
|
202
|
+
});
|
|
185
203
|
}
|
|
186
204
|
|
|
187
|
-
const
|
|
188
|
-
|
|
189
|
-
lastBlockInfo.indexWithinCheckpoint,
|
|
190
|
-
checkpointHeader.inHash,
|
|
191
|
-
archiveRoot,
|
|
192
|
-
lastBlockInfo.txHashes,
|
|
193
|
-
lastBlockInfo.txs,
|
|
194
|
-
payloadSigner,
|
|
195
|
-
);
|
|
196
|
-
|
|
197
|
-
return new CheckpointProposal(checkpointHeader, archiveRoot, feeAssetPriceModifier, checkpointSignature, {
|
|
198
|
-
blockHeader: lastBlockInfo.blockHeader,
|
|
199
|
-
indexWithinCheckpoint: lastBlockInfo.indexWithinCheckpoint,
|
|
200
|
-
txHashes: lastBlockInfo.txHashes,
|
|
201
|
-
signature: lastBlockProposal.signature,
|
|
202
|
-
signedTxs: lastBlockProposal.signedTxs,
|
|
203
|
-
});
|
|
205
|
+
const checkpointSignature = await payloadSigner(checkpointHash, checkpointContext);
|
|
206
|
+
return new CheckpointProposal(checkpointHeader, archiveRoot, feeAssetPriceModifier, checkpointSignature);
|
|
204
207
|
}
|
|
205
208
|
|
|
206
209
|
/**
|
package/src/tests/factories.ts
CHANGED
|
@@ -92,10 +92,8 @@ import {
|
|
|
92
92
|
type ContractClassPublic,
|
|
93
93
|
ContractDeploymentData,
|
|
94
94
|
type ContractInstanceWithAddress,
|
|
95
|
-
type ExecutablePrivateFunctionWithMembershipProof,
|
|
96
95
|
type PrivateFunction,
|
|
97
96
|
SerializableContractInstance,
|
|
98
|
-
type UtilityFunctionWithMembershipProof,
|
|
99
97
|
computeContractClassId,
|
|
100
98
|
computePublicBytecodeCommitment,
|
|
101
99
|
} from '../contract/index.js';
|
|
@@ -1183,35 +1181,6 @@ export function makePublicTxBaseRollupPrivateInputs(seed = 0) {
|
|
|
1183
1181
|
});
|
|
1184
1182
|
}
|
|
1185
1183
|
|
|
1186
|
-
export function makeExecutablePrivateFunctionWithMembershipProof(
|
|
1187
|
-
seed = 0,
|
|
1188
|
-
): ExecutablePrivateFunctionWithMembershipProof {
|
|
1189
|
-
return {
|
|
1190
|
-
selector: makeSelector(seed),
|
|
1191
|
-
bytecode: makeBytes(100, seed + 1),
|
|
1192
|
-
artifactTreeSiblingPath: makeTuple(3, fr, seed + 2),
|
|
1193
|
-
artifactTreeLeafIndex: seed + 2,
|
|
1194
|
-
privateFunctionTreeSiblingPath: makeTuple(3, fr, seed + 3),
|
|
1195
|
-
privateFunctionTreeLeafIndex: seed + 3,
|
|
1196
|
-
artifactMetadataHash: fr(seed + 4),
|
|
1197
|
-
functionMetadataHash: fr(seed + 5),
|
|
1198
|
-
utilityFunctionsTreeRoot: fr(seed + 6),
|
|
1199
|
-
vkHash: fr(seed + 7),
|
|
1200
|
-
};
|
|
1201
|
-
}
|
|
1202
|
-
|
|
1203
|
-
export function makeUtilityFunctionWithMembershipProof(seed = 0): UtilityFunctionWithMembershipProof {
|
|
1204
|
-
return {
|
|
1205
|
-
selector: makeSelector(seed),
|
|
1206
|
-
bytecode: makeBytes(100, seed + 1),
|
|
1207
|
-
artifactTreeSiblingPath: makeTuple(3, fr, seed + 2),
|
|
1208
|
-
artifactTreeLeafIndex: seed + 2,
|
|
1209
|
-
artifactMetadataHash: fr(seed + 4),
|
|
1210
|
-
functionMetadataHash: fr(seed + 5),
|
|
1211
|
-
privateFunctionsArtifactTreeRoot: fr(seed + 6),
|
|
1212
|
-
};
|
|
1213
|
-
}
|
|
1214
|
-
|
|
1215
1184
|
export async function makeContractClassPublic(seed = 0, publicBytecode?: Buffer): Promise<ContractClassPublic> {
|
|
1216
1185
|
const artifactHash = fr(seed + 1);
|
|
1217
1186
|
const privateFunctionsRoot = fr(seed + 3);
|
|
@@ -1223,8 +1192,6 @@ export async function makeContractClassPublic(seed = 0, publicBytecode?: Buffer)
|
|
|
1223
1192
|
artifactHash,
|
|
1224
1193
|
packedBytecode,
|
|
1225
1194
|
privateFunctionsRoot,
|
|
1226
|
-
privateFunctions: [],
|
|
1227
|
-
utilityFunctions: [],
|
|
1228
1195
|
version: 1,
|
|
1229
1196
|
};
|
|
1230
1197
|
}
|