@aztec/simulator 0.33.0 → 0.35.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 +4 -1
- package/dest/acvm/acvm.d.ts.map +1 -1
- package/dest/acvm/acvm.js +5 -5
- package/dest/acvm/deserialize.d.ts +3 -5
- package/dest/acvm/deserialize.d.ts.map +1 -1
- package/dest/acvm/deserialize.js +6 -9
- package/dest/acvm/oracle/oracle.d.ts +3 -1
- package/dest/acvm/oracle/oracle.d.ts.map +1 -1
- package/dest/acvm/oracle/oracle.js +14 -6
- package/dest/acvm/oracle/typed_oracle.d.ts +2 -0
- package/dest/acvm/oracle/typed_oracle.d.ts.map +1 -1
- package/dest/acvm/oracle/typed_oracle.js +7 -1
- package/dest/avm/avm_execution_environment.d.ts +6 -3
- package/dest/avm/avm_execution_environment.d.ts.map +1 -1
- package/dest/avm/avm_execution_environment.js +12 -9
- package/dest/avm/avm_gas.js +2 -2
- 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 +24 -6
- package/dest/avm/avm_memory_types.js +6 -6
- package/dest/avm/avm_simulator.js +7 -7
- 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 +11 -4
- package/dest/avm/journal/journal.d.ts +15 -13
- package/dest/avm/journal/journal.d.ts.map +1 -1
- package/dest/avm/journal/journal.js +16 -5
- package/dest/avm/journal/trace.d.ts +8 -19
- package/dest/avm/journal/trace.d.ts.map +1 -1
- package/dest/avm/journal/trace.js +48 -116
- package/dest/avm/journal/trace_types.d.ts +23 -4
- package/dest/avm/journal/trace_types.d.ts.map +1 -1
- package/dest/avm/opcodes/accrued_substate.d.ts +2 -1
- package/dest/avm/opcodes/accrued_substate.d.ts.map +1 -1
- package/dest/avm/opcodes/accrued_substate.js +14 -6
- package/dest/avm/opcodes/context_getters.js +2 -2
- package/dest/avm/opcodes/external_calls.d.ts +2 -2
- package/dest/avm/opcodes/external_calls.d.ts.map +1 -1
- package/dest/avm/opcodes/external_calls.js +26 -10
- package/dest/avm/opcodes/hashing.d.ts +8 -8
- package/dest/avm/opcodes/hashing.d.ts.map +1 -1
- package/dest/avm/opcodes/hashing.js +35 -43
- package/dest/avm/serialization/instruction_serialization.d.ts +1 -1
- package/dest/avm/serialization/instruction_serialization.d.ts.map +1 -1
- package/dest/avm/serialization/instruction_serialization.js +2 -2
- package/dest/client/client_execution_context.d.ts +14 -4
- package/dest/client/client_execution_context.d.ts.map +1 -1
- package/dest/client/client_execution_context.js +28 -13
- package/dest/client/private_execution.d.ts +1 -1
- package/dest/client/private_execution.d.ts.map +1 -1
- package/dest/client/private_execution.js +10 -8
- package/dest/client/simulator.d.ts.map +1 -1
- package/dest/client/simulator.js +6 -5
- package/dest/client/unconstrained_execution.d.ts +1 -1
- package/dest/client/unconstrained_execution.d.ts.map +1 -1
- package/dest/client/unconstrained_execution.js +6 -5
- package/dest/client/view_data_oracle.d.ts +2 -2
- package/dest/client/view_data_oracle.d.ts.map +1 -1
- package/dest/client/view_data_oracle.js +2 -2
- package/dest/common/index.d.ts +1 -1
- package/dest/common/index.d.ts.map +1 -1
- package/dest/common/index.js +2 -2
- package/dest/common/packed_values_cache.d.ts +28 -0
- package/dest/common/packed_values_cache.d.ts.map +1 -0
- package/dest/common/packed_values_cache.js +50 -0
- package/dest/index.d.ts +1 -0
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +2 -1
- package/dest/mocks/fixtures.d.ts +42 -0
- package/dest/mocks/fixtures.d.ts.map +1 -0
- package/dest/mocks/fixtures.js +84 -0
- package/dest/mocks/index.d.ts +2 -0
- package/dest/mocks/index.d.ts.map +1 -0
- package/dest/mocks/index.js +2 -0
- package/dest/public/abstract_phase_manager.d.ts +82 -0
- package/dest/public/abstract_phase_manager.d.ts.map +1 -0
- package/dest/public/abstract_phase_manager.js +320 -0
- package/dest/public/app_logic_phase_manager.d.ts +29 -0
- package/dest/public/app_logic_phase_manager.d.ts.map +1 -0
- package/dest/public/app_logic_phase_manager.js +50 -0
- package/dest/public/execution.d.ts +3 -0
- package/dest/public/execution.d.ts.map +1 -1
- package/dest/public/execution.js +1 -1
- package/dest/public/executor.d.ts +1 -15
- package/dest/public/executor.d.ts.map +1 -1
- package/dest/public/executor.js +80 -83
- package/dest/public/hints_builder.d.ts +23 -0
- package/dest/public/hints_builder.d.ts.map +1 -0
- package/dest/public/hints_builder.js +62 -0
- package/dest/public/index.d.ts +5 -0
- package/dest/public/index.d.ts.map +1 -1
- package/dest/public/index.js +6 -1
- package/dest/public/phase_manager_factory.d.ts +18 -0
- package/dest/public/phase_manager_factory.d.ts.map +1 -0
- package/dest/public/phase_manager_factory.js +56 -0
- package/dest/public/public_execution_context.d.ts +20 -10
- package/dest/public/public_execution_context.d.ts.map +1 -1
- package/dest/public/public_execution_context.js +35 -23
- package/dest/public/public_executor.d.ts +79 -0
- package/dest/public/public_executor.d.ts.map +1 -0
- package/dest/public/public_executor.js +198 -0
- package/dest/public/public_kernel.d.ts +37 -0
- package/dest/public/public_kernel.d.ts.map +1 -0
- package/dest/public/public_kernel.js +97 -0
- package/dest/public/public_kernel_circuit_simulator.d.ts +31 -0
- package/dest/public/public_kernel_circuit_simulator.d.ts.map +1 -0
- package/dest/public/public_kernel_circuit_simulator.js +2 -0
- package/dest/public/public_processor.d.ts +53 -0
- package/dest/public/public_processor.d.ts.map +1 -0
- package/dest/public/public_processor.js +144 -0
- package/dest/public/setup_phase_manager.d.ts +30 -0
- package/dest/public/setup_phase_manager.d.ts.map +1 -0
- package/dest/public/setup_phase_manager.js +46 -0
- package/dest/public/tail_phase_manager.d.ts +30 -0
- package/dest/public/tail_phase_manager.d.ts.map +1 -0
- package/dest/public/tail_phase_manager.js +60 -0
- package/dest/public/teardown_phase_manager.d.ts +30 -0
- package/dest/public/teardown_phase_manager.d.ts.map +1 -0
- package/dest/public/teardown_phase_manager.js +46 -0
- package/dest/public/transitional_adaptors.d.ts +33 -0
- package/dest/public/transitional_adaptors.d.ts.map +1 -0
- package/dest/public/transitional_adaptors.js +162 -0
- package/dest/public/utils.d.ts +8 -0
- package/dest/public/utils.d.ts.map +1 -0
- package/dest/public/utils.js +29 -0
- package/dest/simulator/acvm_native.d.ts +19 -3
- package/dest/simulator/acvm_native.d.ts.map +1 -1
- package/dest/simulator/acvm_native.js +75 -48
- package/dest/simulator/acvm_wasm.d.ts.map +1 -1
- package/dest/simulator/acvm_wasm.js +3 -4
- package/package.json +8 -5
- package/src/acvm/acvm.ts +8 -5
- package/src/acvm/deserialize.ts +5 -9
- package/src/acvm/oracle/oracle.ts +15 -5
- package/src/acvm/oracle/typed_oracle.ts +8 -0
- package/src/avm/avm_execution_environment.ts +17 -17
- package/src/avm/avm_gas.ts +1 -1
- package/src/avm/avm_machine_state.ts +26 -5
- package/src/avm/avm_memory_types.ts +5 -5
- package/src/avm/avm_simulator.ts +6 -6
- package/src/avm/fixtures/index.ts +14 -1
- package/src/avm/journal/journal.ts +37 -17
- package/src/avm/journal/trace.ts +59 -121
- package/src/avm/journal/trace_types.ts +39 -39
- package/src/avm/opcodes/accrued_substate.ts +17 -5
- package/src/avm/opcodes/context_getters.ts +1 -1
- package/src/avm/opcodes/external_calls.ts +32 -9
- package/src/avm/opcodes/hashing.ts +38 -54
- package/src/avm/serialization/instruction_serialization.ts +1 -1
- package/src/client/client_execution_context.ts +30 -11
- package/src/client/private_execution.ts +9 -8
- package/src/client/simulator.ts +7 -3
- package/src/client/unconstrained_execution.ts +5 -4
- package/src/client/view_data_oracle.ts +1 -1
- package/src/common/index.ts +1 -1
- package/src/common/packed_values_cache.ts +55 -0
- package/src/index.ts +1 -0
- package/src/mocks/fixtures.ts +169 -0
- package/src/mocks/index.ts +1 -0
- package/src/public/abstract_phase_manager.ts +571 -0
- package/src/public/app_logic_phase_manager.ts +76 -0
- package/src/public/execution.ts +4 -0
- package/src/public/executor.ts +93 -93
- package/src/public/hints_builder.ts +119 -0
- package/src/public/index.ts +5 -0
- package/src/public/phase_manager_factory.ts +126 -0
- package/src/public/public_execution_context.ts +43 -37
- package/src/public/public_executor.ts +267 -0
- package/src/public/public_kernel.ts +139 -0
- package/src/public/public_kernel_circuit_simulator.ts +36 -0
- package/src/public/public_processor.ts +212 -0
- package/src/public/setup_phase_manager.ts +66 -0
- package/src/public/tail_phase_manager.ts +120 -0
- package/src/public/teardown_phase_manager.ts +66 -0
- package/src/public/transitional_adaptors.ts +249 -0
- package/src/public/utils.ts +31 -0
- package/src/simulator/acvm_native.ts +94 -47
- package/src/simulator/acvm_wasm.ts +7 -3
- package/dest/avm/temporary_executor_migration.d.ts +0 -27
- package/dest/avm/temporary_executor_migration.d.ts.map +0 -1
- package/dest/avm/temporary_executor_migration.js +0 -94
- package/dest/common/packed_args_cache.d.ts +0 -28
- package/dest/common/packed_args_cache.d.ts.map +0 -1
- package/dest/common/packed_args_cache.js +0 -50
- package/src/avm/temporary_executor_migration.ts +0 -136
- package/src/common/packed_args_cache.ts +0 -55
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
// All code in this file needs to die once the public executor is phased out in favor of the AVM.
|
|
2
|
+
import { UnencryptedFunctionL2Logs, UnencryptedL2Log } from '@aztec/circuit-types';
|
|
3
|
+
import {
|
|
4
|
+
CallContext,
|
|
5
|
+
ContractStorageRead,
|
|
6
|
+
ContractStorageUpdateRequest,
|
|
7
|
+
FunctionData,
|
|
8
|
+
Gas,
|
|
9
|
+
type GlobalVariables,
|
|
10
|
+
type Header,
|
|
11
|
+
L2ToL1Message,
|
|
12
|
+
ReadRequest,
|
|
13
|
+
SideEffect,
|
|
14
|
+
SideEffectLinkedToNoteHash,
|
|
15
|
+
} from '@aztec/circuits.js';
|
|
16
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
17
|
+
|
|
18
|
+
import { type AvmContext } from '../avm/avm_context.js';
|
|
19
|
+
import { AvmExecutionEnvironment } from '../avm/avm_execution_environment.js';
|
|
20
|
+
import { type AvmMachineState } from '../avm/avm_machine_state.js';
|
|
21
|
+
import { AvmContractCallResults } from '../avm/avm_message_call_result.js';
|
|
22
|
+
import { type JournalData } from '../avm/journal/journal.js';
|
|
23
|
+
import { Mov } from '../avm/opcodes/memory.js';
|
|
24
|
+
import { createSimulationError } from '../common/errors.js';
|
|
25
|
+
import { PackedValuesCache, SideEffectCounter } from '../index.js';
|
|
26
|
+
import { type PublicExecution, type PublicExecutionResult } from './execution.js';
|
|
27
|
+
import { PublicExecutionContext } from './public_execution_context.js';
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Convert a PublicExecution(Environment) object to an AvmExecutionEnvironment
|
|
31
|
+
*
|
|
32
|
+
* @param current
|
|
33
|
+
* @param globalVariables
|
|
34
|
+
* @returns
|
|
35
|
+
*/
|
|
36
|
+
export function createAvmExecutionEnvironment(
|
|
37
|
+
current: PublicExecution,
|
|
38
|
+
header: Header,
|
|
39
|
+
globalVariables: GlobalVariables,
|
|
40
|
+
): AvmExecutionEnvironment {
|
|
41
|
+
return new AvmExecutionEnvironment(
|
|
42
|
+
current.contractAddress,
|
|
43
|
+
current.callContext.storageContractAddress,
|
|
44
|
+
current.callContext.msgSender, // TODO: origin is not available
|
|
45
|
+
current.callContext.msgSender,
|
|
46
|
+
current.callContext.portalContractAddress,
|
|
47
|
+
globalVariables.gasFees.feePerL1Gas,
|
|
48
|
+
globalVariables.gasFees.feePerL2Gas,
|
|
49
|
+
globalVariables.gasFees.feePerDaGas,
|
|
50
|
+
/*contractCallDepth=*/ Fr.zero(),
|
|
51
|
+
header,
|
|
52
|
+
globalVariables,
|
|
53
|
+
current.callContext.isStaticCall,
|
|
54
|
+
current.callContext.isDelegateCall,
|
|
55
|
+
current.args,
|
|
56
|
+
current.callContext.gasSettings,
|
|
57
|
+
current.callContext.transactionFee,
|
|
58
|
+
current.functionData.selector,
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function createPublicExecutionContext(avmContext: AvmContext, calldata: Fr[]): PublicExecutionContext {
|
|
63
|
+
const sideEffectCounter = avmContext.persistableState.trace.accessCounter;
|
|
64
|
+
const callContext = CallContext.from({
|
|
65
|
+
msgSender: avmContext.environment.sender,
|
|
66
|
+
storageContractAddress: avmContext.environment.storageAddress,
|
|
67
|
+
portalContractAddress: avmContext.environment.portal,
|
|
68
|
+
functionSelector: avmContext.environment.temporaryFunctionSelector,
|
|
69
|
+
gasLeft: Gas.from(avmContext.machineState.gasLeft),
|
|
70
|
+
isDelegateCall: avmContext.environment.isDelegateCall,
|
|
71
|
+
isStaticCall: avmContext.environment.isStaticCall,
|
|
72
|
+
sideEffectCounter: sideEffectCounter,
|
|
73
|
+
gasSettings: avmContext.environment.gasSettings,
|
|
74
|
+
transactionFee: avmContext.environment.transactionFee,
|
|
75
|
+
});
|
|
76
|
+
const functionData = new FunctionData(avmContext.environment.temporaryFunctionSelector, /*isPrivate=*/ false);
|
|
77
|
+
const execution: PublicExecution = {
|
|
78
|
+
contractAddress: avmContext.environment.address,
|
|
79
|
+
callContext,
|
|
80
|
+
args: calldata,
|
|
81
|
+
functionData,
|
|
82
|
+
};
|
|
83
|
+
const packedArgs = PackedValuesCache.create([]);
|
|
84
|
+
|
|
85
|
+
const context = new PublicExecutionContext(
|
|
86
|
+
execution,
|
|
87
|
+
avmContext.environment.header,
|
|
88
|
+
avmContext.environment.globals,
|
|
89
|
+
packedArgs,
|
|
90
|
+
new SideEffectCounter(sideEffectCounter),
|
|
91
|
+
avmContext.persistableState.hostStorage.publicStateDb,
|
|
92
|
+
avmContext.persistableState.hostStorage.contractsDb,
|
|
93
|
+
avmContext.persistableState.hostStorage.commitmentsDb,
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
return context;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Convert the result of an AVM contract call to a PublicExecutionResult for the public kernel
|
|
101
|
+
*
|
|
102
|
+
* @param execution
|
|
103
|
+
* @param newWorldState
|
|
104
|
+
* @param result
|
|
105
|
+
* @returns
|
|
106
|
+
*/
|
|
107
|
+
export async function convertAvmResults(
|
|
108
|
+
executionContext: PublicExecutionContext,
|
|
109
|
+
newWorldState: JournalData,
|
|
110
|
+
result: AvmContractCallResults,
|
|
111
|
+
endMachineState: AvmMachineState,
|
|
112
|
+
): Promise<PublicExecutionResult> {
|
|
113
|
+
const execution = executionContext.execution;
|
|
114
|
+
|
|
115
|
+
const contractStorageReads: ContractStorageRead[] = newWorldState.storageReads.map(
|
|
116
|
+
read => new ContractStorageRead(read.slot, read.value, read.counter.toNumber()),
|
|
117
|
+
);
|
|
118
|
+
const contractStorageUpdateRequests: ContractStorageUpdateRequest[] = newWorldState.storageWrites.map(
|
|
119
|
+
write => new ContractStorageUpdateRequest(write.slot, write.value, write.counter.toNumber()),
|
|
120
|
+
);
|
|
121
|
+
// We need to write the storage updates to the DB, because that's what the ACVM expects.
|
|
122
|
+
// Assumes the updates are in the right order.
|
|
123
|
+
for (const write of newWorldState.storageWrites) {
|
|
124
|
+
await executionContext.stateDb.storageWrite(write.storageAddress, write.slot, write.value);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const newNoteHashes = newWorldState.newNoteHashes.map(
|
|
128
|
+
noteHash => new SideEffect(noteHash.noteHash, noteHash.counter),
|
|
129
|
+
);
|
|
130
|
+
const nullifierReadRequests: ReadRequest[] = newWorldState.nullifierChecks
|
|
131
|
+
.filter(nullifierCheck => nullifierCheck.exists)
|
|
132
|
+
.map(nullifierCheck => new ReadRequest(nullifierCheck.nullifier, nullifierCheck.counter.toNumber()));
|
|
133
|
+
const nullifierNonExistentReadRequests: ReadRequest[] = newWorldState.nullifierChecks
|
|
134
|
+
.filter(nullifierCheck => !nullifierCheck.exists)
|
|
135
|
+
.map(nullifierCheck => new ReadRequest(nullifierCheck.nullifier, nullifierCheck.counter.toNumber()));
|
|
136
|
+
const newNullifiers: SideEffectLinkedToNoteHash[] = newWorldState.newNullifiers.map(
|
|
137
|
+
tracedNullifier =>
|
|
138
|
+
new SideEffectLinkedToNoteHash(
|
|
139
|
+
/*value=*/ tracedNullifier.nullifier,
|
|
140
|
+
/*noteHash=*/ Fr.ZERO, // NEEDED?
|
|
141
|
+
tracedNullifier.counter,
|
|
142
|
+
),
|
|
143
|
+
);
|
|
144
|
+
const unencryptedLogs: UnencryptedFunctionL2Logs = new UnencryptedFunctionL2Logs(
|
|
145
|
+
newWorldState.newLogs.map(log => new UnencryptedL2Log(log.contractAddress, log.selector, log.data)),
|
|
146
|
+
);
|
|
147
|
+
const newL2ToL1Messages = newWorldState.newL1Messages.map(m => new L2ToL1Message(m.recipient, m.content));
|
|
148
|
+
|
|
149
|
+
const returnValues = result.output;
|
|
150
|
+
|
|
151
|
+
// TODO: Support nested executions.
|
|
152
|
+
const nestedExecutions: PublicExecutionResult[] = [];
|
|
153
|
+
// TODO keep track of side effect counters
|
|
154
|
+
const startSideEffectCounter = Fr.ZERO;
|
|
155
|
+
const endSideEffectCounter = Fr.ZERO;
|
|
156
|
+
|
|
157
|
+
return {
|
|
158
|
+
execution,
|
|
159
|
+
nullifierReadRequests,
|
|
160
|
+
nullifierNonExistentReadRequests,
|
|
161
|
+
newNoteHashes,
|
|
162
|
+
newL2ToL1Messages,
|
|
163
|
+
startSideEffectCounter,
|
|
164
|
+
endSideEffectCounter,
|
|
165
|
+
newNullifiers,
|
|
166
|
+
contractStorageReads,
|
|
167
|
+
contractStorageUpdateRequests,
|
|
168
|
+
returnValues,
|
|
169
|
+
nestedExecutions,
|
|
170
|
+
unencryptedLogs,
|
|
171
|
+
reverted: result.reverted,
|
|
172
|
+
revertReason: result.revertReason ? createSimulationError(result.revertReason) : undefined,
|
|
173
|
+
gasLeft: endMachineState.gasLeft,
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
export function convertPublicExecutionResult(res: PublicExecutionResult): AvmContractCallResults {
|
|
178
|
+
return new AvmContractCallResults(res.reverted, res.returnValues, res.revertReason);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export function updateAvmContextFromPublicExecutionResult(ctx: AvmContext, result: PublicExecutionResult): void {
|
|
182
|
+
// We have to push these manually and not use the trace* functions
|
|
183
|
+
// so that we respect the side effect counters.
|
|
184
|
+
for (const readRequest of result.contractStorageReads) {
|
|
185
|
+
ctx.persistableState.trace.publicStorageReads.push({
|
|
186
|
+
storageAddress: ctx.environment.storageAddress,
|
|
187
|
+
exists: true, // FIXME
|
|
188
|
+
slot: readRequest.storageSlot,
|
|
189
|
+
value: readRequest.currentValue,
|
|
190
|
+
counter: new Fr(readRequest.sideEffectCounter ?? Fr.ZERO),
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
for (const updateRequest of result.contractStorageUpdateRequests) {
|
|
195
|
+
ctx.persistableState.trace.publicStorageWrites.push({
|
|
196
|
+
storageAddress: ctx.environment.storageAddress,
|
|
197
|
+
slot: updateRequest.storageSlot,
|
|
198
|
+
value: updateRequest.newValue,
|
|
199
|
+
counter: new Fr(updateRequest.sideEffectCounter ?? Fr.ZERO),
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
// We need to manually populate the cache.
|
|
203
|
+
ctx.persistableState.publicStorage.write(
|
|
204
|
+
ctx.environment.storageAddress,
|
|
205
|
+
updateRequest.storageSlot,
|
|
206
|
+
updateRequest.newValue,
|
|
207
|
+
);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
for (const nullifier of result.newNullifiers) {
|
|
211
|
+
ctx.persistableState.trace.newNullifiers.push({
|
|
212
|
+
storageAddress: ctx.environment.storageAddress,
|
|
213
|
+
nullifier: nullifier.value,
|
|
214
|
+
counter: nullifier.counter,
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
for (const noteHash of result.newNoteHashes) {
|
|
219
|
+
ctx.persistableState.trace.newNoteHashes.push({
|
|
220
|
+
storageAddress: ctx.environment.storageAddress,
|
|
221
|
+
noteHash: noteHash.value,
|
|
222
|
+
counter: noteHash.counter,
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
for (const message of result.newL2ToL1Messages) {
|
|
227
|
+
ctx.persistableState.newL1Messages.push(message);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
for (const log of result.unencryptedLogs.logs) {
|
|
231
|
+
ctx.persistableState.newLogs.push(new UnencryptedL2Log(log.contractAddress, log.selector, log.data));
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
const AVM_MAGIC_SUFFIX = Buffer.from([
|
|
236
|
+
Mov.opcode, // opcode
|
|
237
|
+
0x00, // indirect
|
|
238
|
+
...Buffer.from('000018ca', 'hex'), // srcOffset
|
|
239
|
+
...Buffer.from('000018ca', 'hex'), // dstOffset
|
|
240
|
+
]);
|
|
241
|
+
|
|
242
|
+
export function markBytecodeAsAvm(bytecode: Buffer): Buffer {
|
|
243
|
+
return Buffer.concat([bytecode, AVM_MAGIC_SUFFIX]);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
export function isAvmBytecode(bytecode: Buffer): boolean {
|
|
247
|
+
const magicSize = AVM_MAGIC_SUFFIX.length;
|
|
248
|
+
return bytecode.subarray(-magicSize).equals(AVM_MAGIC_SUFFIX);
|
|
249
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type Tx } from '@aztec/circuit-types';
|
|
2
|
+
import { CallRequest } from '@aztec/circuits.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Looks at the side effects of a transaction and returns the highest counter
|
|
6
|
+
* @param tx - A transaction
|
|
7
|
+
* @returns The highest side effect counter in the transaction so far
|
|
8
|
+
*/
|
|
9
|
+
export function lastSideEffectCounter(tx: Tx): number {
|
|
10
|
+
const data = tx.data.forPublic!;
|
|
11
|
+
const sideEffectCounters = [
|
|
12
|
+
...data.endNonRevertibleData.newNoteHashes,
|
|
13
|
+
...data.endNonRevertibleData.newNullifiers,
|
|
14
|
+
...data.endNonRevertibleData.publicCallStack,
|
|
15
|
+
...data.end.newNoteHashes,
|
|
16
|
+
...data.end.newNullifiers,
|
|
17
|
+
...data.end.publicCallStack,
|
|
18
|
+
];
|
|
19
|
+
|
|
20
|
+
let max = 0;
|
|
21
|
+
for (const sideEffect of sideEffectCounters) {
|
|
22
|
+
if (sideEffect instanceof CallRequest) {
|
|
23
|
+
// look at both start and end counters because for enqueued public calls start > 0 while end === 0
|
|
24
|
+
max = Math.max(max, sideEffect.startSideEffectCounter.toNumber(), sideEffect.endSideEffectCounter.toNumber());
|
|
25
|
+
} else {
|
|
26
|
+
max = Math.max(max, sideEffect.counter.toNumber());
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return max;
|
|
31
|
+
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { randomBytes } from '@aztec/foundation/crypto';
|
|
2
|
+
import { createDebugLogger } from '@aztec/foundation/log';
|
|
3
|
+
import { Timer } from '@aztec/foundation/timer';
|
|
2
4
|
import { type NoirCompiledCircuit } from '@aztec/types/noir';
|
|
3
5
|
|
|
4
6
|
import { type WitnessMap } from '@noir-lang/types';
|
|
@@ -7,6 +9,26 @@ import fs from 'fs/promises';
|
|
|
7
9
|
|
|
8
10
|
import { type SimulationProvider } from './simulation_provider.js';
|
|
9
11
|
|
|
12
|
+
const logger = createDebugLogger('aztec:acvm-native');
|
|
13
|
+
|
|
14
|
+
export enum ACVM_RESULT {
|
|
15
|
+
SUCCESS,
|
|
16
|
+
FAILURE,
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export type ACVMSuccess = {
|
|
20
|
+
status: ACVM_RESULT.SUCCESS;
|
|
21
|
+
duration: number;
|
|
22
|
+
witness: Map<number, string>;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export type ACVMFailure = {
|
|
26
|
+
status: ACVM_RESULT.FAILURE;
|
|
27
|
+
reason: string;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export type ACVMResult = ACVMSuccess | ACVMFailure;
|
|
31
|
+
|
|
10
32
|
/**
|
|
11
33
|
* Parses a TOML format witness map string into a Map structure
|
|
12
34
|
* @param outputString - The witness map in TOML format
|
|
@@ -29,7 +51,8 @@ function parseIntoWitnessMap(outputString: string) {
|
|
|
29
51
|
* @param inputWitness - The circuit's input witness
|
|
30
52
|
* @param bytecode - The circuit bytecode
|
|
31
53
|
* @param workingDirectory - A directory to use for temporary files by the ACVM
|
|
32
|
-
* @param pathToAcvm - The path to the
|
|
54
|
+
* @param pathToAcvm - The path to the ACVM binary
|
|
55
|
+
* @param outputFilename - If specified, the output will be stored as a file, encoded using Bincode
|
|
33
56
|
* @returns The completed partial witness outputted from the circuit
|
|
34
57
|
*/
|
|
35
58
|
export async function executeNativeCircuit(
|
|
@@ -37,7 +60,8 @@ export async function executeNativeCircuit(
|
|
|
37
60
|
bytecode: Buffer,
|
|
38
61
|
workingDirectory: string,
|
|
39
62
|
pathToAcvm: string,
|
|
40
|
-
|
|
63
|
+
outputFilename?: string,
|
|
64
|
+
): Promise<ACVMResult> {
|
|
41
65
|
const bytecodeFilename = 'bytecode';
|
|
42
66
|
const witnessFilename = 'input_witness.toml';
|
|
43
67
|
|
|
@@ -47,55 +71,69 @@ export async function executeNativeCircuit(
|
|
|
47
71
|
witnessMap = witnessMap.concat(`${key} = '${value}'\n`);
|
|
48
72
|
});
|
|
49
73
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
await fs.writeFile(`${workingDirectory}/${witnessFilename}`, witnessMap);
|
|
57
|
-
|
|
58
|
-
// Execute the ACVM using the given args
|
|
59
|
-
const args = [
|
|
60
|
-
`execute`,
|
|
61
|
-
`--working-directory`,
|
|
62
|
-
`${workingDirectory}`,
|
|
63
|
-
`--bytecode`,
|
|
64
|
-
`${bytecodeFilename}`,
|
|
65
|
-
`--input-witness`,
|
|
66
|
-
`${witnessFilename}`,
|
|
67
|
-
`--print`,
|
|
68
|
-
];
|
|
69
|
-
const processPromise = new Promise<string>((resolve, reject) => {
|
|
70
|
-
let outputWitness = Buffer.alloc(0);
|
|
71
|
-
let errorBuffer = Buffer.alloc(0);
|
|
72
|
-
const acvm = proc.spawn(pathToAcvm, args);
|
|
73
|
-
acvm.stdout.on('data', data => {
|
|
74
|
-
outputWitness = Buffer.concat([outputWitness, data]);
|
|
75
|
-
});
|
|
76
|
-
acvm.stderr.on('data', data => {
|
|
77
|
-
errorBuffer = Buffer.concat([errorBuffer, data]);
|
|
78
|
-
});
|
|
79
|
-
acvm.on('close', code => {
|
|
80
|
-
if (code === 0) {
|
|
81
|
-
resolve(outputWitness.toString('utf-8'));
|
|
82
|
-
} else {
|
|
83
|
-
reject(errorBuffer.toString('utf-8'));
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
});
|
|
74
|
+
try {
|
|
75
|
+
// Check that the directory exists
|
|
76
|
+
await fs.access(workingDirectory);
|
|
77
|
+
} catch (error) {
|
|
78
|
+
return { status: ACVM_RESULT.FAILURE, reason: `Working directory ${workingDirectory} does not exist` };
|
|
79
|
+
}
|
|
87
80
|
|
|
88
81
|
try {
|
|
82
|
+
// Write the bytecode and input witness to the working directory
|
|
83
|
+
await fs.writeFile(`${workingDirectory}/${bytecodeFilename}`, bytecode);
|
|
84
|
+
await fs.writeFile(`${workingDirectory}/${witnessFilename}`, witnessMap);
|
|
85
|
+
|
|
86
|
+
// Execute the ACVM using the given args
|
|
87
|
+
const args = [
|
|
88
|
+
`execute`,
|
|
89
|
+
`--working-directory`,
|
|
90
|
+
`${workingDirectory}`,
|
|
91
|
+
`--bytecode`,
|
|
92
|
+
`${bytecodeFilename}`,
|
|
93
|
+
`--input-witness`,
|
|
94
|
+
`${witnessFilename}`,
|
|
95
|
+
'--print',
|
|
96
|
+
'--output-witness',
|
|
97
|
+
'output-witness',
|
|
98
|
+
];
|
|
99
|
+
|
|
100
|
+
logger.debug(`Calling ACVM with ${args.join(' ')}`);
|
|
101
|
+
|
|
102
|
+
const processPromise = new Promise<string>((resolve, reject) => {
|
|
103
|
+
let outputWitness = Buffer.alloc(0);
|
|
104
|
+
let errorBuffer = Buffer.alloc(0);
|
|
105
|
+
const acvm = proc.spawn(pathToAcvm, args);
|
|
106
|
+
acvm.stdout.on('data', data => {
|
|
107
|
+
outputWitness = Buffer.concat([outputWitness, data]);
|
|
108
|
+
});
|
|
109
|
+
acvm.stderr.on('data', data => {
|
|
110
|
+
errorBuffer = Buffer.concat([errorBuffer, data]);
|
|
111
|
+
});
|
|
112
|
+
acvm.on('close', code => {
|
|
113
|
+
if (code === 0) {
|
|
114
|
+
resolve(outputWitness.toString('utf-8'));
|
|
115
|
+
} else {
|
|
116
|
+
logger.error(`From ACVM: ${errorBuffer.toString('utf-8')}`);
|
|
117
|
+
reject(errorBuffer.toString('utf-8'));
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
const duration = new Timer();
|
|
89
123
|
const output = await processPromise;
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
124
|
+
if (outputFilename) {
|
|
125
|
+
const outputWitnessFileName = `${workingDirectory}/output-witness.gz`;
|
|
126
|
+
await fs.copyFile(outputWitnessFileName, outputFilename);
|
|
127
|
+
}
|
|
128
|
+
const witness = parseIntoWitnessMap(output);
|
|
129
|
+
return { status: ACVM_RESULT.SUCCESS, witness, duration: duration.ms() };
|
|
130
|
+
} catch (error) {
|
|
131
|
+
return { status: ACVM_RESULT.FAILURE, reason: `${error}` };
|
|
94
132
|
}
|
|
95
133
|
}
|
|
96
134
|
|
|
97
135
|
export class NativeACVMSimulator implements SimulationProvider {
|
|
98
|
-
constructor(private workingDirectory: string, private pathToAcvm: string) {}
|
|
136
|
+
constructor(private workingDirectory: string, private pathToAcvm: string, private witnessFilename?: string) {}
|
|
99
137
|
async simulateCircuit(input: WitnessMap, compiledCircuit: NoirCompiledCircuit): Promise<WitnessMap> {
|
|
100
138
|
// Execute the circuit on those initial witness values
|
|
101
139
|
|
|
@@ -103,10 +141,19 @@ export class NativeACVMSimulator implements SimulationProvider {
|
|
|
103
141
|
const decodedBytecode = Buffer.from(compiledCircuit.bytecode, 'base64');
|
|
104
142
|
|
|
105
143
|
// Provide a unique working directory so we don't get clashes with parallel executions
|
|
106
|
-
const directory = `${this.workingDirectory}/${randomBytes(
|
|
144
|
+
const directory = `${this.workingDirectory}/${randomBytes(8).toString('hex')}`;
|
|
145
|
+
|
|
146
|
+
await fs.mkdir(directory, { recursive: true });
|
|
147
|
+
|
|
107
148
|
// Execute the circuit
|
|
108
|
-
const
|
|
149
|
+
const result = await executeNativeCircuit(input, decodedBytecode, directory, this.pathToAcvm, this.witnessFilename);
|
|
150
|
+
|
|
151
|
+
await fs.rm(directory, { force: true, recursive: true });
|
|
152
|
+
|
|
153
|
+
if (result.status == ACVM_RESULT.FAILURE) {
|
|
154
|
+
throw new Error(`Failed to generate witness: ${result.reason}`);
|
|
155
|
+
}
|
|
109
156
|
|
|
110
|
-
return
|
|
157
|
+
return result.witness;
|
|
111
158
|
}
|
|
112
159
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { foreignCallHandler } from '@aztec/noir-protocol-circuits-types';
|
|
1
2
|
import { type NoirCompiledCircuit } from '@aztec/types/noir';
|
|
2
3
|
|
|
3
4
|
import {
|
|
@@ -26,9 +27,12 @@ export class WASMSimulator implements SimulationProvider {
|
|
|
26
27
|
const decodedBytecode = Buffer.from(compiledCircuit.bytecode, 'base64');
|
|
27
28
|
//
|
|
28
29
|
// Execute the circuit
|
|
29
|
-
const _witnessMap = await executeCircuitWithBlackBoxSolver(
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
const _witnessMap = await executeCircuitWithBlackBoxSolver(
|
|
31
|
+
await getSolver(),
|
|
32
|
+
decodedBytecode,
|
|
33
|
+
input,
|
|
34
|
+
foreignCallHandler, // handle calls to debug_log
|
|
35
|
+
);
|
|
32
36
|
|
|
33
37
|
return _witnessMap;
|
|
34
38
|
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
-
import { type GlobalVariables } from '@aztec/circuits.js';
|
|
3
|
-
import { type PublicExecution, type PublicExecutionResult } from '../public/execution.js';
|
|
4
|
-
import { AvmExecutionEnvironment } from './avm_execution_environment.js';
|
|
5
|
-
import { type AvmContractCallResults } from './avm_message_call_result.js';
|
|
6
|
-
import { type JournalData } from './journal/journal.js';
|
|
7
|
-
/** Temporary Method
|
|
8
|
-
*
|
|
9
|
-
* Convert a PublicExecution(Environment) object to an AvmExecutionEnvironment
|
|
10
|
-
*
|
|
11
|
-
* @param current
|
|
12
|
-
* @param globalVariables
|
|
13
|
-
* @returns
|
|
14
|
-
*/
|
|
15
|
-
export declare function temporaryCreateAvmExecutionEnvironment(current: PublicExecution, globalVariables: GlobalVariables): AvmExecutionEnvironment;
|
|
16
|
-
/** Temporary Method
|
|
17
|
-
*
|
|
18
|
-
* Convert the result of an AVM contract call to a PublicExecutionResult for the public kernel
|
|
19
|
-
*
|
|
20
|
-
* @param execution
|
|
21
|
-
* @param newWorldState
|
|
22
|
-
* @param result
|
|
23
|
-
* @returns
|
|
24
|
-
*/
|
|
25
|
-
export declare function temporaryConvertAvmResults(execution: PublicExecution, newWorldState: JournalData, result: AvmContractCallResults): PublicExecutionResult;
|
|
26
|
-
export declare function isAvmBytecode(bytecode: Buffer): boolean;
|
|
27
|
-
//# sourceMappingURL=temporary_executor_migration.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"temporary_executor_migration.d.ts","sourceRoot":"","sources":["../../src/avm/temporary_executor_migration.ts"],"names":[],"mappings":";AAEA,OAAO,EAGL,KAAK,eAAe,EAKrB,MAAM,oBAAoB,CAAC;AAI5B,OAAO,EAAE,KAAK,eAAe,EAAE,KAAK,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC1F,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AACzE,OAAO,EAAE,KAAK,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAC3E,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAGxD;;;;;;;GAOG;AACH,wBAAgB,sCAAsC,CACpD,OAAO,EAAE,eAAe,EACxB,eAAe,EAAE,eAAe,GAC/B,uBAAuB,CAkBzB;AAED;;;;;;;;GAQG;AACH,wBAAgB,0BAA0B,CACxC,SAAS,EAAE,eAAe,EAC1B,aAAa,EAAE,WAAW,EAC1B,MAAM,EAAE,sBAAsB,GAC7B,qBAAqB,CA4DvB;AAED,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CASvD"}
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
// All code in this file needs to die once the public executor is phased out.
|
|
2
|
-
import { UnencryptedFunctionL2Logs } from '@aztec/circuit-types';
|
|
3
|
-
import { ContractStorageRead, ContractStorageUpdateRequest, L2ToL1Message, SideEffect, SideEffectLinkedToNoteHash, } from '@aztec/circuits.js';
|
|
4
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
5
|
-
import { createSimulationError } from '../common/errors.js';
|
|
6
|
-
import { AvmExecutionEnvironment } from './avm_execution_environment.js';
|
|
7
|
-
import { Mov } from './opcodes/memory.js';
|
|
8
|
-
/** Temporary Method
|
|
9
|
-
*
|
|
10
|
-
* Convert a PublicExecution(Environment) object to an AvmExecutionEnvironment
|
|
11
|
-
*
|
|
12
|
-
* @param current
|
|
13
|
-
* @param globalVariables
|
|
14
|
-
* @returns
|
|
15
|
-
*/
|
|
16
|
-
export function temporaryCreateAvmExecutionEnvironment(current, globalVariables) {
|
|
17
|
-
// Function selector is included temporarily until noir codegens public contract bytecode in a single blob
|
|
18
|
-
return new AvmExecutionEnvironment(current.contractAddress, current.callContext.storageContractAddress, current.callContext.msgSender, // TODO: origin is not available
|
|
19
|
-
current.callContext.msgSender, current.callContext.portalContractAddress,
|
|
20
|
-
/*feePerL1Gas=*/ Fr.zero(),
|
|
21
|
-
/*feePerL2Gas=*/ Fr.zero(),
|
|
22
|
-
/*feePerDaGas=*/ Fr.zero(),
|
|
23
|
-
/*contractCallDepth=*/ Fr.zero(), globalVariables, current.callContext.isStaticCall, current.callContext.isDelegateCall, current.args, current.functionData.selector);
|
|
24
|
-
}
|
|
25
|
-
/** Temporary Method
|
|
26
|
-
*
|
|
27
|
-
* Convert the result of an AVM contract call to a PublicExecutionResult for the public kernel
|
|
28
|
-
*
|
|
29
|
-
* @param execution
|
|
30
|
-
* @param newWorldState
|
|
31
|
-
* @param result
|
|
32
|
-
* @returns
|
|
33
|
-
*/
|
|
34
|
-
export function temporaryConvertAvmResults(execution, newWorldState, result) {
|
|
35
|
-
const newNoteHashes = newWorldState.newNoteHashes.map(noteHash => new SideEffect(noteHash, Fr.zero()));
|
|
36
|
-
const contractStorageReads = [];
|
|
37
|
-
const reduceStorageReadRequests = (contractAddress, storageReads) => {
|
|
38
|
-
return storageReads.forEach((innerArray, key) => {
|
|
39
|
-
innerArray.forEach(value => {
|
|
40
|
-
contractStorageReads.push(new ContractStorageRead(new Fr(key), new Fr(value), 0));
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
};
|
|
44
|
-
newWorldState.storageReads.forEach((storageMap, address) => reduceStorageReadRequests(address, storageMap));
|
|
45
|
-
const contractStorageUpdateRequests = [];
|
|
46
|
-
const reduceStorageUpdateRequests = (contractAddress, storageUpdateRequests) => {
|
|
47
|
-
return storageUpdateRequests.forEach((innerArray, key) => {
|
|
48
|
-
innerArray.forEach(value => {
|
|
49
|
-
contractStorageUpdateRequests.push(new ContractStorageUpdateRequest(new Fr(key), new Fr(value), 0));
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
};
|
|
53
|
-
newWorldState.storageWrites.forEach((storageMap, address) => reduceStorageUpdateRequests(address, storageMap));
|
|
54
|
-
const returnValues = result.output;
|
|
55
|
-
// TODO(follow up in pr tree): NOT SUPPORTED YET, make sure hashing and log resolution is done correctly
|
|
56
|
-
// Disabled.
|
|
57
|
-
const nestedExecutions = [];
|
|
58
|
-
const nullifierReadRequests = [];
|
|
59
|
-
const nullifierNonExistentReadRequests = [];
|
|
60
|
-
const newNullifiers = newWorldState.newNullifiers.map((nullifier, i) => new SideEffectLinkedToNoteHash(nullifier.toField(), Fr.zero(), new Fr(i + 1)));
|
|
61
|
-
const unencryptedLogs = UnencryptedFunctionL2Logs.empty();
|
|
62
|
-
const newL2ToL1Messages = newWorldState.newL1Messages.map(() => L2ToL1Message.empty());
|
|
63
|
-
// TODO keep track of side effect counters
|
|
64
|
-
const startSideEffectCounter = Fr.ZERO;
|
|
65
|
-
const endSideEffectCounter = Fr.ZERO;
|
|
66
|
-
return {
|
|
67
|
-
execution,
|
|
68
|
-
nullifierReadRequests,
|
|
69
|
-
nullifierNonExistentReadRequests,
|
|
70
|
-
newNoteHashes,
|
|
71
|
-
newL2ToL1Messages,
|
|
72
|
-
startSideEffectCounter,
|
|
73
|
-
endSideEffectCounter,
|
|
74
|
-
newNullifiers,
|
|
75
|
-
contractStorageReads,
|
|
76
|
-
contractStorageUpdateRequests,
|
|
77
|
-
returnValues,
|
|
78
|
-
nestedExecutions,
|
|
79
|
-
unencryptedLogs,
|
|
80
|
-
reverted: result.reverted,
|
|
81
|
-
revertReason: result.revertReason ? createSimulationError(result.revertReason) : undefined,
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
export function isAvmBytecode(bytecode) {
|
|
85
|
-
const magicBuf = Buffer.from([
|
|
86
|
-
Mov.opcode, // opcode
|
|
87
|
-
0x00, // indirect
|
|
88
|
-
...Buffer.from('000018ca', 'hex'), // srcOffset
|
|
89
|
-
...Buffer.from('000018ca', 'hex'), // dstOffset
|
|
90
|
-
]);
|
|
91
|
-
const magicSize = magicBuf.length;
|
|
92
|
-
return bytecode.subarray(-magicSize).equals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FBQyxxQkFBcUIsQ0FBQyxNQUFNLENBQUMsWUFBWSxDQUFDLENBQUMsQ0FBQyxDQUFDLFNBQVM7S0FDM0YsQ0FBQztBQUNKLENBQUM7QUFFRCxNQUFNLFVBQVUsYUFBYSxDQUFDLFFBQWdCO0lBQzVDLE1BQU0sUUFBUSxHQUFHLE1BQU0sQ0FBQyxJQUFJLENBQUM7UUFDM0IsR0FBRyxDQUFDLE1BQU0sRUFBRSxTQUFTO1FBQ3JCLElBQUksRUFBRSxXQUFXO1FBQ2pCLEdBQUcsTUFBTSxDQUFDLElBQUksQ0FBQyxVQUFVLEVBQUUsS0FBSyxDQUFDLEVBQUUsWUFBWTtRQUMvQyxHQUFHLE1BQU0sQ0FBQyxJQUFJLENBQUMsVUFBVSxFQUFFLEtBQUssQ0FBQyxFQUFFLFlBQVk7S0FDaEQsQ0FBQyxDQUFDO0lBQ0gsTUFBTSxTQUFTLEdBQUcsUUFBUSxDQUFDLE1BQU0sQ0FBQztJQUNsQyxPQUFPLFFBQVEsQ0FBQyxRQUFRLENBQUMsQ0FBQyxTQUFTLENBQUMsQ0FBQyxNQUFNLENBQUMsUUFBUSxDQUFDLENBQUM7QUFDeEQsQ0FBQyJ9
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { PackedArguments } from '@aztec/circuit-types';
|
|
2
|
-
import { Fr } from '@aztec/circuits.js';
|
|
3
|
-
/**
|
|
4
|
-
* A cache for packed arguments during transaction execution.
|
|
5
|
-
*/
|
|
6
|
-
export declare class PackedArgsCache {
|
|
7
|
-
private cache;
|
|
8
|
-
constructor(initialArguments?: PackedArguments[]);
|
|
9
|
-
/**
|
|
10
|
-
* Creates a new packed arguments cache.
|
|
11
|
-
* @param initialArguments - The initial arguments to add to the cache.
|
|
12
|
-
* @returns The new packed arguments cache.
|
|
13
|
-
*/
|
|
14
|
-
static create(initialArguments?: PackedArguments[]): PackedArgsCache;
|
|
15
|
-
/**
|
|
16
|
-
* Unpacks packed arguments.
|
|
17
|
-
* @param hash - The hash of the packed arguments.
|
|
18
|
-
* @returns The unpacked arguments.
|
|
19
|
-
*/
|
|
20
|
-
unpack(hash: Fr): Fr[];
|
|
21
|
-
/**
|
|
22
|
-
* Packs arguments.
|
|
23
|
-
* @param args - The arguments to pack.
|
|
24
|
-
* @returns The hash of the packed arguments.
|
|
25
|
-
*/
|
|
26
|
-
pack(args: Fr[]): Fr;
|
|
27
|
-
}
|
|
28
|
-
//# sourceMappingURL=packed_args_cache.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"packed_args_cache.d.ts","sourceRoot":"","sources":["../../src/common/packed_args_cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,EAAE,EAAE,MAAM,oBAAoB,CAAC;AAExC;;GAEG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,KAAK,CAAoB;gBAErB,gBAAgB,GAAE,eAAe,EAAO;IAOpD;;;;OAIG;WACW,MAAM,CAAC,gBAAgB,GAAE,eAAe,EAAO;IAI7D;;;;OAIG;IACI,MAAM,CAAC,IAAI,EAAE,EAAE,GAAG,EAAE,EAAE;IAW7B;;;;OAIG;IACI,IAAI,CAAC,IAAI,EAAE,EAAE,EAAE;CAQvB"}
|