@aztec/stdlib 1.2.0 → 2.0.0-nightly.20250813
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/abi/abi.d.ts +0 -67
- package/dest/abi/abi.d.ts.map +1 -1
- package/dest/abi/abi.js +1 -14
- package/dest/abi/authorization_selector.d.ts +52 -0
- package/dest/abi/authorization_selector.d.ts.map +1 -0
- package/dest/abi/authorization_selector.js +70 -0
- package/dest/abi/contract_artifact.d.ts.map +1 -1
- package/dest/abi/contract_artifact.js +0 -40
- package/dest/abi/decoder.d.ts.map +1 -1
- package/dest/abi/decoder.js +3 -6
- package/dest/abi/index.d.ts +1 -0
- package/dest/abi/index.d.ts.map +1 -1
- package/dest/abi/index.js +1 -0
- package/dest/avm/avm.d.ts +278 -412
- package/dest/avm/avm.d.ts.map +1 -1
- package/dest/avm/avm.js +12 -12
- package/dest/avm/avm_proving_request.d.ts +160 -186
- package/dest/avm/avm_proving_request.d.ts.map +1 -1
- package/dest/block/l2_block.d.ts +8 -0
- package/dest/block/l2_block.d.ts.map +1 -1
- package/dest/block/l2_block.js +9 -0
- package/dest/block/l2_block_source.d.ts +446 -2
- package/dest/block/l2_block_source.d.ts.map +1 -1
- package/dest/block/l2_block_source.js +29 -0
- package/dest/block/proposal/committee_attestation.d.ts +3 -1
- package/dest/block/proposal/committee_attestation.d.ts.map +1 -1
- package/dest/block/proposal/committee_attestation.js +3 -0
- package/dest/block/published_l2_block.d.ts +2 -1
- package/dest/block/published_l2_block.d.ts.map +1 -1
- package/dest/block/published_l2_block.js +6 -1
- package/dest/contract/contract_instance.d.ts +3 -3
- package/dest/contract/contract_instance.d.ts.map +1 -1
- package/dest/contract/contract_instance.js +3 -3
- package/dest/contract/interfaces/contract_class.d.ts +2 -2
- package/dest/contract/interfaces/protocol_contract_addresses.d.ts +9 -9
- package/dest/contract/interfaces/protocol_contract_addresses.d.ts.map +1 -1
- package/dest/contract/interfaces/protocol_contract_addresses.js +4 -4
- package/dest/contract/private_function_membership_proof.d.ts +1 -1
- package/dest/contract/private_function_membership_proof.js +1 -1
- package/dest/contract/utility_function_membership_proof.d.ts +1 -1
- package/dest/contract/utility_function_membership_proof.js +1 -1
- package/dest/delayed_public_mutable/delayed_public_mutable_values.d.ts +20 -0
- package/dest/delayed_public_mutable/delayed_public_mutable_values.d.ts.map +1 -0
- package/dest/{shared_mutable/shared_mutable_values.js → delayed_public_mutable/delayed_public_mutable_values.js} +9 -9
- package/dest/{shared_mutable/shared_mutable_values_with_hash.d.ts → delayed_public_mutable/delayed_public_mutable_values_with_hash.d.ts} +6 -6
- package/dest/delayed_public_mutable/delayed_public_mutable_values_with_hash.d.ts.map +1 -0
- package/dest/delayed_public_mutable/delayed_public_mutable_values_with_hash.js +30 -0
- package/dest/delayed_public_mutable/index.d.ts +5 -0
- package/dest/delayed_public_mutable/index.d.ts.map +1 -0
- package/dest/delayed_public_mutable/index.js +4 -0
- package/dest/delayed_public_mutable/scheduled_delay_change.d.ts.map +1 -0
- package/dest/delayed_public_mutable/scheduled_value_change.d.ts.map +1 -0
- package/dest/gas/gas.d.ts +1 -0
- package/dest/gas/gas.d.ts.map +1 -1
- package/dest/gas/gas.js +3 -0
- package/dest/hash/hash.d.ts.map +1 -1
- package/dest/hash/hash.js +1 -4
- package/dest/interfaces/archiver.d.ts.map +1 -1
- package/dest/interfaces/archiver.js +4 -2
- package/dest/interfaces/aztec-node-admin.d.ts +211 -8
- package/dest/interfaces/aztec-node-admin.d.ts.map +1 -1
- package/dest/interfaces/aztec-node-admin.js +9 -3
- package/dest/interfaces/configs.d.ts +27 -0
- package/dest/interfaces/configs.d.ts.map +1 -1
- package/dest/interfaces/configs.js +6 -1
- package/dest/interfaces/get_logs_response.d.ts +1 -1
- package/dest/interfaces/proving-job.d.ts +166 -192
- package/dest/interfaces/proving-job.d.ts.map +1 -1
- package/dest/interfaces/pxe.d.ts +3 -1
- package/dest/interfaces/pxe.d.ts.map +1 -1
- package/dest/interfaces/pxe.js +1 -1
- package/dest/interfaces/server.d.ts +4 -2
- package/dest/interfaces/server.d.ts.map +1 -1
- package/dest/interfaces/server.js +4 -2
- package/dest/interfaces/slasher.d.ts +86 -0
- package/dest/interfaces/slasher.d.ts.map +1 -0
- package/dest/interfaces/slasher.js +23 -0
- package/dest/interfaces/tx_provider.d.ts +24 -0
- package/dest/interfaces/tx_provider.d.ts.map +1 -0
- package/dest/kernel/claimed_length_array.d.ts +34 -0
- package/dest/kernel/claimed_length_array.d.ts.map +1 -0
- package/dest/kernel/claimed_length_array.js +58 -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 +18 -20
- package/dest/kernel/hints/build_nullifier_read_request_hints.d.ts +7 -10
- package/dest/kernel/hints/build_nullifier_read_request_hints.d.ts.map +1 -1
- package/dest/kernel/hints/build_nullifier_read_request_hints.js +17 -32
- package/dest/kernel/hints/build_transient_data_hints.d.ts +4 -3
- package/dest/kernel/hints/build_transient_data_hints.d.ts.map +1 -1
- package/dest/kernel/hints/build_transient_data_hints.js +9 -10
- package/dest/kernel/hints/index.d.ts +1 -2
- package/dest/kernel/hints/index.d.ts.map +1 -1
- package/dest/kernel/hints/index.js +1 -2
- 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/private_kernel_reset_hints.d.ts +5 -5
- package/dest/kernel/hints/private_kernel_reset_hints.d.ts.map +1 -1
- package/dest/kernel/hints/private_kernel_reset_hints.js +9 -9
- 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/{transient_data_index_hint.d.ts → transient_data_squashing_hint.d.ts} +5 -5
- package/dest/kernel/hints/transient_data_squashing_hint.d.ts.map +1 -0
- package/dest/kernel/hints/{transient_data_index_hint.js → transient_data_squashing_hint.js} +5 -5
- package/dest/kernel/index.d.ts +1 -0
- package/dest/kernel/index.d.ts.map +1 -1
- package/dest/kernel/index.js +1 -0
- package/dest/kernel/private_accumulated_data.d.ts +16 -15
- package/dest/kernel/private_accumulated_data.d.ts.map +1 -1
- package/dest/kernel/private_accumulated_data.js +3 -3
- package/dest/kernel/private_call_data.d.ts +4 -4
- package/dest/kernel/private_call_data.d.ts.map +1 -1
- package/dest/kernel/private_call_data.js +2 -2
- package/dest/kernel/private_circuit_public_inputs.d.ts +26 -25
- package/dest/kernel/private_circuit_public_inputs.d.ts.map +1 -1
- package/dest/kernel/private_circuit_public_inputs.js +33 -15
- package/dest/kernel/private_kernel_circuit_public_inputs.d.ts +9 -0
- package/dest/kernel/private_kernel_circuit_public_inputs.d.ts.map +1 -1
- package/dest/kernel/private_kernel_circuit_public_inputs.js +8 -4
- package/dest/kernel/private_kernel_tail_circuit_private_inputs.d.ts +10 -1
- package/dest/kernel/private_kernel_tail_circuit_private_inputs.d.ts.map +1 -1
- package/dest/kernel/private_kernel_tail_circuit_private_inputs.js +9 -6
- package/dest/kernel/private_kernel_tail_circuit_public_inputs.d.ts +11 -4
- package/dest/kernel/private_kernel_tail_circuit_public_inputs.d.ts.map +1 -1
- package/dest/kernel/private_kernel_tail_circuit_public_inputs.js +20 -18
- 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 +9 -10
- 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 +11 -12
- package/dest/kernel/private_validation_requests.d.ts +8 -20
- package/dest/kernel/private_validation_requests.d.ts.map +1 -1
- package/dest/kernel/private_validation_requests.js +9 -21
- package/dest/kernel/utils/order_and_comparison.d.ts +0 -3
- package/dest/kernel/utils/order_and_comparison.d.ts.map +1 -1
- package/dest/kernel/utils/order_and_comparison.js +0 -19
- package/dest/logs/extended_public_log.d.ts +1 -1
- package/dest/logs/shared_secret_derivation.d.ts +1 -1
- package/dest/logs/shared_secret_derivation.js +1 -1
- package/dest/messaging/l2_to_l1_membership.d.ts +4 -1
- package/dest/messaging/l2_to_l1_membership.d.ts.map +1 -1
- package/dest/messaging/l2_to_l1_membership.js +49 -54
- package/dest/messaging/l2_to_l1_message.d.ts +2 -0
- package/dest/messaging/l2_to_l1_message.d.ts.map +1 -1
- package/dest/messaging/l2_to_l1_message.js +7 -0
- package/dest/note/notes_filter.d.ts +5 -2
- package/dest/note/notes_filter.d.ts.map +1 -1
- package/dest/note/notes_filter.js +1 -1
- package/dest/p2p/attestation_utils.d.ts +10 -0
- package/dest/p2p/attestation_utils.d.ts.map +1 -0
- package/dest/p2p/attestation_utils.js +21 -0
- package/dest/p2p/block_attestation.d.ts +3 -4
- package/dest/p2p/block_attestation.d.ts.map +1 -1
- package/dest/p2p/block_attestation.js +3 -4
- package/dest/p2p/block_proposal.d.ts +8 -1
- package/dest/p2p/block_proposal.d.ts.map +1 -1
- package/dest/p2p/block_proposal.js +21 -8
- package/dest/p2p/consensus_payload.d.ts +3 -11
- package/dest/p2p/consensus_payload.d.ts.map +1 -1
- package/dest/p2p/consensus_payload.js +13 -22
- package/dest/p2p/index.d.ts +1 -0
- package/dest/p2p/index.d.ts.map +1 -1
- package/dest/p2p/index.js +1 -0
- package/dest/p2p/topic_type.d.ts.map +1 -1
- package/dest/p2p/topic_type.js +5 -3
- package/dest/rollup/block_root_rollup.d.ts +1 -1
- package/dest/slashing/index.d.ts +51 -0
- package/dest/slashing/index.d.ts.map +1 -0
- package/dest/slashing/index.js +54 -0
- package/dest/stats/stats.d.ts +2 -2
- package/dest/stats/stats.d.ts.map +1 -1
- package/dest/tests/factories.d.ts +0 -2
- package/dest/tests/factories.d.ts.map +1 -1
- package/dest/tests/factories.js +25 -24
- package/dest/tests/mocks.d.ts +2 -0
- package/dest/tests/mocks.d.ts.map +1 -1
- package/dest/tests/mocks.js +31 -22
- package/dest/tx/index.d.ts +0 -1
- package/dest/tx/index.d.ts.map +1 -1
- package/dest/tx/index.js +0 -1
- 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/processed_tx.d.ts +2 -2
- package/dest/tx/processed_tx.d.ts.map +1 -1
- package/dest/tx/processed_tx.js +4 -4
- package/dest/tx/proven_tx.d.ts +1 -1
- package/dest/tx/proven_tx.d.ts.map +1 -1
- package/dest/tx/proven_tx.js +7 -3
- package/dest/tx/simulated_tx.d.ts +11 -17
- package/dest/tx/simulated_tx.d.ts.map +1 -1
- package/dest/tx/simulated_tx.js +12 -12
- package/dest/tx/tx.d.ts +25 -25
- package/dest/tx/tx.d.ts.map +1 -1
- package/dest/tx/tx.js +60 -48
- package/dest/tx/tx_effect.d.ts +2 -2
- package/dest/tx/tx_effect.d.ts.map +1 -1
- package/dest/tx/tx_effect.js +3 -18
- package/dest/tx/tx_execution_request.js +2 -2
- package/dest/tx/tx_hash.d.ts +7 -0
- package/dest/tx/tx_hash.d.ts.map +1 -1
- package/dest/tx/tx_hash.js +19 -1
- package/dest/tx/tx_request.d.ts +5 -5
- package/dest/tx/tx_request.d.ts.map +1 -1
- package/dest/tx/tx_request.js +7 -7
- package/dest/tx/validator/error_texts.d.ts +1 -0
- package/dest/tx/validator/error_texts.d.ts.map +1 -1
- package/dest/tx/validator/error_texts.js +1 -0
- package/dest/tx/validator/tx_validator.d.ts +6 -4
- package/dest/tx/validator/tx_validator.d.ts.map +1 -1
- package/dest/tx/validator/tx_validator.js +3 -0
- package/dest/versioning/versioning.d.ts.map +1 -1
- package/dest/vks/verification_key.d.ts.map +1 -1
- package/dest/vks/verification_key.js +4 -4
- package/package.json +10 -9
- package/src/abi/abi.ts +0 -38
- package/src/abi/authorization_selector.ts +95 -0
- package/src/abi/contract_artifact.ts +0 -49
- package/src/abi/decoder.ts +3 -6
- package/src/abi/index.ts +1 -0
- package/src/avm/avm.ts +7 -9
- package/src/block/l2_block.ts +18 -0
- package/src/block/l2_block_source.ts +70 -1
- package/src/block/proposal/committee_attestation.ts +5 -1
- package/src/block/published_l2_block.ts +14 -5
- package/src/contract/contract_instance.ts +3 -3
- package/src/contract/interfaces/protocol_contract_addresses.ts +5 -10
- package/src/contract/private_function_membership_proof.ts +1 -1
- package/src/contract/utility_function_membership_proof.ts +1 -1
- package/src/{shared_mutable/shared_mutable_values.ts → delayed_public_mutable/delayed_public_mutable_values.ts} +10 -10
- package/src/delayed_public_mutable/delayed_public_mutable_values_with_hash.ts +38 -0
- package/src/delayed_public_mutable/index.ts +4 -0
- package/src/gas/gas.ts +4 -0
- package/src/hash/hash.ts +1 -4
- package/src/interfaces/archiver.ts +3 -1
- package/src/interfaces/aztec-node-admin.ts +19 -8
- package/src/interfaces/configs.ts +17 -0
- package/src/interfaces/pxe.ts +4 -2
- package/src/interfaces/server.ts +4 -2
- package/src/interfaces/slasher.ts +49 -0
- package/src/interfaces/tx_provider.ts +16 -0
- package/src/kernel/claimed_length_array.ts +104 -0
- package/src/kernel/hints/build_note_hash_read_request_hints.ts +28 -30
- package/src/kernel/hints/build_nullifier_read_request_hints.ts +28 -59
- package/src/kernel/hints/build_transient_data_hints.ts +12 -14
- package/src/kernel/hints/index.ts +1 -2
- package/src/kernel/hints/note_hash_read_request_hints.ts +4 -16
- package/src/kernel/hints/nullifier_read_request_hints.ts +4 -16
- package/src/kernel/hints/private_kernel_reset_hints.ts +7 -7
- package/src/kernel/hints/read_request_hints.ts +22 -22
- package/src/kernel/hints/{transient_data_index_hint.ts → transient_data_squashing_hint.ts} +5 -5
- package/src/kernel/index.ts +1 -0
- package/src/kernel/private_accumulated_data.ts +23 -23
- package/src/kernel/private_call_data.ts +3 -3
- package/src/kernel/private_circuit_public_inputs.ts +92 -68
- package/src/kernel/private_kernel_circuit_public_inputs.ts +9 -1
- package/src/kernel/private_kernel_tail_circuit_private_inputs.ts +13 -4
- 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 +16 -10
- package/src/kernel/private_validation_requests.ts +19 -50
- package/src/kernel/utils/order_and_comparison.ts +0 -25
- package/src/logs/shared_secret_derivation.ts +1 -1
- package/src/messaging/l2_to_l1_membership.ts +76 -85
- package/src/messaging/l2_to_l1_message.ts +9 -0
- package/src/note/notes_filter.ts +6 -3
- package/src/p2p/attestation_utils.ts +35 -0
- package/src/p2p/block_attestation.ts +3 -4
- package/src/p2p/block_proposal.ts +23 -5
- package/src/p2p/consensus_payload.ts +10 -29
- package/src/p2p/index.ts +1 -0
- package/src/p2p/topic_type.ts +3 -1
- package/src/slashing/index.ts +74 -0
- package/src/stats/stats.ts +2 -2
- package/src/tests/factories.ts +37 -27
- package/src/tests/mocks.ts +24 -22
- package/src/tx/index.ts +0 -1
- package/src/tx/private_execution_result.ts +11 -9
- package/src/tx/processed_tx.ts +6 -6
- package/src/tx/proven_tx.ts +7 -8
- package/src/tx/simulated_tx.ts +13 -19
- package/src/tx/tx.ts +70 -57
- package/src/tx/tx_effect.ts +5 -20
- package/src/tx/tx_execution_request.ts +2 -2
- package/src/tx/tx_hash.ts +21 -1
- package/src/tx/tx_request.ts +7 -6
- package/src/tx/validator/error_texts.ts +1 -0
- package/src/tx/validator/tx_validator.ts +5 -0
- package/src/versioning/versioning.ts +0 -3
- package/src/vks/verification_key.ts +4 -7
- package/dest/interfaces/tx-collector.d.ts +0 -15
- package/dest/interfaces/tx-collector.d.ts.map +0 -1
- package/dest/kernel/hints/rollup_validation_requests.d.ts +0 -34
- package/dest/kernel/hints/rollup_validation_requests.d.ts.map +0 -1
- package/dest/kernel/hints/rollup_validation_requests.js +0 -55
- package/dest/kernel/hints/transient_data_index_hint.d.ts.map +0 -1
- package/dest/shared_mutable/index.d.ts +0 -5
- package/dest/shared_mutable/index.d.ts.map +0 -1
- package/dest/shared_mutable/index.js +0 -4
- package/dest/shared_mutable/scheduled_delay_change.d.ts.map +0 -1
- package/dest/shared_mutable/scheduled_value_change.d.ts.map +0 -1
- package/dest/shared_mutable/shared_mutable_values.d.ts +0 -20
- package/dest/shared_mutable/shared_mutable_values.d.ts.map +0 -1
- package/dest/shared_mutable/shared_mutable_values_with_hash.d.ts.map +0 -1
- package/dest/shared_mutable/shared_mutable_values_with_hash.js +0 -30
- package/dest/tx/include_by_timestamp.d.ts +0 -54
- package/dest/tx/include_by_timestamp.d.ts.map +0 -1
- package/dest/tx/include_by_timestamp.js +0 -72
- package/src/interfaces/tx-collector.ts +0 -17
- package/src/kernel/hints/rollup_validation_requests.ts +0 -71
- package/src/shared_mutable/index.ts +0 -4
- package/src/shared_mutable/shared_mutable_values_with_hash.ts +0 -38
- package/src/tx/include_by_timestamp.ts +0 -90
- /package/dest/{shared_mutable → delayed_public_mutable}/scheduled_delay_change.d.ts +0 -0
- /package/dest/{shared_mutable → delayed_public_mutable}/scheduled_delay_change.js +0 -0
- /package/dest/{shared_mutable → delayed_public_mutable}/scheduled_value_change.d.ts +0 -0
- /package/dest/{shared_mutable → delayed_public_mutable}/scheduled_value_change.js +0 -0
- /package/dest/interfaces/{tx-collector.js → tx_provider.js} +0 -0
- /package/src/{shared_mutable → delayed_public_mutable}/scheduled_delay_change.ts +0 -0
- /package/src/{shared_mutable → delayed_public_mutable}/scheduled_value_change.ts +0 -0
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import type { Fr } from '@aztec/foundation/fields';
|
|
2
|
+
import {
|
|
3
|
+
BufferReader,
|
|
4
|
+
FieldReader,
|
|
5
|
+
type Serializable,
|
|
6
|
+
type Tuple,
|
|
7
|
+
serializeToBuffer,
|
|
8
|
+
serializeToFields,
|
|
9
|
+
} from '@aztec/foundation/serialize';
|
|
10
|
+
|
|
11
|
+
import { inspect } from 'util';
|
|
12
|
+
|
|
13
|
+
export class ClaimedLengthArray<T extends Serializable, N extends number> {
|
|
14
|
+
constructor(
|
|
15
|
+
public array: Tuple<T, N>,
|
|
16
|
+
// Named `claimedLength` instead of `length` to avoid being confused with array.length.
|
|
17
|
+
public claimedLength: number,
|
|
18
|
+
) {}
|
|
19
|
+
|
|
20
|
+
static fromBuffer<T extends Serializable, N extends number>(
|
|
21
|
+
buffer: Buffer | BufferReader,
|
|
22
|
+
deserializer: {
|
|
23
|
+
fromBuffer: (reader: BufferReader) => T;
|
|
24
|
+
},
|
|
25
|
+
arrayLength: N,
|
|
26
|
+
): ClaimedLengthArray<T, N> {
|
|
27
|
+
const reader = BufferReader.asReader(buffer);
|
|
28
|
+
const array = reader.readArray(arrayLength, deserializer);
|
|
29
|
+
const claimedLength = reader.readNumber();
|
|
30
|
+
return new ClaimedLengthArray(array, claimedLength);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
toBuffer() {
|
|
34
|
+
return serializeToBuffer(this.array, this.claimedLength);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
static fromFields<T extends Serializable, N extends number>(
|
|
38
|
+
fields: Fr[] | FieldReader,
|
|
39
|
+
deserializer: {
|
|
40
|
+
fromFields: (reader: FieldReader) => T;
|
|
41
|
+
},
|
|
42
|
+
arrayLength: N,
|
|
43
|
+
): ClaimedLengthArray<T, N> {
|
|
44
|
+
const reader = FieldReader.asReader(fields);
|
|
45
|
+
const array = reader.readArray(arrayLength, deserializer);
|
|
46
|
+
const claimedLength = reader.readU32();
|
|
47
|
+
return new ClaimedLengthArray(array, claimedLength);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
toFields() {
|
|
51
|
+
return serializeToFields(this.array, this.claimedLength);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
static empty<T extends Serializable, N extends number>(
|
|
55
|
+
elem: { empty: () => T },
|
|
56
|
+
arraySize: number,
|
|
57
|
+
): ClaimedLengthArray<T, N> {
|
|
58
|
+
const array = Array(arraySize).fill(elem.empty()) as Tuple<T, N>;
|
|
59
|
+
return new ClaimedLengthArray(array, 0);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
isEmpty() {
|
|
63
|
+
return this.claimedLength === 0;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
getActiveItems(): T[] {
|
|
67
|
+
return this.array.slice(0, this.claimedLength);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
getSize() {
|
|
71
|
+
return this.toBuffer().length;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
[inspect.custom]() {
|
|
75
|
+
return `ClaimedLengthArray {
|
|
76
|
+
array: [${this.getActiveItems()
|
|
77
|
+
.map(x => inspect(x))
|
|
78
|
+
.join(', ')}],
|
|
79
|
+
claimedLength: ${this.claimedLength},
|
|
80
|
+
`;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export function ClaimedLengthArrayFromBuffer<T extends Serializable, N extends number>(
|
|
85
|
+
deserializer: {
|
|
86
|
+
fromBuffer: (reader: BufferReader) => T;
|
|
87
|
+
},
|
|
88
|
+
arrayLength: N,
|
|
89
|
+
): {
|
|
90
|
+
fromBuffer: (reader: BufferReader) => ClaimedLengthArray<T, N>;
|
|
91
|
+
} {
|
|
92
|
+
return { fromBuffer: (reader: BufferReader) => ClaimedLengthArray.fromBuffer(reader, deserializer, arrayLength) };
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export function ClaimedLengthArrayFromFields<T extends Serializable, N extends number>(
|
|
96
|
+
deserializer: {
|
|
97
|
+
fromFields: (reader: FieldReader) => T;
|
|
98
|
+
},
|
|
99
|
+
arrayLength: N,
|
|
100
|
+
): {
|
|
101
|
+
fromFields: (reader: FieldReader) => ClaimedLengthArray<T, N>;
|
|
102
|
+
} {
|
|
103
|
+
return { fromFields: (reader: FieldReader) => ClaimedLengthArray.fromFields(reader, deserializer, arrayLength) };
|
|
104
|
+
}
|
|
@@ -3,14 +3,13 @@ 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';
|
|
7
6
|
import type { MembershipWitness } from '@aztec/foundation/trees';
|
|
8
7
|
|
|
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';
|
|
11
10
|
import { NoteHashReadRequestHintsBuilder } from './note_hash_read_request_hints.js';
|
|
12
11
|
import type { ScopedReadRequest } from './read_request.js';
|
|
13
|
-
import { PendingReadHint,
|
|
12
|
+
import { PendingReadHint, ReadRequestActionEnum, ReadRequestResetActions } from './read_request_hints.js';
|
|
14
13
|
import { ScopedValueCache } from './scoped_value_cache.js';
|
|
15
14
|
|
|
16
15
|
export function isValidNoteHashReadRequest(readRequest: ScopedReadRequest, noteHash: ScopedNoteHash) {
|
|
@@ -21,15 +20,15 @@ export function isValidNoteHashReadRequest(readRequest: ScopedReadRequest, noteH
|
|
|
21
20
|
);
|
|
22
21
|
}
|
|
23
22
|
|
|
24
|
-
export function
|
|
25
|
-
noteHashReadRequests:
|
|
26
|
-
noteHashes:
|
|
23
|
+
export function getNoteHashReadRequestResetActions(
|
|
24
|
+
noteHashReadRequests: ClaimedLengthArray<ScopedReadRequest, typeof MAX_NOTE_HASH_READ_REQUESTS_PER_TX>,
|
|
25
|
+
noteHashes: ClaimedLengthArray<ScopedNoteHash, typeof MAX_NOTE_HASHES_PER_TX>,
|
|
27
26
|
futureNoteHashes: ScopedNoteHash[],
|
|
28
|
-
):
|
|
29
|
-
const
|
|
27
|
+
): ReadRequestResetActions<typeof MAX_NOTE_HASH_READ_REQUESTS_PER_TX> {
|
|
28
|
+
const resetActions = ReadRequestResetActions.empty(MAX_NOTE_HASH_READ_REQUESTS_PER_TX);
|
|
30
29
|
|
|
31
30
|
const noteHashMap: Map<bigint, { noteHash: ScopedNoteHash; index: number }[]> = new Map();
|
|
32
|
-
|
|
31
|
+
noteHashes.getActiveItems().forEach((noteHash, index) => {
|
|
33
32
|
const value = noteHash.value.toBigInt();
|
|
34
33
|
const arr = noteHashMap.get(value) ?? [];
|
|
35
34
|
arr.push({ noteHash, index });
|
|
@@ -38,49 +37,48 @@ export function getNoteHashReadRequestResetStates(
|
|
|
38
37
|
|
|
39
38
|
const futureNoteHashMap = new ScopedValueCache(futureNoteHashes);
|
|
40
39
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
const readRequest = noteHashReadRequests[i];
|
|
40
|
+
for (let i = 0; i < noteHashReadRequests.claimedLength; ++i) {
|
|
41
|
+
const readRequest = noteHashReadRequests.array[i];
|
|
44
42
|
|
|
45
43
|
const pendingNoteHash = noteHashMap
|
|
46
44
|
.get(readRequest.value.toBigInt())
|
|
47
45
|
?.find(n => isValidNoteHashReadRequest(readRequest, n.noteHash));
|
|
48
46
|
|
|
49
47
|
if (pendingNoteHash !== undefined) {
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
resetActions.actions[i] = ReadRequestActionEnum.READ_AS_PENDING;
|
|
49
|
+
resetActions.pendingReadHints.push(new PendingReadHint(i, pendingNoteHash.index));
|
|
52
50
|
} else if (
|
|
53
51
|
!futureNoteHashMap
|
|
54
52
|
.get(readRequest)
|
|
55
53
|
.find(futureNoteHash => isValidNoteHashReadRequest(readRequest, futureNoteHash))
|
|
56
54
|
) {
|
|
57
|
-
|
|
55
|
+
resetActions.actions[i] = ReadRequestActionEnum.READ_AS_SETTLED;
|
|
58
56
|
}
|
|
59
57
|
}
|
|
60
58
|
|
|
61
|
-
return
|
|
59
|
+
return resetActions;
|
|
62
60
|
}
|
|
63
61
|
|
|
64
|
-
export async function
|
|
62
|
+
export async function buildNoteHashReadRequestHintsFromResetActions<PENDING extends number, SETTLED extends number>(
|
|
65
63
|
oracle: {
|
|
66
64
|
getNoteHashMembershipWitness(leafIndex: bigint): Promise<MembershipWitness<typeof NOTE_HASH_TREE_HEIGHT>>;
|
|
67
65
|
},
|
|
68
|
-
noteHashReadRequests:
|
|
69
|
-
noteHashes:
|
|
70
|
-
|
|
66
|
+
noteHashReadRequests: ClaimedLengthArray<ScopedReadRequest, typeof MAX_NOTE_HASH_READ_REQUESTS_PER_TX>,
|
|
67
|
+
noteHashes: ClaimedLengthArray<ScopedNoteHash, typeof MAX_NOTE_HASHES_PER_TX>,
|
|
68
|
+
resetActions: ReadRequestResetActions<typeof MAX_NOTE_HASH_READ_REQUESTS_PER_TX>,
|
|
71
69
|
noteHashLeafIndexMap: Map<bigint, bigint>,
|
|
72
70
|
maxPending: PENDING = MAX_NOTE_HASH_READ_REQUESTS_PER_TX as PENDING,
|
|
73
71
|
maxSettled: SETTLED = MAX_NOTE_HASH_READ_REQUESTS_PER_TX as SETTLED,
|
|
74
72
|
) {
|
|
75
73
|
const builder = new NoteHashReadRequestHintsBuilder(maxPending, maxSettled);
|
|
76
74
|
|
|
77
|
-
|
|
75
|
+
resetActions.pendingReadHints.forEach(hint => {
|
|
78
76
|
builder.addPendingReadRequest(hint.readRequestIndex, hint.pendingValueIndex);
|
|
79
77
|
});
|
|
80
78
|
|
|
81
|
-
for (let i = 0; i <
|
|
82
|
-
if (
|
|
83
|
-
const readRequest = noteHashReadRequests[i];
|
|
79
|
+
for (let i = 0; i < resetActions.actions.length; i++) {
|
|
80
|
+
if (resetActions.actions[i] === ReadRequestActionEnum.READ_AS_SETTLED) {
|
|
81
|
+
const readRequest = noteHashReadRequests.array[i];
|
|
84
82
|
const leafIndex = noteHashLeafIndexMap.get(readRequest.value.toBigInt());
|
|
85
83
|
if (leafIndex === undefined) {
|
|
86
84
|
throw new Error('Read request is reading an unknown note hash.');
|
|
@@ -91,7 +89,7 @@ export async function buildNoteHashReadRequestHintsFromResetStates<PENDING exten
|
|
|
91
89
|
}
|
|
92
90
|
|
|
93
91
|
const noteHashMap: Map<bigint, { noteHash: ScopedNoteHash; index: number }[]> = new Map();
|
|
94
|
-
|
|
92
|
+
noteHashes.getActiveItems().forEach((noteHash, index) => {
|
|
95
93
|
const value = noteHash.value.toBigInt();
|
|
96
94
|
const arr = noteHashMap.get(value) ?? [];
|
|
97
95
|
arr.push({ noteHash, index });
|
|
@@ -105,19 +103,19 @@ export async function buildNoteHashReadRequestHints<PENDING extends number, SETT
|
|
|
105
103
|
oracle: {
|
|
106
104
|
getNoteHashMembershipWitness(leafIndex: bigint): Promise<MembershipWitness<typeof NOTE_HASH_TREE_HEIGHT>>;
|
|
107
105
|
},
|
|
108
|
-
noteHashReadRequests:
|
|
109
|
-
noteHashes:
|
|
106
|
+
noteHashReadRequests: ClaimedLengthArray<ScopedReadRequest, typeof MAX_NOTE_HASH_READ_REQUESTS_PER_TX>,
|
|
107
|
+
noteHashes: ClaimedLengthArray<ScopedNoteHash, typeof MAX_NOTE_HASHES_PER_TX>,
|
|
110
108
|
noteHashLeafIndexMap: Map<bigint, bigint>,
|
|
111
109
|
futureNoteHashes: ScopedNoteHash[],
|
|
112
110
|
maxPending: PENDING = MAX_NOTE_HASH_READ_REQUESTS_PER_TX as PENDING,
|
|
113
111
|
maxSettled: SETTLED = MAX_NOTE_HASH_READ_REQUESTS_PER_TX as SETTLED,
|
|
114
112
|
) {
|
|
115
|
-
const
|
|
116
|
-
return await
|
|
113
|
+
const resetActions = getNoteHashReadRequestResetActions(noteHashReadRequests, noteHashes, futureNoteHashes);
|
|
114
|
+
return await buildNoteHashReadRequestHintsFromResetActions(
|
|
117
115
|
oracle,
|
|
118
116
|
noteHashReadRequests,
|
|
119
117
|
noteHashes,
|
|
120
|
-
|
|
118
|
+
resetActions,
|
|
121
119
|
noteHashLeafIndexMap,
|
|
122
120
|
maxPending,
|
|
123
121
|
maxSettled,
|
|
@@ -3,18 +3,15 @@ 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';
|
|
7
6
|
import type { Fr } from '@aztec/foundation/fields';
|
|
8
|
-
import type { Tuple } from '@aztec/foundation/serialize';
|
|
9
7
|
import { type IndexedTreeLeafPreimage, MembershipWitness } from '@aztec/foundation/trees';
|
|
10
8
|
|
|
11
|
-
import { AztecAddress } from '../../aztec-address/index.js';
|
|
12
9
|
import { siloNullifier } from '../../hash/hash.js';
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
10
|
+
import type { ClaimedLengthArray } from '../claimed_length_array.js';
|
|
11
|
+
import type { ScopedNullifier } from '../nullifier.js';
|
|
15
12
|
import { NullifierReadRequestHintsBuilder } from './nullifier_read_request_hints.js';
|
|
16
|
-
import {
|
|
17
|
-
import { PendingReadHint,
|
|
13
|
+
import { ScopedReadRequest } from './read_request.js';
|
|
14
|
+
import { PendingReadHint, ReadRequestActionEnum, ReadRequestResetActions } from './read_request_hints.js';
|
|
18
15
|
import { ScopedValueCache } from './scoped_value_cache.js';
|
|
19
16
|
|
|
20
17
|
export function isValidNullifierReadRequest(readRequest: ScopedReadRequest, nullifier: ScopedNullifier) {
|
|
@@ -30,15 +27,15 @@ interface NullifierMembershipWitnessWithPreimage {
|
|
|
30
27
|
leafPreimage: IndexedTreeLeafPreimage;
|
|
31
28
|
}
|
|
32
29
|
|
|
33
|
-
export function
|
|
34
|
-
nullifierReadRequests:
|
|
35
|
-
nullifiers:
|
|
30
|
+
export function getNullifierReadRequestResetActions(
|
|
31
|
+
nullifierReadRequests: ClaimedLengthArray<ScopedReadRequest, typeof MAX_NULLIFIER_READ_REQUESTS_PER_TX>,
|
|
32
|
+
nullifiers: ClaimedLengthArray<ScopedNullifier, typeof MAX_NULLIFIERS_PER_TX>,
|
|
36
33
|
futureNullifiers: ScopedNullifier[],
|
|
37
|
-
):
|
|
38
|
-
const
|
|
34
|
+
): ReadRequestResetActions<typeof MAX_NULLIFIER_READ_REQUESTS_PER_TX> {
|
|
35
|
+
const resetActions = ReadRequestResetActions.empty(MAX_NULLIFIER_READ_REQUESTS_PER_TX);
|
|
39
36
|
|
|
40
37
|
const nullifierMap: Map<bigint, { nullifier: ScopedNullifier; index: number }[]> = new Map();
|
|
41
|
-
|
|
38
|
+
nullifiers.getActiveItems().forEach((nullifier, index) => {
|
|
42
39
|
const value = nullifier.value.toBigInt();
|
|
43
40
|
const arr = nullifierMap.get(value) ?? [];
|
|
44
41
|
arr.push({ nullifier, index });
|
|
@@ -47,48 +44,46 @@ export function getNullifierReadRequestResetStates(
|
|
|
47
44
|
|
|
48
45
|
const futureNullifiersMap = new ScopedValueCache(futureNullifiers);
|
|
49
46
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
for (let i = 0; i < numReadRequests; ++i) {
|
|
53
|
-
const readRequest = nullifierReadRequests[i];
|
|
47
|
+
for (let i = 0; i < nullifierReadRequests.claimedLength; ++i) {
|
|
48
|
+
const readRequest = nullifierReadRequests.array[i];
|
|
54
49
|
const pendingNullifier = nullifierMap
|
|
55
50
|
.get(readRequest.value.toBigInt())
|
|
56
51
|
?.find(({ nullifier }) => isValidNullifierReadRequest(readRequest, nullifier));
|
|
57
52
|
|
|
58
53
|
if (pendingNullifier !== undefined) {
|
|
59
|
-
|
|
60
|
-
|
|
54
|
+
resetActions.actions[i] = ReadRequestActionEnum.READ_AS_PENDING;
|
|
55
|
+
resetActions.pendingReadHints.push(new PendingReadHint(i, pendingNullifier.index));
|
|
61
56
|
} else if (
|
|
62
57
|
!futureNullifiersMap
|
|
63
58
|
.get(readRequest)
|
|
64
59
|
.some(futureNullifier => isValidNullifierReadRequest(readRequest, futureNullifier))
|
|
65
60
|
) {
|
|
66
|
-
|
|
61
|
+
resetActions.actions[i] = ReadRequestActionEnum.READ_AS_SETTLED;
|
|
67
62
|
}
|
|
68
63
|
}
|
|
69
64
|
|
|
70
|
-
return
|
|
65
|
+
return resetActions;
|
|
71
66
|
}
|
|
72
67
|
|
|
73
|
-
export async function
|
|
68
|
+
export async function buildNullifierReadRequestHintsFromResetActions<PENDING extends number, SETTLED extends number>(
|
|
74
69
|
oracle: {
|
|
75
70
|
getNullifierMembershipWitness(nullifier: Fr): Promise<NullifierMembershipWitnessWithPreimage>;
|
|
76
71
|
},
|
|
77
|
-
nullifierReadRequests:
|
|
78
|
-
|
|
72
|
+
nullifierReadRequests: ClaimedLengthArray<ScopedReadRequest, typeof MAX_NULLIFIER_READ_REQUESTS_PER_TX>,
|
|
73
|
+
resetActions: ReadRequestResetActions<typeof MAX_NULLIFIER_READ_REQUESTS_PER_TX>,
|
|
79
74
|
maxPending: PENDING = MAX_NULLIFIER_READ_REQUESTS_PER_TX as PENDING,
|
|
80
75
|
maxSettled: SETTLED = MAX_NULLIFIER_READ_REQUESTS_PER_TX as SETTLED,
|
|
81
76
|
siloed = false,
|
|
82
77
|
) {
|
|
83
78
|
const builder = new NullifierReadRequestHintsBuilder(maxPending, maxSettled);
|
|
84
79
|
|
|
85
|
-
|
|
80
|
+
resetActions.pendingReadHints.forEach(hint => {
|
|
86
81
|
builder.addPendingReadRequest(hint.readRequestIndex, hint.pendingValueIndex);
|
|
87
82
|
});
|
|
88
83
|
|
|
89
|
-
for (let i = 0; i <
|
|
90
|
-
if (
|
|
91
|
-
const readRequest = nullifierReadRequests[i];
|
|
84
|
+
for (let i = 0; i < resetActions.actions.length; i++) {
|
|
85
|
+
if (resetActions.actions[i] === ReadRequestActionEnum.READ_AS_SETTLED) {
|
|
86
|
+
const readRequest = nullifierReadRequests.array[i];
|
|
92
87
|
const siloedValue = siloed
|
|
93
88
|
? readRequest.value
|
|
94
89
|
: await siloNullifier(readRequest.contractAddress, readRequest.value);
|
|
@@ -108,46 +103,20 @@ export async function buildNullifierReadRequestHints<PENDING extends number, SET
|
|
|
108
103
|
oracle: {
|
|
109
104
|
getNullifierMembershipWitness(nullifier: Fr): Promise<NullifierMembershipWitnessWithPreimage>;
|
|
110
105
|
},
|
|
111
|
-
nullifierReadRequests:
|
|
112
|
-
nullifiers:
|
|
106
|
+
nullifierReadRequests: ClaimedLengthArray<ScopedReadRequest, typeof MAX_NULLIFIER_READ_REQUESTS_PER_TX>,
|
|
107
|
+
nullifiers: ClaimedLengthArray<ScopedNullifier, typeof MAX_NULLIFIERS_PER_TX>,
|
|
113
108
|
futureNullifiers: ScopedNullifier[],
|
|
114
109
|
maxPending: PENDING = MAX_NULLIFIER_READ_REQUESTS_PER_TX as PENDING,
|
|
115
110
|
maxSettled: SETTLED = MAX_NULLIFIER_READ_REQUESTS_PER_TX as SETTLED,
|
|
116
111
|
siloed = false,
|
|
117
112
|
) {
|
|
118
|
-
const
|
|
119
|
-
return await
|
|
113
|
+
const resetActions = getNullifierReadRequestResetActions(nullifierReadRequests, nullifiers, futureNullifiers);
|
|
114
|
+
return await buildNullifierReadRequestHintsFromResetActions(
|
|
120
115
|
oracle,
|
|
121
116
|
nullifierReadRequests,
|
|
122
|
-
|
|
117
|
+
resetActions,
|
|
123
118
|
maxPending,
|
|
124
119
|
maxSettled,
|
|
125
120
|
siloed,
|
|
126
121
|
);
|
|
127
122
|
}
|
|
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,35 +1,32 @@
|
|
|
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';
|
|
4
5
|
import type { ScopedNoteHash } from '../note_hash.js';
|
|
5
6
|
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';
|
|
10
10
|
import { ScopedValueCache } from './scoped_value_cache.js';
|
|
11
|
-
import {
|
|
11
|
+
import { TransientDataSquashingHint } from './transient_data_squashing_hint.js';
|
|
12
12
|
|
|
13
13
|
export function buildTransientDataHints<NOTE_HASHES_LEN extends number, NULLIFIERS_LEN extends number>(
|
|
14
|
-
noteHashes:
|
|
15
|
-
nullifiers:
|
|
14
|
+
noteHashes: ClaimedLengthArray<ScopedNoteHash, NOTE_HASHES_LEN>,
|
|
15
|
+
nullifiers: ClaimedLengthArray<ScopedNullifier, NULLIFIERS_LEN>,
|
|
16
16
|
futureNoteHashReads: ScopedReadRequest[],
|
|
17
17
|
futureNullifierReads: ScopedReadRequest[],
|
|
18
18
|
noteHashNullifierCounterMap: Map<number, number>,
|
|
19
19
|
validationRequestsSplitCounter: number,
|
|
20
|
-
|
|
21
|
-
nullifiersLength: NULLIFIERS_LEN = nullifiers.length as NULLIFIERS_LEN,
|
|
22
|
-
): { numTransientData: number; hints: Tuple<TransientDataIndexHint, NULLIFIERS_LEN> } {
|
|
20
|
+
): { numTransientData: number; hints: Tuple<TransientDataSquashingHint, NULLIFIERS_LEN> } {
|
|
23
21
|
const futureNoteHashReadsMap = new ScopedValueCache(futureNoteHashReads);
|
|
24
22
|
const futureNullifierReadsMap = new ScopedValueCache(futureNullifierReads);
|
|
25
23
|
|
|
26
24
|
const nullifierIndexMap: Map<number, number> = new Map();
|
|
27
|
-
nullifiers.forEach((n, i) => nullifierIndexMap.set(n.counter, i));
|
|
25
|
+
nullifiers.getActiveItems().forEach((n, i) => nullifierIndexMap.set(n.counter, i));
|
|
28
26
|
|
|
29
27
|
const hints = [];
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const noteHash = noteHashes[noteHashIndex];
|
|
28
|
+
for (let noteHashIndex = 0; noteHashIndex < noteHashes.claimedLength; noteHashIndex++) {
|
|
29
|
+
const noteHash = noteHashes.array[noteHashIndex];
|
|
33
30
|
const noteHashNullifierCounter = noteHashNullifierCounterMap.get(noteHash.counter);
|
|
34
31
|
// The note hash might not be linked to a nullifier or it might be read in the future
|
|
35
32
|
if (
|
|
@@ -45,7 +42,7 @@ export function buildTransientDataHints<NOTE_HASHES_LEN extends number, NULLIFIE
|
|
|
45
42
|
continue;
|
|
46
43
|
}
|
|
47
44
|
|
|
48
|
-
const nullifier = nullifiers[nullifierIndex];
|
|
45
|
+
const nullifier = nullifiers.array[nullifierIndex];
|
|
49
46
|
// Cannot nullify a non-revertible note hash with a revertible nullifier.
|
|
50
47
|
if (noteHash.counter < validationRequestsSplitCounter && nullifier.counter >= validationRequestsSplitCounter) {
|
|
51
48
|
continue;
|
|
@@ -71,11 +68,12 @@ export function buildTransientDataHints<NOTE_HASHES_LEN extends number, NULLIFIE
|
|
|
71
68
|
continue;
|
|
72
69
|
}
|
|
73
70
|
|
|
74
|
-
hints.push(new
|
|
71
|
+
hints.push(new TransientDataSquashingHint(nullifierIndex, noteHashIndex));
|
|
75
72
|
}
|
|
76
73
|
|
|
74
|
+
const noActionHint = new TransientDataSquashingHint(nullifiers.array.length, noteHashes.array.length);
|
|
77
75
|
return {
|
|
78
76
|
numTransientData: hints.length,
|
|
79
|
-
hints: padArrayEnd(hints,
|
|
77
|
+
hints: padArrayEnd(hints, noActionHint, nullifiers.array.length as NULLIFIERS_LEN),
|
|
80
78
|
};
|
|
81
79
|
}
|
|
@@ -10,7 +10,6 @@ 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 './
|
|
14
|
-
export * from './transient_data_index_hint.js';
|
|
13
|
+
export * from './transient_data_squashing_hint.js';
|
|
15
14
|
export * from './private_kernel_reset_hints.js';
|
|
16
15
|
export * from './tree_leaf_read_request.js';
|
|
@@ -4,13 +4,7 @@ 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 {
|
|
8
|
-
PendingReadHint,
|
|
9
|
-
ReadRequestResetHints,
|
|
10
|
-
ReadRequestState,
|
|
11
|
-
ReadRequestStatus,
|
|
12
|
-
SettledReadHint,
|
|
13
|
-
} from './read_request_hints.js';
|
|
7
|
+
import { PendingReadHint, ReadRequestAction, ReadRequestResetHints, SettledReadHint } from './read_request_hints.js';
|
|
14
8
|
|
|
15
9
|
type NoteHashLeafValue = Fr;
|
|
16
10
|
|
|
@@ -47,7 +41,7 @@ export class NoteHashReadRequestHintsBuilder<PENDING extends number, SETTLED ext
|
|
|
47
41
|
public readonly maxSettled: SETTLED,
|
|
48
42
|
) {
|
|
49
43
|
this.hints = new ReadRequestResetHints(
|
|
50
|
-
makeTuple(MAX_NOTE_HASH_READ_REQUESTS_PER_TX,
|
|
44
|
+
makeTuple(MAX_NOTE_HASH_READ_REQUESTS_PER_TX, ReadRequestAction.skip),
|
|
51
45
|
makeTuple(maxPending, () => PendingReadHint.nada(MAX_NOTE_HASH_READ_REQUESTS_PER_TX)),
|
|
52
46
|
makeTuple(maxSettled, () =>
|
|
53
47
|
SettledReadHint.nada(MAX_NOTE_HASH_READ_REQUESTS_PER_TX, NOTE_HASH_TREE_HEIGHT, Fr.zero),
|
|
@@ -63,10 +57,7 @@ export class NoteHashReadRequestHintsBuilder<PENDING extends number, SETTLED ext
|
|
|
63
57
|
if (this.numPendingReadHints === this.maxPending) {
|
|
64
58
|
throw new Error('Cannot add more pending read request.');
|
|
65
59
|
}
|
|
66
|
-
this.hints.
|
|
67
|
-
ReadRequestState.PENDING,
|
|
68
|
-
this.numPendingReadHints,
|
|
69
|
-
);
|
|
60
|
+
this.hints.readRequestActions[readRequestIndex] = ReadRequestAction.readAsPending(this.numPendingReadHints);
|
|
70
61
|
this.hints.pendingReadHints[this.numPendingReadHints] = new PendingReadHint(readRequestIndex, noteHashIndex);
|
|
71
62
|
this.numPendingReadHints++;
|
|
72
63
|
}
|
|
@@ -79,10 +70,7 @@ export class NoteHashReadRequestHintsBuilder<PENDING extends number, SETTLED ext
|
|
|
79
70
|
if (this.numSettledReadHints === this.maxSettled) {
|
|
80
71
|
throw new Error('Cannot add more settled read request.');
|
|
81
72
|
}
|
|
82
|
-
this.hints.
|
|
83
|
-
ReadRequestState.SETTLED,
|
|
84
|
-
this.numSettledReadHints,
|
|
85
|
-
);
|
|
73
|
+
this.hints.readRequestActions[readRequestIndex] = ReadRequestAction.readAsSettled(this.numSettledReadHints);
|
|
86
74
|
this.hints.settledReadHints[this.numSettledReadHints] = new SettledReadHint(
|
|
87
75
|
readRequestIndex,
|
|
88
76
|
membershipWitness,
|
|
@@ -4,13 +4,7 @@ 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 {
|
|
8
|
-
PendingReadHint,
|
|
9
|
-
ReadRequestResetHints,
|
|
10
|
-
ReadRequestState,
|
|
11
|
-
ReadRequestStatus,
|
|
12
|
-
SettledReadHint,
|
|
13
|
-
} from './read_request_hints.js';
|
|
7
|
+
import { PendingReadHint, ReadRequestAction, ReadRequestResetHints, SettledReadHint } from './read_request_hints.js';
|
|
14
8
|
|
|
15
9
|
export type NullifierReadRequestHints<PENDING extends number, SETTLED extends number> = ReadRequestResetHints<
|
|
16
10
|
typeof MAX_NULLIFIER_READ_REQUESTS_PER_TX,
|
|
@@ -45,7 +39,7 @@ export class NullifierReadRequestHintsBuilder<PENDING extends number, SETTLED ex
|
|
|
45
39
|
public readonly maxSettled: SETTLED,
|
|
46
40
|
) {
|
|
47
41
|
this.hints = new ReadRequestResetHints(
|
|
48
|
-
makeTuple(MAX_NULLIFIER_READ_REQUESTS_PER_TX,
|
|
42
|
+
makeTuple(MAX_NULLIFIER_READ_REQUESTS_PER_TX, ReadRequestAction.skip),
|
|
49
43
|
makeTuple(maxPending, () => PendingReadHint.nada(MAX_NULLIFIER_READ_REQUESTS_PER_TX)),
|
|
50
44
|
makeTuple(maxSettled, () =>
|
|
51
45
|
SettledReadHint.nada(MAX_NULLIFIER_READ_REQUESTS_PER_TX, NULLIFIER_TREE_HEIGHT, NullifierLeafPreimage.empty),
|
|
@@ -62,10 +56,7 @@ export class NullifierReadRequestHintsBuilder<PENDING extends number, SETTLED ex
|
|
|
62
56
|
throw new Error('Cannot add more pending read request.');
|
|
63
57
|
}
|
|
64
58
|
|
|
65
|
-
this.hints.
|
|
66
|
-
ReadRequestState.PENDING,
|
|
67
|
-
this.numPendingReadHints,
|
|
68
|
-
);
|
|
59
|
+
this.hints.readRequestActions[readRequestIndex] = ReadRequestAction.readAsPending(this.numPendingReadHints);
|
|
69
60
|
this.hints.pendingReadHints[this.numPendingReadHints] = new PendingReadHint(readRequestIndex, nullifierIndex);
|
|
70
61
|
this.numPendingReadHints++;
|
|
71
62
|
}
|
|
@@ -78,10 +69,7 @@ export class NullifierReadRequestHintsBuilder<PENDING extends number, SETTLED ex
|
|
|
78
69
|
if (this.numSettledReadHints === this.maxSettled) {
|
|
79
70
|
throw new Error('Cannot add more settled read request.');
|
|
80
71
|
}
|
|
81
|
-
this.hints.
|
|
82
|
-
ReadRequestState.SETTLED,
|
|
83
|
-
this.numSettledReadHints,
|
|
84
|
-
);
|
|
72
|
+
this.hints.readRequestActions[readRequestIndex] = ReadRequestAction.readAsSettled(this.numSettledReadHints);
|
|
85
73
|
this.hints.settledReadHints[this.numSettledReadHints] = new SettledReadHint(
|
|
86
74
|
readRequestIndex,
|
|
87
75
|
membershipWitness,
|
|
@@ -3,7 +3,7 @@ import { BufferReader, type Tuple, serializeToBuffer } from '@aztec/foundation/s
|
|
|
3
3
|
import { KeyValidationHint } from './key_validation_hint.js';
|
|
4
4
|
import { type NoteHashReadRequestHints, noteHashReadRequestHintsFromBuffer } from './note_hash_read_request_hints.js';
|
|
5
5
|
import { type NullifierReadRequestHints, nullifierReadRequestHintsFromBuffer } from './nullifier_read_request_hints.js';
|
|
6
|
-
import {
|
|
6
|
+
import { TransientDataSquashingHint } from './transient_data_squashing_hint.js';
|
|
7
7
|
|
|
8
8
|
export class PrivateKernelResetHints<
|
|
9
9
|
NH_RR_PENDING extends number,
|
|
@@ -29,7 +29,7 @@ export class PrivateKernelResetHints<
|
|
|
29
29
|
/**
|
|
30
30
|
* Contains hints for the transient note hashes to locate corresponding nullifiers.
|
|
31
31
|
*/
|
|
32
|
-
public
|
|
32
|
+
public transientDataSquashingHints: Tuple<TransientDataSquashingHint, TRANSIENT_DATA_HINTS_LEN>,
|
|
33
33
|
/**
|
|
34
34
|
* The "final" minRevertibleSideEffectCounter of a tx, to split the data for squashing.
|
|
35
35
|
* Not the minRevertibleSideEffectCounter at the point the reset circuit is run.
|
|
@@ -42,7 +42,7 @@ export class PrivateKernelResetHints<
|
|
|
42
42
|
this.noteHashReadRequestHints,
|
|
43
43
|
this.nullifierReadRequestHints,
|
|
44
44
|
this.keyValidationHints,
|
|
45
|
-
this.
|
|
45
|
+
this.transientDataSquashingHints,
|
|
46
46
|
this.validationRequestsSplitCounter,
|
|
47
47
|
);
|
|
48
48
|
}
|
|
@@ -53,7 +53,7 @@ export class PrivateKernelResetHints<
|
|
|
53
53
|
numNullifierReadRequestPending: number,
|
|
54
54
|
numNullifierReadRequestSettled: number,
|
|
55
55
|
numKeyValidationHints: number,
|
|
56
|
-
|
|
56
|
+
numTransientDataSquashingHints: number,
|
|
57
57
|
) {
|
|
58
58
|
// Noir does not allow empty arrays. So we make the minimum array size 1.
|
|
59
59
|
// There is a constant for each dimension, coded in the circuit that indicates how many hints should be applied.
|
|
@@ -70,7 +70,7 @@ export class PrivateKernelResetHints<
|
|
|
70
70
|
useSize(numNullifierReadRequestSettled),
|
|
71
71
|
),
|
|
72
72
|
this.keyValidationHints.slice(0, useSize(numKeyValidationHints)),
|
|
73
|
-
this.
|
|
73
|
+
this.transientDataSquashingHints.slice(0, useSize(numTransientDataSquashingHints)),
|
|
74
74
|
this.validationRequestsSplitCounter,
|
|
75
75
|
);
|
|
76
76
|
}
|
|
@@ -93,7 +93,7 @@ export class PrivateKernelResetHints<
|
|
|
93
93
|
numNullifierReadRequestPending: NLL_RR_PENDING,
|
|
94
94
|
numNullifierReadRequestSettled: NLL_RR_SETTLED,
|
|
95
95
|
numKeyValidationHints: KEY_VALIDATION_HINTS_LEN,
|
|
96
|
-
|
|
96
|
+
numTransientDataSquashingHints: TRANSIENT_DATA_HINTS_LEN,
|
|
97
97
|
): PrivateKernelResetHints<
|
|
98
98
|
NH_RR_PENDING,
|
|
99
99
|
NH_RR_SETTLED,
|
|
@@ -113,7 +113,7 @@ export class PrivateKernelResetHints<
|
|
|
113
113
|
nullifierReadRequestHintsFromBuffer(buf, numNullifierReadRequestPending, numNullifierReadRequestSettled),
|
|
114
114
|
}),
|
|
115
115
|
reader.readArray(numKeyValidationHints, KeyValidationHint),
|
|
116
|
-
reader.readArray(
|
|
116
|
+
reader.readArray(numTransientDataSquashingHints, TransientDataSquashingHint),
|
|
117
117
|
reader.readNumber(),
|
|
118
118
|
);
|
|
119
119
|
}
|