@aztec/stdlib 5.0.0-rc.1 → 5.0.0-rc.2
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/buffer.d.ts +6 -2
- package/dest/abi/buffer.d.ts.map +1 -1
- package/dest/abi/buffer.js +13 -1
- package/dest/avm/avm.js +1 -1
- package/dest/aztec-address/index.d.ts +35 -5
- package/dest/aztec-address/index.d.ts.map +1 -1
- package/dest/aztec-address/index.js +32 -8
- package/dest/block/l2_block_source.d.ts +11 -25
- package/dest/block/l2_block_source.d.ts.map +1 -1
- package/dest/block/l2_block_source.js +0 -1
- package/dest/block/l2_block_stream/interfaces.d.ts +25 -5
- package/dest/block/l2_block_stream/interfaces.d.ts.map +1 -1
- package/dest/block/l2_block_stream/l2_block_stream.d.ts +29 -7
- package/dest/block/l2_block_stream/l2_block_stream.d.ts.map +1 -1
- package/dest/block/l2_block_stream/l2_block_stream.js +165 -152
- package/dest/block/l2_block_stream/l2_tips_store_base.d.ts +10 -2
- 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 +33 -15
- 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 +94 -3
- 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/simulation_overrides.d.ts +61 -0
- package/dest/checkpoint/simulation_overrides.d.ts.map +1 -0
- package/dest/checkpoint/simulation_overrides.js +98 -0
- package/dest/contract/interfaces/contract_data_source.d.ts +3 -5
- package/dest/contract/interfaces/contract_data_source.d.ts.map +1 -1
- package/dest/file-store/factory.d.ts +1 -1
- package/dest/file-store/factory.d.ts.map +1 -1
- package/dest/file-store/factory.js +7 -0
- package/dest/file-store/index.d.ts +2 -1
- package/dest/file-store/index.d.ts.map +1 -1
- package/dest/file-store/index.js +1 -0
- package/dest/file-store/memory.d.ts +24 -0
- package/dest/file-store/memory.d.ts.map +1 -0
- package/dest/file-store/memory.js +80 -0
- package/dest/interfaces/archiver.js +1 -1
- package/dest/interfaces/aztec-node-debug.d.ts +26 -1
- package/dest/interfaces/aztec-node-debug.d.ts.map +1 -1
- package/dest/interfaces/aztec-node-debug.js +20 -0
- package/dest/interfaces/aztec-node.d.ts +20 -20
- package/dest/interfaces/aztec-node.d.ts.map +1 -1
- package/dest/interfaces/aztec-node.js +8 -15
- package/dest/interfaces/chain_tips.d.ts +8 -47
- package/dest/interfaces/chain_tips.d.ts.map +1 -1
- package/dest/interfaces/chain_tips.js +1 -6
- package/dest/interfaces/checkpoint_parameter.d.ts +3 -3
- package/dest/interfaces/checkpoint_parameter.d.ts.map +1 -1
- package/dest/interfaces/checkpoint_parameter.js +3 -3
- package/dest/interfaces/prover-node.d.ts +6 -7
- package/dest/interfaces/prover-node.d.ts.map +1 -1
- package/dest/interfaces/prover-node.js +15 -10
- package/dest/kernel/hints/read_request.js +1 -1
- package/dest/kernel/log_hash.d.ts +1 -1
- package/dest/kernel/log_hash.d.ts.map +1 -1
- package/dest/kernel/log_hash.js +2 -2
- package/dest/kernel/note_hash.js +1 -1
- package/dest/kernel/nullifier.js +1 -1
- package/dest/kernel/private_log_data.d.ts +1 -1
- package/dest/kernel/private_log_data.d.ts.map +1 -1
- package/dest/kernel/private_log_data.js +1 -1
- package/dest/logs/app_tagging_secret.d.ts +21 -6
- package/dest/logs/app_tagging_secret.d.ts.map +1 -1
- package/dest/logs/app_tagging_secret.js +32 -22
- package/dest/logs/contract_class_log.d.ts +1 -2
- package/dest/logs/contract_class_log.d.ts.map +1 -1
- package/dest/logs/contract_class_log.js +0 -4
- package/dest/logs/message_context.d.ts +5 -15
- package/dest/logs/message_context.d.ts.map +1 -1
- package/dest/logs/message_context.js +1 -66
- package/dest/logs/pending_tagged_log.d.ts +6 -8
- package/dest/logs/pending_tagged_log.d.ts.map +1 -1
- package/dest/logs/pending_tagged_log.js +1 -31
- package/dest/p2p/checkpoint_attestation.d.ts +2 -1
- package/dest/p2p/checkpoint_attestation.d.ts.map +1 -1
- package/dest/p2p/checkpoint_proposal.d.ts +2 -1
- package/dest/p2p/checkpoint_proposal.d.ts.map +1 -1
- package/dest/p2p/consensus_payload.d.ts +2 -1
- package/dest/p2p/consensus_payload.d.ts.map +1 -1
- package/dest/rollup/checkpoint_header.d.ts +8 -3
- package/dest/rollup/checkpoint_header.d.ts.map +1 -1
- package/dest/rollup/checkpoint_header.js +20 -10
- package/dest/tests/factories.d.ts +1 -1
- package/dest/tests/factories.d.ts.map +1 -1
- package/dest/tests/factories.js +3 -12
- package/dest/trees/nullifier_membership_witness.d.ts +5 -8
- package/dest/trees/nullifier_membership_witness.d.ts.map +1 -1
- package/dest/trees/nullifier_membership_witness.js +0 -9
- package/dest/trees/public_data_witness.d.ts +7 -17
- package/dest/trees/public_data_witness.d.ts.map +1 -1
- package/dest/trees/public_data_witness.js +0 -27
- package/dest/tx/execution_payload.d.ts +1 -1
- package/dest/tx/execution_payload.d.ts.map +1 -1
- package/dest/tx/execution_payload.js +1 -1
- package/dest/tx/global_variable_builder.d.ts +2 -12
- package/dest/tx/global_variable_builder.d.ts.map +1 -1
- package/dest/tx/global_variables.js +2 -2
- package/package.json +8 -8
- package/src/abi/buffer.ts +13 -1
- package/src/avm/avm.ts +1 -1
- package/src/aztec-address/index.ts +36 -6
- package/src/block/l2_block_source.ts +10 -15
- package/src/block/l2_block_stream/interfaces.ts +25 -5
- package/src/block/l2_block_stream/l2_block_stream.ts +222 -172
- package/src/block/l2_block_stream/l2_tips_store_base.ts +36 -15
- package/src/block/test/l2_tips_store_test_suite.ts +73 -4
- package/src/checkpoint/index.ts +1 -0
- package/src/checkpoint/simulation_overrides.ts +171 -0
- package/src/contract/interfaces/contract_data_source.ts +2 -4
- package/src/file-store/factory.ts +7 -0
- package/src/file-store/index.ts +1 -0
- package/src/file-store/memory.ts +94 -0
- package/src/interfaces/archiver.ts +1 -1
- package/src/interfaces/aztec-node-debug.ts +37 -0
- package/src/interfaces/aztec-node.ts +30 -33
- package/src/interfaces/chain_tips.ts +8 -16
- package/src/interfaces/checkpoint_parameter.ts +3 -3
- package/src/interfaces/prover-node.ts +19 -11
- package/src/kernel/hints/read_request.ts +1 -1
- package/src/kernel/log_hash.ts +5 -2
- package/src/kernel/note_hash.ts +1 -1
- package/src/kernel/nullifier.ts +1 -1
- package/src/kernel/private_log_data.ts +4 -1
- package/src/logs/app_tagging_secret.ts +39 -23
- package/src/logs/contract_class_log.ts +0 -9
- package/src/logs/message_context.ts +7 -65
- package/src/logs/pending_tagged_log.ts +6 -33
- package/src/rollup/checkpoint_header.ts +16 -2
- package/src/tests/factories.ts +3 -6
- package/src/trees/nullifier_membership_witness.ts +0 -11
- package/src/trees/public_data_witness.ts +0 -31
- package/src/tx/execution_payload.ts +2 -1
- package/src/tx/global_variable_builder.ts +1 -17
- package/src/tx/global_variables.ts +2 -2
|
@@ -2,18 +2,18 @@ import { CheckpointNumberSchema, SlotNumberSchema } from '@aztec/foundation/bran
|
|
|
2
2
|
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { CheckpointTagSchema } from './chain_tips.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Selector for a checkpoint in RPC calls.
|
|
9
9
|
*
|
|
10
10
|
* Accepts a numeric checkpoint number (or `{ number }`), a slot number (`{ slot }`),
|
|
11
|
-
* or a
|
|
11
|
+
* or a checkpoint-tip name (e.g. `'checkpointed'`, `'proven'`, `'finalized'`).
|
|
12
12
|
*/
|
|
13
13
|
export const CheckpointParameterSchema = z.union([
|
|
14
14
|
z.object({ number: CheckpointNumberSchema }).strict(),
|
|
15
15
|
z.object({ slot: SlotNumberSchema }).strict(),
|
|
16
|
-
|
|
16
|
+
CheckpointTagSchema,
|
|
17
17
|
CheckpointNumberSchema,
|
|
18
18
|
]);
|
|
19
19
|
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
+
import { createSafeJsonRpcClient, defaultFetch } from '@aztec/foundation/json-rpc/client';
|
|
2
|
+
|
|
1
3
|
import { z } from 'zod';
|
|
2
4
|
|
|
3
|
-
import { type L2Tips, L2TipsSchema } from '../block/l2_block_source.js';
|
|
4
5
|
import { type ApiSchemaFor, schemas } from '../schemas/index.js';
|
|
5
|
-
import { type
|
|
6
|
+
import { type ComponentsVersions, getVersioningResponseHandler } from '../versioning/index.js';
|
|
6
7
|
|
|
7
8
|
const EpochProvingJobState = [
|
|
8
9
|
'initialized',
|
|
9
10
|
'awaiting-checkpoints',
|
|
11
|
+
'awaiting-root',
|
|
10
12
|
'awaiting-predecessor',
|
|
11
13
|
'publishing-proof',
|
|
12
14
|
'completed',
|
|
@@ -30,7 +32,7 @@ export const EpochProvingJobTerminalState: EpochProvingJobState[] = [
|
|
|
30
32
|
|
|
31
33
|
export type EpochProvingJobTerminalState = (typeof EpochProvingJobTerminalState)[number];
|
|
32
34
|
|
|
33
|
-
/** JSON RPC
|
|
35
|
+
/** JSON RPC admin interface to a prover node. */
|
|
34
36
|
export interface ProverNodeApi {
|
|
35
37
|
getJobs(): Promise<{ uuid: string; status: EpochProvingJobState; epochNumber: number }[]>;
|
|
36
38
|
|
|
@@ -40,10 +42,6 @@ export interface ProverNodeApi {
|
|
|
40
42
|
* track the returned job's progress.
|
|
41
43
|
*/
|
|
42
44
|
startProof(epochNumber: number): Promise<string>;
|
|
43
|
-
|
|
44
|
-
getL2Tips(): Promise<L2Tips>;
|
|
45
|
-
|
|
46
|
-
getWorldStateSyncStatus(): Promise<WorldStateSyncStatus>;
|
|
47
45
|
}
|
|
48
46
|
|
|
49
47
|
/** Schemas for prover node API functions. */
|
|
@@ -54,8 +52,18 @@ export const ProverNodeApiSchema: ApiSchemaFor<ProverNodeApi> = {
|
|
|
54
52
|
}),
|
|
55
53
|
|
|
56
54
|
startProof: z.function({ input: z.tuple([schemas.Integer]), output: z.string() }),
|
|
57
|
-
|
|
58
|
-
getL2Tips: z.function({ input: z.tuple([]), output: L2TipsSchema }),
|
|
59
|
-
|
|
60
|
-
getWorldStateSyncStatus: z.function({ input: z.tuple([]), output: WorldStateSyncStatusSchema }),
|
|
61
55
|
};
|
|
56
|
+
|
|
57
|
+
export function createProverNodeAdminClient(
|
|
58
|
+
url: string,
|
|
59
|
+
versions: Partial<ComponentsVersions> = {},
|
|
60
|
+
fetch = defaultFetch,
|
|
61
|
+
apiKey?: string,
|
|
62
|
+
): ProverNodeApi {
|
|
63
|
+
return createSafeJsonRpcClient<ProverNodeApi>(url, ProverNodeApiSchema, {
|
|
64
|
+
namespaceMethods: 'prover',
|
|
65
|
+
fetch,
|
|
66
|
+
onResponse: getVersioningResponseHandler(versions),
|
|
67
|
+
...(apiKey ? { extraHeaders: { 'x-api-key': apiKey } } : {}),
|
|
68
|
+
});
|
|
69
|
+
}
|
|
@@ -112,7 +112,7 @@ export class ScopedReadRequest {
|
|
|
112
112
|
|
|
113
113
|
static fromFields(fields: Fr[] | FieldReader) {
|
|
114
114
|
const reader = FieldReader.asReader(fields);
|
|
115
|
-
return new ScopedReadRequest(reader.readObject(ReadRequest), AztecAddress.
|
|
115
|
+
return new ScopedReadRequest(reader.readObject(ReadRequest), AztecAddress.fromFieldUnsafe(reader.readField()));
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
/**
|
package/src/kernel/log_hash.ts
CHANGED
|
@@ -114,7 +114,7 @@ export class ScopedLogHash {
|
|
|
114
114
|
|
|
115
115
|
static fromFields(fields: Fr[] | FieldReader) {
|
|
116
116
|
const reader = FieldReader.asReader(fields);
|
|
117
|
-
return new ScopedLogHash(reader.readObject(LogHash), AztecAddress.
|
|
117
|
+
return new ScopedLogHash(reader.readObject(LogHash), AztecAddress.fromFieldUnsafe(reader.readField()));
|
|
118
118
|
}
|
|
119
119
|
|
|
120
120
|
isEmpty() {
|
|
@@ -156,7 +156,10 @@ export class ScopedCountedLogHash {
|
|
|
156
156
|
|
|
157
157
|
static fromFields(fields: Fr[] | FieldReader) {
|
|
158
158
|
const reader = FieldReader.asReader(fields);
|
|
159
|
-
return new ScopedCountedLogHash(
|
|
159
|
+
return new ScopedCountedLogHash(
|
|
160
|
+
reader.readObject(CountedLogHash),
|
|
161
|
+
AztecAddress.fromFieldUnsafe(reader.readField()),
|
|
162
|
+
);
|
|
160
163
|
}
|
|
161
164
|
|
|
162
165
|
toBuffer(): Buffer;
|
package/src/kernel/note_hash.ts
CHANGED
|
@@ -65,7 +65,7 @@ export class ScopedNoteHash implements Ordered {
|
|
|
65
65
|
|
|
66
66
|
static fromFields(fields: Fr[] | FieldReader) {
|
|
67
67
|
const reader = FieldReader.asReader(fields);
|
|
68
|
-
return new ScopedNoteHash(reader.readObject(NoteHash), AztecAddress.
|
|
68
|
+
return new ScopedNoteHash(reader.readObject(NoteHash), AztecAddress.fromFieldUnsafe(reader.readField()));
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
isEmpty() {
|
package/src/kernel/nullifier.ts
CHANGED
|
@@ -70,7 +70,7 @@ export class ScopedNullifier implements Ordered {
|
|
|
70
70
|
|
|
71
71
|
static fromFields(fields: Fr[] | FieldReader) {
|
|
72
72
|
const reader = FieldReader.asReader(fields);
|
|
73
|
-
return new ScopedNullifier(reader.readObject(Nullifier), AztecAddress.
|
|
73
|
+
return new ScopedNullifier(reader.readObject(Nullifier), AztecAddress.fromFieldUnsafe(reader.readField()));
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
isEmpty() {
|
|
@@ -85,7 +85,10 @@ export class ScopedPrivateLogData {
|
|
|
85
85
|
|
|
86
86
|
static fromFields(fields: Fr[] | FieldReader) {
|
|
87
87
|
const reader = FieldReader.asReader(fields);
|
|
88
|
-
return new ScopedPrivateLogData(
|
|
88
|
+
return new ScopedPrivateLogData(
|
|
89
|
+
reader.readObject(PrivateLogData),
|
|
90
|
+
AztecAddress.fromFieldUnsafe(reader.readField()),
|
|
91
|
+
);
|
|
89
92
|
}
|
|
90
93
|
|
|
91
94
|
isEmpty() {
|
|
@@ -30,16 +30,33 @@ export class AppTaggingSecret {
|
|
|
30
30
|
) {}
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
|
-
* Derives
|
|
34
|
-
* secret. Returns undefined if `externalAddress` is an invalid address.
|
|
33
|
+
* Derives an app-siloed, recipient-directional tagging secret from a shared tagging secret point.
|
|
35
34
|
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
35
|
+
* The point is obtained either via {@link computeSharedTaggingSecret} (an ECDH key exchange against a sender) or
|
|
36
|
+
* registered directly as a pre-shared secret. Each secret point yields a distinct tagging secret per (app, recipient)
|
|
37
|
+
* pair.
|
|
38
|
+
*
|
|
39
|
+
* @param taggingSecretPoint - The shared tagging secret point (ECDH output, or a directly registered pre-shared secret)
|
|
39
40
|
* @param app - Contract address to silo the secret to
|
|
40
41
|
* @param recipient - Recipient of the log. Defines the "direction of the secret".
|
|
41
42
|
* @returns The secret that can be used along with an index to compute a tag to be included in a log.
|
|
42
43
|
*/
|
|
44
|
+
static async compute(
|
|
45
|
+
taggingSecretPoint: Point,
|
|
46
|
+
app: AztecAddress,
|
|
47
|
+
recipient: AztecAddress,
|
|
48
|
+
): Promise<AppTaggingSecret> {
|
|
49
|
+
const appTaggingSecret = await poseidon2Hash([taggingSecretPoint.x, taggingSecretPoint.y, app]);
|
|
50
|
+
const directionalAppTaggingSecret = await poseidon2Hash([appTaggingSecret, recipient]);
|
|
51
|
+
|
|
52
|
+
return new AppTaggingSecret(directionalAppTaggingSecret, app);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Derives the unconstrained tagging secret for `(externalAddress, recipient, app)` by performing the ECDH key
|
|
57
|
+
* exchange against `externalAddress` and then siloing and directing the result. Returns undefined if
|
|
58
|
+
* `externalAddress` is not a valid address.
|
|
59
|
+
*/
|
|
43
60
|
static async computeUnconstrained(
|
|
44
61
|
localAddress: CompleteAddress,
|
|
45
62
|
localIvsk: Fq,
|
|
@@ -52,10 +69,7 @@ export class AppTaggingSecret {
|
|
|
52
69
|
return undefined;
|
|
53
70
|
}
|
|
54
71
|
|
|
55
|
-
|
|
56
|
-
const directionalAppTaggingSecret = await poseidon2Hash([appTaggingSecret, recipient]);
|
|
57
|
-
|
|
58
|
-
return new AppTaggingSecret(directionalAppTaggingSecret, app);
|
|
72
|
+
return AppTaggingSecret.compute(taggingSecretPoint, app, recipient);
|
|
59
73
|
}
|
|
60
74
|
|
|
61
75
|
toString(): string {
|
|
@@ -71,13 +85,13 @@ export class AppTaggingSecret {
|
|
|
71
85
|
if (parts.length === 2) {
|
|
72
86
|
// TODO(F-680): Remove legacy two-part parsing after stored tagging keys are migrated.
|
|
73
87
|
const [secretStr, appStr] = parts;
|
|
74
|
-
return new AppTaggingSecret(Fr.fromString(secretStr), AztecAddress.
|
|
88
|
+
return new AppTaggingSecret(Fr.fromString(secretStr), AztecAddress.fromStringUnsafe(appStr));
|
|
75
89
|
}
|
|
76
90
|
if (parts.length === 3) {
|
|
77
91
|
const [kindStr, secretStr, appStr] = parts;
|
|
78
92
|
return new AppTaggingSecret(
|
|
79
93
|
Fr.fromString(secretStr),
|
|
80
|
-
AztecAddress.
|
|
94
|
+
AztecAddress.fromStringUnsafe(appStr),
|
|
81
95
|
appTaggingSecretKindFromString(kindStr),
|
|
82
96
|
);
|
|
83
97
|
}
|
|
@@ -111,18 +125,17 @@ function appTaggingSecretKindFromString(kind: string): AppTaggingSecretKind {
|
|
|
111
125
|
}
|
|
112
126
|
}
|
|
113
127
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
128
|
+
/**
|
|
129
|
+
* Computes the shared tagging secret point between a local address (i.e. one for which the privacy keys are known) and
|
|
130
|
+
* an external one via a Diffie-Hellman key exchange.
|
|
131
|
+
*
|
|
132
|
+
* Returns undefined if `externalAddress` is an invalid address.
|
|
133
|
+
*/
|
|
134
|
+
export async function computeSharedTaggingSecret(
|
|
117
135
|
localAddress: CompleteAddress,
|
|
118
136
|
localIvsk: Fq,
|
|
119
137
|
externalAddress: AztecAddress,
|
|
120
138
|
): Promise<Point | undefined> {
|
|
121
|
-
// Given A (local complete address) -> B (external address) and h == preaddress
|
|
122
|
-
// Compute shared secret as S = (h_A + local_ivsk_A) * Addr_Point_B
|
|
123
|
-
|
|
124
|
-
const knownPreaddress = await computePreaddress(await localAddress.publicKeys.hash(), localAddress.partialAddress);
|
|
125
|
-
|
|
126
139
|
// An invalid address has no corresponding address point
|
|
127
140
|
if (!(await externalAddress.isValid())) {
|
|
128
141
|
return undefined;
|
|
@@ -130,8 +143,11 @@ async function computeSharedTaggingSecret(
|
|
|
130
143
|
|
|
131
144
|
const externalAddressPoint = await externalAddress.toAddressPoint();
|
|
132
145
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
146
|
+
const localPreaddress = await computePreaddress(await localAddress.publicKeys.hash(), localAddress.partialAddress);
|
|
147
|
+
const localAddressSecret = await computeAddressSecret(localPreaddress, localIvsk);
|
|
148
|
+
|
|
149
|
+
// For a given local address A and external address B, the shared tagging secret S is (h_A + ivsk_A) * Addr_Point_B
|
|
150
|
+
// (conceptually, in reality we don't use h_A + ivsk_A directly but rather the actual address secret, which is the
|
|
151
|
+
// same but with an optional sign adjustment to prevent A's address point from having a negative y-coordinate).
|
|
152
|
+
return Grumpkin.mul(externalAddressPoint, localAddressSecret);
|
|
137
153
|
}
|
|
@@ -138,15 +138,6 @@ export class ContractClassLog {
|
|
|
138
138
|
);
|
|
139
139
|
}
|
|
140
140
|
|
|
141
|
-
static fromFields(fields: Fr[] | FieldReader) {
|
|
142
|
-
const reader = FieldReader.asReader(fields);
|
|
143
|
-
return new ContractClassLog(
|
|
144
|
-
reader.readObject(AztecAddress),
|
|
145
|
-
reader.readObject(ContractClassLogFields),
|
|
146
|
-
reader.readU32(),
|
|
147
|
-
);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
141
|
getEmittedFields() {
|
|
151
142
|
return this.fields.getEmittedFields(this.emittedLength);
|
|
152
143
|
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { range } from '@aztec/foundation/array';
|
|
3
|
-
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
1
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
2
|
|
|
5
|
-
import { TxHash } from '../tx/tx_hash.js';
|
|
3
|
+
import type { TxHash } from '../tx/tx_hash.js';
|
|
6
4
|
|
|
7
5
|
/**
|
|
8
6
|
* Additional information needed to process a message.
|
|
@@ -13,64 +11,8 @@ import { TxHash } from '../tx/tx_hash.js';
|
|
|
13
11
|
*
|
|
14
12
|
* A TS version of `message_context.nr`.
|
|
15
13
|
*/
|
|
16
|
-
export
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
) {}
|
|
22
|
-
|
|
23
|
-
toFields(): Fr[] {
|
|
24
|
-
return [
|
|
25
|
-
this.txHash.hash,
|
|
26
|
-
...serializeBoundedVec(this.uniqueNoteHashesInTx, MAX_NOTE_HASHES_PER_TX),
|
|
27
|
-
this.firstNullifierInTx,
|
|
28
|
-
];
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
toNoirStruct() {
|
|
32
|
-
/* eslint-disable camelcase */
|
|
33
|
-
return {
|
|
34
|
-
tx_hash: this.txHash.hash,
|
|
35
|
-
unique_note_hashes_in_tx: this.uniqueNoteHashesInTx,
|
|
36
|
-
first_nullifier_in_tx: this.firstNullifierInTx,
|
|
37
|
-
};
|
|
38
|
-
/* eslint-enable camelcase */
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
static empty(): MessageContext {
|
|
42
|
-
return new MessageContext(TxHash.zero(), [], Fr.ZERO);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
static toEmptyFields(): Fr[] {
|
|
46
|
-
const serializationLen =
|
|
47
|
-
1 /* txHash */ + MAX_NOTE_HASHES_PER_TX + 1 /* uniqueNoteHashesInTx BVec */ + 1; /* firstNullifierInTx */
|
|
48
|
-
return range(serializationLen).map(_ => Fr.zero());
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
static toSerializedOption(response: MessageContext | null): Fr[] {
|
|
52
|
-
if (response) {
|
|
53
|
-
return [new Fr(1), ...response.toFields()];
|
|
54
|
-
} else {
|
|
55
|
-
return [new Fr(0), ...MessageContext.toEmptyFields()];
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Helper function to serialize a bounded vector according to Noir's BoundedVec format
|
|
62
|
-
* @param values - The values to serialize
|
|
63
|
-
* @param maxLength - The maximum length of the bounded vector
|
|
64
|
-
* @returns The serialized bounded vector as Fr[]
|
|
65
|
-
* @dev Copied over from pending_tagged_log.ts.
|
|
66
|
-
*/
|
|
67
|
-
function serializeBoundedVec(values: Fr[], maxLength: number): Fr[] {
|
|
68
|
-
if (values.length > maxLength) {
|
|
69
|
-
throw new Error(`Attempted to serialize ${values} values into a BoundedVec with max length ${maxLength}`);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
const lengthDiff = maxLength - values.length;
|
|
73
|
-
const zeroPaddingArray = Array(lengthDiff).fill(Fr.ZERO);
|
|
74
|
-
const storage = values.concat(zeroPaddingArray);
|
|
75
|
-
return [...storage, new Fr(values.length)];
|
|
76
|
-
}
|
|
14
|
+
export type MessageContext = {
|
|
15
|
+
txHash: TxHash;
|
|
16
|
+
uniqueNoteHashesInTx: Fr[];
|
|
17
|
+
firstNullifierInTx: Fr;
|
|
18
|
+
};
|
|
@@ -1,39 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
1
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
2
|
|
|
4
|
-
import type {
|
|
5
|
-
import { MessageContext } from './message_context.js';
|
|
3
|
+
import type { MessageContext } from './message_context.js';
|
|
6
4
|
|
|
7
5
|
/**
|
|
8
6
|
* Represents a pending tagged log as it is stored in the pending tagged log array to which the fetchTaggedLogs oracle
|
|
9
7
|
* inserts found private logs. A TS version of `pending_tagged_log.nr`.
|
|
10
8
|
*/
|
|
11
|
-
export
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
public log: Fr[],
|
|
16
|
-
txHash: TxHash,
|
|
17
|
-
uniqueNoteHashesInTx: Fr[],
|
|
18
|
-
firstNullifierInTx: Fr,
|
|
19
|
-
) {
|
|
20
|
-
this.context = new MessageContext(txHash, uniqueNoteHashesInTx, firstNullifierInTx);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
toFields(): Fr[] {
|
|
24
|
-
return [...serializeBoundedVec(this.log, PRIVATE_LOG_SIZE_IN_FIELDS), ...this.context.toFields()];
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Helper function to serialize a bounded vector according to Noir's BoundedVec format
|
|
30
|
-
* @param values - The values to serialize
|
|
31
|
-
* @param maxLength - The maximum length of the bounded vector
|
|
32
|
-
* @returns The serialized bounded vector as Fr[]
|
|
33
|
-
*/
|
|
34
|
-
function serializeBoundedVec(values: Fr[], maxLength: number): Fr[] {
|
|
35
|
-
const lengthDiff = maxLength - values.length;
|
|
36
|
-
const zeroPaddingArray = Array(lengthDiff).fill(Fr.ZERO);
|
|
37
|
-
const storage = values.concat(zeroPaddingArray);
|
|
38
|
-
return [...storage, new Fr(values.length)];
|
|
39
|
-
}
|
|
9
|
+
export type PendingTaggedLog = {
|
|
10
|
+
log: Fr[];
|
|
11
|
+
context: MessageContext;
|
|
12
|
+
};
|
|
@@ -52,6 +52,8 @@ export class CheckpointHeader {
|
|
|
52
52
|
public gasFees: GasFees,
|
|
53
53
|
/** Total mana used in the block, computed by the root rollup circuit */
|
|
54
54
|
public totalManaUsed: Fr,
|
|
55
|
+
/** Total fees accrued across the checkpoint. */
|
|
56
|
+
public accumulatedFees: Fr,
|
|
55
57
|
) {}
|
|
56
58
|
|
|
57
59
|
static get schema(): ZodFor<CheckpointHeader> {
|
|
@@ -68,6 +70,7 @@ export class CheckpointHeader {
|
|
|
68
70
|
feeRecipient: schemas.AztecAddress,
|
|
69
71
|
gasFees: GasFees.schema,
|
|
70
72
|
totalManaUsed: schemas.Fr,
|
|
73
|
+
accumulatedFees: schemas.Fr,
|
|
71
74
|
})
|
|
72
75
|
.transform(CheckpointHeader.from);
|
|
73
76
|
}
|
|
@@ -85,6 +88,7 @@ export class CheckpointHeader {
|
|
|
85
88
|
fields.feeRecipient,
|
|
86
89
|
fields.gasFees,
|
|
87
90
|
fields.totalManaUsed,
|
|
91
|
+
fields.accumulatedFees,
|
|
88
92
|
] as const;
|
|
89
93
|
}
|
|
90
94
|
|
|
@@ -107,6 +111,7 @@ export class CheckpointHeader {
|
|
|
107
111
|
reader.readObject(AztecAddress),
|
|
108
112
|
reader.readObject(GasFees),
|
|
109
113
|
reader.readObject(Fr),
|
|
114
|
+
reader.readObject(Fr),
|
|
110
115
|
);
|
|
111
116
|
}
|
|
112
117
|
|
|
@@ -122,7 +127,8 @@ export class CheckpointHeader {
|
|
|
122
127
|
this.coinbase.equals(other.coinbase) &&
|
|
123
128
|
this.feeRecipient.equals(other.feeRecipient) &&
|
|
124
129
|
this.gasFees.equals(other.gasFees) &&
|
|
125
|
-
this.totalManaUsed.equals(other.totalManaUsed)
|
|
130
|
+
this.totalManaUsed.equals(other.totalManaUsed) &&
|
|
131
|
+
this.accumulatedFees.equals(other.accumulatedFees)
|
|
126
132
|
);
|
|
127
133
|
}
|
|
128
134
|
|
|
@@ -151,6 +157,7 @@ export class CheckpointHeader {
|
|
|
151
157
|
this.feeRecipient,
|
|
152
158
|
this.gasFees,
|
|
153
159
|
this.totalManaUsed,
|
|
160
|
+
this.accumulatedFees,
|
|
154
161
|
]);
|
|
155
162
|
}
|
|
156
163
|
|
|
@@ -171,6 +178,7 @@ export class CheckpointHeader {
|
|
|
171
178
|
feeRecipient: AztecAddress.ZERO,
|
|
172
179
|
gasFees: GasFees.empty(),
|
|
173
180
|
totalManaUsed: Fr.ZERO,
|
|
181
|
+
accumulatedFees: Fr.ZERO,
|
|
174
182
|
...fields,
|
|
175
183
|
});
|
|
176
184
|
}
|
|
@@ -188,6 +196,7 @@ export class CheckpointHeader {
|
|
|
188
196
|
feeRecipient: new AztecAddress(Fr.random()),
|
|
189
197
|
gasFees: GasFees.random(),
|
|
190
198
|
totalManaUsed: new Fr(BigInt(Math.floor(Math.random() * 1000000))),
|
|
199
|
+
accumulatedFees: new Fr(BigInt(Math.floor(Math.random() * 1000000))),
|
|
191
200
|
...overrides,
|
|
192
201
|
});
|
|
193
202
|
}
|
|
@@ -204,7 +213,8 @@ export class CheckpointHeader {
|
|
|
204
213
|
this.coinbase.isZero() &&
|
|
205
214
|
this.feeRecipient.isZero() &&
|
|
206
215
|
this.gasFees.isEmpty() &&
|
|
207
|
-
this.totalManaUsed.isZero()
|
|
216
|
+
this.totalManaUsed.isZero() &&
|
|
217
|
+
this.accumulatedFees.isZero()
|
|
208
218
|
);
|
|
209
219
|
}
|
|
210
220
|
|
|
@@ -233,6 +243,7 @@ export class CheckpointHeader {
|
|
|
233
243
|
new AztecAddress(hexToBuffer(header.feeRecipient)),
|
|
234
244
|
new GasFees(header.gasFees.feePerDaGas, header.gasFees.feePerL2Gas),
|
|
235
245
|
new Fr(header.totalManaUsed),
|
|
246
|
+
new Fr(header.accumulatedFees),
|
|
236
247
|
);
|
|
237
248
|
}
|
|
238
249
|
|
|
@@ -260,6 +271,7 @@ export class CheckpointHeader {
|
|
|
260
271
|
feePerL2Gas: this.gasFees.feePerL2Gas,
|
|
261
272
|
},
|
|
262
273
|
totalManaUsed: this.totalManaUsed.toBigInt(),
|
|
274
|
+
accumulatedFees: this.accumulatedFees.toBigInt(),
|
|
263
275
|
};
|
|
264
276
|
}
|
|
265
277
|
|
|
@@ -276,6 +288,7 @@ export class CheckpointHeader {
|
|
|
276
288
|
feeRecipient: this.feeRecipient.toString(),
|
|
277
289
|
gasFees: this.gasFees.toInspect(),
|
|
278
290
|
totalManaUsed: this.totalManaUsed.toBigInt(),
|
|
291
|
+
accumulatedFees: this.accumulatedFees.toBigInt(),
|
|
279
292
|
};
|
|
280
293
|
}
|
|
281
294
|
|
|
@@ -292,6 +305,7 @@ export class CheckpointHeader {
|
|
|
292
305
|
feeRecipient: ${this.feeRecipient.toString()},
|
|
293
306
|
gasFees: { da:${this.gasFees.feePerDaGas}, l2:${this.gasFees.feePerL2Gas} },
|
|
294
307
|
totalManaUsed: ${this.totalManaUsed.toBigInt()},
|
|
308
|
+
accumulatedFees: ${this.accumulatedFees.toBigInt()},
|
|
295
309
|
}`;
|
|
296
310
|
}
|
|
297
311
|
}
|
package/src/tests/factories.ts
CHANGED
|
@@ -703,7 +703,7 @@ export function makeGlobalVariables(seed = 1, overrides: Partial<FieldsOf<Global
|
|
|
703
703
|
slotNumber: SlotNumber(seed + 3),
|
|
704
704
|
timestamp: BigInt(seed + 4),
|
|
705
705
|
coinbase: EthAddress.fromField(new Fr(seed + 5)),
|
|
706
|
-
feeRecipient: AztecAddress.
|
|
706
|
+
feeRecipient: AztecAddress.fromFieldUnsafe(new Fr(seed + 6)),
|
|
707
707
|
gasFees: new GasFees(seed + 7, seed + 8),
|
|
708
708
|
...compact(overrides),
|
|
709
709
|
});
|
|
@@ -753,7 +753,7 @@ export function makeBytes(size = 32, fill = 1): Buffer {
|
|
|
753
753
|
* @returns An aztec address.
|
|
754
754
|
*/
|
|
755
755
|
export function makeAztecAddress(seed = 1): AztecAddress {
|
|
756
|
-
return AztecAddress.
|
|
756
|
+
return AztecAddress.fromFieldUnsafe(fr(seed));
|
|
757
757
|
}
|
|
758
758
|
|
|
759
759
|
function makeBlockConstantData(seed = 1, globalVariables?: GlobalVariables) {
|
|
@@ -916,6 +916,7 @@ export function makeCheckpointHeader(seed = 0, overrides: Partial<FieldsOf<Check
|
|
|
916
916
|
feeRecipient: makeAztecAddress(seed + 0x600),
|
|
917
917
|
gasFees: makeGasFees(seed + 0x700),
|
|
918
918
|
totalManaUsed: fr(seed + 0x800),
|
|
919
|
+
accumulatedFees: fr(seed + 0x850),
|
|
919
920
|
...overrides,
|
|
920
921
|
});
|
|
921
922
|
}
|
|
@@ -1745,10 +1746,6 @@ export function makeL2Tips(
|
|
|
1745
1746
|
block: { number: bn, hash },
|
|
1746
1747
|
checkpoint: { number: cpn, hash: cph },
|
|
1747
1748
|
},
|
|
1748
|
-
proposedCheckpoint: {
|
|
1749
|
-
block: { number: bn, hash },
|
|
1750
|
-
checkpoint: { number: cpn, hash: cph },
|
|
1751
|
-
},
|
|
1752
1749
|
proven: {
|
|
1753
1750
|
block: { number: bn, hash },
|
|
1754
1751
|
checkpoint: { number: cpn, hash: cph },
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { NULLIFIER_TREE_HEIGHT } from '@aztec/constants';
|
|
2
|
-
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
2
|
import { MembershipWitness, SiblingPath } from '@aztec/foundation/trees';
|
|
4
3
|
|
|
5
4
|
import { z } from 'zod';
|
|
@@ -52,14 +51,4 @@ export class NullifierMembershipWitness {
|
|
|
52
51
|
public withoutPreimage(): MembershipWitness<typeof NULLIFIER_TREE_HEIGHT> {
|
|
53
52
|
return new MembershipWitness(NULLIFIER_TREE_HEIGHT, this.index, this.siblingPath.toTuple());
|
|
54
53
|
}
|
|
55
|
-
|
|
56
|
-
/** Serializes as `(NullifierLeafPreimage, MembershipWitness)` to match the Noir oracle return type. */
|
|
57
|
-
public toNoirRepresentation(): (string | string[])[] {
|
|
58
|
-
// TODO(#12874): remove the stupid as string conversion by modifying ForeignCallOutput type in acvm.js
|
|
59
|
-
return [
|
|
60
|
-
...(this.leafPreimage.toFields().map(fr => fr.toString()) as string[]),
|
|
61
|
-
new Fr(this.index).toString() as string,
|
|
62
|
-
this.siblingPath.toFields().map(fr => fr.toString()) as string[],
|
|
63
|
-
];
|
|
64
|
-
}
|
|
65
54
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { PUBLIC_DATA_TREE_HEIGHT } from '@aztec/constants';
|
|
2
2
|
import { toBigIntBE } from '@aztec/foundation/bigint-buffer';
|
|
3
|
-
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
3
|
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
5
4
|
import { bufferToHex, hexToBuffer } from '@aztec/foundation/string';
|
|
6
5
|
import { MembershipWitness, SiblingPath } from '@aztec/foundation/trees';
|
|
@@ -43,36 +42,6 @@ export class PublicDataWitness {
|
|
|
43
42
|
.transform(({ index, leafPreimage, siblingPath }) => new PublicDataWitness(index, leafPreimage, siblingPath));
|
|
44
43
|
}
|
|
45
44
|
|
|
46
|
-
/**
|
|
47
|
-
* Returns a field array representation of a public data witness.
|
|
48
|
-
* @returns A field array representation of a public data witness.
|
|
49
|
-
*/
|
|
50
|
-
public toFields(): Fr[] {
|
|
51
|
-
return [
|
|
52
|
-
new Fr(this.index),
|
|
53
|
-
new Fr(this.leafPreimage.leaf.slot),
|
|
54
|
-
new Fr(this.leafPreimage.leaf.value),
|
|
55
|
-
new Fr(this.leafPreimage.nextIndex),
|
|
56
|
-
new Fr(this.leafPreimage.nextKey),
|
|
57
|
-
...this.siblingPath.toFields(),
|
|
58
|
-
];
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Returns a representation of the public data witness as expected by intrinsic Noir deserialization.
|
|
63
|
-
*/
|
|
64
|
-
public toNoirRepresentation(): (string | string[])[] {
|
|
65
|
-
// TODO(#12874): remove the stupid as string conversion by modifying ForeignCallOutput type in acvm.js
|
|
66
|
-
return [
|
|
67
|
-
new Fr(this.index).toString() as string,
|
|
68
|
-
new Fr(this.leafPreimage.leaf.slot).toString() as string,
|
|
69
|
-
new Fr(this.leafPreimage.leaf.value).toString() as string,
|
|
70
|
-
new Fr(this.leafPreimage.nextKey).toString() as string,
|
|
71
|
-
new Fr(this.leafPreimage.nextIndex).toString() as string,
|
|
72
|
-
this.siblingPath.toFields().map(fr => fr.toString()) as string[],
|
|
73
|
-
];
|
|
74
|
-
}
|
|
75
|
-
|
|
76
45
|
toBuffer(): Buffer {
|
|
77
46
|
return serializeToBuffer([this.index, this.leafPreimage, this.siblingPath]);
|
|
78
47
|
}
|
|
@@ -54,7 +54,8 @@ export function mergeExecutionPayloads(requests: ExecutionPayload[]): ExecutionP
|
|
|
54
54
|
);
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
const feePayer =
|
|
57
|
+
const feePayer =
|
|
58
|
+
uniqueFeePayers.size === 1 ? AztecAddress.fromStringUnsafe(Array.from(uniqueFeePayers)[0]) : undefined;
|
|
58
59
|
|
|
59
60
|
return new ExecutionPayload(calls, combinedAuthWitnesses, combinedCapsules, combinedExtraHashedArgs, feePayer);
|
|
60
61
|
}
|
|
@@ -3,28 +3,12 @@ import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
|
3
3
|
import type { SlotNumber } from '@aztec/foundation/schemas';
|
|
4
4
|
|
|
5
5
|
import type { AztecAddress } from '../aztec-address/index.js';
|
|
6
|
-
import type {
|
|
7
|
-
import type { CheckpointGlobalVariables, GlobalVariables } from './global_variables.js';
|
|
6
|
+
import type { CheckpointGlobalVariables } from './global_variables.js';
|
|
8
7
|
|
|
9
8
|
/**
|
|
10
9
|
* Interface for building global variables for Aztec blocks.
|
|
11
10
|
*/
|
|
12
11
|
export interface GlobalVariableBuilder {
|
|
13
|
-
/**
|
|
14
|
-
* Builds global variables for a given block.
|
|
15
|
-
* @param blockNumber - The block number to build global variables for.
|
|
16
|
-
* @param coinbase - The address to receive block reward.
|
|
17
|
-
* @param feeRecipient - The address to receive fees.
|
|
18
|
-
* @param slotNumber - Optional. The slot number to use for the global variables. If undefined, it will be calculated.
|
|
19
|
-
* @returns A promise that resolves to the GlobalVariables for the given block number.
|
|
20
|
-
*/
|
|
21
|
-
buildGlobalVariables(
|
|
22
|
-
blockNumber: UInt32,
|
|
23
|
-
coinbase: EthAddress,
|
|
24
|
-
feeRecipient: AztecAddress,
|
|
25
|
-
slotNumber?: SlotNumber,
|
|
26
|
-
): Promise<GlobalVariables>;
|
|
27
|
-
|
|
28
12
|
/** Builds global variables that are constant throughout a checkpoint. */
|
|
29
13
|
buildCheckpointGlobalVariables(
|
|
30
14
|
coinbase: EthAddress,
|
|
@@ -125,7 +125,7 @@ export class GlobalVariables {
|
|
|
125
125
|
SlotNumber(reader.readU32()),
|
|
126
126
|
reader.readField().toBigInt(),
|
|
127
127
|
EthAddress.fromField(reader.readField()),
|
|
128
|
-
AztecAddress.
|
|
128
|
+
AztecAddress.fromFieldUnsafe(reader.readField()),
|
|
129
129
|
GasFees.fromFields(reader),
|
|
130
130
|
);
|
|
131
131
|
}
|
|
@@ -220,7 +220,7 @@ export class GlobalVariables {
|
|
|
220
220
|
blockNumber: BlockNumber(randomInt(100_000)),
|
|
221
221
|
slotNumber: SlotNumber(randomInt(100_000)),
|
|
222
222
|
coinbase: EthAddress.random(),
|
|
223
|
-
feeRecipient: AztecAddress.
|
|
223
|
+
feeRecipient: AztecAddress.fromFieldUnsafe(Fr.random()),
|
|
224
224
|
gasFees: GasFees.random(),
|
|
225
225
|
timestamp: BigInt(randomInt(100_000_000)),
|
|
226
226
|
...overrides,
|