@aztec/stdlib 0.0.1-commit.808bf7f90 → 0.0.1-commit.8227e42
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/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/package.json +8 -8
- 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
|
@@ -6,11 +6,11 @@ import type { ScopedNoteHash } from '../note_hash.js';
|
|
|
6
6
|
import type { ScopedReadRequest } from './read_request.js';
|
|
7
7
|
import { ReadRequestResetActions } from './read_request_hints.js';
|
|
8
8
|
export declare function isValidNoteHashReadRequest(readRequest: ScopedReadRequest, noteHash: ScopedNoteHash): boolean;
|
|
9
|
-
export declare function getNoteHashReadRequestResetActions(noteHashReadRequests: ClaimedLengthArray<ScopedReadRequest, typeof MAX_NOTE_HASH_READ_REQUESTS_PER_TX>, noteHashes: ClaimedLengthArray<ScopedNoteHash, typeof MAX_NOTE_HASHES_PER_TX
|
|
9
|
+
export declare function getNoteHashReadRequestResetActions(noteHashReadRequests: ClaimedLengthArray<ScopedReadRequest, typeof MAX_NOTE_HASH_READ_REQUESTS_PER_TX>, noteHashes: ClaimedLengthArray<ScopedNoteHash, typeof MAX_NOTE_HASHES_PER_TX>): ReadRequestResetActions<typeof MAX_NOTE_HASH_READ_REQUESTS_PER_TX>;
|
|
10
10
|
export declare function buildNoteHashReadRequestHintsFromResetActions<PENDING extends number, SETTLED extends number>(oracle: {
|
|
11
11
|
getNoteHashMembershipWitness(noteHash: Fr): Promise<MembershipWitness<typeof NOTE_HASH_TREE_HEIGHT> | undefined>;
|
|
12
12
|
}, noteHashReadRequests: ClaimedLengthArray<ScopedReadRequest, typeof MAX_NOTE_HASH_READ_REQUESTS_PER_TX>, noteHashes: ClaimedLengthArray<ScopedNoteHash, typeof MAX_NOTE_HASHES_PER_TX>, resetActions: ReadRequestResetActions<typeof MAX_NOTE_HASH_READ_REQUESTS_PER_TX>, maxPending?: PENDING, maxSettled?: SETTLED): Promise<import("./note_hash_read_request_hints.js").NoteHashReadRequestHints<PENDING, SETTLED>>;
|
|
13
13
|
export declare function buildNoteHashReadRequestHints<PENDING extends number, SETTLED extends number>(oracle: {
|
|
14
14
|
getNoteHashMembershipWitness(noteHash: Fr): Promise<MembershipWitness<typeof NOTE_HASH_TREE_HEIGHT>>;
|
|
15
|
-
}, noteHashReadRequests: ClaimedLengthArray<ScopedReadRequest, typeof MAX_NOTE_HASH_READ_REQUESTS_PER_TX>, noteHashes: ClaimedLengthArray<ScopedNoteHash, typeof MAX_NOTE_HASHES_PER_TX>,
|
|
16
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
15
|
+
}, noteHashReadRequests: ClaimedLengthArray<ScopedReadRequest, typeof MAX_NOTE_HASH_READ_REQUESTS_PER_TX>, noteHashes: ClaimedLengthArray<ScopedNoteHash, typeof MAX_NOTE_HASHES_PER_TX>, maxPending?: PENDING, maxSettled?: SETTLED): Promise<import("./note_hash_read_request_hints.js").NoteHashReadRequestHints<PENDING, SETTLED>>;
|
|
16
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYnVpbGRfbm90ZV9oYXNoX3JlYWRfcmVxdWVzdF9oaW50cy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdX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KAAK,qBAAqB,EAC3B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAEjE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AACrE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEtD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAA0C,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"build_note_hash_read_request_hints.d.ts","sourceRoot":"","sources":["../../../src/kernel/hints/build_note_hash_read_request_hints.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,sBAAsB,EAC3B,kCAAkC,EAClC,KAAK,qBAAqB,EAC3B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAEjE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AACrE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEtD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAA0C,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAE1G,wBAAgB,0BAA0B,CAAC,WAAW,EAAE,iBAAiB,EAAE,QAAQ,EAAE,cAAc,WAMlG;AAED,wBAAgB,kCAAkC,CAChD,oBAAoB,EAAE,kBAAkB,CAAC,iBAAiB,EAAE,OAAO,kCAAkC,CAAC,EACtG,UAAU,EAAE,kBAAkB,CAAC,cAAc,EAAE,OAAO,sBAAsB,CAAC,GAC5E,uBAAuB,CAAC,OAAO,kCAAkC,CAAC,CAgCpE;AAED,wBAAsB,6CAA6C,CAAC,OAAO,SAAS,MAAM,EAAE,OAAO,SAAS,MAAM,EAChH,MAAM,EAAE;IACN,4BAA4B,CAAC,QAAQ,EAAE,EAAE,GAAG,OAAO,CAAC,iBAAiB,CAAC,OAAO,qBAAqB,CAAC,GAAG,SAAS,CAAC,CAAC;CAClH,EACD,oBAAoB,EAAE,kBAAkB,CAAC,iBAAiB,EAAE,OAAO,kCAAkC,CAAC,EACtG,UAAU,EAAE,kBAAkB,CAAC,cAAc,EAAE,OAAO,sBAAsB,CAAC,EAC7E,YAAY,EAAE,uBAAuB,CAAC,OAAO,kCAAkC,CAAC,EAChF,UAAU,GAAE,OAAuD,EACnE,UAAU,GAAE,OAAuD,mGAuCpE;AAED,wBAAsB,6BAA6B,CAAC,OAAO,SAAS,MAAM,EAAE,OAAO,SAAS,MAAM,EAChG,MAAM,EAAE;IACN,4BAA4B,CAAC,QAAQ,EAAE,EAAE,GAAG,OAAO,CAAC,iBAAiB,CAAC,OAAO,qBAAqB,CAAC,CAAC,CAAC;CACtG,EACD,oBAAoB,EAAE,kBAAkB,CAAC,iBAAiB,EAAE,OAAO,kCAAkC,CAAC,EACtG,UAAU,EAAE,kBAAkB,CAAC,cAAc,EAAE,OAAO,sBAAsB,CAAC,EAC7E,UAAU,GAAE,OAAuD,EACnE,UAAU,GAAE,OAAuD,mGAWpE"}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { MAX_NOTE_HASH_READ_REQUESTS_PER_TX } from '@aztec/constants';
|
|
2
2
|
import { NoteHashReadRequestHintsBuilder } from './note_hash_read_request_hints.js';
|
|
3
3
|
import { PendingReadHint, ReadRequestActionEnum, ReadRequestResetActions } from './read_request_hints.js';
|
|
4
|
-
import { ScopedValueCache } from './scoped_value_cache.js';
|
|
5
4
|
export function isValidNoteHashReadRequest(readRequest, noteHash) {
|
|
6
5
|
return noteHash.value.equals(readRequest.value) && noteHash.contractAddress.equals(readRequest.contractAddress) && readRequest.counter > noteHash.counter;
|
|
7
6
|
}
|
|
8
|
-
export function getNoteHashReadRequestResetActions(noteHashReadRequests, noteHashes
|
|
7
|
+
export function getNoteHashReadRequestResetActions(noteHashReadRequests, noteHashes) {
|
|
9
8
|
const resetActions = ReadRequestResetActions.empty(MAX_NOTE_HASH_READ_REQUESTS_PER_TX);
|
|
10
9
|
const noteHashMap = new Map();
|
|
11
10
|
noteHashes.getActiveItems().forEach((noteHash, index)=>{
|
|
@@ -17,15 +16,19 @@ export function getNoteHashReadRequestResetActions(noteHashReadRequests, noteHas
|
|
|
17
16
|
});
|
|
18
17
|
noteHashMap.set(value, arr);
|
|
19
18
|
});
|
|
20
|
-
const futureNoteHashMap = new ScopedValueCache(futureNoteHashes);
|
|
21
19
|
for(let i = 0; i < noteHashReadRequests.claimedLength; ++i){
|
|
22
20
|
const readRequest = noteHashReadRequests.array[i];
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
resetActions.actions[i] = ReadRequestActionEnum.READ_AS_PENDING;
|
|
26
|
-
resetActions.pendingReadHints.push(new PendingReadHint(i, pendingNoteHash.index));
|
|
27
|
-
} else if (!futureNoteHashMap.get(readRequest).find((futureNoteHash)=>isValidNoteHashReadRequest(readRequest, futureNoteHash))) {
|
|
21
|
+
if (readRequest.contractAddress.isZero()) {
|
|
22
|
+
// Settled read: empty contract address means resolve against the note hash tree.
|
|
28
23
|
resetActions.actions[i] = ReadRequestActionEnum.READ_AS_SETTLED;
|
|
24
|
+
} else {
|
|
25
|
+
// Pending read: non-empty contract address means match against a pending note hash.
|
|
26
|
+
const pendingNoteHash = noteHashMap.get(readRequest.value.toBigInt())?.find((n)=>isValidNoteHashReadRequest(readRequest, n.noteHash));
|
|
27
|
+
if (pendingNoteHash) {
|
|
28
|
+
resetActions.actions[i] = ReadRequestActionEnum.READ_AS_PENDING;
|
|
29
|
+
resetActions.pendingReadHints.push(new PendingReadHint(i, pendingNoteHash.index));
|
|
30
|
+
}
|
|
31
|
+
// Otherwise, the read request may be resolved by a future note hash. Leave as NOOP.
|
|
29
32
|
}
|
|
30
33
|
}
|
|
31
34
|
return resetActions;
|
|
@@ -67,7 +70,7 @@ export async function buildNoteHashReadRequestHintsFromResetActions(oracle, note
|
|
|
67
70
|
});
|
|
68
71
|
return builder.toHints();
|
|
69
72
|
}
|
|
70
|
-
export async function buildNoteHashReadRequestHints(oracle, noteHashReadRequests, noteHashes,
|
|
71
|
-
const resetActions = getNoteHashReadRequestResetActions(noteHashReadRequests, noteHashes
|
|
73
|
+
export async function buildNoteHashReadRequestHints(oracle, noteHashReadRequests, noteHashes, maxPending = MAX_NOTE_HASH_READ_REQUESTS_PER_TX, maxSettled = MAX_NOTE_HASH_READ_REQUESTS_PER_TX) {
|
|
74
|
+
const resetActions = getNoteHashReadRequestResetActions(noteHashReadRequests, noteHashes);
|
|
72
75
|
return await buildNoteHashReadRequestHintsFromResetActions(oracle, noteHashReadRequests, noteHashes, resetActions, maxPending, maxSettled);
|
|
73
76
|
}
|
|
@@ -11,12 +11,12 @@ interface NullifierMembershipWitnessWithPreimage {
|
|
|
11
11
|
membershipWitness: MembershipWitness<typeof NULLIFIER_TREE_HEIGHT>;
|
|
12
12
|
leafPreimage: NullifierLeafPreimage;
|
|
13
13
|
}
|
|
14
|
-
export declare function getNullifierReadRequestResetActions(nullifierReadRequests: ClaimedLengthArray<ScopedReadRequest, typeof MAX_NULLIFIER_READ_REQUESTS_PER_TX>, nullifiers: ClaimedLengthArray<ScopedNullifier, typeof MAX_NULLIFIERS_PER_TX
|
|
14
|
+
export declare function getNullifierReadRequestResetActions(nullifierReadRequests: ClaimedLengthArray<ScopedReadRequest, typeof MAX_NULLIFIER_READ_REQUESTS_PER_TX>, nullifiers: ClaimedLengthArray<ScopedNullifier, typeof MAX_NULLIFIERS_PER_TX>): ReadRequestResetActions<typeof MAX_NULLIFIER_READ_REQUESTS_PER_TX>;
|
|
15
15
|
export declare function buildNullifierReadRequestHintsFromResetActions<PENDING extends number, SETTLED extends number>(oracle: {
|
|
16
16
|
getNullifierMembershipWitness(nullifier: Fr): Promise<NullifierMembershipWitnessWithPreimage>;
|
|
17
17
|
}, nullifierReadRequests: ClaimedLengthArray<ScopedReadRequest, typeof MAX_NULLIFIER_READ_REQUESTS_PER_TX>, resetActions: ReadRequestResetActions<typeof MAX_NULLIFIER_READ_REQUESTS_PER_TX>, maxPending?: PENDING, maxSettled?: SETTLED): Promise<import("./nullifier_read_request_hints.js").NullifierReadRequestHints<PENDING, SETTLED>>;
|
|
18
18
|
export declare function buildNullifierReadRequestHints<PENDING extends number, SETTLED extends number>(oracle: {
|
|
19
19
|
getNullifierMembershipWitness(nullifier: Fr): Promise<NullifierMembershipWitnessWithPreimage>;
|
|
20
|
-
}, nullifierReadRequests: ClaimedLengthArray<ScopedReadRequest, typeof MAX_NULLIFIER_READ_REQUESTS_PER_TX>, nullifiers: ClaimedLengthArray<ScopedNullifier, typeof MAX_NULLIFIERS_PER_TX>,
|
|
20
|
+
}, nullifierReadRequests: ClaimedLengthArray<ScopedReadRequest, typeof MAX_NULLIFIER_READ_REQUESTS_PER_TX>, nullifiers: ClaimedLengthArray<ScopedNullifier, typeof MAX_NULLIFIERS_PER_TX>, maxPending?: PENDING, maxSettled?: SETTLED): Promise<import("./nullifier_read_request_hints.js").NullifierReadRequestHints<PENDING, SETTLED>>;
|
|
21
21
|
export {};
|
|
22
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
22
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYnVpbGRfbnVsbGlmaWVyX3JlYWRfcmVxdWVzdF9oaW50cy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2tlcm5lbC9oaW50cy9idWlsZF9udWxsaWZpZXJfcmVhZF9yZXF1ZXN0X2hpbnRzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFDTCxLQUFLLHFCQUFxQixFQUMx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AAE,MAAM,yBAAyB,CAAC;AAE5D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAC3E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AACrE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAA0C,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"build_nullifier_read_request_hints.d.ts","sourceRoot":"","sources":["../../../src/kernel/hints/build_nullifier_read_request_hints.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,qBAAqB,EAC1B,kCAAkC,EAClC,KAAK,qBAAqB,EAC3B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAC3E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AACrE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAA0C,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAE1G,wBAAgB,2BAA2B,CAAC,WAAW,EAAE,iBAAiB,EAAE,SAAS,EAAE,eAAe,WAMrG;AAED,UAAU,sCAAsC;IAC9C,iBAAiB,EAAE,iBAAiB,CAAC,OAAO,qBAAqB,CAAC,CAAC;IACnE,YAAY,EAAE,qBAAqB,CAAC;CACrC;AAED,wBAAgB,mCAAmC,CACjD,qBAAqB,EAAE,kBAAkB,CAAC,iBAAiB,EAAE,OAAO,kCAAkC,CAAC,EACvG,UAAU,EAAE,kBAAkB,CAAC,eAAe,EAAE,OAAO,qBAAqB,CAAC,GAC5E,uBAAuB,CAAC,OAAO,kCAAkC,CAAC,CAgCpE;AAED,wBAAsB,8CAA8C,CAAC,OAAO,SAAS,MAAM,EAAE,OAAO,SAAS,MAAM,EACjH,MAAM,EAAE;IACN,6BAA6B,CAAC,SAAS,EAAE,EAAE,GAAG,OAAO,CAAC,sCAAsC,CAAC,CAAC;CAC/F,EACD,qBAAqB,EAAE,kBAAkB,CAAC,iBAAiB,EAAE,OAAO,kCAAkC,CAAC,EACvG,YAAY,EAAE,uBAAuB,CAAC,OAAO,kCAAkC,CAAC,EAChF,UAAU,GAAE,OAAuD,EACnE,UAAU,GAAE,OAAuD,oGA+BpE;AAED,wBAAsB,8BAA8B,CAAC,OAAO,SAAS,MAAM,EAAE,OAAO,SAAS,MAAM,EACjG,MAAM,EAAE;IACN,6BAA6B,CAAC,SAAS,EAAE,EAAE,GAAG,OAAO,CAAC,sCAAsC,CAAC,CAAC;CAC/F,EACD,qBAAqB,EAAE,kBAAkB,CAAC,iBAAiB,EAAE,OAAO,kCAAkC,CAAC,EACvG,UAAU,EAAE,kBAAkB,CAAC,eAAe,EAAE,OAAO,qBAAqB,CAAC,EAC7E,UAAU,GAAE,OAAuD,EACnE,UAAU,GAAE,OAAuD,oGAUpE"}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { MAX_NULLIFIER_READ_REQUESTS_PER_TX } from '@aztec/constants';
|
|
2
2
|
import { NullifierReadRequestHintsBuilder } from './nullifier_read_request_hints.js';
|
|
3
3
|
import { PendingReadHint, ReadRequestActionEnum, ReadRequestResetActions } from './read_request_hints.js';
|
|
4
|
-
import { ScopedValueCache } from './scoped_value_cache.js';
|
|
5
4
|
export function isValidNullifierReadRequest(readRequest, nullifier) {
|
|
6
5
|
return readRequest.value.equals(nullifier.value) && nullifier.contractAddress.equals(readRequest.contractAddress) && readRequest.counter > nullifier.counter;
|
|
7
6
|
}
|
|
8
|
-
export function getNullifierReadRequestResetActions(nullifierReadRequests, nullifiers
|
|
7
|
+
export function getNullifierReadRequestResetActions(nullifierReadRequests, nullifiers) {
|
|
9
8
|
const resetActions = ReadRequestResetActions.empty(MAX_NULLIFIER_READ_REQUESTS_PER_TX);
|
|
10
9
|
const nullifierMap = new Map();
|
|
11
10
|
nullifiers.getActiveItems().forEach((nullifier, index)=>{
|
|
@@ -17,15 +16,19 @@ export function getNullifierReadRequestResetActions(nullifierReadRequests, nulli
|
|
|
17
16
|
});
|
|
18
17
|
nullifierMap.set(value, arr);
|
|
19
18
|
});
|
|
20
|
-
const futureNullifiersMap = new ScopedValueCache(futureNullifiers);
|
|
21
19
|
for(let i = 0; i < nullifierReadRequests.claimedLength; ++i){
|
|
22
20
|
const readRequest = nullifierReadRequests.array[i];
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
resetActions.actions[i] = ReadRequestActionEnum.READ_AS_PENDING;
|
|
26
|
-
resetActions.pendingReadHints.push(new PendingReadHint(i, pendingNullifier.index));
|
|
27
|
-
} else if (!futureNullifiersMap.get(readRequest).some((futureNullifier)=>isValidNullifierReadRequest(readRequest, futureNullifier))) {
|
|
21
|
+
if (readRequest.contractAddress.isZero()) {
|
|
22
|
+
// Settled read: empty contract address means resolve against the nullifier tree.
|
|
28
23
|
resetActions.actions[i] = ReadRequestActionEnum.READ_AS_SETTLED;
|
|
24
|
+
} else {
|
|
25
|
+
// Pending read: non-empty contract address means match against a pending nullifier.
|
|
26
|
+
const pendingNullifier = nullifierMap.get(readRequest.value.toBigInt())?.find(({ nullifier })=>isValidNullifierReadRequest(readRequest, nullifier));
|
|
27
|
+
if (pendingNullifier) {
|
|
28
|
+
resetActions.actions[i] = ReadRequestActionEnum.READ_AS_PENDING;
|
|
29
|
+
resetActions.pendingReadHints.push(new PendingReadHint(i, pendingNullifier.index));
|
|
30
|
+
}
|
|
31
|
+
// Otherwise, the read request may be resolved by a future nullifier. Leave as NOOP.
|
|
29
32
|
}
|
|
30
33
|
}
|
|
31
34
|
return resetActions;
|
|
@@ -54,7 +57,7 @@ export async function buildNullifierReadRequestHintsFromResetActions(oracle, nul
|
|
|
54
57
|
}
|
|
55
58
|
return builder.toHints();
|
|
56
59
|
}
|
|
57
|
-
export async function buildNullifierReadRequestHints(oracle, nullifierReadRequests, nullifiers,
|
|
58
|
-
const resetActions = getNullifierReadRequestResetActions(nullifierReadRequests, nullifiers
|
|
60
|
+
export async function buildNullifierReadRequestHints(oracle, nullifierReadRequests, nullifiers, maxPending = MAX_NULLIFIER_READ_REQUESTS_PER_TX, maxSettled = MAX_NULLIFIER_READ_REQUESTS_PER_TX) {
|
|
61
|
+
const resetActions = getNullifierReadRequestResetActions(nullifierReadRequests, nullifiers);
|
|
59
62
|
return await buildNullifierReadRequestHintsFromResetActions(oracle, nullifierReadRequests, resetActions, maxPending, maxSettled);
|
|
60
63
|
}
|
|
@@ -2,10 +2,13 @@ import type { Tuple } from '@aztec/foundation/serialize';
|
|
|
2
2
|
import type { ClaimedLengthArray } from '../claimed_length_array.js';
|
|
3
3
|
import type { ScopedNoteHash } from '../note_hash.js';
|
|
4
4
|
import type { ScopedNullifier } from '../nullifier.js';
|
|
5
|
+
import type { PrivateLogData, ScopedPrivateLogData } from '../private_log_data.js';
|
|
5
6
|
import type { ScopedReadRequest } from './read_request.js';
|
|
6
7
|
import { TransientDataSquashingHint } from './transient_data_squashing_hint.js';
|
|
7
|
-
export declare function buildTransientDataHints<NOTE_HASHES_LEN extends number, NULLIFIERS_LEN extends number>(noteHashes: ClaimedLengthArray<ScopedNoteHash, NOTE_HASHES_LEN>, nullifiers: ClaimedLengthArray<ScopedNullifier, NULLIFIERS_LEN>, futureNoteHashReads: ScopedReadRequest[], futureNullifierReads: ScopedReadRequest[], noteHashNullifierCounterMap: Map<number, number>, splitCounter: number): {
|
|
8
|
+
export declare function buildTransientDataHints<NOTE_HASHES_LEN extends number, NULLIFIERS_LEN extends number>(noteHashes: ClaimedLengthArray<ScopedNoteHash, NOTE_HASHES_LEN>, nullifiers: ClaimedLengthArray<ScopedNullifier, NULLIFIERS_LEN>, futureNoteHashReads: ScopedReadRequest[], futureNullifierReads: ScopedReadRequest[], futureLogs: PrivateLogData[], noteHashNullifierCounterMap: Map<number, number>, splitCounter: number): {
|
|
8
9
|
numTransientData: number;
|
|
9
10
|
hints: Tuple<TransientDataSquashingHint, NULLIFIERS_LEN>;
|
|
10
11
|
};
|
|
11
|
-
|
|
12
|
+
/** Counts private logs that are linked to squashed note hashes and would be removed along with them. */
|
|
13
|
+
export declare function countSquashedLogs<NOTE_HASHES_LEN extends number, LOGS_LEN extends number>(noteHashes: ClaimedLengthArray<ScopedNoteHash, NOTE_HASHES_LEN>, privateLogs: ClaimedLengthArray<ScopedPrivateLogData, LOGS_LEN>, squashingHints: TransientDataSquashingHint[]): number;
|
|
14
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYnVpbGRfdHJhbnNpZW50X2RhdGFfaGludHMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9rZXJuZWwvaGludHMvYnVpbGRfdHJhbnNpZW50X2RhdGFfaGludHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0EsT0FBTyxLQUFLLEVBQUUsS0FBSyxFQUFFLE1BQU0sNkJBQTZCLENBQUM7QUFFekQsT0FBTyxLQUFLLEVBQUUsa0JBQWtCLEVBQUUsTUFBTSw0QkFBNEIsQ0FBQztBQUNyRSxPQUFPLEtBQUssRUFBRSxjQUFjLEVBQUUsTUFBTSxpQkFBaUIsQ0FBQztBQUN0RCxPQUFPLEtBQUssRUFBRSxlQUFlLEVBQUUsTUFBTSxpQkFBaUIsQ0FBQztBQUN2RCxPQUFPLEtBQUssRUFBRSxjQUFjLEVBQUUsb0JBQW9CLEVBQUUsTUFBTSx3QkFBd0IsQ0FBQztBQUduRixPQUFPLEtBQUssRUFBRSxpQkFBaUIsRUFBRSxNQUF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G;AACxG,wBAAgB,iBAAiB,CAAC,eAAe,SAAS,MAAM,EAAE,QAAQ,SAAS,MAAM,EACvF,UAAU,EAAE,kBAAkB,CAAC,cAAc,EAAE,eAAe,CAAC,EAC/D,WAAW,EAAE,kBAAkB,CAAC,oBAAoB,EAAE,QAAQ,CAAC,EAC/D,cAAc,EAAE,0BAA0B,EAAE,GAC3C,MAAM,CAGR"}
|
|
@@ -3,17 +3,19 @@ import { isValidNoteHashReadRequest } from './build_note_hash_read_request_hints
|
|
|
3
3
|
import { isValidNullifierReadRequest } from './build_nullifier_read_request_hints.js';
|
|
4
4
|
import { ScopedValueCache } from './scoped_value_cache.js';
|
|
5
5
|
import { TransientDataSquashingHint } from './transient_data_squashing_hint.js';
|
|
6
|
-
export function buildTransientDataHints(noteHashes, nullifiers, futureNoteHashReads, futureNullifierReads, noteHashNullifierCounterMap, splitCounter) {
|
|
6
|
+
export function buildTransientDataHints(noteHashes, nullifiers, futureNoteHashReads, futureNullifierReads, futureLogs, noteHashNullifierCounterMap, splitCounter) {
|
|
7
7
|
const futureNoteHashReadsMap = new ScopedValueCache(futureNoteHashReads);
|
|
8
8
|
const futureNullifierReadsMap = new ScopedValueCache(futureNullifierReads);
|
|
9
|
+
const futureLogNoteHashCounters = new Set(futureLogs.filter((l)=>l.noteHashCounter > 0).map((l)=>l.noteHashCounter));
|
|
9
10
|
const nullifierIndexMap = new Map();
|
|
10
11
|
nullifiers.getActiveItems().forEach((n, i)=>nullifierIndexMap.set(n.counter, i));
|
|
11
12
|
const hints = [];
|
|
12
13
|
for(let noteHashIndex = 0; noteHashIndex < noteHashes.claimedLength; noteHashIndex++){
|
|
13
14
|
const noteHash = noteHashes.array[noteHashIndex];
|
|
14
15
|
const noteHashNullifierCounter = noteHashNullifierCounterMap.get(noteHash.counter);
|
|
15
|
-
// The note hash might not be linked to a nullifier or it might be read in the future
|
|
16
|
-
|
|
16
|
+
// The note hash might not be linked to a nullifier, or it might be read in the future, or a future log might be
|
|
17
|
+
// linked to it.
|
|
18
|
+
if (!noteHashNullifierCounter || futureNoteHashReadsMap.get(noteHash).find((read)=>isValidNoteHashReadRequest(read, noteHash)) || futureLogNoteHashCounters.has(noteHash.counter)) {
|
|
17
19
|
continue;
|
|
18
20
|
}
|
|
19
21
|
const nullifierIndex = nullifierIndexMap.get(noteHashNullifierCounter);
|
|
@@ -48,3 +50,7 @@ export function buildTransientDataHints(noteHashes, nullifiers, futureNoteHashRe
|
|
|
48
50
|
hints: padArrayEnd(hints, noActionHint, nullifiers.array.length)
|
|
49
51
|
};
|
|
50
52
|
}
|
|
53
|
+
/** Counts private logs that are linked to squashed note hashes and would be removed along with them. */ export function countSquashedLogs(noteHashes, privateLogs, squashingHints) {
|
|
54
|
+
const squashedNoteHashCounters = new Set(squashingHints.map((h)=>noteHashes.array[h.noteHashIndex].counter));
|
|
55
|
+
return privateLogs.getActiveItems().filter((l)=>squashedNoteHashCounters.has(l.inner.noteHashCounter)).length;
|
|
56
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/stdlib",
|
|
3
|
-
"version": "0.0.1-commit.
|
|
3
|
+
"version": "0.0.1-commit.8227e42",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"inherits": [
|
|
6
6
|
"../package.common.json",
|
|
@@ -91,13 +91,13 @@
|
|
|
91
91
|
},
|
|
92
92
|
"dependencies": {
|
|
93
93
|
"@aws-sdk/client-s3": "^3.892.0",
|
|
94
|
-
"@aztec/bb.js": "0.0.1-commit.
|
|
95
|
-
"@aztec/blob-lib": "0.0.1-commit.
|
|
96
|
-
"@aztec/constants": "0.0.1-commit.
|
|
97
|
-
"@aztec/ethereum": "0.0.1-commit.
|
|
98
|
-
"@aztec/foundation": "0.0.1-commit.
|
|
99
|
-
"@aztec/l1-artifacts": "0.0.1-commit.
|
|
100
|
-
"@aztec/noir-noirc_abi": "0.0.1-commit.
|
|
94
|
+
"@aztec/bb.js": "0.0.1-commit.8227e42",
|
|
95
|
+
"@aztec/blob-lib": "0.0.1-commit.8227e42",
|
|
96
|
+
"@aztec/constants": "0.0.1-commit.8227e42",
|
|
97
|
+
"@aztec/ethereum": "0.0.1-commit.8227e42",
|
|
98
|
+
"@aztec/foundation": "0.0.1-commit.8227e42",
|
|
99
|
+
"@aztec/l1-artifacts": "0.0.1-commit.8227e42",
|
|
100
|
+
"@aztec/noir-noirc_abi": "0.0.1-commit.8227e42",
|
|
101
101
|
"@google-cloud/storage": "^7.15.0",
|
|
102
102
|
"axios": "^1.12.0",
|
|
103
103
|
"json-stringify-deterministic": "1.0.12",
|
|
@@ -11,7 +11,6 @@ import type { ScopedNoteHash } from '../note_hash.js';
|
|
|
11
11
|
import { NoteHashReadRequestHintsBuilder } from './note_hash_read_request_hints.js';
|
|
12
12
|
import type { ScopedReadRequest } from './read_request.js';
|
|
13
13
|
import { PendingReadHint, ReadRequestActionEnum, ReadRequestResetActions } from './read_request_hints.js';
|
|
14
|
-
import { ScopedValueCache } from './scoped_value_cache.js';
|
|
15
14
|
|
|
16
15
|
export function isValidNoteHashReadRequest(readRequest: ScopedReadRequest, noteHash: ScopedNoteHash) {
|
|
17
16
|
return (
|
|
@@ -24,7 +23,6 @@ export function isValidNoteHashReadRequest(readRequest: ScopedReadRequest, noteH
|
|
|
24
23
|
export function getNoteHashReadRequestResetActions(
|
|
25
24
|
noteHashReadRequests: ClaimedLengthArray<ScopedReadRequest, typeof MAX_NOTE_HASH_READ_REQUESTS_PER_TX>,
|
|
26
25
|
noteHashes: ClaimedLengthArray<ScopedNoteHash, typeof MAX_NOTE_HASHES_PER_TX>,
|
|
27
|
-
futureNoteHashes: ScopedNoteHash[],
|
|
28
26
|
): ReadRequestResetActions<typeof MAX_NOTE_HASH_READ_REQUESTS_PER_TX> {
|
|
29
27
|
const resetActions = ReadRequestResetActions.empty(MAX_NOTE_HASH_READ_REQUESTS_PER_TX);
|
|
30
28
|
|
|
@@ -36,24 +34,23 @@ export function getNoteHashReadRequestResetActions(
|
|
|
36
34
|
noteHashMap.set(value, arr);
|
|
37
35
|
});
|
|
38
36
|
|
|
39
|
-
const futureNoteHashMap = new ScopedValueCache(futureNoteHashes);
|
|
40
|
-
|
|
41
37
|
for (let i = 0; i < noteHashReadRequests.claimedLength; ++i) {
|
|
42
38
|
const readRequest = noteHashReadRequests.array[i];
|
|
43
39
|
|
|
44
|
-
|
|
45
|
-
.
|
|
46
|
-
?.find(n => isValidNoteHashReadRequest(readRequest, n.noteHash));
|
|
47
|
-
|
|
48
|
-
if (pendingNoteHash !== undefined) {
|
|
49
|
-
resetActions.actions[i] = ReadRequestActionEnum.READ_AS_PENDING;
|
|
50
|
-
resetActions.pendingReadHints.push(new PendingReadHint(i, pendingNoteHash.index));
|
|
51
|
-
} else if (
|
|
52
|
-
!futureNoteHashMap
|
|
53
|
-
.get(readRequest)
|
|
54
|
-
.find(futureNoteHash => isValidNoteHashReadRequest(readRequest, futureNoteHash))
|
|
55
|
-
) {
|
|
40
|
+
if (readRequest.contractAddress.isZero()) {
|
|
41
|
+
// Settled read: empty contract address means resolve against the note hash tree.
|
|
56
42
|
resetActions.actions[i] = ReadRequestActionEnum.READ_AS_SETTLED;
|
|
43
|
+
} else {
|
|
44
|
+
// Pending read: non-empty contract address means match against a pending note hash.
|
|
45
|
+
const pendingNoteHash = noteHashMap
|
|
46
|
+
.get(readRequest.value.toBigInt())
|
|
47
|
+
?.find(n => isValidNoteHashReadRequest(readRequest, n.noteHash));
|
|
48
|
+
|
|
49
|
+
if (pendingNoteHash) {
|
|
50
|
+
resetActions.actions[i] = ReadRequestActionEnum.READ_AS_PENDING;
|
|
51
|
+
resetActions.pendingReadHints.push(new PendingReadHint(i, pendingNoteHash.index));
|
|
52
|
+
}
|
|
53
|
+
// Otherwise, the read request may be resolved by a future note hash. Leave as NOOP.
|
|
57
54
|
}
|
|
58
55
|
}
|
|
59
56
|
|
|
@@ -115,11 +112,10 @@ export async function buildNoteHashReadRequestHints<PENDING extends number, SETT
|
|
|
115
112
|
},
|
|
116
113
|
noteHashReadRequests: ClaimedLengthArray<ScopedReadRequest, typeof MAX_NOTE_HASH_READ_REQUESTS_PER_TX>,
|
|
117
114
|
noteHashes: ClaimedLengthArray<ScopedNoteHash, typeof MAX_NOTE_HASHES_PER_TX>,
|
|
118
|
-
futureNoteHashes: ScopedNoteHash[],
|
|
119
115
|
maxPending: PENDING = MAX_NOTE_HASH_READ_REQUESTS_PER_TX as PENDING,
|
|
120
116
|
maxSettled: SETTLED = MAX_NOTE_HASH_READ_REQUESTS_PER_TX as SETTLED,
|
|
121
117
|
) {
|
|
122
|
-
const resetActions = getNoteHashReadRequestResetActions(noteHashReadRequests, noteHashes
|
|
118
|
+
const resetActions = getNoteHashReadRequestResetActions(noteHashReadRequests, noteHashes);
|
|
123
119
|
return await buildNoteHashReadRequestHintsFromResetActions(
|
|
124
120
|
oracle,
|
|
125
121
|
noteHashReadRequests,
|
|
@@ -12,7 +12,6 @@ import type { ScopedNullifier } from '../nullifier.js';
|
|
|
12
12
|
import { NullifierReadRequestHintsBuilder } from './nullifier_read_request_hints.js';
|
|
13
13
|
import { ScopedReadRequest } from './read_request.js';
|
|
14
14
|
import { PendingReadHint, ReadRequestActionEnum, ReadRequestResetActions } from './read_request_hints.js';
|
|
15
|
-
import { ScopedValueCache } from './scoped_value_cache.js';
|
|
16
15
|
|
|
17
16
|
export function isValidNullifierReadRequest(readRequest: ScopedReadRequest, nullifier: ScopedNullifier) {
|
|
18
17
|
return (
|
|
@@ -30,7 +29,6 @@ interface NullifierMembershipWitnessWithPreimage {
|
|
|
30
29
|
export function getNullifierReadRequestResetActions(
|
|
31
30
|
nullifierReadRequests: ClaimedLengthArray<ScopedReadRequest, typeof MAX_NULLIFIER_READ_REQUESTS_PER_TX>,
|
|
32
31
|
nullifiers: ClaimedLengthArray<ScopedNullifier, typeof MAX_NULLIFIERS_PER_TX>,
|
|
33
|
-
futureNullifiers: ScopedNullifier[],
|
|
34
32
|
): ReadRequestResetActions<typeof MAX_NULLIFIER_READ_REQUESTS_PER_TX> {
|
|
35
33
|
const resetActions = ReadRequestResetActions.empty(MAX_NULLIFIER_READ_REQUESTS_PER_TX);
|
|
36
34
|
|
|
@@ -42,23 +40,23 @@ export function getNullifierReadRequestResetActions(
|
|
|
42
40
|
nullifierMap.set(value, arr);
|
|
43
41
|
});
|
|
44
42
|
|
|
45
|
-
const futureNullifiersMap = new ScopedValueCache(futureNullifiers);
|
|
46
|
-
|
|
47
43
|
for (let i = 0; i < nullifierReadRequests.claimedLength; ++i) {
|
|
48
44
|
const readRequest = nullifierReadRequests.array[i];
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
if (pendingNullifier !== undefined) {
|
|
54
|
-
resetActions.actions[i] = ReadRequestActionEnum.READ_AS_PENDING;
|
|
55
|
-
resetActions.pendingReadHints.push(new PendingReadHint(i, pendingNullifier.index));
|
|
56
|
-
} else if (
|
|
57
|
-
!futureNullifiersMap
|
|
58
|
-
.get(readRequest)
|
|
59
|
-
.some(futureNullifier => isValidNullifierReadRequest(readRequest, futureNullifier))
|
|
60
|
-
) {
|
|
45
|
+
|
|
46
|
+
if (readRequest.contractAddress.isZero()) {
|
|
47
|
+
// Settled read: empty contract address means resolve against the nullifier tree.
|
|
61
48
|
resetActions.actions[i] = ReadRequestActionEnum.READ_AS_SETTLED;
|
|
49
|
+
} else {
|
|
50
|
+
// Pending read: non-empty contract address means match against a pending nullifier.
|
|
51
|
+
const pendingNullifier = nullifierMap
|
|
52
|
+
.get(readRequest.value.toBigInt())
|
|
53
|
+
?.find(({ nullifier }) => isValidNullifierReadRequest(readRequest, nullifier));
|
|
54
|
+
|
|
55
|
+
if (pendingNullifier) {
|
|
56
|
+
resetActions.actions[i] = ReadRequestActionEnum.READ_AS_PENDING;
|
|
57
|
+
resetActions.pendingReadHints.push(new PendingReadHint(i, pendingNullifier.index));
|
|
58
|
+
}
|
|
59
|
+
// Otherwise, the read request may be resolved by a future nullifier. Leave as NOOP.
|
|
62
60
|
}
|
|
63
61
|
}
|
|
64
62
|
|
|
@@ -111,11 +109,10 @@ export async function buildNullifierReadRequestHints<PENDING extends number, SET
|
|
|
111
109
|
},
|
|
112
110
|
nullifierReadRequests: ClaimedLengthArray<ScopedReadRequest, typeof MAX_NULLIFIER_READ_REQUESTS_PER_TX>,
|
|
113
111
|
nullifiers: ClaimedLengthArray<ScopedNullifier, typeof MAX_NULLIFIERS_PER_TX>,
|
|
114
|
-
futureNullifiers: ScopedNullifier[],
|
|
115
112
|
maxPending: PENDING = MAX_NULLIFIER_READ_REQUESTS_PER_TX as PENDING,
|
|
116
113
|
maxSettled: SETTLED = MAX_NULLIFIER_READ_REQUESTS_PER_TX as SETTLED,
|
|
117
114
|
) {
|
|
118
|
-
const resetActions = getNullifierReadRequestResetActions(nullifierReadRequests, nullifiers
|
|
115
|
+
const resetActions = getNullifierReadRequestResetActions(nullifierReadRequests, nullifiers);
|
|
119
116
|
return await buildNullifierReadRequestHintsFromResetActions(
|
|
120
117
|
oracle,
|
|
121
118
|
nullifierReadRequests,
|
|
@@ -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
|
+
}
|