@aztec/simulator 0.59.0 → 0.61.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 +1 -0
- package/dest/acvm/acvm.d.ts.map +1 -1
- package/dest/acvm/oracle/oracle.d.ts +5 -3
- package/dest/acvm/oracle/oracle.d.ts.map +1 -1
- package/dest/acvm/oracle/oracle.js +15 -7
- package/dest/acvm/oracle/typed_oracle.d.ts +7 -4
- package/dest/acvm/oracle/typed_oracle.d.ts.map +1 -1
- package/dest/acvm/oracle/typed_oracle.js +10 -4
- package/dest/acvm/serialize.d.ts +1 -0
- package/dest/acvm/serialize.d.ts.map +1 -1
- package/dest/avm/avm_context.d.ts +1 -1
- package/dest/avm/avm_context.js +1 -1
- package/dest/avm/avm_execution_environment.d.ts +2 -5
- package/dest/avm/avm_execution_environment.d.ts.map +1 -1
- package/dest/avm/avm_execution_environment.js +7 -15
- package/dest/avm/avm_gas.d.ts.map +1 -1
- package/dest/avm/avm_gas.js +6 -10
- package/dest/avm/avm_machine_state.d.ts +2 -0
- package/dest/avm/avm_machine_state.d.ts.map +1 -1
- package/dest/avm/avm_machine_state.js +3 -1
- package/dest/avm/avm_memory_types.d.ts +1 -0
- package/dest/avm/avm_memory_types.d.ts.map +1 -1
- package/dest/avm/avm_simulator.d.ts +16 -0
- package/dest/avm/avm_simulator.d.ts.map +1 -1
- package/dest/avm/avm_simulator.js +45 -4
- package/dest/avm/bytecode_utils.d.ts +1 -0
- package/dest/avm/bytecode_utils.d.ts.map +1 -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 +8 -2
- package/dest/avm/journal/journal.d.ts +19 -19
- package/dest/avm/journal/journal.d.ts.map +1 -1
- package/dest/avm/journal/journal.js +73 -48
- package/dest/avm/journal/nullifiers.d.ts +9 -9
- package/dest/avm/journal/nullifiers.d.ts.map +1 -1
- package/dest/avm/journal/nullifiers.js +24 -24
- package/dest/avm/journal/public_storage.d.ts +10 -10
- package/dest/avm/journal/public_storage.d.ts.map +1 -1
- package/dest/avm/journal/public_storage.js +21 -21
- package/dest/avm/opcodes/accrued_substate.d.ts.map +1 -1
- package/dest/avm/opcodes/accrued_substate.js +5 -5
- package/dest/avm/opcodes/contract.d.ts +8 -1
- package/dest/avm/opcodes/contract.d.ts.map +1 -1
- package/dest/avm/opcodes/contract.js +41 -21
- package/dest/avm/opcodes/conversion.d.ts +1 -1
- package/dest/avm/opcodes/conversion.d.ts.map +1 -1
- package/dest/avm/opcodes/conversion.js +12 -9
- package/dest/avm/opcodes/environment_getters.d.ts +13 -14
- package/dest/avm/opcodes/environment_getters.d.ts.map +1 -1
- package/dest/avm/opcodes/environment_getters.js +17 -16
- package/dest/avm/opcodes/external_calls.d.ts +3 -6
- package/dest/avm/opcodes/external_calls.d.ts.map +1 -1
- package/dest/avm/opcodes/external_calls.js +23 -43
- package/dest/avm/opcodes/hashing.d.ts +2 -26
- package/dest/avm/opcodes/hashing.d.ts.map +1 -1
- package/dest/avm/opcodes/hashing.js +11 -95
- package/dest/avm/opcodes/index.d.ts +0 -1
- package/dest/avm/opcodes/index.d.ts.map +1 -1
- package/dest/avm/opcodes/index.js +1 -2
- package/dest/avm/opcodes/instruction.d.ts +1 -0
- package/dest/avm/opcodes/instruction.d.ts.map +1 -1
- package/dest/avm/opcodes/memory.d.ts +20 -0
- package/dest/avm/opcodes/memory.d.ts.map +1 -1
- package/dest/avm/opcodes/memory.js +59 -3
- package/dest/avm/opcodes/storage.js +3 -3
- package/dest/avm/serialization/buffer_cursor.d.ts +1 -0
- package/dest/avm/serialization/buffer_cursor.d.ts.map +1 -1
- package/dest/avm/serialization/bytecode_serialization.d.ts +1 -0
- package/dest/avm/serialization/bytecode_serialization.d.ts.map +1 -1
- package/dest/avm/serialization/bytecode_serialization.js +5 -7
- package/dest/avm/serialization/instruction_serialization.d.ts +34 -35
- package/dest/avm/serialization/instruction_serialization.d.ts.map +1 -1
- package/dest/avm/serialization/instruction_serialization.js +34 -36
- package/dest/avm/test_utils.d.ts +3 -1
- package/dest/avm/test_utils.d.ts.map +1 -1
- package/dest/avm/test_utils.js +4 -1
- package/dest/client/client_execution_context.d.ts +9 -18
- package/dest/client/client_execution_context.d.ts.map +1 -1
- package/dest/client/client_execution_context.js +30 -50
- package/dest/client/db_oracle.d.ts +17 -1
- package/dest/client/db_oracle.d.ts.map +1 -1
- package/dest/client/db_oracle.js +1 -1
- package/dest/client/private_execution.d.ts.map +1 -1
- package/dest/client/private_execution.js +3 -4
- package/dest/client/simulator.d.ts.map +1 -1
- package/dest/client/simulator.js +3 -3
- package/dest/client/view_data_oracle.d.ts +17 -1
- package/dest/client/view_data_oracle.d.ts.map +1 -1
- package/dest/client/view_data_oracle.js +21 -1
- package/dest/common/index.d.ts +0 -1
- package/dest/common/index.d.ts.map +1 -1
- package/dest/common/index.js +1 -2
- package/dest/mocks/fixtures.js +2 -2
- package/dest/providers/acvm_native.d.ts +1 -0
- package/dest/providers/acvm_native.d.ts.map +1 -1
- package/dest/public/db_interfaces.d.ts +1 -0
- package/dest/public/db_interfaces.d.ts.map +1 -1
- package/dest/public/dual_side_effect_trace.d.ts +10 -11
- package/dest/public/dual_side_effect_trace.d.ts.map +1 -1
- package/dest/public/dual_side_effect_trace.js +26 -22
- package/dest/public/enqueued_call_side_effect_trace.d.ts +11 -12
- package/dest/public/enqueued_call_side_effect_trace.d.ts.map +1 -1
- package/dest/public/enqueued_call_side_effect_trace.js +33 -23
- package/dest/public/enqueued_call_simulator.d.ts +3 -3
- package/dest/public/enqueued_call_simulator.d.ts.map +1 -1
- package/dest/public/enqueued_call_simulator.js +30 -39
- package/dest/public/enqueued_calls_processor.d.ts +2 -3
- package/dest/public/enqueued_calls_processor.d.ts.map +1 -1
- package/dest/public/enqueued_calls_processor.js +19 -26
- package/dest/public/execution.d.ts +1 -0
- package/dest/public/execution.d.ts.map +1 -1
- package/dest/public/execution.js +2 -2
- package/dest/public/executor.d.ts.map +1 -1
- package/dest/public/executor.js +6 -5
- package/dest/public/public_db_sources.d.ts +1 -0
- package/dest/public/public_db_sources.d.ts.map +1 -1
- package/dest/public/public_kernel.d.ts +0 -1
- package/dest/public/public_kernel.d.ts.map +1 -1
- package/dest/public/public_kernel.js +5 -8
- package/dest/public/public_kernel_tail_simulator.d.ts +1 -5
- package/dest/public/public_kernel_tail_simulator.d.ts.map +1 -1
- package/dest/public/public_kernel_tail_simulator.js +6 -12
- package/dest/public/public_processor.js +4 -4
- package/dest/public/side_effect_trace.d.ts +11 -9
- package/dest/public/side_effect_trace.d.ts.map +1 -1
- package/dest/public/side_effect_trace.js +40 -30
- package/dest/public/side_effect_trace_interface.d.ts +10 -9
- package/dest/public/side_effect_trace_interface.d.ts.map +1 -1
- package/package.json +9 -9
- package/src/acvm/oracle/oracle.ts +13 -6
- package/src/acvm/oracle/typed_oracle.ts +9 -3
- package/src/avm/avm_context.ts +1 -1
- package/src/avm/avm_execution_environment.ts +0 -15
- package/src/avm/avm_gas.ts +5 -9
- package/src/avm/avm_machine_state.ts +2 -0
- package/src/avm/avm_simulator.ts +69 -6
- package/src/avm/fixtures/index.ts +7 -2
- package/src/avm/journal/journal.ts +93 -50
- package/src/avm/journal/nullifiers.ts +23 -23
- package/src/avm/journal/public_storage.ts +20 -20
- package/src/avm/opcodes/accrued_substate.ts +4 -8
- package/src/avm/opcodes/contract.ts +45 -21
- package/src/avm/opcodes/conversion.ts +9 -6
- package/src/avm/opcodes/environment_getters.ts +7 -5
- package/src/avm/opcodes/external_calls.ts +21 -45
- package/src/avm/opcodes/hashing.ts +9 -122
- package/src/avm/opcodes/index.ts +0 -1
- package/src/avm/opcodes/memory.ts +69 -2
- package/src/avm/opcodes/storage.ts +2 -2
- package/src/avm/serialization/bytecode_serialization.ts +6 -9
- package/src/avm/serialization/instruction_serialization.ts +3 -5
- package/src/avm/test_utils.ts +5 -1
- package/src/client/client_execution_context.ts +21 -71
- package/src/client/db_oracle.ts +26 -0
- package/src/client/private_execution.ts +1 -9
- package/src/client/simulator.ts +0 -2
- package/src/client/view_data_oracle.ts +31 -1
- package/src/common/index.ts +0 -1
- package/src/mocks/fixtures.ts +1 -1
- package/src/public/dual_side_effect_trace.ts +38 -24
- package/src/public/enqueued_call_side_effect_trace.ts +60 -28
- package/src/public/enqueued_call_simulator.ts +52 -49
- package/src/public/enqueued_calls_processor.ts +27 -41
- package/src/public/execution.ts +1 -1
- package/src/public/executor.ts +11 -5
- package/src/public/public_kernel.ts +9 -12
- package/src/public/public_kernel_tail_simulator.ts +6 -15
- package/src/public/public_processor.ts +3 -3
- package/src/public/side_effect_trace.ts +73 -29
- package/src/public/side_effect_trace_interface.ts +15 -10
- package/dest/avm/opcodes/commitment.d.ts +0 -16
- package/dest/avm/opcodes/commitment.d.ts.map +0 -1
- package/dest/avm/opcodes/commitment.js +0 -51
- package/dest/client/test_utils.d.ts +0 -9
- package/dest/client/test_utils.d.ts.map +0 -1
- package/dest/client/test_utils.js +0 -27
- package/dest/common/side_effect_counter.d.ts +0 -10
- package/dest/common/side_effect_counter.d.ts.map +0 -1
- package/dest/common/side_effect_counter.js +0 -18
- package/dest/rollup/index.d.ts +0 -2
- package/dest/rollup/index.d.ts.map +0 -1
- package/dest/rollup/index.js +0 -2
- package/dest/rollup/rollup.d.ts +0 -101
- package/dest/rollup/rollup.d.ts.map +0 -1
- package/dest/rollup/rollup.js +0 -100
- package/src/avm/opcodes/commitment.ts +0 -65
- package/src/client/test_utils.ts +0 -57
- package/src/common/side_effect_counter.ts +0 -17
- package/src/rollup/index.ts +0 -1
- package/src/rollup/rollup.ts +0 -228
package/src/public/execution.ts
CHANGED
|
@@ -139,7 +139,7 @@ export function checkValidStaticCall(
|
|
|
139
139
|
export function resultToPublicCallRequest(result: PublicExecutionResult) {
|
|
140
140
|
const request = result.executionRequest;
|
|
141
141
|
const item = new PublicCallStackItemCompressed(
|
|
142
|
-
request.contractAddress,
|
|
142
|
+
request.callContext.contractAddress,
|
|
143
143
|
request.callContext,
|
|
144
144
|
computeVarArgsHash(request.args),
|
|
145
145
|
computeVarArgsHash(result.returnValues),
|
package/src/public/executor.ts
CHANGED
|
@@ -63,11 +63,13 @@ export class PublicExecutor {
|
|
|
63
63
|
previousValidationRequestArrayLengths: PublicValidationRequestArrayLengths = PublicValidationRequestArrayLengths.empty(),
|
|
64
64
|
previousAccumulatedDataArrayLengths: PublicAccumulatedDataArrayLengths = PublicAccumulatedDataArrayLengths.empty(),
|
|
65
65
|
): Promise<PublicExecutionResult> {
|
|
66
|
-
const address = executionRequest.contractAddress;
|
|
66
|
+
const address = executionRequest.callContext.contractAddress;
|
|
67
67
|
const selector = executionRequest.callContext.functionSelector;
|
|
68
68
|
const fnName = await getPublicFunctionDebugName(this.worldStateDB, address, selector, executionRequest.args);
|
|
69
69
|
|
|
70
|
-
PublicExecutor.log.verbose(
|
|
70
|
+
PublicExecutor.log.verbose(
|
|
71
|
+
`[AVM] Executing public external function ${fnName}@${address} with ${allocatedGas.l2Gas} allocated L2 gas.`,
|
|
72
|
+
);
|
|
71
73
|
const timer = new Timer();
|
|
72
74
|
|
|
73
75
|
const innerCallTrace = new PublicSideEffectTrace(startSideEffectCounter);
|
|
@@ -132,6 +134,12 @@ export class PublicExecutor {
|
|
|
132
134
|
avmResult,
|
|
133
135
|
);
|
|
134
136
|
|
|
137
|
+
PublicExecutor.log.verbose(
|
|
138
|
+
`[AVM] ${fnName} simulation complete. Reverted=${avmResult.reverted}. Consumed ${
|
|
139
|
+
allocatedGas.l2Gas - avmContext.machineState.gasLeft.l2Gas
|
|
140
|
+
} L2 gas, ending with ${avmContext.machineState.gasLeft.l2Gas} L2 gas left.`,
|
|
141
|
+
);
|
|
142
|
+
|
|
135
143
|
return publicExecutionResult;
|
|
136
144
|
}
|
|
137
145
|
}
|
|
@@ -149,15 +157,13 @@ function createAvmExecutionEnvironment(
|
|
|
149
157
|
transactionFee: Fr,
|
|
150
158
|
): AvmExecutionEnvironment {
|
|
151
159
|
return new AvmExecutionEnvironment(
|
|
152
|
-
executionRequest.contractAddress,
|
|
153
|
-
executionRequest.callContext.storageContractAddress,
|
|
160
|
+
executionRequest.callContext.contractAddress,
|
|
154
161
|
executionRequest.callContext.msgSender,
|
|
155
162
|
executionRequest.callContext.functionSelector,
|
|
156
163
|
/*contractCallDepth=*/ Fr.zero(),
|
|
157
164
|
transactionFee,
|
|
158
165
|
globalVariables,
|
|
159
166
|
executionRequest.callContext.isStaticCall,
|
|
160
|
-
executionRequest.callContext.isDelegateCall,
|
|
161
167
|
executionRequest.args,
|
|
162
168
|
);
|
|
163
169
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { type CircuitSimulationStats } from '@aztec/circuit-types/stats';
|
|
2
1
|
import {
|
|
3
2
|
type KernelCircuitPublicInputs,
|
|
4
3
|
type PublicKernelCircuitPrivateInputs,
|
|
@@ -10,7 +9,9 @@ import {
|
|
|
10
9
|
import { createDebugLogger } from '@aztec/foundation/log';
|
|
11
10
|
import { elapsed } from '@aztec/foundation/timer';
|
|
12
11
|
import {
|
|
13
|
-
|
|
12
|
+
SimulatedPublicKernelInnerArtifact,
|
|
13
|
+
SimulatedPublicKernelMergeArtifact,
|
|
14
|
+
SimulatedPublicKernelTailArtifact,
|
|
14
15
|
convertSimulatedPublicInnerInputsToWitnessMap,
|
|
15
16
|
convertSimulatedPublicInnerOutputFromWitnessMap,
|
|
16
17
|
convertSimulatedPublicMergeInputsToWitnessMap,
|
|
@@ -19,7 +20,6 @@ import {
|
|
|
19
20
|
convertSimulatedPublicTailOutputFromWitnessMap,
|
|
20
21
|
} from '@aztec/noir-protocol-circuits-types';
|
|
21
22
|
|
|
22
|
-
import { WASMSimulator } from '../providers/acvm_wasm.js';
|
|
23
23
|
import { type SimulationProvider } from '../providers/simulation_provider.js';
|
|
24
24
|
import { type PublicKernelCircuitSimulator } from './public_kernel_circuit_simulator.js';
|
|
25
25
|
|
|
@@ -29,9 +29,6 @@ import { type PublicKernelCircuitSimulator } from './public_kernel_circuit_simul
|
|
|
29
29
|
export class RealPublicKernelCircuitSimulator implements PublicKernelCircuitSimulator {
|
|
30
30
|
private log = createDebugLogger('aztec:public-kernel-simulator');
|
|
31
31
|
|
|
32
|
-
// Some circuits are so small it is faster to use WASM
|
|
33
|
-
private wasmSimulator: WASMSimulator = new WASMSimulator();
|
|
34
|
-
|
|
35
32
|
constructor(private simulator: SimulationProvider) {}
|
|
36
33
|
|
|
37
34
|
/**
|
|
@@ -42,7 +39,7 @@ export class RealPublicKernelCircuitSimulator implements PublicKernelCircuitSimu
|
|
|
42
39
|
public async publicKernelCircuitInner(input: PublicKernelInnerCircuitPrivateInputs): Promise<VMCircuitPublicInputs> {
|
|
43
40
|
const inputWitness = convertSimulatedPublicInnerInputsToWitnessMap(input);
|
|
44
41
|
const [duration, witness] = await elapsed(() =>
|
|
45
|
-
this.
|
|
42
|
+
this.simulator.simulateCircuit(inputWitness, SimulatedPublicKernelInnerArtifact),
|
|
46
43
|
);
|
|
47
44
|
const result = convertSimulatedPublicInnerOutputFromWitnessMap(witness);
|
|
48
45
|
this.log.debug(`Simulated public kernel inner circuit`, {
|
|
@@ -51,7 +48,7 @@ export class RealPublicKernelCircuitSimulator implements PublicKernelCircuitSimu
|
|
|
51
48
|
duration,
|
|
52
49
|
inputSize: input.toBuffer().length,
|
|
53
50
|
outputSize: result.toBuffer().length,
|
|
54
|
-
}
|
|
51
|
+
});
|
|
55
52
|
return result;
|
|
56
53
|
}
|
|
57
54
|
|
|
@@ -65,7 +62,7 @@ export class RealPublicKernelCircuitSimulator implements PublicKernelCircuitSimu
|
|
|
65
62
|
): Promise<PublicKernelCircuitPublicInputs> {
|
|
66
63
|
const inputWitness = convertSimulatedPublicMergeInputsToWitnessMap(input);
|
|
67
64
|
const [duration, witness] = await elapsed(() =>
|
|
68
|
-
this.
|
|
65
|
+
this.simulator.simulateCircuit(inputWitness, SimulatedPublicKernelMergeArtifact),
|
|
69
66
|
);
|
|
70
67
|
const result = convertSimulatedPublicMergeOutputFromWitnessMap(witness);
|
|
71
68
|
this.log.debug(`Simulated public kernel merge circuit`, {
|
|
@@ -74,7 +71,7 @@ export class RealPublicKernelCircuitSimulator implements PublicKernelCircuitSimu
|
|
|
74
71
|
duration,
|
|
75
72
|
inputSize: input.toBuffer().length,
|
|
76
73
|
outputSize: result.toBuffer().length,
|
|
77
|
-
}
|
|
74
|
+
});
|
|
78
75
|
return result;
|
|
79
76
|
}
|
|
80
77
|
|
|
@@ -88,7 +85,7 @@ export class RealPublicKernelCircuitSimulator implements PublicKernelCircuitSimu
|
|
|
88
85
|
): Promise<KernelCircuitPublicInputs> {
|
|
89
86
|
const inputWitness = convertSimulatedPublicTailInputsToWitnessMap(input);
|
|
90
87
|
const [duration, witness] = await elapsed(() =>
|
|
91
|
-
this.
|
|
88
|
+
this.simulator.simulateCircuit(inputWitness, SimulatedPublicKernelTailArtifact),
|
|
92
89
|
);
|
|
93
90
|
const result = convertSimulatedPublicTailOutputFromWitnessMap(witness);
|
|
94
91
|
this.log.debug(`Simulated public kernel tail circuit`, {
|
|
@@ -97,7 +94,7 @@ export class RealPublicKernelCircuitSimulator implements PublicKernelCircuitSimu
|
|
|
97
94
|
duration,
|
|
98
95
|
inputSize: input.toBuffer().length,
|
|
99
96
|
outputSize: result.toBuffer().length,
|
|
100
|
-
}
|
|
97
|
+
});
|
|
101
98
|
return result;
|
|
102
99
|
}
|
|
103
100
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { ProvingRequestType, type PublicKernelTailRequest } from '@aztec/circuit-types';
|
|
2
1
|
import {
|
|
3
2
|
type KernelCircuitPublicInputs,
|
|
4
3
|
MAX_NULLIFIERS_PER_TX,
|
|
@@ -7,10 +6,11 @@ import {
|
|
|
7
6
|
type PublicKernelCircuitPublicInputs,
|
|
8
7
|
PublicKernelData,
|
|
9
8
|
PublicKernelTailCircuitPrivateInputs,
|
|
9
|
+
VerificationKeyData,
|
|
10
10
|
makeEmptyRecursiveProof,
|
|
11
11
|
mergeAccumulatedData,
|
|
12
12
|
} from '@aztec/circuits.js';
|
|
13
|
-
import {
|
|
13
|
+
import { getVKSiblingPath } from '@aztec/noir-protocol-circuits-types';
|
|
14
14
|
import { type MerkleTreeReadOperations } from '@aztec/world-state';
|
|
15
15
|
|
|
16
16
|
import { HintsBuilder } from './hints_builder.js';
|
|
@@ -28,19 +28,10 @@ export class PublicKernelTailSimulator {
|
|
|
28
28
|
return new PublicKernelTailSimulator(db, publicKernelSimulator, hintsBuilder);
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
async simulate(
|
|
32
|
-
previousOutput: PublicKernelCircuitPublicInputs,
|
|
33
|
-
): Promise<{ output: KernelCircuitPublicInputs; provingRequest: PublicKernelTailRequest }> {
|
|
31
|
+
async simulate(previousOutput: PublicKernelCircuitPublicInputs): Promise<KernelCircuitPublicInputs> {
|
|
34
32
|
const inputs = await this.buildPrivateInputs(previousOutput);
|
|
35
33
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const provingRequest: PublicKernelTailRequest = {
|
|
39
|
-
type: ProvingRequestType.PUBLIC_KERNEL_TAIL,
|
|
40
|
-
inputs,
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
return { output, provingRequest };
|
|
34
|
+
return await this.publicKernelSimulator.publicKernelCircuitTail(inputs);
|
|
44
35
|
}
|
|
45
36
|
|
|
46
37
|
private async buildPrivateInputs(previousOutput: PublicKernelCircuitPublicInputs) {
|
|
@@ -98,8 +89,8 @@ export class PublicKernelTailSimulator {
|
|
|
98
89
|
|
|
99
90
|
private getPreviousKernelData(previousOutput: PublicKernelCircuitPublicInputs): PublicKernelData {
|
|
100
91
|
const proof = makeEmptyRecursiveProof(NESTED_RECURSIVE_PROOF_LENGTH);
|
|
101
|
-
const vk =
|
|
102
|
-
const vkIndex =
|
|
92
|
+
const vk = VerificationKeyData.makeFakeHonk();
|
|
93
|
+
const vkIndex = 0;
|
|
103
94
|
const siblingPath = getVKSiblingPath(vkIndex);
|
|
104
95
|
return new PublicKernelData(previousOutput, proof, vk, vkIndex, siblingPath);
|
|
105
96
|
}
|
|
@@ -152,7 +152,7 @@ export class PublicProcessor {
|
|
|
152
152
|
}
|
|
153
153
|
try {
|
|
154
154
|
const [processedTx, returnValues] = !tx.hasPublicCalls()
|
|
155
|
-
? [makeProcessedTx(tx, tx.data.toKernelCircuitPublicInputs()
|
|
155
|
+
? [makeProcessedTx(tx, tx.data.toKernelCircuitPublicInputs())]
|
|
156
156
|
: await this.processTxWithPublicCalls(tx);
|
|
157
157
|
this.log.debug(`Processed tx`, {
|
|
158
158
|
txHash: processedTx.hash,
|
|
@@ -253,7 +253,7 @@ export class PublicProcessor {
|
|
|
253
253
|
private async processTxWithPublicCalls(tx: Tx): Promise<[ProcessedTx, NestedProcessReturnValues[]]> {
|
|
254
254
|
const timer = new Timer();
|
|
255
255
|
|
|
256
|
-
const { tailKernelOutput, returnValues, revertReason,
|
|
256
|
+
const { avmProvingRequest, tailKernelOutput, returnValues, revertReason, gasUsed, processedPhases } =
|
|
257
257
|
await this.enqueuedCallsProcessor.process(tx);
|
|
258
258
|
|
|
259
259
|
if (!tailKernelOutput) {
|
|
@@ -279,7 +279,7 @@ export class PublicProcessor {
|
|
|
279
279
|
const phaseCount = processedPhases.length;
|
|
280
280
|
this.metrics.recordTx(phaseCount, timer.ms());
|
|
281
281
|
|
|
282
|
-
const processedTx = makeProcessedTx(tx, tailKernelOutput,
|
|
282
|
+
const processedTx = makeProcessedTx(tx, tailKernelOutput, { avmProvingRequest, revertReason, gasUsed });
|
|
283
283
|
return [processedTx, returnValues];
|
|
284
284
|
}
|
|
285
285
|
}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { PublicExecutionRequest, UnencryptedFunctionL2Logs, UnencryptedL2Log } from '@aztec/circuit-types';
|
|
2
2
|
import {
|
|
3
|
+
AvmContractBytecodeHints,
|
|
3
4
|
AvmContractInstanceHint,
|
|
4
5
|
AvmExecutionHints,
|
|
5
6
|
AvmExternalCallHint,
|
|
6
7
|
AvmKeyValueHint,
|
|
7
8
|
AztecAddress,
|
|
8
9
|
CallContext,
|
|
10
|
+
type ContractClassIdPreimage,
|
|
9
11
|
type ContractInstanceWithAddress,
|
|
10
12
|
ContractStorageRead,
|
|
11
13
|
ContractStorageUpdateRequest,
|
|
@@ -27,6 +29,7 @@ import {
|
|
|
27
29
|
Nullifier,
|
|
28
30
|
type PublicInnerCallRequest,
|
|
29
31
|
ReadRequest,
|
|
32
|
+
SerializableContractInstance,
|
|
30
33
|
TreeLeafReadRequest,
|
|
31
34
|
} from '@aztec/circuits.js';
|
|
32
35
|
import { Fr } from '@aztec/foundation/fields';
|
|
@@ -42,7 +45,7 @@ import { type PublicSideEffectTraceInterface } from './side_effect_trace_interfa
|
|
|
42
45
|
export type TracedContractInstance = { exists: boolean } & ContractInstanceWithAddress;
|
|
43
46
|
|
|
44
47
|
export class PublicSideEffectTrace implements PublicSideEffectTraceInterface {
|
|
45
|
-
public
|
|
48
|
+
public log = createDebugLogger('aztec:public_side_effect_trace');
|
|
46
49
|
|
|
47
50
|
/** The side effect counter increments with every call to the trace. */
|
|
48
51
|
private sideEffectCounter: number; // kept as number until finalized for efficiency
|
|
@@ -90,37 +93,35 @@ export class PublicSideEffectTrace implements PublicSideEffectTraceInterface {
|
|
|
90
93
|
this.sideEffectCounter++;
|
|
91
94
|
}
|
|
92
95
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
public tracePublicStorageRead(storageAddress: Fr, slot: Fr, value: Fr, _exists: boolean, _cached: boolean) {
|
|
96
|
+
public tracePublicStorageRead(contractAddress: Fr, slot: Fr, value: Fr, _exists: boolean, _cached: boolean) {
|
|
96
97
|
// NOTE: exists and cached are unused for now but may be used for optimizations or kernel hints later
|
|
97
98
|
if (this.contractStorageReads.length >= MAX_PUBLIC_DATA_READS_PER_TX) {
|
|
98
99
|
throw new SideEffectLimitReachedError('contract storage read', MAX_PUBLIC_DATA_READS_PER_TX);
|
|
99
100
|
}
|
|
100
101
|
this.contractStorageReads.push(
|
|
101
|
-
new ContractStorageRead(slot, value, this.sideEffectCounter, AztecAddress.fromField(
|
|
102
|
+
new ContractStorageRead(slot, value, this.sideEffectCounter, AztecAddress.fromField(contractAddress)),
|
|
102
103
|
);
|
|
103
104
|
this.avmCircuitHints.storageValues.items.push(
|
|
104
105
|
new AvmKeyValueHint(/*key=*/ new Fr(this.sideEffectCounter), /*value=*/ value),
|
|
105
106
|
);
|
|
106
|
-
this.
|
|
107
|
+
this.log.debug(`SLOAD cnt: ${this.sideEffectCounter} val: ${value} slot: ${slot}`);
|
|
107
108
|
this.incrementSideEffectCounter();
|
|
108
109
|
}
|
|
109
110
|
|
|
110
|
-
public tracePublicStorageWrite(
|
|
111
|
+
public tracePublicStorageWrite(contractAddress: Fr, slot: Fr, value: Fr) {
|
|
111
112
|
if (this.contractStorageUpdateRequests.length >= MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX) {
|
|
112
113
|
throw new SideEffectLimitReachedError('contract storage write', MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX);
|
|
113
114
|
}
|
|
114
115
|
this.contractStorageUpdateRequests.push(
|
|
115
|
-
new ContractStorageUpdateRequest(slot, value, this.sideEffectCounter,
|
|
116
|
+
new ContractStorageUpdateRequest(slot, value, this.sideEffectCounter, contractAddress),
|
|
116
117
|
);
|
|
117
|
-
this.
|
|
118
|
+
this.log.debug(`SSTORE cnt: ${this.sideEffectCounter} val: ${value} slot: ${slot}`);
|
|
118
119
|
this.incrementSideEffectCounter();
|
|
119
120
|
}
|
|
120
121
|
|
|
121
122
|
// TODO(8287): _exists can be removed once we have the vm properly handling the equality check
|
|
122
|
-
public traceNoteHashCheck(
|
|
123
|
-
// NOTE:
|
|
123
|
+
public traceNoteHashCheck(_contractAddress: Fr, noteHash: Fr, leafIndex: Fr, exists: boolean) {
|
|
124
|
+
// NOTE: contractAddress is unused but will be important when an AVM circuit processes an entire enqueued call
|
|
124
125
|
if (this.noteHashReadRequests.length >= MAX_NOTE_HASH_READ_REQUESTS_PER_TX) {
|
|
125
126
|
throw new SideEffectLimitReachedError('note hash read request', MAX_NOTE_HASH_READ_REQUESTS_PER_TX);
|
|
126
127
|
}
|
|
@@ -131,17 +132,23 @@ export class PublicSideEffectTrace implements PublicSideEffectTraceInterface {
|
|
|
131
132
|
// NOTE: counter does not increment for note hash checks (because it doesn't rely on pending note hashes)
|
|
132
133
|
}
|
|
133
134
|
|
|
134
|
-
public traceNewNoteHash(
|
|
135
|
+
public traceNewNoteHash(_contractAddress: Fr, noteHash: Fr) {
|
|
135
136
|
if (this.noteHashes.length >= MAX_NOTE_HASHES_PER_TX) {
|
|
136
137
|
throw new SideEffectLimitReachedError('note hash', MAX_NOTE_HASHES_PER_TX);
|
|
137
138
|
}
|
|
138
139
|
this.noteHashes.push(new NoteHash(noteHash, this.sideEffectCounter));
|
|
139
|
-
this.
|
|
140
|
+
this.log.debug(`NEW_NOTE_HASH cnt: ${this.sideEffectCounter}`);
|
|
140
141
|
this.incrementSideEffectCounter();
|
|
141
142
|
}
|
|
142
143
|
|
|
143
|
-
public traceNullifierCheck(
|
|
144
|
-
|
|
144
|
+
public traceNullifierCheck(
|
|
145
|
+
_contractAddress: Fr,
|
|
146
|
+
nullifier: Fr,
|
|
147
|
+
_leafIndex: Fr,
|
|
148
|
+
exists: boolean,
|
|
149
|
+
_isPending: boolean,
|
|
150
|
+
) {
|
|
151
|
+
// NOTE: contractAddress is unused but will be important when an AVM circuit processes an entire enqueued call
|
|
145
152
|
// NOTE: isPending and leafIndex are unused for now but may be used for optimizations or kernel hints later
|
|
146
153
|
|
|
147
154
|
this.enforceLimitOnNullifierChecks();
|
|
@@ -155,17 +162,17 @@ export class PublicSideEffectTrace implements PublicSideEffectTraceInterface {
|
|
|
155
162
|
this.avmCircuitHints.nullifierExists.items.push(
|
|
156
163
|
new AvmKeyValueHint(/*key=*/ new Fr(this.sideEffectCounter), /*value=*/ new Fr(exists ? 1 : 0)),
|
|
157
164
|
);
|
|
158
|
-
this.
|
|
165
|
+
this.log.debug(`NULLIFIER_EXISTS cnt: ${this.sideEffectCounter}`);
|
|
159
166
|
this.incrementSideEffectCounter();
|
|
160
167
|
}
|
|
161
168
|
|
|
162
|
-
public traceNewNullifier(
|
|
163
|
-
// NOTE:
|
|
169
|
+
public traceNewNullifier(_contractAddress: Fr, nullifier: Fr) {
|
|
170
|
+
// NOTE: contractAddress is unused but will be important when an AVM circuit processes an entire enqueued call
|
|
164
171
|
if (this.nullifiers.length >= MAX_NULLIFIERS_PER_TX) {
|
|
165
172
|
throw new SideEffectLimitReachedError('nullifier', MAX_NULLIFIERS_PER_TX);
|
|
166
173
|
}
|
|
167
174
|
this.nullifiers.push(new Nullifier(nullifier, this.sideEffectCounter, /*noteHash=*/ Fr.ZERO));
|
|
168
|
-
this.
|
|
175
|
+
this.log.debug(`NEW_NULLIFIER cnt: ${this.sideEffectCounter}`);
|
|
169
176
|
this.incrementSideEffectCounter();
|
|
170
177
|
}
|
|
171
178
|
|
|
@@ -188,7 +195,7 @@ export class PublicSideEffectTrace implements PublicSideEffectTraceInterface {
|
|
|
188
195
|
}
|
|
189
196
|
const recipientAddress = EthAddress.fromField(recipient);
|
|
190
197
|
this.newL2ToL1Messages.push(new L2ToL1Message(recipientAddress, content, this.sideEffectCounter));
|
|
191
|
-
this.
|
|
198
|
+
this.log.debug(`NEW_L2_TO_L1_MSG cnt: ${this.sideEffectCounter}`);
|
|
192
199
|
this.incrementSideEffectCounter();
|
|
193
200
|
}
|
|
194
201
|
|
|
@@ -206,18 +213,21 @@ export class PublicSideEffectTrace implements PublicSideEffectTraceInterface {
|
|
|
206
213
|
// This length is for charging DA and is checked on-chain - has to be length of log preimage + 4 bytes.
|
|
207
214
|
// The .length call also has a +4 but that is unrelated
|
|
208
215
|
this.unencryptedLogsHashes.push(new LogHash(basicLogHash, this.sideEffectCounter, new Fr(ulog.length + 4)));
|
|
209
|
-
this.
|
|
216
|
+
this.log.debug(`NEW_UNENCRYPTED_LOG cnt: ${this.sideEffectCounter}`);
|
|
210
217
|
this.incrementSideEffectCounter();
|
|
211
218
|
}
|
|
212
219
|
|
|
213
|
-
public traceGetContractInstance(
|
|
220
|
+
public traceGetContractInstance(
|
|
221
|
+
contractAddress: Fr,
|
|
222
|
+
exists: boolean,
|
|
223
|
+
instance: SerializableContractInstance = SerializableContractInstance.default(),
|
|
224
|
+
) {
|
|
214
225
|
this.enforceLimitOnNullifierChecks('(contract address nullifier from GETCONTRACTINSTANCE)');
|
|
215
|
-
// TODO(dbanks12): should emit a nullifier read request
|
|
216
226
|
|
|
217
227
|
this.avmCircuitHints.contractInstances.items.push(
|
|
218
228
|
new AvmContractInstanceHint(
|
|
219
|
-
|
|
220
|
-
|
|
229
|
+
contractAddress,
|
|
230
|
+
exists,
|
|
221
231
|
instance.salt,
|
|
222
232
|
instance.deployer,
|
|
223
233
|
instance.contractClassId,
|
|
@@ -225,10 +235,44 @@ export class PublicSideEffectTrace implements PublicSideEffectTraceInterface {
|
|
|
225
235
|
instance.publicKeys,
|
|
226
236
|
),
|
|
227
237
|
);
|
|
228
|
-
this.
|
|
238
|
+
this.log.debug(`CONTRACT_INSTANCE cnt: ${this.sideEffectCounter}`);
|
|
229
239
|
this.incrementSideEffectCounter();
|
|
230
240
|
}
|
|
231
241
|
|
|
242
|
+
// This tracing function gets called everytime we start simulation/execution.
|
|
243
|
+
// This happens both when starting a new top-level trace and the start of every nested trace
|
|
244
|
+
// We use this to collect the AvmContractBytecodeHints
|
|
245
|
+
public traceGetBytecode(
|
|
246
|
+
contractAddress: Fr,
|
|
247
|
+
exists: boolean,
|
|
248
|
+
bytecode: Buffer = Buffer.alloc(0),
|
|
249
|
+
contractInstance: SerializableContractInstance = SerializableContractInstance.default(),
|
|
250
|
+
contractClass: ContractClassIdPreimage = {
|
|
251
|
+
artifactHash: Fr.zero(),
|
|
252
|
+
privateFunctionsRoot: Fr.zero(),
|
|
253
|
+
publicBytecodeCommitment: Fr.zero(),
|
|
254
|
+
},
|
|
255
|
+
) {
|
|
256
|
+
const instance = new AvmContractInstanceHint(
|
|
257
|
+
contractAddress,
|
|
258
|
+
exists,
|
|
259
|
+
contractInstance.salt,
|
|
260
|
+
contractInstance.deployer,
|
|
261
|
+
contractInstance.contractClassId,
|
|
262
|
+
contractInstance.initializationHash,
|
|
263
|
+
contractInstance.publicKeys,
|
|
264
|
+
);
|
|
265
|
+
// We need to deduplicate the contract instances based on addresses
|
|
266
|
+
this.avmCircuitHints.contractBytecodeHints.items.push(
|
|
267
|
+
new AvmContractBytecodeHints(bytecode, instance, contractClass),
|
|
268
|
+
);
|
|
269
|
+
this.log.debug(
|
|
270
|
+
`Bytecode retrieval for contract execution traced: exists=${exists}, instance=${JSON.stringify(
|
|
271
|
+
contractInstance,
|
|
272
|
+
)}`,
|
|
273
|
+
);
|
|
274
|
+
}
|
|
275
|
+
|
|
232
276
|
/**
|
|
233
277
|
* Trace a nested call.
|
|
234
278
|
* Accept some results from a finished nested call's trace into this one.
|
|
@@ -282,6 +326,7 @@ export class PublicSideEffectTrace implements PublicSideEffectTraceInterface {
|
|
|
282
326
|
result.returnValues,
|
|
283
327
|
gasUsed,
|
|
284
328
|
result.endSideEffectCounter,
|
|
329
|
+
nestedEnvironment.address,
|
|
285
330
|
),
|
|
286
331
|
);
|
|
287
332
|
}
|
|
@@ -369,10 +414,9 @@ export class PublicSideEffectTrace implements PublicSideEffectTraceInterface {
|
|
|
369
414
|
function createPublicExecutionRequest(avmEnvironment: AvmExecutionEnvironment): PublicExecutionRequest {
|
|
370
415
|
const callContext = CallContext.from({
|
|
371
416
|
msgSender: avmEnvironment.sender,
|
|
372
|
-
|
|
417
|
+
contractAddress: avmEnvironment.address,
|
|
373
418
|
functionSelector: avmEnvironment.functionSelector,
|
|
374
|
-
isDelegateCall: avmEnvironment.isDelegateCall,
|
|
375
419
|
isStaticCall: avmEnvironment.isStaticCall,
|
|
376
420
|
});
|
|
377
|
-
return new PublicExecutionRequest(
|
|
421
|
+
return new PublicExecutionRequest(callContext, avmEnvironment.calldata);
|
|
378
422
|
}
|
|
@@ -1,25 +1,30 @@
|
|
|
1
|
-
import { type Gas } from '@aztec/circuits.js';
|
|
1
|
+
import { type ContractClassIdPreimage, type Gas, type SerializableContractInstance } from '@aztec/circuits.js';
|
|
2
2
|
import { type Fr } from '@aztec/foundation/fields';
|
|
3
3
|
|
|
4
4
|
import { type AvmContractCallResult } from '../avm/avm_contract_call_result.js';
|
|
5
5
|
import { type AvmExecutionEnvironment } from '../avm/avm_execution_environment.js';
|
|
6
|
-
import { type TracedContractInstance } from './side_effect_trace.js';
|
|
7
6
|
|
|
8
7
|
export interface PublicSideEffectTraceInterface {
|
|
9
8
|
fork(): PublicSideEffectTraceInterface;
|
|
10
9
|
getCounter(): number;
|
|
11
10
|
// all "trace*" functions can throw SideEffectLimitReachedError
|
|
12
|
-
tracePublicStorageRead(
|
|
13
|
-
tracePublicStorageWrite(
|
|
14
|
-
traceNoteHashCheck(
|
|
15
|
-
traceNewNoteHash(
|
|
16
|
-
traceNullifierCheck(
|
|
17
|
-
traceNewNullifier(
|
|
11
|
+
tracePublicStorageRead(contractAddress: Fr, slot: Fr, value: Fr, exists: boolean, cached: boolean): void;
|
|
12
|
+
tracePublicStorageWrite(contractAddress: Fr, slot: Fr, value: Fr): void;
|
|
13
|
+
traceNoteHashCheck(contractAddress: Fr, noteHash: Fr, leafIndex: Fr, exists: boolean): void;
|
|
14
|
+
traceNewNoteHash(contractAddress: Fr, noteHash: Fr): void;
|
|
15
|
+
traceNullifierCheck(contractAddress: Fr, nullifier: Fr, leafIndex: Fr, exists: boolean, isPending: boolean): void;
|
|
16
|
+
traceNewNullifier(contractAddress: Fr, nullifier: Fr): void;
|
|
18
17
|
traceL1ToL2MessageCheck(contractAddress: Fr, msgHash: Fr, msgLeafIndex: Fr, exists: boolean): void;
|
|
19
18
|
traceNewL2ToL1Message(contractAddress: Fr, recipient: Fr, content: Fr): void;
|
|
20
19
|
traceUnencryptedLog(contractAddress: Fr, log: Fr[]): void;
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
traceGetContractInstance(contractAddress: Fr, exists: boolean, instance?: SerializableContractInstance): void;
|
|
21
|
+
traceGetBytecode(
|
|
22
|
+
contractAddress: Fr,
|
|
23
|
+
exists: boolean,
|
|
24
|
+
bytecode?: Buffer,
|
|
25
|
+
contractInstance?: SerializableContractInstance,
|
|
26
|
+
contractClass?: ContractClassIdPreimage,
|
|
27
|
+
): void;
|
|
23
28
|
traceNestedCall(
|
|
24
29
|
/** The trace of the nested call. */
|
|
25
30
|
nestedCallTrace: PublicSideEffectTraceInterface,
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { type AvmContext } from '../avm_context.js';
|
|
2
|
-
import { Opcode, OperandType } from '../serialization/instruction_serialization.js';
|
|
3
|
-
import { Instruction } from './instruction.js';
|
|
4
|
-
export declare class PedersenCommitment extends Instruction {
|
|
5
|
-
private indirect;
|
|
6
|
-
private inputOffset;
|
|
7
|
-
private outputOffset;
|
|
8
|
-
private inputSizeOffset;
|
|
9
|
-
private genIndexOffset;
|
|
10
|
-
static type: string;
|
|
11
|
-
static readonly opcode: Opcode;
|
|
12
|
-
static readonly wireFormat: OperandType[];
|
|
13
|
-
constructor(indirect: number, inputOffset: number, outputOffset: number, inputSizeOffset: number, genIndexOffset: number);
|
|
14
|
-
execute(context: AvmContext): Promise<void>;
|
|
15
|
-
}
|
|
16
|
-
//# sourceMappingURL=commitment.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"commitment.d.ts","sourceRoot":"","sources":["../../../src/avm/opcodes/commitment.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,+CAA+C,CAAC;AAEpF,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,qBAAa,kBAAmB,SAAQ,WAAW;IAe/C,OAAO,CAAC,QAAQ;IAChB,OAAO,CAAC,WAAW;IACnB,OAAO,CAAC,YAAY;IACpB,OAAO,CAAC,eAAe;IACvB,OAAO,CAAC,cAAc;IAlBxB,MAAM,CAAC,IAAI,EAAE,MAAM,CAAwB;IAC3C,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAA6B;IAG3D,MAAM,CAAC,QAAQ,CAAC,UAAU,EAAE,WAAW,EAAE,CAOvC;gBAGQ,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,EACpB,eAAe,EAAE,MAAM,EACvB,cAAc,EAAE,MAAM;IAKnB,OAAO,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;CAgCzD"}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { pedersenCommit } from '@aztec/foundation/crypto';
|
|
2
|
-
import { Field, TypeTag, Uint8 } from '../avm_memory_types.js';
|
|
3
|
-
import { Opcode, OperandType } from '../serialization/instruction_serialization.js';
|
|
4
|
-
import { Addressing } from './addressing_mode.js';
|
|
5
|
-
import { Instruction } from './instruction.js';
|
|
6
|
-
export class PedersenCommitment extends Instruction {
|
|
7
|
-
constructor(indirect, inputOffset, outputOffset, inputSizeOffset, genIndexOffset) {
|
|
8
|
-
super();
|
|
9
|
-
this.indirect = indirect;
|
|
10
|
-
this.inputOffset = inputOffset;
|
|
11
|
-
this.outputOffset = outputOffset;
|
|
12
|
-
this.inputSizeOffset = inputSizeOffset;
|
|
13
|
-
this.genIndexOffset = genIndexOffset;
|
|
14
|
-
}
|
|
15
|
-
async execute(context) {
|
|
16
|
-
const memory = context.machineState.memory.track(this.type);
|
|
17
|
-
const operands = [this.inputOffset, this.outputOffset, this.inputSizeOffset, this.genIndexOffset];
|
|
18
|
-
const addressing = Addressing.fromWire(this.indirect, operands.length);
|
|
19
|
-
const [inputOffset, outputOffset, inputSizeOffset, genIndexOffset] = addressing.resolve(operands, memory);
|
|
20
|
-
const inputSize = memory.get(inputSizeOffset).toNumber();
|
|
21
|
-
memory.checkTag(TypeTag.UINT32, inputSizeOffset);
|
|
22
|
-
const inputs = memory.getSlice(inputOffset, inputSize);
|
|
23
|
-
memory.checkTagsRange(TypeTag.FIELD, inputOffset, inputSize);
|
|
24
|
-
const generatorIndex = memory.get(genIndexOffset).toNumber();
|
|
25
|
-
memory.checkTag(TypeTag.UINT32, genIndexOffset);
|
|
26
|
-
context.machineState.consumeGas(this.gasCost(inputSize));
|
|
27
|
-
const inputBuffer = inputs.map(input => input.toBuffer());
|
|
28
|
-
// TODO: Add the generate index to the pedersenCommit function
|
|
29
|
-
const commitment = pedersenCommit(inputBuffer, generatorIndex).map(f => new Field(f));
|
|
30
|
-
// The function doesnt include a flag if the output point is infinity, come back to this
|
|
31
|
-
// for now we just check if theyre zero - until we know how bb encodes them
|
|
32
|
-
const isInfinity = commitment[0].equals(new Field(0)) && commitment[1].equals(new Field(0));
|
|
33
|
-
memory.set(outputOffset, commitment[0]); // Field typed
|
|
34
|
-
memory.set(outputOffset + 1, commitment[1]); // Field typed
|
|
35
|
-
memory.set(outputOffset + 2, new Uint8(isInfinity ? 1 : 0)); // U8 typed
|
|
36
|
-
memory.assert({ reads: inputSize + 2, writes: 3, addressing });
|
|
37
|
-
context.machineState.incrementPc();
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
PedersenCommitment.type = 'PEDERSENCOMMITMENT';
|
|
41
|
-
PedersenCommitment.opcode = Opcode.PEDERSENCOMMITMENT;
|
|
42
|
-
// Informs (de)serialization. See Instruction.deserialize.
|
|
43
|
-
PedersenCommitment.wireFormat = [
|
|
44
|
-
OperandType.UINT8 /* Opcode */,
|
|
45
|
-
OperandType.UINT8 /* Indirect */,
|
|
46
|
-
OperandType.UINT32 /* Input Offset*/,
|
|
47
|
-
OperandType.UINT32 /* Dst Offset */,
|
|
48
|
-
OperandType.UINT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NBQVMsR0FBRyxDQUFDLEVBQUUsTUFBTSxFQUFFLENBQUMsRUFBRSxVQUFVLEVBQUUsQ0FBQyxDQUFDO1FBQy9ELE9BQU8sQ0FBQyxZQUFZLENBQUMsV0FBVyxFQUFFLENBQUM7SUFDckMsQ0FBQzs7QUF0RE0sdUJBQUksR0FBVyxvQkFBb0IsQ0FBQztBQUMzQix5QkFBTSxHQUFXLE1BQU0sQ0FBQyxrQkFBa0IsQ0FBQztBQUUzRCwwREFBMEQ7QUFDMUMsNkJBQVUsR0FBa0I7SUFDMUMsV0FBVyxDQUFDLEtBQUssQ0FBQyxZQUFZO0lBQzlCLFdBQVcsQ0FBQyxLQUFLLENBQUMsY0FBYztJQUNoQyxXQUFXLENBQUMsTUFBTSxDQUFDLGlCQUFpQjtJQUNwQyxXQUFXLENBQUMsTUFBTSxDQUFDLGdCQUFnQjtJQUNuQyxXQUFXLENBQUMsTUFBTSxDQUFDLHVCQUF1QjtJQUMxQyxXQUFXLENBQUMsTUFBTSxDQUFDLDRCQUE0QjtDQUNoRCxDQUFDIn0=
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Fr } from '@aztec/circuits.js';
|
|
2
|
-
/**
|
|
3
|
-
* Computes a note hiding point as is done by the default implementation injected by macros.
|
|
4
|
-
* @param storageSlot - The slot to which the note was inserted.
|
|
5
|
-
* @param noteContent - The note content (e.g. note.items).
|
|
6
|
-
* @returns A note hash.
|
|
7
|
-
*/
|
|
8
|
-
export declare function computeNoteHash(storageSlot: Fr, noteContent: Fr[]): Fr;
|
|
9
|
-
//# sourceMappingURL=test_utils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"test_utils.d.ts","sourceRoot":"","sources":["../../src/client/test_utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAM,EAAE,EAAS,MAAM,oBAAoB,CAAC;AAsCnD;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,WAAW,EAAE,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE,GAAG,EAAE,CAYtE"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { Fq, Fr, Point } from '@aztec/circuits.js';
|
|
2
|
-
import { Grumpkin } from '@aztec/circuits.js/barretenberg';
|
|
3
|
-
// Copied over from `noir-projects/aztec-nr/aztec/src/generators.nr`
|
|
4
|
-
const GENERATORS = [
|
|
5
|
-
new Point(new Fr(0x30426e64aee30e998c13c8ceecda3a77807dbead52bc2f3bf0eae851b4b710c1n), new Fr(0x113156a068f603023240c96b4da5474667db3b8711c521c748212a15bc034ea6n), false),
|
|
6
|
-
new Point(new Fr(0x2825c79cc6a5cbbeef7d6a8f1b6a12b312aa338440aefeb4396148c89147c049n), new Fr(0x129bfd1da54b7062d6b544e7e36b90736350f6fba01228c41c72099509f5701en), false),
|
|
7
|
-
new Point(new Fr(0x0edb1e293c3ce91bfc04e3ceaa50d2c541fa9d091c72eb403efb1cfa2cb3357fn), new Fr(0x1341d675fa030ece3113ad53ca34fd13b19b6e9762046734f414824c4d6ade35n), false),
|
|
8
|
-
new Point(new Fr(0x0e0dad2250583f2a9f0acb04ededf1701b85b0393cae753fe7e14b88af81cb52n), new Fr(0x0973b02c5caac339ee4ad5dab51329920f7bf1b6a07e1dabe5df67040b300962n), false),
|
|
9
|
-
new Point(new Fr(0x2f3342e900e8c488a28931aae68970738fdc68afde2910de7b320c00c902087dn), new Fr(0x1bf958dc63cb09d59230603a0269ae86d6f92494da244910351f1132df20fc08n), false),
|
|
10
|
-
];
|
|
11
|
-
const G_SLOT = new Point(new Fr(0x041223147b680850dc82e8a55a952d4df20256fe0593d949a9541ca00f0abf15n), new Fr(0x0a8c72e60d0e60f5d804549d48f3044d06140b98ed717a9b532af630c1530791n), false);
|
|
12
|
-
/**
|
|
13
|
-
* Computes a note hiding point as is done by the default implementation injected by macros.
|
|
14
|
-
* @param storageSlot - The slot to which the note was inserted.
|
|
15
|
-
* @param noteContent - The note content (e.g. note.items).
|
|
16
|
-
* @returns A note hash.
|
|
17
|
-
*/
|
|
18
|
-
export function computeNoteHash(storageSlot, noteContent) {
|
|
19
|
-
const grumpkin = new Grumpkin();
|
|
20
|
-
const noteHidingPointBeforeSlotting = noteContent
|
|
21
|
-
.slice(1)
|
|
22
|
-
.reduce((acc, item, i) => grumpkin.add(acc, grumpkin.mul(GENERATORS[i + 1], new Fq(item.toBigInt()))), grumpkin.mul(GENERATORS[0], new Fq(noteContent[0].toBigInt())));
|
|
23
|
-
const slotPoint = grumpkin.mul(G_SLOT, new Fq(storageSlot.toBigInt()));
|
|
24
|
-
const noteHidingPoint = grumpkin.add(noteHidingPointBeforeSlotting, slotPoint);
|
|
25
|
-
return noteHidingPoint.x;
|
|
26
|
-
}
|
|
27
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdF91dGlscy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9jbGllbnQvdGVzdF91dGlscy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsRUFBRSxFQUFFLEVBQUUsRUFBRSxLQUFLLEVBQUUsTUFBTSxvQkFBb0IsQ0FBQztBQUNuRCxPQUFPLEVBQUUsUUFBUSxFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFFM0Qsb0VBQW9FO0FBQ3BFLE1BQU0sVUFBVSxHQUFHO0lBQ2pCLElBQUksS0FBSyxDQUNQLElBQUksRUFBRSxDQUFDLG1FQUFtRSxDQUFDLEVBQzNFLElBQUksRUFBRSxDQUFDLG1FQUFtRSxDQUFDLEVBQzNFLEtBQUssQ0FDTjtJQUNELElBQUksS0FBSyxDQUNQLElBQUksRUFBRSxDQUFDLG1FQUFtRSxDQUFDLEVBQzNFLElBQUksRUFBRSxDQUFDLG1FQUFtRSxDQUFDLEVBQzNFLEtBQUssQ0FDTjtJQUNELElBQUksS0FBSyxDQUNQLElBQUksRUFBRSxDQU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UMsV0FBVyxDQUFDLENBQUMsQ0FBQyxDQUFDLFFBQVEsRUFBRSxDQUFDLENBQUMsQ0FDL0QsQ0FBQztJQUVKLE1BQU0sU0FBUyxHQUFHLFFBQVEsQ0FBQyxHQUFHLENBQUMsTUFBTSxFQUFFLElBQUksRUFBRSxDQUFDLFdBQVcsQ0FBQyxRQUFRLEVBQUUsQ0FBQyxDQUFDLENBQUM7SUFDdkUsTUFBTSxlQUFlLEdBQUcsUUFBUSxDQUFDLEdBQUcsQ0FBQyw2QkFBNkIsRUFBRSxTQUFTLENBQUMsQ0FBQztJQUMvRSxPQUFPLGVBQWUsQ0FBQyxDQUFDLENBQUM7QUFDM0IsQ0FBQyJ9
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Keep track of the number of side effects across execution contexts.
|
|
3
|
-
*/
|
|
4
|
-
export declare class SideEffectCounter {
|
|
5
|
-
private value;
|
|
6
|
-
constructor(value?: number);
|
|
7
|
-
current(): number;
|
|
8
|
-
count(): number;
|
|
9
|
-
}
|
|
10
|
-
//# sourceMappingURL=side_effect_counter.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"side_effect_counter.d.ts","sourceRoot":"","sources":["../../src/common/side_effect_counter.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,iBAAiB;IAChB,OAAO,CAAC,KAAK;gBAAL,KAAK,SAAI;IAG7B,OAAO;IAIP,KAAK;CAKN"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Keep track of the number of side effects across execution contexts.
|
|
3
|
-
*/
|
|
4
|
-
export class SideEffectCounter {
|
|
5
|
-
constructor(value = 0) {
|
|
6
|
-
this.value = value;
|
|
7
|
-
}
|
|
8
|
-
// TODO(alexg) remove this once public side effect counters is fully accounted for on Noir side
|
|
9
|
-
current() {
|
|
10
|
-
return this.value;
|
|
11
|
-
}
|
|
12
|
-
count() {
|
|
13
|
-
const value = this.value;
|
|
14
|
-
this.value++;
|
|
15
|
-
return value;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2lkZV9lZmZlY3RfY291bnRlci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9jb21tb24vc2lkZV9lZmZlY3RfY291bnRlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7R0FFRztBQUNILE1BQU0sT0FBTyxpQkFBaUI7SUFDNUIsWUFBb0IsUUFBUSxDQUFDO1FBQVQsVUFBSyxHQUFMLEtBQUssQ0FBSTtJQUFHLENBQUM7SUFFakMsK0ZBQStGO0lBQy9GLE9BQU87UUFDTCxPQUFPLElBQUksQ0FBQyxLQUFLLENBQUM7SUFDcEIsQ0FBQztJQUVELEtBQUs7UUFDSCxNQUFNLEtBQUssR0FBRyxJQUFJLENBQUMsS0FBSyxDQUFDO1FBQ3pCLElBQUksQ0FBQyxLQUFLLEVBQUUsQ0FBQztRQUNiLE9BQU8sS0FBSyxDQUFDO0lBQ2YsQ0FBQztDQUNGIn0=
|