@aztec/simulator 0.47.1 → 0.49.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/acvm/acvm.d.ts +2 -2
- package/dest/acvm/acvm.d.ts.map +1 -1
- package/dest/acvm/acvm.js +12 -7
- package/dest/acvm/oracle/oracle.d.ts +3 -3
- package/dest/acvm/oracle/oracle.d.ts.map +1 -1
- package/dest/acvm/oracle/oracle.js +8 -9
- package/dest/acvm/oracle/typed_oracle.d.ts +5 -5
- package/dest/acvm/oracle/typed_oracle.d.ts.map +1 -1
- package/dest/acvm/oracle/typed_oracle.js +6 -6
- package/dest/avm/avm_gas.d.ts +1 -0
- package/dest/avm/avm_gas.d.ts.map +1 -1
- package/dest/avm/avm_gas.js +142 -79
- package/dest/avm/fixtures/index.d.ts.map +1 -1
- package/dest/avm/fixtures/index.js +2 -2
- package/dest/avm/opcodes/accrued_substate.js +2 -2
- package/dest/avm/opcodes/commitment.js +4 -4
- package/dest/avm/opcodes/conversion.js +2 -2
- package/dest/avm/opcodes/external_calls.js +4 -4
- package/dest/avm/opcodes/instruction.d.ts +2 -1
- package/dest/avm/opcodes/instruction.d.ts.map +1 -1
- package/dest/avm/opcodes/instruction.js +8 -5
- package/dest/avm/opcodes/memory.js +2 -2
- package/dest/avm/opcodes/storage.js +3 -3
- package/dest/avm/serialization/instruction_serialization.js +2 -2
- package/dest/client/client_execution_context.d.ts +8 -8
- package/dest/client/client_execution_context.d.ts.map +1 -1
- package/dest/client/client_execution_context.js +22 -23
- package/dest/client/db_oracle.d.ts +4 -3
- package/dest/client/db_oracle.d.ts.map +1 -1
- package/dest/client/execution_note_cache.d.ts +17 -13
- package/dest/client/execution_note_cache.d.ts.map +1 -1
- package/dest/client/execution_note_cache.js +65 -26
- package/dest/client/execution_result.d.ts +3 -2
- package/dest/client/execution_result.d.ts.map +1 -1
- package/dest/client/execution_result.js +20 -9
- package/dest/client/private_execution.js +3 -3
- package/dest/client/simulator.d.ts +7 -6
- package/dest/client/simulator.d.ts.map +1 -1
- package/dest/client/simulator.js +14 -12
- package/dest/client/test_utils.d.ts +9 -0
- package/dest/client/test_utils.d.ts.map +1 -0
- package/dest/client/test_utils.js +21 -0
- package/dest/client/view_data_oracle.d.ts +2 -1
- package/dest/client/view_data_oracle.d.ts.map +1 -1
- package/dest/client/view_data_oracle.js +4 -3
- package/dest/index.d.ts +0 -1
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -2
- package/dest/providers/acvm_native.js +2 -2
- package/dest/public/abstract_phase_manager.d.ts.map +1 -1
- package/dest/public/abstract_phase_manager.js +3 -3
- package/dest/public/executor.d.ts +4 -1
- package/dest/public/executor.d.ts.map +1 -1
- package/dest/public/executor.js +10 -2
- package/dest/public/executor_metrics.d.ts +10 -0
- package/dest/public/executor_metrics.d.ts.map +1 -0
- package/dest/public/executor_metrics.js +32 -0
- package/dest/public/fee_payment.d.ts +2 -2
- package/dest/public/fee_payment.d.ts.map +1 -1
- package/dest/public/fee_payment.js +9 -10
- package/dest/public/hints_builder.d.ts.map +1 -1
- package/dest/public/hints_builder.js +1 -1
- package/dest/public/public_processor.d.ts +6 -5
- package/dest/public/public_processor.d.ts.map +1 -1
- package/dest/public/public_processor.js +38 -18
- package/dest/public/public_processor_metrics.d.ts +19 -0
- package/dest/public/public_processor_metrics.d.ts.map +1 -0
- package/dest/public/public_processor_metrics.js +59 -0
- package/package.json +9 -9
- package/src/acvm/acvm.ts +14 -5
- package/src/acvm/oracle/oracle.ts +8 -23
- package/src/acvm/oracle/typed_oracle.ts +8 -21
- package/src/avm/avm_gas.ts +145 -79
- package/src/avm/fixtures/index.ts +1 -0
- package/src/avm/opcodes/accrued_substate.ts +1 -1
- package/src/avm/opcodes/commitment.ts +3 -3
- package/src/avm/opcodes/conversion.ts +1 -1
- package/src/avm/opcodes/external_calls.ts +3 -3
- package/src/avm/opcodes/instruction.ts +7 -4
- package/src/avm/opcodes/memory.ts +1 -1
- package/src/avm/opcodes/storage.ts +2 -2
- package/src/avm/serialization/instruction_serialization.ts +1 -1
- package/src/client/client_execution_context.ts +23 -20
- package/src/client/db_oracle.ts +9 -3
- package/src/client/execution_note_cache.ts +76 -25
- package/src/client/execution_result.ts +29 -9
- package/src/client/private_execution.ts +2 -2
- package/src/client/simulator.ts +18 -14
- package/src/client/test_utils.ts +30 -0
- package/src/client/view_data_oracle.ts +2 -1
- package/src/index.ts +0 -1
- package/src/providers/acvm_native.ts +1 -1
- package/src/public/abstract_phase_manager.ts +1 -2
- package/src/public/executor.ts +14 -1
- package/src/public/executor_metrics.ts +48 -0
- package/src/public/fee_payment.ts +8 -10
- package/src/public/hints_builder.ts +2 -2
- package/src/public/public_processor.ts +52 -20
- package/src/public/public_processor_metrics.ts +92 -0
- package/dest/utils.d.ts +0 -12
- package/dest/utils.d.ts.map +0 -1
- package/dest/utils.js +0 -11
- package/src/utils.ts +0 -18
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
|
-
type BlockProver,
|
|
3
2
|
type FailedTx,
|
|
4
3
|
NestedProcessReturnValues,
|
|
5
4
|
type ProcessedTx,
|
|
5
|
+
type ProcessedTxHandler,
|
|
6
6
|
PublicKernelType,
|
|
7
7
|
type PublicProvingRequest,
|
|
8
8
|
type SimulationError,
|
|
@@ -13,7 +13,8 @@ import {
|
|
|
13
13
|
} from '@aztec/circuit-types';
|
|
14
14
|
import {
|
|
15
15
|
AztecAddress,
|
|
16
|
-
|
|
16
|
+
ContractClassRegisteredEvent,
|
|
17
|
+
FEE_JUICE_ADDRESS,
|
|
17
18
|
type GlobalVariables,
|
|
18
19
|
type Header,
|
|
19
20
|
type KernelCircuitPublicInputs,
|
|
@@ -23,7 +24,9 @@ import {
|
|
|
23
24
|
} from '@aztec/circuits.js';
|
|
24
25
|
import { times } from '@aztec/foundation/collection';
|
|
25
26
|
import { createDebugLogger } from '@aztec/foundation/log';
|
|
27
|
+
import { Timer } from '@aztec/foundation/timer';
|
|
26
28
|
import { type ProtocolArtifact } from '@aztec/noir-protocol-circuits-types';
|
|
29
|
+
import { ClassRegistererAddress } from '@aztec/protocol-contracts/class-registerer';
|
|
27
30
|
import {
|
|
28
31
|
PublicExecutor,
|
|
29
32
|
type PublicStateDB,
|
|
@@ -40,6 +43,7 @@ import { PhaseManagerFactory } from './phase_manager_factory.js';
|
|
|
40
43
|
import { ContractsDataSourcePublicDB, WorldStateDB, WorldStatePublicDB } from './public_db_sources.js';
|
|
41
44
|
import { RealPublicKernelCircuitSimulator } from './public_kernel.js';
|
|
42
45
|
import { type PublicKernelCircuitSimulator } from './public_kernel_circuit_simulator.js';
|
|
46
|
+
import { PublicProcessorMetrics } from './public_processor_metrics.js';
|
|
43
47
|
|
|
44
48
|
/**
|
|
45
49
|
* Creates new instances of PublicProcessor given the provided merkle tree db and contract data source.
|
|
@@ -56,18 +60,24 @@ export class PublicProcessorFactory {
|
|
|
56
60
|
* Creates a new instance of a PublicProcessor.
|
|
57
61
|
* @param historicalHeader - The header of a block previous to the one in which the tx is included.
|
|
58
62
|
* @param globalVariables - The global variables for the block being processed.
|
|
59
|
-
* @param newContracts - Provides access to contract bytecode for public executions.
|
|
60
63
|
* @returns A new instance of a PublicProcessor.
|
|
61
64
|
*/
|
|
62
|
-
public create(
|
|
63
|
-
|
|
64
|
-
|
|
65
|
+
public create(maybeHistoricalHeader: Header | undefined, globalVariables: GlobalVariables): PublicProcessor {
|
|
66
|
+
const { merkleTree, telemetryClient } = this;
|
|
67
|
+
const historicalHeader = maybeHistoricalHeader ?? merkleTree.getInitialHeader();
|
|
65
68
|
const publicContractsDB = new ContractsDataSourcePublicDB(this.contractDataSource);
|
|
66
|
-
|
|
67
|
-
const
|
|
68
|
-
const
|
|
69
|
+
|
|
70
|
+
const worldStatePublicDB = new WorldStatePublicDB(merkleTree);
|
|
71
|
+
const worldStateDB = new WorldStateDB(merkleTree);
|
|
72
|
+
const publicExecutor = new PublicExecutor(
|
|
73
|
+
worldStatePublicDB,
|
|
74
|
+
publicContractsDB,
|
|
75
|
+
worldStateDB,
|
|
76
|
+
historicalHeader,
|
|
77
|
+
telemetryClient,
|
|
78
|
+
);
|
|
69
79
|
return new PublicProcessor(
|
|
70
|
-
|
|
80
|
+
merkleTree,
|
|
71
81
|
publicExecutor,
|
|
72
82
|
new RealPublicKernelCircuitSimulator(this.simulator),
|
|
73
83
|
globalVariables,
|
|
@@ -84,7 +94,7 @@ export class PublicProcessorFactory {
|
|
|
84
94
|
* any public function calls in them. Txs with private calls only are unaffected.
|
|
85
95
|
*/
|
|
86
96
|
export class PublicProcessor {
|
|
87
|
-
|
|
97
|
+
private metrics: PublicProcessorMetrics;
|
|
88
98
|
constructor(
|
|
89
99
|
protected db: MerkleTreeOperations,
|
|
90
100
|
protected publicExecutor: PublicExecutor,
|
|
@@ -96,18 +106,23 @@ export class PublicProcessor {
|
|
|
96
106
|
telemetryClient: TelemetryClient,
|
|
97
107
|
private log = createDebugLogger('aztec:sequencer:public-processor'),
|
|
98
108
|
) {
|
|
99
|
-
this.
|
|
109
|
+
this.metrics = new PublicProcessorMetrics(telemetryClient, 'PublicProcessor');
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
get tracer(): Tracer {
|
|
113
|
+
return this.metrics.tracer;
|
|
100
114
|
}
|
|
101
115
|
|
|
102
116
|
/**
|
|
103
117
|
* Run each tx through the public circuit and the public kernel circuit if needed.
|
|
104
118
|
* @param txs - Txs to process.
|
|
119
|
+
* @param processedTxHandler - Handler for processed txs in the context of block building or proving.
|
|
105
120
|
* @returns The list of processed txs with their circuit simulation outputs.
|
|
106
121
|
*/
|
|
107
122
|
public async process(
|
|
108
123
|
txs: Tx[],
|
|
109
124
|
maxTransactions = txs.length,
|
|
110
|
-
|
|
125
|
+
processedTxHandler?: ProcessedTxHandler,
|
|
111
126
|
txValidator?: TxValidator<ProcessedTx>,
|
|
112
127
|
): Promise<[ProcessedTx[], FailedTx[], NestedProcessReturnValues[]]> {
|
|
113
128
|
// The processor modifies the tx objects in place, so we need to clone them.
|
|
@@ -150,9 +165,9 @@ export class PublicProcessor {
|
|
|
150
165
|
throw new Error(`Transaction ${invalid[0].hash} invalid after processing public functions`);
|
|
151
166
|
}
|
|
152
167
|
}
|
|
153
|
-
// if we were given a
|
|
154
|
-
if (
|
|
155
|
-
await
|
|
168
|
+
// if we were given a handler then send the transaction to it for block building or proving
|
|
169
|
+
if (processedTxHandler) {
|
|
170
|
+
await processedTxHandler.addNewTx(processedTx);
|
|
156
171
|
}
|
|
157
172
|
result.push(processedTx);
|
|
158
173
|
returns = returns.concat(returnValues ?? []);
|
|
@@ -188,12 +203,12 @@ export class PublicProcessor {
|
|
|
188
203
|
return finalPublicDataUpdateRequests;
|
|
189
204
|
}
|
|
190
205
|
|
|
191
|
-
const
|
|
206
|
+
const feeJuiceAddress = AztecAddress.fromBigInt(FEE_JUICE_ADDRESS);
|
|
192
207
|
const balanceSlot = computeFeePayerBalanceStorageSlot(feePayer);
|
|
193
208
|
const leafSlot = computeFeePayerBalanceLeafSlot(feePayer);
|
|
194
209
|
const txFee = tx.data.getTransactionFee(this.globalVariables.gasFees);
|
|
195
210
|
|
|
196
|
-
this.log.debug(`Deducting ${txFee} balance in
|
|
211
|
+
this.log.debug(`Deducting ${txFee} balance in Fee Juice for ${feePayer}`);
|
|
197
212
|
|
|
198
213
|
const existingBalanceWriteIndex = finalPublicDataUpdateRequests.findIndex(request =>
|
|
199
214
|
request.leafSlot.equals(leafSlot),
|
|
@@ -202,14 +217,14 @@ export class PublicProcessor {
|
|
|
202
217
|
const balance =
|
|
203
218
|
existingBalanceWriteIndex > -1
|
|
204
219
|
? finalPublicDataUpdateRequests[existingBalanceWriteIndex].newValue
|
|
205
|
-
: await this.publicStateDB.storageRead(
|
|
220
|
+
: await this.publicStateDB.storageRead(feeJuiceAddress, balanceSlot);
|
|
206
221
|
|
|
207
222
|
if (balance.lt(txFee)) {
|
|
208
223
|
throw new Error(`Not enough balance for fee payer to pay for transaction (got ${balance} needs ${txFee})`);
|
|
209
224
|
}
|
|
210
225
|
|
|
211
226
|
const updatedBalance = balance.sub(txFee);
|
|
212
|
-
await this.publicStateDB.storageWrite(
|
|
227
|
+
await this.publicStateDB.storageWrite(feeJuiceAddress, balanceSlot, updatedBalance);
|
|
213
228
|
|
|
214
229
|
finalPublicDataUpdateRequests[
|
|
215
230
|
existingBalanceWriteIndex > -1 ? existingBalanceWriteIndex : MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX
|
|
@@ -222,6 +237,7 @@ export class PublicProcessor {
|
|
|
222
237
|
[Attributes.TX_HASH]: tx.getTxHash().toString(),
|
|
223
238
|
}))
|
|
224
239
|
private async processTxWithPublicCalls(tx: Tx): Promise<[ProcessedTx, NestedProcessReturnValues[]]> {
|
|
240
|
+
const timer = new Timer();
|
|
225
241
|
let returnValues: NestedProcessReturnValues[] = [];
|
|
226
242
|
const publicProvingRequests: PublicProvingRequest[] = [];
|
|
227
243
|
let phase: AbstractPhaseManager | undefined = PhaseManagerFactory.phaseFromTx(
|
|
@@ -240,8 +256,18 @@ export class PublicProcessor {
|
|
|
240
256
|
let finalKernelOutput: KernelCircuitPublicInputs | undefined;
|
|
241
257
|
let revertReason: SimulationError | undefined;
|
|
242
258
|
const gasUsed: ProcessedTx['gasUsed'] = {};
|
|
259
|
+
let phaseCount = 0;
|
|
243
260
|
while (phase) {
|
|
261
|
+
phaseCount++;
|
|
262
|
+
const phaseTimer = new Timer();
|
|
244
263
|
const output = await phase.handle(tx, publicKernelPublicInput, lastKernelArtifact);
|
|
264
|
+
|
|
265
|
+
if (output.revertReason) {
|
|
266
|
+
this.metrics.recordRevertedPhase(phase.phase);
|
|
267
|
+
} else {
|
|
268
|
+
this.metrics.recordPhaseDuration(phase.phase, phaseTimer.ms());
|
|
269
|
+
}
|
|
270
|
+
|
|
245
271
|
gasUsed[phase.phase] = output.gasUsed;
|
|
246
272
|
if (phase.phase === PublicKernelType.APP_LOGIC) {
|
|
247
273
|
returnValues = output.returnValues;
|
|
@@ -265,9 +291,15 @@ export class PublicProcessor {
|
|
|
265
291
|
}
|
|
266
292
|
|
|
267
293
|
if (!finalKernelOutput) {
|
|
294
|
+
this.metrics.recordFailedTx();
|
|
268
295
|
throw new Error('Final public kernel was not executed.');
|
|
269
296
|
}
|
|
270
297
|
|
|
298
|
+
this.metrics.recordClassRegistration(
|
|
299
|
+
...ContractClassRegisteredEvent.fromLogs(tx.unencryptedLogs.unrollLogs(), ClassRegistererAddress),
|
|
300
|
+
);
|
|
301
|
+
|
|
302
|
+
this.metrics.recordTx(phaseCount, timer.ms());
|
|
271
303
|
const processedTx = makeProcessedTx(tx, finalKernelOutput, publicProvingRequests, revertReason, gasUsed);
|
|
272
304
|
return [processedTx, returnValues];
|
|
273
305
|
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { type PublicKernelType } from '@aztec/circuit-types';
|
|
2
|
+
import { type ContractClassRegisteredEvent } from '@aztec/circuits.js';
|
|
3
|
+
import {
|
|
4
|
+
Attributes,
|
|
5
|
+
type Histogram,
|
|
6
|
+
Metrics,
|
|
7
|
+
type TelemetryClient,
|
|
8
|
+
type Tracer,
|
|
9
|
+
type UpDownCounter,
|
|
10
|
+
ValueType,
|
|
11
|
+
} from '@aztec/telemetry-client';
|
|
12
|
+
|
|
13
|
+
export class PublicProcessorMetrics {
|
|
14
|
+
public readonly tracer: Tracer;
|
|
15
|
+
|
|
16
|
+
private txDuration: Histogram;
|
|
17
|
+
private txCount: UpDownCounter;
|
|
18
|
+
private txPhaseCount: UpDownCounter;
|
|
19
|
+
|
|
20
|
+
private phaseDuration: Histogram;
|
|
21
|
+
private phaseCount: UpDownCounter;
|
|
22
|
+
|
|
23
|
+
private bytecodeDeployed: Histogram;
|
|
24
|
+
|
|
25
|
+
constructor(client: TelemetryClient, name = 'PublicProcessor') {
|
|
26
|
+
this.tracer = client.getTracer(name);
|
|
27
|
+
const meter = client.getMeter(name);
|
|
28
|
+
|
|
29
|
+
this.txDuration = meter.createHistogram(Metrics.PUBLIC_PROCESSOR_TX_DURATION, {
|
|
30
|
+
description: 'How long it takes to process a transaction',
|
|
31
|
+
unit: 'ms',
|
|
32
|
+
valueType: ValueType.INT,
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
this.txCount = meter.createUpDownCounter(Metrics.PUBLIC_PROCESSOR_TX_COUNT, {
|
|
36
|
+
description: 'Number of transactions processed',
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
this.txPhaseCount = meter.createUpDownCounter(Metrics.PUBLIC_PROCESSOR_TX_PHASE_COUNT, {
|
|
40
|
+
description: 'Number of phases processed',
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
this.phaseDuration = meter.createHistogram(Metrics.PUBLIC_PROCESSOR_PHASE_DURATION, {
|
|
44
|
+
description: 'How long it takes to process a phase',
|
|
45
|
+
unit: 'ms',
|
|
46
|
+
valueType: ValueType.INT,
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
this.phaseCount = meter.createUpDownCounter(Metrics.PUBLIC_PROCESSOR_PHASE_COUNT, {
|
|
50
|
+
description: 'Number of failed phases',
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
this.bytecodeDeployed = meter.createHistogram(Metrics.PUBLIC_PROCESSOR_DEPLOY_BYTECODE_SIZE, {
|
|
54
|
+
description: 'Size of deployed bytecode',
|
|
55
|
+
unit: 'By',
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
recordPhaseDuration(phaseName: PublicKernelType, durationMs: number) {
|
|
60
|
+
this.phaseCount.add(1, { [Attributes.TX_PHASE_NAME]: phaseName, [Attributes.OK]: true });
|
|
61
|
+
this.phaseDuration.record(Math.ceil(durationMs), { [Attributes.TX_PHASE_NAME]: phaseName });
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
recordTx(phaseCount: number, durationMs: number) {
|
|
65
|
+
this.txPhaseCount.add(phaseCount);
|
|
66
|
+
this.txDuration.record(Math.ceil(durationMs));
|
|
67
|
+
this.txCount.add(1, {
|
|
68
|
+
[Attributes.OK]: true,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
recordFailedTx() {
|
|
73
|
+
this.txCount.add(1, {
|
|
74
|
+
[Attributes.OK]: false,
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
recordRevertedPhase(phaseName: PublicKernelType) {
|
|
79
|
+
this.phaseCount.add(1, { [Attributes.TX_PHASE_NAME]: phaseName, [Attributes.OK]: false });
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
recordClassRegistration(...events: ContractClassRegisteredEvent[]) {
|
|
83
|
+
let totalBytecode = 0;
|
|
84
|
+
for (const event of events) {
|
|
85
|
+
totalBytecode += event.packedPublicBytecode.length;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (totalBytecode > 0) {
|
|
89
|
+
this.bytecodeDeployed.record(totalBytecode);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
package/dest/utils.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { type Fr } from '@aztec/foundation/fields';
|
|
2
|
-
/**
|
|
3
|
-
* Computes the resulting storage slot for an entry in a mapping.
|
|
4
|
-
* @param mappingSlot - The slot of the mapping within state.
|
|
5
|
-
* @param key - The key of the mapping.
|
|
6
|
-
* @returns The slot in the contract storage where the value is stored.
|
|
7
|
-
*/
|
|
8
|
-
export declare function computeSlotForMapping(mappingSlot: Fr, key: {
|
|
9
|
-
/** Serialize to a field. */
|
|
10
|
-
toField: () => Fr;
|
|
11
|
-
}): Fr;
|
|
12
|
-
//# sourceMappingURL=utils.d.ts.map
|
package/dest/utils.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAEnD;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,WAAW,EAAE,EAAE,EACf,GAAG,EAAE;IACH,4BAA4B;IAC5B,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,MAGF"}
|
package/dest/utils.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { pedersenHash } from '@aztec/foundation/crypto';
|
|
2
|
-
/**
|
|
3
|
-
* Computes the resulting storage slot for an entry in a mapping.
|
|
4
|
-
* @param mappingSlot - The slot of the mapping within state.
|
|
5
|
-
* @param key - The key of the mapping.
|
|
6
|
-
* @returns The slot in the contract storage where the value is stored.
|
|
7
|
-
*/
|
|
8
|
-
export function computeSlotForMapping(mappingSlot, key) {
|
|
9
|
-
return pedersenHash([mappingSlot, key.toField()]);
|
|
10
|
-
}
|
|
11
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbHMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvdXRpbHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLFlBQVksRUFBRSxNQUFNLDBCQUEwQixDQUFDO0FBR3hEOzs7OztHQUtHO0FBQ0gsTUFBTSxVQUFVLHFCQUFxQixDQUNuQyxXQUFlLEVBQ2YsR0FHQztJQUVELE9BQU8sWUFBWSxDQUFDLENBQUMsV0FBVyxFQUFFLEdBQUcsQ0FBQyxPQUFPLEVBQUUsQ0FBQyxDQUFDLENBQUM7QUFDcEQsQ0FBQyJ9
|
package/src/utils.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { pedersenHash } from '@aztec/foundation/crypto';
|
|
2
|
-
import { type Fr } from '@aztec/foundation/fields';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Computes the resulting storage slot for an entry in a mapping.
|
|
6
|
-
* @param mappingSlot - The slot of the mapping within state.
|
|
7
|
-
* @param key - The key of the mapping.
|
|
8
|
-
* @returns The slot in the contract storage where the value is stored.
|
|
9
|
-
*/
|
|
10
|
-
export function computeSlotForMapping(
|
|
11
|
-
mappingSlot: Fr,
|
|
12
|
-
key: {
|
|
13
|
-
/** Serialize to a field. */
|
|
14
|
-
toField: () => Fr;
|
|
15
|
-
},
|
|
16
|
-
) {
|
|
17
|
-
return pedersenHash([mappingSlot, key.toField()]);
|
|
18
|
-
}
|