@aztec/simulator 0.60.0 → 0.62.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/oracle/oracle.d.ts +3 -0
- package/dest/acvm/oracle/oracle.d.ts.map +1 -1
- package/dest/acvm/oracle/oracle.js +12 -1
- package/dest/acvm/oracle/typed_oracle.d.ts +4 -1
- package/dest/acvm/oracle/typed_oracle.d.ts.map +1 -1
- package/dest/acvm/oracle/typed_oracle.js +10 -1
- package/dest/avm/avm_gas.d.ts.map +1 -1
- package/dest/avm/avm_gas.js +8 -5
- 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_simulator.d.ts +15 -0
- package/dest/avm/avm_simulator.d.ts.map +1 -1
- package/dest/avm/avm_simulator.js +45 -4
- package/dest/avm/fixtures/index.d.ts +1 -1
- package/dest/avm/fixtures/index.d.ts.map +1 -1
- package/dest/avm/fixtures/index.js +7 -7
- package/dest/avm/journal/journal.d.ts +5 -6
- package/dest/avm/journal/journal.d.ts.map +1 -1
- package/dest/avm/journal/journal.js +42 -17
- 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/control_flow.js +5 -5
- 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 +1 -1
- package/dest/avm/opcodes/environment_getters.d.ts.map +1 -1
- package/dest/avm/opcodes/environment_getters.js +5 -1
- 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/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/serialization/bytecode_serialization.d.ts.map +1 -1
- package/dest/avm/serialization/bytecode_serialization.js +5 -3
- package/dest/avm/serialization/instruction_serialization.d.ts +36 -34
- package/dest/avm/serialization/instruction_serialization.d.ts.map +1 -1
- package/dest/avm/serialization/instruction_serialization.js +37 -35
- package/dest/avm/test_utils.d.ts +2 -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 +1 -8
- package/dest/client/client_execution_context.d.ts.map +1 -1
- package/dest/client/client_execution_context.js +4 -18
- package/dest/client/db_oracle.d.ts +24 -1
- package/dest/client/db_oracle.d.ts.map +1 -1
- package/dest/client/db_oracle.js +1 -1
- 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/public/dual_side_effect_trace.d.ts +3 -5
- package/dest/public/dual_side_effect_trace.d.ts.map +1 -1
- package/dest/public/dual_side_effect_trace.js +8 -4
- package/dest/public/enqueued_call_side_effect_trace.d.ts +4 -6
- package/dest/public/enqueued_call_side_effect_trace.d.ts.map +1 -1
- package/dest/public/enqueued_call_side_effect_trace.js +19 -7
- package/dest/public/enqueued_call_simulator.d.ts +2 -2
- package/dest/public/enqueued_call_simulator.d.ts.map +1 -1
- package/dest/public/enqueued_call_simulator.js +21 -29
- 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 +18 -25
- package/dest/public/public_db_sources.d.ts.map +1 -1
- package/dest/public/public_db_sources.js +10 -15
- 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 +4 -3
- package/dest/public/side_effect_trace.d.ts.map +1 -1
- package/dest/public/side_effect_trace.js +27 -16
- package/dest/public/side_effect_trace_interface.d.ts +3 -3
- package/dest/public/side_effect_trace_interface.d.ts.map +1 -1
- package/dest/test/utils.d.ts +2 -2
- package/dest/test/utils.d.ts.map +1 -1
- package/dest/test/utils.js +4 -4
- package/package.json +9 -9
- package/src/acvm/oracle/oracle.ts +20 -0
- package/src/acvm/oracle/typed_oracle.ts +13 -0
- package/src/avm/avm_gas.ts +7 -4
- package/src/avm/avm_machine_state.ts +2 -0
- package/src/avm/avm_simulator.ts +69 -6
- package/src/avm/fixtures/index.ts +7 -7
- package/src/avm/journal/journal.ts +62 -19
- package/src/avm/opcodes/contract.ts +45 -21
- package/src/avm/opcodes/control_flow.ts +5 -5
- package/src/avm/opcodes/conversion.ts +9 -6
- package/src/avm/opcodes/environment_getters.ts +7 -2
- package/src/avm/opcodes/external_calls.ts +21 -45
- package/src/avm/opcodes/memory.ts +69 -2
- package/src/avm/serialization/bytecode_serialization.ts +6 -2
- package/src/avm/serialization/instruction_serialization.ts +5 -3
- package/src/avm/test_utils.ts +5 -1
- package/src/client/client_execution_context.ts +4 -27
- package/src/client/db_oracle.ts +38 -0
- package/src/client/view_data_oracle.ts +31 -1
- package/src/common/index.ts +0 -1
- package/src/public/dual_side_effect_trace.ts +20 -6
- package/src/public/enqueued_call_side_effect_trace.ts +46 -8
- package/src/public/enqueued_call_simulator.ts +42 -26
- package/src/public/enqueued_calls_processor.ts +26 -38
- package/src/public/public_db_sources.ts +10 -15
- 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 +54 -15
- package/src/public/side_effect_trace_interface.ts +9 -4
- package/src/test/utils.ts +9 -2
- 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/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
|
@@ -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,8 +93,6 @@ export class PublicSideEffectTrace implements PublicSideEffectTraceInterface {
|
|
|
90
93
|
this.sideEffectCounter++;
|
|
91
94
|
}
|
|
92
95
|
|
|
93
|
-
// TODO(dbanks12): checks against tx-wide limit need access to parent trace's length
|
|
94
|
-
|
|
95
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) {
|
|
@@ -103,7 +104,7 @@ export class PublicSideEffectTrace implements PublicSideEffectTraceInterface {
|
|
|
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
|
|
|
@@ -114,7 +115,7 @@ export class PublicSideEffectTrace implements PublicSideEffectTraceInterface {
|
|
|
114
115
|
this.contractStorageUpdateRequests.push(
|
|
115
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
|
|
|
@@ -136,7 +137,7 @@ export class PublicSideEffectTrace implements PublicSideEffectTraceInterface {
|
|
|
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
|
|
|
@@ -161,7 +162,7 @@ export class PublicSideEffectTrace implements PublicSideEffectTraceInterface {
|
|
|
161
162
|
this.avmCircuitHints.nullifierExists.items.push(
|
|
162
163
|
new AvmKeyValueHint(/*key=*/ new Fr(this.sideEffectCounter), /*value=*/ new Fr(exists ? 1 : 0)),
|
|
163
164
|
);
|
|
164
|
-
this.
|
|
165
|
+
this.log.debug(`NULLIFIER_EXISTS cnt: ${this.sideEffectCounter}`);
|
|
165
166
|
this.incrementSideEffectCounter();
|
|
166
167
|
}
|
|
167
168
|
|
|
@@ -171,7 +172,7 @@ export class PublicSideEffectTrace implements PublicSideEffectTraceInterface {
|
|
|
171
172
|
throw new SideEffectLimitReachedError('nullifier', MAX_NULLIFIERS_PER_TX);
|
|
172
173
|
}
|
|
173
174
|
this.nullifiers.push(new Nullifier(nullifier, this.sideEffectCounter, /*noteHash=*/ Fr.ZERO));
|
|
174
|
-
this.
|
|
175
|
+
this.log.debug(`NEW_NULLIFIER cnt: ${this.sideEffectCounter}`);
|
|
175
176
|
this.incrementSideEffectCounter();
|
|
176
177
|
}
|
|
177
178
|
|
|
@@ -194,7 +195,7 @@ export class PublicSideEffectTrace implements PublicSideEffectTraceInterface {
|
|
|
194
195
|
}
|
|
195
196
|
const recipientAddress = EthAddress.fromField(recipient);
|
|
196
197
|
this.newL2ToL1Messages.push(new L2ToL1Message(recipientAddress, content, this.sideEffectCounter));
|
|
197
|
-
this.
|
|
198
|
+
this.log.debug(`NEW_L2_TO_L1_MSG cnt: ${this.sideEffectCounter}`);
|
|
198
199
|
this.incrementSideEffectCounter();
|
|
199
200
|
}
|
|
200
201
|
|
|
@@ -212,18 +213,21 @@ export class PublicSideEffectTrace implements PublicSideEffectTraceInterface {
|
|
|
212
213
|
// This length is for charging DA and is checked on-chain - has to be length of log preimage + 4 bytes.
|
|
213
214
|
// The .length call also has a +4 but that is unrelated
|
|
214
215
|
this.unencryptedLogsHashes.push(new LogHash(basicLogHash, this.sideEffectCounter, new Fr(ulog.length + 4)));
|
|
215
|
-
this.
|
|
216
|
+
this.log.debug(`NEW_UNENCRYPTED_LOG cnt: ${this.sideEffectCounter}`);
|
|
216
217
|
this.incrementSideEffectCounter();
|
|
217
218
|
}
|
|
218
219
|
|
|
219
|
-
public traceGetContractInstance(
|
|
220
|
+
public traceGetContractInstance(
|
|
221
|
+
contractAddress: Fr,
|
|
222
|
+
exists: boolean,
|
|
223
|
+
instance: SerializableContractInstance = SerializableContractInstance.default(),
|
|
224
|
+
) {
|
|
220
225
|
this.enforceLimitOnNullifierChecks('(contract address nullifier from GETCONTRACTINSTANCE)');
|
|
221
|
-
// TODO(dbanks12): should emit a nullifier read request
|
|
222
226
|
|
|
223
227
|
this.avmCircuitHints.contractInstances.items.push(
|
|
224
228
|
new AvmContractInstanceHint(
|
|
225
|
-
|
|
226
|
-
|
|
229
|
+
contractAddress,
|
|
230
|
+
exists,
|
|
227
231
|
instance.salt,
|
|
228
232
|
instance.deployer,
|
|
229
233
|
instance.contractClassId,
|
|
@@ -231,10 +235,44 @@ export class PublicSideEffectTrace implements PublicSideEffectTraceInterface {
|
|
|
231
235
|
instance.publicKeys,
|
|
232
236
|
),
|
|
233
237
|
);
|
|
234
|
-
this.
|
|
238
|
+
this.log.debug(`CONTRACT_INSTANCE cnt: ${this.sideEffectCounter}`);
|
|
235
239
|
this.incrementSideEffectCounter();
|
|
236
240
|
}
|
|
237
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
|
+
|
|
238
276
|
/**
|
|
239
277
|
* Trace a nested call.
|
|
240
278
|
* Accept some results from a finished nested call's trace into this one.
|
|
@@ -288,6 +326,7 @@ export class PublicSideEffectTrace implements PublicSideEffectTraceInterface {
|
|
|
288
326
|
result.returnValues,
|
|
289
327
|
gasUsed,
|
|
290
328
|
result.endSideEffectCounter,
|
|
329
|
+
nestedEnvironment.address,
|
|
291
330
|
),
|
|
292
331
|
);
|
|
293
332
|
}
|
|
@@ -1,9 +1,8 @@
|
|
|
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;
|
|
@@ -18,8 +17,14 @@ export interface PublicSideEffectTraceInterface {
|
|
|
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,
|
package/src/test/utils.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { L1Actor, L1ToL2Message, L2Actor } from '@aztec/circuit-types';
|
|
2
|
-
import { type AztecAddress, EthAddress,
|
|
2
|
+
import { type AztecAddress, EthAddress, Fr } from '@aztec/circuits.js';
|
|
3
3
|
import { computeSecretHash } from '@aztec/circuits.js/hash';
|
|
4
4
|
import { sha256ToField } from '@aztec/foundation/crypto';
|
|
5
5
|
|
|
@@ -16,6 +16,7 @@ export const buildL1ToL2Message = (
|
|
|
16
16
|
contentPreimage: Fr[],
|
|
17
17
|
targetContract: AztecAddress,
|
|
18
18
|
secret: Fr,
|
|
19
|
+
msgIndex: Fr | number,
|
|
19
20
|
) => {
|
|
20
21
|
// Write the selector into a buffer.
|
|
21
22
|
const selectorBuf = Buffer.from(selector, 'hex');
|
|
@@ -23,5 +24,11 @@ export const buildL1ToL2Message = (
|
|
|
23
24
|
const content = sha256ToField([selectorBuf, ...contentPreimage]);
|
|
24
25
|
const secretHash = computeSecretHash(secret);
|
|
25
26
|
|
|
26
|
-
return new L1ToL2Message(
|
|
27
|
+
return new L1ToL2Message(
|
|
28
|
+
new L1Actor(EthAddress.random(), 1),
|
|
29
|
+
new L2Actor(targetContract, 1),
|
|
30
|
+
content,
|
|
31
|
+
secretHash,
|
|
32
|
+
new Fr(msgIndex),
|
|
33
|
+
);
|
|
27
34
|
};
|
|
@@ -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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdF91dGlscy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9jbGllbnQvdGVzdF91dGlscy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsRUFBRSxFQUFFLEVBQUUsRUFBRSxLQUFLLEVBQUUsTUFBTSxvQkFBb0IsQ0FBQztBQUNuRCxPQUFPLEVBQUUsUUFBUSxFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFFM0Qsb0VBQW9FO0FBQ3BFLE1BQU0sVUFBVSxHQUFHO0lBQ2pCLElBQUksS0FBSyxDQUNQLElBQUksRUFBRSxDQUFDLG1FQUFtRSxDQUFDLEVBQzNFLElBQUksRUFBRSxDQUFDLG1FQUFtRSxDQUFDLEVBQzNFLEtBQUssQ0FDTjtJQUNELElBQUksS0FBSyxDQUNQLElBQUksRUFBRSxDQUFDLG1FQUFtRSxDQUFDLEVBQzNFLElBQUksRUFBRSxDQUFDLG1FQUFtRSxDQUFDLEVBQzNFLEtBQUssQ0FDTjtJQUNELElBQUksS0FBSyxDQUNQLElBQUksRUFBRSxDQUFDLG1FQUFtRSxDQUFDLEVBQzNFLElBQUksRUFBRSxDQUFDL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FBRSxDQUFDLENBQUMsQ0FDL0QsQ0FBQztJQUVKLE1BQU0sU0FBUyxHQUFHLFFBQVEsQ0FBQyxHQUFHLENBQUMsTUFBTSxFQUFFLElBQUksRUFBRSxDQUFDLFdBQVcsQ0FBQyxRQUFRLEVBQUUsQ0FBQyxDQUFDLENBQUM7SUFDdkUsTUFBTSxlQUFlLEdBQUcsUUFBUSxDQUFDLEdBQUcsQ0FBQyw2QkFBNkIsRUFBRSxTQUFTLENBQUMsQ0FBQztJQUMvRSxPQUFPLGVBQWUsQ0FBQyxDQUFDLENBQUM7QUFDM0IsQ0FBQyJ9
|
|
@@ -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=
|
package/dest/rollup/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/rollup/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC"}
|
package/dest/rollup/index.js
DELETED
package/dest/rollup/rollup.d.ts
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import { type BaseOrMergeRollupPublicInputs, type BaseParityInputs, type BaseRollupInputs, type BlockMergeRollupInputs, type BlockRootOrBlockMergePublicInputs, type BlockRootRollupInputs, type MergeRollupInputs, type ParityPublicInputs, type RootParityInputs, type RootRollupInputs, type RootRollupPublicInputs } from '@aztec/circuits.js';
|
|
2
|
-
import { type SimulationProvider } from '../providers/simulation_provider.js';
|
|
3
|
-
/**
|
|
4
|
-
* Circuit simulator for the rollup circuits.
|
|
5
|
-
*/
|
|
6
|
-
export interface RollupSimulator {
|
|
7
|
-
/**
|
|
8
|
-
* Simulates the base parity circuit from its inputs.
|
|
9
|
-
* @param inputs - Inputs to the circuit.
|
|
10
|
-
* @returns The public inputs of the parity circuit.
|
|
11
|
-
*/
|
|
12
|
-
baseParityCircuit(inputs: BaseParityInputs): Promise<ParityPublicInputs>;
|
|
13
|
-
/**
|
|
14
|
-
* Simulates the root parity circuit from its inputs.
|
|
15
|
-
* @param inputs - Inputs to the circuit.
|
|
16
|
-
* @returns The public inputs of the parity circuit.
|
|
17
|
-
*/
|
|
18
|
-
rootParityCircuit(inputs: RootParityInputs): Promise<ParityPublicInputs>;
|
|
19
|
-
/**
|
|
20
|
-
* Simulates the base rollup circuit from its inputs.
|
|
21
|
-
* @param input - Inputs to the circuit.
|
|
22
|
-
* @returns The public inputs as outputs of the simulation.
|
|
23
|
-
*/
|
|
24
|
-
baseRollupCircuit(input: BaseRollupInputs): Promise<BaseOrMergeRollupPublicInputs>;
|
|
25
|
-
/**
|
|
26
|
-
* Simulates the merge rollup circuit from its inputs.
|
|
27
|
-
* @param input - Inputs to the circuit.
|
|
28
|
-
* @returns The public inputs as outputs of the simulation.
|
|
29
|
-
*/
|
|
30
|
-
mergeRollupCircuit(input: MergeRollupInputs): Promise<BaseOrMergeRollupPublicInputs>;
|
|
31
|
-
/**
|
|
32
|
-
* Simulates the block root rollup circuit from its inputs.
|
|
33
|
-
* @param input - Inputs to the circuit.
|
|
34
|
-
* @returns The public inputs as outputs of the simulation.
|
|
35
|
-
*/
|
|
36
|
-
blockRootRollupCircuit(input: BlockRootRollupInputs): Promise<BlockRootOrBlockMergePublicInputs>;
|
|
37
|
-
/**
|
|
38
|
-
* Simulates the block merge rollup circuit from its inputs.
|
|
39
|
-
* @param input - Inputs to the circuit.
|
|
40
|
-
* @returns The public inputs as outputs of the simulation.
|
|
41
|
-
*/
|
|
42
|
-
blockMergeRollupCircuit(input: BlockMergeRollupInputs): Promise<BlockRootOrBlockMergePublicInputs>;
|
|
43
|
-
/**
|
|
44
|
-
* Simulates the root rollup circuit from its inputs.
|
|
45
|
-
* @param input - Inputs to the circuit.
|
|
46
|
-
* @returns The public inputs as outputs of the simulation.
|
|
47
|
-
*/
|
|
48
|
-
rootRollupCircuit(input: RootRollupInputs): Promise<RootRollupPublicInputs>;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Implements the rollup circuit simulator.
|
|
52
|
-
*/
|
|
53
|
-
export declare class RealRollupCircuitSimulator implements RollupSimulator {
|
|
54
|
-
private simulationProvider;
|
|
55
|
-
private log;
|
|
56
|
-
private wasmSimulator;
|
|
57
|
-
constructor(simulationProvider: SimulationProvider);
|
|
58
|
-
/**
|
|
59
|
-
* Simulates the base parity circuit from its inputs.
|
|
60
|
-
* @param inputs - Inputs to the circuit.
|
|
61
|
-
* @returns The public inputs of the parity circuit.
|
|
62
|
-
*/
|
|
63
|
-
baseParityCircuit(inputs: BaseParityInputs): Promise<ParityPublicInputs>;
|
|
64
|
-
/**
|
|
65
|
-
* Simulates the root parity circuit from its inputs.
|
|
66
|
-
* @param inputs - Inputs to the circuit.
|
|
67
|
-
* @returns The public inputs of the parity circuit.
|
|
68
|
-
*/
|
|
69
|
-
rootParityCircuit(inputs: RootParityInputs): Promise<ParityPublicInputs>;
|
|
70
|
-
/**
|
|
71
|
-
* Simulates the base rollup circuit from its inputs.
|
|
72
|
-
* @param input - Inputs to the circuit.
|
|
73
|
-
* @returns The public inputs as outputs of the simulation.
|
|
74
|
-
*/
|
|
75
|
-
baseRollupCircuit(input: BaseRollupInputs): Promise<BaseOrMergeRollupPublicInputs>;
|
|
76
|
-
/**
|
|
77
|
-
* Simulates the merge rollup circuit from its inputs.
|
|
78
|
-
* @param input - Inputs to the circuit.
|
|
79
|
-
* @returns The public inputs as outputs of the simulation.
|
|
80
|
-
*/
|
|
81
|
-
mergeRollupCircuit(input: MergeRollupInputs): Promise<BaseOrMergeRollupPublicInputs>;
|
|
82
|
-
/**
|
|
83
|
-
* Simulates the block root rollup circuit from its inputs.
|
|
84
|
-
* @param input - Inputs to the circuit.
|
|
85
|
-
* @returns The public inputs as outputs of the simulation.
|
|
86
|
-
*/
|
|
87
|
-
blockRootRollupCircuit(input: BlockRootRollupInputs): Promise<BlockRootOrBlockMergePublicInputs>;
|
|
88
|
-
/**
|
|
89
|
-
* Simulates the block merge rollup circuit from its inputs.
|
|
90
|
-
* @param input - Inputs to the circuit.
|
|
91
|
-
* @returns The public inputs as outputs of the simulation.
|
|
92
|
-
*/
|
|
93
|
-
blockMergeRollupCircuit(input: BlockMergeRollupInputs): Promise<BlockRootOrBlockMergePublicInputs>;
|
|
94
|
-
/**
|
|
95
|
-
* Simulates the root rollup circuit from its inputs.
|
|
96
|
-
* @param input - Inputs to the circuit.
|
|
97
|
-
* @returns The public inputs as outputs of the simulation.
|
|
98
|
-
*/
|
|
99
|
-
rootRollupCircuit(input: RootRollupInputs): Promise<RootRollupPublicInputs>;
|
|
100
|
-
}
|
|
101
|
-
//# sourceMappingURL=rollup.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rollup.d.ts","sourceRoot":"","sources":["../../src/rollup/rollup.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,6BAA6B,EAClC,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,EAC3B,KAAK,iCAAiC,EACtC,KAAK,qBAAqB,EAC1B,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,EAC5B,MAAM,oBAAoB,CAAC;AAsB5B,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AAE9E;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;;;OAIG;IACH,iBAAiB,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;IACzE;;;;OAIG;IACH,i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iCAAiC,CAAC;IAa/G;;;;OAIG;IACU,iBAAiB,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,sBAAsB,CAAC;CAkBzF"}
|
package/dest/rollup/rollup.js
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import { createDebugLogger } from '@aztec/foundation/log';
|
|
2
|
-
import { elapsed } from '@aztec/foundation/timer';
|
|
3
|
-
import { SimulatedServerCircuitArtifacts, convertBaseParityInputsToWitnessMap, convertBaseParityOutputsFromWitnessMap, convertBlockMergeRollupInputsToWitnessMap, convertBlockMergeRollupOutputsFromWitnessMap, convertBlockRootRollupInputsToWitnessMap, convertBlockRootRollupOutputsFromWitnessMap, convertMergeRollupInputsToWitnessMap, convertMergeRollupOutputsFromWitnessMap, convertRootParityInputsToWitnessMap, convertRootParityOutputsFromWitnessMap, convertRootRollupInputsToWitnessMap, convertRootRollupOutputsFromWitnessMap, convertSimulatedBaseRollupInputsToWitnessMap, convertSimulatedBaseRollupOutputsFromWitnessMap, } from '@aztec/noir-protocol-circuits-types';
|
|
4
|
-
import { WASMSimulator } from '../providers/acvm_wasm.js';
|
|
5
|
-
/**
|
|
6
|
-
* Implements the rollup circuit simulator.
|
|
7
|
-
*/
|
|
8
|
-
export class RealRollupCircuitSimulator {
|
|
9
|
-
constructor(simulationProvider) {
|
|
10
|
-
this.simulationProvider = simulationProvider;
|
|
11
|
-
this.log = createDebugLogger('aztec:rollup-simulator');
|
|
12
|
-
// Some circuits are so small it is faster to use WASM
|
|
13
|
-
this.wasmSimulator = new WASMSimulator();
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Simulates the base parity circuit from its inputs.
|
|
17
|
-
* @param inputs - Inputs to the circuit.
|
|
18
|
-
* @returns The public inputs of the parity circuit.
|
|
19
|
-
*/
|
|
20
|
-
async baseParityCircuit(inputs) {
|
|
21
|
-
const witnessMap = convertBaseParityInputsToWitnessMap(inputs);
|
|
22
|
-
const witness = await this.simulationProvider.simulateCircuit(witnessMap, SimulatedServerCircuitArtifacts.BaseParityArtifact);
|
|
23
|
-
const result = convertBaseParityOutputsFromWitnessMap(witness);
|
|
24
|
-
return Promise.resolve(result);
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Simulates the root parity circuit from its inputs.
|
|
28
|
-
* @param inputs - Inputs to the circuit.
|
|
29
|
-
* @returns The public inputs of the parity circuit.
|
|
30
|
-
*/
|
|
31
|
-
async rootParityCircuit(inputs) {
|
|
32
|
-
const witnessMap = convertRootParityInputsToWitnessMap(inputs);
|
|
33
|
-
const witness = await this.simulationProvider.simulateCircuit(witnessMap, SimulatedServerCircuitArtifacts.RootParityArtifact);
|
|
34
|
-
const result = convertRootParityOutputsFromWitnessMap(witness);
|
|
35
|
-
return Promise.resolve(result);
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Simulates the base rollup circuit from its inputs.
|
|
39
|
-
* @param input - Inputs to the circuit.
|
|
40
|
-
* @returns The public inputs as outputs of the simulation.
|
|
41
|
-
*/
|
|
42
|
-
async baseRollupCircuit(input) {
|
|
43
|
-
const witnessMap = convertSimulatedBaseRollupInputsToWitnessMap(input);
|
|
44
|
-
const witness = await this.simulationProvider.simulateCircuit(witnessMap, SimulatedServerCircuitArtifacts.BaseRollupArtifact);
|
|
45
|
-
const result = convertSimulatedBaseRollupOutputsFromWitnessMap(witness);
|
|
46
|
-
return Promise.resolve(result);
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Simulates the merge rollup circuit from its inputs.
|
|
50
|
-
* @param input - Inputs to the circuit.
|
|
51
|
-
* @returns The public inputs as outputs of the simulation.
|
|
52
|
-
*/
|
|
53
|
-
async mergeRollupCircuit(input) {
|
|
54
|
-
const witnessMap = convertMergeRollupInputsToWitnessMap(input);
|
|
55
|
-
const witness = await this.wasmSimulator.simulateCircuit(witnessMap, SimulatedServerCircuitArtifacts.MergeRollupArtifact);
|
|
56
|
-
const result = convertMergeRollupOutputsFromWitnessMap(witness);
|
|
57
|
-
return result;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Simulates the block root rollup circuit from its inputs.
|
|
61
|
-
* @param input - Inputs to the circuit.
|
|
62
|
-
* @returns The public inputs as outputs of the simulation.
|
|
63
|
-
*/
|
|
64
|
-
async blockRootRollupCircuit(input) {
|
|
65
|
-
const witnessMap = convertBlockRootRollupInputsToWitnessMap(input);
|
|
66
|
-
const witness = await this.wasmSimulator.simulateCircuit(witnessMap, SimulatedServerCircuitArtifacts.BlockRootRollupArtifact);
|
|
67
|
-
const result = convertBlockRootRollupOutputsFromWitnessMap(witness);
|
|
68
|
-
return Promise.resolve(result);
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Simulates the block merge rollup circuit from its inputs.
|
|
72
|
-
* @param input - Inputs to the circuit.
|
|
73
|
-
* @returns The public inputs as outputs of the simulation.
|
|
74
|
-
*/
|
|
75
|
-
async blockMergeRollupCircuit(input) {
|
|
76
|
-
const witnessMap = convertBlockMergeRollupInputsToWitnessMap(input);
|
|
77
|
-
const witness = await this.wasmSimulator.simulateCircuit(witnessMap, SimulatedServerCircuitArtifacts.BlockMergeRollupArtifact);
|
|
78
|
-
const result = convertBlockMergeRollupOutputsFromWitnessMap(witness);
|
|
79
|
-
return Promise.resolve(result);
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Simulates the root rollup circuit from its inputs.
|
|
83
|
-
* @param input - Inputs to the circuit.
|
|
84
|
-
* @returns The public inputs as outputs of the simulation.
|
|
85
|
-
*/
|
|
86
|
-
async rootRollupCircuit(input) {
|
|
87
|
-
const witnessMap = convertRootRollupInputsToWitnessMap(input);
|
|
88
|
-
const [duration, witness] = await elapsed(() => this.wasmSimulator.simulateCircuit(witnessMap, SimulatedServerCircuitArtifacts.RootRollupArtifact));
|
|
89
|
-
const result = convertRootRollupOutputsFromWitnessMap(witness);
|
|
90
|
-
this.log.debug(`Simulated root rollup circuit`, {
|
|
91
|
-
eventName: 'circuit-simulation',
|
|
92
|
-
circuitName: 'root-rollup',
|
|
93
|
-
duration,
|
|
94
|
-
inputSize: input.toBuffer().length,
|
|
95
|
-
outputSize: result.toBuffer().length,
|
|
96
|
-
});
|
|
97
|
-
return result;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicm9sbHVwLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3JvbGx1cC9yb2xsdXAudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBY0EsT0FBTyxFQUFFLGlCQUFpQixFQUFFLE1BQU0sdUJBQXVCLENBQUM7QUFDMUQsT0FBTyxFQUFFLE9BQU8sRUFBRSxNQUFNLHlCQUF5QixDQUFDO0FBQ2xELE9BQU8sRUFDTCwrQkFBK0IsRUFDL0IsbUNBQW1DLEVBQ25DLHNDQUFzQyxFQUN0Qyx5Q0FBeUMsRUFDekMsNENBQTRDLEVBQzVDLHdDQUF3QyxFQUN4QywyQ0FBMkMsRUFDM0Msb0NBQW9DLEVBQ3BDLHVDQUF1QyxFQUN2QyxtQ0FBbUMsRUFDbkMsc0NBQXNDLEVBQ3RDLG1DQUFtQyxFQUNuQyxzQ0FBc0MsRUFDdEMsNENBQTRDLEVBQzVDLCtDQUErQyxHQUNoRCxNQUFNLHFDQUFxQyxDQUFDO0FBRTdDLE9BQU8sRUFBRSxhQUFhLEVBQUUsTUFBTSwyQkFBMkIsQ0FBQztBQW1EMUQ7O0dBRUc7QUFDSCxNQUFNLE9BQU8sMEJBQTBCO0lBTXJDLFlBQW9CLGtCQUFzQztRQUF0Qyx1QkFBa0IsR0FBbEIsa0JBQWtCLENBQW9CO1FBTGxELFFBQUcsR0FBRyxpQkFBaUIsQ0FBQyx3QkFBd0IsQ0FBQyxDQUFDO1FBRTFELHNEQUFzRDtRQUM5QyxrQkFBYSxHQUFrQixJQUFJLGFBQ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ED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { Fq, Fr, Point } from '@aztec/circuits.js';
|
|
2
|
-
import { Grumpkin } from '@aztec/circuits.js/barretenberg';
|
|
3
|
-
|
|
4
|
-
// Copied over from `noir-projects/aztec-nr/aztec/src/generators.nr`
|
|
5
|
-
const GENERATORS = [
|
|
6
|
-
new Point(
|
|
7
|
-
new Fr(0x30426e64aee30e998c13c8ceecda3a77807dbead52bc2f3bf0eae851b4b710c1n),
|
|
8
|
-
new Fr(0x113156a068f603023240c96b4da5474667db3b8711c521c748212a15bc034ea6n),
|
|
9
|
-
false,
|
|
10
|
-
),
|
|
11
|
-
new Point(
|
|
12
|
-
new Fr(0x2825c79cc6a5cbbeef7d6a8f1b6a12b312aa338440aefeb4396148c89147c049n),
|
|
13
|
-
new Fr(0x129bfd1da54b7062d6b544e7e36b90736350f6fba01228c41c72099509f5701en),
|
|
14
|
-
false,
|
|
15
|
-
),
|
|
16
|
-
new Point(
|
|
17
|
-
new Fr(0x0edb1e293c3ce91bfc04e3ceaa50d2c541fa9d091c72eb403efb1cfa2cb3357fn),
|
|
18
|
-
new Fr(0x1341d675fa030ece3113ad53ca34fd13b19b6e9762046734f414824c4d6ade35n),
|
|
19
|
-
false,
|
|
20
|
-
),
|
|
21
|
-
new Point(
|
|
22
|
-
new Fr(0x0e0dad2250583f2a9f0acb04ededf1701b85b0393cae753fe7e14b88af81cb52n),
|
|
23
|
-
new Fr(0x0973b02c5caac339ee4ad5dab51329920f7bf1b6a07e1dabe5df67040b300962n),
|
|
24
|
-
false,
|
|
25
|
-
),
|
|
26
|
-
new Point(
|
|
27
|
-
new Fr(0x2f3342e900e8c488a28931aae68970738fdc68afde2910de7b320c00c902087dn),
|
|
28
|
-
new Fr(0x1bf958dc63cb09d59230603a0269ae86d6f92494da244910351f1132df20fc08n),
|
|
29
|
-
false,
|
|
30
|
-
),
|
|
31
|
-
];
|
|
32
|
-
|
|
33
|
-
const G_SLOT = new Point(
|
|
34
|
-
new Fr(0x041223147b680850dc82e8a55a952d4df20256fe0593d949a9541ca00f0abf15n),
|
|
35
|
-
new Fr(0x0a8c72e60d0e60f5d804549d48f3044d06140b98ed717a9b532af630c1530791n),
|
|
36
|
-
false,
|
|
37
|
-
);
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Computes a note hiding point as is done by the default implementation injected by macros.
|
|
41
|
-
* @param storageSlot - The slot to which the note was inserted.
|
|
42
|
-
* @param noteContent - The note content (e.g. note.items).
|
|
43
|
-
* @returns A note hash.
|
|
44
|
-
*/
|
|
45
|
-
export function computeNoteHash(storageSlot: Fr, noteContent: Fr[]): Fr {
|
|
46
|
-
const grumpkin = new Grumpkin();
|
|
47
|
-
const noteHidingPointBeforeSlotting = noteContent
|
|
48
|
-
.slice(1)
|
|
49
|
-
.reduce(
|
|
50
|
-
(acc, item, i) => grumpkin.add(acc, grumpkin.mul(GENERATORS[i + 1], new Fq(item.toBigInt()))),
|
|
51
|
-
grumpkin.mul(GENERATORS[0], new Fq(noteContent[0].toBigInt())),
|
|
52
|
-
);
|
|
53
|
-
|
|
54
|
-
const slotPoint = grumpkin.mul(G_SLOT, new Fq(storageSlot.toBigInt()));
|
|
55
|
-
const noteHidingPoint = grumpkin.add(noteHidingPointBeforeSlotting, slotPoint);
|
|
56
|
-
return noteHidingPoint.x;
|
|
57
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Keep track of the number of side effects across execution contexts.
|
|
3
|
-
*/
|
|
4
|
-
export class SideEffectCounter {
|
|
5
|
-
constructor(private value = 0) {}
|
|
6
|
-
|
|
7
|
-
// TODO(alexg) remove this once public side effect counters is fully accounted for on Noir side
|
|
8
|
-
current() {
|
|
9
|
-
return this.value;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
count() {
|
|
13
|
-
const value = this.value;
|
|
14
|
-
this.value++;
|
|
15
|
-
return value;
|
|
16
|
-
}
|
|
17
|
-
}
|
package/src/rollup/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './rollup.js';
|