@aztec/pxe 0.0.1-commit.e558bd1c → 0.0.1-commit.e5a3663dd
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/bin/check_oracle_version.js +4 -4
- package/dest/block_synchronizer/block_stream_source.d.ts +10 -0
- package/dest/block_synchronizer/block_stream_source.d.ts.map +1 -0
- package/dest/block_synchronizer/block_stream_source.js +37 -0
- package/dest/block_synchronizer/block_synchronizer.d.ts +6 -2
- package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
- package/dest/block_synchronizer/block_synchronizer.js +30 -10
- package/dest/config/index.d.ts +2 -2
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +8 -15
- package/dest/config/package_info.js +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.d.ts +62 -30
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +206 -76
- package/dest/contract_function_simulator/ephemeral_array_service.d.ts +28 -0
- package/dest/contract_function_simulator/ephemeral_array_service.d.ts.map +1 -0
- package/dest/contract_function_simulator/ephemeral_array_service.js +78 -0
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +7 -7
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -1
- package/dest/contract_function_simulator/execution_tagging_index_cache.js +19 -11
- package/dest/contract_function_simulator/index.d.ts +2 -1
- package/dest/contract_function_simulator/index.d.ts.map +1 -1
- package/dest/contract_function_simulator/index.js +1 -0
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +4 -6
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/event_validation_request.js +8 -10
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts +1 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.js +1 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +2 -2
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.js +2 -4
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +4 -7
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/note_validation_request.js +6 -11
- package/dest/contract_function_simulator/oracle/interfaces.d.ts +63 -45
- package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts +9 -0
- package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.js +47 -0
- package/dest/contract_function_simulator/oracle/oracle.d.ts +76 -44
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.js +289 -97
- package/dest/contract_function_simulator/oracle/private_execution.js +5 -3
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +58 -86
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +121 -95
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +124 -64
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +356 -126
- package/dest/contract_function_simulator/pick_notes.d.ts +1 -1
- package/dest/contract_function_simulator/pick_notes.d.ts.map +1 -1
- package/dest/contract_function_simulator/pick_notes.js +20 -3
- package/dest/contract_function_simulator/proxied_contract_data_source.d.ts +1 -1
- package/dest/contract_function_simulator/proxied_contract_data_source.d.ts.map +1 -1
- package/dest/contract_function_simulator/proxied_contract_data_source.js +3 -0
- package/dest/contract_logging.d.ts +27 -0
- package/dest/contract_logging.d.ts.map +1 -0
- package/dest/contract_logging.js +38 -0
- package/dest/contract_sync/contract_sync_service.d.ts +7 -4
- package/dest/contract_sync/contract_sync_service.d.ts.map +1 -1
- package/dest/contract_sync/contract_sync_service.js +69 -35
- package/dest/contract_sync/helpers.d.ts +2 -2
- package/dest/contract_sync/helpers.d.ts.map +1 -1
- package/dest/contract_sync/helpers.js +9 -4
- package/dest/debug/pxe_debug_utils.d.ts +5 -6
- package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
- package/dest/debug/pxe_debug_utils.js +4 -7
- package/dest/entrypoints/client/bundle/index.d.ts +3 -1
- package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/index.js +2 -0
- package/dest/entrypoints/client/bundle/utils.d.ts +2 -2
- package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/utils.js +11 -3
- package/dest/entrypoints/client/lazy/index.d.ts +3 -1
- package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/index.js +2 -0
- package/dest/entrypoints/client/lazy/utils.d.ts +2 -2
- package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/utils.js +11 -3
- package/dest/entrypoints/pxe_creation_options.d.ts +3 -1
- package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -1
- package/dest/entrypoints/pxe_creation_options.js +3 -1
- package/dest/entrypoints/server/index.d.ts +3 -2
- package/dest/entrypoints/server/index.d.ts.map +1 -1
- package/dest/entrypoints/server/index.js +2 -1
- package/dest/entrypoints/server/utils.d.ts +2 -2
- package/dest/entrypoints/server/utils.d.ts.map +1 -1
- package/dest/entrypoints/server/utils.js +11 -3
- package/dest/events/event_service.d.ts +3 -2
- package/dest/events/event_service.d.ts.map +1 -1
- package/dest/events/event_service.js +26 -5
- package/dest/events/private_event_filter_validator.d.ts +3 -2
- package/dest/events/private_event_filter_validator.d.ts.map +1 -1
- package/dest/events/private_event_filter_validator.js +15 -0
- package/dest/logs/log_service.d.ts +7 -7
- package/dest/logs/log_service.d.ts.map +1 -1
- package/dest/logs/log_service.js +33 -48
- package/dest/messages/message_context_service.d.ts +17 -0
- package/dest/messages/message_context_service.d.ts.map +1 -0
- package/dest/messages/message_context_service.js +36 -0
- package/dest/notes/note_service.d.ts +4 -4
- package/dest/notes/note_service.d.ts.map +1 -1
- package/dest/notes/note_service.js +17 -7
- package/dest/notes_filter.d.ts +24 -0
- package/dest/notes_filter.d.ts.map +1 -0
- package/dest/notes_filter.js +4 -0
- package/dest/oracle_version.d.ts +4 -3
- package/dest/oracle_version.d.ts.map +1 -1
- package/dest/oracle_version.js +20 -10
- package/dest/private_kernel/hints/compute_tx_expiration_timestamp.d.ts +4 -0
- package/dest/private_kernel/hints/compute_tx_expiration_timestamp.d.ts.map +1 -0
- package/dest/private_kernel/hints/{compute_tx_include_by_timestamp.js → compute_tx_expiration_timestamp.js} +12 -12
- package/dest/private_kernel/hints/index.d.ts +1 -1
- package/dest/private_kernel/hints/index.js +1 -1
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts +4 -3
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts.map +1 -1
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.js +129 -68
- package/dest/private_kernel/hints/test_utils.d.ts +122 -0
- package/dest/private_kernel/hints/test_utils.d.ts.map +1 -0
- package/dest/private_kernel/hints/test_utils.js +203 -0
- package/dest/private_kernel/private_kernel_execution_prover.d.ts +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.js +18 -13
- package/dest/private_kernel/private_kernel_oracle.d.ts +10 -6
- package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_oracle.js +19 -18
- package/dest/pxe.d.ts +84 -24
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +153 -83
- package/dest/storage/anchor_block_store/anchor_block_store.js +1 -1
- package/dest/storage/capsule_store/capsule_service.d.ts +21 -0
- package/dest/storage/capsule_store/capsule_service.d.ts.map +1 -0
- package/dest/storage/capsule_store/capsule_service.js +50 -0
- package/dest/storage/capsule_store/capsule_store.d.ts +9 -9
- package/dest/storage/capsule_store/capsule_store.d.ts.map +1 -1
- package/dest/storage/capsule_store/capsule_store.js +36 -28
- package/dest/storage/capsule_store/index.d.ts +2 -1
- package/dest/storage/capsule_store/index.d.ts.map +1 -1
- package/dest/storage/capsule_store/index.js +1 -0
- package/dest/storage/contract_store/contract_store.d.ts +42 -15
- package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
- package/dest/storage/contract_store/contract_store.js +148 -70
- package/dest/storage/metadata.d.ts +1 -1
- package/dest/storage/metadata.js +1 -1
- package/dest/storage/note_store/note_store.d.ts +3 -3
- package/dest/storage/note_store/note_store.d.ts.map +1 -1
- package/dest/storage/note_store/note_store.js +3 -4
- package/dest/storage/private_event_store/private_event_store.d.ts +1 -1
- package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -1
- package/dest/storage/private_event_store/private_event_store.js +3 -0
- package/dest/storage/private_event_store/stored_private_event.js +1 -1
- package/dest/storage/tagging_store/recipient_tagging_store.d.ts +6 -6
- package/dest/storage/tagging_store/recipient_tagging_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/sender_tagging_store.d.ts +29 -28
- package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/sender_tagging_store.js +141 -115
- package/dest/tagging/get_all_logs_by_tags.d.ts +1 -1
- package/dest/tagging/get_all_logs_by_tags.d.ts.map +1 -1
- package/dest/tagging/get_all_logs_by_tags.js +17 -3
- package/dest/tagging/index.d.ts +3 -3
- package/dest/tagging/index.d.ts.map +1 -1
- package/dest/tagging/index.js +1 -1
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +4 -5
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts.map +1 -1
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.js +8 -22
- package/dest/tagging/recipient_sync/utils/find_highest_indexes.js +2 -2
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts +6 -7
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts.map +1 -1
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.js +12 -11
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +4 -8
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -1
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +13 -7
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts +4 -3
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts.map +1 -1
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.js +20 -10
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +5 -7
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -1
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.js +36 -24
- package/package.json +16 -16
- package/src/bin/check_oracle_version.ts +4 -4
- package/src/block_synchronizer/block_stream_source.ts +52 -0
- package/src/block_synchronizer/block_synchronizer.ts +33 -11
- package/src/config/index.ts +3 -9
- package/src/config/package_info.ts +1 -1
- package/src/contract_function_simulator/contract_function_simulator.ts +366 -138
- package/src/contract_function_simulator/ephemeral_array_service.ts +110 -0
- package/src/contract_function_simulator/execution_tagging_index_cache.ts +19 -14
- package/src/contract_function_simulator/index.ts +1 -0
- package/src/contract_function_simulator/noir-structs/event_validation_request.ts +9 -9
- package/src/contract_function_simulator/noir-structs/log_retrieval_request.ts +1 -1
- package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +2 -5
- package/src/contract_function_simulator/noir-structs/note_validation_request.ts +4 -10
- package/src/contract_function_simulator/oracle/interfaces.ts +91 -53
- package/src/contract_function_simulator/oracle/legacy_oracle_mappings.ts +104 -0
- package/src/contract_function_simulator/oracle/oracle.ts +378 -140
- package/src/contract_function_simulator/oracle/private_execution.ts +4 -4
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +151 -183
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +598 -156
- package/src/contract_function_simulator/pick_notes.ts +22 -3
- package/src/contract_function_simulator/proxied_contract_data_source.ts +8 -1
- package/src/contract_logging.ts +52 -0
- package/src/contract_sync/contract_sync_service.ts +102 -55
- package/src/contract_sync/helpers.ts +8 -3
- package/src/debug/pxe_debug_utils.ts +11 -14
- package/src/entrypoints/client/bundle/index.ts +2 -0
- package/src/entrypoints/client/bundle/utils.ts +11 -4
- package/src/entrypoints/client/lazy/index.ts +2 -0
- package/src/entrypoints/client/lazy/utils.ts +11 -4
- package/src/entrypoints/pxe_creation_options.ts +7 -0
- package/src/entrypoints/server/index.ts +2 -1
- package/src/entrypoints/server/utils.ts +9 -10
- package/src/events/event_service.ts +30 -5
- package/src/events/private_event_filter_validator.ts +21 -1
- package/src/logs/log_service.ts +63 -91
- package/src/messages/message_context_service.ts +44 -0
- package/src/notes/note_service.ts +19 -8
- package/src/notes_filter.ts +24 -0
- package/src/oracle_version.ts +20 -10
- package/src/private_kernel/hints/{compute_tx_include_by_timestamp.ts → compute_tx_expiration_timestamp.ts} +13 -13
- package/src/private_kernel/hints/index.ts +1 -1
- package/src/private_kernel/hints/private_kernel_reset_private_inputs_builder.ts +164 -117
- package/src/private_kernel/hints/test_utils.ts +325 -0
- package/src/private_kernel/private_kernel_execution_prover.ts +18 -16
- package/src/private_kernel/private_kernel_oracle.ts +21 -21
- package/src/pxe.ts +278 -131
- package/src/storage/anchor_block_store/anchor_block_store.ts +1 -1
- package/src/storage/capsule_store/capsule_service.ts +90 -0
- package/src/storage/capsule_store/capsule_store.ts +44 -26
- package/src/storage/capsule_store/index.ts +1 -0
- package/src/storage/contract_store/contract_store.ts +181 -80
- package/src/storage/metadata.ts +1 -1
- package/src/storage/note_store/note_store.ts +5 -5
- package/src/storage/private_event_store/private_event_store.ts +4 -0
- package/src/storage/private_event_store/stored_private_event.ts +1 -1
- package/src/storage/tagging_store/recipient_tagging_store.ts +9 -5
- package/src/storage/tagging_store/sender_tagging_store.ts +185 -138
- package/src/tagging/get_all_logs_by_tags.ts +28 -4
- package/src/tagging/index.ts +2 -2
- package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +12 -25
- package/src/tagging/recipient_sync/utils/find_highest_indexes.ts +2 -2
- package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +10 -15
- package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +23 -10
- package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +26 -11
- package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +27 -26
- package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts +0 -4
- package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts.map +0 -1
|
@@ -85,9 +85,24 @@ interface ContainsNote {
|
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
const selectPropertyFromPackedNoteContent = (noteData: Fr[], selector: PropertySelector): Fr => {
|
|
88
|
+
if (selector.index >= noteData.length) {
|
|
89
|
+
throw new Error(`Property selector index ${selector.index} out of bounds for note with ${noteData.length} fields`);
|
|
90
|
+
}
|
|
91
|
+
if (selector.offset + selector.length > Fr.SIZE_IN_BYTES) {
|
|
92
|
+
throw new Error(
|
|
93
|
+
`Property selector range (offset=${selector.offset}, length=${selector.length}) exceeds Fr buffer size of ${Fr.SIZE_IN_BYTES} bytes`,
|
|
94
|
+
);
|
|
95
|
+
}
|
|
88
96
|
const noteValueBuffer = noteData[selector.index].toBuffer();
|
|
89
|
-
|
|
90
|
-
|
|
97
|
+
// Noir's PropertySelector counts offset from the LSB (last byte of the big-endian buffer),
|
|
98
|
+
// so offset=0,length=Fr.SIZE_IN_BYTES reads the entire field, and offset=0,length=1 reads the last byte.
|
|
99
|
+
const start = Fr.SIZE_IN_BYTES - selector.offset - selector.length;
|
|
100
|
+
const end = Fr.SIZE_IN_BYTES - selector.offset;
|
|
101
|
+
const noteValue = noteValueBuffer.subarray(start, end);
|
|
102
|
+
// Left-pad to Fr.SIZE_IN_BYTES so Fr.fromBuffer interprets the value correctly.
|
|
103
|
+
const padded = Buffer.alloc(Fr.SIZE_IN_BYTES);
|
|
104
|
+
noteValue.copy(padded, Fr.SIZE_IN_BYTES - noteValue.length);
|
|
105
|
+
return Fr.fromBuffer(padded);
|
|
91
106
|
};
|
|
92
107
|
|
|
93
108
|
const selectNotes = <T extends ContainsNote>(noteDatas: T[], selects: Select[]): T[] =>
|
|
@@ -103,7 +118,11 @@ const selectNotes = <T extends ContainsNote>(noteDatas: T[], selects: Select[]):
|
|
|
103
118
|
[Comparator.GTE]: () => !noteValueFr.lt(value),
|
|
104
119
|
};
|
|
105
120
|
|
|
106
|
-
|
|
121
|
+
const fn = comparatorSelector[comparator];
|
|
122
|
+
if (!fn) {
|
|
123
|
+
throw new Error(`Invalid comparator value: ${comparator}`);
|
|
124
|
+
}
|
|
125
|
+
return fn();
|
|
107
126
|
}),
|
|
108
127
|
);
|
|
109
128
|
|
|
@@ -29,6 +29,7 @@ export class ProxiedContractStoreFactory {
|
|
|
29
29
|
}
|
|
30
30
|
instance.currentContractClassId = realInstance.currentContractClassId;
|
|
31
31
|
instance.originalContractClassId = realInstance.originalContractClassId;
|
|
32
|
+
instance.initializationHash = realInstance.initializationHash;
|
|
32
33
|
return instance;
|
|
33
34
|
} else {
|
|
34
35
|
return target.getContractInstance(address);
|
|
@@ -47,6 +48,9 @@ export class ProxiedContractStoreFactory {
|
|
|
47
48
|
return fn;
|
|
48
49
|
}
|
|
49
50
|
}
|
|
51
|
+
throw new Error(
|
|
52
|
+
`Function with selector ${selector} not found in stub artifact for overridden contract at ${contractAddress}. The stub does not implement this function.`,
|
|
53
|
+
);
|
|
50
54
|
} else {
|
|
51
55
|
return target.getFunctionArtifact(contractAddress, selector);
|
|
52
56
|
}
|
|
@@ -64,6 +68,9 @@ export class ProxiedContractStoreFactory {
|
|
|
64
68
|
return fn;
|
|
65
69
|
}
|
|
66
70
|
}
|
|
71
|
+
throw new Error(
|
|
72
|
+
`Function with selector ${selector} not found in stub artifact for overridden contract at ${contractAddress}. The stub does not implement this function.`,
|
|
73
|
+
);
|
|
67
74
|
} else {
|
|
68
75
|
return target.getFunctionArtifactWithDebugMetadata(contractAddress, selector);
|
|
69
76
|
}
|
|
@@ -78,6 +85,6 @@ export class ProxiedContractStoreFactory {
|
|
|
78
85
|
}
|
|
79
86
|
}
|
|
80
87
|
},
|
|
81
|
-
});
|
|
88
|
+
}) satisfies ContractStore;
|
|
82
89
|
}
|
|
83
90
|
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
+
import { type LogLevel, type Logger, applyStringFormatting, createLogger } from '@aztec/foundation/log';
|
|
3
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
|
+
import type { DebugLog } from '@aztec/stdlib/logs';
|
|
5
|
+
|
|
6
|
+
/** Resolves a contract address to a human-readable name, if available. */
|
|
7
|
+
export type ContractNameResolver = (address: AztecAddress) => Promise<string | undefined>;
|
|
8
|
+
export type CONTRACT_LOG_KIND = 'aztecnr' | 'user';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Creates a logger whose output is prefixed with `contract:<name>(<addrAbbrev>)`.
|
|
12
|
+
*/
|
|
13
|
+
export async function createContractLogger(
|
|
14
|
+
contractAddress: AztecAddress,
|
|
15
|
+
getContractName: ContractNameResolver,
|
|
16
|
+
kind: CONTRACT_LOG_KIND,
|
|
17
|
+
options?: { instanceId?: string },
|
|
18
|
+
): Promise<Logger> {
|
|
19
|
+
const addrAbbrev = contractAddress.toString().slice(0, 10);
|
|
20
|
+
const name = await getContractName(contractAddress);
|
|
21
|
+
|
|
22
|
+
const prefix = kind == 'aztecnr' ? 'aztecnr' : 'contract';
|
|
23
|
+
const module = name ? `${prefix}:${name}(${addrAbbrev})` : `${prefix}:Unknown(${addrAbbrev})`;
|
|
24
|
+
return createLogger(module, options);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Formats and emits a single contract log message through the given logger.
|
|
29
|
+
*/
|
|
30
|
+
export function logContractMessage(logger: Logger, level: LogLevel, message: string, fields: Fr[]): void {
|
|
31
|
+
logger[level](applyStringFormatting(message, fields));
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Displays debug logs collected during public function simulation,
|
|
36
|
+
* using the `contract:` prefixed logger format.
|
|
37
|
+
*/
|
|
38
|
+
export async function displayDebugLogs(debugLogs: DebugLog[], getContractName: ContractNameResolver): Promise<void> {
|
|
39
|
+
for (const log of debugLogs) {
|
|
40
|
+
const { kind, message } = stripAztecnrLogPrefix(log.message);
|
|
41
|
+
const logger = await createContractLogger(log.contractAddress, getContractName, kind);
|
|
42
|
+
logContractMessage(logger, log.level, message, log.fields);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function stripAztecnrLogPrefix(message: string): { kind: CONTRACT_LOG_KIND; message: string } {
|
|
47
|
+
if (message.startsWith('[aztec-nr] ')) {
|
|
48
|
+
return { kind: 'aztecnr', message: message.slice('[aztec-nr] '.length) };
|
|
49
|
+
} else {
|
|
50
|
+
return { kind: 'user', message };
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Logger } from '@aztec/foundation/log';
|
|
2
|
+
import { Semaphore } from '@aztec/foundation/queue';
|
|
2
3
|
import type { FunctionCall, FunctionSelector } from '@aztec/stdlib/abi';
|
|
3
4
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
5
|
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
@@ -9,6 +10,9 @@ import type { ContractStore } from '../storage/contract_store/contract_store.js'
|
|
|
9
10
|
import type { NoteStore } from '../storage/note_store/note_store.js';
|
|
10
11
|
import { syncState, verifyCurrentClassId } from './helpers.js';
|
|
11
12
|
|
|
13
|
+
/** Maximum number of scope syncs running concurrently across the PXE. */
|
|
14
|
+
const MAX_CONCURRENT_SCOPE_SYNCS = 5;
|
|
15
|
+
|
|
12
16
|
/**
|
|
13
17
|
* Service for syncing the private state of contracts and verifying that the PXE holds the current class artifact.
|
|
14
18
|
* It uses a cache to avoid redundant sync operations - the cache is wiped when the anchor block changes.
|
|
@@ -18,12 +22,18 @@ import { syncState, verifyCurrentClassId } from './helpers.js';
|
|
|
18
22
|
export class ContractSyncService implements StagedStore {
|
|
19
23
|
readonly storeName = 'contract_sync';
|
|
20
24
|
|
|
21
|
-
// Tracks contracts synced since last wipe.
|
|
22
|
-
//
|
|
25
|
+
// Tracks contracts synced since last wipe. The cache is keyed per individual scope address
|
|
26
|
+
// (`contractAddress:scopeAddress`), or `contractAddress:*` for all scopes (all accounts).
|
|
27
|
+
// The value is a promise that resolves when the contract is synced.
|
|
23
28
|
private syncedContracts: Map<string, Promise<void>> = new Map();
|
|
24
29
|
|
|
25
|
-
// Per-job
|
|
26
|
-
private
|
|
30
|
+
// Per-job excluded contract addresses - these contracts should not be synced.
|
|
31
|
+
private excludedFromSync: Map<string, Set<string>> = new Map();
|
|
32
|
+
|
|
33
|
+
// Bounds the number of scope syncs running concurrently. Scopes beyond this limit queue here. Sized to trade off
|
|
34
|
+
// parallelism on non-ACIR work (node RPC, note store reads) against memory pressure from concurrent circuit
|
|
35
|
+
// execution.
|
|
36
|
+
#syncSlot = new Semaphore(MAX_CONCURRENT_SCOPE_SYNCS);
|
|
27
37
|
|
|
28
38
|
constructor(
|
|
29
39
|
private aztecNode: AztecNode,
|
|
@@ -33,8 +43,8 @@ export class ContractSyncService implements StagedStore {
|
|
|
33
43
|
) {}
|
|
34
44
|
|
|
35
45
|
/** Sets contracts that should be skipped during sync for a specific job. */
|
|
36
|
-
|
|
37
|
-
this.
|
|
46
|
+
setExcludedFromSync(jobId: string, addresses: Set<string>): void {
|
|
47
|
+
this.excludedFromSync.set(jobId, addresses);
|
|
38
48
|
}
|
|
39
49
|
|
|
40
50
|
/**
|
|
@@ -44,67 +54,47 @@ export class ContractSyncService implements StagedStore {
|
|
|
44
54
|
* @param functionToInvokeAfterSync - The function selector that will be called after sync (used to validate it's
|
|
45
55
|
* not sync_state itself).
|
|
46
56
|
* @param utilityExecutor - Executor function for running the sync_state utility function.
|
|
57
|
+
* @param scopes - Access scopes to pass through to the utility executor (affects whose account's private state is discovered).
|
|
47
58
|
*/
|
|
48
59
|
async ensureContractSynced(
|
|
49
60
|
contractAddress: AztecAddress,
|
|
50
61
|
functionToInvokeAfterSync: FunctionSelector | null,
|
|
51
|
-
utilityExecutor: (call: FunctionCall) => Promise<any>,
|
|
62
|
+
utilityExecutor: (call: FunctionCall, scopes: AztecAddress[]) => Promise<any>,
|
|
52
63
|
anchorBlockHeader: BlockHeader,
|
|
53
64
|
jobId: string,
|
|
65
|
+
scopes: AztecAddress[],
|
|
54
66
|
): Promise<void> {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
// Skip sync if this contract has an override for this job
|
|
58
|
-
const overrides = this.overriddenContracts.get(jobId);
|
|
59
|
-
if (overrides?.has(key)) {
|
|
67
|
+
if (this.#shouldSkipSync(jobId, contractAddress)) {
|
|
60
68
|
return;
|
|
61
69
|
}
|
|
62
70
|
|
|
63
|
-
|
|
64
|
-
if (existing) {
|
|
65
|
-
return existing;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
const syncPromise = this.#doSync(
|
|
71
|
+
this.#startSyncIfNeeded(
|
|
69
72
|
contractAddress,
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
73
|
+
scopes,
|
|
74
|
+
() => verifyCurrentClassId(contractAddress, this.aztecNode, this.contractStore, anchorBlockHeader),
|
|
75
|
+
scope =>
|
|
76
|
+
syncState(
|
|
77
|
+
contractAddress,
|
|
78
|
+
this.contractStore,
|
|
79
|
+
functionToInvokeAfterSync,
|
|
80
|
+
utilityExecutor,
|
|
81
|
+
this.noteStore,
|
|
82
|
+
this.aztecNode,
|
|
83
|
+
anchorBlockHeader,
|
|
84
|
+
jobId,
|
|
85
|
+
scope,
|
|
86
|
+
),
|
|
74
87
|
);
|
|
75
|
-
this.syncedContracts.set(key, syncPromise);
|
|
76
88
|
|
|
77
|
-
|
|
78
|
-
await syncPromise;
|
|
79
|
-
} catch (err) {
|
|
80
|
-
// There was an error syncing the contract, so we remove it from the cache so that it can be retried.
|
|
81
|
-
this.syncedContracts.delete(key);
|
|
82
|
-
throw err;
|
|
83
|
-
}
|
|
89
|
+
await this.#awaitSync(contractAddress, scopes);
|
|
84
90
|
}
|
|
85
91
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
): Promise<void> {
|
|
93
|
-
this.log.debug(`Syncing contract ${contractAddress}`);
|
|
94
|
-
await Promise.all([
|
|
95
|
-
syncState(
|
|
96
|
-
contractAddress,
|
|
97
|
-
this.contractStore,
|
|
98
|
-
functionToInvokeAfterSync,
|
|
99
|
-
utilityExecutor,
|
|
100
|
-
this.noteStore,
|
|
101
|
-
this.aztecNode,
|
|
102
|
-
anchorBlockHeader,
|
|
103
|
-
jobId,
|
|
104
|
-
),
|
|
105
|
-
verifyCurrentClassId(contractAddress, this.aztecNode, this.contractStore, anchorBlockHeader),
|
|
106
|
-
]);
|
|
107
|
-
this.log.debug(`Contract ${contractAddress} synced`);
|
|
92
|
+
/** Clears sync cache entries for the given scopes of a contract. */
|
|
93
|
+
invalidateContractForScopes(contractAddress: AztecAddress, scopes: AztecAddress[]): void {
|
|
94
|
+
if (scopes.length === 0) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
scopes.forEach(scope => this.syncedContracts.delete(toKey(contractAddress, scope)));
|
|
108
98
|
}
|
|
109
99
|
|
|
110
100
|
/** Clears sync cache. Called by BlockSynchronizer when anchor block changes. */
|
|
@@ -114,8 +104,8 @@ export class ContractSyncService implements StagedStore {
|
|
|
114
104
|
}
|
|
115
105
|
|
|
116
106
|
commit(jobId: string): Promise<void> {
|
|
117
|
-
// Clear
|
|
118
|
-
this.
|
|
107
|
+
// Clear excluded contracts for this job
|
|
108
|
+
this.excludedFromSync.delete(jobId);
|
|
119
109
|
return Promise.resolve();
|
|
120
110
|
}
|
|
121
111
|
|
|
@@ -123,7 +113,64 @@ export class ContractSyncService implements StagedStore {
|
|
|
123
113
|
// We clear the synced contracts cache here because, when the job is discarded, any associated database writes from
|
|
124
114
|
// the sync are also undone.
|
|
125
115
|
this.syncedContracts.clear();
|
|
126
|
-
this.
|
|
116
|
+
this.excludedFromSync.delete(jobId);
|
|
127
117
|
return Promise.resolve();
|
|
128
118
|
}
|
|
119
|
+
/** Returns true if sync should be skipped for this contract */
|
|
120
|
+
#shouldSkipSync(jobId: string, contractAddress: AztecAddress): boolean {
|
|
121
|
+
return !!this.excludedFromSync.get(jobId)?.has(contractAddress.toString());
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* If there are unsynced scopes, starts one sync per scope (bounded by #syncSlot) and stores each promise in the
|
|
126
|
+
* cache with per-scope error cleanup. The verifyFn runs once for the whole fan-out and is awaited by every new
|
|
127
|
+
* scope's promise, matching the pre-parallelization invariant that a cache-miss batch re-verifies the class id.
|
|
128
|
+
*/
|
|
129
|
+
#startSyncIfNeeded(
|
|
130
|
+
contractAddress: AztecAddress,
|
|
131
|
+
scopes: AztecAddress[],
|
|
132
|
+
verifyFn: () => Promise<void>,
|
|
133
|
+
syncScopeFn: (scope: AztecAddress) => Promise<void>,
|
|
134
|
+
): void {
|
|
135
|
+
const scopesToSync = scopes.filter(scope => !this.syncedContracts.has(toKey(contractAddress, scope)));
|
|
136
|
+
if (scopesToSync.length === 0) {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
this.log.debug(`Syncing contract ${contractAddress} for ${scopesToSync.length} scope(s)`);
|
|
141
|
+
const verifyPromise = verifyFn();
|
|
142
|
+
|
|
143
|
+
for (const scope of scopesToSync) {
|
|
144
|
+
const key = toKey(contractAddress, scope);
|
|
145
|
+
const promise = Promise.all([verifyPromise, this.#runBounded(() => syncScopeFn(scope))])
|
|
146
|
+
.then(() => {})
|
|
147
|
+
.catch(err => {
|
|
148
|
+
this.syncedContracts.delete(key);
|
|
149
|
+
throw err;
|
|
150
|
+
});
|
|
151
|
+
this.syncedContracts.set(key, promise);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/** Runs fn while holding a slot in #syncSlot, bounding total concurrent scope syncs. */
|
|
156
|
+
async #runBounded<T>(fn: () => Promise<T>): Promise<T> {
|
|
157
|
+
await this.#syncSlot.acquire();
|
|
158
|
+
try {
|
|
159
|
+
return await fn();
|
|
160
|
+
} finally {
|
|
161
|
+
this.#syncSlot.release();
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/** Collects all relevant scope promises (including in-flight ones from concurrent calls) and awaits them. */
|
|
166
|
+
async #awaitSync(contractAddress: AztecAddress, scopes: AztecAddress[]): Promise<void> {
|
|
167
|
+
const promises = scopes
|
|
168
|
+
.map(scope => this.syncedContracts.get(toKey(contractAddress, scope)))
|
|
169
|
+
.filter(p => p !== undefined);
|
|
170
|
+
await Promise.all(promises);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
function toKey(contract: AztecAddress, scope: AztecAddress) {
|
|
175
|
+
return `${contract.toString()}:${scope.toString()}`;
|
|
129
176
|
}
|
|
@@ -42,15 +42,16 @@ export async function syncState(
|
|
|
42
42
|
contractAddress: AztecAddress,
|
|
43
43
|
contractStore: ContractStore,
|
|
44
44
|
functionToInvokeAfterSync: FunctionSelector | null,
|
|
45
|
-
utilityExecutor: (privateSyncCall: FunctionCall) => Promise<any>,
|
|
45
|
+
utilityExecutor: (privateSyncCall: FunctionCall, scopes: AztecAddress[]) => Promise<any>,
|
|
46
46
|
noteStore: NoteStore,
|
|
47
47
|
aztecNode: AztecNode,
|
|
48
48
|
anchorBlockHeader: BlockHeader,
|
|
49
49
|
jobId: string,
|
|
50
|
+
scope: AztecAddress,
|
|
50
51
|
) {
|
|
51
52
|
// Protocol contracts don't have private state to sync
|
|
52
53
|
if (!isProtocolContract(contractAddress)) {
|
|
53
|
-
const syncStateFunctionCall = await contractStore.getFunctionCall('sync_state', [], contractAddress);
|
|
54
|
+
const syncStateFunctionCall = await contractStore.getFunctionCall('sync_state', [scope], contractAddress);
|
|
54
55
|
if (functionToInvokeAfterSync && functionToInvokeAfterSync.equals(syncStateFunctionCall.selector)) {
|
|
55
56
|
throw new Error(
|
|
56
57
|
'Forbidden `sync_state` invocation. `sync_state` can only be invoked by PXE, manual execution can lead to inconsistencies.',
|
|
@@ -58,10 +59,14 @@ export async function syncState(
|
|
|
58
59
|
}
|
|
59
60
|
|
|
60
61
|
const noteService = new NoteService(noteStore, aztecNode, anchorBlockHeader, jobId);
|
|
62
|
+
const scopes: AztecAddress[] = [scope];
|
|
61
63
|
|
|
62
64
|
// Both sync_state and syncNoteNullifiers interact with the note store, but running them in parallel is safe
|
|
63
65
|
// because note store is designed to handle concurrent operations.
|
|
64
|
-
await Promise.all([
|
|
66
|
+
await Promise.all([
|
|
67
|
+
utilityExecutor(syncStateFunctionCall, scopes),
|
|
68
|
+
noteService.syncNoteNullifiers(contractAddress, scopes),
|
|
69
|
+
]);
|
|
65
70
|
}
|
|
66
71
|
}
|
|
67
72
|
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import type { FunctionCall } from '@aztec/stdlib/abi';
|
|
2
2
|
import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
3
3
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
|
-
import type { NoteDao
|
|
5
|
-
import type {
|
|
4
|
+
import type { NoteDao } from '@aztec/stdlib/note';
|
|
5
|
+
import type { ContractOverrides } from '@aztec/stdlib/tx';
|
|
6
6
|
|
|
7
7
|
import type { BlockSynchronizer } from '../block_synchronizer/block_synchronizer.js';
|
|
8
8
|
import type { ContractFunctionSimulator } from '../contract_function_simulator/contract_function_simulator.js';
|
|
9
9
|
import type { ContractSyncService } from '../contract_sync/contract_sync_service.js';
|
|
10
|
+
import type { NotesFilter } from '../notes_filter.js';
|
|
10
11
|
import type { AnchorBlockStore } from '../storage/index.js';
|
|
11
12
|
import type { NoteStore } from '../storage/note_store/note_store.js';
|
|
12
13
|
|
|
@@ -17,11 +18,11 @@ import type { NoteStore } from '../storage/note_store/note_store.js';
|
|
|
17
18
|
export class PXEDebugUtils {
|
|
18
19
|
#putJobInQueue!: <T>(job: (jobId: string) => Promise<T>) => Promise<T>;
|
|
19
20
|
#getSimulatorForTx!: (overrides?: { contracts?: ContractOverrides }) => ContractFunctionSimulator;
|
|
20
|
-
#
|
|
21
|
+
#executeUtility!: (
|
|
21
22
|
contractFunctionSimulator: ContractFunctionSimulator,
|
|
22
23
|
call: FunctionCall,
|
|
23
24
|
authWitnesses: AuthWitness[] | undefined,
|
|
24
|
-
scopes: AztecAddress[]
|
|
25
|
+
scopes: AztecAddress[],
|
|
25
26
|
jobId: string,
|
|
26
27
|
) => Promise<any>;
|
|
27
28
|
|
|
@@ -36,17 +37,17 @@ export class PXEDebugUtils {
|
|
|
36
37
|
public setPXEHelpers(
|
|
37
38
|
putJobInQueue: <T>(job: (jobId: string) => Promise<T>) => Promise<T>,
|
|
38
39
|
getSimulatorForTx: (overrides?: { contracts?: ContractOverrides }) => ContractFunctionSimulator,
|
|
39
|
-
|
|
40
|
+
executeUtility: (
|
|
40
41
|
contractFunctionSimulator: ContractFunctionSimulator,
|
|
41
42
|
call: FunctionCall,
|
|
42
43
|
authWitnesses: AuthWitness[] | undefined,
|
|
43
|
-
scopes: AztecAddress[]
|
|
44
|
+
scopes: AztecAddress[],
|
|
44
45
|
jobId: string,
|
|
45
46
|
) => Promise<any>,
|
|
46
47
|
) {
|
|
47
48
|
this.#putJobInQueue = putJobInQueue;
|
|
48
49
|
this.#getSimulatorForTx = getSimulatorForTx;
|
|
49
|
-
this.#
|
|
50
|
+
this.#executeUtility = executeUtility;
|
|
50
51
|
}
|
|
51
52
|
|
|
52
53
|
/**
|
|
@@ -71,21 +72,17 @@ export class PXEDebugUtils {
|
|
|
71
72
|
await this.contractSyncService.ensureContractSynced(
|
|
72
73
|
filter.contractAddress,
|
|
73
74
|
null,
|
|
74
|
-
async privateSyncCall =>
|
|
75
|
-
await this.#
|
|
75
|
+
async (privateSyncCall, execScopes) =>
|
|
76
|
+
await this.#executeUtility(contractFunctionSimulator, privateSyncCall, [], execScopes, jobId),
|
|
76
77
|
anchorBlockHeader,
|
|
77
78
|
jobId,
|
|
79
|
+
filter.scopes,
|
|
78
80
|
);
|
|
79
81
|
|
|
80
82
|
return this.noteStore.getNotes(filter, jobId);
|
|
81
83
|
});
|
|
82
84
|
}
|
|
83
85
|
|
|
84
|
-
/** Returns the block header up to which the PXE has synced. */
|
|
85
|
-
public getSyncedBlockHeader(): Promise<BlockHeader> {
|
|
86
|
-
return this.anchorBlockStore.getBlockHeader();
|
|
87
|
-
}
|
|
88
|
-
|
|
89
86
|
/**
|
|
90
87
|
* Triggers a sync of the PXE with the node.
|
|
91
88
|
* Blocks until the sync is complete.
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
export * from '../../../notes_filter.js';
|
|
1
2
|
export * from '../../../pxe.js';
|
|
2
3
|
export * from '../../../config/index.js';
|
|
3
4
|
export * from '../../../error_enriching.js';
|
|
5
|
+
export * from '../../../contract_logging.js';
|
|
4
6
|
export * from '../../../storage/index.js';
|
|
5
7
|
export * from './utils.js';
|
|
6
8
|
export type { PXECreationOptions } from '../../pxe_creation_options.js';
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { BBPrivateKernelProver } from '@aztec/bb-prover/client';
|
|
2
1
|
import { BBBundlePrivateKernelProver } from '@aztec/bb-prover/client/bundle';
|
|
3
2
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
3
|
import { createStore } from '@aztec/kv-store/indexeddb';
|
|
@@ -9,7 +8,7 @@ import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
|
9
8
|
import type { PXEConfig } from '../../../config/index.js';
|
|
10
9
|
import { PXE } from '../../../pxe.js';
|
|
11
10
|
import { PXE_DATA_SCHEMA_VERSION } from '../../../storage/metadata.js';
|
|
12
|
-
import type
|
|
11
|
+
import { type PXECreationOptions, isPrivateKernelProver } from '../../pxe_creation_options.js';
|
|
13
12
|
|
|
14
13
|
/**
|
|
15
14
|
* Create and start an PXE instance with the given AztecNode.
|
|
@@ -44,7 +43,7 @@ export async function createPXE(
|
|
|
44
43
|
const proverLogger = loggers.prover ?? createLogger('pxe:bb:wasm:bundle', { actor });
|
|
45
44
|
|
|
46
45
|
let prover;
|
|
47
|
-
if (options.proverOrOptions
|
|
46
|
+
if (isPrivateKernelProver(options.proverOrOptions)) {
|
|
48
47
|
prover = options.proverOrOptions;
|
|
49
48
|
} else {
|
|
50
49
|
prover = new BBBundlePrivateKernelProver(simulator, { ...options.proverOrOptions, logger: proverLogger });
|
|
@@ -52,6 +51,14 @@ export async function createPXE(
|
|
|
52
51
|
const protocolContractsProvider = new BundledProtocolContractsProvider();
|
|
53
52
|
|
|
54
53
|
const pxeLogger = loggers.pxe ?? createLogger('pxe:service', { actor });
|
|
55
|
-
const pxe = await PXE.create(
|
|
54
|
+
const pxe = await PXE.create({
|
|
55
|
+
node: aztecNode,
|
|
56
|
+
store,
|
|
57
|
+
proofCreator: prover,
|
|
58
|
+
simulator,
|
|
59
|
+
protocolContractsProvider,
|
|
60
|
+
config,
|
|
61
|
+
loggerOrSuffix: pxeLogger,
|
|
62
|
+
});
|
|
56
63
|
return pxe;
|
|
57
64
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
export * from '../../../notes_filter.js';
|
|
1
2
|
export * from '../../../pxe.js';
|
|
2
3
|
export * from '../../../config/index.js';
|
|
3
4
|
export * from '../../../storage/index.js';
|
|
4
5
|
export * from '../../../error_enriching.js';
|
|
6
|
+
export * from '../../../contract_logging.js';
|
|
5
7
|
export * from './utils.js';
|
|
6
8
|
export { type PXECreationOptions } from '../../pxe_creation_options.js';
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { BBPrivateKernelProver } from '@aztec/bb-prover/client';
|
|
2
1
|
import { BBLazyPrivateKernelProver } from '@aztec/bb-prover/client/lazy';
|
|
3
2
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
3
|
import { createStore } from '@aztec/kv-store/indexeddb';
|
|
@@ -9,7 +8,7 @@ import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
|
9
8
|
import type { PXEConfig } from '../../../config/index.js';
|
|
10
9
|
import { PXE } from '../../../pxe.js';
|
|
11
10
|
import { PXE_DATA_SCHEMA_VERSION } from '../../../storage/metadata.js';
|
|
12
|
-
import type
|
|
11
|
+
import { type PXECreationOptions, isPrivateKernelProver } from '../../pxe_creation_options.js';
|
|
13
12
|
|
|
14
13
|
/**
|
|
15
14
|
* Create and start an PXE instance with the given AztecNode.
|
|
@@ -44,7 +43,7 @@ export async function createPXE(
|
|
|
44
43
|
const proverLogger = loggers.prover ?? createLogger('pxe:bb:wasm:bundle', { actor });
|
|
45
44
|
|
|
46
45
|
let prover;
|
|
47
|
-
if (options.proverOrOptions
|
|
46
|
+
if (isPrivateKernelProver(options.proverOrOptions)) {
|
|
48
47
|
prover = options.proverOrOptions;
|
|
49
48
|
} else {
|
|
50
49
|
prover = new BBLazyPrivateKernelProver(simulator, { ...options.proverOrOptions, logger: proverLogger });
|
|
@@ -52,6 +51,14 @@ export async function createPXE(
|
|
|
52
51
|
const protocolContractsProvider = new LazyProtocolContractsProvider();
|
|
53
52
|
|
|
54
53
|
const pxeLogger = loggers.pxe ?? createLogger('pxe:service', { actor });
|
|
55
|
-
const pxe = await PXE.create(
|
|
54
|
+
const pxe = await PXE.create({
|
|
55
|
+
node: aztecNode,
|
|
56
|
+
store,
|
|
57
|
+
proofCreator: prover,
|
|
58
|
+
simulator,
|
|
59
|
+
protocolContractsProvider,
|
|
60
|
+
config,
|
|
61
|
+
loggerOrSuffix: pxeLogger,
|
|
62
|
+
});
|
|
56
63
|
return pxe;
|
|
57
64
|
}
|
|
@@ -12,3 +12,10 @@ export type PXECreationOptions = {
|
|
|
12
12
|
store?: AztecAsyncKVStore;
|
|
13
13
|
simulator?: CircuitSimulator;
|
|
14
14
|
};
|
|
15
|
+
|
|
16
|
+
/** Checks if the given value implements the PrivateKernelProver interface via duck-typing. */
|
|
17
|
+
export function isPrivateKernelProver(value: unknown): value is PrivateKernelProver {
|
|
18
|
+
return (
|
|
19
|
+
typeof value === 'object' && value !== null && typeof (value as PrivateKernelProver).createChonkProof === 'function'
|
|
20
|
+
);
|
|
21
|
+
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
export * from '../../notes_filter.js';
|
|
1
2
|
export * from '../../pxe.js';
|
|
2
3
|
export * from '../../config/index.js';
|
|
3
4
|
export * from '../../error_enriching.js';
|
|
4
5
|
export * from '../../storage/index.js';
|
|
5
6
|
export * from './utils.js';
|
|
6
7
|
export { NoteService } from '../../notes/note_service.js';
|
|
7
|
-
export {
|
|
8
|
+
export { ORACLE_VERSION_MAJOR, ORACLE_VERSION_MINOR } from '../../oracle_version.js';
|
|
8
9
|
export { type PXECreationOptions } from '../pxe_creation_options.js';
|
|
9
10
|
export { JobCoordinator } from '../../job_coordinator/job_coordinator.js';
|
|
10
11
|
export { ContractSyncService } from '../../contract_sync/contract_sync_service.js';
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { BBPrivateKernelProver } from '@aztec/bb-prover/client';
|
|
2
1
|
import { BBBundlePrivateKernelProver } from '@aztec/bb-prover/client/bundle';
|
|
3
2
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
3
|
import { createStore } from '@aztec/kv-store/lmdb-v2';
|
|
@@ -10,7 +9,7 @@ import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
|
10
9
|
import type { PXEConfig } from '../../config/index.js';
|
|
11
10
|
import { PXE } from '../../pxe.js';
|
|
12
11
|
import { PXE_DATA_SCHEMA_VERSION } from '../../storage/index.js';
|
|
13
|
-
import type
|
|
12
|
+
import { type PXECreationOptions, isPrivateKernelProver } from '../pxe_creation_options.js';
|
|
14
13
|
|
|
15
14
|
type PXEConfigWithoutDefaults = Omit<PXEConfig, 'l1Contracts' | 'l1ChainId' | 'l2BlockBatchSize' | 'rollupVersion'>;
|
|
16
15
|
|
|
@@ -49,7 +48,7 @@ export async function createPXE(
|
|
|
49
48
|
const proverLogger = loggers.prover ?? createLogger('pxe:bb:native', { actor });
|
|
50
49
|
|
|
51
50
|
let prover;
|
|
52
|
-
if (options.proverOrOptions
|
|
51
|
+
if (isPrivateKernelProver(options.proverOrOptions)) {
|
|
53
52
|
prover = options.proverOrOptions;
|
|
54
53
|
} else {
|
|
55
54
|
prover = new BBBundlePrivateKernelProver(simulator, { ...options.proverOrOptions, logger: proverLogger });
|
|
@@ -58,14 +57,14 @@ export async function createPXE(
|
|
|
58
57
|
const protocolContractsProvider = new BundledProtocolContractsProvider();
|
|
59
58
|
|
|
60
59
|
const pxeLogger = loggers.pxe ?? createLogger('pxe:service', { actor });
|
|
61
|
-
const pxe = await PXE.create(
|
|
62
|
-
aztecNode,
|
|
63
|
-
options.store,
|
|
64
|
-
prover,
|
|
60
|
+
const pxe = await PXE.create({
|
|
61
|
+
node: aztecNode,
|
|
62
|
+
store: options.store,
|
|
63
|
+
proofCreator: prover,
|
|
65
64
|
simulator,
|
|
66
65
|
protocolContractsProvider,
|
|
67
|
-
configWithContracts,
|
|
68
|
-
pxeLogger,
|
|
69
|
-
);
|
|
66
|
+
config: configWithContracts,
|
|
67
|
+
loggerOrSuffix: pxeLogger,
|
|
68
|
+
});
|
|
70
69
|
return pxe;
|
|
71
70
|
}
|