@aztec/stdlib 1.0.0-nightly.20250708 → 1.0.0-staging.1
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.map +1 -1
- package/dest/abi/decoder.js +6 -3
- package/dest/abi/index.d.ts +0 -1
- package/dest/abi/index.d.ts.map +1 -1
- package/dest/abi/index.js +0 -1
- package/dest/block/l2_block.d.ts +0 -7
- package/dest/block/l2_block.d.ts.map +1 -1
- package/dest/block/l2_block.js +0 -8
- package/dest/block/l2_block_stream/l2_block_stream.js +1 -1
- package/dest/gas/gas.d.ts +0 -1
- package/dest/gas/gas.d.ts.map +1 -1
- package/dest/gas/gas.js +0 -3
- package/dest/interfaces/aztec-node-admin.d.ts.map +1 -1
- package/dest/interfaces/aztec-node-admin.js +1 -3
- package/dest/interfaces/client.d.ts +0 -1
- package/dest/interfaces/client.d.ts.map +1 -1
- package/dest/interfaces/client.js +0 -1
- package/dest/interfaces/configs.d.ts +0 -10
- package/dest/interfaces/configs.d.ts.map +1 -1
- package/dest/interfaces/configs.js +1 -3
- package/dest/interfaces/proving-job.d.ts +18 -18
- package/dest/interfaces/pxe.d.ts +0 -2
- package/dest/interfaces/pxe.d.ts.map +1 -1
- package/dest/interfaces/server.d.ts +1 -3
- package/dest/interfaces/server.d.ts.map +1 -1
- package/dest/interfaces/server.js +1 -3
- package/dest/interfaces/tx-collector.d.ts +15 -0
- package/dest/interfaces/tx-collector.d.ts.map +1 -0
- package/dest/kernel/hints/build_note_hash_read_request_hints.d.ts +6 -6
- 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 +20 -18
- package/dest/kernel/hints/build_nullifier_read_request_hints.d.ts +10 -7
- package/dest/kernel/hints/build_nullifier_read_request_hints.d.ts.map +1 -1
- package/dest/kernel/hints/build_nullifier_read_request_hints.js +32 -17
- package/dest/kernel/hints/build_transient_data_hints.d.ts +1 -2
- package/dest/kernel/hints/build_transient_data_hints.d.ts.map +1 -1
- package/dest/kernel/hints/build_transient_data_hints.js +8 -7
- package/dest/kernel/hints/index.d.ts +1 -0
- package/dest/kernel/hints/index.d.ts.map +1 -1
- package/dest/kernel/hints/index.js +1 -0
- package/dest/kernel/hints/note_hash_read_request_hints.d.ts.map +1 -1
- package/dest/kernel/hints/note_hash_read_request_hints.js +4 -4
- package/dest/kernel/hints/nullifier_read_request_hints.d.ts.map +1 -1
- package/dest/kernel/hints/nullifier_read_request_hints.js +4 -4
- package/dest/kernel/hints/read_request_hints.d.ts +17 -17
- package/dest/kernel/hints/read_request_hints.d.ts.map +1 -1
- package/dest/kernel/hints/read_request_hints.js +28 -28
- package/dest/kernel/hints/rollup_validation_requests.d.ts +34 -0
- package/dest/kernel/hints/rollup_validation_requests.d.ts.map +1 -0
- package/dest/kernel/hints/rollup_validation_requests.js +55 -0
- package/dest/kernel/index.d.ts +0 -1
- package/dest/kernel/index.d.ts.map +1 -1
- package/dest/kernel/index.js +0 -1
- package/dest/kernel/private_accumulated_data.d.ts +15 -16
- package/dest/kernel/private_accumulated_data.d.ts.map +1 -1
- package/dest/kernel/private_accumulated_data.js +3 -3
- package/dest/kernel/private_circuit_public_inputs.d.ts +25 -26
- package/dest/kernel/private_circuit_public_inputs.d.ts.map +1 -1
- package/dest/kernel/private_circuit_public_inputs.js +15 -33
- package/dest/kernel/private_kernel_circuit_public_inputs.d.ts +0 -9
- package/dest/kernel/private_kernel_circuit_public_inputs.d.ts.map +1 -1
- package/dest/kernel/private_kernel_circuit_public_inputs.js +4 -8
- package/dest/kernel/private_kernel_tail_circuit_private_inputs.d.ts +1 -10
- package/dest/kernel/private_kernel_tail_circuit_private_inputs.d.ts.map +1 -1
- package/dest/kernel/private_kernel_tail_circuit_private_inputs.js +6 -9
- package/dest/kernel/private_kernel_tail_circuit_public_inputs.d.ts +4 -11
- package/dest/kernel/private_kernel_tail_circuit_public_inputs.d.ts.map +1 -1
- package/dest/kernel/private_kernel_tail_circuit_public_inputs.js +18 -20
- package/dest/kernel/private_to_public_kernel_circuit_public_inputs.d.ts +4 -4
- package/dest/kernel/private_to_public_kernel_circuit_public_inputs.d.ts.map +1 -1
- package/dest/kernel/private_to_public_kernel_circuit_public_inputs.js +10 -9
- package/dest/kernel/private_to_rollup_kernel_circuit_public_inputs.d.ts +11 -11
- package/dest/kernel/private_to_rollup_kernel_circuit_public_inputs.d.ts.map +1 -1
- package/dest/kernel/private_to_rollup_kernel_circuit_public_inputs.js +12 -11
- package/dest/kernel/private_validation_requests.d.ts +20 -8
- package/dest/kernel/private_validation_requests.d.ts.map +1 -1
- package/dest/kernel/private_validation_requests.js +21 -9
- package/dest/kernel/utils/order_and_comparison.d.ts +3 -0
- package/dest/kernel/utils/order_and_comparison.d.ts.map +1 -1
- package/dest/kernel/utils/order_and_comparison.js +19 -0
- package/dest/messaging/l2_to_l1_message.d.ts +0 -2
- package/dest/messaging/l2_to_l1_message.d.ts.map +1 -1
- package/dest/messaging/l2_to_l1_message.js +0 -7
- package/dest/p2p/block_proposal.d.ts +1 -8
- package/dest/p2p/block_proposal.d.ts.map +1 -1
- package/dest/p2p/block_proposal.js +8 -21
- package/dest/p2p/consensus_payload.d.ts +11 -3
- package/dest/p2p/consensus_payload.d.ts.map +1 -1
- package/dest/p2p/consensus_payload.js +22 -13
- package/dest/p2p/topic_type.d.ts.map +1 -1
- package/dest/p2p/topic_type.js +3 -5
- package/dest/tests/factories.d.ts +2 -0
- package/dest/tests/factories.d.ts.map +1 -1
- package/dest/tests/factories.js +22 -20
- package/dest/tests/mocks.d.ts.map +1 -1
- package/dest/tests/mocks.js +12 -14
- package/dest/tx/include_by_timestamp.d.ts +54 -0
- package/dest/tx/include_by_timestamp.d.ts.map +1 -0
- package/dest/tx/include_by_timestamp.js +72 -0
- package/dest/tx/index.d.ts +1 -0
- package/dest/tx/index.d.ts.map +1 -1
- package/dest/tx/index.js +1 -0
- package/dest/tx/private_execution_result.d.ts +2 -2
- package/dest/tx/private_execution_result.d.ts.map +1 -1
- package/dest/tx/private_execution_result.js +11 -11
- package/dest/tx/simulated_tx.js +1 -1
- package/dest/tx/tx.d.ts +2 -7
- package/dest/tx/tx.d.ts.map +1 -1
- package/dest/tx/tx.js +0 -8
- package/dest/versioning/versioning.d.ts.map +1 -1
- package/package.json +7 -7
- package/src/abi/decoder.ts +6 -3
- package/src/abi/index.ts +0 -1
- package/src/block/l2_block.ts +0 -16
- package/src/block/l2_block_stream/l2_block_stream.ts +1 -1
- package/src/gas/gas.ts +0 -4
- package/src/interfaces/aztec-node-admin.ts +1 -8
- package/src/interfaces/client.ts +0 -1
- package/src/interfaces/configs.ts +0 -6
- package/src/interfaces/pxe.ts +0 -2
- package/src/interfaces/server.ts +1 -3
- package/src/interfaces/tx-collector.ts +17 -0
- package/src/kernel/hints/build_note_hash_read_request_hints.ts +30 -28
- package/src/kernel/hints/build_nullifier_read_request_hints.ts +59 -28
- package/src/kernel/hints/build_transient_data_hints.ts +11 -9
- package/src/kernel/hints/index.ts +1 -0
- package/src/kernel/hints/note_hash_read_request_hints.ts +16 -4
- package/src/kernel/hints/nullifier_read_request_hints.ts +16 -4
- package/src/kernel/hints/read_request_hints.ts +22 -22
- package/src/kernel/hints/rollup_validation_requests.ts +71 -0
- package/src/kernel/index.ts +0 -1
- package/src/kernel/private_accumulated_data.ts +23 -23
- package/src/kernel/private_circuit_public_inputs.ts +68 -92
- package/src/kernel/private_kernel_circuit_public_inputs.ts +1 -9
- package/src/kernel/private_kernel_tail_circuit_private_inputs.ts +4 -13
- package/src/kernel/private_kernel_tail_circuit_public_inputs.ts +20 -20
- package/src/kernel/private_to_public_kernel_circuit_public_inputs.ts +7 -7
- package/src/kernel/private_to_rollup_kernel_circuit_public_inputs.ts +10 -16
- package/src/kernel/private_validation_requests.ts +50 -19
- package/src/kernel/utils/order_and_comparison.ts +25 -0
- package/src/messaging/l2_to_l1_message.ts +0 -9
- package/src/p2p/block_proposal.ts +5 -23
- package/src/p2p/consensus_payload.ts +29 -10
- package/src/p2p/topic_type.ts +1 -3
- package/src/tests/factories.ts +26 -33
- package/src/tests/mocks.ts +9 -7
- package/src/tx/include_by_timestamp.ts +90 -0
- package/src/tx/index.ts +1 -0
- package/src/tx/private_execution_result.ts +9 -11
- package/src/tx/simulated_tx.ts +2 -2
- package/src/tx/tx.ts +1 -14
- package/src/versioning/versioning.ts +3 -0
- package/dest/abi/authorization_selector.d.ts +0 -52
- package/dest/abi/authorization_selector.d.ts.map +0 -1
- package/dest/abi/authorization_selector.js +0 -70
- package/dest/interfaces/tx_provider.d.ts +0 -24
- package/dest/interfaces/tx_provider.d.ts.map +0 -1
- package/dest/kernel/claimed_length_array.d.ts +0 -34
- package/dest/kernel/claimed_length_array.d.ts.map +0 -1
- package/dest/kernel/claimed_length_array.js +0 -58
- package/src/abi/authorization_selector.ts +0 -95
- package/src/interfaces/tx_provider.ts +0 -16
- package/src/kernel/claimed_length_array.ts +0 -104
- /package/dest/interfaces/{tx_provider.js → tx-collector.js} +0 -0
|
@@ -3,13 +3,14 @@ import {
|
|
|
3
3
|
MAX_NOTE_HASH_READ_REQUESTS_PER_TX,
|
|
4
4
|
type NOTE_HASH_TREE_HEIGHT,
|
|
5
5
|
} from '@aztec/constants';
|
|
6
|
+
import type { Tuple } from '@aztec/foundation/serialize';
|
|
6
7
|
import type { MembershipWitness } from '@aztec/foundation/trees';
|
|
7
8
|
|
|
8
|
-
import type { ClaimedLengthArray } from '../claimed_length_array.js';
|
|
9
9
|
import type { ScopedNoteHash } from '../note_hash.js';
|
|
10
|
+
import { countAccumulatedItems, getNonEmptyItems } from '../utils/order_and_comparison.js';
|
|
10
11
|
import { NoteHashReadRequestHintsBuilder } from './note_hash_read_request_hints.js';
|
|
11
12
|
import type { ScopedReadRequest } from './read_request.js';
|
|
12
|
-
import { PendingReadHint,
|
|
13
|
+
import { PendingReadHint, ReadRequestResetStates, ReadRequestState } from './read_request_hints.js';
|
|
13
14
|
import { ScopedValueCache } from './scoped_value_cache.js';
|
|
14
15
|
|
|
15
16
|
export function isValidNoteHashReadRequest(readRequest: ScopedReadRequest, noteHash: ScopedNoteHash) {
|
|
@@ -20,15 +21,15 @@ export function isValidNoteHashReadRequest(readRequest: ScopedReadRequest, noteH
|
|
|
20
21
|
);
|
|
21
22
|
}
|
|
22
23
|
|
|
23
|
-
export function
|
|
24
|
-
noteHashReadRequests:
|
|
25
|
-
noteHashes:
|
|
24
|
+
export function getNoteHashReadRequestResetStates(
|
|
25
|
+
noteHashReadRequests: Tuple<ScopedReadRequest, typeof MAX_NOTE_HASH_READ_REQUESTS_PER_TX>,
|
|
26
|
+
noteHashes: Tuple<ScopedNoteHash, typeof MAX_NOTE_HASHES_PER_TX>,
|
|
26
27
|
futureNoteHashes: ScopedNoteHash[],
|
|
27
|
-
):
|
|
28
|
-
const
|
|
28
|
+
): ReadRequestResetStates<typeof MAX_NOTE_HASH_READ_REQUESTS_PER_TX> {
|
|
29
|
+
const resetStates = ReadRequestResetStates.empty(MAX_NOTE_HASH_READ_REQUESTS_PER_TX);
|
|
29
30
|
|
|
30
31
|
const noteHashMap: Map<bigint, { noteHash: ScopedNoteHash; index: number }[]> = new Map();
|
|
31
|
-
noteHashes
|
|
32
|
+
getNonEmptyItems(noteHashes).forEach((noteHash, index) => {
|
|
32
33
|
const value = noteHash.value.toBigInt();
|
|
33
34
|
const arr = noteHashMap.get(value) ?? [];
|
|
34
35
|
arr.push({ noteHash, index });
|
|
@@ -37,48 +38,49 @@ export function getNoteHashReadRequestResetActions(
|
|
|
37
38
|
|
|
38
39
|
const futureNoteHashMap = new ScopedValueCache(futureNoteHashes);
|
|
39
40
|
|
|
40
|
-
|
|
41
|
-
|
|
41
|
+
const numReadRequests = countAccumulatedItems(noteHashReadRequests);
|
|
42
|
+
for (let i = 0; i < numReadRequests; ++i) {
|
|
43
|
+
const readRequest = noteHashReadRequests[i];
|
|
42
44
|
|
|
43
45
|
const pendingNoteHash = noteHashMap
|
|
44
46
|
.get(readRequest.value.toBigInt())
|
|
45
47
|
?.find(n => isValidNoteHashReadRequest(readRequest, n.noteHash));
|
|
46
48
|
|
|
47
49
|
if (pendingNoteHash !== undefined) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
+
resetStates.states[i] = ReadRequestState.PENDING;
|
|
51
|
+
resetStates.pendingReadHints.push(new PendingReadHint(i, pendingNoteHash.index));
|
|
50
52
|
} else if (
|
|
51
53
|
!futureNoteHashMap
|
|
52
54
|
.get(readRequest)
|
|
53
55
|
.find(futureNoteHash => isValidNoteHashReadRequest(readRequest, futureNoteHash))
|
|
54
56
|
) {
|
|
55
|
-
|
|
57
|
+
resetStates.states[i] = ReadRequestState.SETTLED;
|
|
56
58
|
}
|
|
57
59
|
}
|
|
58
60
|
|
|
59
|
-
return
|
|
61
|
+
return resetStates;
|
|
60
62
|
}
|
|
61
63
|
|
|
62
|
-
export async function
|
|
64
|
+
export async function buildNoteHashReadRequestHintsFromResetStates<PENDING extends number, SETTLED extends number>(
|
|
63
65
|
oracle: {
|
|
64
66
|
getNoteHashMembershipWitness(leafIndex: bigint): Promise<MembershipWitness<typeof NOTE_HASH_TREE_HEIGHT>>;
|
|
65
67
|
},
|
|
66
|
-
noteHashReadRequests:
|
|
67
|
-
noteHashes:
|
|
68
|
-
|
|
68
|
+
noteHashReadRequests: Tuple<ScopedReadRequest, typeof MAX_NOTE_HASH_READ_REQUESTS_PER_TX>,
|
|
69
|
+
noteHashes: Tuple<ScopedNoteHash, typeof MAX_NOTE_HASHES_PER_TX>,
|
|
70
|
+
resetStates: ReadRequestResetStates<typeof MAX_NOTE_HASH_READ_REQUESTS_PER_TX>,
|
|
69
71
|
noteHashLeafIndexMap: Map<bigint, bigint>,
|
|
70
72
|
maxPending: PENDING = MAX_NOTE_HASH_READ_REQUESTS_PER_TX as PENDING,
|
|
71
73
|
maxSettled: SETTLED = MAX_NOTE_HASH_READ_REQUESTS_PER_TX as SETTLED,
|
|
72
74
|
) {
|
|
73
75
|
const builder = new NoteHashReadRequestHintsBuilder(maxPending, maxSettled);
|
|
74
76
|
|
|
75
|
-
|
|
77
|
+
resetStates.pendingReadHints.forEach(hint => {
|
|
76
78
|
builder.addPendingReadRequest(hint.readRequestIndex, hint.pendingValueIndex);
|
|
77
79
|
});
|
|
78
80
|
|
|
79
|
-
for (let i = 0; i <
|
|
80
|
-
if (
|
|
81
|
-
const readRequest = noteHashReadRequests
|
|
81
|
+
for (let i = 0; i < resetStates.states.length; i++) {
|
|
82
|
+
if (resetStates.states[i] === ReadRequestState.SETTLED) {
|
|
83
|
+
const readRequest = noteHashReadRequests[i];
|
|
82
84
|
const leafIndex = noteHashLeafIndexMap.get(readRequest.value.toBigInt());
|
|
83
85
|
if (leafIndex === undefined) {
|
|
84
86
|
throw new Error('Read request is reading an unknown note hash.');
|
|
@@ -89,7 +91,7 @@ export async function buildNoteHashReadRequestHintsFromResetActions<PENDING exte
|
|
|
89
91
|
}
|
|
90
92
|
|
|
91
93
|
const noteHashMap: Map<bigint, { noteHash: ScopedNoteHash; index: number }[]> = new Map();
|
|
92
|
-
noteHashes
|
|
94
|
+
getNonEmptyItems(noteHashes).forEach((noteHash, index) => {
|
|
93
95
|
const value = noteHash.value.toBigInt();
|
|
94
96
|
const arr = noteHashMap.get(value) ?? [];
|
|
95
97
|
arr.push({ noteHash, index });
|
|
@@ -103,19 +105,19 @@ export async function buildNoteHashReadRequestHints<PENDING extends number, SETT
|
|
|
103
105
|
oracle: {
|
|
104
106
|
getNoteHashMembershipWitness(leafIndex: bigint): Promise<MembershipWitness<typeof NOTE_HASH_TREE_HEIGHT>>;
|
|
105
107
|
},
|
|
106
|
-
noteHashReadRequests:
|
|
107
|
-
noteHashes:
|
|
108
|
+
noteHashReadRequests: Tuple<ScopedReadRequest, typeof MAX_NOTE_HASH_READ_REQUESTS_PER_TX>,
|
|
109
|
+
noteHashes: Tuple<ScopedNoteHash, typeof MAX_NOTE_HASHES_PER_TX>,
|
|
108
110
|
noteHashLeafIndexMap: Map<bigint, bigint>,
|
|
109
111
|
futureNoteHashes: ScopedNoteHash[],
|
|
110
112
|
maxPending: PENDING = MAX_NOTE_HASH_READ_REQUESTS_PER_TX as PENDING,
|
|
111
113
|
maxSettled: SETTLED = MAX_NOTE_HASH_READ_REQUESTS_PER_TX as SETTLED,
|
|
112
114
|
) {
|
|
113
|
-
const
|
|
114
|
-
return await
|
|
115
|
+
const resetStates = getNoteHashReadRequestResetStates(noteHashReadRequests, noteHashes, futureNoteHashes);
|
|
116
|
+
return await buildNoteHashReadRequestHintsFromResetStates(
|
|
115
117
|
oracle,
|
|
116
118
|
noteHashReadRequests,
|
|
117
119
|
noteHashes,
|
|
118
|
-
|
|
120
|
+
resetStates,
|
|
119
121
|
noteHashLeafIndexMap,
|
|
120
122
|
maxPending,
|
|
121
123
|
maxSettled,
|
|
@@ -3,15 +3,18 @@ import {
|
|
|
3
3
|
MAX_NULLIFIER_READ_REQUESTS_PER_TX,
|
|
4
4
|
type NULLIFIER_TREE_HEIGHT,
|
|
5
5
|
} from '@aztec/constants';
|
|
6
|
+
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
6
7
|
import type { Fr } from '@aztec/foundation/fields';
|
|
8
|
+
import type { Tuple } from '@aztec/foundation/serialize';
|
|
7
9
|
import { type IndexedTreeLeafPreimage, MembershipWitness } from '@aztec/foundation/trees';
|
|
8
10
|
|
|
11
|
+
import { AztecAddress } from '../../aztec-address/index.js';
|
|
9
12
|
import { siloNullifier } from '../../hash/hash.js';
|
|
10
|
-
import type
|
|
11
|
-
import
|
|
13
|
+
import { Nullifier, type ScopedNullifier } from '../nullifier.js';
|
|
14
|
+
import { countAccumulatedItems, getNonEmptyItems } from '../utils/order_and_comparison.js';
|
|
12
15
|
import { NullifierReadRequestHintsBuilder } from './nullifier_read_request_hints.js';
|
|
13
|
-
import { ScopedReadRequest } from './read_request.js';
|
|
14
|
-
import { PendingReadHint,
|
|
16
|
+
import { ReadRequest, ScopedReadRequest } from './read_request.js';
|
|
17
|
+
import { PendingReadHint, ReadRequestResetStates, ReadRequestState } from './read_request_hints.js';
|
|
15
18
|
import { ScopedValueCache } from './scoped_value_cache.js';
|
|
16
19
|
|
|
17
20
|
export function isValidNullifierReadRequest(readRequest: ScopedReadRequest, nullifier: ScopedNullifier) {
|
|
@@ -27,15 +30,15 @@ interface NullifierMembershipWitnessWithPreimage {
|
|
|
27
30
|
leafPreimage: IndexedTreeLeafPreimage;
|
|
28
31
|
}
|
|
29
32
|
|
|
30
|
-
export function
|
|
31
|
-
nullifierReadRequests:
|
|
32
|
-
nullifiers:
|
|
33
|
+
export function getNullifierReadRequestResetStates(
|
|
34
|
+
nullifierReadRequests: Tuple<ScopedReadRequest, typeof MAX_NULLIFIER_READ_REQUESTS_PER_TX>,
|
|
35
|
+
nullifiers: Tuple<ScopedNullifier, typeof MAX_NULLIFIERS_PER_TX>,
|
|
33
36
|
futureNullifiers: ScopedNullifier[],
|
|
34
|
-
):
|
|
35
|
-
const
|
|
37
|
+
): ReadRequestResetStates<typeof MAX_NULLIFIER_READ_REQUESTS_PER_TX> {
|
|
38
|
+
const resetStates = ReadRequestResetStates.empty(MAX_NULLIFIER_READ_REQUESTS_PER_TX);
|
|
36
39
|
|
|
37
40
|
const nullifierMap: Map<bigint, { nullifier: ScopedNullifier; index: number }[]> = new Map();
|
|
38
|
-
nullifiers
|
|
41
|
+
getNonEmptyItems(nullifiers).forEach((nullifier, index) => {
|
|
39
42
|
const value = nullifier.value.toBigInt();
|
|
40
43
|
const arr = nullifierMap.get(value) ?? [];
|
|
41
44
|
arr.push({ nullifier, index });
|
|
@@ -44,46 +47,48 @@ export function getNullifierReadRequestResetActions(
|
|
|
44
47
|
|
|
45
48
|
const futureNullifiersMap = new ScopedValueCache(futureNullifiers);
|
|
46
49
|
|
|
47
|
-
|
|
48
|
-
|
|
50
|
+
const numReadRequests = countAccumulatedItems(nullifierReadRequests);
|
|
51
|
+
|
|
52
|
+
for (let i = 0; i < numReadRequests; ++i) {
|
|
53
|
+
const readRequest = nullifierReadRequests[i];
|
|
49
54
|
const pendingNullifier = nullifierMap
|
|
50
55
|
.get(readRequest.value.toBigInt())
|
|
51
56
|
?.find(({ nullifier }) => isValidNullifierReadRequest(readRequest, nullifier));
|
|
52
57
|
|
|
53
58
|
if (pendingNullifier !== undefined) {
|
|
54
|
-
|
|
55
|
-
|
|
59
|
+
resetStates.states[i] = ReadRequestState.PENDING;
|
|
60
|
+
resetStates.pendingReadHints.push(new PendingReadHint(i, pendingNullifier.index));
|
|
56
61
|
} else if (
|
|
57
62
|
!futureNullifiersMap
|
|
58
63
|
.get(readRequest)
|
|
59
64
|
.some(futureNullifier => isValidNullifierReadRequest(readRequest, futureNullifier))
|
|
60
65
|
) {
|
|
61
|
-
|
|
66
|
+
resetStates.states[i] = ReadRequestState.SETTLED;
|
|
62
67
|
}
|
|
63
68
|
}
|
|
64
69
|
|
|
65
|
-
return
|
|
70
|
+
return resetStates;
|
|
66
71
|
}
|
|
67
72
|
|
|
68
|
-
export async function
|
|
73
|
+
export async function buildNullifierReadRequestHintsFromResetStates<PENDING extends number, SETTLED extends number>(
|
|
69
74
|
oracle: {
|
|
70
75
|
getNullifierMembershipWitness(nullifier: Fr): Promise<NullifierMembershipWitnessWithPreimage>;
|
|
71
76
|
},
|
|
72
|
-
nullifierReadRequests:
|
|
73
|
-
|
|
77
|
+
nullifierReadRequests: Tuple<ScopedReadRequest, typeof MAX_NULLIFIER_READ_REQUESTS_PER_TX>,
|
|
78
|
+
resetStates: ReadRequestResetStates<typeof MAX_NULLIFIER_READ_REQUESTS_PER_TX>,
|
|
74
79
|
maxPending: PENDING = MAX_NULLIFIER_READ_REQUESTS_PER_TX as PENDING,
|
|
75
80
|
maxSettled: SETTLED = MAX_NULLIFIER_READ_REQUESTS_PER_TX as SETTLED,
|
|
76
81
|
siloed = false,
|
|
77
82
|
) {
|
|
78
83
|
const builder = new NullifierReadRequestHintsBuilder(maxPending, maxSettled);
|
|
79
84
|
|
|
80
|
-
|
|
85
|
+
resetStates.pendingReadHints.forEach(hint => {
|
|
81
86
|
builder.addPendingReadRequest(hint.readRequestIndex, hint.pendingValueIndex);
|
|
82
87
|
});
|
|
83
88
|
|
|
84
|
-
for (let i = 0; i <
|
|
85
|
-
if (
|
|
86
|
-
const readRequest = nullifierReadRequests
|
|
89
|
+
for (let i = 0; i < resetStates.states.length; i++) {
|
|
90
|
+
if (resetStates.states[i] === ReadRequestState.SETTLED) {
|
|
91
|
+
const readRequest = nullifierReadRequests[i];
|
|
87
92
|
const siloedValue = siloed
|
|
88
93
|
? readRequest.value
|
|
89
94
|
: await siloNullifier(readRequest.contractAddress, readRequest.value);
|
|
@@ -103,20 +108,46 @@ export async function buildNullifierReadRequestHints<PENDING extends number, SET
|
|
|
103
108
|
oracle: {
|
|
104
109
|
getNullifierMembershipWitness(nullifier: Fr): Promise<NullifierMembershipWitnessWithPreimage>;
|
|
105
110
|
},
|
|
106
|
-
nullifierReadRequests:
|
|
107
|
-
nullifiers:
|
|
111
|
+
nullifierReadRequests: Tuple<ScopedReadRequest, typeof MAX_NULLIFIER_READ_REQUESTS_PER_TX>,
|
|
112
|
+
nullifiers: Tuple<ScopedNullifier, typeof MAX_NULLIFIERS_PER_TX>,
|
|
108
113
|
futureNullifiers: ScopedNullifier[],
|
|
109
114
|
maxPending: PENDING = MAX_NULLIFIER_READ_REQUESTS_PER_TX as PENDING,
|
|
110
115
|
maxSettled: SETTLED = MAX_NULLIFIER_READ_REQUESTS_PER_TX as SETTLED,
|
|
111
116
|
siloed = false,
|
|
112
117
|
) {
|
|
113
|
-
const
|
|
114
|
-
return await
|
|
118
|
+
const resetStates = getNullifierReadRequestResetStates(nullifierReadRequests, nullifiers, futureNullifiers);
|
|
119
|
+
return await buildNullifierReadRequestHintsFromResetStates(
|
|
115
120
|
oracle,
|
|
116
121
|
nullifierReadRequests,
|
|
117
|
-
|
|
122
|
+
resetStates,
|
|
118
123
|
maxPending,
|
|
119
124
|
maxSettled,
|
|
120
125
|
siloed,
|
|
121
126
|
);
|
|
122
127
|
}
|
|
128
|
+
|
|
129
|
+
export async function buildSiloedNullifierReadRequestHints<PENDING extends number, SETTLED extends number>(
|
|
130
|
+
oracle: {
|
|
131
|
+
getNullifierMembershipWitness(nullifier: Fr): Promise<NullifierMembershipWitnessWithPreimage>;
|
|
132
|
+
},
|
|
133
|
+
nullifierReadRequests: Tuple<ScopedReadRequest, typeof MAX_NULLIFIER_READ_REQUESTS_PER_TX>,
|
|
134
|
+
nullifiers: Tuple<Nullifier, typeof MAX_NULLIFIERS_PER_TX>,
|
|
135
|
+
maxPending: PENDING = MAX_NULLIFIER_READ_REQUESTS_PER_TX as PENDING,
|
|
136
|
+
maxSettled: SETTLED = MAX_NULLIFIER_READ_REQUESTS_PER_TX as SETTLED,
|
|
137
|
+
) {
|
|
138
|
+
// Nullifiers outputted from public kernels are already siloed while read requests are not.
|
|
139
|
+
// Siloing the read request values and set the contract addresses to zero to find the matching nullifier contexts.
|
|
140
|
+
const nonEmptyNullifierReadRequests = getNonEmptyItems(nullifierReadRequests);
|
|
141
|
+
const readRequests = await Promise.all(
|
|
142
|
+
nonEmptyNullifierReadRequests.map(async r =>
|
|
143
|
+
new ReadRequest(await siloNullifier(r.contractAddress, r.value), r.counter).scope(AztecAddress.ZERO),
|
|
144
|
+
),
|
|
145
|
+
);
|
|
146
|
+
const siloedReadRequests = padArrayEnd(readRequests, ScopedReadRequest.empty(), MAX_NULLIFIER_READ_REQUESTS_PER_TX);
|
|
147
|
+
|
|
148
|
+
const scopedNullifiers = nullifiers.map(n =>
|
|
149
|
+
new Nullifier(n.value, n.counter, n.noteHash).scope(AztecAddress.ZERO),
|
|
150
|
+
) as Tuple<ScopedNullifier, typeof MAX_NULLIFIERS_PER_TX>;
|
|
151
|
+
|
|
152
|
+
return buildNullifierReadRequestHints(oracle, siloedReadRequests, scopedNullifiers, [], maxPending, maxSettled, true);
|
|
153
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
2
2
|
import type { Tuple } from '@aztec/foundation/serialize';
|
|
3
3
|
|
|
4
|
-
import type { ClaimedLengthArray } from '../claimed_length_array.js';
|
|
5
4
|
import type { ScopedNoteHash } from '../note_hash.js';
|
|
6
5
|
import type { ScopedNullifier } from '../nullifier.js';
|
|
6
|
+
import { countAccumulatedItems } from '../utils/order_and_comparison.js';
|
|
7
7
|
import { isValidNoteHashReadRequest } from './build_note_hash_read_request_hints.js';
|
|
8
8
|
import { isValidNullifierReadRequest } from './build_nullifier_read_request_hints.js';
|
|
9
9
|
import type { ScopedReadRequest } from './read_request.js';
|
|
@@ -11,22 +11,25 @@ import { ScopedValueCache } from './scoped_value_cache.js';
|
|
|
11
11
|
import { TransientDataIndexHint } from './transient_data_index_hint.js';
|
|
12
12
|
|
|
13
13
|
export function buildTransientDataHints<NOTE_HASHES_LEN extends number, NULLIFIERS_LEN extends number>(
|
|
14
|
-
noteHashes:
|
|
15
|
-
nullifiers:
|
|
14
|
+
noteHashes: Tuple<ScopedNoteHash, NOTE_HASHES_LEN>,
|
|
15
|
+
nullifiers: Tuple<ScopedNullifier, NULLIFIERS_LEN>,
|
|
16
16
|
futureNoteHashReads: ScopedReadRequest[],
|
|
17
17
|
futureNullifierReads: ScopedReadRequest[],
|
|
18
18
|
noteHashNullifierCounterMap: Map<number, number>,
|
|
19
19
|
validationRequestsSplitCounter: number,
|
|
20
|
+
noteHashesLength: NOTE_HASHES_LEN = noteHashes.length as NOTE_HASHES_LEN,
|
|
21
|
+
nullifiersLength: NULLIFIERS_LEN = nullifiers.length as NULLIFIERS_LEN,
|
|
20
22
|
): { numTransientData: number; hints: Tuple<TransientDataIndexHint, NULLIFIERS_LEN> } {
|
|
21
23
|
const futureNoteHashReadsMap = new ScopedValueCache(futureNoteHashReads);
|
|
22
24
|
const futureNullifierReadsMap = new ScopedValueCache(futureNullifierReads);
|
|
23
25
|
|
|
24
26
|
const nullifierIndexMap: Map<number, number> = new Map();
|
|
25
|
-
nullifiers.
|
|
27
|
+
nullifiers.forEach((n, i) => nullifierIndexMap.set(n.counter, i));
|
|
26
28
|
|
|
27
29
|
const hints = [];
|
|
28
|
-
|
|
29
|
-
|
|
30
|
+
const numNoteHashes = countAccumulatedItems(noteHashes);
|
|
31
|
+
for (let noteHashIndex = 0; noteHashIndex < numNoteHashes; noteHashIndex++) {
|
|
32
|
+
const noteHash = noteHashes[noteHashIndex];
|
|
30
33
|
const noteHashNullifierCounter = noteHashNullifierCounterMap.get(noteHash.counter);
|
|
31
34
|
// The note hash might not be linked to a nullifier or it might be read in the future
|
|
32
35
|
if (
|
|
@@ -42,7 +45,7 @@ export function buildTransientDataHints<NOTE_HASHES_LEN extends number, NULLIFIE
|
|
|
42
45
|
continue;
|
|
43
46
|
}
|
|
44
47
|
|
|
45
|
-
const nullifier = nullifiers
|
|
48
|
+
const nullifier = nullifiers[nullifierIndex];
|
|
46
49
|
// Cannot nullify a non-revertible note hash with a revertible nullifier.
|
|
47
50
|
if (noteHash.counter < validationRequestsSplitCounter && nullifier.counter >= validationRequestsSplitCounter) {
|
|
48
51
|
continue;
|
|
@@ -71,9 +74,8 @@ export function buildTransientDataHints<NOTE_HASHES_LEN extends number, NULLIFIE
|
|
|
71
74
|
hints.push(new TransientDataIndexHint(nullifierIndex, noteHashIndex));
|
|
72
75
|
}
|
|
73
76
|
|
|
74
|
-
const noActionHint = new TransientDataIndexHint(nullifiers.array.length, noteHashes.array.length);
|
|
75
77
|
return {
|
|
76
78
|
numTransientData: hints.length,
|
|
77
|
-
hints: padArrayEnd(hints,
|
|
79
|
+
hints: padArrayEnd(hints, new TransientDataIndexHint(nullifiersLength, noteHashesLength), nullifiersLength),
|
|
78
80
|
};
|
|
79
81
|
}
|
|
@@ -10,6 +10,7 @@ export * from './key_validation_request_and_generator.js';
|
|
|
10
10
|
export * from './read_request.js';
|
|
11
11
|
export * from './key_validation_request.js';
|
|
12
12
|
export * from './scoped_key_validation_request_and_generator.js';
|
|
13
|
+
export * from './rollup_validation_requests.js';
|
|
13
14
|
export * from './transient_data_index_hint.js';
|
|
14
15
|
export * from './private_kernel_reset_hints.js';
|
|
15
16
|
export * from './tree_leaf_read_request.js';
|
|
@@ -4,7 +4,13 @@ import { Fr } from '@aztec/foundation/fields';
|
|
|
4
4
|
import type { BufferReader } from '@aztec/foundation/serialize';
|
|
5
5
|
import type { MembershipWitness } from '@aztec/foundation/trees';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
PendingReadHint,
|
|
9
|
+
ReadRequestResetHints,
|
|
10
|
+
ReadRequestState,
|
|
11
|
+
ReadRequestStatus,
|
|
12
|
+
SettledReadHint,
|
|
13
|
+
} from './read_request_hints.js';
|
|
8
14
|
|
|
9
15
|
type NoteHashLeafValue = Fr;
|
|
10
16
|
|
|
@@ -41,7 +47,7 @@ export class NoteHashReadRequestHintsBuilder<PENDING extends number, SETTLED ext
|
|
|
41
47
|
public readonly maxSettled: SETTLED,
|
|
42
48
|
) {
|
|
43
49
|
this.hints = new ReadRequestResetHints(
|
|
44
|
-
makeTuple(MAX_NOTE_HASH_READ_REQUESTS_PER_TX,
|
|
50
|
+
makeTuple(MAX_NOTE_HASH_READ_REQUESTS_PER_TX, ReadRequestStatus.nada),
|
|
45
51
|
makeTuple(maxPending, () => PendingReadHint.nada(MAX_NOTE_HASH_READ_REQUESTS_PER_TX)),
|
|
46
52
|
makeTuple(maxSettled, () =>
|
|
47
53
|
SettledReadHint.nada(MAX_NOTE_HASH_READ_REQUESTS_PER_TX, NOTE_HASH_TREE_HEIGHT, Fr.zero),
|
|
@@ -57,7 +63,10 @@ export class NoteHashReadRequestHintsBuilder<PENDING extends number, SETTLED ext
|
|
|
57
63
|
if (this.numPendingReadHints === this.maxPending) {
|
|
58
64
|
throw new Error('Cannot add more pending read request.');
|
|
59
65
|
}
|
|
60
|
-
this.hints.
|
|
66
|
+
this.hints.readRequestStatuses[readRequestIndex] = new ReadRequestStatus(
|
|
67
|
+
ReadRequestState.PENDING,
|
|
68
|
+
this.numPendingReadHints,
|
|
69
|
+
);
|
|
61
70
|
this.hints.pendingReadHints[this.numPendingReadHints] = new PendingReadHint(readRequestIndex, noteHashIndex);
|
|
62
71
|
this.numPendingReadHints++;
|
|
63
72
|
}
|
|
@@ -70,7 +79,10 @@ export class NoteHashReadRequestHintsBuilder<PENDING extends number, SETTLED ext
|
|
|
70
79
|
if (this.numSettledReadHints === this.maxSettled) {
|
|
71
80
|
throw new Error('Cannot add more settled read request.');
|
|
72
81
|
}
|
|
73
|
-
this.hints.
|
|
82
|
+
this.hints.readRequestStatuses[readRequestIndex] = new ReadRequestStatus(
|
|
83
|
+
ReadRequestState.SETTLED,
|
|
84
|
+
this.numSettledReadHints,
|
|
85
|
+
);
|
|
74
86
|
this.hints.settledReadHints[this.numSettledReadHints] = new SettledReadHint(
|
|
75
87
|
readRequestIndex,
|
|
76
88
|
membershipWitness,
|
|
@@ -4,7 +4,13 @@ import type { BufferReader } from '@aztec/foundation/serialize';
|
|
|
4
4
|
import type { MembershipWitness, TreeLeafPreimage } from '@aztec/foundation/trees';
|
|
5
5
|
|
|
6
6
|
import { NullifierLeafPreimage } from '../../trees/index.js';
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
PendingReadHint,
|
|
9
|
+
ReadRequestResetHints,
|
|
10
|
+
ReadRequestState,
|
|
11
|
+
ReadRequestStatus,
|
|
12
|
+
SettledReadHint,
|
|
13
|
+
} from './read_request_hints.js';
|
|
8
14
|
|
|
9
15
|
export type NullifierReadRequestHints<PENDING extends number, SETTLED extends number> = ReadRequestResetHints<
|
|
10
16
|
typeof MAX_NULLIFIER_READ_REQUESTS_PER_TX,
|
|
@@ -39,7 +45,7 @@ export class NullifierReadRequestHintsBuilder<PENDING extends number, SETTLED ex
|
|
|
39
45
|
public readonly maxSettled: SETTLED,
|
|
40
46
|
) {
|
|
41
47
|
this.hints = new ReadRequestResetHints(
|
|
42
|
-
makeTuple(MAX_NULLIFIER_READ_REQUESTS_PER_TX,
|
|
48
|
+
makeTuple(MAX_NULLIFIER_READ_REQUESTS_PER_TX, ReadRequestStatus.nada),
|
|
43
49
|
makeTuple(maxPending, () => PendingReadHint.nada(MAX_NULLIFIER_READ_REQUESTS_PER_TX)),
|
|
44
50
|
makeTuple(maxSettled, () =>
|
|
45
51
|
SettledReadHint.nada(MAX_NULLIFIER_READ_REQUESTS_PER_TX, NULLIFIER_TREE_HEIGHT, NullifierLeafPreimage.empty),
|
|
@@ -56,7 +62,10 @@ export class NullifierReadRequestHintsBuilder<PENDING extends number, SETTLED ex
|
|
|
56
62
|
throw new Error('Cannot add more pending read request.');
|
|
57
63
|
}
|
|
58
64
|
|
|
59
|
-
this.hints.
|
|
65
|
+
this.hints.readRequestStatuses[readRequestIndex] = new ReadRequestStatus(
|
|
66
|
+
ReadRequestState.PENDING,
|
|
67
|
+
this.numPendingReadHints,
|
|
68
|
+
);
|
|
60
69
|
this.hints.pendingReadHints[this.numPendingReadHints] = new PendingReadHint(readRequestIndex, nullifierIndex);
|
|
61
70
|
this.numPendingReadHints++;
|
|
62
71
|
}
|
|
@@ -69,7 +78,10 @@ export class NullifierReadRequestHintsBuilder<PENDING extends number, SETTLED ex
|
|
|
69
78
|
if (this.numSettledReadHints === this.maxSettled) {
|
|
70
79
|
throw new Error('Cannot add more settled read request.');
|
|
71
80
|
}
|
|
72
|
-
this.hints.
|
|
81
|
+
this.hints.readRequestStatuses[readRequestIndex] = new ReadRequestStatus(
|
|
82
|
+
ReadRequestState.SETTLED,
|
|
83
|
+
this.numSettledReadHints,
|
|
84
|
+
);
|
|
73
85
|
this.hints.settledReadHints[this.numSettledReadHints] = new SettledReadHint(
|
|
74
86
|
readRequestIndex,
|
|
75
87
|
membershipWitness,
|
|
@@ -2,37 +2,37 @@ import { makeTuple } from '@aztec/foundation/array';
|
|
|
2
2
|
import { BufferReader, type Bufferable, type Tuple, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
3
3
|
import { MembershipWitness } from '@aztec/foundation/trees';
|
|
4
4
|
|
|
5
|
-
export enum
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
export enum ReadRequestState {
|
|
6
|
+
NADA = 0,
|
|
7
|
+
PENDING = 1,
|
|
8
|
+
SETTLED = 2,
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
export class
|
|
11
|
+
export class ReadRequestStatus {
|
|
12
12
|
constructor(
|
|
13
|
-
public
|
|
13
|
+
public state: ReadRequestState,
|
|
14
14
|
public hintIndex: number,
|
|
15
15
|
) {}
|
|
16
16
|
|
|
17
|
-
static
|
|
18
|
-
return new
|
|
17
|
+
static nada() {
|
|
18
|
+
return new ReadRequestStatus(ReadRequestState.NADA, 0);
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
static
|
|
22
|
-
return new
|
|
21
|
+
static pending(hintIndex: number) {
|
|
22
|
+
return new ReadRequestStatus(ReadRequestState.PENDING, hintIndex);
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
static
|
|
26
|
-
return new
|
|
25
|
+
static settled(hintIndex: number) {
|
|
26
|
+
return new ReadRequestStatus(ReadRequestState.SETTLED, hintIndex);
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
static fromBuffer(buffer: Buffer | BufferReader) {
|
|
30
30
|
const reader = BufferReader.asReader(buffer);
|
|
31
|
-
return new
|
|
31
|
+
return new ReadRequestStatus(reader.readNumber(), reader.readNumber());
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
toBuffer() {
|
|
35
|
-
return serializeToBuffer(this.
|
|
35
|
+
return serializeToBuffer(this.state, this.hintIndex);
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
|
|
@@ -100,7 +100,7 @@ export class ReadRequestResetHints<
|
|
|
100
100
|
LEAF_PREIMAGE extends Bufferable,
|
|
101
101
|
> {
|
|
102
102
|
constructor(
|
|
103
|
-
public
|
|
103
|
+
public readRequestStatuses: Tuple<ReadRequestStatus, READ_REQUEST_LEN>,
|
|
104
104
|
/**
|
|
105
105
|
* The hints for read requests reading pending values.
|
|
106
106
|
*/
|
|
@@ -122,7 +122,7 @@ export class ReadRequestResetHints<
|
|
|
122
122
|
LEAF_PREIMAGE
|
|
123
123
|
> {
|
|
124
124
|
return new ReadRequestResetHints(
|
|
125
|
-
this.
|
|
125
|
+
this.readRequestStatuses,
|
|
126
126
|
this.pendingReadHints.slice(0, numPendingReads) as Tuple<PendingReadHint, NEW_PENDING_READ_HINTS_LEN>,
|
|
127
127
|
this.settledReadHints.slice(0, numSettledReads) as Tuple<
|
|
128
128
|
SettledReadHint<TREE_HEIGHT, LEAF_PREIMAGE>,
|
|
@@ -158,7 +158,7 @@ export class ReadRequestResetHints<
|
|
|
158
158
|
> {
|
|
159
159
|
const reader = BufferReader.asReader(buffer);
|
|
160
160
|
return new ReadRequestResetHints(
|
|
161
|
-
reader.readArray(readRequestLen,
|
|
161
|
+
reader.readArray(readRequestLen, ReadRequestStatus),
|
|
162
162
|
reader.readArray(numPendingReads, PendingReadHint),
|
|
163
163
|
reader.readArray(numSettledReads, {
|
|
164
164
|
fromBuffer: r => SettledReadHint.fromBuffer(r, treeHeight, leafPreimageFromBuffer),
|
|
@@ -167,19 +167,19 @@ export class ReadRequestResetHints<
|
|
|
167
167
|
}
|
|
168
168
|
|
|
169
169
|
toBuffer() {
|
|
170
|
-
return serializeToBuffer(this.
|
|
170
|
+
return serializeToBuffer(this.readRequestStatuses, this.pendingReadHints, this.settledReadHints);
|
|
171
171
|
}
|
|
172
172
|
}
|
|
173
173
|
|
|
174
|
-
export class
|
|
174
|
+
export class ReadRequestResetStates<NUM_READS extends number> {
|
|
175
175
|
constructor(
|
|
176
|
-
public
|
|
176
|
+
public states: Tuple<ReadRequestState, NUM_READS>,
|
|
177
177
|
public pendingReadHints: PendingReadHint[],
|
|
178
178
|
) {}
|
|
179
179
|
|
|
180
180
|
static empty<NUM_READS extends number>(numReads: NUM_READS) {
|
|
181
|
-
return new
|
|
182
|
-
makeTuple(numReads, () =>
|
|
181
|
+
return new ReadRequestResetStates(
|
|
182
|
+
makeTuple(numReads, () => ReadRequestState.NADA),
|
|
183
183
|
[],
|
|
184
184
|
);
|
|
185
185
|
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { ROLLUP_VALIDATION_REQUESTS_LENGTH } from '@aztec/constants';
|
|
2
|
+
import type { Fr } from '@aztec/foundation/fields';
|
|
3
|
+
import { BufferReader, FieldReader, serializeToBuffer, serializeToFields } from '@aztec/foundation/serialize';
|
|
4
|
+
import { bufferToHex, hexToBuffer } from '@aztec/foundation/string';
|
|
5
|
+
import type { FieldsOf } from '@aztec/foundation/types';
|
|
6
|
+
|
|
7
|
+
import { IncludeByTimestamp } from '../../tx/include_by_timestamp.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Validation requests directed at the rollup, accumulated during the execution of the transaction.
|
|
11
|
+
*/
|
|
12
|
+
export class RollupValidationRequests {
|
|
13
|
+
constructor(
|
|
14
|
+
/** The highest timestamp of a block in which this transaction can still be included. */
|
|
15
|
+
public includeByTimestamp: IncludeByTimestamp,
|
|
16
|
+
) {}
|
|
17
|
+
|
|
18
|
+
getSize() {
|
|
19
|
+
return this.toBuffer().length;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
toBuffer() {
|
|
23
|
+
return serializeToBuffer(this.includeByTimestamp);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
toString() {
|
|
27
|
+
return bufferToHex(this.toBuffer());
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
static getFields(fields: FieldsOf<RollupValidationRequests>) {
|
|
31
|
+
return [fields.includeByTimestamp] as const;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
static fromFields(fields: Fr[] | FieldReader) {
|
|
35
|
+
const reader = FieldReader.asReader(fields);
|
|
36
|
+
return new RollupValidationRequests(IncludeByTimestamp.fromFields(reader));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
toFields(): Fr[] {
|
|
40
|
+
const fields = serializeToFields(...RollupValidationRequests.getFields(this));
|
|
41
|
+
if (fields.length !== ROLLUP_VALIDATION_REQUESTS_LENGTH) {
|
|
42
|
+
throw new Error(
|
|
43
|
+
`Invalid number of fields for RollupValidationRequests. Expected ${ROLLUP_VALIDATION_REQUESTS_LENGTH}, got ${fields.length}`,
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
return fields;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Deserializes from a buffer or reader, corresponding to a write in cpp.
|
|
51
|
+
* @param buffer - Buffer or reader to read from.
|
|
52
|
+
* @returns Deserialized object.
|
|
53
|
+
*/
|
|
54
|
+
static fromBuffer(buffer: Buffer | BufferReader) {
|
|
55
|
+
const reader = BufferReader.asReader(buffer);
|
|
56
|
+
return new RollupValidationRequests(reader.readObject(IncludeByTimestamp));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Deserializes from a string, corresponding to a write in cpp.
|
|
61
|
+
* @param str - String to read from.
|
|
62
|
+
* @returns Deserialized object.
|
|
63
|
+
*/
|
|
64
|
+
static fromString(str: string) {
|
|
65
|
+
return RollupValidationRequests.fromBuffer(hexToBuffer(str));
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
static empty() {
|
|
69
|
+
return new RollupValidationRequests(IncludeByTimestamp.empty());
|
|
70
|
+
}
|
|
71
|
+
}
|
package/src/kernel/index.ts
CHANGED