@aztec/simulator 0.0.1-commit.2f68f620 → 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/client.d.ts +1 -3
- package/dest/client.d.ts.map +1 -1
- package/dest/client.js +0 -2
- package/dest/private/circuit_recording/circuit_recorder.d.ts +36 -23
- package/dest/private/circuit_recording/circuit_recorder.d.ts.map +1 -1
- package/dest/private/circuit_recording/circuit_recorder.js +65 -69
- package/dest/private/circuit_recording/file_circuit_recorder.d.ts +7 -19
- package/dest/private/circuit_recording/file_circuit_recorder.d.ts.map +1 -1
- package/dest/private/circuit_recording/file_circuit_recorder.js +38 -42
- package/dest/private/circuit_recording/simulator_recorder_wrapper.d.ts +1 -1
- package/dest/private/circuit_recording/simulator_recorder_wrapper.d.ts.map +1 -1
- package/dest/private/circuit_recording/simulator_recorder_wrapper.js +11 -14
- package/dest/public/avm/testing/base_avm_simulation_tester.js +1 -1
- package/dest/public/avm/testing/utils.js +1 -1
- package/dest/public/avm_simulator.d.ts +28 -0
- package/dest/public/avm_simulator.d.ts.map +1 -0
- package/dest/public/avm_simulator.js +4 -0
- package/dest/public/avm_simulator_pool.d.ts +45 -0
- package/dest/public/avm_simulator_pool.d.ts.map +1 -0
- package/dest/public/avm_simulator_pool.js +197 -0
- package/dest/public/cdb/generated/api_types.d.ts +171 -0
- package/dest/public/cdb/generated/api_types.d.ts.map +1 -0
- package/dest/public/cdb/generated/api_types.js +314 -0
- package/dest/public/cdb/generated/server.d.ts +26 -0
- package/dest/public/cdb/generated/server.d.ts.map +1 -0
- package/dest/public/cdb/generated/server.js +135 -0
- package/dest/public/cdb_ipc_server.d.ts +33 -0
- package/dest/public/cdb_ipc_server.d.ts.map +1 -0
- package/dest/public/cdb_ipc_server.js +153 -0
- package/dest/public/fixtures/amm_test.js +2 -2
- package/dest/public/fixtures/bulk_test.js +2 -2
- package/dest/public/fixtures/custom_bytecode_tester.d.ts +1 -1
- package/dest/public/fixtures/custom_bytecode_tester.d.ts.map +1 -1
- package/dest/public/fixtures/custom_bytecode_tester.js +2 -2
- package/dest/public/fixtures/index.d.ts +2 -1
- package/dest/public/fixtures/index.d.ts.map +1 -1
- package/dest/public/fixtures/index.js +1 -0
- package/dest/public/fixtures/public_processor_test_env.d.ts +30 -0
- package/dest/public/fixtures/public_processor_test_env.d.ts.map +1 -0
- package/dest/public/fixtures/public_processor_test_env.js +73 -0
- package/dest/public/fixtures/public_tx_simulation_tester.d.ts +9 -5
- package/dest/public/fixtures/public_tx_simulation_tester.d.ts.map +1 -1
- package/dest/public/fixtures/public_tx_simulation_tester.js +29 -11
- package/dest/public/fixtures/token_test.js +3 -3
- package/dest/public/fixtures/utils.d.ts +1 -1
- package/dest/public/fixtures/utils.d.ts.map +1 -1
- package/dest/public/fixtures/utils.js +5 -3
- package/dest/public/fuzzing/avm_fuzzer_simulator.d.ts +7 -2
- package/dest/public/fuzzing/avm_fuzzer_simulator.d.ts.map +1 -1
- package/dest/public/fuzzing/avm_fuzzer_simulator.js +15 -6
- package/dest/public/index.d.ts +5 -2
- package/dest/public/index.d.ts.map +1 -1
- package/dest/public/index.js +2 -1
- package/dest/public/public_db_sources.d.ts +2 -2
- package/dest/public/public_db_sources.d.ts.map +1 -1
- package/dest/public/public_db_sources.js +1 -1
- package/dest/public/public_processor/public_processor.d.ts +8 -4
- package/dest/public/public_processor/public_processor.d.ts.map +1 -1
- package/dest/public/public_processor/public_processor.js +17 -13
- package/dest/public/public_tx_simulator/dumping_public_tx_simulator.d.ts +6 -12
- package/dest/public/public_tx_simulator/dumping_public_tx_simulator.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/dumping_public_tx_simulator.js +8 -21
- package/dest/public/public_tx_simulator/factories.d.ts +5 -5
- package/dest/public/public_tx_simulator/factories.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/factories.js +5 -5
- package/dest/public/public_tx_simulator/index.d.ts +3 -3
- package/dest/public/public_tx_simulator/index.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/index.js +1 -1
- package/dest/public/public_tx_simulator/public_tx_simulator.d.ts +16 -16
- package/dest/public/public_tx_simulator/public_tx_simulator.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/public_tx_simulator.js +59 -58
- package/dest/public/public_tx_simulator/public_tx_simulator_base.d.ts +10 -8
- package/dest/public/public_tx_simulator/public_tx_simulator_base.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/public_tx_simulator_base.js +11 -8
- package/dest/public/public_tx_simulator/public_tx_simulator_interface.d.ts +5 -5
- package/package.json +21 -17
- package/src/client.ts +0 -2
- package/src/private/circuit_recording/circuit_recorder.ts +84 -78
- package/src/private/circuit_recording/file_circuit_recorder.ts +38 -48
- package/src/private/circuit_recording/simulator_recorder_wrapper.ts +9 -15
- package/src/public/avm/testing/base_avm_simulation_tester.ts +1 -1
- package/src/public/avm/testing/utils.ts +1 -1
- package/src/public/avm_simulator.ts +29 -0
- package/src/public/avm_simulator_pool.ts +226 -0
- package/src/public/cdb/generated/api_types.ts +457 -0
- package/src/public/cdb/generated/server.ts +109 -0
- package/src/public/cdb_ipc_server.ts +197 -0
- package/src/public/fixtures/amm_test.ts +2 -2
- package/src/public/fixtures/bulk_test.ts +2 -2
- package/src/public/fixtures/custom_bytecode_tester.ts +2 -2
- package/src/public/fixtures/index.ts +1 -0
- package/src/public/fixtures/public_processor_test_env.ts +88 -0
- package/src/public/fixtures/public_tx_simulation_tester.ts +37 -25
- package/src/public/fixtures/token_test.ts +3 -3
- package/src/public/fixtures/utils.ts +6 -11
- package/src/public/fuzzing/avm_fuzzer_simulator.ts +28 -10
- package/src/public/index.ts +4 -0
- package/src/public/public_db_sources.ts +1 -1
- package/src/public/public_processor/public_processor.ts +22 -15
- package/src/public/public_tx_simulator/dumping_public_tx_simulator.ts +13 -29
- package/src/public/public_tx_simulator/factories.ts +24 -7
- package/src/public/public_tx_simulator/index.ts +5 -2
- package/src/public/public_tx_simulator/public_tx_simulator.ts +70 -81
- package/src/public/public_tx_simulator/public_tx_simulator_base.ts +8 -6
- package/src/public/public_tx_simulator/public_tx_simulator_interface.ts +5 -5
- package/dest/public/public_tx_simulator/contract_provider_for_cpp.d.ts +0 -19
- package/dest/public/public_tx_simulator/contract_provider_for_cpp.d.ts.map +0 -1
- package/dest/public/public_tx_simulator/contract_provider_for_cpp.js +0 -99
- package/src/public/public_tx_simulator/contract_provider_for_cpp.ts +0 -125
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
3
|
-
import { FunctionSelector } from '@aztec/stdlib/abi';
|
|
4
|
-
import { deserializeFromMessagePack, serializeWithMessagePack } from '@aztec/stdlib/avm';
|
|
5
|
-
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
6
|
-
import { ContractDeploymentData } from '@aztec/stdlib/contract';
|
|
7
|
-
export class ContractProviderForCpp {
|
|
8
|
-
contractsDB;
|
|
9
|
-
globalVariables;
|
|
10
|
-
log;
|
|
11
|
-
constructor(contractsDB, globalVariables, bindings){
|
|
12
|
-
this.contractsDB = contractsDB;
|
|
13
|
-
this.globalVariables = globalVariables;
|
|
14
|
-
this.getContractInstance = async (address)=>{
|
|
15
|
-
this.log.trace(`Contract provider callback: getContractInstance(${address})`);
|
|
16
|
-
const aztecAddr = AztecAddress.fromString(address);
|
|
17
|
-
const instance = await this.contractsDB.getContractInstance(aztecAddr, this.globalVariables.timestamp);
|
|
18
|
-
if (!instance) {
|
|
19
|
-
this.log.debug(`Contract instance not found: ${address}`);
|
|
20
|
-
return undefined;
|
|
21
|
-
}
|
|
22
|
-
return serializeWithMessagePack(instance);
|
|
23
|
-
};
|
|
24
|
-
this.getContractClass = async (classId)=>{
|
|
25
|
-
this.log.trace(`Contract provider callback: getContractClass(${classId})`);
|
|
26
|
-
// Parse classId string to Fr
|
|
27
|
-
const classIdFr = Fr.fromString(classId);
|
|
28
|
-
// Fetch contract class from the contracts DB
|
|
29
|
-
const contractClass = await this.contractsDB.getContractClass(classIdFr);
|
|
30
|
-
if (!contractClass) {
|
|
31
|
-
this.log.debug(`Contract class not found: ${classId}`);
|
|
32
|
-
return undefined;
|
|
33
|
-
}
|
|
34
|
-
return serializeWithMessagePack(contractClass);
|
|
35
|
-
};
|
|
36
|
-
this.addContracts = async (contractDeploymentDataBuffer)=>{
|
|
37
|
-
this.log.trace(`Contract provider callback: addContracts`);
|
|
38
|
-
const rawData = deserializeFromMessagePack(contractDeploymentDataBuffer);
|
|
39
|
-
// Construct ContractDeploymentData from plain object.
|
|
40
|
-
const contractDeploymentData = ContractDeploymentData.fromPlainObject(rawData);
|
|
41
|
-
// Add contracts to the contracts DB
|
|
42
|
-
this.log.trace(`Calling contractsDB.addContractsFromLogs`);
|
|
43
|
-
this.contractsDB.addContractsFromLogs(contractDeploymentData);
|
|
44
|
-
};
|
|
45
|
-
this.getBytecodeCommitment = async (classId)=>{
|
|
46
|
-
this.log.trace(`Contract provider callback: getBytecodeCommitment(${classId})`);
|
|
47
|
-
// Parse classId string to Fr
|
|
48
|
-
const classIdFr = Fr.fromString(classId);
|
|
49
|
-
// Fetch bytecode commitment from the contracts DB
|
|
50
|
-
const commitment = await this.contractsDB.getBytecodeCommitment(classIdFr);
|
|
51
|
-
if (!commitment) {
|
|
52
|
-
this.log.debug(`Bytecode commitment not found: ${classId}`);
|
|
53
|
-
return undefined;
|
|
54
|
-
}
|
|
55
|
-
// Serialize the Fr to buffer
|
|
56
|
-
return serializeWithMessagePack(commitment);
|
|
57
|
-
};
|
|
58
|
-
this.getDebugFunctionName = async (address, selector)=>{
|
|
59
|
-
this.log.trace(`Contract provider callback: getDebugFunctionName(${address}, ${selector})`);
|
|
60
|
-
// Parse address and selector strings
|
|
61
|
-
const aztecAddr = AztecAddress.fromString(address);
|
|
62
|
-
const selectorFr = Fr.fromString(selector);
|
|
63
|
-
const functionSelector = FunctionSelector.fromFieldOrUndefined(selectorFr);
|
|
64
|
-
if (!functionSelector) {
|
|
65
|
-
this.log.trace(`calldata[0] is not a function selector: ${selector}`);
|
|
66
|
-
return undefined;
|
|
67
|
-
}
|
|
68
|
-
// Fetch debug function name from the contracts DB
|
|
69
|
-
const name = await this.contractsDB.getDebugFunctionName(aztecAddr, functionSelector);
|
|
70
|
-
if (!name) {
|
|
71
|
-
this.log.trace(`Debug function name not found for ${address}:${selector}`);
|
|
72
|
-
return undefined;
|
|
73
|
-
}
|
|
74
|
-
return name;
|
|
75
|
-
};
|
|
76
|
-
this.createCheckpoint = ()=>{
|
|
77
|
-
this.log.trace(`Contract provider callback: createCheckpoint`);
|
|
78
|
-
return Promise.resolve(this.contractsDB.createCheckpoint());
|
|
79
|
-
};
|
|
80
|
-
this.commitCheckpoint = ()=>{
|
|
81
|
-
this.log.trace(`Contract provider callback: commitCheckpoint`);
|
|
82
|
-
return Promise.resolve(this.contractsDB.commitCheckpoint());
|
|
83
|
-
};
|
|
84
|
-
this.revertCheckpoint = ()=>{
|
|
85
|
-
this.log.trace(`Contract provider callback: revertCheckpoint`);
|
|
86
|
-
return Promise.resolve(this.contractsDB.revertCheckpoint());
|
|
87
|
-
};
|
|
88
|
-
this.log = createLogger('simulator:contract_provider_for_cpp', bindings);
|
|
89
|
-
}
|
|
90
|
-
getContractInstance;
|
|
91
|
-
getContractClass;
|
|
92
|
-
// eslint-disable-next-line require-await
|
|
93
|
-
addContracts;
|
|
94
|
-
getBytecodeCommitment;
|
|
95
|
-
getDebugFunctionName;
|
|
96
|
-
createCheckpoint;
|
|
97
|
-
commitCheckpoint;
|
|
98
|
-
revertCheckpoint;
|
|
99
|
-
}
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
-
import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
|
|
3
|
-
import type { ContractProvider } from '@aztec/native';
|
|
4
|
-
import { FunctionSelector } from '@aztec/stdlib/abi';
|
|
5
|
-
import { deserializeFromMessagePack, serializeWithMessagePack } from '@aztec/stdlib/avm';
|
|
6
|
-
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
7
|
-
import { ContractDeploymentData } from '@aztec/stdlib/contract';
|
|
8
|
-
import type { GlobalVariables } from '@aztec/stdlib/tx';
|
|
9
|
-
|
|
10
|
-
import type { PublicContractsDB } from '../public_db_sources.js';
|
|
11
|
-
|
|
12
|
-
export class ContractProviderForCpp implements ContractProvider {
|
|
13
|
-
private log: Logger;
|
|
14
|
-
|
|
15
|
-
constructor(
|
|
16
|
-
private contractsDB: PublicContractsDB,
|
|
17
|
-
private globalVariables: GlobalVariables,
|
|
18
|
-
bindings?: LoggerBindings,
|
|
19
|
-
) {
|
|
20
|
-
this.log = createLogger('simulator:contract_provider_for_cpp', bindings);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
public getContractInstance = async (address: string): Promise<Buffer | undefined> => {
|
|
24
|
-
this.log.trace(`Contract provider callback: getContractInstance(${address})`);
|
|
25
|
-
|
|
26
|
-
const aztecAddr = AztecAddress.fromString(address);
|
|
27
|
-
|
|
28
|
-
const instance = await this.contractsDB.getContractInstance(aztecAddr, this.globalVariables.timestamp);
|
|
29
|
-
|
|
30
|
-
if (!instance) {
|
|
31
|
-
this.log.debug(`Contract instance not found: ${address}`);
|
|
32
|
-
return undefined;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return serializeWithMessagePack(instance);
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
public getContractClass = async (classId: string): Promise<Buffer | undefined> => {
|
|
39
|
-
this.log.trace(`Contract provider callback: getContractClass(${classId})`);
|
|
40
|
-
|
|
41
|
-
// Parse classId string to Fr
|
|
42
|
-
const classIdFr = Fr.fromString(classId);
|
|
43
|
-
|
|
44
|
-
// Fetch contract class from the contracts DB
|
|
45
|
-
const contractClass = await this.contractsDB.getContractClass(classIdFr);
|
|
46
|
-
|
|
47
|
-
if (!contractClass) {
|
|
48
|
-
this.log.debug(`Contract class not found: ${classId}`);
|
|
49
|
-
return undefined;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return serializeWithMessagePack(contractClass);
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
// eslint-disable-next-line require-await
|
|
56
|
-
public addContracts = async (contractDeploymentDataBuffer: Buffer): Promise<void> => {
|
|
57
|
-
this.log.trace(`Contract provider callback: addContracts`);
|
|
58
|
-
|
|
59
|
-
const rawData: any = deserializeFromMessagePack(contractDeploymentDataBuffer);
|
|
60
|
-
|
|
61
|
-
// Construct ContractDeploymentData from plain object.
|
|
62
|
-
const contractDeploymentData = ContractDeploymentData.fromPlainObject(rawData);
|
|
63
|
-
|
|
64
|
-
// Add contracts to the contracts DB
|
|
65
|
-
this.log.trace(`Calling contractsDB.addContractsFromLogs`);
|
|
66
|
-
this.contractsDB.addContractsFromLogs(contractDeploymentData);
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
public getBytecodeCommitment = async (classId: string): Promise<Buffer | undefined> => {
|
|
70
|
-
this.log.trace(`Contract provider callback: getBytecodeCommitment(${classId})`);
|
|
71
|
-
|
|
72
|
-
// Parse classId string to Fr
|
|
73
|
-
const classIdFr = Fr.fromString(classId);
|
|
74
|
-
|
|
75
|
-
// Fetch bytecode commitment from the contracts DB
|
|
76
|
-
const commitment = await this.contractsDB.getBytecodeCommitment(classIdFr);
|
|
77
|
-
|
|
78
|
-
if (!commitment) {
|
|
79
|
-
this.log.debug(`Bytecode commitment not found: ${classId}`);
|
|
80
|
-
return undefined;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// Serialize the Fr to buffer
|
|
84
|
-
return serializeWithMessagePack(commitment);
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
public getDebugFunctionName = async (address: string, selector: string): Promise<string | undefined> => {
|
|
88
|
-
this.log.trace(`Contract provider callback: getDebugFunctionName(${address}, ${selector})`);
|
|
89
|
-
|
|
90
|
-
// Parse address and selector strings
|
|
91
|
-
const aztecAddr = AztecAddress.fromString(address);
|
|
92
|
-
const selectorFr = Fr.fromString(selector);
|
|
93
|
-
const functionSelector = FunctionSelector.fromFieldOrUndefined(selectorFr);
|
|
94
|
-
|
|
95
|
-
if (!functionSelector) {
|
|
96
|
-
this.log.trace(`calldata[0] is not a function selector: ${selector}`);
|
|
97
|
-
return undefined;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
// Fetch debug function name from the contracts DB
|
|
101
|
-
const name = await this.contractsDB.getDebugFunctionName(aztecAddr, functionSelector);
|
|
102
|
-
|
|
103
|
-
if (!name) {
|
|
104
|
-
this.log.trace(`Debug function name not found for ${address}:${selector}`);
|
|
105
|
-
return undefined;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
return name;
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
public createCheckpoint = (): Promise<void> => {
|
|
112
|
-
this.log.trace(`Contract provider callback: createCheckpoint`);
|
|
113
|
-
return Promise.resolve(this.contractsDB.createCheckpoint());
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
public commitCheckpoint = (): Promise<void> => {
|
|
117
|
-
this.log.trace(`Contract provider callback: commitCheckpoint`);
|
|
118
|
-
return Promise.resolve(this.contractsDB.commitCheckpoint());
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
public revertCheckpoint = (): Promise<void> => {
|
|
122
|
-
this.log.trace(`Contract provider callback: revertCheckpoint`);
|
|
123
|
-
return Promise.resolve(this.contractsDB.revertCheckpoint());
|
|
124
|
-
};
|
|
125
|
-
}
|