@aztec/pxe 5.0.0-rc.2 → 5.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/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 +11 -7
- package/dest/contract_function_simulator/oracle/oracle_registry.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle_registry.js +50 -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 +23 -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 +105 -60
- 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/index.d.ts +2 -1
- package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/index.js +1 -0
- package/dest/entrypoints/client/bundle/utils.d.ts +1 -1
- package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/utils.js +11 -5
- package/dest/entrypoints/client/lazy/index.d.ts +2 -1
- package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/index.js +1 -0
- package/dest/entrypoints/client/lazy/utils.d.ts +1 -1
- package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/utils.js +11 -5
- package/dest/entrypoints/client/store.d.ts +14 -0
- package/dest/entrypoints/client/store.d.ts.map +1 -0
- package/dest/entrypoints/client/store.js +28 -0
- package/dest/entrypoints/server/index.d.ts +6 -2
- package/dest/entrypoints/server/index.d.ts.map +1 -1
- package/dest/entrypoints/server/index.js +4 -1
- package/dest/entrypoints/server/store.d.ts +18 -0
- package/dest/entrypoints/server/store.d.ts.map +1 -0
- package/dest/entrypoints/server/store.js +28 -0
- package/dest/entrypoints/server/utils.d.ts +1 -1
- package/dest/entrypoints/server/utils.d.ts.map +1 -1
- package/dest/entrypoints/server/utils.js +8 -2
- 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 +5 -3
- package/dest/logs/log_service.d.ts.map +1 -1
- package/dest/logs/log_service.js +38 -17
- package/dest/notes/note_service.d.ts +1 -1
- package/dest/notes/note_service.js +1 -1
- 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 +138 -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/store_identity.d.ts +35 -0
- package/dest/storage/store_identity.d.ts.map +1 -0
- package/dest/storage/store_identity.js +44 -0
- package/dest/storage/tagging_store/sender_tagging_store.d.ts +19 -3
- package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/sender_tagging_store.js +48 -11
- 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/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +1 -1
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +1 -1
- 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 +6 -2
- 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 +37 -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 +149 -71
- package/src/debug/pxe_debug_utils.ts +1 -1
- package/src/entrypoints/client/bundle/index.ts +1 -0
- package/src/entrypoints/client/bundle/utils.ts +16 -4
- package/src/entrypoints/client/lazy/index.ts +1 -0
- package/src/entrypoints/client/lazy/utils.ts +16 -4
- package/src/entrypoints/client/store.ts +38 -0
- package/src/entrypoints/server/index.ts +6 -1
- package/src/entrypoints/server/store.ts +47 -0
- package/src/entrypoints/server/utils.ts +21 -7
- 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 +35 -11
- package/src/notes/note_service.ts +1 -1
- 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 +212 -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/store_identity.ts +72 -0
- package/src/storage/tagging_store/sender_tagging_store.ts +62 -15
- package/src/storage/tagging_store/tagging_secret_sources_store.ts +36 -15
- package/src/tagging/constants.ts +19 -9
- package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +1 -1
- package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +6 -2
- 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
|
@@ -2,8 +2,15 @@ import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
|
2
2
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
3
|
|
|
4
4
|
import { assertAllowedScope } from '../allowed_scopes.js';
|
|
5
|
-
import type {
|
|
5
|
+
import type { FactStore } from './fact_store.js';
|
|
6
6
|
import type { FactCollectionKey, FactCollectionTypeKey, OriginBlock } from './fact_store_keys.js';
|
|
7
|
+
import {
|
|
8
|
+
type FactCollectionWithOriginState,
|
|
9
|
+
type FactWithOriginState,
|
|
10
|
+
type TipBlockNumbers,
|
|
11
|
+
toFactWithOriginState,
|
|
12
|
+
} from './origin_state.js';
|
|
13
|
+
import type { Fact } from './stored_fact.js';
|
|
7
14
|
|
|
8
15
|
/**
|
|
9
16
|
* Wraps a {@link FactStore} with scope-based access control.
|
|
@@ -33,13 +40,30 @@ export class FactService {
|
|
|
33
40
|
return this.factStore.deleteFactCollection(factCollectionKey, jobId);
|
|
34
41
|
}
|
|
35
42
|
|
|
36
|
-
getFactCollection(
|
|
43
|
+
async getFactCollection(
|
|
44
|
+
factCollectionKey: FactCollectionKey,
|
|
45
|
+
tips: TipBlockNumbers,
|
|
46
|
+
jobId: string,
|
|
47
|
+
): Promise<FactCollectionWithOriginState | undefined> {
|
|
37
48
|
assertAllowedScope(factCollectionKey.scope, this.allowedScopes);
|
|
38
|
-
|
|
49
|
+
const collection = await this.factStore.getFactCollection(factCollectionKey, jobId);
|
|
50
|
+
if (!collection) {
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
53
|
+
return { key: collection.key, facts: this.#annotate(collection.facts, tips) };
|
|
39
54
|
}
|
|
40
55
|
|
|
41
|
-
getFactCollectionsByType(
|
|
56
|
+
async getFactCollectionsByType(
|
|
57
|
+
factCollectionTypeKey: FactCollectionTypeKey,
|
|
58
|
+
tips: TipBlockNumbers,
|
|
59
|
+
jobId: string,
|
|
60
|
+
): Promise<FactCollectionWithOriginState[]> {
|
|
42
61
|
assertAllowedScope(factCollectionTypeKey.scope, this.allowedScopes);
|
|
43
|
-
|
|
62
|
+
const collections = await this.factStore.getFactCollectionsByType(factCollectionTypeKey, jobId);
|
|
63
|
+
return collections.map(collection => ({ key: collection.key, facts: this.#annotate(collection.facts, tips) }));
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
#annotate(facts: Fact[], tips: TipBlockNumbers): FactWithOriginState[] {
|
|
67
|
+
return facts.map(fact => toFactWithOriginState(fact, tips));
|
|
44
68
|
}
|
|
45
69
|
}
|
|
@@ -82,7 +82,7 @@ export class FactStore implements StagedStore {
|
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
/**
|
|
85
|
-
* Records a fact in a collection.
|
|
85
|
+
* Records a fact in a collection, visible under the given scope.
|
|
86
86
|
*
|
|
87
87
|
* The collection is created implicitly on the first fact recorded for its key: recording into an existing collection
|
|
88
88
|
* just adds to it.
|
|
@@ -2,3 +2,13 @@ export { FactStore, type FactCollection } from './fact_store.js';
|
|
|
2
2
|
export { FactService } from './fact_service.js';
|
|
3
3
|
export { FactCollectionKey, FactCollectionTypeKey, type OriginBlock } from './fact_store_keys.js';
|
|
4
4
|
export type { Fact } from './stored_fact.js';
|
|
5
|
+
export {
|
|
6
|
+
OriginBlockState,
|
|
7
|
+
classifyOriginBlockState,
|
|
8
|
+
anchoredTipBlockNumbers,
|
|
9
|
+
toFactWithOriginState,
|
|
10
|
+
type TipBlockNumbers,
|
|
11
|
+
type RetractableFactOrigin,
|
|
12
|
+
type FactWithOriginState,
|
|
13
|
+
type FactCollectionWithOriginState,
|
|
14
|
+
} from './origin_state.js';
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
+
import type { L2Tips } from '@aztec/stdlib/block';
|
|
3
|
+
|
|
4
|
+
import type { FactCollectionKey, OriginBlock } from './fact_store_keys.js';
|
|
5
|
+
import type { Fact } from './stored_fact.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Chain state of a retractable fact's origin block, mirroring the L2 chain tips.
|
|
9
|
+
*
|
|
10
|
+
* - `Pending`: above the proven tip.
|
|
11
|
+
* - `Proven`: proof on L1 but not yet finalized.
|
|
12
|
+
* - `Finalized`: L1-finalized.
|
|
13
|
+
*
|
|
14
|
+
* The numeric discriminants must stay in sync with the Noir `OriginBlockState` in
|
|
15
|
+
* `noir-projects/aztec-nr/aztec/src/facts/origin_state.nr`: PXE serializes this value into the `Fact` oracle response
|
|
16
|
+
* and Noir deserializes it via `from_u8`, which rejects any value outside this set.
|
|
17
|
+
*/
|
|
18
|
+
export enum OriginBlockState {
|
|
19
|
+
Pending = 1,
|
|
20
|
+
Proven = 2,
|
|
21
|
+
Finalized = 3,
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** The two chain-tip block numbers needed to classify an origin block (`finalized <= proven` always holds). */
|
|
25
|
+
export type TipBlockNumbers = { provenBlockNumber: number; finalizedBlockNumber: number };
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Projects the live chain tips to the block numbers used for classification, capped at the anchor block.
|
|
29
|
+
*
|
|
30
|
+
* A utility execution reads against a fixed anchor block, and every other node query in the oracle is bounded by it.
|
|
31
|
+
* Capping the proven/finalized tips at the anchor keeps origin-state consistent with that view and deterministic
|
|
32
|
+
* across runs: an origin block at or before the anchor classifies exactly as it would against the live tips, while an
|
|
33
|
+
* origin block above the anchor is reported `Pending` rather than trusting tips that look past the anchor.
|
|
34
|
+
*/
|
|
35
|
+
export function anchoredTipBlockNumbers(tips: L2Tips, anchorBlockNumber: number): TipBlockNumbers {
|
|
36
|
+
return {
|
|
37
|
+
provenBlockNumber: Math.min(tips.proven.block.number, anchorBlockNumber),
|
|
38
|
+
finalizedBlockNumber: Math.min(tips.finalized.block.number, anchorBlockNumber),
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** A retractable fact's origin block annotated with that block's current chain state. */
|
|
43
|
+
export type RetractableFactOrigin = OriginBlock & { blockState: OriginBlockState };
|
|
44
|
+
|
|
45
|
+
/** A fact enriched with origin-block state. `originBlock` is undefined for a non-retractable fact. */
|
|
46
|
+
export type FactWithOriginState = { factTypeId: Fr; payload: Fr[]; originBlock: RetractableFactOrigin | undefined };
|
|
47
|
+
|
|
48
|
+
/** A fact collection whose facts carry origin-block state. */
|
|
49
|
+
export type FactCollectionWithOriginState = { key: FactCollectionKey; facts: FactWithOriginState[] };
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Classifies an origin block by number against the chain tips. A surviving retractable fact's origin block is
|
|
53
|
+
* guaranteed canonical (a reorg would have pruned the fact), so a number comparison is sufficient.
|
|
54
|
+
*/
|
|
55
|
+
export function classifyOriginBlockState(blockNumber: number, tips: TipBlockNumbers): OriginBlockState {
|
|
56
|
+
if (blockNumber <= tips.finalizedBlockNumber) {
|
|
57
|
+
return OriginBlockState.Finalized;
|
|
58
|
+
}
|
|
59
|
+
if (blockNumber <= tips.provenBlockNumber) {
|
|
60
|
+
return OriginBlockState.Proven;
|
|
61
|
+
}
|
|
62
|
+
return OriginBlockState.Pending;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** Enriches a stored fact with the chain state of its origin block (when retractable). */
|
|
66
|
+
export function toFactWithOriginState(fact: Fact, tips: TipBlockNumbers): FactWithOriginState {
|
|
67
|
+
const originBlock: RetractableFactOrigin | undefined = fact.originBlock
|
|
68
|
+
? {
|
|
69
|
+
blockNumber: fact.originBlock.blockNumber,
|
|
70
|
+
blockHash: fact.originBlock.blockHash,
|
|
71
|
+
blockState: classifyOriginBlockState(fact.originBlock.blockNumber, tips),
|
|
72
|
+
}
|
|
73
|
+
: undefined;
|
|
74
|
+
return { factTypeId: fact.factTypeId, payload: fact.payload, originBlock };
|
|
75
|
+
}
|
package/src/storage/metadata.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const PXE_DATA_SCHEMA_VERSION =
|
|
1
|
+
export const PXE_DATA_SCHEMA_VERSION = 13;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
|
+
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
3
|
+
import { DatabaseVersion } from '@aztec/stdlib/database-version/version';
|
|
4
|
+
|
|
5
|
+
/** The triple that determine which physical store a logical store name maps to. */
|
|
6
|
+
export type StoreIdentity = {
|
|
7
|
+
/** Chain ID of the L1 the rollup is deployed to. */
|
|
8
|
+
l1ChainId: number;
|
|
9
|
+
/** Address of the rollup contract the store's data pertains to. */
|
|
10
|
+
rollupAddress: EthAddress;
|
|
11
|
+
/** Schema version of the data held in the store. */
|
|
12
|
+
schemaVersion: number;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Composes the store-name discriminator for a store identity. Two identities map to the same physical store iff
|
|
17
|
+
* their slugs are equal, so the format must stay stable: `<l1ChainId>-<rollupAddress>-v<schemaVersion>` — changing
|
|
18
|
+
* it orphans every existing store.
|
|
19
|
+
*/
|
|
20
|
+
export function storeIdentitySlug({ l1ChainId, rollupAddress, schemaVersion }: StoreIdentity): string {
|
|
21
|
+
return `${l1ChainId}-${rollupAddress.toString()}-v${schemaVersion}`;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** Composes the physical store name for a logical store name and identity. */
|
|
25
|
+
export function effectiveStoreName(name: string, identity: StoreIdentity): string {
|
|
26
|
+
return `${name}_${storeIdentitySlug(identity)}`;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Invariant check for stores whose physical name carries their identity: the recorded version can
|
|
31
|
+
* only disagree with the expected one if there is a store-naming bug.
|
|
32
|
+
*/
|
|
33
|
+
export async function assertStoreIdentity(
|
|
34
|
+
store: AztecAsyncKVStore,
|
|
35
|
+
storeName: string,
|
|
36
|
+
identity: StoreIdentity,
|
|
37
|
+
): Promise<void> {
|
|
38
|
+
const expected = new DatabaseVersion(identity.schemaVersion, identity.rollupAddress);
|
|
39
|
+
const singleton = store.openSingleton<string>('dbVersion');
|
|
40
|
+
const stored = await singleton.getAsync();
|
|
41
|
+
if (stored === undefined) {
|
|
42
|
+
await singleton.set(expected.toBuffer().toString('utf-8'));
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
let storedVersion: DatabaseVersion;
|
|
46
|
+
try {
|
|
47
|
+
storedVersion = DatabaseVersion.fromBuffer(Buffer.from(stored, 'utf-8'));
|
|
48
|
+
} catch {
|
|
49
|
+
throw new StoreIdentityMismatchError(storeName, expected.toString(), stored);
|
|
50
|
+
}
|
|
51
|
+
if (!storedVersion.equals(expected)) {
|
|
52
|
+
throw new StoreIdentityMismatchError(storeName, expected.toString(), storedVersion.toString());
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Thrown when a store's recorded identity does not match the identity it was opened under. Since the identity is
|
|
58
|
+
* part of the physical store name, this can only indicate a store-naming bug; the store is left untouched.
|
|
59
|
+
*/
|
|
60
|
+
export class StoreIdentityMismatchError extends Error {
|
|
61
|
+
constructor(
|
|
62
|
+
public readonly storeName: string,
|
|
63
|
+
public readonly expected: string,
|
|
64
|
+
public readonly actual: string,
|
|
65
|
+
) {
|
|
66
|
+
super(
|
|
67
|
+
`Store '${storeName}' records identity ${actual} but was opened as ${expected}. ` +
|
|
68
|
+
`Refusing to open; data was NOT modified.`,
|
|
69
|
+
);
|
|
70
|
+
this.name = 'StoreIdentityMismatchError';
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -128,10 +128,11 @@ export class SenderTaggingStore implements StagedStore {
|
|
|
128
128
|
}
|
|
129
129
|
|
|
130
130
|
/**
|
|
131
|
-
* Stores pending index ranges.
|
|
131
|
+
* Stores pending index ranges, rejecting any range that disagrees with an already-stored one.
|
|
132
132
|
* @remarks If the same (secret, txHash) pair already exists in the db with an equal range, it's a no-op. This is
|
|
133
133
|
* expected to happen because whenever we start sync we start from the last finalized index and we can have pending
|
|
134
|
-
* ranges already stored from previous syncs. If the ranges differ, it throws an error as that indicates a bug
|
|
134
|
+
* ranges already stored from previous syncs. If the ranges differ, it throws an error as that indicates a bug in
|
|
135
|
+
* callers that record indexes at prove time. Discovery from onchain logs must use `mergePendingIndexes` instead.
|
|
135
136
|
* @param ranges - The tagging index ranges containing the directional app tagging secrets and the index ranges that are
|
|
136
137
|
* to be stored in the db.
|
|
137
138
|
* @param txHash - The tx in which the tagging indexes were used in private logs.
|
|
@@ -141,6 +142,33 @@ export class SenderTaggingStore implements StagedStore {
|
|
|
141
142
|
* @throws If a different range already exists for the same (secret, txHash) pair.
|
|
142
143
|
*/
|
|
143
144
|
storePendingIndexes(ranges: TaggingIndexRange[], txHash: TxHash, jobId: string): Promise<void> {
|
|
145
|
+
return this.#storePendingIndexes(ranges, txHash, jobId, false);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Stores pending index ranges, widening an existing entry for the same (secret, txHash) pair to the union of the
|
|
150
|
+
* stored and incoming ranges instead of throwing on a mismatch. Discovery from onchain logs needs this: it may see
|
|
151
|
+
* only the surviving (non-revertible phase) sub-range of a partially reverted tx recorded at prove time (the
|
|
152
|
+
* finalized receipt step of the sync resolves that difference), or indexes beyond a partially discovered entry
|
|
153
|
+
* when a tx from another PXE straddles a sync window boundary. Callers that record indexes at prove time must use
|
|
154
|
+
* `storePendingIndexes` instead, so that a range disagreement surfaces as a bug rather than being absorbed.
|
|
155
|
+
* @param ranges - The tagging index ranges containing the directional app tagging secrets and the index ranges that are
|
|
156
|
+
* to be stored in the db.
|
|
157
|
+
* @param txHash - The tx in which the tagging indexes were used in private logs.
|
|
158
|
+
* @param jobId - job context for staged writes to this store. See `JobCoordinator` for more details.
|
|
159
|
+
* @throws If the highestIndex is further than window length from the highest finalized index for the same secret.
|
|
160
|
+
* @throws If the lowestIndex is lower than or equal to the last finalized index for the same secret.
|
|
161
|
+
*/
|
|
162
|
+
mergePendingIndexes(ranges: TaggingIndexRange[], txHash: TxHash, jobId: string): Promise<void> {
|
|
163
|
+
return this.#storePendingIndexes(ranges, txHash, jobId, true);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
#storePendingIndexes(
|
|
167
|
+
ranges: TaggingIndexRange[],
|
|
168
|
+
txHash: TxHash,
|
|
169
|
+
jobId: string,
|
|
170
|
+
mergeExisting: boolean,
|
|
171
|
+
): Promise<void> {
|
|
144
172
|
if (ranges.length === 0) {
|
|
145
173
|
return Promise.resolve();
|
|
146
174
|
}
|
|
@@ -187,21 +215,40 @@ export class SenderTaggingStore implements StagedStore {
|
|
|
187
215
|
// Check if an entry with the same txHash already exists
|
|
188
216
|
const existingEntry = pendingData.find(entry => entry.txHash === txHashStr);
|
|
189
217
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
throw new Error(
|
|
194
|
-
`Conflicting range for secret ${secretStr} and txHash ${txHashStr}: ` +
|
|
195
|
-
`existing [${existingEntry.lowestIndex}, ${existingEntry.highestIndex}] vs ` +
|
|
196
|
-
`new [${range.lowestIndex}, ${range.highestIndex}]`,
|
|
197
|
-
);
|
|
198
|
-
}
|
|
199
|
-
// Exact duplicate — skip
|
|
200
|
-
} else {
|
|
201
|
-
this.#writePendingIndexes(jobId, secretStr, [
|
|
218
|
+
let updatedPending: PendingIndexesEntry[] | undefined;
|
|
219
|
+
if (!existingEntry) {
|
|
220
|
+
updatedPending = [
|
|
202
221
|
...pendingData,
|
|
203
222
|
{ lowestIndex: range.lowestIndex, highestIndex: range.highestIndex, txHash: txHashStr },
|
|
204
|
-
]
|
|
223
|
+
];
|
|
224
|
+
} else if (mergeExisting) {
|
|
225
|
+
// Widen the entry to the union of both ranges, never shrink it: replacing would drop prove-time
|
|
226
|
+
// indexes the chain doesn't show (partially reverted tx), and skipping would drop onchain indexes
|
|
227
|
+
// discovered in a later sync window (tx straddling the window boundary).
|
|
228
|
+
const lowestIndex = Math.min(existingEntry.lowestIndex, range.lowestIndex);
|
|
229
|
+
const highestIndex = Math.max(existingEntry.highestIndex, range.highestIndex);
|
|
230
|
+
if (lowestIndex !== existingEntry.lowestIndex || highestIndex !== existingEntry.highestIndex) {
|
|
231
|
+
updatedPending = pendingData.map(entry =>
|
|
232
|
+
entry === existingEntry ? { lowestIndex, highestIndex, txHash: entry.txHash } : entry,
|
|
233
|
+
);
|
|
234
|
+
}
|
|
235
|
+
} else if (
|
|
236
|
+
existingEntry.lowestIndex !== range.lowestIndex ||
|
|
237
|
+
existingEntry.highestIndex !== range.highestIndex
|
|
238
|
+
) {
|
|
239
|
+
// Different ranges for the same (secret, txHash) indicate a bug in callers that record indexes at prove
|
|
240
|
+
// time.
|
|
241
|
+
throw new Error(
|
|
242
|
+
`Conflicting range for secret ${secretStr} and txHash ${txHashStr}: ` +
|
|
243
|
+
`existing [${existingEntry.lowestIndex}, ${existingEntry.highestIndex}] vs ` +
|
|
244
|
+
`new [${range.lowestIndex}, ${range.highestIndex}]`,
|
|
245
|
+
);
|
|
246
|
+
}
|
|
247
|
+
// Remaining cases (a merge whose union equals the stored range, or an identical range without
|
|
248
|
+
// mergeExisting): duplicate evidence, nothing to write.
|
|
249
|
+
|
|
250
|
+
if (updatedPending) {
|
|
251
|
+
this.#writePendingIndexes(jobId, secretStr, updatedPending);
|
|
205
252
|
}
|
|
206
253
|
}
|
|
207
254
|
});
|
|
@@ -3,6 +3,14 @@ import { toArray } from '@aztec/foundation/iterable';
|
|
|
3
3
|
import type { AztecAsyncKVStore, AztecAsyncMap, AztecAsyncMultiMap } from '@aztec/kv-store';
|
|
4
4
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* The kinds of shared secret an entry can hold.
|
|
8
|
+
*/
|
|
9
|
+
export type SharedSecretKind = 'arbitrary-secret' | 'handshake';
|
|
10
|
+
|
|
11
|
+
/** A shared secret registered for a recipient, with the kind that determines which tag streams it backs. */
|
|
12
|
+
export type SharedSecret = { kind: SharedSecretKind; secret: Point };
|
|
13
|
+
|
|
6
14
|
/**
|
|
7
15
|
* Stores the sources from which directional app tagging secrets are derived during recipient log synchronization.
|
|
8
16
|
*
|
|
@@ -13,12 +21,13 @@ import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
|
13
21
|
* - Pre-shared tagging secrets: shared secret points registered directly, bypassing ECDH. These are scoped to a
|
|
14
22
|
* specific recipient, since the derivation of the directional app tagging secret does not require any secret
|
|
15
23
|
* recipient data: given the original secret anyone can derive a recipient's app-siloed directional tagging secret,
|
|
16
|
-
* and so these must not be reused to preserve privacy.
|
|
24
|
+
* and so these must not be reused across recipients to preserve privacy. Each carries the {@link SharedSecretKind}
|
|
25
|
+
* it was registered through, which determines the tag streams it is scanned under.
|
|
17
26
|
*/
|
|
18
27
|
export class TaggingSecretSourcesStore {
|
|
19
28
|
#store: AztecAsyncKVStore;
|
|
20
29
|
#senders: AztecAsyncMap<string, true>;
|
|
21
|
-
#sharedSecretsByRecipient: AztecAsyncMultiMap<string,
|
|
30
|
+
#sharedSecretsByRecipient: AztecAsyncMultiMap<string, StoredSharedSecret>;
|
|
22
31
|
|
|
23
32
|
constructor(store: AztecAsyncKVStore) {
|
|
24
33
|
this.#store = store;
|
|
@@ -61,52 +70,57 @@ export class TaggingSecretSourcesStore {
|
|
|
61
70
|
* Registers a pre-shared tagging secret scoped to a recipient.
|
|
62
71
|
* @returns true if the secret was newly added, false if it was already registered for that recipient.
|
|
63
72
|
*/
|
|
64
|
-
addSharedSecret(recipient: AztecAddress, secret: Point): Promise<boolean> {
|
|
73
|
+
addSharedSecret(recipient: AztecAddress, kind: SharedSecretKind, secret: Point): Promise<boolean> {
|
|
65
74
|
return this.#store.transactionAsync(async () => {
|
|
66
75
|
const secretStr = secret.toString();
|
|
67
76
|
// MultiMap.set silently ignores an identical (key, value), so we scan to report whether this is a new secret.
|
|
68
77
|
for await (const existing of this.#sharedSecretsByRecipient.getValuesAsync(recipient.toString())) {
|
|
69
|
-
if (existing === secretStr) {
|
|
78
|
+
if (existing.secret === secretStr) {
|
|
79
|
+
if (existing.kind !== kind) {
|
|
80
|
+
throw new Error(
|
|
81
|
+
`Secret already registered for recipient with kind '${existing.kind}', cannot re-register it as '${kind}'.`,
|
|
82
|
+
);
|
|
83
|
+
}
|
|
70
84
|
return false;
|
|
71
85
|
}
|
|
72
86
|
}
|
|
73
87
|
|
|
74
|
-
await this.#sharedSecretsByRecipient.set(recipient.toString(), secretStr);
|
|
88
|
+
await this.#sharedSecretsByRecipient.set(recipient.toString(), { kind, secret: secretStr });
|
|
75
89
|
|
|
76
90
|
return true;
|
|
77
91
|
});
|
|
78
92
|
}
|
|
79
93
|
|
|
80
94
|
/** Returns the pre-shared tagging secrets registered for a given recipient. */
|
|
81
|
-
getSharedSecretsForRecipient(recipient: AztecAddress): Promise<
|
|
95
|
+
getSharedSecretsForRecipient(recipient: AztecAddress): Promise<SharedSecret[]> {
|
|
82
96
|
return this.#store.transactionAsync(async () => {
|
|
83
|
-
return (await toArray(this.#sharedSecretsByRecipient.getValuesAsync(recipient.toString()))).map(
|
|
84
|
-
|
|
97
|
+
return (await toArray(this.#sharedSecretsByRecipient.getValuesAsync(recipient.toString()))).map(
|
|
98
|
+
deserializeSharedSecret,
|
|
85
99
|
);
|
|
86
100
|
});
|
|
87
101
|
}
|
|
88
102
|
|
|
89
103
|
/** Returns every registered pre-shared tagging secret, each paired with the recipient it is scoped to. */
|
|
90
|
-
getAllSharedSecrets(): Promise<{ recipient: AztecAddress; secret: Point }[]> {
|
|
104
|
+
getAllSharedSecrets(): Promise<{ recipient: AztecAddress; kind: SharedSecretKind; secret: Point }[]> {
|
|
91
105
|
return this.#store.transactionAsync(async () => {
|
|
92
106
|
const entries = await toArray(this.#sharedSecretsByRecipient.entriesAsync());
|
|
93
|
-
return entries.map(([recipient,
|
|
107
|
+
return entries.map(([recipient, entry]) => ({
|
|
94
108
|
recipient: AztecAddress.fromStringUnsafe(recipient),
|
|
95
|
-
|
|
109
|
+
...deserializeSharedSecret(entry),
|
|
96
110
|
}));
|
|
97
111
|
});
|
|
98
112
|
}
|
|
99
113
|
|
|
100
114
|
/**
|
|
101
|
-
* Removes a pre-shared tagging secret scoped to a recipient.
|
|
115
|
+
* Removes a pre-shared tagging secret scoped to a recipient. Both the secret and its kind must match.
|
|
102
116
|
* @returns true if the secret was registered and removed, false if it was not registered for that recipient.
|
|
103
117
|
*/
|
|
104
|
-
removeSharedSecret(recipient: AztecAddress, secret: Point): Promise<boolean> {
|
|
118
|
+
removeSharedSecret(recipient: AztecAddress, kind: SharedSecretKind, secret: Point): Promise<boolean> {
|
|
105
119
|
return this.#store.transactionAsync(async () => {
|
|
106
120
|
const secretStr = secret.toString();
|
|
107
121
|
for await (const existing of this.#sharedSecretsByRecipient.getValuesAsync(recipient.toString())) {
|
|
108
|
-
if (existing === secretStr) {
|
|
109
|
-
await this.#sharedSecretsByRecipient.deleteValue(recipient.toString(),
|
|
122
|
+
if (existing.kind === kind && existing.secret === secretStr) {
|
|
123
|
+
await this.#sharedSecretsByRecipient.deleteValue(recipient.toString(), existing);
|
|
110
124
|
return true;
|
|
111
125
|
}
|
|
112
126
|
}
|
|
@@ -115,3 +129,10 @@ export class TaggingSecretSourcesStore {
|
|
|
115
129
|
});
|
|
116
130
|
}
|
|
117
131
|
}
|
|
132
|
+
|
|
133
|
+
/** The wire form a shared secret entry is persisted as. */
|
|
134
|
+
type StoredSharedSecret = { kind: SharedSecretKind; secret: string };
|
|
135
|
+
|
|
136
|
+
function deserializeSharedSecret(entry: StoredSharedSecret): SharedSecret {
|
|
137
|
+
return { kind: entry.kind, secret: Point.fromString(entry.secret) };
|
|
138
|
+
}
|
package/src/tagging/constants.ts
CHANGED
|
@@ -1,10 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
// This
|
|
4
|
-
//
|
|
5
|
-
// and the note is nullified in the same tx.
|
|
1
|
+
import { MAX_PRIVATE_LOGS_PER_TX } from '@aztec/constants';
|
|
2
|
+
|
|
3
|
+
// This window bounds how far a sender's next tag index for a directional app tagging secret can run ahead of that
|
|
4
|
+
// secret's highest finalized index before `PXE::proveTx` throws.
|
|
6
5
|
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
|
|
6
|
+
// MAX_PRIVATE_LOGS_PER_TX is a floor for ordinary transaction patterns: the private kernel accumulates every
|
|
7
|
+
// surviving private log into a single tx-wide array of exactly this size, so a fresh secret's very first
|
|
8
|
+
// ordinary tx can consume that many indexes before anything is finalized.
|
|
9
|
+
//
|
|
10
|
+
// The +20 on top is headroom for multiple pending ordinary txs to the same counterparty stacking up
|
|
11
|
+
// before the first one is observed as mined. Only a run of near-MAX_PRIVATE_LOGS_PER_TX txs back-to-back would
|
|
12
|
+
// exhaust this; ordinary transfers use far fewer logs per tx, so the same margin covers many more of those. Keep the
|
|
13
|
+
// margin additive rather than another multiple of the floor. A larger window also makes recipient-side sync more
|
|
14
|
+
// expensive, since discovery has to probe ahead of the last finalized index for every active secret.
|
|
15
|
+
//
|
|
16
|
+
// TODO(F-783): MAX_PRIVATE_LOGS_PER_TX is not a hard ceiling in general — a tx that creates and nullifies (squashes)
|
|
17
|
+
// many notes/logs to the same secret can drive that secret's raw tag index arbitrarily higher, since indexes are
|
|
18
|
+
// reserved at log emission time, before squashing is decided, and the kernel's reset/squash loop is not bounded by
|
|
19
|
+
// MAX_PRIVATE_LOGS_PER_TX. No fixed window value closes that gap.
|
|
20
|
+
export const UNFINALIZED_TAGGING_INDEXES_WINDOW_LEN = MAX_PRIVATE_LOGS_PER_TX + 20;
|
|
@@ -74,7 +74,7 @@ export async function syncSenderTaggingIndexes(
|
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
// Receipts for pending tx hashes that the logs query just surfaced still need a sequential follow-up call.
|
|
77
|
-
// `
|
|
77
|
+
// `mergePendingIndexes` is idempotent on (secret, txHash), so a re-discovered hash stays classified as known
|
|
78
78
|
// and is not re-fetched here.
|
|
79
79
|
const knownSet = new Set(knownPendingTxHashes.map(h => h.toString()));
|
|
80
80
|
const newPendingTxHashes = allPendingTxHashes.filter(h => !knownSet.has(h.toString()));
|
|
@@ -36,11 +36,15 @@ export async function loadAndStoreNewTaggingIndexes(
|
|
|
36
36
|
const txsForTags = await getTxsContainingTags(siloedTagsForWindow, aztecNode, anchorBlockHash);
|
|
37
37
|
const txIndexesMap = getTxIndexesMap(txsForTags, start, siloedTagsForWindow.length);
|
|
38
38
|
|
|
39
|
-
// Now we iterate over the map, construct the tagging index ranges and store them in the db.
|
|
39
|
+
// Now we iterate over the map, construct the tagging index ranges and store them in the db. A tx already tracked
|
|
40
|
+
// in the store is merged rather than range-checked: if this PXE sent the tx and it partially reverted, the chain
|
|
41
|
+
// only shows the surviving sub-range of the prove-time entry (the finalized receipt step of the sync owns
|
|
42
|
+
// resolving that difference), and a tx from another PXE may straddle a sync window boundary, in which case the
|
|
43
|
+
// entry is widened so the next index choice covers the full onchain range.
|
|
40
44
|
for (const [txHashStr, indexes] of txIndexesMap.entries()) {
|
|
41
45
|
const txHash = TxHash.fromString(txHashStr);
|
|
42
46
|
const ranges = [{ extendedSecret, lowestIndex: Math.min(...indexes), highestIndex: Math.max(...indexes) }];
|
|
43
|
-
await taggingStore.
|
|
47
|
+
await taggingStore.mergePendingIndexes(ranges, txHash, jobId);
|
|
44
48
|
}
|
|
45
49
|
}
|
|
46
50
|
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { ContractOverrides } from '@aztec/stdlib/tx';
|
|
2
|
-
import type { ContractStore } from '../storage/contract_store/contract_store.js';
|
|
3
|
-
export declare class ProxiedContractStoreFactory {
|
|
4
|
-
static create(contractStore: ContractStore, overrides?: ContractOverrides): ContractStore;
|
|
5
|
-
}
|
|
6
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJveGllZF9jb250cmFjdF9kYXRhX3NvdXJjZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2NvbnRyYWN0X2Z1bmN0aW9uX3NpbXVsYXRvci9wcm94aWVkX2NvbnRyYWN0X2RhdGFfc291cmNlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUVBLE9BQU8sS0FBSyxFQUFFLGlCQUFpQixFQUFFLE1BQU0sa0JBQWtCLENBQUM7QUFFMUQsT0FBTyxLQUFLLEVBQUUsYUFBYSxFQUFFLE1BQU0sNkNBQTZDLENBQUM7QUFjakYscUJBQWEsMkJBQTJCO0lBQ3RDLE1BQU0sQ0FBQyxNQUFNLENBQUMsYUFBYSxFQUFFLGFBQWEsRUFBRSxTQUFTLENBQUMsRUFBRSxpQkFBaUIsaUJBdUN4RTtDQUNGIn0=
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"proxied_contract_data_source.d.ts","sourceRoot":"","sources":["../../src/contract_function_simulator/proxied_contract_data_source.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAE1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6CAA6C,CAAC;AAcjF,qBAAa,2BAA2B;IACtC,MAAM,CAAC,MAAM,CAAC,aAAa,EAAE,aAAa,EAAE,SAAS,CAAC,EAAE,iBAAiB,iBAuCxE;CACF"}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { findFunctionArtifactBySelector } from '@aztec/stdlib/abi';
|
|
2
|
-
/*
|
|
3
|
-
* Proxy generator for a ContractStore that allows overriding contract instances at given addresses,
|
|
4
|
-
* so the contract function simulator can execute different bytecode on certain addresses. An example
|
|
5
|
-
* use case would be overriding your own account contract so that valid signatures don't have to be
|
|
6
|
-
* provided while simulating.
|
|
7
|
-
*
|
|
8
|
-
* Function artifact lookups for an overridden address are routed via the override-instance's
|
|
9
|
-
* `currentContractClassId` rather than the underlying ContractStore's address→class mapping —
|
|
10
|
-
* `ContractStore.getFunctionArtifact` calls `this.getContractInstance` internally, which the proxy
|
|
11
|
-
* cannot intercept (the binding sees the raw target, not the proxy). The target class must be
|
|
12
|
-
* registered ahead of time via `pxe.registerContractClass(...)`.
|
|
13
|
-
*/ export class ProxiedContractStoreFactory {
|
|
14
|
-
static create(contractStore, overrides) {
|
|
15
|
-
if (!overrides) {
|
|
16
|
-
return contractStore;
|
|
17
|
-
}
|
|
18
|
-
return new Proxy(contractStore, {
|
|
19
|
-
get (target, prop) {
|
|
20
|
-
if (prop === 'getContractInstance') {
|
|
21
|
-
return (address)=>{
|
|
22
|
-
const override = overrides[address.toString()];
|
|
23
|
-
return override ? Promise.resolve(override.instance) : target.getContractInstance(address);
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
if (prop === 'getFunctionArtifact' || prop === 'getFunctionArtifactWithDebugMetadata') {
|
|
27
|
-
return async (contractAddress, selector)=>{
|
|
28
|
-
const override = overrides[contractAddress.toString()];
|
|
29
|
-
if (!override) {
|
|
30
|
-
return target[prop].call(target, contractAddress, selector);
|
|
31
|
-
}
|
|
32
|
-
const artifact = await target.getContractArtifact(override.instance.currentContractClassId);
|
|
33
|
-
if (!artifact) {
|
|
34
|
-
throw new Error(`No artifact registered for override class ${override.instance.currentContractClassId} ` + `at ${contractAddress}. Register it via pxe.registerContractClass(...) before simulating.`);
|
|
35
|
-
}
|
|
36
|
-
const fn = await findFunctionArtifactBySelector(artifact, selector);
|
|
37
|
-
if (!fn) {
|
|
38
|
-
throw new Error(`Function with selector ${selector} not found in stub artifact for overridden contract at ${contractAddress}.`);
|
|
39
|
-
}
|
|
40
|
-
return {
|
|
41
|
-
...fn,
|
|
42
|
-
contractName: artifact.name
|
|
43
|
-
};
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
const value = Reflect.get(target, prop);
|
|
47
|
-
return typeof value === 'function' ? value.bind(target) : value;
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"contract_sync_service.d.ts","sourceRoot":"","sources":["../../src/contract_sync/contract_sync_service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAGpD,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACxE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AAEzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6CAA6C,CAAC;AACjF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qCAAqC,CAAC;AAGrE;;;GAGG;AACH,eAAO,MAAM,0BAA0B,IAAI,CAAC;AAE5C;;;;;GAKG;AACH,qBAAa,mBAAoB,YAAW,WAAW;;IAanD,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,aAAa;IACrB,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,GAAG;IAfb,QAAQ,CAAC,SAAS,mBAAmB;IAKrC,OAAO,CAAC,eAAe,CAAyC;IAIhE,OAAO,CAAC,wBAAwB,CAAyC;IAEzE,YACU,SAAS,EAAE,SAAS,EACpB,aAAa,EAAE,aAAa,EAC5B,SAAS,EAAE,SAAS,EACpB,GAAG,EAAE,MAAM,EACjB;IAEJ;;;;;;;;OAQG;IACG,oBAAoB,CACxB,eAAe,EAAE,YAAY,EAC7B,yBAAyB,EAAE,gBAAgB,GAAG,IAAI,EAClD,eAAe,EAAE,CAAC,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,KAAK,OAAO,CAAC,GAAG,CAAC,EAC7E,iBAAiB,EAAE,WAAW,EAC9B,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,YAAY,EAAE,GACrB,OAAO,CAAC,IAAI,CAAC,CAMf;IAED,oEAAoE;IACpE,2BAA2B,CAAC,eAAe,EAAE,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,GAAG,IAAI,CAKvF;IAED,gFAAgF;IAChF,IAAI,IAAI,IAAI,CAIX;IAED,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAEpC;IAED,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAM3C;CAsFF"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { FunctionCall, FunctionSelector } from '@aztec/stdlib/abi';
|
|
2
|
-
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
|
-
import type { ContractInstance } from '@aztec/stdlib/contract';
|
|
4
|
-
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
5
|
-
import type { BlockHeader } from '@aztec/stdlib/tx';
|
|
6
|
-
import type { ContractStore } from '../storage/contract_store/contract_store.js';
|
|
7
|
-
/**
|
|
8
|
-
* Read the current class id of a contract as of the given block, as seen by the AztecNode. The node resolves it from
|
|
9
|
-
* the same scheduled value change the AVM enforces against the public data tree. If the node has no record of the
|
|
10
|
-
* instance (e.g. it was never publicly deployed), the original class id from the local instance is used.
|
|
11
|
-
* @param contractAddress - The address of the contract to read the class id for.
|
|
12
|
-
* @param instance - The local instance of the contract, used as a fallback when the node doesn't know it.
|
|
13
|
-
* @param aztecNode - The Aztec node to query.
|
|
14
|
-
* @param header - The header of the block at which to resolve the current class id.
|
|
15
|
-
* @returns The current class id.
|
|
16
|
-
*/
|
|
17
|
-
export declare function readCurrentClassId(contractAddress: AztecAddress, instance: ContractInstance, aztecNode: AztecNode, header: BlockHeader): Promise<import("@aztec/foundation/schemas").Fr>;
|
|
18
|
-
export declare function syncScope(contractAddress: AztecAddress, contractStore: ContractStore, functionToInvokeAfterSync: FunctionSelector | null, utilityExecutor: (privateSyncCall: FunctionCall, scopes: AztecAddress[]) => Promise<any>, scope: AztecAddress): Promise<void>;
|
|
19
|
-
/**
|
|
20
|
-
* Verify that the current class id of a contract obtained from AztecNode is the same as the one in contract data
|
|
21
|
-
* provider (i.e. PXE's own storage).
|
|
22
|
-
* @param contractAddress - The address of the contract to verify.
|
|
23
|
-
* @param aztecNode - The Aztec node to query for storage.
|
|
24
|
-
* @param contractStore - The contract store to fetch the local instance from.
|
|
25
|
-
* @param header - The header of the block at which to verify the current class id.
|
|
26
|
-
*/
|
|
27
|
-
export declare function verifyCurrentClassId(contractAddress: AztecAddress, aztecNode: AztecNode, contractStore: ContractStore, header: BlockHeader): Promise<void>;
|
|
28
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaGVscGVycy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2NvbnRyYWN0X3N5bmMvaGVscGVycy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFDQSxPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsZ0JBQWdCLEVBQUUsTUFBTSxtQkFBbUIsQ0FBQztBQUN4RSxPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsTUFBTSw2QkFBNkIsQ0FBQztBQUNoRSxPQUFPLEtBQUssRUFBRSxnQkFBZ0IsRUFBRSxNQUFNLHdCQUF3QixDQUFDO0FBQy9ELE9BQU8sS0FBSyxFQUFFLFNBQVMsRUFBRSxNQUFNLGlDQUFpQyxDQUFDO0FBQ2pFLE9BQU8sS0FBSyxFQUFFLFdBQVcsRUFBRSxNQUFNLGtCQUFrQixDQUFDO0FBRXBELE9BQU8sS0FBSyxFQUFFLGFBQWEsRUFBRSxNQUFNLDZDQUE2QyxDQUFDO0FBRWpGOzs7Ozs7Ozs7R0FTRztBQUNILHdCQUFzQixrQkFBa0IsQ0FDdEMsZUFBZSxFQUFFLFlBQVksRUFDN0IsUUFBUSxFQUFFLGdCQUFnQixFQUMxQixTQUFTLEVBQUUsU0FBUyxFQUNwQixNQUFNLEVBQUUsV0FBVyxtREFNcEI7QUFFRCx3QkFBc0IsU0FBUyxDQUM3QixlQUFlLEVBQUUsWUFBWSxFQUM3QixhQUFhLEVBQUUsYUFBYSxFQUM1Qix5QkFBeUIsRUFBRSxnQkFBZ0IsR0FBRyxJQUFJLEVBQ2xELGVBQWUsRUFBRSxDQUFDLGVBQWUsRUFBRSxZQUFZLEVBQUUsTUFBTSxFQUFFLFlBQVksRUFBRSxLQUFLLE9BQU8sQ0FBQyxHQUFHLENBQUMsRUFDeEYsS0FBSyxFQUFFLFlBQVksaUJBZXBCO0FBRUQ7Ozs7Ozs7R0FPRztBQUNILHdCQUFzQixvQkFBb0IsQ0FDeEMsZUFBZSxFQUFFLFlBQVksRUFDN0IsU0FBUyxFQUFFLFNBQVMsRUFDcEIsYUFBYSxFQUFFLGFBQWEsRUFDNUIsTUFBTSxFQUFFLFdBQVcsaUJBYXBCIn0=
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/contract_sync/helpers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACxE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6CAA6C,CAAC;AAEjF;;;;;;;;;GASG;AACH,wBAAsB,kBAAkB,CACtC,eAAe,EAAE,YAAY,EAC7B,QAAQ,EAAE,gBAAgB,EAC1B,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,WAAW,mDAMpB;AAED,wBAAsB,SAAS,CAC7B,eAAe,EAAE,YAAY,EAC7B,aAAa,EAAE,aAAa,EAC5B,yBAAyB,EAAE,gBAAgB,GAAG,IAAI,EAClD,eAAe,EAAE,CAAC,eAAe,EAAE,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,KAAK,OAAO,CAAC,GAAG,CAAC,EACxF,KAAK,EAAE,YAAY,iBAepB;AAED;;;;;;;GAOG;AACH,wBAAsB,oBAAoB,CACxC,eAAe,EAAE,YAAY,EAC7B,SAAS,EAAE,SAAS,EACpB,aAAa,EAAE,aAAa,EAC5B,MAAM,EAAE,WAAW,iBAapB"}
|