@aztec/simulator 0.80.0 → 0.82.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/common/db_interfaces.d.ts +30 -17
- package/dest/common/db_interfaces.d.ts.map +1 -1
- package/dest/common/db_interfaces.js +1 -1
- package/dest/common/debug_fn_name.d.ts +2 -2
- package/dest/common/debug_fn_name.d.ts.map +1 -1
- package/dest/common/message_load_oracle_inputs.d.ts +4 -0
- package/dest/common/message_load_oracle_inputs.d.ts.map +1 -1
- package/dest/common/message_load_oracle_inputs.js +9 -0
- package/dest/private/acvm/acvm.d.ts +6 -1
- package/dest/private/acvm/acvm.d.ts.map +1 -1
- package/dest/private/acvm/acvm.js +7 -13
- package/dest/private/acvm/deserialize.d.ts +19 -18
- package/dest/private/acvm/deserialize.d.ts.map +1 -1
- package/dest/private/acvm/deserialize.js +31 -23
- package/dest/private/acvm/oracle/oracle.d.ts +36 -34
- package/dest/private/acvm/oracle/oracle.d.ts.map +1 -1
- package/dest/private/acvm/oracle/oracle.js +134 -79
- package/dest/private/acvm/oracle/typed_oracle.d.ts +3 -2
- package/dest/private/acvm/oracle/typed_oracle.d.ts.map +1 -1
- package/dest/private/acvm/oracle/typed_oracle.js +5 -2
- package/dest/private/acvm/serialize.d.ts +11 -0
- package/dest/private/acvm/serialize.d.ts.map +1 -1
- package/dest/private/acvm/serialize.js +27 -0
- package/dest/private/execution_data_provider.d.ts +15 -13
- package/dest/private/execution_data_provider.d.ts.map +1 -1
- package/dest/private/private_execution.d.ts +2 -2
- package/dest/private/private_execution.d.ts.map +1 -1
- package/dest/private/private_execution.js +4 -5
- package/dest/private/private_execution_oracle.d.ts.map +1 -1
- package/dest/private/private_execution_oracle.js +1 -1
- package/dest/private/providers/acvm_native.d.ts +6 -4
- package/dest/private/providers/acvm_native.d.ts.map +1 -1
- package/dest/private/providers/acvm_native.js +6 -3
- package/dest/private/providers/acvm_wasm.d.ts +6 -7
- package/dest/private/providers/acvm_wasm.d.ts.map +1 -1
- package/dest/private/providers/acvm_wasm.js +13 -15
- package/dest/private/providers/acvm_wasm_with_blobs.d.ts +5 -5
- package/dest/private/providers/acvm_wasm_with_blobs.d.ts.map +1 -1
- package/dest/private/providers/acvm_wasm_with_blobs.js +7 -9
- package/dest/private/providers/circuit_recording/circuit_recorder.d.ts +90 -0
- package/dest/private/providers/circuit_recording/circuit_recorder.d.ts.map +1 -0
- package/dest/private/providers/circuit_recording/circuit_recorder.js +246 -0
- package/dest/private/providers/circuit_recording/simulation_provider_recorder_wrapper.d.ts +18 -0
- package/dest/private/providers/circuit_recording/simulation_provider_recorder_wrapper.d.ts.map +1 -0
- package/dest/private/providers/circuit_recording/simulation_provider_recorder_wrapper.js +39 -0
- package/dest/private/providers/simulation_provider.d.ts +21 -7
- package/dest/private/providers/simulation_provider.d.ts.map +1 -1
- package/dest/private/simulator.d.ts +3 -2
- package/dest/private/simulator.d.ts.map +1 -1
- package/dest/private/simulator.js +2 -2
- package/dest/private/unconstrained_execution.d.ts +2 -2
- package/dest/private/unconstrained_execution.d.ts.map +1 -1
- package/dest/private/unconstrained_execution.js +1 -2
- package/dest/private/unconstrained_execution_oracle.d.ts +5 -3
- package/dest/private/unconstrained_execution_oracle.d.ts.map +1 -1
- package/dest/private/unconstrained_execution_oracle.js +9 -5
- package/dest/public/avm/avm_simulator.d.ts.map +1 -1
- package/dest/public/avm/avm_simulator.js +0 -2
- package/dest/public/avm/fixtures/avm_simulation_tester.d.ts.map +1 -1
- package/dest/public/avm/fixtures/avm_simulation_tester.js +5 -5
- package/dest/public/avm/fixtures/index.d.ts +4 -4
- package/dest/public/avm/fixtures/index.d.ts.map +1 -1
- package/dest/public/avm/fixtures/index.js +9 -6
- package/dest/public/avm/fixtures/simple_contract_data_source.d.ts +1 -2
- package/dest/public/avm/fixtures/simple_contract_data_source.d.ts.map +1 -1
- package/dest/public/avm/fixtures/simple_contract_data_source.js +0 -3
- package/dest/public/avm/journal/journal.d.ts +16 -70
- package/dest/public/avm/journal/journal.d.ts.map +1 -1
- package/dest/public/avm/journal/journal.js +88 -210
- package/dest/public/avm/journal/nullifiers.d.ts +2 -2
- package/dest/public/avm/journal/nullifiers.d.ts.map +1 -1
- package/dest/public/avm/journal/public_storage.d.ts +2 -2
- package/dest/public/avm/journal/public_storage.d.ts.map +1 -1
- package/dest/public/avm/test_utils.d.ts +10 -13
- package/dest/public/avm/test_utils.d.ts.map +1 -1
- package/dest/public/avm/test_utils.js +8 -13
- package/dest/public/fixtures/public_tx_simulation_tester.d.ts +3 -3
- package/dest/public/fixtures/public_tx_simulation_tester.d.ts.map +1 -1
- package/dest/public/fixtures/public_tx_simulation_tester.js +10 -9
- package/dest/public/hinting_db_sources.d.ts +19 -0
- package/dest/public/hinting_db_sources.d.ts.map +1 -0
- package/dest/public/hinting_db_sources.js +36 -0
- package/dest/public/public_db_sources.d.ts +46 -22
- package/dest/public/public_db_sources.d.ts.map +1 -1
- package/dest/public/public_db_sources.js +82 -27
- package/dest/public/public_processor/public_processor.d.ts +5 -5
- package/dest/public/public_processor/public_processor.d.ts.map +1 -1
- package/dest/public/public_processor/public_processor.js +21 -20
- package/dest/public/public_tx_simulator/public_tx_context.d.ts +9 -14
- package/dest/public/public_tx_simulator/public_tx_context.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/public_tx_context.js +15 -19
- package/dest/public/public_tx_simulator/public_tx_simulator.d.ts +9 -6
- package/dest/public/public_tx_simulator/public_tx_simulator.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/public_tx_simulator.js +28 -14
- package/dest/public/side_effect_trace.d.ts +6 -22
- package/dest/public/side_effect_trace.d.ts.map +1 -1
- package/dest/public/side_effect_trace.js +11 -70
- package/dest/public/side_effect_trace_interface.d.ts +5 -19
- package/dest/public/side_effect_trace_interface.d.ts.map +1 -1
- package/dest/testing.d.ts +2 -0
- package/dest/testing.d.ts.map +1 -0
- package/dest/testing.js +1 -0
- package/package.json +15 -14
- package/src/common/db_interfaces.ts +32 -18
- package/src/common/debug_fn_name.ts +2 -2
- package/src/common/message_load_oracle_inputs.ts +8 -0
- package/src/private/acvm/acvm.ts +8 -24
- package/src/private/acvm/deserialize.ts +35 -29
- package/src/private/acvm/oracle/oracle.ts +171 -129
- package/src/private/acvm/oracle/typed_oracle.ts +7 -3
- package/src/private/acvm/serialize.ts +28 -0
- package/src/private/execution_data_provider.ts +19 -14
- package/src/private/private_execution.ts +11 -7
- package/src/private/private_execution_oracle.ts +5 -1
- package/src/private/providers/acvm_native.ts +17 -6
- package/src/private/providers/acvm_wasm.ts +27 -20
- package/src/private/providers/acvm_wasm_with_blobs.ts +15 -12
- package/src/private/providers/circuit_recording/circuit_recorder.ts +283 -0
- package/src/private/providers/circuit_recording/simulation_provider_recorder_wrapper.ts +82 -0
- package/src/private/providers/simulation_provider.ts +30 -5
- package/src/private/simulator.ts +5 -3
- package/src/private/unconstrained_execution.ts +8 -4
- package/src/private/unconstrained_execution_oracle.ts +15 -9
- package/src/public/avm/avm_simulator.ts +0 -2
- package/src/public/avm/fixtures/avm_simulation_tester.ts +8 -5
- package/src/public/avm/fixtures/index.ts +16 -10
- package/src/public/avm/fixtures/simple_contract_data_source.ts +1 -10
- package/src/public/avm/journal/journal.ts +119 -353
- package/src/public/avm/journal/nullifiers.ts +2 -2
- package/src/public/avm/journal/public_storage.ts +2 -2
- package/src/public/avm/test_utils.ts +20 -29
- package/src/public/fixtures/public_tx_simulation_tester.ts +9 -12
- package/src/public/hinting_db_sources.ts +71 -0
- package/src/public/public_db_sources.ts +134 -32
- package/src/public/public_processor/public_processor.ts +22 -21
- package/src/public/public_tx_simulator/public_tx_context.ts +30 -38
- package/src/public/public_tx_simulator/public_tx_simulator.ts +47 -17
- package/src/public/side_effect_trace.ts +8 -172
- package/src/public/side_effect_trace_interface.ts +4 -55
- package/src/testing.ts +1 -0
- package/dest/public/avm/bytecode_utils.d.ts +0 -5
- package/dest/public/avm/bytecode_utils.d.ts.map +0 -1
- package/dest/public/avm/bytecode_utils.js +0 -17
- package/src/public/avm/bytecode_utils.ts +0 -17
|
@@ -1,34 +1,20 @@
|
|
|
1
1
|
import type { Fr } from '@aztec/foundation/fields';
|
|
2
|
-
import type { AvmPublicDataReadTreeHint } from '@aztec/stdlib/avm';
|
|
3
2
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
|
-
import type { ContractClassWithCommitment, SerializableContractInstance } from '@aztec/stdlib/contract';
|
|
5
3
|
import type { PublicCallRequest } from '@aztec/stdlib/kernel';
|
|
6
4
|
import type { PublicLog } from '@aztec/stdlib/logs';
|
|
7
|
-
import type { NullifierLeafPreimage, PublicDataTreeLeafPreimage } from '@aztec/stdlib/trees';
|
|
8
5
|
export interface PublicSideEffectTraceInterface {
|
|
9
6
|
fork(): PublicSideEffectTraceInterface;
|
|
10
7
|
merge(nestedTrace: PublicSideEffectTraceInterface, reverted?: boolean): void;
|
|
11
8
|
getCounter(): number;
|
|
12
|
-
tracePublicStorageRead(contractAddress: AztecAddress, slot: Fr, value: Fr, leafPreimage?: PublicDataTreeLeafPreimage, leafIndex?: Fr, path?: Fr[]): void;
|
|
13
9
|
tracePublicStorageWrite(contractAddress: AztecAddress, slot: Fr, // This is the storage slot not the computed leaf slot
|
|
14
|
-
value: Fr, protocolWrite: boolean
|
|
15
|
-
|
|
16
|
-
traceNewNoteHash(uniqueNoteHash: Fr, leafIndex?: Fr, path?: Fr[]): void;
|
|
10
|
+
value: Fr, protocolWrite: boolean): Promise<void>;
|
|
11
|
+
traceNewNoteHash(uniqueNoteHash: Fr): void;
|
|
17
12
|
getNoteHashCount(): number;
|
|
18
|
-
|
|
19
|
-
traceNewNullifier(siloedNullifier: Fr, lowLeafPreimage?: NullifierLeafPreimage, lowLeafIndex?: Fr, lowLeafPath?: Fr[], insertionPath?: Fr[]): void;
|
|
20
|
-
traceL1ToL2MessageCheck(contractAddress: AztecAddress, msgHash: Fr, msgLeafIndex: Fr, exists: boolean, path?: Fr[]): void;
|
|
13
|
+
traceNewNullifier(siloedNullifier: Fr): void;
|
|
21
14
|
traceNewL2ToL1Message(contractAddress: AztecAddress, recipient: Fr, content: Fr): void;
|
|
22
15
|
tracePublicLog(contractAddress: AztecAddress, log: Fr[]): void;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
traceEnqueuedCall(
|
|
26
|
-
/** The call request from private that enqueued this call. */
|
|
27
|
-
publicCallRequest: PublicCallRequest,
|
|
28
|
-
/** The call's calldata */
|
|
29
|
-
calldata: Fr[],
|
|
30
|
-
/** Did the call revert? */
|
|
31
|
-
reverted: boolean): void;
|
|
16
|
+
traceGetContractClass(contractClassId: Fr, exists: boolean): void;
|
|
17
|
+
traceEnqueuedCall(publicCallRequest: PublicCallRequest): void;
|
|
32
18
|
getPublicLogs(): PublicLog[];
|
|
33
19
|
}
|
|
34
20
|
//# sourceMappingURL=side_effect_trace_interface.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"side_effect_trace_interface.d.ts","sourceRoot":"","sources":["../../src/public/side_effect_trace_interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"side_effect_trace_interface.d.ts","sourceRoot":"","sources":["../../src/public/side_effect_trace_interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD,MAAM,WAAW,8BAA8B;IAC7C,IAAI,IAAI,8BAA8B,CAAC;IACvC,KAAK,CAAC,WAAW,EAAE,8BAA8B,EAAE,QAAQ,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC7E,UAAU,IAAI,MAAM,CAAC;IAErB,uBAAuB,CACrB,eAAe,EAAE,YAAY,EAC7B,IAAI,EAAE,EAAE,EAAE,sDAAsD;IAChE,KAAK,EAAE,EAAE,EACT,aAAa,EAAE,OAAO,GACrB,OAAO,CAAC,IAAI,CAAC,CAAC;IACjB,gBAAgB,CAAC,cAAc,EAAE,EAAE,GAAG,IAAI,CAAC;IAC3C,gBAAgB,IAAI,MAAM,CAAC;IAC3B,iBAAiB,CAAC,eAAe,EAAE,EAAE,GAAG,IAAI,CAAC;IAC7C,qBAAqB,CAAC,eAAe,EAAE,YAAY,EAAE,SAAS,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC;IACvF,cAAc,CAAC,eAAe,EAAE,YAAY,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,IAAI,CAAC;IAC/D,qBAAqB,CAAC,eAAe,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;IAClE,iBAAiB,CAAC,iBAAiB,EAAE,iBAAiB,GAAG,IAAI,CAAC;IAC9D,aAAa,IAAI,SAAS,EAAE,CAAC;CAC9B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iCAAiC,EAAE,MAAM,+EAA+E,CAAC"}
|
package/dest/testing.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SimulationProviderRecorderWrapper } from './private/providers/circuit_recording/simulation_provider_recorder_wrapper.js';
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/simulator",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.82.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./server": "./dest/server.js",
|
|
7
7
|
"./client": "./dest/client.js",
|
|
8
|
+
"./testing": "./dest/testing.js",
|
|
8
9
|
"./public/fixtures": "./dest/public/fixtures/index.js"
|
|
9
10
|
},
|
|
10
11
|
"typedocOptions": {
|
|
@@ -59,16 +60,16 @@
|
|
|
59
60
|
]
|
|
60
61
|
},
|
|
61
62
|
"dependencies": {
|
|
62
|
-
"@aztec/constants": "0.
|
|
63
|
-
"@aztec/foundation": "0.
|
|
64
|
-
"@aztec/noir-acvm_js": "0.
|
|
65
|
-
"@aztec/noir-noirc_abi": "0.
|
|
66
|
-
"@aztec/noir-protocol-circuits-types": "0.
|
|
67
|
-
"@aztec/noir-types": "0.
|
|
68
|
-
"@aztec/protocol-contracts": "0.
|
|
69
|
-
"@aztec/stdlib": "0.
|
|
70
|
-
"@aztec/telemetry-client": "0.
|
|
71
|
-
"@aztec/world-state": "0.
|
|
63
|
+
"@aztec/constants": "0.82.0",
|
|
64
|
+
"@aztec/foundation": "0.82.0",
|
|
65
|
+
"@aztec/noir-acvm_js": "0.82.0",
|
|
66
|
+
"@aztec/noir-noirc_abi": "0.82.0",
|
|
67
|
+
"@aztec/noir-protocol-circuits-types": "0.82.0",
|
|
68
|
+
"@aztec/noir-types": "0.82.0",
|
|
69
|
+
"@aztec/protocol-contracts": "0.82.0",
|
|
70
|
+
"@aztec/stdlib": "0.82.0",
|
|
71
|
+
"@aztec/telemetry-client": "0.82.0",
|
|
72
|
+
"@aztec/world-state": "0.82.0",
|
|
72
73
|
"levelup": "^5.1.1",
|
|
73
74
|
"lodash.clonedeep": "^4.5.0",
|
|
74
75
|
"lodash.merge": "^4.6.2",
|
|
@@ -76,9 +77,9 @@
|
|
|
76
77
|
"tslib": "^2.4.0"
|
|
77
78
|
},
|
|
78
79
|
"devDependencies": {
|
|
79
|
-
"@aztec/kv-store": "0.
|
|
80
|
-
"@aztec/merkle-tree": "0.
|
|
81
|
-
"@aztec/noir-contracts.js": "0.
|
|
80
|
+
"@aztec/kv-store": "0.82.0",
|
|
81
|
+
"@aztec/merkle-tree": "0.82.0",
|
|
82
|
+
"@aztec/noir-contracts.js": "0.82.0",
|
|
82
83
|
"@jest/globals": "^29.5.0",
|
|
83
84
|
"@types/jest": "^29.5.0",
|
|
84
85
|
"@types/levelup": "^5.1.3",
|
|
@@ -2,7 +2,7 @@ import type { L1_TO_L2_MSG_TREE_HEIGHT } from '@aztec/constants';
|
|
|
2
2
|
import type { Fr } from '@aztec/foundation/fields';
|
|
3
3
|
import type { FunctionSelector } from '@aztec/stdlib/abi';
|
|
4
4
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
|
-
import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
5
|
+
import type { ContractClassPublic, ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
6
6
|
import type { NullifierMembershipWitness } from '@aztec/stdlib/trees';
|
|
7
7
|
|
|
8
8
|
import type { MessageLoadOracleInputs } from './message_load_oracle_inputs.js';
|
|
@@ -10,7 +10,7 @@ import type { MessageLoadOracleInputs } from './message_load_oracle_inputs.js';
|
|
|
10
10
|
/**
|
|
11
11
|
* Database interface for providing access to public state.
|
|
12
12
|
*/
|
|
13
|
-
export interface
|
|
13
|
+
export interface PublicStateDBInterface {
|
|
14
14
|
/**
|
|
15
15
|
* Reads a value from public storage, returning zero if none.
|
|
16
16
|
* @param contract - Owner of the storage.
|
|
@@ -31,19 +31,40 @@ export interface PublicStateDB {
|
|
|
31
31
|
/**
|
|
32
32
|
* Database interface for providing access to public contract data.
|
|
33
33
|
*/
|
|
34
|
-
export interface
|
|
34
|
+
export interface PublicContractsDBInterface {
|
|
35
35
|
/**
|
|
36
36
|
* Returns a publicly deployed contract instance.
|
|
37
37
|
* @param address - Address of the contract.
|
|
38
|
+
* @param blockNumber - The block number at which to retrieve the contract instance.
|
|
38
39
|
* @returns The contract instance or undefined if not found.
|
|
39
40
|
*/
|
|
40
|
-
getContractInstance(address: AztecAddress): Promise<ContractInstanceWithAddress | undefined>;
|
|
41
|
+
getContractInstance(address: AztecAddress, blockNumber: number): Promise<ContractInstanceWithAddress | undefined>;
|
|
41
42
|
|
|
43
|
+
/**
|
|
44
|
+
* Returns a publicly deployed contract class.
|
|
45
|
+
* @param contractClassId - ID of the contract class.
|
|
46
|
+
* @returns The contract class or undefined if not found
|
|
47
|
+
*/
|
|
48
|
+
getContractClass(contractClassId: Fr): Promise<ContractClassPublic | undefined>;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Returns the commitment to the bytecode of a contract class.
|
|
52
|
+
* @param contractClassId - ID of the contract class.
|
|
53
|
+
* @returns The commitment to the bytecode or undefined if not found.
|
|
54
|
+
*/
|
|
55
|
+
getBytecodeCommitment(contractClassId: Fr): Promise<Fr | undefined>;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Returns the function name of a contract's function given its selector.
|
|
59
|
+
* @param contractAddress - Address of the contract.
|
|
60
|
+
* @param selector - Selector of the function.
|
|
61
|
+
* @returns The name of the function or undefined if not found.
|
|
62
|
+
*/
|
|
42
63
|
getDebugFunctionName(contractAddress: AztecAddress, selector: FunctionSelector): Promise<string | undefined>;
|
|
43
64
|
}
|
|
44
65
|
|
|
45
|
-
/** Database interface for providing access to
|
|
46
|
-
export interface
|
|
66
|
+
/** Database interface for providing access to note hash tree, l1 to l2 message tree, and nullifier tree. */
|
|
67
|
+
export interface CommitmentsDBInterface {
|
|
47
68
|
/**
|
|
48
69
|
* Fetches a message from the db, given its key.
|
|
49
70
|
* @param contractAddress - Address of a contract by which the message was emitted.
|
|
@@ -60,23 +81,16 @@ export interface CommitmentsDB {
|
|
|
60
81
|
|
|
61
82
|
/**
|
|
62
83
|
* @param leafIndex the leaf to look up
|
|
63
|
-
* @returns The l1 to l2 leaf
|
|
64
|
-
*/
|
|
65
|
-
getL1ToL2LeafValue(leafIndex: bigint): Promise<Fr | undefined>;
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Gets the index of a commitment in the note hash tree.
|
|
69
|
-
* @param commitment - The commitment.
|
|
70
|
-
* @returns - The index of the commitment. Undefined if it does not exist in the tree.
|
|
84
|
+
* @returns The l1 to l2 leaf message hash or undefined if not found.
|
|
71
85
|
*/
|
|
72
|
-
|
|
86
|
+
getL1ToL2MessageHash(leafIndex: bigint): Promise<Fr | undefined>;
|
|
73
87
|
|
|
74
88
|
/**
|
|
75
|
-
* Gets
|
|
89
|
+
* Gets note hash in the note hash tree at the given leaf index.
|
|
76
90
|
* @param leafIndex - the leaf to look up.
|
|
77
|
-
* @returns - The
|
|
91
|
+
* @returns - The note hash at that index. Undefined if leaf index is not found.
|
|
78
92
|
*/
|
|
79
|
-
|
|
93
|
+
getNoteHash(leafIndex: bigint): Promise<Fr | undefined>;
|
|
80
94
|
|
|
81
95
|
/**
|
|
82
96
|
* Gets the index of a nullifier in the nullifier tree.
|
|
@@ -2,10 +2,10 @@ import type { Fr } from '@aztec/foundation/fields';
|
|
|
2
2
|
import { FunctionSelector } from '@aztec/stdlib/abi';
|
|
3
3
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
4
|
|
|
5
|
-
import type {
|
|
5
|
+
import type { PublicContractsDBInterface } from './db_interfaces.js';
|
|
6
6
|
|
|
7
7
|
export async function getPublicFunctionDebugName(
|
|
8
|
-
db:
|
|
8
|
+
db: PublicContractsDBInterface,
|
|
9
9
|
contractAddress: AztecAddress,
|
|
10
10
|
calldata: Fr[],
|
|
11
11
|
): Promise<string> {
|
|
@@ -12,4 +12,12 @@ export class MessageLoadOracleInputs<N extends number> {
|
|
|
12
12
|
toFields(): Fr[] {
|
|
13
13
|
return [new Fr(this.index), ...this.siblingPath.toFields()];
|
|
14
14
|
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Returns a representation of the public data witness as expected by intrinsic Noir deserialization.
|
|
18
|
+
*/
|
|
19
|
+
public toNoirRepresentation(): (string | string[])[] {
|
|
20
|
+
// TODO(#12874): remove the stupid as string conversion by modifying ForeignCallOutput type in acvm.js
|
|
21
|
+
return [new Fr(this.index).toString() as string, this.siblingPath.toFields().map(fr => fr.toString()) as string[]];
|
|
22
|
+
}
|
|
15
23
|
}
|
package/src/private/acvm/acvm.ts
CHANGED
|
@@ -15,18 +15,7 @@ import type { ORACLE_NAMES } from './oracle/index.js';
|
|
|
15
15
|
/**
|
|
16
16
|
* The callback interface for the ACIR.
|
|
17
17
|
*/
|
|
18
|
-
export type ACIRCallback = Record<
|
|
19
|
-
ORACLE_NAMES,
|
|
20
|
-
(
|
|
21
|
-
...args: ForeignCallInput[]
|
|
22
|
-
) =>
|
|
23
|
-
| void
|
|
24
|
-
| Promise<void>
|
|
25
|
-
| ForeignCallOutput
|
|
26
|
-
| ForeignCallOutput[]
|
|
27
|
-
| Promise<ForeignCallOutput>
|
|
28
|
-
| Promise<ForeignCallOutput[]>
|
|
29
|
-
>;
|
|
18
|
+
export type ACIRCallback = Record<ORACLE_NAMES, (...args: ForeignCallInput[]) => Promise<ForeignCallOutput[]>>;
|
|
30
19
|
|
|
31
20
|
/**
|
|
32
21
|
* The result of executing an ACIR.
|
|
@@ -43,6 +32,11 @@ export interface ACIRExecutionResult {
|
|
|
43
32
|
|
|
44
33
|
/**
|
|
45
34
|
* The function call that executes an ACIR.
|
|
35
|
+
* @param acir - The ACIR circuit bytecode to execute.
|
|
36
|
+
* @param initialWitness - The initial witness map defining all of the inputs to `circuit`.
|
|
37
|
+
* @param callback - A callback to process any foreign calls from the circuit.
|
|
38
|
+
* @returns The solved witness calculated by executing the circuit on the provided inputs, as well as the return
|
|
39
|
+
* witness indices as specified by the circuit.
|
|
46
40
|
*/
|
|
47
41
|
export async function acvm(
|
|
48
42
|
acir: Buffer,
|
|
@@ -54,7 +48,7 @@ export async function acvm(
|
|
|
54
48
|
const solvedAndReturnWitness = await executeCircuitWithReturnWitness(
|
|
55
49
|
acir,
|
|
56
50
|
initialWitness,
|
|
57
|
-
|
|
51
|
+
(name: string, args: ForeignCallInput[]) => {
|
|
58
52
|
try {
|
|
59
53
|
logger.debug(`Oracle callback ${name}`);
|
|
60
54
|
const oracleFunction = callback[name as ORACLE_NAMES];
|
|
@@ -62,17 +56,7 @@ export async function acvm(
|
|
|
62
56
|
throw new Error(`Oracle callback ${name} not found`);
|
|
63
57
|
}
|
|
64
58
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
if (typeof result === 'undefined') {
|
|
68
|
-
return [];
|
|
69
|
-
} else if (result instanceof Array && !result.every(item => typeof item === 'string')) {
|
|
70
|
-
// We are dealing with a nested array which means that we do not need it wrap it in another array as to have
|
|
71
|
-
// the nested array structure it is already "wrapped".
|
|
72
|
-
return result;
|
|
73
|
-
} else {
|
|
74
|
-
return [result] as ForeignCallOutput[];
|
|
75
|
-
}
|
|
59
|
+
return oracleFunction.call(callback, ...args);
|
|
76
60
|
} catch (err) {
|
|
77
61
|
let typedError: Error;
|
|
78
62
|
if (err instanceof Error) {
|
|
@@ -1,34 +1,8 @@
|
|
|
1
1
|
import { Fr } from '@aztec/foundation/fields';
|
|
2
|
+
import { hexToBuffer } from '@aztec/foundation/string';
|
|
2
3
|
|
|
3
4
|
import type { ACVMField, ACVMWitness } from './acvm_types.js';
|
|
4
5
|
|
|
5
|
-
/**
|
|
6
|
-
* Converts an ACVM field to a Fr.
|
|
7
|
-
* @param field - The ACVM field to convert.
|
|
8
|
-
* @returns The Fr.
|
|
9
|
-
*/
|
|
10
|
-
export function fromACVMField(field: ACVMField): Fr {
|
|
11
|
-
return Fr.fromBuffer(Buffer.from(field.slice(2), 'hex'));
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Converts a field to a number.
|
|
16
|
-
* @param fr - The field to convert.
|
|
17
|
-
* @returns The number.
|
|
18
|
-
* TODO(#4102): Nuke this once block number is big int.
|
|
19
|
-
*/
|
|
20
|
-
export function frToNumber(fr: Fr): number {
|
|
21
|
-
return Number(fr.value);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Converts a field to a boolean.
|
|
26
|
-
* @param fr - The field to convert.
|
|
27
|
-
*/
|
|
28
|
-
export function frToBoolean(fr: Fr): boolean {
|
|
29
|
-
return fr.toBigInt() === BigInt(1);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
6
|
/**
|
|
33
7
|
* Converts a Noir BoundedVec of Fields into an Fr array. Note that BoundedVecs are structs, and therefore translated as
|
|
34
8
|
* two separate ACVMField values (an array and a single field).
|
|
@@ -38,7 +12,25 @@ export function frToBoolean(fr: Fr): boolean {
|
|
|
38
12
|
* @returns An array with the same content as the Noir version. Elements past the length are discarded.
|
|
39
13
|
*/
|
|
40
14
|
export function fromBoundedVec(storage: ACVMField[], length: ACVMField): Fr[] {
|
|
41
|
-
return storage.slice(0,
|
|
15
|
+
return storage.slice(0, Fr.fromString(length).toNumber()).map(Fr.fromString);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Converts a Noir BoundedVec of unsigned integers into a Buffer. Note that BoundedVecs are structs, and therefore
|
|
20
|
+
* translated as two separate ACVMField values (an array and a single field).
|
|
21
|
+
*
|
|
22
|
+
* @param storage The array with the BoundedVec's storage (i.e. BoundedVec::storage())
|
|
23
|
+
* @param length The length of the BoundedVec (i.e. BoundedVec::len())
|
|
24
|
+
* @param uintBitSize If it's an array of Noir u8's, put `8`, etc.
|
|
25
|
+
* @returns A buffer containing the unsigned integers tightly packed
|
|
26
|
+
*/
|
|
27
|
+
export function fromUintBoundedVec(storage: ACVMField[], length: ACVMField, uintBitSize: number): Buffer {
|
|
28
|
+
if (uintBitSize % 8 !== 0) {
|
|
29
|
+
throw new Error(`u${uintBitSize} is not a supported type in Noir`);
|
|
30
|
+
}
|
|
31
|
+
const uintByteSize = uintBitSize / 8;
|
|
32
|
+
const boundedStorage = storage.slice(0, Fr.fromString(length).toNumber());
|
|
33
|
+
return Buffer.concat(boundedStorage.map(str => hexToBuffer(str).subarray(-uintByteSize)));
|
|
42
34
|
}
|
|
43
35
|
|
|
44
36
|
/**
|
|
@@ -48,5 +40,19 @@ export function fromBoundedVec(storage: ACVMField[], length: ACVMField): Fr[] {
|
|
|
48
40
|
*/
|
|
49
41
|
export function witnessMapToFields(witness: ACVMWitness): Fr[] {
|
|
50
42
|
const sortedKeys = [...witness.keys()].sort((a, b) => a - b);
|
|
51
|
-
return sortedKeys.map(key => witness.get(key)!).map(
|
|
43
|
+
return sortedKeys.map(key => witness.get(key)!).map(Fr.fromString);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Converts an array of Noir unsigned integers to a single tightly-packed buffer.
|
|
48
|
+
* @param uintBitSize If it's an array of Noir u8's, put `8`, etc.
|
|
49
|
+
* @returns A buffer where each byte is correctly represented as a single byte in the buffer.
|
|
50
|
+
* Copy of the function in txe/src/util/encoding.ts.
|
|
51
|
+
*/
|
|
52
|
+
export function fromUintArray(obj: ACVMField[], uintBitSize: number): Buffer {
|
|
53
|
+
if (uintBitSize % 8 !== 0) {
|
|
54
|
+
throw new Error(`u${uintBitSize} is not a supported type in Noir`);
|
|
55
|
+
}
|
|
56
|
+
const uintByteSize = uintBitSize / 8;
|
|
57
|
+
return Buffer.concat(obj.map(str => hexToBuffer(str).slice(-uintByteSize)));
|
|
52
58
|
}
|