@aztec-labs/pxe 6.0.0-rc.3 → 6.0.0-rc.4
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/config/index.d.ts +1 -1
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +2 -1
- package/dest/contract_function_simulator/index.d.ts +2 -2
- package/dest/contract_function_simulator/index.d.ts.map +1 -1
- package/dest/contract_function_simulator/index.js +1 -1
- package/dest/contract_function_simulator/noir-structs/fact_collection.d.ts +6 -12
- package/dest/contract_function_simulator/noir-structs/fact_collection.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/fact_collection.js +1 -15
- package/dest/contract_function_simulator/oracle/oracle_registry.d.ts +5 -5
- package/dest/contract_function_simulator/oracle/oracle_registry.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle_registry.js +5 -5
- package/dest/contract_function_simulator/oracle/oracle_type_mappings.d.ts +3 -2
- package/dest/contract_function_simulator/oracle/oracle_type_mappings.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle_type_mappings.js +16 -2
- package/dest/contract_function_simulator/oracle/private_execution.d.ts +1 -1
- package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution.js +1 -0
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +6 -6
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +3 -2
- package/dest/contract_function_simulator/pick_notes.d.ts +1 -1
- package/dest/contract_function_simulator/pick_notes.d.ts.map +1 -1
- package/dest/contract_function_simulator/pick_notes.js +1 -0
- package/dest/entrypoints/server/circuit_recording/simulator_recorder_wrapper.d.ts +1 -1
- package/dest/entrypoints/server/circuit_recording/simulator_recorder_wrapper.d.ts.map +1 -1
- package/dest/entrypoints/server/circuit_recording/simulator_recorder_wrapper.js +1 -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 +3 -1
- package/dest/oracle_version.d.ts +3 -3
- 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 -0
- package/dest/private_kernel/hints/test_utils.d.ts +1 -1
- package/dest/private_kernel/hints/test_utils.d.ts.map +1 -1
- package/dest/private_kernel/hints/test_utils.js +1 -0
- package/dest/private_kernel/private_kernel_execution_prover.d.ts +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.js +1 -0
- package/dest/pxe.d.ts +27 -2
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +201 -128
- package/dest/storage/address_store/address_store.d.ts +1 -1
- package/dest/storage/address_store/address_store.d.ts.map +1 -1
- package/dest/storage/address_store/address_store.js +1 -0
- package/dest/storage/backwards_compatibility_tests/kv_store_snapshot.d.ts +1 -1
- package/dest/storage/backwards_compatibility_tests/kv_store_snapshot.d.ts.map +1 -1
- package/dest/storage/backwards_compatibility_tests/kv_store_snapshot.js +1 -0
- 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 +23 -1
- package/dest/storage/contract_store/contract_store.d.ts +2 -1
- package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
- package/dest/storage/contract_store/contract_store.js +1 -0
- package/dest/storage/fact_store/fact_scope.d.ts +19 -0
- package/dest/storage/fact_store/fact_scope.d.ts.map +1 -0
- package/dest/storage/fact_store/fact_scope.js +37 -0
- package/dest/storage/fact_store/fact_service.d.ts +2 -2
- package/dest/storage/fact_store/fact_service.d.ts.map +1 -1
- package/dest/storage/fact_store/fact_service.js +19 -5
- package/dest/storage/fact_store/fact_store_keys.d.ts +6 -5
- package/dest/storage/fact_store/fact_store_keys.d.ts.map +1 -1
- package/dest/storage/fact_store/fact_store_keys.js +24 -8
- 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/stored_fact.d.ts +9 -3
- package/dest/storage/fact_store/stored_fact.d.ts.map +1 -1
- package/dest/storage/fact_store/stored_fact.js +45 -3
- package/dest/storage/store_identity.d.ts +1 -1
- package/dest/storage/store_identity.d.ts.map +1 -1
- package/dest/storage/store_identity.js +1 -0
- package/package.json +21 -20
- package/src/config/index.ts +2 -1
- package/src/contract_function_simulator/index.ts +1 -0
- package/src/contract_function_simulator/noir-structs/fact_collection.ts +6 -22
- package/src/contract_function_simulator/oracle/oracle_registry.ts +5 -4
- package/src/contract_function_simulator/oracle/oracle_type_mappings.ts +15 -1
- package/src/contract_function_simulator/oracle/private_execution.ts +1 -0
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +8 -7
- package/src/contract_function_simulator/pick_notes.ts +1 -0
- package/src/entrypoints/server/circuit_recording/simulator_recorder_wrapper.ts +1 -0
- package/src/entrypoints/server/utils.ts +4 -2
- package/src/oracle_version.ts +3 -3
- package/src/private_kernel/batch_planner.ts +1 -0
- package/src/private_kernel/hints/test_utils.ts +1 -0
- package/src/private_kernel/private_kernel_execution_prover.ts +1 -0
- package/src/pxe.ts +291 -189
- package/src/storage/address_store/address_store.ts +1 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/FactStore.json +20 -0
- package/src/storage/backwards_compatibility_tests/kv_store_snapshot.ts +1 -0
- package/src/storage/backwards_compatibility_tests/schema_tests.ts +18 -1
- package/src/storage/contract_store/contract_store.ts +1 -0
- package/src/storage/fact_store/fact_scope.ts +39 -0
- package/src/storage/fact_store/fact_service.ts +20 -5
- package/src/storage/fact_store/fact_store_keys.ts +28 -15
- package/src/storage/fact_store/index.ts +1 -0
- package/src/storage/fact_store/stored_fact.ts +50 -14
- package/src/storage/store_identity.ts +1 -0
|
@@ -8,7 +8,7 @@ import { type FactCollectionWithOriginState, type TipBlockNumbers } from './orig
|
|
|
8
8
|
* Wraps a {@link FactStore} with scope-based access control.
|
|
9
9
|
*
|
|
10
10
|
* Each method asserts scope validity before delegating to FactStore, gating which accounts a contract may record facts
|
|
11
|
-
* under or read facts from.
|
|
11
|
+
* under or read facts from. The public scope belongs to no account, so it is always allowed.
|
|
12
12
|
*/
|
|
13
13
|
export declare class FactService {
|
|
14
14
|
#private;
|
|
@@ -20,4 +20,4 @@ export declare class FactService {
|
|
|
20
20
|
getFactCollection(factCollectionKey: FactCollectionKey, tips: TipBlockNumbers, changeSetId: ChangeSetId): Promise<FactCollectionWithOriginState | undefined>;
|
|
21
21
|
getFactCollectionsByType(factCollectionTypeKey: FactCollectionTypeKey, tips: TipBlockNumbers, changeSetId: ChangeSetId): Promise<FactCollectionWithOriginState[]>;
|
|
22
22
|
}
|
|
23
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
23
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmFjdF9zZXJ2aWNlLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvc3RvcmFnZS9mYWN0X3N0b3JlL2ZhY3Rfc2VydmljZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxFQUFFLEVBQUUsTUFBTSxxQ0FBcUMsQ0FBQztBQUM5RCxPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsTUFBTSxrQ0FBa0MsQ0FBQztBQUdyRSxPQUFPLEtBQUssRUFBRSxXQUFXLEVBQUUsTUFBTSxnQ0FBZ0MsQ0FBQztBQUVsRSxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxpQkFBaUIsQ0FBQztBQUNqRCxPQ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UFDLENBSTFDO0NBbUJGIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fact_service.d.ts","sourceRoot":"","sources":["../../../src/storage/fact_store/fact_service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,qCAAqC,CAAC;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAGrE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"fact_service.d.ts","sourceRoot":"","sources":["../../../src/storage/fact_store/fact_service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,qCAAqC,CAAC;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAGrE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAElE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AACrG,OAAO,EACL,KAAK,6BAA6B,EAElC,KAAK,eAAe,EAErB,MAAM,mBAAmB,CAAC;AAG3B;;;;;GAKG;AACH,qBAAa,WAAW;;IAEpB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,aAAa;IAFhC,YACmB,SAAS,EAAE,SAAS,EACpB,aAAa,EAAE,YAAY,EAAE,EAC5C;IAEJ,UAAU,CACR,iBAAiB,EAAE,iBAAiB,EACpC,UAAU,EAAE,EAAE,EACd,OAAO,EAAE,EAAE,EAAE,EACb,WAAW,EAAE,cAAc,GAAG,SAAS,EACvC,WAAW,EAAE,WAAW,GACvB,OAAO,CAAC,IAAI,CAAC,CAGf;IAED,oBAAoB,CAAC,iBAAiB,EAAE,iBAAiB,EAAE,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAGlG;IAEK,iBAAiB,CACrB,iBAAiB,EAAE,iBAAiB,EACpC,IAAI,EAAE,eAAe,EACrB,WAAW,EAAE,WAAW,GACvB,OAAO,CAAC,6BAA6B,GAAG,SAAS,CAAC,CAOpD;IAEK,wBAAwB,CAC5B,qBAAqB,EAAE,qBAAqB,EAC5C,IAAI,EAAE,eAAe,EACrB,WAAW,EAAE,WAAW,GACvB,OAAO,CAAC,6BAA6B,EAAE,CAAC,CAI1C;CAmBF"}
|
|
@@ -4,7 +4,7 @@ import { toFactWithOriginState } from './origin_state.js';
|
|
|
4
4
|
* Wraps a {@link FactStore} with scope-based access control.
|
|
5
5
|
*
|
|
6
6
|
* Each method asserts scope validity before delegating to FactStore, gating which accounts a contract may record facts
|
|
7
|
-
* under or read facts from.
|
|
7
|
+
* under or read facts from. The public scope belongs to no account, so it is always allowed.
|
|
8
8
|
*/ export class FactService {
|
|
9
9
|
factStore;
|
|
10
10
|
allowedScopes;
|
|
@@ -13,15 +13,15 @@ import { toFactWithOriginState } from './origin_state.js';
|
|
|
13
13
|
this.allowedScopes = allowedScopes;
|
|
14
14
|
}
|
|
15
15
|
recordFact(factCollectionKey, factTypeId, payload, originBlock, changeSetId) {
|
|
16
|
-
|
|
16
|
+
this.#assertAllowedFactScope(factCollectionKey.scope);
|
|
17
17
|
return this.factStore.recordFact(factCollectionKey, factTypeId, payload, originBlock, changeSetId);
|
|
18
18
|
}
|
|
19
19
|
deleteFactCollection(factCollectionKey, changeSetId) {
|
|
20
|
-
|
|
20
|
+
this.#assertAllowedFactScope(factCollectionKey.scope);
|
|
21
21
|
return this.factStore.deleteFactCollection(factCollectionKey, changeSetId);
|
|
22
22
|
}
|
|
23
23
|
async getFactCollection(factCollectionKey, tips, changeSetId) {
|
|
24
|
-
|
|
24
|
+
this.#assertAllowedFactScope(factCollectionKey.scope);
|
|
25
25
|
const collection = await this.factStore.getFactCollection(factCollectionKey, changeSetId);
|
|
26
26
|
if (!collection) {
|
|
27
27
|
return undefined;
|
|
@@ -32,13 +32,27 @@ import { toFactWithOriginState } from './origin_state.js';
|
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
34
|
async getFactCollectionsByType(factCollectionTypeKey, tips, changeSetId) {
|
|
35
|
-
|
|
35
|
+
this.#assertAllowedFactScope(factCollectionTypeKey.scope);
|
|
36
36
|
const collections = await this.factStore.getFactCollectionsByType(factCollectionTypeKey, changeSetId);
|
|
37
37
|
return collections.map((collection)=>({
|
|
38
38
|
key: collection.key,
|
|
39
39
|
facts: this.#annotate(collection.facts, tips)
|
|
40
40
|
}));
|
|
41
41
|
}
|
|
42
|
+
#assertAllowedFactScope(scope) {
|
|
43
|
+
switch(scope.type){
|
|
44
|
+
case 'account':
|
|
45
|
+
assertAllowedScope(scope.account, this.allowedScopes);
|
|
46
|
+
break;
|
|
47
|
+
case 'public':
|
|
48
|
+
break;
|
|
49
|
+
default:
|
|
50
|
+
{
|
|
51
|
+
const _exhaustive = scope;
|
|
52
|
+
throw new Error(`Unhandled fact scope type: ${JSON.stringify(_exhaustive)}`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
42
56
|
#annotate(facts, tips) {
|
|
43
57
|
return facts.map((fact)=>toFactWithOriginState(fact, tips));
|
|
44
58
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Fr } from '@aztec-labs/foundation/curves/bn254';
|
|
2
2
|
import type { FieldsOf } from '@aztec-labs/foundation/types';
|
|
3
3
|
import { AztecAddress } from '@aztec-labs/stdlib/aztec-address';
|
|
4
|
+
import type { FactScope } from './fact_scope.js';
|
|
4
5
|
/** A block, identified by its number and hash. */
|
|
5
6
|
export type BlockReference = {
|
|
6
7
|
blockNumber: number;
|
|
@@ -9,19 +10,19 @@ export type BlockReference = {
|
|
|
9
10
|
/** Identifies all fact collections of one type within a contract, for one scope. */
|
|
10
11
|
export declare class FactCollectionTypeKey {
|
|
11
12
|
readonly contractAddress: AztecAddress;
|
|
12
|
-
readonly scope:
|
|
13
|
+
readonly scope: FactScope;
|
|
13
14
|
readonly factCollectionTypeId: Fr;
|
|
14
|
-
constructor(contractAddress: AztecAddress, scope:
|
|
15
|
+
constructor(contractAddress: AztecAddress, scope: FactScope, factCollectionTypeId: Fr);
|
|
15
16
|
static from(fields: FieldsOf<FactCollectionTypeKey>): FactCollectionTypeKey;
|
|
16
17
|
toString(): string;
|
|
17
18
|
}
|
|
18
19
|
/** Uniquely identifies a single fact collection, isolated by scope; all its facts share this key. */
|
|
19
20
|
export declare class FactCollectionKey {
|
|
20
21
|
readonly contractAddress: AztecAddress;
|
|
21
|
-
readonly scope:
|
|
22
|
+
readonly scope: FactScope;
|
|
22
23
|
readonly factCollectionTypeId: Fr;
|
|
23
24
|
readonly factCollectionId: Fr;
|
|
24
|
-
constructor(contractAddress: AztecAddress, scope:
|
|
25
|
+
constructor(contractAddress: AztecAddress, scope: FactScope, factCollectionTypeId: Fr, factCollectionId: Fr);
|
|
25
26
|
static from(fields: FieldsOf<FactCollectionKey>): FactCollectionKey;
|
|
26
27
|
/** Inverse of toString */
|
|
27
28
|
static fromString(str: string): FactCollectionKey;
|
|
@@ -29,4 +30,4 @@ export declare class FactCollectionKey {
|
|
|
29
30
|
factCollectionTypeKey(): FactCollectionTypeKey;
|
|
30
31
|
toString(): string;
|
|
31
32
|
}
|
|
32
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
33
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmFjdF9zdG9yZV9rZXlzLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvc3RvcmFnZS9mYWN0X3N0b3JlL2ZhY3Rfc3RvcmVfa2V5cy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsRUFBRSxFQUFFLE1BQU0scUNBQXFDLENBQUM7QUFDekQsT0FBTyx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UcsaUJBQWlCLENBT2xFO0lBRUQsMEJBQTBCO0lBQzFCLE1BQU0sQ0FBQyxVQUFVLENBQUMsR0FBRyxFQUFFLE1BQU0sR0FBRyxpQkFBaUIsQ0FRaEQ7SUFFRCxrSEFBa0g7SUFDbEgscUJBQXFCLElBQUkscUJBQXFCLENBRTdDO0lBRUQsUUFBUSxJQUFJLE1BQU0sQ0FFakI7Q0FDRiJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fact_store_keys.d.ts","sourceRoot":"","sources":["../../../src/storage/fact_store/fact_store_keys.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,qCAAqC,CAAC;AACzD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAEhE,kDAAkD;AAClD,MAAM,MAAM,cAAc,GAAG;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,EAAE,CAAA;CAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"fact_store_keys.d.ts","sourceRoot":"","sources":["../../../src/storage/fact_store/fact_store_keys.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,qCAAqC,CAAC;AACzD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAEhE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD,kDAAkD;AAClD,MAAM,MAAM,cAAc,GAAG;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,EAAE,CAAA;CAAE,CAAC;AAwBpE,oFAAoF;AACpF,qBAAa,qBAAqB;aAEd,eAAe,EAAE,YAAY;aAC7B,KAAK,EAAE,SAAS;aAChB,oBAAoB,EAAE,EAAE;IAH1C,YACkB,eAAe,EAAE,YAAY,EAC7B,KAAK,EAAE,SAAS,EAChB,oBAAoB,EAAE,EAAE,EACtC;IAEJ,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,qBAAqB,CAAC,GAAG,qBAAqB,CAE1E;IAED,QAAQ,IAAI,MAAM,CAEjB;CACF;AAED,qGAAqG;AACrG,qBAAa,iBAAiB;aAEV,eAAe,EAAE,YAAY;aAC7B,KAAK,EAAE,SAAS;aAChB,oBAAoB,EAAE,EAAE;aACxB,gBAAgB,EAAE,EAAE;IAJtC,YACkB,eAAe,EAAE,YAAY,EAC7B,KAAK,EAAE,SAAS,EAChB,oBAAoB,EAAE,EAAE,EACxB,gBAAgB,EAAE,EAAE,EAClC;IAEJ,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,iBAAiB,CAAC,GAAG,iBAAiB,CAOlE;IAED,0BAA0B;IAC1B,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,iBAAiB,CAQhD;IAED,kHAAkH;IAClH,qBAAqB,IAAI,qBAAqB,CAE7C;IAED,QAAQ,IAAI,MAAM,CAEjB;CACF"}
|
|
@@ -1,10 +1,28 @@
|
|
|
1
1
|
import { Fr } from '@aztec-labs/foundation/curves/bn254';
|
|
2
2
|
import { AztecAddress } from '@aztec-labs/stdlib/aztec-address';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
// Account scopes are keyed by their hex address, which can never equal this token.
|
|
4
|
+
const PUBLIC_SCOPE_KEY_PART = 'public';
|
|
5
|
+
function scopeToKeyPart(scope) {
|
|
6
|
+
switch(scope.type){
|
|
7
|
+
case 'account':
|
|
8
|
+
return scope.account.toString();
|
|
9
|
+
case 'public':
|
|
10
|
+
return PUBLIC_SCOPE_KEY_PART;
|
|
11
|
+
default:
|
|
12
|
+
{
|
|
13
|
+
const _exhaustive = scope;
|
|
14
|
+
throw new Error(`Unhandled fact scope type: ${JSON.stringify(_exhaustive)}`);
|
|
15
|
+
}
|
|
6
16
|
}
|
|
7
17
|
}
|
|
18
|
+
function scopeFromKeyPart(part) {
|
|
19
|
+
return part === PUBLIC_SCOPE_KEY_PART ? {
|
|
20
|
+
type: 'public'
|
|
21
|
+
} : {
|
|
22
|
+
type: 'account',
|
|
23
|
+
account: AztecAddress.fromStringUnsafe(part)
|
|
24
|
+
};
|
|
25
|
+
}
|
|
8
26
|
/** Identifies all fact collections of one type within a contract, for one scope. */ export class FactCollectionTypeKey {
|
|
9
27
|
contractAddress;
|
|
10
28
|
scope;
|
|
@@ -13,13 +31,12 @@ import { AztecAddress } from '@aztec-labs/stdlib/aztec-address';
|
|
|
13
31
|
this.contractAddress = contractAddress;
|
|
14
32
|
this.scope = scope;
|
|
15
33
|
this.factCollectionTypeId = factCollectionTypeId;
|
|
16
|
-
assertNonZeroScope(scope);
|
|
17
34
|
}
|
|
18
35
|
static from(fields) {
|
|
19
36
|
return new FactCollectionTypeKey(fields.contractAddress, fields.scope, fields.factCollectionTypeId);
|
|
20
37
|
}
|
|
21
38
|
toString() {
|
|
22
|
-
return `${this.contractAddress}:${this.scope}:${this.factCollectionTypeId}`;
|
|
39
|
+
return `${this.contractAddress}:${scopeToKeyPart(this.scope)}:${this.factCollectionTypeId}`;
|
|
23
40
|
}
|
|
24
41
|
}
|
|
25
42
|
/** Uniquely identifies a single fact collection, isolated by scope; all its facts share this key. */ export class FactCollectionKey {
|
|
@@ -32,19 +49,18 @@ import { AztecAddress } from '@aztec-labs/stdlib/aztec-address';
|
|
|
32
49
|
this.scope = scope;
|
|
33
50
|
this.factCollectionTypeId = factCollectionTypeId;
|
|
34
51
|
this.factCollectionId = factCollectionId;
|
|
35
|
-
assertNonZeroScope(scope);
|
|
36
52
|
}
|
|
37
53
|
static from(fields) {
|
|
38
54
|
return new FactCollectionKey(fields.contractAddress, fields.scope, fields.factCollectionTypeId, fields.factCollectionId);
|
|
39
55
|
}
|
|
40
56
|
/** Inverse of toString */ static fromString(str) {
|
|
41
57
|
const [contractAddress, scope, factCollectionTypeId, factCollectionId] = str.split(':');
|
|
42
|
-
return new FactCollectionKey(AztecAddress.fromStringUnsafe(contractAddress),
|
|
58
|
+
return new FactCollectionKey(AztecAddress.fromStringUnsafe(contractAddress), scopeFromKeyPart(scope), Fr.fromString(factCollectionTypeId), Fr.fromString(factCollectionId));
|
|
43
59
|
}
|
|
44
60
|
/** The key grouping this collection with the other collections of its type within the same contract and scope. */ factCollectionTypeKey() {
|
|
45
61
|
return new FactCollectionTypeKey(this.contractAddress, this.scope, this.factCollectionTypeId);
|
|
46
62
|
}
|
|
47
63
|
toString() {
|
|
48
|
-
return `${this.contractAddress}:${this.scope}:${this.factCollectionTypeId}:${this.factCollectionId}`;
|
|
64
|
+
return `${this.contractAddress}:${scopeToKeyPart(this.scope)}:${this.factCollectionTypeId}:${this.factCollectionId}`;
|
|
49
65
|
}
|
|
50
66
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { FactStore, type FactCollection } from './fact_store.js';
|
|
2
2
|
export { FactService } from './fact_service.js';
|
|
3
|
+
export { type FactScope, factScopeFromFields, factScopeToFields } from './fact_scope.js';
|
|
3
4
|
export { FactCollectionKey, FactCollectionTypeKey, type BlockReference } from './fact_store_keys.js';
|
|
4
5
|
export type { Fact } from './stored_fact.js';
|
|
5
6
|
export { OriginBlockState, classifyOriginBlockState, originBlockStateFromNumber, anchoredTipBlockNumbers, toFactWithOriginState, type TipBlockNumbers, type RetractableFactOrigin, type FactWithOriginState, type FactCollectionWithOriginState, } from './origin_state.js';
|
|
6
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
7
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9zdG9yYWdlL2ZhY3Rfc3RvcmUvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE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K,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,KAAK,SAAS,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACzF,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,KAAK,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACrG,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,5 @@
|
|
|
1
1
|
export { FactStore } from './fact_store.js';
|
|
2
2
|
export { FactService } from './fact_service.js';
|
|
3
|
+
export { factScopeFromFields, factScopeToFields } from './fact_scope.js';
|
|
3
4
|
export { FactCollectionKey, FactCollectionTypeKey } from './fact_store_keys.js';
|
|
4
5
|
export { OriginBlockState, classifyOriginBlockState, originBlockStateFromNumber, anchoredTipBlockNumbers, toFactWithOriginState } from './origin_state.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Fr } from '@aztec-labs/foundation/curves/bn254';
|
|
2
|
-
import {
|
|
2
|
+
import { Buffer } from 'buffer';
|
|
3
3
|
import { type BlockReference, FactCollectionKey } from './fact_store_keys.js';
|
|
4
4
|
/** A fact as returned by the fact store. */
|
|
5
5
|
export type Fact = {
|
|
@@ -23,10 +23,16 @@ export declare class StoredFact {
|
|
|
23
23
|
/** Returns the externally facing view of this fact. */
|
|
24
24
|
toFact(): Fact;
|
|
25
25
|
toBuffer(): Buffer;
|
|
26
|
-
|
|
26
|
+
/**
|
|
27
|
+
* Inverse of {@link toBuffer}.
|
|
28
|
+
*
|
|
29
|
+
* `buffer` must end where the record does, since any bytes after an account record are read as the public scope
|
|
30
|
+
* marker.
|
|
31
|
+
*/
|
|
32
|
+
static fromBuffer(buffer: Buffer): StoredFact;
|
|
27
33
|
}
|
|
28
34
|
/**
|
|
29
35
|
* Builds the serialized key that identifies a fact in the store.
|
|
30
36
|
*/
|
|
31
37
|
export declare function factKeyStrOf(fact: StoredFact): string;
|
|
32
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
38
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3RvcmVkX2ZhY3QuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9zdG9yYWdlL2ZhY3Rfc3RvcmUvc3RvcmVkX2ZhY3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0EsT0FBTyxFQUFFLEVBQUUsRUFBRSxNQUFNLHFDQUFxQyxDQUFDO0FBR3pELE9BQU8sRUFBRSxNQUFNLEVBQUUsTUFBTSxRQUFRLENBQUM7QUFHaEMsT0FBTyxFQUFFLEtBQUssY0FBYyxFQUFFLGlCQUFpQixFQUFFLE1BQU0sc0JBQXNCLENBQUM7QUFFOUUsNENBQTRDO0FBQzVDLE1BQU0sTUFBTSxJQUFJLEdBQUc7SUFBRSxVQUFVLEVBQUUsRUFBRSxDQUFDO0lBQUMsT0FBTyxFQUFFLEVBQUUsRUFBRSxDQUFDO0lBQUMsV0FBVyxFQUFFLGNBQWMsR0FBRyxTQUFTLENBQUE7Q0FBRSxDQUFDO0FBRTlGOztHQUVHO0FBQ0gscUJBQWEsVUFBVTthQUVILGlCQUFpQixFQUFFLGlCQUFpQjthQUNwQyxVQUFVLEVBQUUsRUFBRTthQUNkLE9BQU8sRUFBRSxFQUFFLEVBQUU7YUFDYixXQUFXLEVBQUUsY0FBYyxHQUFHLFNBQVM7SUFKekQsWUFDa0IsaUJBQWlCLEVBQUUsaUJBQWlCLEVBQ3BDLFVBQVUsRUFBRSxFQUFFLEVBQ2QsT0FBTyxFQUFFLEVBQUUsRUFBRSxFQUNiLFdBQVcsRUFBRSxjQUFjLEdBQUcsU0FBUyxFQUNyRDtJQUVKLHVGQUF1RjtJQUN2RixJQUFJLGFBQWEsSUFBSSxPQUFPLENBRTNCO0lBRUQsK0RBQStEO0lBQy9ELFdBQVcsSUFBSSxFQUFFLENBRWhCO0lBRUQsdURBQXVEO0lBQ3ZELE1BQU0sSUFBSSxJQUFJLENBRWI7SUFFRCxRQUFRLElBQUksTUFBTSxDQTJCakI7SUFFRDs7Ozs7T0FLRztJQUNILE1BQU0sQ0FBQyxVQUFVLENBQUMsTUFBTSxFQUFFLE1BQU0sR0FBRyxVQUFVLENBaUM1QztDQUNGO0FBRUQ7O0dBRUc7QUFDSCx3QkFBZ0IsWUFBWSxDQUFDLElBQUksRUFBRSxVQUFVLEdBQUcsTUFBTSxDQUdyRCJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stored_fact.d.ts","sourceRoot":"","sources":["../../../src/storage/fact_store/stored_fact.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,MAAM,qCAAqC,CAAC;
|
|
1
|
+
{"version":3,"file":"stored_fact.d.ts","sourceRoot":"","sources":["../../../src/storage/fact_store/stored_fact.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,MAAM,qCAAqC,CAAC;AAGzD,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGhC,OAAO,EAAE,KAAK,cAAc,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAE9E,4CAA4C;AAC5C,MAAM,MAAM,IAAI,GAAG;IAAE,UAAU,EAAE,EAAE,CAAC;IAAC,OAAO,EAAE,EAAE,EAAE,CAAC;IAAC,WAAW,EAAE,cAAc,GAAG,SAAS,CAAA;CAAE,CAAC;AAE9F;;GAEG;AACH,qBAAa,UAAU;aAEH,iBAAiB,EAAE,iBAAiB;aACpC,UAAU,EAAE,EAAE;aACd,OAAO,EAAE,EAAE,EAAE;aACb,WAAW,EAAE,cAAc,GAAG,SAAS;IAJzD,YACkB,iBAAiB,EAAE,iBAAiB,EACpC,UAAU,EAAE,EAAE,EACd,OAAO,EAAE,EAAE,EAAE,EACb,WAAW,EAAE,cAAc,GAAG,SAAS,EACrD;IAEJ,uFAAuF;IACvF,IAAI,aAAa,IAAI,OAAO,CAE3B;IAED,+DAA+D;IAC/D,WAAW,IAAI,EAAE,CAEhB;IAED,uDAAuD;IACvD,MAAM,IAAI,IAAI,CAEb;IAED,QAAQ,IAAI,MAAM,CA2BjB;IAED;;;;;OAKG;IACH,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,CAiC5C;CACF;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,CAGrD"}
|
|
@@ -2,6 +2,7 @@ import { sha256ToField } from '@aztec-labs/foundation/crypto/sha256';
|
|
|
2
2
|
import { Fr } from '@aztec-labs/foundation/curves/bn254';
|
|
3
3
|
import { BufferReader, serializeToBuffer } from '@aztec-labs/foundation/serialize';
|
|
4
4
|
import { AztecAddress } from '@aztec-labs/stdlib/aztec-address';
|
|
5
|
+
import { Buffer } from 'buffer';
|
|
5
6
|
import { FactCollectionKey } from './fact_store_keys.js';
|
|
6
7
|
/**
|
|
7
8
|
* A single immutable fact belonging to a fact collection.
|
|
@@ -33,12 +34,34 @@ import { FactCollectionKey } from './fact_store_keys.js';
|
|
|
33
34
|
};
|
|
34
35
|
}
|
|
35
36
|
toBuffer() {
|
|
36
|
-
|
|
37
|
+
const { scope } = this.factCollectionKey;
|
|
38
|
+
const record = (scopeAccount)=>serializeToBuffer(this.factCollectionKey.contractAddress, scopeAccount, this.factCollectionKey.factCollectionTypeId, this.factCollectionKey.factCollectionId, this.factTypeId, this.payload.length, ...this.payload, this.originBlock !== undefined, this.originBlock ? this.originBlock.blockNumber : 0, this.originBlock ? this.originBlock.blockHash : Fr.ZERO);
|
|
39
|
+
// For DB schema compatibility, account records use the schema's record layout unchanged, and public records extend
|
|
40
|
+
// it with a trailing marker instead of adding a scope kind field.
|
|
41
|
+
switch(scope.type){
|
|
42
|
+
case 'account':
|
|
43
|
+
return record(scope.account);
|
|
44
|
+
case 'public':
|
|
45
|
+
return Buffer.concat([
|
|
46
|
+
record(AztecAddress.ZERO),
|
|
47
|
+
serializeToBuffer(true)
|
|
48
|
+
]);
|
|
49
|
+
default:
|
|
50
|
+
{
|
|
51
|
+
const _exhaustive = scope;
|
|
52
|
+
throw new Error(`Unhandled fact scope type: ${JSON.stringify(_exhaustive)}`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
37
55
|
}
|
|
38
|
-
|
|
56
|
+
/**
|
|
57
|
+
* Inverse of {@link toBuffer}.
|
|
58
|
+
*
|
|
59
|
+
* `buffer` must end where the record does, since any bytes after an account record are read as the public scope
|
|
60
|
+
* marker.
|
|
61
|
+
*/ static fromBuffer(buffer) {
|
|
39
62
|
const reader = BufferReader.asReader(buffer);
|
|
40
63
|
const contractAddress = reader.readObject(AztecAddress);
|
|
41
|
-
const
|
|
64
|
+
const scopeAccount = reader.readObject(AztecAddress);
|
|
42
65
|
const factCollectionTypeId = reader.readObject(Fr);
|
|
43
66
|
const factCollectionId = reader.readObject(Fr);
|
|
44
67
|
const factTypeId = reader.readObject(Fr);
|
|
@@ -51,6 +74,25 @@ import { FactCollectionKey } from './fact_store_keys.js';
|
|
|
51
74
|
blockNumber,
|
|
52
75
|
blockHash
|
|
53
76
|
} : undefined;
|
|
77
|
+
let scope = {
|
|
78
|
+
type: 'account',
|
|
79
|
+
account: scopeAccount
|
|
80
|
+
};
|
|
81
|
+
if (!reader.isEmpty()) {
|
|
82
|
+
const malformed = `Malformed public scope marker in stored fact of contract ${contractAddress}`;
|
|
83
|
+
if (!reader.readBoolean()) {
|
|
84
|
+
throw new Error(`${malformed}: marker is false`);
|
|
85
|
+
}
|
|
86
|
+
if (!reader.isEmpty()) {
|
|
87
|
+
throw new Error(`${malformed}: trailing bytes after the marker`);
|
|
88
|
+
}
|
|
89
|
+
if (!scopeAccount.isZero()) {
|
|
90
|
+
throw new Error(`${malformed}: record names account ${scopeAccount}`);
|
|
91
|
+
}
|
|
92
|
+
scope = {
|
|
93
|
+
type: 'public'
|
|
94
|
+
};
|
|
95
|
+
}
|
|
54
96
|
return new StoredFact(new FactCollectionKey(contractAddress, scope, factCollectionTypeId, factCollectionId), factTypeId, [
|
|
55
97
|
...payload
|
|
56
98
|
], originBlock);
|
|
@@ -32,4 +32,4 @@ export declare class StoreIdentityMismatchError extends Error {
|
|
|
32
32
|
readonly actual: string;
|
|
33
33
|
constructor(storeName: string, expected: string, actual: string);
|
|
34
34
|
}
|
|
35
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
35
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3RvcmVfaWRlbnRpdHkuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9zdG9yYWdlL3N0b3JlX2lkZW50aXR5LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLFVBQVUsRUFBRSxNQUFNLG9DQUFvQyxDQUFDO0FBQ3JFLE9BQU8sS0FBSyxFQUFFLGlCQUFpQixFQUFFLE1BQU0sc0JBQXNCLENBQUM7QUFJOUQsbUZBQW1GO0FBQ25GLE1BQU0sTUFBTSxhQUFhLEdBQUc7SUFDMUIsb0RBQW9EO0lBQ3BELFNBQVMsRUFBRSxNQUFNLENBQUM7SUFDbEIsbUVBQW1FO0lBQ25FLGFBQWEsRUFBRSxVQUFVLENBQUM7SUFDMUIsb0RBQW9EO0lBQ3BELGFBQWEsRUFBRSxNQUFNLENBQUM7Q0FDdkIsQ0FBQztBQUVGOzs7O0dBSUc7QUFDSCx3QkFBZ0IsaUJBQWlCLENBQUMsRUFBRSxTQUFTLEVBQUUsYUFBYSxFQUFFLGFBQWEsRUFBRSxFQUFFLGFBQWEsR0FBRyxNQUFNLENBRXBHO0FBRUQsOEVBQThFO0FBQzlFLHdCQUFnQixrQkFBa0IsQ0FBQyxJQUFJLEVBQUUsTUFBTSxFQUFFLFFBQVEsRUFBRSxhQUFhLEdBQUcsTUFBTSxDQUVoRjtBQUVEOzs7R0FHRztBQUNILHdCQUFzQixtQkFBbUIsQ0FDdkMsS0FBSyxFQUFFLGlCQUFpQixFQUN4QixTQUFTLEVBQUUsTUFBTSxFQUNqQixRQUFRLEVBQUUsYUFBYSxHQUN0QixPQUFPLENBQUMsSUFBSSxDQUFDLENBaUJmO0FBRUQ7OztHQUdHO0FBQ0gscUJBQWEsMEJBQTJCLFNBQVEsS0FBSzthQUVqQyxTQUFTLEVBQUUsTUFBTTthQUNqQixRQUFRLEVBQUUsTUFBTTthQUNoQixNQUFNLEVBQUUsTUFBTTtJQUhoQyxZQUNrQixTQUFTLEVBQUUsTUFBTSxFQUNqQixRQUFRLEVBQUUsTUFBTSxFQUNoQixNQUFNLEVBQUUsTUFBTSxFQU8vQjtDQUNGIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store_identity.d.ts","sourceRoot":"","sources":["../../src/storage/store_identity.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AACrE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"store_identity.d.ts","sourceRoot":"","sources":["../../src/storage/store_identity.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AACrE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAI9D,mFAAmF;AACnF,MAAM,MAAM,aAAa,GAAG;IAC1B,oDAAoD;IACpD,SAAS,EAAE,MAAM,CAAC;IAClB,mEAAmE;IACnE,aAAa,EAAE,UAAU,CAAC;IAC1B,oDAAoD;IACpD,aAAa,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,EAAE,SAAS,EAAE,aAAa,EAAE,aAAa,EAAE,EAAE,aAAa,GAAG,MAAM,CAEpG;AAED,8EAA8E;AAC9E,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,GAAG,MAAM,CAEhF;AAED;;;GAGG;AACH,wBAAsB,mBAAmB,CACvC,KAAK,EAAE,iBAAiB,EACxB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,aAAa,GACtB,OAAO,CAAC,IAAI,CAAC,CAiBf;AAED;;;GAGG;AACH,qBAAa,0BAA2B,SAAQ,KAAK;aAEjC,SAAS,EAAE,MAAM;aACjB,QAAQ,EAAE,MAAM;aAChB,MAAM,EAAE,MAAM;IAHhC,YACkB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EAO/B;CACF"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { DatabaseVersion } from '@aztec-labs/stdlib/database-version/version';
|
|
2
|
+
import { Buffer } from 'buffer';
|
|
2
3
|
/**
|
|
3
4
|
* Composes the store-name discriminator for a store identity. Two identities map to the same physical store iff
|
|
4
5
|
* their slugs are equal, so the format must stay stable: `<l1ChainId>-<rollupAddress>-v<schemaVersion>` — changing
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec-labs/pxe",
|
|
3
|
-
"version": "6.0.0-rc.
|
|
3
|
+
"version": "6.0.0-rc.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"typedocOptions": {
|
|
6
6
|
"entryPoints": [
|
|
@@ -71,31 +71,32 @@
|
|
|
71
71
|
]
|
|
72
72
|
},
|
|
73
73
|
"dependencies": {
|
|
74
|
-
"@aztec-foundation/bb.js": "6.0.0-rc.
|
|
75
|
-
"@aztec-foundation/noir-acvm_js": "6.0.0-rc.
|
|
76
|
-
"@aztec-foundation/noir-noirc_abi": "6.0.0-rc.
|
|
77
|
-
"@aztec-foundation/noir-types": "6.0.0-rc.
|
|
78
|
-
"@aztec-labs/bb-prover": "6.0.0-rc.
|
|
79
|
-
"@aztec-labs/constants": "6.0.0-rc.
|
|
80
|
-
"@aztec-labs/ethereum": "6.0.0-rc.
|
|
81
|
-
"@aztec-labs/foundation": "6.0.0-rc.
|
|
82
|
-
"@aztec-labs/key-store": "6.0.0-rc.
|
|
83
|
-
"@aztec-labs/kv-store": "6.0.0-rc.
|
|
84
|
-
"@aztec-labs/noir-protocol-circuits-types": "6.0.0-rc.
|
|
85
|
-
"@aztec-labs/protocol-contracts": "6.0.0-rc.
|
|
86
|
-
"@aztec-labs/simulator": "6.0.0-rc.
|
|
87
|
-
"@aztec-labs/standard-contracts": "6.0.0-rc.
|
|
88
|
-
"@aztec-labs/stdlib": "6.0.0-rc.
|
|
74
|
+
"@aztec-foundation/bb.js": "6.0.0-rc.7",
|
|
75
|
+
"@aztec-foundation/noir-acvm_js": "6.0.0-rc.7",
|
|
76
|
+
"@aztec-foundation/noir-noirc_abi": "6.0.0-rc.7",
|
|
77
|
+
"@aztec-foundation/noir-types": "6.0.0-rc.7",
|
|
78
|
+
"@aztec-labs/bb-prover": "6.0.0-rc.4",
|
|
79
|
+
"@aztec-labs/constants": "6.0.0-rc.4",
|
|
80
|
+
"@aztec-labs/ethereum": "6.0.0-rc.4",
|
|
81
|
+
"@aztec-labs/foundation": "6.0.0-rc.4",
|
|
82
|
+
"@aztec-labs/key-store": "6.0.0-rc.4",
|
|
83
|
+
"@aztec-labs/kv-store": "6.0.0-rc.4",
|
|
84
|
+
"@aztec-labs/noir-protocol-circuits-types": "6.0.0-rc.4",
|
|
85
|
+
"@aztec-labs/protocol-contracts": "6.0.0-rc.4",
|
|
86
|
+
"@aztec-labs/simulator": "6.0.0-rc.4",
|
|
87
|
+
"@aztec-labs/standard-contracts": "6.0.0-rc.4",
|
|
88
|
+
"@aztec-labs/stdlib": "6.0.0-rc.4",
|
|
89
|
+
"buffer": "^6.0.3",
|
|
89
90
|
"koa": "^2.16.1",
|
|
90
91
|
"koa-router": "^13.1.1",
|
|
91
92
|
"lodash.omit": "^4.5.0",
|
|
92
93
|
"sha3": "^2.1.4",
|
|
93
94
|
"tslib": "^2.4.0",
|
|
94
|
-
"viem": "
|
|
95
|
+
"viem": "2.57.1"
|
|
95
96
|
},
|
|
96
97
|
"devDependencies": {
|
|
97
|
-
"@aztec-labs/noir-test-contracts.js": "6.0.0-rc.
|
|
98
|
-
"@aztec-labs/world-state": "6.0.0-rc.
|
|
98
|
+
"@aztec-labs/noir-test-contracts.js": "6.0.0-rc.4",
|
|
99
|
+
"@aztec-labs/world-state": "6.0.0-rc.4",
|
|
99
100
|
"@jest/globals": "^30.0.0",
|
|
100
101
|
"@types/jest": "^30.0.0",
|
|
101
102
|
"@types/lodash.omit": "^4.5.7",
|
|
@@ -116,6 +117,6 @@
|
|
|
116
117
|
],
|
|
117
118
|
"types": "./dest/index.d.ts",
|
|
118
119
|
"engines": {
|
|
119
|
-
"node": ">=20.
|
|
120
|
+
"node": ">=20.16"
|
|
120
121
|
}
|
|
121
122
|
}
|
package/src/config/index.ts
CHANGED
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
numberConfigHelper,
|
|
7
7
|
parseBooleanEnv,
|
|
8
8
|
} from '@aztec-labs/foundation/config';
|
|
9
|
+
import { getEnv } from '@aztec-labs/foundation/config/env';
|
|
9
10
|
import { type ChainConfig, chainConfigMappings } from '@aztec-labs/stdlib/config';
|
|
10
11
|
import { type DataStoreConfig, dataConfigMappings } from '@aztec-labs/stdlib/kv-store';
|
|
11
12
|
|
|
@@ -120,7 +121,7 @@ export const allPxeConfigMappings: ConfigMappingsType<CliPXEOptions & PXEConfig>
|
|
|
120
121
|
...dataConfigMappings,
|
|
121
122
|
proverEnabled: {
|
|
122
123
|
env: 'PXE_PROVER_ENABLED',
|
|
123
|
-
parseEnv: (val: string) => parseBooleanEnv(val) || !!
|
|
124
|
+
parseEnv: (val: string) => parseBooleanEnv(val) || !!getEnv().NETWORK,
|
|
124
125
|
description: 'Enable real proofs',
|
|
125
126
|
isBoolean: true,
|
|
126
127
|
defaultValue: true,
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { Fr } from '@aztec-labs/foundation/curves/bn254';
|
|
2
|
-
import { AztecAddress } from '@aztec-labs/stdlib/aztec-address';
|
|
1
|
+
import type { Fr } from '@aztec-labs/foundation/curves/bn254';
|
|
2
|
+
import type { AztecAddress } from '@aztec-labs/stdlib/aztec-address';
|
|
3
3
|
|
|
4
|
-
import type { FactWithOriginState, RetractableFactOrigin } from '../../storage/fact_store/index.js';
|
|
5
|
-
import { OriginBlockState } from '../../storage/fact_store/index.js';
|
|
4
|
+
import type { FactScope, FactWithOriginState, RetractableFactOrigin } from '../../storage/fact_store/index.js';
|
|
6
5
|
import type { EphemeralArrayService } from '../ephemeral_array_service.js';
|
|
7
6
|
import { EphemeralArray } from './ephemeral_array.js';
|
|
8
7
|
import type { Fact } from './fact.js';
|
|
@@ -13,7 +12,7 @@ import { Option } from './option.js';
|
|
|
13
12
|
*/
|
|
14
13
|
export type FactCollection = {
|
|
15
14
|
contractAddress: AztecAddress;
|
|
16
|
-
scope:
|
|
15
|
+
scope: FactScope;
|
|
17
16
|
factCollectionTypeId: Fr;
|
|
18
17
|
factCollectionId: Fr;
|
|
19
18
|
facts: EphemeralArray<Fact>;
|
|
@@ -25,7 +24,7 @@ export type FactCollection = {
|
|
|
25
24
|
export function toNoirFactCollection(
|
|
26
25
|
service: EphemeralArrayService,
|
|
27
26
|
contractAddress: AztecAddress,
|
|
28
|
-
scope:
|
|
27
|
+
scope: FactScope,
|
|
29
28
|
factCollectionTypeId: Fr,
|
|
30
29
|
factCollectionId: Fr,
|
|
31
30
|
facts: FactWithOriginState[],
|
|
@@ -41,24 +40,9 @@ export function toNoirFactCollection(
|
|
|
41
40
|
(fact: FactWithOriginState): Fact => ({
|
|
42
41
|
factTypeId: fact.factTypeId,
|
|
43
42
|
payload: EphemeralArray.fromValues(service, fact.payload),
|
|
44
|
-
originBlock: fact.originBlock
|
|
45
|
-
? Option.some(fact.originBlock)
|
|
46
|
-
: Option.none<RetractableFactOrigin>({
|
|
47
|
-
blockNumber: 0,
|
|
48
|
-
blockHash: Fr.ZERO,
|
|
49
|
-
blockState: OriginBlockState.Pending,
|
|
50
|
-
}),
|
|
43
|
+
originBlock: fact.originBlock ? Option.some(fact.originBlock) : Option.none<RetractableFactOrigin>(),
|
|
51
44
|
}),
|
|
52
45
|
),
|
|
53
46
|
),
|
|
54
47
|
};
|
|
55
48
|
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* A zeroed `FactCollection` used only as a serialization shape template for the `None` case of
|
|
59
|
-
* `Option<FactCollection>`. Noir's `Option<T>` is fixed-width on the wire, so `None` must emit the same number of
|
|
60
|
-
* (zeroed) field slots as `Some`.
|
|
61
|
-
**/
|
|
62
|
-
export function emptyFactCollection(service: EphemeralArrayService): FactCollection {
|
|
63
|
-
return toNoirFactCollection(service, AztecAddress.ZERO, AztecAddress.ZERO, Fr.ZERO, Fr.ZERO, []);
|
|
64
|
-
}
|
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
EPHEMERAL_ARRAY,
|
|
20
20
|
EVENT_VALIDATION_REQUEST,
|
|
21
21
|
FACT_COLLECTION,
|
|
22
|
+
FACT_SCOPE,
|
|
22
23
|
FIELD,
|
|
23
24
|
FIXED_ARRAY,
|
|
24
25
|
FUNCTION_SELECTOR,
|
|
@@ -353,7 +354,7 @@ export const ORACLE_REGISTRY = {
|
|
|
353
354
|
aztec_utl_recordFact: makeEntry({
|
|
354
355
|
params: [
|
|
355
356
|
{ name: 'contractAddress', type: AZTEC_ADDRESS },
|
|
356
|
-
{ name: 'scope', type:
|
|
357
|
+
{ name: 'scope', type: FACT_SCOPE },
|
|
357
358
|
{ name: 'factCollectionTypeId', type: FIELD },
|
|
358
359
|
{ name: 'factCollectionId', type: FIELD },
|
|
359
360
|
{ name: 'factTypeId', type: FIELD },
|
|
@@ -365,7 +366,7 @@ export const ORACLE_REGISTRY = {
|
|
|
365
366
|
aztec_utl_deleteFactCollection: makeEntry({
|
|
366
367
|
params: [
|
|
367
368
|
{ name: 'contractAddress', type: AZTEC_ADDRESS },
|
|
368
|
-
{ name: 'scope', type:
|
|
369
|
+
{ name: 'scope', type: FACT_SCOPE },
|
|
369
370
|
{ name: 'factCollectionTypeId', type: FIELD },
|
|
370
371
|
{ name: 'factCollectionId', type: FIELD },
|
|
371
372
|
],
|
|
@@ -374,7 +375,7 @@ export const ORACLE_REGISTRY = {
|
|
|
374
375
|
aztec_utl_getFactCollection: makeEntry({
|
|
375
376
|
params: [
|
|
376
377
|
{ name: 'contractAddress', type: AZTEC_ADDRESS },
|
|
377
|
-
{ name: 'scope', type:
|
|
378
|
+
{ name: 'scope', type: FACT_SCOPE },
|
|
378
379
|
{ name: 'factCollectionTypeId', type: FIELD },
|
|
379
380
|
{ name: 'factCollectionId', type: FIELD },
|
|
380
381
|
],
|
|
@@ -384,7 +385,7 @@ export const ORACLE_REGISTRY = {
|
|
|
384
385
|
aztec_utl_getFactCollectionsByType: makeEntry({
|
|
385
386
|
params: [
|
|
386
387
|
{ name: 'contractAddress', type: AZTEC_ADDRESS },
|
|
387
|
-
{ name: 'scope', type:
|
|
388
|
+
{ name: 'scope', type: FACT_SCOPE },
|
|
388
389
|
{ name: 'factCollectionTypeId', type: FIELD },
|
|
389
390
|
],
|
|
390
391
|
returnType: EPHEMERAL_ARRAY(FACT_COLLECTION),
|
|
@@ -49,11 +49,15 @@ import {
|
|
|
49
49
|
type StateReference,
|
|
50
50
|
TxHash,
|
|
51
51
|
} from '@aztec-labs/stdlib/tx';
|
|
52
|
+
import { Buffer } from 'buffer';
|
|
52
53
|
|
|
53
54
|
import {
|
|
54
55
|
type BlockReference,
|
|
56
|
+
type FactScope,
|
|
55
57
|
type OriginBlockState,
|
|
56
58
|
type RetractableFactOrigin,
|
|
59
|
+
factScopeFromFields,
|
|
60
|
+
factScopeToFields,
|
|
57
61
|
originBlockStateFromNumber,
|
|
58
62
|
} from '../../storage/fact_store/index.js';
|
|
59
63
|
import { BoundedVec } from '../noir-structs/bounded_vec.js';
|
|
@@ -585,9 +589,19 @@ export const FACT: TypeMapping<Fact> = STRUCT([
|
|
|
585
589
|
{ name: 'originBlock', type: OPTION(RETRACTABLE_FACT_ORIGIN) },
|
|
586
590
|
]);
|
|
587
591
|
|
|
592
|
+
export const FACT_SCOPE: TypeMapping<FactScope> = LEAF({
|
|
593
|
+
kind: 'fact-scope',
|
|
594
|
+
serialization: { fn: scope => factScopeToFields(scope) },
|
|
595
|
+
deserialization: {
|
|
596
|
+
fn: ([kindReader, accountReader]) =>
|
|
597
|
+
factScopeFromFields(kindReader.readField().toNumber(), accountReader.readField()),
|
|
598
|
+
},
|
|
599
|
+
shape: ['scalar', 'scalar'],
|
|
600
|
+
});
|
|
601
|
+
|
|
588
602
|
export const FACT_COLLECTION: TypeMapping<FactCollection> = STRUCT([
|
|
589
603
|
{ name: 'contractAddress', type: AZTEC_ADDRESS },
|
|
590
|
-
{ name: 'scope', type:
|
|
604
|
+
{ name: 'scope', type: FACT_SCOPE },
|
|
591
605
|
{ name: 'factCollectionTypeId', type: FIELD },
|
|
592
606
|
{ name: 'factCollectionId', type: FIELD },
|
|
593
607
|
{ name: 'facts', type: EPHEMERAL_ARRAY(FACT) },
|
|
@@ -20,6 +20,7 @@ import type { AztecAddress } from '@aztec-labs/stdlib/aztec-address';
|
|
|
20
20
|
import { PrivateCircuitPublicInputs } from '@aztec-labs/stdlib/kernel';
|
|
21
21
|
import type { CircuitWitnessGenerationStats } from '@aztec-labs/stdlib/stats';
|
|
22
22
|
import { PrivateCallExecutionResult } from '@aztec-labs/stdlib/tx';
|
|
23
|
+
import { Buffer } from 'buffer';
|
|
23
24
|
|
|
24
25
|
import { buildACIRCallback } from './acir_callback.js';
|
|
25
26
|
import type { PrivateExecutionOracle } from './private_execution_oracle.js';
|