@aztec/pxe 5.0.0-rc.2 → 5.0.0
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/block_synchronizer/block_synchronizer.d.ts +5 -3
- package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
- package/dest/block_synchronizer/block_synchronizer.js +7 -1
- package/dest/contract/contract_class_service.d.ts +31 -0
- package/dest/contract/contract_class_service.d.ts.map +1 -0
- package/dest/contract/contract_class_service.js +68 -0
- package/dest/{contract_sync → contract}/contract_sync_service.d.ts +7 -6
- package/dest/contract/contract_sync_service.d.ts.map +1 -0
- package/dest/{contract_sync → contract}/contract_sync_service.js +10 -30
- package/dest/contract/helpers.d.ts +7 -0
- package/dest/contract/helpers.d.ts.map +1 -0
- package/dest/contract/helpers.js +20 -0
- package/dest/contract_function_simulator/anchored_contract_data.d.ts +36 -0
- package/dest/contract_function_simulator/anchored_contract_data.d.ts.map +1 -0
- package/dest/contract_function_simulator/anchored_contract_data.js +54 -0
- package/dest/contract_function_simulator/aztec_node_read_cache.d.ts +39 -0
- package/dest/contract_function_simulator/aztec_node_read_cache.d.ts.map +1 -0
- package/dest/contract_function_simulator/aztec_node_read_cache.js +60 -0
- package/dest/contract_function_simulator/contract_function_simulator.d.ts +9 -3
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +31 -14
- package/dest/contract_function_simulator/execution_note_cache.d.ts +3 -9
- package/dest/contract_function_simulator/execution_note_cache.d.ts.map +1 -1
- package/dest/contract_function_simulator/execution_note_cache.js +8 -28
- package/dest/contract_function_simulator/index.d.ts +4 -2
- package/dest/contract_function_simulator/index.d.ts.map +1 -1
- package/dest/contract_function_simulator/index.js +2 -1
- package/dest/contract_function_simulator/noir-structs/fact.d.ts +5 -5
- package/dest/contract_function_simulator/noir-structs/fact.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/fact.js +2 -2
- package/dest/contract_function_simulator/noir-structs/fact_collection.d.ts +3 -3
- package/dest/contract_function_simulator/noir-structs/fact_collection.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/fact_collection.js +3 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +7 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/pending_tagged_log.d.ts +11 -0
- package/dest/contract_function_simulator/noir-structs/pending_tagged_log.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/pending_tagged_log.js +4 -0
- package/dest/contract_function_simulator/noir-structs/provided_secret.d.ts +2 -2
- package/dest/contract_function_simulator/noir-structs/provided_secret.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/provided_secret.js +1 -1
- package/dest/contract_function_simulator/noir-structs/resolved_tagging_strategy.d.ts +8 -1
- package/dest/contract_function_simulator/noir-structs/resolved_tagging_strategy.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/resolved_tagging_strategy.js +17 -0
- package/dest/contract_function_simulator/oracle/acir_callback.d.ts +7 -2
- package/dest/contract_function_simulator/oracle/acir_callback.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/acir_callback.js +55 -11
- package/dest/contract_function_simulator/oracle/legacy_oracle_registry.d.ts +39 -0
- package/dest/contract_function_simulator/oracle/legacy_oracle_registry.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/legacy_oracle_registry.js +107 -0
- package/dest/contract_function_simulator/oracle/oracle_registry.d.ts +10 -7
- package/dest/contract_function_simulator/oracle/oracle_registry.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle_registry.js +41 -10
- package/dest/contract_function_simulator/oracle/oracle_type_mappings.d.ts +48 -9
- package/dest/contract_function_simulator/oracle/oracle_type_mappings.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle_type_mappings.js +51 -30
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +10 -2
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +73 -32
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +20 -16
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +68 -47
- package/dest/debug/pxe_debug_utils.d.ts +2 -2
- package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/utils.js +2 -2
- package/dest/entrypoints/client/lazy/utils.js +2 -2
- package/dest/entrypoints/server/index.d.ts +5 -2
- package/dest/entrypoints/server/index.d.ts.map +1 -1
- package/dest/entrypoints/server/index.js +3 -1
- package/dest/error_enriching.d.ts +5 -3
- package/dest/error_enriching.d.ts.map +1 -1
- package/dest/error_enriching.js +12 -10
- package/dest/hooks/execution_hooks.d.ts +15 -4
- package/dest/hooks/execution_hooks.d.ts.map +1 -1
- package/dest/hooks/index.d.ts +3 -2
- package/dest/hooks/index.d.ts.map +1 -1
- package/dest/hooks/index.js +1 -0
- package/dest/hooks/resolve_custom_request.d.ts +23 -0
- package/dest/hooks/resolve_custom_request.d.ts.map +1 -0
- package/dest/hooks/resolve_custom_request.js +3 -0
- package/dest/hooks/resolve_tagging_secret_strategy.d.ts +10 -1
- package/dest/hooks/resolve_tagging_secret_strategy.d.ts.map +1 -1
- package/dest/hooks/resolve_tagging_secret_strategy.js +3 -3
- package/dest/logs/log_service.d.ts +3 -2
- package/dest/logs/log_service.d.ts.map +1 -1
- package/dest/logs/log_service.js +33 -16
- package/dest/oracle_version.d.ts +2 -2
- package/dest/oracle_version.js +2 -2
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts +1 -1
- 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 +6 -2
- 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 +17 -36
- package/dest/private_kernel/private_kernel_oracle.d.ts +4 -2
- package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_oracle.js +17 -5
- package/dest/pxe.d.ts +81 -46
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +135 -104
- package/dest/storage/backwards_compatibility_tests/schema_tests.d.ts +1 -1
- package/dest/storage/backwards_compatibility_tests/schema_tests.d.ts.map +1 -1
- package/dest/storage/backwards_compatibility_tests/schema_tests.js +31 -7
- package/dest/storage/contract_store/contract_store.d.ts +27 -24
- package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
- package/dest/storage/contract_store/contract_store.js +63 -74
- package/dest/storage/fact_store/fact_service.d.ts +6 -4
- package/dest/storage/fact_store/fact_service.d.ts.map +1 -1
- package/dest/storage/fact_store/fact_service.js +19 -4
- package/dest/storage/fact_store/fact_store.d.ts +1 -1
- package/dest/storage/fact_store/fact_store.js +1 -1
- package/dest/storage/fact_store/index.d.ts +2 -1
- package/dest/storage/fact_store/index.d.ts.map +1 -1
- package/dest/storage/fact_store/index.js +1 -0
- package/dest/storage/fact_store/origin_state.d.ts +57 -0
- package/dest/storage/fact_store/origin_state.d.ts.map +1 -0
- package/dest/storage/fact_store/origin_state.js +53 -0
- package/dest/storage/metadata.d.ts +2 -2
- package/dest/storage/metadata.d.ts.map +1 -1
- package/dest/storage/metadata.js +1 -1
- package/dest/storage/tagging_store/tagging_secret_sources_store.d.ts +17 -6
- package/dest/storage/tagging_store/tagging_secret_sources_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/tagging_secret_sources_store.js +24 -11
- package/dest/tagging/constants.d.ts +2 -2
- package/dest/tagging/constants.d.ts.map +1 -1
- package/dest/tagging/constants.js +18 -9
- package/package.json +17 -17
- package/src/block_synchronizer/block_synchronizer.ts +9 -1
- package/src/contract/contract_class_service.ts +83 -0
- package/src/{contract_sync → contract}/contract_sync_service.ts +18 -37
- package/src/contract/helpers.ts +35 -0
- package/src/contract_function_simulator/anchored_contract_data.ts +74 -0
- package/src/contract_function_simulator/aztec_node_read_cache.ts +89 -0
- package/src/contract_function_simulator/contract_function_simulator.ts +56 -14
- package/src/contract_function_simulator/execution_note_cache.ts +7 -28
- package/src/contract_function_simulator/index.ts +7 -1
- package/src/contract_function_simulator/noir-structs/fact.ts +4 -4
- package/src/contract_function_simulator/noir-structs/fact_collection.ts +9 -4
- package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +6 -0
- package/src/contract_function_simulator/noir-structs/pending_tagged_log.ts +12 -0
- package/src/contract_function_simulator/noir-structs/provided_secret.ts +1 -1
- package/src/contract_function_simulator/noir-structs/resolved_tagging_strategy.ts +21 -0
- package/src/contract_function_simulator/oracle/acir_callback.ts +58 -12
- package/src/contract_function_simulator/oracle/legacy_oracle_registry.ts +147 -0
- package/src/contract_function_simulator/oracle/oracle_registry.ts +32 -7
- package/src/contract_function_simulator/oracle/oracle_type_mappings.ts +49 -32
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +92 -41
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +104 -59
- package/src/debug/pxe_debug_utils.ts +1 -1
- package/src/entrypoints/client/bundle/utils.ts +2 -2
- package/src/entrypoints/client/lazy/utils.ts +2 -2
- package/src/entrypoints/server/index.ts +5 -1
- package/src/error_enriching.ts +26 -10
- package/src/hooks/execution_hooks.ts +14 -3
- package/src/hooks/index.ts +2 -0
- package/src/hooks/resolve_custom_request.ts +24 -0
- package/src/hooks/resolve_tagging_secret_strategy.ts +14 -0
- package/src/logs/log_service.ts +31 -11
- package/src/oracle_version.ts +2 -2
- package/src/private_kernel/hints/private_kernel_reset_private_inputs_builder.ts +11 -1
- package/src/private_kernel/private_kernel_execution_prover.ts +22 -52
- package/src/private_kernel/private_kernel_oracle.ts +23 -4
- package/src/pxe.ts +209 -143
- package/src/storage/backwards_compatibility_tests/__snapshots__/AddressStore.json +6 -6
- package/src/storage/backwards_compatibility_tests/__snapshots__/ContractStore.json +1 -1
- package/src/storage/backwards_compatibility_tests/__snapshots__/KeyStore.json +12 -12
- package/src/storage/backwards_compatibility_tests/__snapshots__/RecipientTaggingStore.json +11 -3
- package/src/storage/backwards_compatibility_tests/__snapshots__/SenderTaggingStore.json +12 -4
- package/src/storage/backwards_compatibility_tests/__snapshots__/TaggingSecretSourcesStore.json +3 -3
- package/src/storage/backwards_compatibility_tests/__snapshots__/opened_stores.json +1 -1
- package/src/storage/backwards_compatibility_tests/schema_tests.ts +38 -4
- package/src/storage/contract_store/contract_store.ts +85 -92
- package/src/storage/fact_store/fact_service.ts +29 -5
- package/src/storage/fact_store/fact_store.ts +1 -1
- package/src/storage/fact_store/index.ts +10 -0
- package/src/storage/fact_store/origin_state.ts +75 -0
- package/src/storage/metadata.ts +1 -1
- package/src/storage/tagging_store/tagging_secret_sources_store.ts +36 -15
- package/src/tagging/constants.ts +19 -9
- package/dest/contract_function_simulator/proxied_contract_data_source.d.ts +0 -6
- package/dest/contract_function_simulator/proxied_contract_data_source.d.ts.map +0 -1
- package/dest/contract_function_simulator/proxied_contract_data_source.js +0 -51
- package/dest/contract_sync/contract_sync_service.d.ts.map +0 -1
- package/dest/contract_sync/helpers.d.ts +0 -28
- package/dest/contract_sync/helpers.d.ts.map +0 -1
- package/dest/contract_sync/helpers.js +0 -48
- package/src/contract_function_simulator/proxied_contract_data_source.ts +0 -60
- package/src/contract_sync/helpers.ts +0 -79
package/dest/pxe.js
CHANGED
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
|
+
import { Point } from '@aztec/foundation/curves/grumpkin';
|
|
2
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
3
4
|
import { SerialQueue } from '@aztec/foundation/queue';
|
|
4
5
|
import { Timer } from '@aztec/foundation/timer';
|
|
5
6
|
import { protocolContractNames } from '@aztec/protocol-contracts';
|
|
6
7
|
import { FunctionType, decodeFunctionSignature } from '@aztec/stdlib/abi';
|
|
7
8
|
import { GENESIS_BLOCK_HEADER_HASH } from '@aztec/stdlib/block';
|
|
8
|
-
import { computeContractAddressFromInstance
|
|
9
|
+
import { computeContractAddressFromInstance } from '@aztec/stdlib/contract';
|
|
9
10
|
import { SimulationError } from '@aztec/stdlib/errors';
|
|
11
|
+
import { computeAddressSecret } from '@aztec/stdlib/keys';
|
|
12
|
+
import { deriveEcdhSharedSecretPoint } from '@aztec/stdlib/logs';
|
|
10
13
|
import { PrivateSimulationResult, TxProfileResult, TxProvingResult, TxSimulationResult } from '@aztec/stdlib/tx';
|
|
11
14
|
import { inspect } from 'util';
|
|
12
15
|
import { BlockSynchronizer } from './block_synchronizer/index.js';
|
|
16
|
+
import { ContractClassService } from './contract/contract_class_service.js';
|
|
17
|
+
import { ContractSyncService } from './contract/contract_sync_service.js';
|
|
13
18
|
import { BenchmarkedNodeFactory } from './contract_function_simulator/benchmarked_node.js';
|
|
14
19
|
import { ContractFunctionSimulator, generateSimulatedProvingResult } from './contract_function_simulator/contract_function_simulator.js';
|
|
15
|
-
import { ProxiedContractStoreFactory } from './contract_function_simulator/proxied_contract_data_source.js';
|
|
16
20
|
import { displayDebugLogs } from './contract_logging.js';
|
|
17
|
-
import { ContractSyncService } from './contract_sync/contract_sync_service.js';
|
|
18
|
-
import { readCurrentClassId } from './contract_sync/helpers.js';
|
|
19
21
|
import { PXEDebugUtils } from './debug/pxe_debug_utils.js';
|
|
20
22
|
import { enrichPublicSimulationError, enrichSimulationError } from './error_enriching.js';
|
|
21
23
|
import { PrivateEventFilterValidator } from './events/private_event_filter_validator.js';
|
|
@@ -45,6 +47,7 @@ import { persistSenderTaggingIndexRangesForTx } from './tagging/index.js';
|
|
|
45
47
|
addressStore;
|
|
46
48
|
privateEventStore;
|
|
47
49
|
contractSyncService;
|
|
50
|
+
contractClassService;
|
|
48
51
|
txResolver;
|
|
49
52
|
l2TipsStore;
|
|
50
53
|
simulator;
|
|
@@ -58,7 +61,7 @@ import { persistSenderTaggingIndexRangesForTx } from './tagging/index.js';
|
|
|
58
61
|
jobCoordinator;
|
|
59
62
|
debug;
|
|
60
63
|
hooks;
|
|
61
|
-
constructor(node, nodeDebug, db, blockStateSynchronizer, keyStore, contractStore, noteStore, capsuleStore, factStore, anchorBlockStore, senderTaggingStore, taggingSecretSourcesStore, recipientTaggingStore, addressStore, privateEventStore, contractSyncService, txResolver, l2TipsStore, simulator, proverEnabled, autoSync, proofCreator, protocolContractsProvider, preloadedContractsProvider, log, jobQueue, jobCoordinator, debug, hooks){
|
|
64
|
+
constructor(node, nodeDebug, db, blockStateSynchronizer, keyStore, contractStore, noteStore, capsuleStore, factStore, anchorBlockStore, senderTaggingStore, taggingSecretSourcesStore, recipientTaggingStore, addressStore, privateEventStore, contractSyncService, contractClassService, txResolver, l2TipsStore, simulator, proverEnabled, autoSync, proofCreator, protocolContractsProvider, preloadedContractsProvider, log, jobQueue, jobCoordinator, debug, hooks){
|
|
62
65
|
this.node = node;
|
|
63
66
|
this.nodeDebug = nodeDebug;
|
|
64
67
|
this.db = db;
|
|
@@ -75,6 +78,7 @@ import { persistSenderTaggingIndexRangesForTx } from './tagging/index.js';
|
|
|
75
78
|
this.addressStore = addressStore;
|
|
76
79
|
this.privateEventStore = privateEventStore;
|
|
77
80
|
this.contractSyncService = contractSyncService;
|
|
81
|
+
this.contractClassService = contractClassService;
|
|
78
82
|
this.txResolver = txResolver;
|
|
79
83
|
this.l2TipsStore = l2TipsStore;
|
|
80
84
|
this.simulator = simulator;
|
|
@@ -109,9 +113,10 @@ import { persistSenderTaggingIndexRangesForTx } from './tagging/index.js';
|
|
|
109
113
|
const initialBlockHash = (await node.getBlock(BlockNumber.ZERO))?.hash ?? GENESIS_BLOCK_HEADER_HASH;
|
|
110
114
|
const proverEnabled = config.proverEnabled !== undefined ? config.proverEnabled : info.realProofs;
|
|
111
115
|
const { addressStore, privateEventStore, contractStore, noteStore, anchorBlockStore, senderTaggingStore, taggingSecretSourcesStore, recipientTaggingStore, capsuleStore, keyStore, l2TipsStore, factStore } = openPxeStores(store, initialBlockHash);
|
|
112
|
-
const
|
|
116
|
+
const contractClassService = new ContractClassService(node, contractStore);
|
|
117
|
+
const contractSyncService = new ContractSyncService(node, contractStore, contractClassService, noteStore, createLogger('pxe:contract_sync', bindings));
|
|
113
118
|
const txResolver = new TxResolverService(node);
|
|
114
|
-
const synchronizer = new BlockSynchronizer(node, store, anchorBlockStore, noteStore, privateEventStore, factStore, l2TipsStore, contractSyncService, config, bindings);
|
|
119
|
+
const synchronizer = new BlockSynchronizer(node, store, anchorBlockStore, noteStore, privateEventStore, factStore, l2TipsStore, contractSyncService, contractClassService, config, bindings);
|
|
115
120
|
const jobCoordinator = new JobCoordinator(store, bindings);
|
|
116
121
|
jobCoordinator.registerStores([
|
|
117
122
|
capsuleStore,
|
|
@@ -124,7 +129,7 @@ import { persistSenderTaggingIndexRangesForTx } from './tagging/index.js';
|
|
|
124
129
|
]);
|
|
125
130
|
const debugUtils = new PXEDebugUtils(contractSyncService, noteStore, synchronizer, anchorBlockStore);
|
|
126
131
|
const jobQueue = new SerialQueue();
|
|
127
|
-
const pxe = new PXE(node, nodeDebug, store, synchronizer, keyStore, contractStore, noteStore, capsuleStore, factStore, anchorBlockStore, senderTaggingStore, taggingSecretSourcesStore, recipientTaggingStore, addressStore, privateEventStore, contractSyncService, txResolver, l2TipsStore, simulator, proverEnabled, config.autoSync, proofCreator, protocolContractsProvider, preloadedContractsProvider, log, jobQueue, jobCoordinator, debugUtils, hooks);
|
|
132
|
+
const pxe = new PXE(node, nodeDebug, store, synchronizer, keyStore, contractStore, noteStore, capsuleStore, factStore, anchorBlockStore, senderTaggingStore, taggingSecretSourcesStore, recipientTaggingStore, addressStore, privateEventStore, contractSyncService, contractClassService, txResolver, l2TipsStore, simulator, proverEnabled, config.autoSync, proofCreator, protocolContractsProvider, preloadedContractsProvider, log, jobQueue, jobCoordinator, debugUtils, hooks);
|
|
128
133
|
debugUtils.setPXEHelpers(pxe.#putInJobQueue.bind(pxe), pxe.#getSimulatorForTx.bind(pxe), pxe.#executeUtility.bind(pxe));
|
|
129
134
|
pxe.jobQueue.start();
|
|
130
135
|
await Promise.all([
|
|
@@ -136,9 +141,10 @@ import { persistSenderTaggingIndexRangesForTx } from './tagging/index.js';
|
|
|
136
141
|
}
|
|
137
142
|
// Internal methods
|
|
138
143
|
#getSimulatorForTx(overrides) {
|
|
139
|
-
const proxyContractStore = ProxiedContractStoreFactory.create(this.contractStore, overrides?.contracts);
|
|
140
144
|
return new ContractFunctionSimulator({
|
|
141
|
-
contractStore:
|
|
145
|
+
contractStore: this.contractStore,
|
|
146
|
+
contractClassService: this.contractClassService,
|
|
147
|
+
overrides: overrides?.contracts,
|
|
142
148
|
noteStore: this.noteStore,
|
|
143
149
|
keyStore: this.keyStore,
|
|
144
150
|
addressStore: this.addressStore,
|
|
@@ -156,6 +162,22 @@ import { persistSenderTaggingIndexRangesForTx } from './tagging/index.js';
|
|
|
156
162
|
hooks: this.hooks
|
|
157
163
|
});
|
|
158
164
|
}
|
|
165
|
+
/** Best-effort debug function name for the class `address` runs at `anchorBlockHeader`. Used for log display only. */ async #getDebugFunctionName(address, selector, anchorBlockHeader) {
|
|
166
|
+
try {
|
|
167
|
+
const classId = await this.contractClassService.getCurrentClassId(address, anchorBlockHeader);
|
|
168
|
+
return classId ? await this.contractStore.getDebugFunctionName(classId, selector) : `${address}:${selector}`;
|
|
169
|
+
} catch {
|
|
170
|
+
return `${address}:${selector}`;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
/** Best-effort debug contract name for the class `address` runs at `anchorBlockHeader`. Used for log display only. */ async #getDebugContractName(address, anchorBlockHeader) {
|
|
174
|
+
try {
|
|
175
|
+
const classId = await this.contractClassService.getCurrentClassId(address, anchorBlockHeader);
|
|
176
|
+
return classId ? await this.contractStore.getDebugContractName(classId) : undefined;
|
|
177
|
+
} catch {
|
|
178
|
+
return undefined;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
159
181
|
#contextualizeError(err, ...context) {
|
|
160
182
|
let contextStr = '';
|
|
161
183
|
if (context.length > 0) {
|
|
@@ -208,10 +230,12 @@ import { persistSenderTaggingIndexRangesForTx } from './tagging/index.js';
|
|
|
208
230
|
}
|
|
209
231
|
async #registerPreloadedContracts() {
|
|
210
232
|
const contracts = await this.preloadedContractsProvider.getPreloadedContracts();
|
|
211
|
-
await Promise.all(contracts.map(({ instance, artifact })=>
|
|
212
|
-
|
|
213
|
-
artifact
|
|
214
|
-
}
|
|
233
|
+
await Promise.all(contracts.map(async ({ instance, artifact })=>{
|
|
234
|
+
if (artifact) {
|
|
235
|
+
await this.registerContractClass(artifact);
|
|
236
|
+
}
|
|
237
|
+
await this.registerContract(instance);
|
|
238
|
+
}));
|
|
215
239
|
this.log.verbose(`Registered preloaded contracts in pxe`, {
|
|
216
240
|
contracts: contracts.map(({ instance })=>instance.address.toString())
|
|
217
241
|
});
|
|
@@ -232,7 +256,7 @@ import { persistSenderTaggingIndexRangesForTx } from './tagging/index.js';
|
|
|
232
256
|
return result;
|
|
233
257
|
} catch (err) {
|
|
234
258
|
if (err instanceof SimulationError) {
|
|
235
|
-
await enrichSimulationError(err, this.contractStore, this.log);
|
|
259
|
+
await enrichSimulationError(err, this.contractStore, this.contractClassService, anchorBlockHeader, this.log);
|
|
236
260
|
}
|
|
237
261
|
throw err;
|
|
238
262
|
}
|
|
@@ -256,7 +280,8 @@ import { persistSenderTaggingIndexRangesForTx } from './tagging/index.js';
|
|
|
256
280
|
};
|
|
257
281
|
} catch (err) {
|
|
258
282
|
if (err instanceof SimulationError) {
|
|
259
|
-
|
|
283
|
+
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
284
|
+
await enrichSimulationError(err, this.contractStore, this.contractClassService, anchorBlockHeader, this.log);
|
|
260
285
|
}
|
|
261
286
|
throw err;
|
|
262
287
|
}
|
|
@@ -278,7 +303,8 @@ import { persistSenderTaggingIndexRangesForTx } from './tagging/index.js';
|
|
|
278
303
|
} catch (err) {
|
|
279
304
|
if (err instanceof SimulationError) {
|
|
280
305
|
try {
|
|
281
|
-
|
|
306
|
+
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
307
|
+
await enrichPublicSimulationError(err, this.contractStore, this.contractClassService, anchorBlockHeader, this.log);
|
|
282
308
|
} catch (enrichErr) {
|
|
283
309
|
this.log.error(`Failed to enrich public simulation error: ${enrichErr}`);
|
|
284
310
|
}
|
|
@@ -297,7 +323,7 @@ import { persistSenderTaggingIndexRangesForTx } from './tagging/index.js';
|
|
|
297
323
|
* @param config - The configuration for the kernel execution prover.
|
|
298
324
|
* @returns An object that contains the output of the kernel execution, including the ChonkProof if proving is enabled.
|
|
299
325
|
*/ async #prove(txExecutionRequest, proofCreator, privateExecutionResult, anchorBlockHeader, config) {
|
|
300
|
-
const kernelOracle = new PrivateKernelOracle(this.contractStore, this.keyStore, this.node, anchorBlockHeader);
|
|
326
|
+
const kernelOracle = new PrivateKernelOracle(this.contractStore, this.contractClassService, this.keyStore, this.node, anchorBlockHeader);
|
|
301
327
|
const kernelTraceProver = new PrivateKernelExecutionProver(kernelOracle, proofCreator, !this.proverEnabled, this.log.getBindings());
|
|
302
328
|
this.log.debug(`Executing kernel trace prover (${JSON.stringify(config)})...`);
|
|
303
329
|
return await kernelTraceProver.proveWithKernels(txExecutionRequest.toTxRequest(), privateExecutionResult, config);
|
|
@@ -328,9 +354,9 @@ import { persistSenderTaggingIndexRangesForTx } from './tagging/index.js';
|
|
|
328
354
|
});
|
|
329
355
|
}
|
|
330
356
|
/**
|
|
331
|
-
* Returns the contract instance
|
|
357
|
+
* Returns the address preimage of the contract instance at a given address, if it's registered in the PXE.
|
|
332
358
|
* @param address - The contract address.
|
|
333
|
-
* @returns The contract instance if found, undefined otherwise.
|
|
359
|
+
* @returns The contract instance address preimage if found, undefined otherwise.
|
|
334
360
|
*/ getContractInstance(address) {
|
|
335
361
|
return this.contractStore.getContractInstance(address);
|
|
336
362
|
}
|
|
@@ -342,17 +368,21 @@ import { persistSenderTaggingIndexRangesForTx } from './tagging/index.js';
|
|
|
342
368
|
return await this.contractStore.getContractArtifact(id);
|
|
343
369
|
}
|
|
344
370
|
/**
|
|
345
|
-
* Registers a user account in PXE
|
|
346
|
-
*
|
|
347
|
-
* the
|
|
348
|
-
*
|
|
371
|
+
* Registers a user account in PXE.
|
|
372
|
+
*
|
|
373
|
+
* PXE holds the account's four privacy secret keys but only the *public* message-signing and fallback keys: their
|
|
374
|
+
* secret keys are withheld, since PXE is not trusted to hold them.
|
|
375
|
+
*
|
|
376
|
+
* Does nothing if the account is already registered.
|
|
349
377
|
*
|
|
350
|
-
*
|
|
378
|
+
* The four privacy secret keys can be retrieved later with {@link getAccountSecretKeys}.
|
|
379
|
+
*
|
|
380
|
+
* @param keys - The account's privacy keys: four secret keys plus the message-signing and fallback public keys.
|
|
351
381
|
* @param partialAddress - The partial address of the account contract corresponding to the account being registered.
|
|
352
382
|
* @returns The complete address of the account.
|
|
353
|
-
*/ async registerAccount(
|
|
383
|
+
*/ async registerAccount(keys, partialAddress) {
|
|
354
384
|
const accounts = await this.keyStore.getAccounts();
|
|
355
|
-
const accountCompleteAddress = await this.keyStore.addAccount(
|
|
385
|
+
const accountCompleteAddress = await this.keyStore.addAccount(keys, partialAddress);
|
|
356
386
|
if (accounts.some((a)=>a.equals(accountCompleteAddress.address))) {
|
|
357
387
|
this.log.info(`Account:\n "${accountCompleteAddress.address.toString()}"\n already registered.`);
|
|
358
388
|
return accountCompleteAddress;
|
|
@@ -364,6 +394,22 @@ import { persistSenderTaggingIndexRangesForTx } from './tagging/index.js';
|
|
|
364
394
|
return accountCompleteAddress;
|
|
365
395
|
}
|
|
366
396
|
/**
|
|
397
|
+
* Retrieves the four privacy secret keys PXE holds for a registered account (nullifier-hiding, incoming-viewing,
|
|
398
|
+
* outgoing-viewing, tagging).
|
|
399
|
+
*
|
|
400
|
+
* These do NOT grant control over an account's assets, e.g. they are insufficient to impersonate the account or to
|
|
401
|
+
* spend notes, but they _do_ guard the account's privacy. Parties that have knowledge of these keys can decrypt all
|
|
402
|
+
* messages sent to the account, discover all of their on-chain activity, including notes, events, etc.
|
|
403
|
+
*
|
|
404
|
+
* Security is paramount when handling these keys, which should itself be a very rare occurrence. Other than exporting
|
|
405
|
+
* and then importing an account into a separate PXE/wallet, there is typically no need for a wallet to ever access
|
|
406
|
+
* these keys. Applications should NEVER be given access to them.
|
|
407
|
+
*
|
|
408
|
+
* @throws If the account is not registered.
|
|
409
|
+
*/ getAccountSecretKeys(account) {
|
|
410
|
+
return this.keyStore.getAccountSecretKeys(account);
|
|
411
|
+
}
|
|
412
|
+
/**
|
|
367
413
|
* Registers a source from which this PXE derives the tagging secrets it scans for to discover incoming private logs.
|
|
368
414
|
* See {@link TaggingSecretSource} for the meaning of each variant. Does nothing if the source is already registered.
|
|
369
415
|
*
|
|
@@ -377,7 +423,10 @@ import { persistSenderTaggingIndexRangesForTx } from './tagging/index.js';
|
|
|
377
423
|
wasAdded = await this.#registerSender(source.sender);
|
|
378
424
|
break;
|
|
379
425
|
case 'arbitrary-secret':
|
|
380
|
-
wasAdded = await this.#
|
|
426
|
+
wasAdded = await this.#registerSharedSecret(source.recipient, 'arbitrary-secret', source.secret);
|
|
427
|
+
break;
|
|
428
|
+
case 'handshake':
|
|
429
|
+
wasAdded = await this.#registerSharedSecret(source.recipient, 'handshake', await this.#deriveHandshakeSecret(source.recipient, source.ephPk));
|
|
381
430
|
break;
|
|
382
431
|
default:
|
|
383
432
|
{
|
|
@@ -391,7 +440,8 @@ import { persistSenderTaggingIndexRangesForTx } from './tagging/index.js';
|
|
|
391
440
|
}
|
|
392
441
|
}
|
|
393
442
|
/**
|
|
394
|
-
* Removes a previously registered tagging secret source
|
|
443
|
+
* Removes a previously registered tagging secret source, identified by its registered form (see
|
|
444
|
+
* {@link getTaggingSecretSources}). Does nothing if it was not registered.
|
|
395
445
|
*/ async removeTaggingSecretSource(source) {
|
|
396
446
|
switch(source.kind){
|
|
397
447
|
case 'address-derived':
|
|
@@ -402,10 +452,11 @@ import { persistSenderTaggingIndexRangesForTx } from './tagging/index.js';
|
|
|
402
452
|
break;
|
|
403
453
|
}
|
|
404
454
|
case 'arbitrary-secret':
|
|
455
|
+
case 'handshake':
|
|
405
456
|
{
|
|
406
|
-
const { recipient, secret } = source;
|
|
407
|
-
const wasRemoved = await this.taggingSecretSourcesStore.removeSharedSecret(recipient, secret);
|
|
408
|
-
this.log.info(wasRemoved ? `Removed shared secret for recipient:\n ${recipient.toString()}` : `
|
|
457
|
+
const { kind, recipient, secret } = source;
|
|
458
|
+
const wasRemoved = await this.taggingSecretSourcesStore.removeSharedSecret(recipient, kind, secret);
|
|
459
|
+
this.log.info(wasRemoved ? `Removed ${kind} shared secret for recipient:\n ${recipient.toString()}` : `No ${kind} shared secret registered for recipient:\n ${recipient.toString()}`);
|
|
409
460
|
break;
|
|
410
461
|
}
|
|
411
462
|
default:
|
|
@@ -425,8 +476,8 @@ import { persistSenderTaggingIndexRangesForTx } from './tagging/index.js';
|
|
|
425
476
|
kind: 'address-derived',
|
|
426
477
|
sender
|
|
427
478
|
})),
|
|
428
|
-
...secrets.map(({ recipient, secret })=>({
|
|
429
|
-
kind
|
|
479
|
+
...secrets.map(({ recipient, kind, secret })=>({
|
|
480
|
+
kind,
|
|
430
481
|
recipient,
|
|
431
482
|
secret
|
|
432
483
|
}))
|
|
@@ -446,15 +497,37 @@ import { persistSenderTaggingIndexRangesForTx } from './tagging/index.js';
|
|
|
446
497
|
this.log.info(wasAdded ? `Added sender:\n ${address.toString()}` : `Sender:\n "${address.toString()}"\n already registered.`);
|
|
447
498
|
return wasAdded;
|
|
448
499
|
}
|
|
449
|
-
/**
|
|
500
|
+
/**
|
|
501
|
+
* Derives the shared secret of a handshake from its ephemeral public key: `S = addressSecret(recipient) * ephPk`,
|
|
502
|
+
* the same derivation the recipient-side scan uses for handshakes discovered onchain. The ephemeral key is
|
|
503
|
+
* reconstructed from its x-coordinate with a positive y, matching how the protocol generates it.
|
|
504
|
+
*
|
|
505
|
+
* @throws If `ephPk` is not the x-coordinate of a Grumpkin curve point, or if `recipient` is not an account of
|
|
506
|
+
* this PXE, since the derivation needs its keys.
|
|
507
|
+
*/ async #deriveHandshakeSecret(recipient, ephPk) {
|
|
508
|
+
let ephPkPoint;
|
|
509
|
+
try {
|
|
510
|
+
ephPkPoint = await Point.fromXAndSign(ephPk, true);
|
|
511
|
+
} catch {
|
|
512
|
+
throw new Error(`Ephemeral public key x-coordinate ${ephPk} does not correspond to a Grumpkin curve point.`);
|
|
513
|
+
}
|
|
514
|
+
const completeAddress = await this.addressStore.getCompleteAddress(recipient);
|
|
515
|
+
if (!completeAddress || !await this.keyStore.hasAccount(recipient)) {
|
|
516
|
+
throw new Error(`Recipient ${recipient} is not an account of this PXE. A handshake's shared secret can only be derived for an account whose keys are held.`);
|
|
517
|
+
}
|
|
518
|
+
const ivskM = await this.keyStore.getMasterIncomingViewingSecretKey(recipient);
|
|
519
|
+
const addressSecret = await computeAddressSecret(await completeAddress.getPreaddress(), ivskM);
|
|
520
|
+
return deriveEcdhSharedSecretPoint(addressSecret, ephPkPoint);
|
|
521
|
+
}
|
|
522
|
+
/** Registers a resolved shared secret scoped to a recipient. Returns whether it was newly added. */ async #registerSharedSecret(recipient, kind, secret) {
|
|
450
523
|
if (!await recipient.isValid()) {
|
|
451
524
|
throw new Error(`Recipient ${recipient} is not valid: it does not correspond to a point on the Grumpkin curve. Cannot register a shared secret for it.`);
|
|
452
525
|
}
|
|
453
526
|
if (secret.isZero() || !secret.isOnCurve()) {
|
|
454
527
|
throw new Error(`Shared secret ${secret} is not a valid non-zero point on the Grumpkin curve.`);
|
|
455
528
|
}
|
|
456
|
-
const wasAdded = await this.taggingSecretSourcesStore.addSharedSecret(recipient, secret);
|
|
457
|
-
this.log.info(wasAdded ? `Added shared secret for recipient:\n ${recipient.toString()}` :
|
|
529
|
+
const wasAdded = await this.taggingSecretSourcesStore.addSharedSecret(recipient, kind, secret);
|
|
530
|
+
this.log.info(wasAdded ? `Added ${kind} shared secret for recipient:\n ${recipient.toString()}` : `${kind} shared secret already registered for recipient:\n ${recipient.toString()}`);
|
|
458
531
|
return wasAdded;
|
|
459
532
|
}
|
|
460
533
|
/**
|
|
@@ -473,76 +546,34 @@ import { persistSenderTaggingIndexRangesForTx } from './tagging/index.js';
|
|
|
473
546
|
* @param artifact - The build artifact for the contract class.
|
|
474
547
|
*/ async registerContractClass(artifact) {
|
|
475
548
|
const contractClassId = await this.contractStore.addContractArtifact(artifact);
|
|
549
|
+
// Publishing the artifact's public function signatures to the node is part of "registering a class", so that
|
|
550
|
+
// node-side debugging works regardless of which entrypoint (registerContractClass or registerContract) was used.
|
|
551
|
+
const publicFunctionSignatures = artifact.functions.filter((fn)=>fn.functionType === FunctionType.PUBLIC).map((fn)=>decodeFunctionSignature(fn.name, fn.parameters));
|
|
552
|
+
if (publicFunctionSignatures.length > 0) {
|
|
553
|
+
await this.nodeDebug?.registerContractFunctionSignatures(publicFunctionSignatures);
|
|
554
|
+
}
|
|
476
555
|
this.log.info(`Added contract class ${artifact.name} with id ${contractClassId}`);
|
|
477
556
|
}
|
|
478
557
|
/**
|
|
479
|
-
*
|
|
480
|
-
*
|
|
481
|
-
*
|
|
482
|
-
*
|
|
558
|
+
* Registers a deployed contract instance so its private state can be synced and its functions simulated. The
|
|
559
|
+
* artifact for the class the instance runs must be registered separately via {@link registerContractClass}, before
|
|
560
|
+
* or after this call; registration performs no validation, so a missing or mismatched artifact only surfaces when
|
|
561
|
+
* the contract is later simulated. This is automatically called by aztec.js when deploying a contract.
|
|
483
562
|
*
|
|
484
|
-
* @param
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
if (artifact) {
|
|
489
|
-
// If the user provides an artifact, validate it against the expected class id and register it
|
|
490
|
-
const contractClass = await getContractClassFromArtifact(artifact);
|
|
491
|
-
if (!contractClass.id.equals(instance.currentContractClassId)) {
|
|
492
|
-
throw new Error(`Artifact does not match expected class id (computed ${contractClass.id} but instance refers to ${instance.currentContractClassId})`);
|
|
493
|
-
}
|
|
494
|
-
const computedAddress = await computeContractAddressFromInstance(instance);
|
|
495
|
-
if (!computedAddress.equals(instance.address)) {
|
|
496
|
-
throw new Error('Added a contract in which the address does not match the contract instance.');
|
|
497
|
-
}
|
|
498
|
-
await this.contractStore.addContractArtifact(artifact, contractClass);
|
|
499
|
-
const publicFunctionSignatures = artifact.functions.filter((fn)=>fn.functionType === FunctionType.PUBLIC).map((fn)=>decodeFunctionSignature(fn.name, fn.parameters));
|
|
500
|
-
if (publicFunctionSignatures.length > 0) {
|
|
501
|
-
await this.nodeDebug?.registerContractFunctionSignatures(publicFunctionSignatures);
|
|
502
|
-
}
|
|
503
|
-
} else {
|
|
504
|
-
// Otherwise, make sure there is an artifact already registered for that class id
|
|
505
|
-
artifact = await this.contractStore.getContractArtifact(instance.currentContractClassId);
|
|
506
|
-
if (!artifact) {
|
|
507
|
-
throw new Error(`Artifact not found when registering an instance. Contract class: ${instance.currentContractClassId}.`);
|
|
508
|
-
}
|
|
509
|
-
}
|
|
510
|
-
await this.contractStore.addContractInstance(instance);
|
|
511
|
-
this.log.info(`Added contract ${artifact.name} at ${instance.address.toString()} with class ${instance.currentContractClassId}`);
|
|
512
|
-
}
|
|
513
|
-
/**
|
|
514
|
-
* Updates a deployed contract in the PXE. This is used to update the contract artifact when
|
|
515
|
-
* an update has happened, so the new code can be used in the simulation of local transactions.
|
|
516
|
-
* This is called by aztec.js when instantiating a contract in a given address with a mismatching artifact.
|
|
517
|
-
* @param contractAddress - The address of the contract to update.
|
|
518
|
-
* @param artifact - The updated artifact for the contract.
|
|
519
|
-
* @throws If the artifact's contract class is not found in the PXE or if the contract class is different from
|
|
520
|
-
* the current one (current one from the point of view of the node to which the PXE is connected).
|
|
521
|
-
*/ updateContract(contractAddress, artifact) {
|
|
522
|
-
// We disable concurrently updating contracts to avoid concurrently syncing with the node, or changing a contract's
|
|
523
|
-
// class while we're simulating it.
|
|
563
|
+
* @param instance - The address preimage of the contract instance to register. The address is derived from it.
|
|
564
|
+
* @returns The address of the registered instance.
|
|
565
|
+
*/ registerContract(instance) {
|
|
566
|
+
// Run inside the job queue so we can't race a concurrent simulation while writing the instance to the store.
|
|
524
567
|
return this.#putInJobQueue(async ()=>{
|
|
525
|
-
const
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
throw new Error('Could not update contract to a class different from the current one.');
|
|
535
|
-
}
|
|
536
|
-
const publicFunctionSignatures = artifact.functions.filter((fn)=>fn.functionType === FunctionType.PUBLIC).map((fn)=>decodeFunctionSignature(fn.name, fn.parameters));
|
|
537
|
-
if (publicFunctionSignatures.length > 0) {
|
|
538
|
-
await this.nodeDebug?.registerContractFunctionSignatures(publicFunctionSignatures);
|
|
539
|
-
}
|
|
540
|
-
currentInstance.currentContractClassId = contractClass.id;
|
|
541
|
-
await Promise.all([
|
|
542
|
-
this.contractStore.addContractArtifact(artifact, contractClass),
|
|
543
|
-
this.contractStore.addContractInstance(currentInstance)
|
|
544
|
-
]);
|
|
545
|
-
this.log.info(`Updated contract ${artifact.name} at ${contractAddress.toString()} to class ${contractClass.id}`);
|
|
568
|
+
const address = await computeContractAddressFromInstance(instance);
|
|
569
|
+
await this.contractStore.addContractInstance({
|
|
570
|
+
...instance,
|
|
571
|
+
address
|
|
572
|
+
});
|
|
573
|
+
this.log.info(`Added contract at ${address}`, {
|
|
574
|
+
address
|
|
575
|
+
});
|
|
576
|
+
return address;
|
|
546
577
|
});
|
|
547
578
|
}
|
|
548
579
|
/**
|
|
@@ -736,7 +767,7 @@ import { persistSenderTaggingIndexRangesForTx } from './tagging/index.js';
|
|
|
736
767
|
let publicInputs;
|
|
737
768
|
let executionSteps = [];
|
|
738
769
|
if (skipKernels) {
|
|
739
|
-
({ publicInputs, executionSteps } = await generateSimulatedProvingResult(privateExecutionResult, (addr, sel)=>this
|
|
770
|
+
({ publicInputs, executionSteps } = await generateSimulatedProvingResult(privateExecutionResult, (addr, sel)=>this.#getDebugFunctionName(addr, sel, anchorBlockHeader), this.node));
|
|
740
771
|
} else {
|
|
741
772
|
// Kernel logic, plus proving of all private functions and kernels.
|
|
742
773
|
({ publicInputs, executionSteps } = await this.#prove(txRequest, this.proofCreator, privateExecutionResult, anchorBlockHeader, {
|
|
@@ -754,7 +785,7 @@ import { persistSenderTaggingIndexRangesForTx } from './tagging/index.js';
|
|
|
754
785
|
publicOutput = await this.#simulatePublicCalls(simulatedTx, skipFeeEnforcement, overrides);
|
|
755
786
|
publicSimulationTime = publicSimulationTimer.ms();
|
|
756
787
|
if (publicOutput?.debugLogs?.length) {
|
|
757
|
-
await displayDebugLogs(publicOutput.debugLogs, (addr)=>this
|
|
788
|
+
await displayDebugLogs(publicOutput.debugLogs, (addr)=>this.#getDebugContractName(addr, anchorBlockHeader));
|
|
758
789
|
}
|
|
759
790
|
}
|
|
760
791
|
let validationTime;
|
|
@@ -12,4 +12,4 @@ export type SchemaTest = {
|
|
|
12
12
|
snapshotStore: (kvStore: AztecAsyncKVStore) => Promise<Record<string, unknown>>;
|
|
13
13
|
};
|
|
14
14
|
export declare const SCHEMA_TESTS: readonly SchemaTest[];
|
|
15
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
15
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2NoZW1hX3Rlc3RzLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvc3RvcmFnZS9iYWNrd2FyZHNfY29tcGF0aWJpbGl0eV90ZXN0cy9zY2hlbWFfdGVzdHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBUUEsT0FBTyxLQUFLLEVBQUUsaUJBQWlCLEVBQUUsTUFBTSxpQkFBaUIsQ0FBQztBQTBDekQ7Ozs7OztHQU1HO0FBQ0gsTUFBTSxNQUFNLFVBQVUsR0FBRztJQUN2QixJQUFJLEVBQUUsTUFBTSxDQUFDO0lBQ2IsWUFBWSxFQUFFLENBQUMsT0FBTyxFQUFFLGlCQUFpQixLQUFLLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FBQztJQUM1RCxhQUFhLEVBQUUsQ0FBQyxPQUFPLEVBQUUsaUJBQWlCLEtBQUssT0FBTyxDQUFDLE1BQU0sQ0FBQyxNQUFNLEVBQUUsT0FBTyxDQUFDLENBQUMsQ0FBQztDQUNqRixDQUFDO0FBRUYsZUFBTyxNQUFNLFlBQVksRUFBRSxTQUFTLFVBQVUsRUEybEI3QyxDQUFDIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema_tests.d.ts","sourceRoot":"","sources":["../../../src/storage/backwards_compatibility_tests/schema_tests.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"schema_tests.d.ts","sourceRoot":"","sources":["../../../src/storage/backwards_compatibility_tests/schema_tests.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AA0CzD;;;;;;GAMG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,CAAC,OAAO,EAAE,iBAAiB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5D,aAAa,EAAE,CAAC,OAAO,EAAE,iBAAiB,KAAK,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CACjF,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,SAAS,UAAU,EA2lB7C,CAAC"}
|
|
@@ -12,8 +12,8 @@ import { BlockHash, Body, GENESIS_BLOCK_HEADER_HASH, L2Block } from '@aztec/stdl
|
|
|
12
12
|
import { Checkpoint, L1PublishedData, PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
|
|
13
13
|
import { CompleteAddress, SerializableContractInstance } from '@aztec/stdlib/contract';
|
|
14
14
|
import { GasFees } from '@aztec/stdlib/gas';
|
|
15
|
-
import { PublicKey, PublicKeys } from '@aztec/stdlib/keys';
|
|
16
|
-
import { AppTaggingSecret, ContractClassLog, ContractClassLogFields, PrivateLog, PublicLog } from '@aztec/stdlib/logs';
|
|
15
|
+
import { PublicKey, PublicKeys, deriveKeys } from '@aztec/stdlib/keys';
|
|
16
|
+
import { AppTaggingSecret, AppTaggingSecretKind, ContractClassLog, ContractClassLogFields, PrivateLog, PublicLog } from '@aztec/stdlib/logs';
|
|
17
17
|
import { Note, NoteDao } from '@aztec/stdlib/note';
|
|
18
18
|
import { CheckpointHeader } from '@aztec/stdlib/rollup';
|
|
19
19
|
import { AppendOnlyTreeSnapshot } from '@aztec/stdlib/trees';
|
|
@@ -194,7 +194,7 @@ export const SCHEMA_TESTS = [
|
|
|
194
194
|
name: 'KeyStore',
|
|
195
195
|
writeToStore: async (kvStore)=>{
|
|
196
196
|
const keyStore = new KeyStore(kvStore);
|
|
197
|
-
await keyStore.addAccount(new Fr(2n), new Fr(3n));
|
|
197
|
+
await keyStore.addAccount(await deriveKeys(new Fr(2n)), new Fr(3n));
|
|
198
198
|
},
|
|
199
199
|
snapshotStore: async (kvStore)=>({
|
|
200
200
|
key_store: await snapshotMap(kvStore.openMap('key_store'))
|
|
@@ -399,9 +399,13 @@ export const SCHEMA_TESTS = [
|
|
|
399
399
|
const jobId = 'fixture-job';
|
|
400
400
|
const secretA = new AppTaggingSecret(new Fr(2n), AztecAddress.fromBigIntUnsafe(3n));
|
|
401
401
|
const secretB = new AppTaggingSecret(new Fr(5n), AztecAddress.fromBigIntUnsafe(7n));
|
|
402
|
+
// A constrained secret keys under the `constrained:` prefix, so the snapshot pins both kinds side by side.
|
|
403
|
+
const secretConstrained = new AppTaggingSecret(new Fr(19n), AztecAddress.fromBigIntUnsafe(23n), AppTaggingSecretKind.CONSTRAINED);
|
|
402
404
|
await recipientTaggingStore.updateHighestFinalizedIndex(secretA, 11, jobId);
|
|
403
405
|
await recipientTaggingStore.updateHighestAgedIndex(secretA, 13, jobId);
|
|
404
406
|
await recipientTaggingStore.updateHighestFinalizedIndex(secretB, 17, jobId);
|
|
407
|
+
await recipientTaggingStore.updateHighestFinalizedIndex(secretConstrained, 11, jobId);
|
|
408
|
+
await recipientTaggingStore.updateHighestAgedIndex(secretConstrained, 13, jobId);
|
|
405
409
|
await kvStore.transactionAsync(()=>recipientTaggingStore.commit(jobId));
|
|
406
410
|
},
|
|
407
411
|
snapshotStore: async (kvStore)=>({
|
|
@@ -416,9 +420,9 @@ export const SCHEMA_TESTS = [
|
|
|
416
420
|
await taggingSecretSourcesStore.addSender(AztecAddress.fromBigIntUnsafe(2n));
|
|
417
421
|
await taggingSecretSourcesStore.addSender(AztecAddress.fromBigIntUnsafe(3n));
|
|
418
422
|
await taggingSecretSourcesStore.addSender(AztecAddress.fromBigIntUnsafe(5n));
|
|
419
|
-
await taggingSecretSourcesStore.addSharedSecret(AztecAddress.fromBigIntUnsafe(7n), new Point(new Fr(2n), new Fr(3n)));
|
|
420
|
-
await taggingSecretSourcesStore.addSharedSecret(AztecAddress.fromBigIntUnsafe(7n), new Point(new Fr(5n), new Fr(7n)));
|
|
421
|
-
await taggingSecretSourcesStore.addSharedSecret(AztecAddress.fromBigIntUnsafe(11n), new Point(new Fr(13n), new Fr(17n)));
|
|
423
|
+
await taggingSecretSourcesStore.addSharedSecret(AztecAddress.fromBigIntUnsafe(7n), 'arbitrary-secret', new Point(new Fr(2n), new Fr(3n)));
|
|
424
|
+
await taggingSecretSourcesStore.addSharedSecret(AztecAddress.fromBigIntUnsafe(7n), 'handshake', new Point(new Fr(5n), new Fr(7n)));
|
|
425
|
+
await taggingSecretSourcesStore.addSharedSecret(AztecAddress.fromBigIntUnsafe(11n), 'arbitrary-secret', new Point(new Fr(13n), new Fr(17n)));
|
|
422
426
|
},
|
|
423
427
|
snapshotStore: async (kvStore)=>({
|
|
424
428
|
senders: await snapshotMap(kvStore.openMap('senders')),
|
|
@@ -433,10 +437,13 @@ export const SCHEMA_TESTS = [
|
|
|
433
437
|
const secretA = new AppTaggingSecret(new Fr(2n), AztecAddress.fromBigIntUnsafe(3n));
|
|
434
438
|
const secretB = new AppTaggingSecret(new Fr(5n), AztecAddress.fromBigIntUnsafe(7n));
|
|
435
439
|
const secretC = new AppTaggingSecret(new Fr(11n), AztecAddress.fromBigIntUnsafe(13n));
|
|
440
|
+
const secretConstrained = new AppTaggingSecret(new Fr(19n), AztecAddress.fromBigIntUnsafe(23n), AppTaggingSecretKind.CONSTRAINED);
|
|
436
441
|
const txHashA = TxHash.fromBigInt(17n);
|
|
437
442
|
const txHashB = TxHash.fromBigInt(19n);
|
|
438
443
|
const txHashC = TxHash.fromBigInt(23n);
|
|
439
444
|
const txHashD = TxHash.fromBigInt(29n);
|
|
445
|
+
const txHashE = TxHash.fromBigInt(31n);
|
|
446
|
+
const txHashF = TxHash.fromBigInt(37n);
|
|
440
447
|
// secretA receives three pending ranges (one per tx); secretB receives one. After finalizing txHashA below,
|
|
441
448
|
// secretA's array shrinks to two elements (the txHashB and txHashC ranges, both with highestIndex > 3) which
|
|
442
449
|
// pins the multi-element JSON encoding of `pending_indexes`.
|
|
@@ -485,8 +492,25 @@ export const SCHEMA_TESTS = [
|
|
|
485
492
|
highestIndex: 9
|
|
486
493
|
}
|
|
487
494
|
], txHashD, jobId);
|
|
495
|
+
// secretConstrained gets a finalized range (txHashE) plus a surviving higher pending range (txHashF), so the
|
|
496
|
+
// `constrained:` key lands in both pending_indexes and last_finalized_indexes.
|
|
497
|
+
await senderTaggingStore.storePendingIndexes([
|
|
498
|
+
{
|
|
499
|
+
extendedSecret: secretConstrained,
|
|
500
|
+
lowestIndex: 1,
|
|
501
|
+
highestIndex: 3
|
|
502
|
+
}
|
|
503
|
+
], txHashE, jobId);
|
|
504
|
+
await senderTaggingStore.storePendingIndexes([
|
|
505
|
+
{
|
|
506
|
+
extendedSecret: secretConstrained,
|
|
507
|
+
lowestIndex: 4,
|
|
508
|
+
highestIndex: 7
|
|
509
|
+
}
|
|
510
|
+
], txHashF, jobId);
|
|
488
511
|
await senderTaggingStore.finalizePendingIndexes([
|
|
489
|
-
txHashA
|
|
512
|
+
txHashA,
|
|
513
|
+
txHashE
|
|
490
514
|
], jobId);
|
|
491
515
|
await kvStore.transactionAsync(()=>senderTaggingStore.commit(jobId));
|
|
492
516
|
},
|