@aztec/simulator 0.41.0 → 0.42.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/acvm/acvm.d.ts +2 -2
- package/dest/acvm/acvm.d.ts.map +1 -1
- package/dest/acvm/acvm.js +3 -3
- package/dest/acvm/oracle/oracle.d.ts +6 -4
- package/dest/acvm/oracle/oracle.d.ts.map +1 -1
- package/dest/acvm/oracle/oracle.js +20 -11
- package/dest/acvm/oracle/typed_oracle.d.ts +5 -3
- package/dest/acvm/oracle/typed_oracle.d.ts.map +1 -1
- package/dest/acvm/oracle/typed_oracle.js +10 -4
- package/dest/acvm/serialize.js +2 -2
- package/dest/avm/avm_gas.d.ts +1 -5
- package/dest/avm/avm_gas.d.ts.map +1 -1
- package/dest/avm/avm_gas.js +67 -73
- package/dest/avm/avm_simulator.d.ts +5 -0
- package/dest/avm/avm_simulator.d.ts.map +1 -1
- package/dest/avm/avm_simulator.js +8 -1
- package/dest/avm/fixtures/index.d.ts +3 -0
- package/dest/avm/fixtures/index.d.ts.map +1 -1
- package/dest/avm/fixtures/index.js +13 -1
- package/dest/avm/index.d.ts +2 -0
- package/dest/avm/index.d.ts.map +1 -0
- package/dest/avm/index.js +2 -0
- package/dest/avm/journal/host_storage.d.ts +1 -1
- package/dest/avm/journal/host_storage.d.ts.map +1 -1
- package/dest/avm/journal/journal.d.ts +2 -0
- package/dest/avm/journal/journal.d.ts.map +1 -1
- package/dest/avm/journal/journal.js +6 -2
- package/dest/avm/journal/trace.d.ts +2 -0
- package/dest/avm/journal/trace.d.ts.map +1 -1
- package/dest/avm/journal/trace.js +7 -1
- package/dest/avm/journal/trace_types.d.ts +1 -0
- package/dest/avm/journal/trace_types.d.ts.map +1 -1
- package/dest/avm/journal/trace_types.js +1 -1
- package/dest/avm/opcodes/arithmetic.d.ts +1 -7
- package/dest/avm/opcodes/arithmetic.d.ts.map +1 -1
- package/dest/avm/opcodes/arithmetic.js +1 -12
- package/dest/avm/opcodes/conversion.js +2 -2
- package/dest/avm/opcodes/external_calls.d.ts.map +1 -1
- package/dest/avm/opcodes/external_calls.js +4 -3
- package/dest/avm/opcodes/instruction.d.ts +1 -1
- package/dest/avm/opcodes/instruction.d.ts.map +1 -1
- package/dest/avm/opcodes/instruction.js +6 -4
- package/dest/avm/opcodes/memory.d.ts +0 -4
- package/dest/avm/opcodes/memory.d.ts.map +1 -1
- package/dest/avm/opcodes/memory.js +1 -7
- package/dest/avm/opcodes/storage.d.ts +0 -5
- package/dest/avm/opcodes/storage.d.ts.map +1 -1
- package/dest/avm/opcodes/storage.js +1 -7
- package/dest/avm/serialization/bytecode_serialization.js +2 -2
- package/dest/client/client_execution_context.d.ts +11 -19
- package/dest/client/client_execution_context.d.ts.map +1 -1
- package/dest/client/client_execution_context.js +26 -43
- package/dest/client/db_oracle.d.ts +7 -1
- package/dest/client/db_oracle.d.ts.map +1 -1
- package/dest/client/execution_note_cache.d.ts +0 -17
- package/dest/client/execution_note_cache.d.ts.map +1 -1
- package/dest/client/execution_note_cache.js +1 -24
- package/dest/client/execution_result.d.ts +8 -4
- package/dest/client/execution_result.d.ts.map +1 -1
- package/dest/client/execution_result.js +16 -6
- package/dest/client/private_execution.d.ts +2 -3
- package/dest/client/private_execution.d.ts.map +1 -1
- package/dest/client/private_execution.js +20 -9
- package/dest/client/simulator.d.ts +0 -16
- package/dest/client/simulator.d.ts.map +1 -1
- package/dest/client/simulator.js +8 -25
- package/dest/client/unconstrained_execution.d.ts +2 -3
- package/dest/client/unconstrained_execution.d.ts.map +1 -1
- package/dest/client/unconstrained_execution.js +5 -7
- package/dest/client/view_data_oracle.d.ts +2 -0
- package/dest/client/view_data_oracle.d.ts.map +1 -1
- package/dest/client/view_data_oracle.js +7 -1
- package/dest/index.d.ts +3 -1
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +4 -2
- package/dest/mocks/fixtures.d.ts +14 -10
- package/dest/mocks/fixtures.d.ts.map +1 -1
- package/dest/mocks/fixtures.js +22 -16
- package/dest/{simulator → providers}/acvm_native.d.ts.map +1 -1
- package/dest/{simulator → providers}/acvm_native.js +13 -14
- package/dest/providers/acvm_wasm.d.ts.map +1 -0
- package/dest/providers/acvm_wasm.js +15 -0
- package/dest/providers/index.d.ts.map +1 -0
- package/dest/{simulator → providers}/index.js +1 -1
- package/dest/{simulator → providers}/simulation_provider.d.ts.map +1 -1
- package/dest/{simulator → providers}/simulation_provider.js +1 -1
- package/dest/public/abstract_phase_manager.d.ts +43 -42
- package/dest/public/abstract_phase_manager.d.ts.map +1 -1
- package/dest/public/abstract_phase_manager.js +77 -106
- package/dest/public/app_logic_phase_manager.d.ts +6 -7
- package/dest/public/app_logic_phase_manager.d.ts.map +1 -1
- package/dest/public/app_logic_phase_manager.js +14 -14
- package/dest/public/{db.d.ts → db_interfaces.d.ts} +3 -3
- package/dest/public/db_interfaces.d.ts.map +1 -0
- package/dest/public/db_interfaces.js +2 -0
- package/dest/public/execution.d.ts +16 -9
- package/dest/public/execution.d.ts.map +1 -1
- package/dest/public/execution.js +1 -1
- package/dest/public/executor.d.ts +3 -30
- package/dest/public/executor.d.ts.map +1 -1
- package/dest/public/executor.js +32 -282
- package/dest/public/fee_payment.d.ts +11 -0
- package/dest/public/fee_payment.d.ts.map +1 -0
- package/dest/public/fee_payment.js +24 -0
- package/dest/public/hints_builder.d.ts +1 -0
- package/dest/public/hints_builder.d.ts.map +1 -1
- package/dest/public/hints_builder.js +6 -2
- package/dest/public/index.d.ts +4 -2
- package/dest/public/index.d.ts.map +1 -1
- package/dest/public/index.js +5 -3
- package/dest/public/phase_manager_factory.d.ts +1 -1
- package/dest/public/phase_manager_factory.d.ts.map +1 -1
- package/dest/public/{public_executor.d.ts → public_db_sources.d.ts} +3 -2
- package/dest/public/public_db_sources.d.ts.map +1 -0
- package/dest/public/public_db_sources.js +198 -0
- package/dest/public/public_kernel.js +14 -14
- package/dest/public/public_processor.d.ts +6 -4
- package/dest/public/public_processor.d.ts.map +1 -1
- package/dest/public/public_processor.js +46 -27
- package/dest/public/setup_phase_manager.d.ts +6 -8
- package/dest/public/setup_phase_manager.d.ts.map +1 -1
- package/dest/public/setup_phase_manager.js +11 -20
- package/dest/public/tail_phase_manager.d.ts +4 -10
- package/dest/public/tail_phase_manager.d.ts.map +1 -1
- package/dest/public/tail_phase_manager.js +15 -35
- package/dest/public/teardown_phase_manager.d.ts +6 -8
- package/dest/public/teardown_phase_manager.d.ts.map +1 -1
- package/dest/public/teardown_phase_manager.js +15 -21
- package/dest/public/transitional_adaptors.d.ts +1 -1
- package/dest/public/transitional_adaptors.d.ts.map +1 -1
- package/dest/public/transitional_adaptors.js +8 -6
- package/dest/public/utils.d.ts +2 -2
- package/dest/public/utils.d.ts.map +1 -1
- package/dest/public/utils.js +21 -14
- package/package.json +12 -9
- package/src/acvm/acvm.ts +0 -3
- package/src/acvm/oracle/oracle.ts +36 -13
- package/src/acvm/oracle/typed_oracle.ts +12 -3
- package/src/acvm/serialize.ts +1 -1
- package/src/avm/avm_gas.ts +66 -73
- package/src/avm/avm_simulator.ts +9 -0
- package/src/avm/fixtures/index.ts +20 -0
- package/src/avm/index.ts +1 -0
- package/src/avm/journal/host_storage.ts +1 -1
- package/src/avm/journal/journal.ts +6 -1
- package/src/avm/journal/trace.ts +12 -0
- package/src/avm/journal/trace_types.ts +1 -0
- package/src/avm/opcodes/arithmetic.ts +1 -14
- package/src/avm/opcodes/conversion.ts +1 -1
- package/src/avm/opcodes/external_calls.ts +3 -1
- package/src/avm/opcodes/instruction.ts +5 -3
- package/src/avm/opcodes/memory.ts +1 -8
- package/src/avm/opcodes/storage.ts +1 -8
- package/src/avm/serialization/bytecode_serialization.ts +1 -1
- package/src/client/client_execution_context.ts +33 -45
- package/src/client/db_oracle.ts +8 -1
- package/src/client/execution_note_cache.ts +0 -28
- package/src/client/execution_result.ts +21 -7
- package/src/client/private_execution.ts +36 -21
- package/src/client/simulator.ts +7 -27
- package/src/client/unconstrained_execution.ts +9 -12
- package/src/client/view_data_oracle.ts +8 -0
- package/src/index.ts +3 -1
- package/src/mocks/fixtures.ts +30 -32
- package/src/{simulator → providers}/acvm_native.ts +21 -19
- package/src/{simulator → providers}/acvm_wasm.ts +2 -16
- package/src/public/abstract_phase_manager.ts +138 -205
- package/src/public/app_logic_phase_manager.ts +23 -39
- package/src/public/{db.ts → db_interfaces.ts} +2 -2
- package/src/public/execution.ts +15 -8
- package/src/public/executor.ts +51 -398
- package/src/public/fee_payment.ts +26 -0
- package/src/public/hints_builder.ts +6 -0
- package/src/public/index.ts +4 -2
- package/src/public/phase_manager_factory.ts +1 -1
- package/src/public/{public_executor.ts → public_db_sources.ts} +3 -2
- package/src/public/public_kernel.ts +24 -24
- package/src/public/public_processor.ts +77 -33
- package/src/public/setup_phase_manager.ts +20 -45
- package/src/public/tail_phase_manager.ts +17 -65
- package/src/public/teardown_phase_manager.ts +22 -41
- package/src/public/transitional_adaptors.ts +7 -11
- package/src/public/utils.ts +20 -14
- package/dest/public/db.d.ts.map +0 -1
- package/dest/public/db.js +0 -2
- package/dest/public/public_execution_context.d.ts +0 -121
- package/dest/public/public_execution_context.d.ts.map +0 -1
- package/dest/public/public_execution_context.js +0 -214
- package/dest/public/public_executor.d.ts.map +0 -1
- package/dest/public/public_executor.js +0 -197
- package/dest/public/state_actions.d.ts +0 -39
- package/dest/public/state_actions.d.ts.map +0 -1
- package/dest/public/state_actions.js +0 -80
- package/dest/simulator/acvm_wasm.d.ts.map +0 -1
- package/dest/simulator/acvm_wasm.js +0 -22
- package/dest/simulator/index.d.ts.map +0 -1
- package/src/public/public_execution_context.ts +0 -289
- package/src/public/state_actions.ts +0 -102
- /package/dest/{simulator → providers}/acvm_native.d.ts +0 -0
- /package/dest/{simulator → providers}/acvm_wasm.d.ts +0 -0
- /package/dest/{simulator → providers}/index.d.ts +0 -0
- /package/dest/{simulator → providers}/simulation_provider.d.ts +0 -0
- /package/src/{simulator → providers}/index.ts +0 -0
- /package/src/{simulator → providers}/simulation_provider.ts +0 -0
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
type DecodedReturn,
|
|
3
|
+
type FunctionArtifact,
|
|
4
|
+
type FunctionSelector,
|
|
5
|
+
decodeReturnValues,
|
|
6
|
+
} from '@aztec/foundation/abi';
|
|
3
7
|
import { type AztecAddress } from '@aztec/foundation/aztec-address';
|
|
4
8
|
import { type Fr } from '@aztec/foundation/fields';
|
|
5
9
|
import { createDebugLogger } from '@aztec/foundation/log';
|
|
@@ -7,7 +11,6 @@ import { createDebugLogger } from '@aztec/foundation/log';
|
|
|
7
11
|
import { witnessMapToFields } from '../acvm/deserialize.js';
|
|
8
12
|
import { Oracle, acvm, extractCallStack, toACVMWitness } from '../acvm/index.js';
|
|
9
13
|
import { ExecutionError } from '../common/errors.js';
|
|
10
|
-
import { AcirSimulator } from './simulator.js';
|
|
11
14
|
import { type ViewDataOracle } from './view_data_oracle.js';
|
|
12
15
|
|
|
13
16
|
// docs:start:execute_unconstrained_function
|
|
@@ -18,21 +21,15 @@ export async function executeUnconstrainedFunction(
|
|
|
18
21
|
oracle: ViewDataOracle,
|
|
19
22
|
artifact: FunctionArtifact,
|
|
20
23
|
contractAddress: AztecAddress,
|
|
21
|
-
|
|
24
|
+
functionSelector: FunctionSelector,
|
|
22
25
|
args: Fr[],
|
|
23
26
|
log = createDebugLogger('aztec:simulator:unconstrained_execution'),
|
|
24
27
|
): Promise<DecodedReturn> {
|
|
25
|
-
const functionSelector = functionData.selector;
|
|
26
28
|
log.verbose(`Executing unconstrained function ${contractAddress}:${functionSelector}(${artifact.name})`);
|
|
27
29
|
|
|
28
30
|
const acir = artifact.bytecode;
|
|
29
31
|
const initialWitness = toACVMWitness(0, args);
|
|
30
|
-
const acirExecutionResult = await acvm(
|
|
31
|
-
await AcirSimulator.getSolver(),
|
|
32
|
-
acir,
|
|
33
|
-
initialWitness,
|
|
34
|
-
new Oracle(oracle),
|
|
35
|
-
).catch((err: Error) => {
|
|
32
|
+
const acirExecutionResult = await acvm(acir, initialWitness, new Oracle(oracle)).catch((err: Error) => {
|
|
36
33
|
throw new ExecutionError(
|
|
37
34
|
err.message,
|
|
38
35
|
{
|
|
@@ -45,6 +42,6 @@ export async function executeUnconstrainedFunction(
|
|
|
45
42
|
});
|
|
46
43
|
|
|
47
44
|
const returnWitness = witnessMapToFields(acirExecutionResult.returnWitness);
|
|
48
|
-
return decodeReturnValues(artifact, returnWitness);
|
|
45
|
+
return decodeReturnValues(artifact.returnTypes, returnWitness);
|
|
49
46
|
}
|
|
50
47
|
// docs:end:execute_unconstrained_function
|
|
@@ -34,6 +34,14 @@ export class ViewDataOracle extends TypedOracle {
|
|
|
34
34
|
super();
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
public override getBlockNumber(): Promise<number> {
|
|
38
|
+
return this.aztecNode.getBlockNumber();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
public override getContractAddress(): Promise<AztecAddress> {
|
|
42
|
+
return Promise.resolve(this.contractAddress);
|
|
43
|
+
}
|
|
44
|
+
|
|
37
45
|
/**
|
|
38
46
|
* Retrieve keys associated with a specific master public key and app address.
|
|
39
47
|
* @param pkMHash - The master public key hash.
|
package/src/index.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export * from './acvm/index.js';
|
|
2
|
+
export * from './avm/index.js';
|
|
2
3
|
export * from './client/index.js';
|
|
3
4
|
export * from './common/index.js';
|
|
4
5
|
export * from './public/index.js';
|
|
5
|
-
export * from './
|
|
6
|
+
export * from './providers/index.js';
|
|
6
7
|
export * from './mocks/index.js';
|
|
7
8
|
export * from './stats/index.js';
|
|
9
|
+
export * from './utils.js';
|
package/src/mocks/fixtures.ts
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
import { type FunctionCall, type SimulationError, UnencryptedFunctionL2Logs } from '@aztec/circuit-types';
|
|
2
2
|
import {
|
|
3
3
|
ARGS_LENGTH,
|
|
4
|
+
AvmExecutionHints,
|
|
4
5
|
type AztecAddress,
|
|
5
6
|
CallContext,
|
|
6
|
-
|
|
7
|
+
type ContractStorageRead,
|
|
7
8
|
type ContractStorageUpdateRequest,
|
|
8
9
|
Fr,
|
|
9
|
-
FunctionData,
|
|
10
10
|
Gas,
|
|
11
|
-
MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX,
|
|
12
|
-
type PrivateKernelTailCircuitPublicInputs,
|
|
13
11
|
type PublicCallRequest,
|
|
14
12
|
} from '@aztec/circuits.js';
|
|
15
13
|
import { makeAztecAddress, makeSelector } from '@aztec/circuits.js/testing';
|
|
14
|
+
import { FunctionType } from '@aztec/foundation/abi';
|
|
16
15
|
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
17
16
|
|
|
18
17
|
import { type PublicExecution, type PublicExecutionResult } from '../public/execution.js';
|
|
@@ -21,6 +20,7 @@ export class PublicExecutionResultBuilder {
|
|
|
21
20
|
private _execution: PublicExecution;
|
|
22
21
|
private _nestedExecutions: PublicExecutionResult[] = [];
|
|
23
22
|
private _contractStorageUpdateRequests: ContractStorageUpdateRequest[] = [];
|
|
23
|
+
private _contractStorageReads: ContractStorageRead[] = [];
|
|
24
24
|
private _returnValues: Fr[] = [];
|
|
25
25
|
private _reverted = false;
|
|
26
26
|
private _revertReason: SimulationError | undefined = undefined;
|
|
@@ -34,17 +34,25 @@ export class PublicExecutionResultBuilder {
|
|
|
34
34
|
returnValues = [new Fr(1n)],
|
|
35
35
|
nestedExecutions = [],
|
|
36
36
|
contractStorageUpdateRequests = [],
|
|
37
|
+
contractStorageReads = [],
|
|
38
|
+
revertReason = undefined,
|
|
37
39
|
}: {
|
|
38
40
|
request: PublicCallRequest;
|
|
39
41
|
returnValues?: Fr[];
|
|
40
42
|
nestedExecutions?: PublicExecutionResult[];
|
|
41
43
|
contractStorageUpdateRequests?: ContractStorageUpdateRequest[];
|
|
44
|
+
contractStorageReads?: ContractStorageRead[];
|
|
45
|
+
revertReason?: SimulationError;
|
|
42
46
|
}): PublicExecutionResultBuilder {
|
|
43
47
|
const builder = new PublicExecutionResultBuilder(request);
|
|
44
48
|
|
|
45
49
|
builder.withNestedExecutions(...nestedExecutions);
|
|
46
50
|
builder.withContractStorageUpdateRequest(...contractStorageUpdateRequests);
|
|
51
|
+
builder.withContractStorageRead(...contractStorageReads);
|
|
47
52
|
builder.withReturnValues(...returnValues);
|
|
53
|
+
if (revertReason) {
|
|
54
|
+
builder.withReverted(revertReason);
|
|
55
|
+
}
|
|
48
56
|
|
|
49
57
|
return builder;
|
|
50
58
|
}
|
|
@@ -55,6 +63,7 @@ export class PublicExecutionResultBuilder {
|
|
|
55
63
|
returnValues = [new Fr(1n)],
|
|
56
64
|
nestedExecutions = [],
|
|
57
65
|
contractStorageUpdateRequests = [],
|
|
66
|
+
contractStorageReads = [],
|
|
58
67
|
revertReason,
|
|
59
68
|
}: {
|
|
60
69
|
from: AztecAddress;
|
|
@@ -62,17 +71,19 @@ export class PublicExecutionResultBuilder {
|
|
|
62
71
|
returnValues?: Fr[];
|
|
63
72
|
nestedExecutions?: PublicExecutionResult[];
|
|
64
73
|
contractStorageUpdateRequests?: ContractStorageUpdateRequest[];
|
|
74
|
+
contractStorageReads?: ContractStorageRead[];
|
|
65
75
|
revertReason?: SimulationError;
|
|
66
76
|
}) {
|
|
67
77
|
const builder = new PublicExecutionResultBuilder({
|
|
68
|
-
callContext: new CallContext(from, tx.to, tx.
|
|
78
|
+
callContext: new CallContext(from, tx.to, tx.selector, false, false, 0),
|
|
69
79
|
contractAddress: tx.to,
|
|
70
|
-
|
|
80
|
+
functionSelector: tx.selector,
|
|
71
81
|
args: tx.args,
|
|
72
82
|
});
|
|
73
83
|
|
|
74
84
|
builder.withNestedExecutions(...nestedExecutions);
|
|
75
85
|
builder.withContractStorageUpdateRequest(...contractStorageUpdateRequests);
|
|
86
|
+
builder.withContractStorageRead(...contractStorageReads);
|
|
76
87
|
builder.withReturnValues(...returnValues);
|
|
77
88
|
if (revertReason) {
|
|
78
89
|
builder.withReverted(revertReason);
|
|
@@ -91,6 +102,11 @@ export class PublicExecutionResultBuilder {
|
|
|
91
102
|
return this;
|
|
92
103
|
}
|
|
93
104
|
|
|
105
|
+
withContractStorageRead(...reads: ContractStorageRead[]): PublicExecutionResultBuilder {
|
|
106
|
+
this._contractStorageReads.push(...reads);
|
|
107
|
+
return this;
|
|
108
|
+
}
|
|
109
|
+
|
|
94
110
|
withReturnValues(...values: Fr[]): PublicExecutionResultBuilder {
|
|
95
111
|
this._returnValues.push(...values);
|
|
96
112
|
return this;
|
|
@@ -106,8 +122,10 @@ export class PublicExecutionResultBuilder {
|
|
|
106
122
|
return {
|
|
107
123
|
execution: this._execution,
|
|
108
124
|
nestedExecutions: this._nestedExecutions,
|
|
125
|
+
noteHashReadRequests: [],
|
|
109
126
|
nullifierReadRequests: [],
|
|
110
127
|
nullifierNonExistentReadRequests: [],
|
|
128
|
+
l1ToL2MsgReadRequests: [],
|
|
111
129
|
contractStorageUpdateRequests: this._contractStorageUpdateRequests,
|
|
112
130
|
returnValues: padArrayEnd(this._returnValues, Fr.ZERO, 4), // TODO(#5450) Need to use the proper return values here
|
|
113
131
|
newNoteHashes: [],
|
|
@@ -124,39 +142,19 @@ export class PublicExecutionResultBuilder {
|
|
|
124
142
|
startGasLeft: Gas.test(),
|
|
125
143
|
endGasLeft: Gas.test(),
|
|
126
144
|
transactionFee: Fr.ZERO,
|
|
145
|
+
calldata: [],
|
|
146
|
+
avmHints: AvmExecutionHints.empty(),
|
|
127
147
|
...overrides,
|
|
128
148
|
};
|
|
129
149
|
}
|
|
130
150
|
}
|
|
131
151
|
|
|
132
152
|
export const makeFunctionCall = (
|
|
153
|
+
name = 'function',
|
|
133
154
|
to = makeAztecAddress(30),
|
|
134
155
|
selector = makeSelector(5),
|
|
156
|
+
type = FunctionType.PUBLIC,
|
|
135
157
|
args = new Array(ARGS_LENGTH).fill(Fr.ZERO),
|
|
136
158
|
isStatic = false,
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
export function addKernelPublicCallStack(
|
|
140
|
-
kernelOutput: PrivateKernelTailCircuitPublicInputs,
|
|
141
|
-
calls: {
|
|
142
|
-
setupCalls: PublicCallRequest[];
|
|
143
|
-
appLogicCalls: PublicCallRequest[];
|
|
144
|
-
teardownCall: PublicCallRequest;
|
|
145
|
-
},
|
|
146
|
-
) {
|
|
147
|
-
// the first two calls are non-revertible
|
|
148
|
-
// the first is for setup, the second is for teardown
|
|
149
|
-
kernelOutput.forPublic!.endNonRevertibleData.publicCallStack = padArrayEnd(
|
|
150
|
-
// this is a stack, so the first item is the last call
|
|
151
|
-
// and callRequests is in the order of the calls
|
|
152
|
-
[calls.teardownCall.toCallRequest(), ...calls.setupCalls.map(c => c.toCallRequest())],
|
|
153
|
-
CallRequest.empty(),
|
|
154
|
-
MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX,
|
|
155
|
-
);
|
|
156
|
-
|
|
157
|
-
kernelOutput.forPublic!.end.publicCallStack = padArrayEnd(
|
|
158
|
-
calls.appLogicCalls.map(c => c.toCallRequest()),
|
|
159
|
-
CallRequest.empty(),
|
|
160
|
-
MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX,
|
|
161
|
-
);
|
|
162
|
-
}
|
|
159
|
+
returnTypes = [],
|
|
160
|
+
) => ({ name, to, selector, type, args, isStatic, returnTypes });
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { runInDirectory } from '@aztec/foundation/fs';
|
|
2
2
|
import { createDebugLogger } from '@aztec/foundation/log';
|
|
3
3
|
import { Timer } from '@aztec/foundation/timer';
|
|
4
4
|
import { type NoirCompiledCircuit } from '@aztec/types/noir';
|
|
@@ -137,23 +137,25 @@ export class NativeACVMSimulator implements SimulationProvider {
|
|
|
137
137
|
async simulateCircuit(input: WitnessMap, compiledCircuit: NoirCompiledCircuit): Promise<WitnessMap> {
|
|
138
138
|
// Execute the circuit on those initial witness values
|
|
139
139
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
140
|
+
const operation = async (directory: string) => {
|
|
141
|
+
// Decode the bytecode from base64 since the acvm does not know about base64 encoding
|
|
142
|
+
const decodedBytecode = Buffer.from(compiledCircuit.bytecode, 'base64');
|
|
143
|
+
// Execute the circuit
|
|
144
|
+
const result = await executeNativeCircuit(
|
|
145
|
+
input,
|
|
146
|
+
decodedBytecode,
|
|
147
|
+
directory,
|
|
148
|
+
this.pathToAcvm,
|
|
149
|
+
this.witnessFilename,
|
|
150
|
+
);
|
|
151
|
+
|
|
152
|
+
if (result.status == ACVM_RESULT.FAILURE) {
|
|
153
|
+
throw new Error(`Failed to generate witness: ${result.reason}`);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
return result.witness;
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
return await runInDirectory(this.workingDirectory, operation);
|
|
158
160
|
}
|
|
159
161
|
}
|
|
@@ -1,24 +1,11 @@
|
|
|
1
1
|
import { foreignCallHandler } from '@aztec/noir-protocol-circuits-types';
|
|
2
2
|
import { type NoirCompiledCircuit } from '@aztec/types/noir';
|
|
3
3
|
|
|
4
|
-
import {
|
|
5
|
-
type WasmBlackBoxFunctionSolver,
|
|
6
|
-
createBlackBoxSolver,
|
|
7
|
-
executeCircuitWithBlackBoxSolver,
|
|
8
|
-
} from '@noir-lang/acvm_js';
|
|
4
|
+
import { executeCircuit } from '@noir-lang/acvm_js';
|
|
9
5
|
import { type WitnessMap } from '@noir-lang/types';
|
|
10
6
|
|
|
11
7
|
import { type SimulationProvider } from './simulation_provider.js';
|
|
12
8
|
|
|
13
|
-
let solver: Promise<WasmBlackBoxFunctionSolver>;
|
|
14
|
-
|
|
15
|
-
const getSolver = (): Promise<WasmBlackBoxFunctionSolver> => {
|
|
16
|
-
if (!solver) {
|
|
17
|
-
solver = createBlackBoxSolver();
|
|
18
|
-
}
|
|
19
|
-
return solver;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
9
|
export class WASMSimulator implements SimulationProvider {
|
|
23
10
|
async simulateCircuit(input: WitnessMap, compiledCircuit: NoirCompiledCircuit): Promise<WitnessMap> {
|
|
24
11
|
// Execute the circuit on those initial witness values
|
|
@@ -27,8 +14,7 @@ export class WASMSimulator implements SimulationProvider {
|
|
|
27
14
|
const decodedBytecode = Buffer.from(compiledCircuit.bytecode, 'base64');
|
|
28
15
|
//
|
|
29
16
|
// Execute the circuit
|
|
30
|
-
const _witnessMap = await
|
|
31
|
-
await getSolver(),
|
|
17
|
+
const _witnessMap = await executeCircuit(
|
|
32
18
|
decodedBytecode,
|
|
33
19
|
input,
|
|
34
20
|
foreignCallHandler, // handle calls to debug_log
|