@aztec/pxe 0.0.1-commit.3100065 → 0.0.1-commit.321f6a9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/bin/check_oracle_version.js +3 -8
- package/dest/bin/index.d.ts +2 -2
- package/dest/bin/index.d.ts.map +1 -1
- package/dest/bin/index.js +1 -1
- package/dest/bin/oracle_version_helpers.d.ts +8 -25
- package/dest/bin/oracle_version_helpers.d.ts.map +1 -1
- package/dest/bin/oracle_version_helpers.js +11 -219
- package/dest/config/package_info.js +1 -1
- package/dest/contract/helpers.d.ts +1 -1
- package/dest/contract/helpers.d.ts.map +1 -1
- package/dest/contract/helpers.js +3 -3
- package/dest/contract/skip_sync_contracts.d.ts +11 -0
- package/dest/contract/skip_sync_contracts.d.ts.map +1 -0
- package/dest/contract/skip_sync_contracts.js +18 -0
- package/dest/contract_function_simulator/contract_function_simulator.d.ts +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +5 -3
- package/dest/contract_function_simulator/index.d.ts +3 -3
- package/dest/contract_function_simulator/index.d.ts.map +1 -1
- package/dest/contract_function_simulator/index.js +1 -2
- package/dest/contract_function_simulator/noir-structs/resolved_tx.d.ts +7 -9
- package/dest/contract_function_simulator/noir-structs/resolved_tx.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/resolved_tx.js +3 -44
- package/dest/contract_function_simulator/noir-structs/tx_effect_data.d.ts +5 -4
- package/dest/contract_function_simulator/noir-structs/tx_effect_data.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/tx_effect_data.js +2 -2
- package/dest/contract_function_simulator/oracle/oracle_registry.d.ts +4 -3
- package/dest/contract_function_simulator/oracle/oracle_registry.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle_registry.js +15 -6
- package/dest/contract_function_simulator/oracle/oracle_type_mappings.d.ts +87 -35
- package/dest/contract_function_simulator/oracle/oracle_type_mappings.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle_type_mappings.js +286 -286
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +5 -6
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +6 -3
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +41 -16
- 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 +10 -4
- 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 +10 -4
- 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 +42 -0
- package/dest/entrypoints/server/index.d.ts +2 -1
- package/dest/entrypoints/server/index.d.ts.map +1 -1
- package/dest/entrypoints/server/index.js +1 -0
- 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/logs/log_service.d.ts +3 -2
- package/dest/logs/log_service.d.ts.map +1 -1
- package/dest/logs/log_service.js +12 -3
- package/dest/messages/tx_resolver_service.d.ts +2 -2
- package/dest/messages/tx_resolver_service.d.ts.map +1 -1
- package/dest/messages/tx_resolver_service.js +7 -2
- 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 +3 -3
- package/dest/private_kernel/batch_planner.d.ts +1 -1
- package/dest/private_kernel/batch_planner.d.ts.map +1 -1
- package/dest/private_kernel/batch_planner.js +1 -1
- 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 +45 -5
- package/dest/pxe.d.ts +1 -1
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +8 -5
- 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 -2
- package/dest/storage/fact_store/index.d.ts.map +1 -1
- package/dest/storage/fact_store/index.js +1 -1
- package/dest/storage/fact_store/origin_state.d.ts +3 -1
- package/dest/storage/fact_store/origin_state.d.ts.map +1 -1
- package/dest/storage/fact_store/origin_state.js +7 -0
- 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/tagging/constants.d.ts +2 -1
- package/dest/tagging/constants.d.ts.map +1 -1
- package/dest/tagging/constants.js +9 -0
- package/dest/tagging/index.d.ts +2 -2
- package/dest/tagging/index.d.ts.map +1 -1
- package/dest/tagging/index.js +1 -1
- package/dest/tagging/recipient_sync/sync_tagged_private_logs.d.ts +9 -4
- package/dest/tagging/recipient_sync/sync_tagged_private_logs.d.ts.map +1 -1
- package/dest/tagging/recipient_sync/sync_tagged_private_logs.js +60 -25
- 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/dest/tagging/testing/tag_query_test_utils.d.ts +6 -0
- package/dest/tagging/testing/tag_query_test_utils.d.ts.map +1 -0
- package/dest/tagging/testing/tag_query_test_utils.js +10 -0
- package/package.json +17 -17
- package/src/bin/check_oracle_version.ts +3 -10
- package/src/bin/index.ts +1 -5
- package/src/bin/oracle_version_helpers.ts +11 -268
- package/src/config/package_info.ts +1 -1
- package/src/contract/helpers.ts +3 -3
- package/src/contract/skip_sync_contracts.ts +23 -0
- package/src/contract_function_simulator/contract_function_simulator.ts +5 -3
- package/src/contract_function_simulator/index.ts +23 -3
- package/src/contract_function_simulator/noir-structs/resolved_tx.ts +11 -45
- package/src/contract_function_simulator/noir-structs/tx_effect_data.ts +4 -3
- package/src/contract_function_simulator/oracle/oracle_registry.ts +12 -8
- package/src/contract_function_simulator/oracle/oracle_type_mappings.ts +285 -197
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +12 -7
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +55 -17
- package/src/entrypoints/client/bundle/index.ts +1 -0
- package/src/entrypoints/client/bundle/utils.ts +15 -3
- package/src/entrypoints/client/lazy/index.ts +1 -0
- package/src/entrypoints/client/lazy/utils.ts +15 -3
- package/src/entrypoints/client/store.ts +54 -0
- package/src/entrypoints/server/index.ts +1 -0
- package/src/entrypoints/server/store.ts +47 -0
- package/src/entrypoints/server/utils.ts +21 -7
- package/src/logs/log_service.ts +11 -2
- package/src/messages/tx_resolver_service.ts +8 -8
- package/src/notes/note_service.ts +1 -1
- package/src/oracle_version.ts +3 -3
- package/src/private_kernel/batch_planner.ts +0 -1
- package/src/private_kernel/private_kernel_execution_prover.ts +90 -4
- package/src/pxe.ts +8 -5
- package/src/storage/fact_store/fact_store.ts +1 -1
- package/src/storage/fact_store/index.ts +1 -0
- package/src/storage/fact_store/origin_state.ts +9 -0
- package/src/storage/store_identity.ts +72 -0
- package/src/storage/tagging_store/sender_tagging_store.ts +62 -15
- package/src/tagging/constants.ts +10 -0
- package/src/tagging/index.ts +1 -1
- package/src/tagging/recipient_sync/sync_tagged_private_logs.ts +103 -46
- 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/src/tagging/testing/tag_query_test_utils.ts +11 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/storage/fact_store/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,KAAK,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAClG,YAAY,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EACL,gBAAgB,EAChB,wBAAwB,EACxB,uBAAuB,EACvB,qBAAqB,EACrB,KAAK,eAAe,EACpB,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,EACxB,KAAK,6BAA6B,GACnC,MAAM,mBAAmB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/storage/fact_store/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,KAAK,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAClG,YAAY,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EACL,gBAAgB,EAChB,wBAAwB,EACxB,0BAA0B,EAC1B,uBAAuB,EACvB,qBAAqB,EACrB,KAAK,eAAe,EACpB,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,EACxB,KAAK,6BAA6B,GACnC,MAAM,mBAAmB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { FactStore } from './fact_store.js';
|
|
2
2
|
export { FactService } from './fact_service.js';
|
|
3
3
|
export { FactCollectionKey, FactCollectionTypeKey } from './fact_store_keys.js';
|
|
4
|
-
export { OriginBlockState, classifyOriginBlockState, anchoredTipBlockNumbers, toFactWithOriginState } from './origin_state.js';
|
|
4
|
+
export { OriginBlockState, classifyOriginBlockState, originBlockStateFromNumber, anchoredTipBlockNumbers, toFactWithOriginState } from './origin_state.js';
|
|
@@ -18,6 +18,8 @@ export declare enum OriginBlockState {
|
|
|
18
18
|
Proven = 2,
|
|
19
19
|
Finalized = 3
|
|
20
20
|
}
|
|
21
|
+
/** Parses a numeric origin-block-state discriminant, rejecting unknown values. */
|
|
22
|
+
export declare function originBlockStateFromNumber(value: number): OriginBlockState;
|
|
21
23
|
/** The two chain-tip block numbers needed to classify an origin block (`finalized <= proven` always holds). */
|
|
22
24
|
export type TipBlockNumbers = {
|
|
23
25
|
provenBlockNumber: number;
|
|
@@ -54,4 +56,4 @@ export type FactCollectionWithOriginState = {
|
|
|
54
56
|
export declare function classifyOriginBlockState(blockNumber: number, tips: TipBlockNumbers): OriginBlockState;
|
|
55
57
|
/** Enriches a stored fact with the chain state of its origin block (when retractable). */
|
|
56
58
|
export declare function toFactWithOriginState(fact: Fact, tips: TipBlockNumbers): FactWithOriginState;
|
|
57
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
59
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjo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E,MAAM,GAAG,gBAAgB,CAM1E;AAED,+GAA+G;AAC/G,MAAM,MAAM,eAAe,GAAG;IAAE,iBAAiB,EAAE,MAAM,CAAC;IAAC,oBAAoB,EAAE,MAAM,CAAA;CAAE,CAAC;AAE1F;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,GAAG,eAAe,CAKhG;AAED,yFAAyF;AACzF,MAAM,MAAM,qBAAqB,GAAG,WAAW,GAAG;IAAE,UAAU,EAAE,gBAAgB,CAAA;CAAE,CAAC;AAEnF,sGAAsG;AACtG,MAAM,MAAM,mBAAmB,GAAG;IAAE,UAAU,EAAE,EAAE,CAAC;IAAC,OAAO,EAAE,EAAE,EAAE,CAAC;IAAC,WAAW,EAAE,qBAAqB,GAAG,SAAS,CAAA;CAAE,CAAC;AAEpH,8DAA8D;AAC9D,MAAM,MAAM,6BAA6B,GAAG;IAAE,GAAG,EAAE,iBAAiB,CAAC;IAAC,KAAK,EAAE,mBAAmB,EAAE,CAAA;CAAE,CAAC;AAErG;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe,GAAG,gBAAgB,CAQrG;AAED,0FAA0F;AAC1F,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,eAAe,GAAG,mBAAmB,CAS5F"}
|
|
@@ -14,6 +14,13 @@
|
|
|
14
14
|
OriginBlockState[OriginBlockState["Finalized"] = 3] = "Finalized";
|
|
15
15
|
return OriginBlockState;
|
|
16
16
|
}({});
|
|
17
|
+
/** Parses a numeric origin-block-state discriminant, rejecting unknown values. */ export function originBlockStateFromNumber(value) {
|
|
18
|
+
if (!(value in OriginBlockState)) {
|
|
19
|
+
const validNames = Object.keys(OriginBlockState).filter((k)=>isNaN(Number(k)));
|
|
20
|
+
throw new Error(`Invalid OriginBlockState value ${value}, expected one of ${validNames.join(', ')}`);
|
|
21
|
+
}
|
|
22
|
+
return value;
|
|
23
|
+
}
|
|
17
24
|
/**
|
|
18
25
|
* Projects the live chain tips to the block numbers used for classification, capped at the anchor block.
|
|
19
26
|
*
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
|
+
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
3
|
+
/** The triple that determine which physical store a logical store name maps to. */
|
|
4
|
+
export type StoreIdentity = {
|
|
5
|
+
/** Chain ID of the L1 the rollup is deployed to. */
|
|
6
|
+
l1ChainId: number;
|
|
7
|
+
/** Address of the rollup contract the store's data pertains to. */
|
|
8
|
+
rollupAddress: EthAddress;
|
|
9
|
+
/** Schema version of the data held in the store. */
|
|
10
|
+
schemaVersion: number;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Composes the store-name discriminator for a store identity. Two identities map to the same physical store iff
|
|
14
|
+
* their slugs are equal, so the format must stay stable: `<l1ChainId>-<rollupAddress>-v<schemaVersion>` — changing
|
|
15
|
+
* it orphans every existing store.
|
|
16
|
+
*/
|
|
17
|
+
export declare function storeIdentitySlug({ l1ChainId, rollupAddress, schemaVersion }: StoreIdentity): string;
|
|
18
|
+
/** Composes the physical store name for a logical store name and identity. */
|
|
19
|
+
export declare function effectiveStoreName(name: string, identity: StoreIdentity): string;
|
|
20
|
+
/**
|
|
21
|
+
* Invariant check for stores whose physical name carries their identity: the recorded version can
|
|
22
|
+
* only disagree with the expected one if there is a store-naming bug.
|
|
23
|
+
*/
|
|
24
|
+
export declare function assertStoreIdentity(store: AztecAsyncKVStore, storeName: string, identity: StoreIdentity): Promise<void>;
|
|
25
|
+
/**
|
|
26
|
+
* Thrown when a store's recorded identity does not match the identity it was opened under. Since the identity is
|
|
27
|
+
* part of the physical store name, this can only indicate a store-naming bug; the store is left untouched.
|
|
28
|
+
*/
|
|
29
|
+
export declare class StoreIdentityMismatchError extends Error {
|
|
30
|
+
readonly storeName: string;
|
|
31
|
+
readonly expected: string;
|
|
32
|
+
readonly actual: string;
|
|
33
|
+
constructor(storeName: string, expected: string, actual: string);
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3RvcmVfaWRlbnRpdHkuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9zdG9yYWdlL3N0b3JlX2lkZW50aXR5LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLFVBQVUsRUFBRSxNQUFNLCtCQUErQixDQUFDO0FBQ2hFLE9BQU8sS0FBSyxFQUFFLGlCQUFpQixFQUFFLE1BQU0saUJBQWlCLENBQUM7QUFHekQsbUZBQW1GO0FBQ25GLE1BQU0sTUFBTSxhQUFhLEdBQUc7SUFDMUIsb0RBQW9EO0lBQ3BELFNBQVMsRUFBRSxNQUFNLENBQUM7SUFDbEIsbUVBQW1FO0lBQ25FLGFBQWEsRUFBRSxVQUFVLENBQUM7SUFDMUIsb0RBQW9EO0lBQ3BELGFBQWEsRUFBRSxNQUFNLENBQUM7Q0FDdkIsQ0FBQztBQUVGOzs7O0dBSUc7QUFDSCx3QkFBZ0IsaUJBQWlCLENBQUMsRUFBRSxTQUFTLEVBQUUsYUFBYSxFQUFFLGFBQWEsRUFBRSxFQUFFLGFBQWEsR0FBRyxNQUFNLENBRXBHO0FBRUQsOEVBQThFO0FBQzlFLHdCQUFnQixrQkFBa0IsQ0FBQyxJQUFJLEVBQUUsTUFBTSxFQUFFLFFBQVEsRUFBRSxhQUFhLEdBQUcsTUFBTSxDQUVoRjtBQUVEOzs7R0FHRztBQUNILHdCQUFzQixtQkFBbUIsQ0FDdkMsS0FBSyxFQUFFLGlCQUFpQixFQUN4QixTQUFTLEVBQUUsTUFBTSxFQUNqQixRQUFRLEVBQUUsYUFBYSxHQUN0QixPQUFPLENBQUMsSUFBSSxDQU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AE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EAO/B;CACF"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { DatabaseVersion } from '@aztec/stdlib/database-version/version';
|
|
2
|
+
/**
|
|
3
|
+
* Composes the store-name discriminator for a store identity. Two identities map to the same physical store iff
|
|
4
|
+
* their slugs are equal, so the format must stay stable: `<l1ChainId>-<rollupAddress>-v<schemaVersion>` — changing
|
|
5
|
+
* it orphans every existing store.
|
|
6
|
+
*/ export function storeIdentitySlug({ l1ChainId, rollupAddress, schemaVersion }) {
|
|
7
|
+
return `${l1ChainId}-${rollupAddress.toString()}-v${schemaVersion}`;
|
|
8
|
+
}
|
|
9
|
+
/** Composes the physical store name for a logical store name and identity. */ export function effectiveStoreName(name, identity) {
|
|
10
|
+
return `${name}_${storeIdentitySlug(identity)}`;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Invariant check for stores whose physical name carries their identity: the recorded version can
|
|
14
|
+
* only disagree with the expected one if there is a store-naming bug.
|
|
15
|
+
*/ export async function assertStoreIdentity(store, storeName, identity) {
|
|
16
|
+
const expected = new DatabaseVersion(identity.schemaVersion, identity.rollupAddress);
|
|
17
|
+
const singleton = store.openSingleton('dbVersion');
|
|
18
|
+
const stored = await singleton.getAsync();
|
|
19
|
+
if (stored === undefined) {
|
|
20
|
+
await singleton.set(expected.toBuffer().toString('utf-8'));
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
let storedVersion;
|
|
24
|
+
try {
|
|
25
|
+
storedVersion = DatabaseVersion.fromBuffer(Buffer.from(stored, 'utf-8'));
|
|
26
|
+
} catch {
|
|
27
|
+
throw new StoreIdentityMismatchError(storeName, expected.toString(), stored);
|
|
28
|
+
}
|
|
29
|
+
if (!storedVersion.equals(expected)) {
|
|
30
|
+
throw new StoreIdentityMismatchError(storeName, expected.toString(), storedVersion.toString());
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Thrown when a store's recorded identity does not match the identity it was opened under. Since the identity is
|
|
35
|
+
* part of the physical store name, this can only indicate a store-naming bug; the store is left untouched.
|
|
36
|
+
*/ export class StoreIdentityMismatchError extends Error {
|
|
37
|
+
storeName;
|
|
38
|
+
expected;
|
|
39
|
+
actual;
|
|
40
|
+
constructor(storeName, expected, actual){
|
|
41
|
+
super(`Store '${storeName}' records identity ${actual} but was opened as ${expected}. ` + `Refusing to open; data was NOT modified.`), this.storeName = storeName, this.expected = expected, this.actual = actual;
|
|
42
|
+
this.name = 'StoreIdentityMismatchError';
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -19,10 +19,11 @@ export declare class SenderTaggingStore implements StagedStore {
|
|
|
19
19
|
commit(jobId: string): Promise<void>;
|
|
20
20
|
discardStaged(jobId: string): Promise<void>;
|
|
21
21
|
/**
|
|
22
|
-
* Stores pending index ranges.
|
|
22
|
+
* Stores pending index ranges, rejecting any range that disagrees with an already-stored one.
|
|
23
23
|
* @remarks If the same (secret, txHash) pair already exists in the db with an equal range, it's a no-op. This is
|
|
24
24
|
* expected to happen because whenever we start sync we start from the last finalized index and we can have pending
|
|
25
|
-
* ranges already stored from previous syncs. If the ranges differ, it throws an error as that indicates a bug
|
|
25
|
+
* ranges already stored from previous syncs. If the ranges differ, it throws an error as that indicates a bug in
|
|
26
|
+
* callers that record indexes at prove time. Discovery from onchain logs must use `mergePendingIndexes` instead.
|
|
26
27
|
* @param ranges - The tagging index ranges containing the directional app tagging secrets and the index ranges that are
|
|
27
28
|
* to be stored in the db.
|
|
28
29
|
* @param txHash - The tx in which the tagging indexes were used in private logs.
|
|
@@ -32,6 +33,21 @@ export declare class SenderTaggingStore implements StagedStore {
|
|
|
32
33
|
* @throws If a different range already exists for the same (secret, txHash) pair.
|
|
33
34
|
*/
|
|
34
35
|
storePendingIndexes(ranges: TaggingIndexRange[], txHash: TxHash, jobId: string): Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* Stores pending index ranges, widening an existing entry for the same (secret, txHash) pair to the union of the
|
|
38
|
+
* stored and incoming ranges instead of throwing on a mismatch. Discovery from onchain logs needs this: it may see
|
|
39
|
+
* only the surviving (non-revertible phase) sub-range of a partially reverted tx recorded at prove time (the
|
|
40
|
+
* finalized receipt step of the sync resolves that difference), or indexes beyond a partially discovered entry
|
|
41
|
+
* when a tx from another PXE straddles a sync window boundary. Callers that record indexes at prove time must use
|
|
42
|
+
* `storePendingIndexes` instead, so that a range disagreement surfaces as a bug rather than being absorbed.
|
|
43
|
+
* @param ranges - The tagging index ranges containing the directional app tagging secrets and the index ranges that are
|
|
44
|
+
* to be stored in the db.
|
|
45
|
+
* @param txHash - The tx in which the tagging indexes were used in private logs.
|
|
46
|
+
* @param jobId - job context for staged writes to this store. See `JobCoordinator` for more details.
|
|
47
|
+
* @throws If the highestIndex is further than window length from the highest finalized index for the same secret.
|
|
48
|
+
* @throws If the lowestIndex is lower than or equal to the last finalized index for the same secret.
|
|
49
|
+
*/
|
|
50
|
+
mergePendingIndexes(ranges: TaggingIndexRange[], txHash: TxHash, jobId: string): Promise<void>;
|
|
35
51
|
/**
|
|
36
52
|
* Returns the transaction hashes of all pending transactions that contain highest indexes within a specified range
|
|
37
53
|
* for a given directional app tagging secret. We check based on the highest indexes only as that is the relevant
|
|
@@ -75,4 +91,4 @@ export declare class SenderTaggingStore implements StagedStore {
|
|
|
75
91
|
*/
|
|
76
92
|
finalizePendingIndexesOfAPartiallyRevertedTx(txEffect: TxEffect, jobId: string): Promise<void>;
|
|
77
93
|
}
|
|
78
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
94
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2VuZGVyX3RhZ2dpbmdfc3RvcmUuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9zdG9yYWdlL3RhZ2dpbmdfc3RvcmUvc2VuZGVyX3RhZ2dp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E,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE7F;IAED;;;;;;;;;;;;;OAaG;IACH,mBAAmB,CAAC,MAAM,EAAE,iBAAiB,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE7F;IA6FD;;;;;;;;;OASG;IACH,2BAA2B,CACzB,MAAM,EAAE,gBAAgB,EACxB,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,MAAM,EAAE,CAAC,CAQnB;IAED;;;;OAIG;IACH,qBAAqB,CAAC,MAAM,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAE1F;IAED;;;;;OAKG;IACH,gBAAgB,CAAC,MAAM,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAiBrF;IAED;;OAEG;IACH,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA2CnE;IA4CD;;;OAGG;IACG,sBAAsB,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAsD7E;IAED;;;;;;;OAOG;IACG,4CAA4C,CAAC,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAgDnG;CACF"}
|
|
@@ -100,10 +100,11 @@ import { UNFINALIZED_TAGGING_INDEXES_WINDOW_LEN } from '../../tagging/constants.
|
|
|
100
100
|
return Promise.resolve();
|
|
101
101
|
}
|
|
102
102
|
/**
|
|
103
|
-
* Stores pending index ranges.
|
|
103
|
+
* Stores pending index ranges, rejecting any range that disagrees with an already-stored one.
|
|
104
104
|
* @remarks If the same (secret, txHash) pair already exists in the db with an equal range, it's a no-op. This is
|
|
105
105
|
* expected to happen because whenever we start sync we start from the last finalized index and we can have pending
|
|
106
|
-
* ranges already stored from previous syncs. If the ranges differ, it throws an error as that indicates a bug
|
|
106
|
+
* ranges already stored from previous syncs. If the ranges differ, it throws an error as that indicates a bug in
|
|
107
|
+
* callers that record indexes at prove time. Discovery from onchain logs must use `mergePendingIndexes` instead.
|
|
107
108
|
* @param ranges - The tagging index ranges containing the directional app tagging secrets and the index ranges that are
|
|
108
109
|
* to be stored in the db.
|
|
109
110
|
* @param txHash - The tx in which the tagging indexes were used in private logs.
|
|
@@ -112,6 +113,25 @@ import { UNFINALIZED_TAGGING_INDEXES_WINDOW_LEN } from '../../tagging/constants.
|
|
|
112
113
|
* @throws If the lowestIndex is lower than or equal to the last finalized index for the same secret.
|
|
113
114
|
* @throws If a different range already exists for the same (secret, txHash) pair.
|
|
114
115
|
*/ storePendingIndexes(ranges, txHash, jobId) {
|
|
116
|
+
return this.#storePendingIndexes(ranges, txHash, jobId, false);
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Stores pending index ranges, widening an existing entry for the same (secret, txHash) pair to the union of the
|
|
120
|
+
* stored and incoming ranges instead of throwing on a mismatch. Discovery from onchain logs needs this: it may see
|
|
121
|
+
* only the surviving (non-revertible phase) sub-range of a partially reverted tx recorded at prove time (the
|
|
122
|
+
* finalized receipt step of the sync resolves that difference), or indexes beyond a partially discovered entry
|
|
123
|
+
* when a tx from another PXE straddles a sync window boundary. Callers that record indexes at prove time must use
|
|
124
|
+
* `storePendingIndexes` instead, so that a range disagreement surfaces as a bug rather than being absorbed.
|
|
125
|
+
* @param ranges - The tagging index ranges containing the directional app tagging secrets and the index ranges that are
|
|
126
|
+
* to be stored in the db.
|
|
127
|
+
* @param txHash - The tx in which the tagging indexes were used in private logs.
|
|
128
|
+
* @param jobId - job context for staged writes to this store. See `JobCoordinator` for more details.
|
|
129
|
+
* @throws If the highestIndex is further than window length from the highest finalized index for the same secret.
|
|
130
|
+
* @throws If the lowestIndex is lower than or equal to the last finalized index for the same secret.
|
|
131
|
+
*/ mergePendingIndexes(ranges, txHash, jobId) {
|
|
132
|
+
return this.#storePendingIndexes(ranges, txHash, jobId, true);
|
|
133
|
+
}
|
|
134
|
+
#storePendingIndexes(ranges, txHash, jobId, mergeExisting) {
|
|
115
135
|
if (ranges.length === 0) {
|
|
116
136
|
return Promise.resolve();
|
|
117
137
|
}
|
|
@@ -144,21 +164,38 @@ import { UNFINALIZED_TAGGING_INDEXES_WINDOW_LEN } from '../../tagging/constants.
|
|
|
144
164
|
}
|
|
145
165
|
// Check if an entry with the same txHash already exists
|
|
146
166
|
const existingEntry = pendingData.find((entry)=>entry.txHash === txHashStr);
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
throw new Error(`Conflicting range for secret ${secretStr} and txHash ${txHashStr}: ` + `existing [${existingEntry.lowestIndex}, ${existingEntry.highestIndex}] vs ` + `new [${range.lowestIndex}, ${range.highestIndex}]`);
|
|
151
|
-
}
|
|
152
|
-
// Exact duplicate — skip
|
|
153
|
-
} else {
|
|
154
|
-
this.#writePendingIndexes(jobId, secretStr, [
|
|
167
|
+
let updatedPending;
|
|
168
|
+
if (!existingEntry) {
|
|
169
|
+
updatedPending = [
|
|
155
170
|
...pendingData,
|
|
156
171
|
{
|
|
157
172
|
lowestIndex: range.lowestIndex,
|
|
158
173
|
highestIndex: range.highestIndex,
|
|
159
174
|
txHash: txHashStr
|
|
160
175
|
}
|
|
161
|
-
]
|
|
176
|
+
];
|
|
177
|
+
} else if (mergeExisting) {
|
|
178
|
+
// Widen the entry to the union of both ranges, never shrink it: replacing would drop prove-time
|
|
179
|
+
// indexes the chain doesn't show (partially reverted tx), and skipping would drop onchain indexes
|
|
180
|
+
// discovered in a later sync window (tx straddling the window boundary).
|
|
181
|
+
const lowestIndex = Math.min(existingEntry.lowestIndex, range.lowestIndex);
|
|
182
|
+
const highestIndex = Math.max(existingEntry.highestIndex, range.highestIndex);
|
|
183
|
+
if (lowestIndex !== existingEntry.lowestIndex || highestIndex !== existingEntry.highestIndex) {
|
|
184
|
+
updatedPending = pendingData.map((entry)=>entry === existingEntry ? {
|
|
185
|
+
lowestIndex,
|
|
186
|
+
highestIndex,
|
|
187
|
+
txHash: entry.txHash
|
|
188
|
+
} : entry);
|
|
189
|
+
}
|
|
190
|
+
} else if (existingEntry.lowestIndex !== range.lowestIndex || existingEntry.highestIndex !== range.highestIndex) {
|
|
191
|
+
// Different ranges for the same (secret, txHash) indicate a bug in callers that record indexes at prove
|
|
192
|
+
// time.
|
|
193
|
+
throw new Error(`Conflicting range for secret ${secretStr} and txHash ${txHashStr}: ` + `existing [${existingEntry.lowestIndex}, ${existingEntry.highestIndex}] vs ` + `new [${range.lowestIndex}, ${range.highestIndex}]`);
|
|
194
|
+
}
|
|
195
|
+
// Remaining cases (a merge whose union equals the stored range, or an identical range without
|
|
196
|
+
// mergeExisting): duplicate evidence, nothing to write.
|
|
197
|
+
if (updatedPending) {
|
|
198
|
+
this.#writePendingIndexes(jobId, secretStr, updatedPending);
|
|
162
199
|
}
|
|
163
200
|
}
|
|
164
201
|
});
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
export declare const UNFINALIZED_TAGGING_INDEXES_WINDOW_LEN: number;
|
|
2
|
-
|
|
2
|
+
export declare const INITIAL_CONSTRAINED_PROBE_LEN = 2;
|
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29uc3RhbnRzLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdGFnZ2luZy9jb25zdGFudHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBbUJBLGVBQU8sTUFBTSxzQ0FBc0MsUUFBK0IsQ0FBQztBQVVuRixlQUFPLE1BQU0sNkJBQTZCLElBQUksQ0FBQyJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/tagging/constants.ts"],"names":[],"mappings":"AAmBA,eAAO,MAAM,sCAAsC,QAA+B,CAAC"}
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/tagging/constants.ts"],"names":[],"mappings":"AAmBA,eAAO,MAAM,sCAAsC,QAA+B,CAAC;AAUnF,eAAO,MAAM,6BAA6B,IAAI,CAAC"}
|
|
@@ -17,3 +17,12 @@ import { MAX_PRIVATE_LOGS_PER_TX } from '@aztec/constants';
|
|
|
17
17
|
// reserved at log emission time, before squashing is decided, and the kernel's reset/squash loop is not bounded by
|
|
18
18
|
// MAX_PRIVATE_LOGS_PER_TX. No fixed window value closes that gap.
|
|
19
19
|
export const UNFINALIZED_TAGGING_INDEXES_WINDOW_LEN = MAX_PRIVATE_LOGS_PER_TX + 20;
|
|
20
|
+
// The number of tags probed per constrained secret in the first round.
|
|
21
|
+
//
|
|
22
|
+
// The probe doubles each round (2, 4, 8, ..., capped at UNFINALIZED_TAGGING_INDEXES_WINDOW_LEN) while every probed
|
|
23
|
+
// index is a hit, stopping at the first missing tag. Constrained delivery is gapless, so a single missing tag proves
|
|
24
|
+
// the stream has ended: at steady state this turns a full WINDOW_LEN probe into two tags. A secret K logs behind
|
|
25
|
+
// catches up in ~log2(K) round-trips while the probe is still doubling (2, 4, 8, 16, 32), but once it saturates the cap
|
|
26
|
+
// and advances WINDOW_LEN tags per round, deeper catch-up is linear at ~K/WINDOW_LEN rounds. Either way it beats both
|
|
27
|
+
// the full window every round and one round per log.
|
|
28
|
+
export const INITIAL_CONSTRAINED_PROBE_LEN = 2;
|
package/dest/tagging/index.d.ts
CHANGED
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
export { syncTaggedPrivateLogs } from './recipient_sync/sync_tagged_private_logs.js';
|
|
12
12
|
export { syncSenderTaggingIndexes } from './sender_sync/sync_sender_tagging_indexes.js';
|
|
13
13
|
export { persistSenderTaggingIndexRangesForTx } from './persist_sender_tagging_index_ranges.js';
|
|
14
|
-
export { UNFINALIZED_TAGGING_INDEXES_WINDOW_LEN } from './constants.js';
|
|
14
|
+
export { UNFINALIZED_TAGGING_INDEXES_WINDOW_LEN, INITIAL_CONSTRAINED_PROBE_LEN } from './constants.js';
|
|
15
15
|
export { getAllPrivateLogsByTags, getAllPublicLogsByTagsFromContract } from './get_all_logs_by_tags.js';
|
|
16
16
|
export { AppTaggingSecret, Tag, SiloedTag } from '@aztec/stdlib/logs';
|
|
17
17
|
export { type PreTag, type TaggingIndexRange } from '@aztec/stdlib/logs';
|
|
18
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
18
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy90YWdnaW5nL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOzs7Ozs7Ozs7R0FTRztBQUVILE9BQU8sRUFBRSxxQkFBcUIsRUFBRSxNQUFNLDhDQUE4QyxDQUFDO0FBQ3JGLE9BQU8sRUFBRSx3QkFBd0IsRUFBRSxNQUFNLDhDQUE4QyxDQUFDO0FBQ3hGLE9BQU8sRUFBRSxvQ0FBb0MsRUFBRSxNQUFNLDBDQUEwQyxDQUFDO0FBQ2hHLE9BQU8sRUFBRSxzQ0FBc0MsRUFBRSw2QkFBNkIsRUFBRSxNQUFNLGdCQUFnQixDQUFDO0FBQ3ZHLE9BQU8sRUFBRSx1QkFBdUIsRUFBRSxrQ0FBa0MsRUFBRSxNQUFNLDJCQUEyQixDQUFDO0FBR3hHLE9BQU8sRUFBRSxnQkFBZ0IsRUFBRSxHQUFHLEVBQUUsU0FBUyxFQUFFLE1BQU0sb0JBQW9CLENBQUM7QUFDdEUsT0FBTyxFQUFFLEtBQUssTUFBTSxFQUFFLEtBQUssaUJBQWlCLEVBQUUsTUFBTSxvQkFBb0IsQ0FBQyJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tagging/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,qBAAqB,EAAE,MAAM,8CAA8C,CAAC;AACrF,OAAO,EAAE,wBAAwB,EAAE,MAAM,8CAA8C,CAAC;AACxF,OAAO,EAAE,oCAAoC,EAAE,MAAM,0CAA0C,CAAC;AAChG,OAAO,EAAE,sCAAsC,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tagging/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,qBAAqB,EAAE,MAAM,8CAA8C,CAAC;AACrF,OAAO,EAAE,wBAAwB,EAAE,MAAM,8CAA8C,CAAC;AACxF,OAAO,EAAE,oCAAoC,EAAE,MAAM,0CAA0C,CAAC;AAChG,OAAO,EAAE,sCAAsC,EAAE,6BAA6B,EAAE,MAAM,gBAAgB,CAAC;AACvG,OAAO,EAAE,uBAAuB,EAAE,kCAAkC,EAAE,MAAM,2BAA2B,CAAC;AAGxG,OAAO,EAAE,gBAAgB,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACtE,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,iBAAiB,EAAE,MAAM,oBAAoB,CAAC"}
|
package/dest/tagging/index.js
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
*/ export { syncTaggedPrivateLogs } from './recipient_sync/sync_tagged_private_logs.js';
|
|
11
11
|
export { syncSenderTaggingIndexes } from './sender_sync/sync_sender_tagging_indexes.js';
|
|
12
12
|
export { persistSenderTaggingIndexRangesForTx } from './persist_sender_tagging_index_ranges.js';
|
|
13
|
-
export { UNFINALIZED_TAGGING_INDEXES_WINDOW_LEN } from './constants.js';
|
|
13
|
+
export { UNFINALIZED_TAGGING_INDEXES_WINDOW_LEN, INITIAL_CONSTRAINED_PROBE_LEN } from './constants.js';
|
|
14
14
|
export { getAllPrivateLogsByTags, getAllPublicLogsByTagsFromContract } from './get_all_logs_by_tags.js';
|
|
15
15
|
// Re-export tagging-related types from stdlib
|
|
16
16
|
export { AppTaggingSecret, Tag, SiloedTag } from '@aztec/stdlib/logs';
|
|
@@ -54,9 +54,14 @@ import type { RecipientTaggingStore } from '../../storage/tagging_store/recipien
|
|
|
54
54
|
* - The lower bound is `highestFinalizedIndex + 1`. The `highestAgedIndex` mechanism is unnecessary because
|
|
55
55
|
* the nullifier chain prevents out-of-order index usage: no device can fill in a lower index after a higher
|
|
56
56
|
* one is already on-chain.
|
|
57
|
-
* -
|
|
58
|
-
*
|
|
59
|
-
*
|
|
57
|
+
* - Because the sequence is gapless, the scan stops at the first missing index: that gap proves the sequence has
|
|
58
|
+
* ended and no further logs exist. We exploit this with a doubling first-miss probe (see
|
|
59
|
+
* `INITIAL_CONSTRAINED_PROBE_LEN` in ../constants.ts), so a
|
|
60
|
+
* steady-state sync with no new logs costs two tags instead of the whole window. The probe length is in-memory
|
|
61
|
+
* state scoped to one sync call, so every sync restarts at the initial probe.
|
|
62
|
+
* - The upper bound is the same as unconstrained: `highestFinalizedIndex + WINDOW_LEN`. Advancing the probe is
|
|
63
|
+
* decoupled from persisting the finalized index, so unfinalized logs at the top of the run are still fetched
|
|
64
|
+
* while only the finalized prefix is persisted.
|
|
60
65
|
*
|
|
61
66
|
* # Batching across secrets
|
|
62
67
|
*
|
|
@@ -66,4 +71,4 @@ import type { RecipientTaggingStore } from '../../storage/tagging_store/recipien
|
|
|
66
71
|
* advanced are kept for the next iteration.
|
|
67
72
|
*/
|
|
68
73
|
export declare function syncTaggedPrivateLogs(secrets: AppTaggingSecret[], aztecNode: AztecNode, taggingStore: RecipientTaggingStore, anchorBlockHeader: BlockHeader, finalizedBlockNumber: BlockNumber, jobId: string): Promise<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"sync_tagged_private_logs.d.ts","sourceRoot":"","sources":["../../../src/tagging/recipient_sync/sync_tagged_private_logs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAG9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,KAAK,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEtE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,wDAAwD,CAAC;AAKpG
|
|
1
|
+
{"version":3,"file":"sync_tagged_private_logs.d.ts","sourceRoot":"","sources":["../../../src/tagging/recipient_sync/sync_tagged_private_logs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAG9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,KAAK,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEtE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,wDAAwD,CAAC;AAKpG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkEG;AACH,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,gBAAgB,EAAE,EAC3B,SAAS,EAAE,SAAS,EACpB,YAAY,EAAE,qBAAqB,EACnC,iBAAiB,EAAE,WAAW,EAC9B,oBAAoB,EAAE,WAAW,EACjC,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,SAAS,EAAE,CAAC,CAqDtB"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
2
|
import { isDefined } from '@aztec/foundation/types';
|
|
3
3
|
import { AppTaggingSecretKind, SiloedTag } from '@aztec/stdlib/logs';
|
|
4
|
-
import { UNFINALIZED_TAGGING_INDEXES_WINDOW_LEN } from '../constants.js';
|
|
4
|
+
import { INITIAL_CONSTRAINED_PROBE_LEN, UNFINALIZED_TAGGING_INDEXES_WINDOW_LEN } from '../constants.js';
|
|
5
5
|
import { getAllPrivateLogsByTags } from '../get_all_logs_by_tags.js';
|
|
6
6
|
import { findHighestIndexes } from './utils/find_highest_indexes.js';
|
|
7
7
|
/**
|
|
@@ -55,9 +55,14 @@ import { findHighestIndexes } from './utils/find_highest_indexes.js';
|
|
|
55
55
|
* - The lower bound is `highestFinalizedIndex + 1`. The `highestAgedIndex` mechanism is unnecessary because
|
|
56
56
|
* the nullifier chain prevents out-of-order index usage: no device can fill in a lower index after a higher
|
|
57
57
|
* one is already on-chain.
|
|
58
|
-
* -
|
|
59
|
-
*
|
|
60
|
-
*
|
|
58
|
+
* - Because the sequence is gapless, the scan stops at the first missing index: that gap proves the sequence has
|
|
59
|
+
* ended and no further logs exist. We exploit this with a doubling first-miss probe (see
|
|
60
|
+
* `INITIAL_CONSTRAINED_PROBE_LEN` in ../constants.ts), so a
|
|
61
|
+
* steady-state sync with no new logs costs two tags instead of the whole window. The probe length is in-memory
|
|
62
|
+
* state scoped to one sync call, so every sync restarts at the initial probe.
|
|
63
|
+
* - The upper bound is the same as unconstrained: `highestFinalizedIndex + WINDOW_LEN`. Advancing the probe is
|
|
64
|
+
* decoupled from persisting the finalized index, so unfinalized logs at the top of the run are still fetched
|
|
65
|
+
* while only the finalized prefix is persisted.
|
|
61
66
|
*
|
|
62
67
|
* # Batching across secrets
|
|
63
68
|
*
|
|
@@ -87,8 +92,7 @@ import { findHighestIndexes } from './utils/find_highest_indexes.js';
|
|
|
87
92
|
allLogs.push(...logsFoundWithSecret.map(({ log })=>log));
|
|
88
93
|
// Persist new indexes. If the finalized index moved forward, the window advances
|
|
89
94
|
// and we need another round for this secret.
|
|
90
|
-
|
|
91
|
-
return await processForKind(pendingSecret, logsFoundWithSecret, taggingStore, currentTimestamp, finalizedBlockNumber, jobId);
|
|
95
|
+
return pendingSecret.kind === AppTaggingSecretKind.CONSTRAINED ? await processConstrainedResults(pendingSecret, logsFoundWithSecret, taggingStore, currentTimestamp, finalizedBlockNumber, jobId) : await processUnconstrainedResults(pendingSecret, logsFoundWithSecret, taggingStore, currentTimestamp, finalizedBlockNumber, jobId);
|
|
92
96
|
}));
|
|
93
97
|
pending = nextRound.filter(isDefined);
|
|
94
98
|
}
|
|
@@ -97,13 +101,29 @@ import { findHighestIndexes } from './utils/find_highest_indexes.js';
|
|
|
97
101
|
/** Reads stored indexes for each secret and computes the initial index range to query. */ function getIndexRangesForSecrets(secrets, taggingStore, jobId) {
|
|
98
102
|
return Promise.all(secrets.map(async (secret)=>{
|
|
99
103
|
const currentHighestFinalizedIndex = await taggingStore.getHighestFinalizedIndex(secret, jobId);
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
|
|
104
|
+
const boundEnd = (currentHighestFinalizedIndex ?? 0) + UNFINALIZED_TAGGING_INDEXES_WINDOW_LEN + 1;
|
|
105
|
+
if (secret.kind === AppTaggingSecretKind.CONSTRAINED) {
|
|
106
|
+
// Constrained streams are gapless and resume at the finalized index, so probe a small initial window and stop
|
|
107
|
+
// at the first missing tag instead of always fetching the full window. The probe grows each round up to the
|
|
108
|
+
// window cap.
|
|
109
|
+
const start = currentHighestFinalizedIndex === undefined ? 0 : currentHighestFinalizedIndex + 1;
|
|
110
|
+
return {
|
|
111
|
+
kind: AppTaggingSecretKind.CONSTRAINED,
|
|
112
|
+
secret,
|
|
113
|
+
start,
|
|
114
|
+
end: Math.min(boundEnd, start + INITIAL_CONSTRAINED_PROBE_LEN),
|
|
115
|
+
boundEnd,
|
|
116
|
+
probeLen: INITIAL_CONSTRAINED_PROBE_LEN
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
// Unconstrained secrets can have gaps, so they scan the whole window starting past the highest aged index.
|
|
120
|
+
const highestAgedIndex = await taggingStore.getHighestAgedIndex(secret, jobId);
|
|
121
|
+
const start = highestAgedIndex === undefined ? 0 : highestAgedIndex + 1;
|
|
103
122
|
return {
|
|
123
|
+
kind: AppTaggingSecretKind.UNCONSTRAINED,
|
|
104
124
|
secret,
|
|
105
125
|
start,
|
|
106
|
-
end
|
|
126
|
+
end: boundEnd
|
|
107
127
|
};
|
|
108
128
|
}));
|
|
109
129
|
}
|
|
@@ -148,30 +168,43 @@ import { findHighestIndexes } from './utils/find_highest_indexes.js';
|
|
|
148
168
|
return logsPerSecret;
|
|
149
169
|
}
|
|
150
170
|
/**
|
|
151
|
-
* Processes fetched logs for a constrained secret
|
|
152
|
-
*
|
|
171
|
+
* Processes fetched logs for a constrained secret: persists the finalized index and advances the probe. See the
|
|
172
|
+
* "# Constrained secrets" section above for why the scan stops at the first missing index. Only `highestFinalizedIndex`
|
|
153
173
|
* is tracked (no aged index).
|
|
154
174
|
*/ async function processConstrainedResults(pending, logsWithIndexes, taggingStore, currentTimestamp, finalizedBlockNumber, jobId) {
|
|
155
|
-
// Find where the contiguous run of indexes ends
|
|
156
|
-
// first gap, so all logs in the batch are within this prefix.
|
|
175
|
+
// Find where the contiguous run of indexes ends; all logs in the batch fall within this prefix.
|
|
157
176
|
const indexesWithLogs = new Set(logsWithIndexes.map((l)=>l.taggingIndex));
|
|
158
177
|
let firstMissingIndex = pending.start;
|
|
159
178
|
while(firstMissingIndex < pending.end && indexesWithLogs.has(firstMissingIndex)){
|
|
160
179
|
firstMissingIndex++;
|
|
161
180
|
}
|
|
162
|
-
//
|
|
163
|
-
// transaction, guaranteeing the log cannot disappear once included, so we persist the
|
|
164
|
-
//
|
|
181
|
+
// Persist the highest finalized index found. The nullifier for a constrained-delivery log is emitted in the same
|
|
182
|
+
// transaction, guaranteeing the log cannot disappear once included, so we persist even when a gap stops the scan.
|
|
183
|
+
// This lets the next sync round skip already-finalized indexes.
|
|
165
184
|
const { highestFinalizedIndex } = findHighestIndexes(logsWithIndexes, currentTimestamp, finalizedBlockNumber);
|
|
166
185
|
if (highestFinalizedIndex !== undefined) {
|
|
167
186
|
await taggingStore.updateHighestFinalizedIndex(pending.secret, highestFinalizedIndex, jobId);
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
187
|
+
}
|
|
188
|
+
// Advancing the probe is decoupled from persisting the finalized index: keep scanning as long as the probe was
|
|
189
|
+
// entirely hits (no gap) and there is room before the protocol bound, even if none of those hits is finalized yet.
|
|
190
|
+
// Gating this on finalization would drop logs in unfinalized blocks, which sit at the top of the contiguous run.
|
|
191
|
+
// The bound re-anchors to any finalized index found this round.
|
|
192
|
+
const probeFullyConsumed = firstMissingIndex >= pending.end;
|
|
193
|
+
const boundEnd = highestFinalizedIndex !== undefined ? Math.max(pending.boundEnd, highestFinalizedIndex + UNFINALIZED_TAGGING_INDEXES_WINDOW_LEN + 1) : pending.boundEnd;
|
|
194
|
+
// Double the probe each round, capped at the window (see INITIAL_CONSTRAINED_PROBE_LEN in ../constants.ts).
|
|
195
|
+
// The queried range is already bounded by boundEnd (a probe can never reach
|
|
196
|
+
// more than WINDOW_LEN past the finalized frontier); this cap just keeps the stored length from growing unbounded
|
|
197
|
+
// once the probe saturates the window.
|
|
198
|
+
const nextProbeLen = Math.min(pending.probeLen * 2, UNFINALIZED_TAGGING_INDEXES_WINDOW_LEN);
|
|
199
|
+
if (probeFullyConsumed && pending.end < boundEnd) {
|
|
200
|
+
return {
|
|
201
|
+
kind: AppTaggingSecretKind.CONSTRAINED,
|
|
202
|
+
secret: pending.secret,
|
|
203
|
+
start: pending.end,
|
|
204
|
+
end: Math.min(boundEnd, pending.end + nextProbeLen),
|
|
205
|
+
boundEnd,
|
|
206
|
+
probeLen: nextProbeLen
|
|
207
|
+
};
|
|
175
208
|
}
|
|
176
209
|
return undefined;
|
|
177
210
|
}
|
|
@@ -195,9 +228,11 @@ import { findHighestIndexes } from './utils/find_highest_indexes.js';
|
|
|
195
228
|
await taggingStore.updateHighestFinalizedIndex(pending.secret, highestFinalizedIndex, jobId);
|
|
196
229
|
// For the next iteration we want to look only at indexes for which we have not yet fetched logs while
|
|
197
230
|
// ensuring that we do not look further than WINDOW_LEN ahead of the highest finalized index.
|
|
231
|
+
const end = highestFinalizedIndex + UNFINALIZED_TAGGING_INDEXES_WINDOW_LEN + 1;
|
|
198
232
|
return {
|
|
233
|
+
kind: AppTaggingSecretKind.UNCONSTRAINED,
|
|
199
234
|
secret: pending.secret,
|
|
200
235
|
start: pending.end,
|
|
201
|
-
end
|
|
236
|
+
end
|
|
202
237
|
};
|
|
203
238
|
}
|
|
@@ -48,7 +48,7 @@ import { loadAndStoreNewTaggingIndexes } from './utils/load_and_store_new_taggin
|
|
|
48
48
|
break;
|
|
49
49
|
}
|
|
50
50
|
// Receipts for pending tx hashes that the logs query just surfaced still need a sequential follow-up call.
|
|
51
|
-
// `
|
|
51
|
+
// `mergePendingIndexes` is idempotent on (secret, txHash), so a re-discovered hash stays classified as known
|
|
52
52
|
// and is not re-fetched here.
|
|
53
53
|
const knownSet = new Set(knownPendingTxHashes.map((h)=>h.toString()));
|
|
54
54
|
const newPendingTxHashes = allPendingTxHashes.filter((h)=>!knownSet.has(h.toString()));
|
|
@@ -16,4 +16,4 @@ import type { SenderTaggingStore } from '../../../storage/tagging_store/sender_t
|
|
|
16
16
|
* preserving way.
|
|
17
17
|
*/
|
|
18
18
|
export declare function loadAndStoreNewTaggingIndexes(extendedSecret: AppTaggingSecret, start: number, end: number, aztecNode: AztecNode, taggingStore: SenderTaggingStore, anchorBlockHash: BlockHash, jobId: string): Promise<void>;
|
|
19
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
19
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibG9hZF9hbmRfc3RvcmVfbmV3X3RhZ2dpbmdfaW5kZXhlcy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vc3JjL3RhZ2dpbmcvc2VuZGVyX3N5bmMvdXRpbHMvbG9hZF9hbmRfc3RvcmVfbmV3X3RhZ2dpbmdfaW5kZXhlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxxQkFBcUIsQ0FBQztBQUNyRCxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUNqRSxPQUFPLEVBQUUsS0FBSyxnQkFBZ0IsRUFBYSxNQUFNLG9CQUFvQixDQUFDO0FBR3RFLE9BQU8sS0FBSyxFQUFFLGtCQUFrQixFQUFFLE1BQU0sd0RBQXdELENBQUM7QUFHakc7Ozs7Ozs7Ozs7OztHQVlHO0FBQ0gsd0JBQXNCLDZCQUE2QixDQUNqRCxjQUFjLEVBQUUsZ0JBQWdCLEVBQ2hDLEtBQUssRUFBRSxNQUFNLEVBQ2IsR0FBRyxFQUFFLE1BQU0sRUFDWCxTQUFTLEVBQUUsU0FBUyxFQUNwQixZQUFZLEVBQUUsa0JBQWtCLEVBQ2hDLGVBQWUsRUFBRSxTQUFTLEVBQzFCLEtBQUssRUFBRSxNQUFNLGlCQW9CZCJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load_and_store_new_tagging_indexes.d.ts","sourceRoot":"","sources":["../../../../src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,KAAK,gBAAgB,EAAa,MAAM,oBAAoB,CAAC;AAGtE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wDAAwD,CAAC;AAGjG;;;;;;;;;;;;GAYG;AACH,wBAAsB,6BAA6B,CACjD,cAAc,EAAE,gBAAgB,EAChC,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,SAAS,EACpB,YAAY,EAAE,kBAAkB,EAChC,eAAe,EAAE,SAAS,EAC1B,KAAK,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"load_and_store_new_tagging_indexes.d.ts","sourceRoot":"","sources":["../../../../src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,KAAK,gBAAgB,EAAa,MAAM,oBAAoB,CAAC;AAGtE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wDAAwD,CAAC;AAGjG;;;;;;;;;;;;GAYG;AACH,wBAAsB,6BAA6B,CACjD,cAAc,EAAE,gBAAgB,EAChC,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,SAAS,EACpB,YAAY,EAAE,kBAAkB,EAChC,eAAe,EAAE,SAAS,EAC1B,KAAK,EAAE,MAAM,iBAoBd"}
|
|
@@ -23,7 +23,11 @@ import { getAllPrivateLogsByTags } from '../../get_all_logs_by_tags.js';
|
|
|
23
23
|
})));
|
|
24
24
|
const txsForTags = await getTxsContainingTags(siloedTagsForWindow, aztecNode, anchorBlockHash);
|
|
25
25
|
const txIndexesMap = getTxIndexesMap(txsForTags, start, siloedTagsForWindow.length);
|
|
26
|
-
// Now we iterate over the map, construct the tagging index ranges and store them in the db.
|
|
26
|
+
// Now we iterate over the map, construct the tagging index ranges and store them in the db. A tx already tracked
|
|
27
|
+
// in the store is merged rather than range-checked: if this PXE sent the tx and it partially reverted, the chain
|
|
28
|
+
// only shows the surviving sub-range of the prove-time entry (the finalized receipt step of the sync owns
|
|
29
|
+
// resolving that difference), and a tx from another PXE may straddle a sync window boundary, in which case the
|
|
30
|
+
// entry is widened so the next index choice covers the full onchain range.
|
|
27
31
|
for (const [txHashStr, indexes] of txIndexesMap.entries()){
|
|
28
32
|
const txHash = TxHash.fromString(txHashStr);
|
|
29
33
|
const ranges = [
|
|
@@ -33,7 +37,7 @@ import { getAllPrivateLogsByTags } from '../../get_all_logs_by_tags.js';
|
|
|
33
37
|
highestIndex: Math.max(...indexes)
|
|
34
38
|
}
|
|
35
39
|
];
|
|
36
|
-
await taggingStore.
|
|
40
|
+
await taggingStore.mergePendingIndexes(ranges, txHash, jobId);
|
|
37
41
|
}
|
|
38
42
|
}
|
|
39
43
|
// Returns txs that used the given tags. A tag might have been used in multiple txs and for this reason we return
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type AppTaggingSecret, type PrivateLogsQuery, SiloedTag } from '@aztec/stdlib/logs';
|
|
2
|
+
/** Computes the siloed tag */
|
|
3
|
+
export declare function computeSiloedTagForIndex(secret: AppTaggingSecret, index: number): Promise<SiloedTag>;
|
|
4
|
+
/** Extracts the bare-tag set from a query */
|
|
5
|
+
export declare function extractTags(query: PrivateLogsQuery): SiloedTag[];
|
|
6
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGFnX3F1ZXJ5X3Rlc3RfdXRpbHMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy90YWdnaW5nL3Rlc3RpbmcvdGFnX3F1ZXJ5X3Rlc3RfdXRpbHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLEtBQUssZ0JBQWdCLEVBQUUsS0FBSyxnQkFBZ0IsRUFBRSxTQUFTLEVBQWlCLE1BQU0sb0JBQW9CLENBQUM7QUFFNUcsOEJBQThCO0FBQzlCLHdCQUFnQix3QkFBd0IsQ0FBQyxNQUFNLEVBQUUsZ0JBQWdCLEVBQUUsS0FBSyxFQUFFLE1BQU0sR0FBRyxPQUFPLENBQUMsU0FBUyxDQUFDLENBRXBHO0FBRUQsNkNBQTZDO0FBQzdDLHdCQUFnQixXQUFXLENBQUMsS0FBSyxFQUFFLGdCQUFnQixHQUFHLFNBQVMsRUFBRSxDQUVoRSJ9
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tag_query_test_utils.d.ts","sourceRoot":"","sources":["../../../src/tagging/testing/tag_query_test_utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,gBAAgB,EAAE,KAAK,gBAAgB,EAAE,SAAS,EAAiB,MAAM,oBAAoB,CAAC;AAE5G,8BAA8B;AAC9B,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,CAEpG;AAED,6CAA6C;AAC7C,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,GAAG,SAAS,EAAE,CAEhE"}
|