@aztec/stdlib 0.0.1-commit.7ac86ea28 → 0.0.1-commit.7b86788
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 +1 -1
- package/dest/abi/decoder.d.ts.map +1 -1
- package/dest/abi/decoder.js +1 -4
- package/dest/abi/encoder.d.ts +1 -1
- package/dest/abi/encoder.d.ts.map +1 -1
- package/dest/abi/encoder.js +9 -5
- package/dest/avm/avm.d.ts +300 -300
- package/dest/avm/avm_proving_request.d.ts +166 -166
- package/dest/avm/revert_code.d.ts +16 -1
- package/dest/avm/revert_code.d.ts.map +1 -1
- package/dest/avm/revert_code.js +15 -5
- package/dest/block/l2_block_stream/l2_block_stream.d.ts +1 -1
- package/dest/block/l2_block_stream/l2_block_stream.d.ts.map +1 -1
- package/dest/block/l2_block_stream/l2_block_stream.js +10 -0
- package/dest/ha-signing/config.d.ts +101 -0
- package/dest/ha-signing/config.d.ts.map +1 -0
- package/dest/ha-signing/config.js +92 -0
- package/dest/ha-signing/index.d.ts +3 -0
- package/dest/ha-signing/index.d.ts.map +1 -0
- package/dest/ha-signing/index.js +2 -0
- package/dest/ha-signing/types.d.ts +85 -0
- package/dest/ha-signing/types.d.ts.map +1 -0
- package/dest/ha-signing/types.js +32 -0
- package/dest/interfaces/p2p.d.ts +3 -8
- package/dest/interfaces/p2p.d.ts.map +1 -1
- package/dest/interfaces/validator.d.ts +2 -2
- package/dest/interfaces/validator.d.ts.map +1 -1
- package/dest/interfaces/validator.js +1 -1
- package/dest/kernel/hints/build_note_hash_read_request_hints.d.ts +3 -3
- package/dest/kernel/hints/build_note_hash_read_request_hints.d.ts.map +1 -1
- package/dest/kernel/hints/build_note_hash_read_request_hints.js +13 -10
- package/dest/kernel/hints/build_nullifier_read_request_hints.d.ts +3 -3
- package/dest/kernel/hints/build_nullifier_read_request_hints.d.ts.map +1 -1
- package/dest/kernel/hints/build_nullifier_read_request_hints.js +13 -10
- package/dest/kernel/hints/build_transient_data_hints.d.ts +5 -2
- package/dest/kernel/hints/build_transient_data_hints.d.ts.map +1 -1
- package/dest/kernel/hints/build_transient_data_hints.js +9 -3
- package/dest/logs/debug_log_store.d.ts +30 -0
- package/dest/logs/debug_log_store.d.ts.map +1 -0
- package/dest/logs/debug_log_store.js +30 -0
- package/dest/logs/extended_directional_app_tagging_secret.d.ts +47 -0
- package/dest/logs/extended_directional_app_tagging_secret.d.ts.map +1 -0
- package/dest/logs/{directional_app_tagging_secret.js → extended_directional_app_tagging_secret.js} +23 -15
- package/dest/logs/index.d.ts +3 -2
- package/dest/logs/index.d.ts.map +1 -1
- package/dest/logs/index.js +2 -1
- package/dest/logs/pre_tag.d.ts +16 -11
- package/dest/logs/pre_tag.d.ts.map +1 -1
- package/dest/logs/pre_tag.js +2 -2
- package/dest/logs/siloed_tag.d.ts +5 -3
- package/dest/logs/siloed_tag.d.ts.map +1 -1
- package/dest/logs/siloed_tag.js +6 -1
- package/dest/logs/tag.js +1 -1
- package/dest/p2p/attestation_utils.d.ts +11 -1
- package/dest/p2p/attestation_utils.d.ts.map +1 -1
- package/dest/p2p/attestation_utils.js +45 -0
- package/dest/p2p/block_proposal.d.ts +2 -2
- package/dest/p2p/block_proposal.d.ts.map +1 -1
- package/dest/p2p/block_proposal.js +1 -1
- package/dest/p2p/checkpoint_proposal.d.ts +2 -2
- package/dest/p2p/checkpoint_proposal.d.ts.map +1 -1
- package/dest/p2p/checkpoint_proposal.js +1 -1
- package/dest/p2p/client_type.d.ts +2 -5
- package/dest/p2p/client_type.d.ts.map +1 -1
- package/dest/p2p/client_type.js +0 -7
- package/dest/p2p/index.d.ts +1 -2
- package/dest/p2p/index.d.ts.map +1 -1
- package/dest/p2p/index.js +0 -1
- package/dest/p2p/topic_type.d.ts +3 -4
- package/dest/p2p/topic_type.d.ts.map +1 -1
- package/dest/p2p/topic_type.js +7 -24
- package/dest/tests/factories.d.ts +3 -1
- package/dest/tests/factories.d.ts.map +1 -1
- package/dest/tests/factories.js +8 -0
- package/dest/tests/mocks.d.ts +2 -2
- package/dest/tests/mocks.d.ts.map +1 -1
- package/dest/tests/mocks.js +5 -5
- package/dest/tx/tx_receipt.d.ts +16 -2
- package/dest/tx/tx_receipt.d.ts.map +1 -1
- package/dest/tx/tx_receipt.js +11 -3
- package/package.json +10 -10
- package/src/abi/decoder.ts +1 -4
- package/src/abi/encoder.ts +8 -5
- package/src/avm/revert_code.ts +15 -0
- package/src/block/l2_block_stream/l2_block_stream.ts +21 -0
- package/src/ha-signing/config.ts +149 -0
- package/src/ha-signing/index.ts +18 -0
- package/src/ha-signing/types.ts +112 -0
- package/src/interfaces/p2p.ts +2 -13
- package/src/interfaces/validator.ts +1 -1
- package/src/kernel/hints/build_note_hash_read_request_hints.ts +14 -18
- package/src/kernel/hints/build_nullifier_read_request_hints.ts +15 -18
- package/src/kernel/hints/build_transient_data_hints.ts +17 -2
- package/src/logs/debug_log_store.ts +54 -0
- package/src/logs/{directional_app_tagging_secret.ts → extended_directional_app_tagging_secret.ts} +24 -16
- package/src/logs/index.ts +2 -1
- package/src/logs/pre_tag.ts +5 -5
- package/src/logs/siloed_tag.ts +8 -2
- package/src/logs/tag.ts +1 -1
- package/src/p2p/attestation_utils.ts +56 -0
- package/src/p2p/block_proposal.ts +1 -1
- package/src/p2p/checkpoint_proposal.ts +1 -1
- package/src/p2p/client_type.ts +0 -6
- package/src/p2p/index.ts +0 -1
- package/src/p2p/topic_type.ts +8 -15
- package/src/tests/factories.ts +9 -0
- package/src/tests/mocks.ts +7 -3
- package/src/tx/tx_receipt.ts +10 -0
- package/dest/logs/directional_app_tagging_secret.d.ts +0 -40
- package/dest/logs/directional_app_tagging_secret.d.ts.map +0 -1
|
@@ -4,6 +4,7 @@ import type { Tuple } from '@aztec/foundation/serialize';
|
|
|
4
4
|
import type { ClaimedLengthArray } from '../claimed_length_array.js';
|
|
5
5
|
import type { ScopedNoteHash } from '../note_hash.js';
|
|
6
6
|
import type { ScopedNullifier } from '../nullifier.js';
|
|
7
|
+
import type { PrivateLogData, ScopedPrivateLogData } from '../private_log_data.js';
|
|
7
8
|
import { isValidNoteHashReadRequest } from './build_note_hash_read_request_hints.js';
|
|
8
9
|
import { isValidNullifierReadRequest } from './build_nullifier_read_request_hints.js';
|
|
9
10
|
import type { ScopedReadRequest } from './read_request.js';
|
|
@@ -15,11 +16,13 @@ export function buildTransientDataHints<NOTE_HASHES_LEN extends number, NULLIFIE
|
|
|
15
16
|
nullifiers: ClaimedLengthArray<ScopedNullifier, NULLIFIERS_LEN>,
|
|
16
17
|
futureNoteHashReads: ScopedReadRequest[],
|
|
17
18
|
futureNullifierReads: ScopedReadRequest[],
|
|
19
|
+
futureLogs: PrivateLogData[],
|
|
18
20
|
noteHashNullifierCounterMap: Map<number, number>,
|
|
19
21
|
splitCounter: number,
|
|
20
22
|
): { numTransientData: number; hints: Tuple<TransientDataSquashingHint, NULLIFIERS_LEN> } {
|
|
21
23
|
const futureNoteHashReadsMap = new ScopedValueCache(futureNoteHashReads);
|
|
22
24
|
const futureNullifierReadsMap = new ScopedValueCache(futureNullifierReads);
|
|
25
|
+
const futureLogNoteHashCounters = new Set(futureLogs.filter(l => l.noteHashCounter > 0).map(l => l.noteHashCounter));
|
|
23
26
|
|
|
24
27
|
const nullifierIndexMap: Map<number, number> = new Map();
|
|
25
28
|
nullifiers.getActiveItems().forEach((n, i) => nullifierIndexMap.set(n.counter, i));
|
|
@@ -28,10 +31,12 @@ export function buildTransientDataHints<NOTE_HASHES_LEN extends number, NULLIFIE
|
|
|
28
31
|
for (let noteHashIndex = 0; noteHashIndex < noteHashes.claimedLength; noteHashIndex++) {
|
|
29
32
|
const noteHash = noteHashes.array[noteHashIndex];
|
|
30
33
|
const noteHashNullifierCounter = noteHashNullifierCounterMap.get(noteHash.counter);
|
|
31
|
-
// The note hash might not be linked to a nullifier or it might be read in the future
|
|
34
|
+
// The note hash might not be linked to a nullifier, or it might be read in the future, or a future log might be
|
|
35
|
+
// linked to it.
|
|
32
36
|
if (
|
|
33
37
|
!noteHashNullifierCounter ||
|
|
34
|
-
futureNoteHashReadsMap.get(noteHash).find(read => isValidNoteHashReadRequest(read, noteHash))
|
|
38
|
+
futureNoteHashReadsMap.get(noteHash).find(read => isValidNoteHashReadRequest(read, noteHash)) ||
|
|
39
|
+
futureLogNoteHashCounters.has(noteHash.counter)
|
|
35
40
|
) {
|
|
36
41
|
continue;
|
|
37
42
|
}
|
|
@@ -77,3 +82,13 @@ export function buildTransientDataHints<NOTE_HASHES_LEN extends number, NULLIFIE
|
|
|
77
82
|
hints: padArrayEnd(hints, noActionHint, nullifiers.array.length as NULLIFIERS_LEN),
|
|
78
83
|
};
|
|
79
84
|
}
|
|
85
|
+
|
|
86
|
+
/** Counts private logs that are linked to squashed note hashes and would be removed along with them. */
|
|
87
|
+
export function countSquashedLogs<NOTE_HASHES_LEN extends number, LOGS_LEN extends number>(
|
|
88
|
+
noteHashes: ClaimedLengthArray<ScopedNoteHash, NOTE_HASHES_LEN>,
|
|
89
|
+
privateLogs: ClaimedLengthArray<ScopedPrivateLogData, LOGS_LEN>,
|
|
90
|
+
squashingHints: TransientDataSquashingHint[],
|
|
91
|
+
): number {
|
|
92
|
+
const squashedNoteHashCounters = new Set(squashingHints.map(h => noteHashes.array[h.noteHashIndex].counter));
|
|
93
|
+
return privateLogs.getActiveItems().filter(l => squashedNoteHashCounters.has(l.inner.noteHashCounter)).length;
|
|
94
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { TxReceipt } from '../tx/tx_receipt.js';
|
|
2
|
+
import type { DebugLog } from './debug_log.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Store for debug logs emitted by public functions during transaction execution.
|
|
6
|
+
*
|
|
7
|
+
* Uses the Null Object pattern: production code uses NullDebugLogStore (no-op), while test mode uses
|
|
8
|
+
* InMemoryDebugLogStore (stores and serves logs).
|
|
9
|
+
*/
|
|
10
|
+
export interface DebugLogStore {
|
|
11
|
+
/** Store debug logs for a processed transaction. */
|
|
12
|
+
storeLogs(txHash: string, logs: DebugLog[]): void;
|
|
13
|
+
/** Decorate a TxReceipt with any stored debug logs for the given tx. */
|
|
14
|
+
decorateReceiptWithLogs(txHash: string, receipt: TxReceipt): void;
|
|
15
|
+
/** Whether debug log collection is enabled. */
|
|
16
|
+
readonly isEnabled: boolean;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** No-op implementation for production mode. */
|
|
20
|
+
export class NullDebugLogStore implements DebugLogStore {
|
|
21
|
+
storeLogs(_txHash: string, _logs: DebugLog[]): void {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
decorateReceiptWithLogs(_txHash: string, _receipt: TxReceipt): void {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
get isEnabled(): boolean {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** In-memory implementation for test mode that stores and serves debug logs. */
|
|
33
|
+
export class InMemoryDebugLogStore implements DebugLogStore {
|
|
34
|
+
private map = new Map<string, DebugLog[]>();
|
|
35
|
+
|
|
36
|
+
storeLogs(txHash: string, logs: DebugLog[]): void {
|
|
37
|
+
if (logs.length > 0) {
|
|
38
|
+
this.map.set(txHash, logs);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
decorateReceiptWithLogs(txHash: string, receipt: TxReceipt): void {
|
|
43
|
+
if (receipt.isMined()) {
|
|
44
|
+
const debugLogs = this.map.get(txHash);
|
|
45
|
+
if (debugLogs) {
|
|
46
|
+
receipt.debugLogs = debugLogs;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
get isEnabled(): boolean {
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
}
|
package/src/logs/{directional_app_tagging_secret.ts → extended_directional_app_tagging_secret.ts}
RENAMED
|
@@ -5,22 +5,28 @@ import type { Point } from '@aztec/foundation/curves/grumpkin';
|
|
|
5
5
|
|
|
6
6
|
import { z } from 'zod';
|
|
7
7
|
|
|
8
|
-
import
|
|
8
|
+
import { AztecAddress } from '../aztec-address/index.js';
|
|
9
9
|
import type { CompleteAddress } from '../contract/complete_address.js';
|
|
10
10
|
import { computeAddressSecret, computePreaddress } from '../keys/derivation.js';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
13
|
+
* Extended directional application tagging secret used for log tagging.
|
|
14
14
|
*
|
|
15
|
-
* "
|
|
16
|
-
*
|
|
15
|
+
* "Extended" because it bundles the directional app tagging secret with the app (contract) address. This bundling was
|
|
16
|
+
* done because where this type is used we commonly need access to both the secret and the address.
|
|
17
17
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
18
|
+
* "Directional" because the derived secret is bound to the recipient address: A→B differs from B→A even with the same
|
|
19
|
+
* participants and app.
|
|
20
|
+
*
|
|
21
|
+
* Note: It's a bit unfortunate that this type resides in `stdlib` as the rest of the tagging functionality resides in
|
|
22
|
+
* `pxe/src/tagging`. We need to use this type in `PreTag` that in turn is used by other types in stdlib hence there
|
|
23
|
+
* doesn't seem to be a good way around this.
|
|
21
24
|
*/
|
|
22
|
-
export class
|
|
23
|
-
private constructor(
|
|
25
|
+
export class ExtendedDirectionalAppTaggingSecret {
|
|
26
|
+
private constructor(
|
|
27
|
+
public readonly secret: Fr,
|
|
28
|
+
public readonly app: AztecAddress,
|
|
29
|
+
) {}
|
|
24
30
|
|
|
25
31
|
/**
|
|
26
32
|
* Derives shared tagging secret and from that, the app address and recipient derives the directional app tagging
|
|
@@ -39,20 +45,21 @@ export class DirectionalAppTaggingSecret {
|
|
|
39
45
|
externalAddress: AztecAddress,
|
|
40
46
|
app: AztecAddress,
|
|
41
47
|
recipient: AztecAddress,
|
|
42
|
-
): Promise<
|
|
48
|
+
): Promise<ExtendedDirectionalAppTaggingSecret> {
|
|
43
49
|
const taggingSecretPoint = await computeSharedTaggingSecret(localAddress, localIvsk, externalAddress);
|
|
44
50
|
const appTaggingSecret = await poseidon2Hash([taggingSecretPoint.x, taggingSecretPoint.y, app]);
|
|
45
51
|
const directionalAppTaggingSecret = await poseidon2Hash([appTaggingSecret, recipient]);
|
|
46
52
|
|
|
47
|
-
return new
|
|
53
|
+
return new ExtendedDirectionalAppTaggingSecret(directionalAppTaggingSecret, app);
|
|
48
54
|
}
|
|
49
55
|
|
|
50
56
|
toString(): string {
|
|
51
|
-
return this.
|
|
57
|
+
return `${this.secret.toString()}:${this.app.toString()}`;
|
|
52
58
|
}
|
|
53
59
|
|
|
54
|
-
static fromString(str: string):
|
|
55
|
-
|
|
60
|
+
static fromString(str: string): ExtendedDirectionalAppTaggingSecret {
|
|
61
|
+
const [secretStr, appStr] = str.split(':');
|
|
62
|
+
return new ExtendedDirectionalAppTaggingSecret(Fr.fromString(secretStr), AztecAddress.fromString(appStr));
|
|
56
63
|
}
|
|
57
64
|
}
|
|
58
65
|
|
|
@@ -74,6 +81,7 @@ async function computeSharedTaggingSecret(
|
|
|
74
81
|
return Grumpkin.mul(externalAddressPoint, await computeAddressSecret(knownPreaddress, localIvsk));
|
|
75
82
|
}
|
|
76
83
|
|
|
77
|
-
export const
|
|
78
|
-
|
|
84
|
+
export const ExtendedDirectionalAppTaggingSecretSchema = z.object({
|
|
85
|
+
secret: Fr.schema,
|
|
86
|
+
app: AztecAddress.schema,
|
|
79
87
|
});
|
package/src/logs/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './extended_directional_app_tagging_secret.js';
|
|
2
2
|
export * from './pre_tag.js';
|
|
3
3
|
export * from './contract_class_log.js';
|
|
4
4
|
export * from './public_log.js';
|
|
@@ -12,5 +12,6 @@ export * from './shared_secret_derivation.js';
|
|
|
12
12
|
export * from './tx_scoped_l2_log.js';
|
|
13
13
|
export * from './message_context.js';
|
|
14
14
|
export * from './debug_log.js';
|
|
15
|
+
export * from './debug_log_store.js';
|
|
15
16
|
export * from './tag.js';
|
|
16
17
|
export * from './siloed_tag.js';
|
package/src/logs/pre_tag.ts
CHANGED
|
@@ -3,9 +3,9 @@ import { schemas } from '@aztec/foundation/schemas';
|
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
5
5
|
import {
|
|
6
|
-
type
|
|
7
|
-
|
|
8
|
-
} from './
|
|
6
|
+
type ExtendedDirectionalAppTaggingSecret,
|
|
7
|
+
ExtendedDirectionalAppTaggingSecretSchema,
|
|
8
|
+
} from './extended_directional_app_tagging_secret.js';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Represents a preimage of a private log tag (see `Tag` in `pxe/src/tagging`).
|
|
@@ -15,11 +15,11 @@ import {
|
|
|
15
15
|
* around this.
|
|
16
16
|
*/
|
|
17
17
|
export type PreTag = {
|
|
18
|
-
|
|
18
|
+
extendedSecret: ExtendedDirectionalAppTaggingSecret;
|
|
19
19
|
index: number;
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
export const PreTagSchema = z.object({
|
|
23
|
-
|
|
23
|
+
extendedSecret: ExtendedDirectionalAppTaggingSecretSchema,
|
|
24
24
|
index: schemas.Integer,
|
|
25
25
|
});
|
package/src/logs/siloed_tag.ts
CHANGED
|
@@ -4,7 +4,8 @@ import type { ZodFor } from '@aztec/foundation/schemas';
|
|
|
4
4
|
import type { AztecAddress } from '../aztec-address/index.js';
|
|
5
5
|
import { computeSiloedPrivateLogFirstField } from '../hash/hash.js';
|
|
6
6
|
import { schemas } from '../schemas/schemas.js';
|
|
7
|
-
import type {
|
|
7
|
+
import type { PreTag } from './pre_tag.js';
|
|
8
|
+
import { Tag } from './tag.js';
|
|
8
9
|
|
|
9
10
|
/* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */
|
|
10
11
|
|
|
@@ -21,7 +22,12 @@ export interface SiloedTag {
|
|
|
21
22
|
export class SiloedTag {
|
|
22
23
|
constructor(public readonly value: Fr) {}
|
|
23
24
|
|
|
24
|
-
static async compute(
|
|
25
|
+
static async compute(preTag: PreTag): Promise<SiloedTag> {
|
|
26
|
+
const tag = await Tag.compute(preTag);
|
|
27
|
+
return SiloedTag.computeFromTagAndApp(tag, preTag.extendedSecret.app);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
static async computeFromTagAndApp(tag: Tag, app: AztecAddress): Promise<SiloedTag> {
|
|
25
31
|
const siloedTag = await computeSiloedPrivateLogFirstField(app, tag.value);
|
|
26
32
|
return new SiloedTag(siloedTag);
|
|
27
33
|
}
|
package/src/logs/tag.ts
CHANGED
|
@@ -20,7 +20,7 @@ export class Tag {
|
|
|
20
20
|
constructor(public readonly value: Fr) {}
|
|
21
21
|
|
|
22
22
|
static async compute(preTag: PreTag): Promise<Tag> {
|
|
23
|
-
const tag = await poseidon2Hash([preTag.secret
|
|
23
|
+
const tag = await poseidon2Hash([preTag.extendedSecret.secret, preTag.index]);
|
|
24
24
|
return new Tag(tag);
|
|
25
25
|
}
|
|
26
26
|
|
|
@@ -33,3 +33,59 @@ export function orderAttestations(
|
|
|
33
33
|
|
|
34
34
|
return orderedAttestations;
|
|
35
35
|
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Trims attestations to the minimum required number to save L1 calldata gas.
|
|
39
|
+
* Each signature costs 65 bytes of calldata vs 20 bytes for just an address.
|
|
40
|
+
*
|
|
41
|
+
* Priority order for keeping attestations:
|
|
42
|
+
* 1. The proposer's attestation (required by L1 contract - MissingProposerSignature revert)
|
|
43
|
+
* 2. Attestations from the local node's validator keys
|
|
44
|
+
* 3. Remaining attestations filled to reach the required count
|
|
45
|
+
*/
|
|
46
|
+
export function trimAttestations(
|
|
47
|
+
attestations: CheckpointAttestation[],
|
|
48
|
+
required: number,
|
|
49
|
+
proposerAddress: EthAddress,
|
|
50
|
+
localAddresses: EthAddress[],
|
|
51
|
+
): CheckpointAttestation[] {
|
|
52
|
+
if (attestations.length <= required) {
|
|
53
|
+
return attestations;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const proposerAttestation: CheckpointAttestation[] = [];
|
|
57
|
+
const localAttestations: CheckpointAttestation[] = [];
|
|
58
|
+
const otherAttestations: CheckpointAttestation[] = [];
|
|
59
|
+
|
|
60
|
+
for (const attestation of attestations) {
|
|
61
|
+
const sender = attestation.getSender();
|
|
62
|
+
if (!sender) {
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
if (sender.equals(proposerAddress)) {
|
|
66
|
+
proposerAttestation.push(attestation);
|
|
67
|
+
} else if (localAddresses.some(addr => addr.equals(sender))) {
|
|
68
|
+
localAttestations.push(attestation);
|
|
69
|
+
} else {
|
|
70
|
+
otherAttestations.push(attestation);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const result: CheckpointAttestation[] = [...proposerAttestation];
|
|
75
|
+
|
|
76
|
+
for (const att of localAttestations) {
|
|
77
|
+
if (result.length >= required) {
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
result.push(att);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
for (const att of otherAttestations) {
|
|
84
|
+
if (result.length >= required) {
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
result.push(att);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return result;
|
|
91
|
+
}
|
|
@@ -6,11 +6,11 @@ import { Fr } from '@aztec/foundation/curves/bn254';
|
|
|
6
6
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
7
7
|
import { Signature } from '@aztec/foundation/eth-signature';
|
|
8
8
|
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
9
|
-
import { DutyType, type SigningContext } from '@aztec/validator-ha-signer/types';
|
|
10
9
|
|
|
11
10
|
import type { L2Block } from '../block/l2_block.js';
|
|
12
11
|
import type { L2BlockInfo } from '../block/l2_block_info.js';
|
|
13
12
|
import { MAX_TXS_PER_BLOCK } from '../deserialization/index.js';
|
|
13
|
+
import { DutyType, type SigningContext } from '../ha-signing/index.js';
|
|
14
14
|
import { BlockHeader } from '../tx/block_header.js';
|
|
15
15
|
import { TxHash } from '../tx/index.js';
|
|
16
16
|
import type { Tx } from '../tx/tx.js';
|
|
@@ -6,10 +6,10 @@ import { Fr } from '@aztec/foundation/curves/bn254';
|
|
|
6
6
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
7
7
|
import { Signature } from '@aztec/foundation/eth-signature';
|
|
8
8
|
import { BufferReader, serializeSignedBigInt, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
9
|
-
import { DutyType, type SigningContext } from '@aztec/validator-ha-signer/types';
|
|
10
9
|
|
|
11
10
|
import type { L2BlockInfo } from '../block/l2_block_info.js';
|
|
12
11
|
import { MAX_TXS_PER_BLOCK } from '../deserialization/index.js';
|
|
12
|
+
import { DutyType, type SigningContext } from '../ha-signing/index.js';
|
|
13
13
|
import { CheckpointHeader } from '../rollup/checkpoint_header.js';
|
|
14
14
|
import { BlockHeader } from '../tx/block_header.js';
|
|
15
15
|
import { TxHash } from '../tx/index.js';
|
package/src/p2p/client_type.ts
CHANGED
package/src/p2p/index.ts
CHANGED
|
@@ -8,7 +8,6 @@ export * from './interface.js';
|
|
|
8
8
|
export * from './signature_utils.js';
|
|
9
9
|
export * from './signed_txs.js';
|
|
10
10
|
export * from './topic_type.js';
|
|
11
|
-
export * from './client_type.js';
|
|
12
11
|
export * from './message_validator.js';
|
|
13
12
|
export * from './peer_error.js';
|
|
14
13
|
export * from './constants.js';
|
package/src/p2p/topic_type.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { P2PClientType } from './client_type.js';
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
2
|
* Creates the topic channel identifier string from a given topic type
|
|
5
3
|
*/
|
|
@@ -27,19 +25,14 @@ export enum TopicType {
|
|
|
27
25
|
checkpoint_attestation = 'checkpoint_attestation',
|
|
28
26
|
}
|
|
29
27
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export function getTopicsForClientAndConfig(clientType: P2PClientType, disableTransactions: boolean) {
|
|
42
|
-
const topics = getTopicTypeForClientType(clientType);
|
|
28
|
+
/** Returns all gossip topics, optionally filtering out transactions. */
|
|
29
|
+
export function getTopicsForConfig(disableTransactions: boolean) {
|
|
30
|
+
const topics = [
|
|
31
|
+
TopicType.tx,
|
|
32
|
+
TopicType.block_proposal,
|
|
33
|
+
TopicType.checkpoint_proposal,
|
|
34
|
+
TopicType.checkpoint_attestation,
|
|
35
|
+
];
|
|
43
36
|
if (disableTransactions) {
|
|
44
37
|
return topics.filter(topic => topic !== TopicType.tx);
|
|
45
38
|
}
|
package/src/tests/factories.ts
CHANGED
|
@@ -128,6 +128,7 @@ import {
|
|
|
128
128
|
PublicCallRequestArrayLengths,
|
|
129
129
|
} from '../kernel/public_call_request.js';
|
|
130
130
|
import { PublicKeys, computeAddress } from '../keys/index.js';
|
|
131
|
+
import { ExtendedDirectionalAppTaggingSecret } from '../logs/extended_directional_app_tagging_secret.js';
|
|
131
132
|
import { ContractClassLog, ContractClassLogFields } from '../logs/index.js';
|
|
132
133
|
import { PrivateLog } from '../logs/private_log.js';
|
|
133
134
|
import { FlatPublicLogs, PublicLog } from '../logs/public_log.js';
|
|
@@ -1757,3 +1758,11 @@ export function makeL2Tips(
|
|
|
1757
1758
|
},
|
|
1758
1759
|
};
|
|
1759
1760
|
}
|
|
1761
|
+
|
|
1762
|
+
export async function randomExtendedDirectionalAppTaggingSecret(): Promise<ExtendedDirectionalAppTaggingSecret> {
|
|
1763
|
+
const resolvedApp = await AztecAddress.random();
|
|
1764
|
+
// Using the fromString method like this is messy as it leaks the underlying serialization format but I don't want to
|
|
1765
|
+
// expose the type's constructor just for tests since in prod the secret is always constructed via compute. Also this
|
|
1766
|
+
// method is tested in extended_directional_app_tagging_secret.test.ts hence all should be fine.
|
|
1767
|
+
return ExtendedDirectionalAppTaggingSecret.fromString(`${Fr.random().toString()}:${resolvedApp.toString()}`);
|
|
1768
|
+
}
|
package/src/tests/mocks.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
|
-
FIXED_DA_GAS,
|
|
3
|
-
FIXED_L2_GAS,
|
|
4
2
|
MAX_ENQUEUED_CALLS_PER_TX,
|
|
5
3
|
MAX_NULLIFIERS_PER_TX,
|
|
6
4
|
MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX,
|
|
7
5
|
MAX_TX_LIFETIME,
|
|
6
|
+
PRIVATE_TX_L2_GAS_OVERHEAD,
|
|
7
|
+
PUBLIC_TX_L2_GAS_OVERHEAD,
|
|
8
|
+
TX_DA_GAS_OVERHEAD,
|
|
8
9
|
} from '@aztec/constants';
|
|
9
10
|
import { type FieldsOf, makeTuple } from '@aztec/foundation/array';
|
|
10
11
|
import { BlockNumber, CheckpointNumber, IndexWithinCheckpoint, SlotNumber } from '@aztec/foundation/branded-types';
|
|
@@ -205,8 +206,11 @@ export async function mockProcessedTx({
|
|
|
205
206
|
feePayer,
|
|
206
207
|
feePaymentPublicDataWrite,
|
|
207
208
|
// The default gasUsed is the tx overhead.
|
|
208
|
-
gasUsed = Gas.from({ daGas: FIXED_DA_GAS, l2Gas: FIXED_L2_GAS }),
|
|
209
209
|
privateOnly = false,
|
|
210
|
+
gasUsed = Gas.from({
|
|
211
|
+
daGas: TX_DA_GAS_OVERHEAD,
|
|
212
|
+
l2Gas: privateOnly ? PRIVATE_TX_L2_GAS_OVERHEAD : PUBLIC_TX_L2_GAS_OVERHEAD,
|
|
213
|
+
}),
|
|
210
214
|
avmAccumulatedData,
|
|
211
215
|
...mockTxOpts
|
|
212
216
|
}: {
|
package/src/tx/tx_receipt.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { z } from 'zod';
|
|
|
4
4
|
|
|
5
5
|
import { RevertCode } from '../avm/revert_code.js';
|
|
6
6
|
import { BlockHash } from '../block/block_hash.js';
|
|
7
|
+
import { DebugLog } from '../logs/debug_log.js';
|
|
7
8
|
import { type ZodFor, schemas } from '../schemas/schemas.js';
|
|
8
9
|
import { TxHash } from './tx_hash.js';
|
|
9
10
|
|
|
@@ -57,6 +58,12 @@ export class TxReceipt {
|
|
|
57
58
|
public blockHash?: BlockHash,
|
|
58
59
|
/** The block number in which the transaction was included. */
|
|
59
60
|
public blockNumber?: BlockNumber,
|
|
61
|
+
/**
|
|
62
|
+
* Debug logs collected during public function execution. Served only when the node is in test mode and placed on
|
|
63
|
+
* the receipt only because it's a convenient place for it (the logs are printed out by the wallet when a mined
|
|
64
|
+
* tx receipt is obtained).
|
|
65
|
+
*/
|
|
66
|
+
public debugLogs?: DebugLog[],
|
|
60
67
|
) {}
|
|
61
68
|
|
|
62
69
|
/** Returns true if the transaction was executed successfully. */
|
|
@@ -103,6 +110,7 @@ export class TxReceipt {
|
|
|
103
110
|
blockHash: BlockHash.schema.optional(),
|
|
104
111
|
blockNumber: BlockNumberSchema.optional(),
|
|
105
112
|
transactionFee: schemas.BigInt.optional(),
|
|
113
|
+
debugLogs: z.array(DebugLog.schema).optional(),
|
|
106
114
|
})
|
|
107
115
|
.transform(fields => TxReceipt.from(fields));
|
|
108
116
|
}
|
|
@@ -115,6 +123,7 @@ export class TxReceipt {
|
|
|
115
123
|
transactionFee?: bigint;
|
|
116
124
|
blockHash?: BlockHash;
|
|
117
125
|
blockNumber?: BlockNumber;
|
|
126
|
+
debugLogs?: DebugLog[];
|
|
118
127
|
}) {
|
|
119
128
|
return new TxReceipt(
|
|
120
129
|
fields.txHash,
|
|
@@ -124,6 +133,7 @@ export class TxReceipt {
|
|
|
124
133
|
fields.transactionFee,
|
|
125
134
|
fields.blockHash,
|
|
126
135
|
fields.blockNumber,
|
|
136
|
+
fields.debugLogs,
|
|
127
137
|
);
|
|
128
138
|
}
|
|
129
139
|
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { type Fq, Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
import type { AztecAddress } from '../aztec-address/index.js';
|
|
4
|
-
import type { CompleteAddress } from '../contract/complete_address.js';
|
|
5
|
-
/**
|
|
6
|
-
* Directional application tagging secret used for log tagging.
|
|
7
|
-
*
|
|
8
|
-
* "Directional" because the derived secret is bound to the recipient
|
|
9
|
-
* address: A→B differs from B→A even with the same participants and app.
|
|
10
|
-
*
|
|
11
|
-
* Note: It's a bit unfortunate that this type resides in `stdlib` as the rest of the tagging functionality resides
|
|
12
|
-
* in `pxe/src/tagging`. We need to use this type in `PreTag` that in turn is used by other types
|
|
13
|
-
* in stdlib hence there doesn't seem to be a good way around this.
|
|
14
|
-
*/
|
|
15
|
-
export declare class DirectionalAppTaggingSecret {
|
|
16
|
-
readonly value: Fr;
|
|
17
|
-
private constructor();
|
|
18
|
-
/**
|
|
19
|
-
* Derives shared tagging secret and from that, the app address and recipient derives the directional app tagging
|
|
20
|
-
* secret.
|
|
21
|
-
*
|
|
22
|
-
* @param localAddress - The complete address of entity A in the shared tagging secret derivation scheme
|
|
23
|
-
* @param localIvsk - The incoming viewing secret key of entity A
|
|
24
|
-
* @param externalAddress - The address of entity B in the shared tagging secret derivation scheme
|
|
25
|
-
* @param app - Contract address to silo the secret to
|
|
26
|
-
* @param recipient - Recipient of the log. Defines the "direction of the secret".
|
|
27
|
-
* @returns The secret that can be used along with an index to compute a tag to be included in a log.
|
|
28
|
-
*/
|
|
29
|
-
static compute(localAddress: CompleteAddress, localIvsk: Fq, externalAddress: AztecAddress, app: AztecAddress, recipient: AztecAddress): Promise<DirectionalAppTaggingSecret>;
|
|
30
|
-
toString(): string;
|
|
31
|
-
static fromString(str: string): DirectionalAppTaggingSecret;
|
|
32
|
-
}
|
|
33
|
-
export declare const DirectionalAppTaggingSecretSchema: z.ZodObject<{
|
|
34
|
-
value: z.ZodType<Fr, any, string>;
|
|
35
|
-
}, "strip", z.ZodTypeAny, {
|
|
36
|
-
value: Fr;
|
|
37
|
-
}, {
|
|
38
|
-
value: string;
|
|
39
|
-
}>;
|
|
40
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGlyZWN0aW9uYWxfYXBwX3RhZ2dpbmdfc2VjcmV0LmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvbG9ncy9kaXJlY3Rpb25hbF9hcHBfdGFnZ2luZ19zZWNyZXQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBRUEsT0FBTyxFQUFFLEtBQUssRUFBRSxFQUFFLEVBQUUsRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBRzdELE9BQU8sRUFBRSxDQUFDLEVBQUUsTUFBTSxLQUFLLENBQUM7QUFFeEIsT0FBTyxLQUFLLEVBQUUsWUFBWSxFQUFFLE1BQU0sMkJBQTJCLENBQUM7QUFDOUQsT0FBTyxLQUFLLEVBQUUsZUFBZSxFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFHdkU7Ozs7Ozs7OztHQVNHO0FBQ0gscUJBQWEsMkJBQTJCO2FBQ0YsS0FBSyxFQUFFLEVBQUU7SUFBN0MsT0FBTyxlQUEwQztJQUVqRDs7Ozs7Ozs7OztPQVVHO0lBQ0gsT0FBYSxPQUFPLENBQ2xCLFlBQVksRUFBRSxlQUFlLEVBQzdCLFNBQVMsRUFBRSxFQUFFLEVBQ2IsZUFBZSxFQUFFLFlBQVksRUFDN0IsR0FBRyxFQUFFLFlBQVksRUFDakIsU0FBUyxFQUFFLFlBQVksR0FDdEIsT0FBTyxDQUFDLDJCQUEyQixDQUFDLENBTXRDO0lBRUQsUUFBUSxJQUFJLE1BQU0sQ0FFakI7SUFFRCxNQUFNLENBQUMsVUFBVSxDQUFDLEdBQUcsRUFBRSxNQUFNLEdBQUcsMkJBQTJCLENBRTFEO0NBQ0Y7QUFvQkQsZUFBTyxNQUFNLGlDQUFpQzs7Ozs7O0VBRTVDLENBQUMifQ==
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"directional_app_tagging_secret.d.ts","sourceRoot":"","sources":["../../src/logs/directional_app_tagging_secret.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AAG7D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAGvE;;;;;;;;;GASG;AACH,qBAAa,2BAA2B;aACF,KAAK,EAAE,EAAE;IAA7C,OAAO,eAA0C;IAEjD;;;;;;;;;;OAUG;IACH,OAAa,OAAO,CAClB,YAAY,EAAE,eAAe,EAC7B,SAAS,EAAE,EAAE,EACb,eAAe,EAAE,YAAY,EAC7B,GAAG,EAAE,YAAY,EACjB,SAAS,EAAE,YAAY,GACtB,OAAO,CAAC,2BAA2B,CAAC,CAMtC;IAED,QAAQ,IAAI,MAAM,CAEjB;IAED,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,2BAA2B,CAE1D;CACF;AAoBD,eAAO,MAAM,iCAAiC;;;;;;EAE5C,CAAC"}
|