@aztec/sequencer-client 0.23.0 → 0.26.1
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/block_builder/solo_block_builder.d.ts +9 -9
- package/dest/block_builder/solo_block_builder.d.ts.map +1 -1
- package/dest/block_builder/solo_block_builder.js +26 -48
- package/dest/global_variable_builder/viem-reader.js +2 -2
- package/dest/prover/empty.d.ts +2 -2
- package/dest/prover/empty.d.ts.map +1 -1
- package/dest/prover/empty.js +1 -1
- package/dest/prover/index.d.ts +2 -2
- package/dest/prover/index.d.ts.map +1 -1
- package/dest/publisher/l1-publisher.d.ts +0 -2
- package/dest/publisher/l1-publisher.d.ts.map +1 -1
- package/dest/publisher/l1-publisher.js +2 -3
- package/dest/publisher/viem-tx-sender.d.ts.map +1 -1
- package/dest/publisher/viem-tx-sender.js +6 -10
- package/dest/sequencer/abstract_phase_manager.d.ts +23 -30
- package/dest/sequencer/abstract_phase_manager.d.ts.map +1 -1
- package/dest/sequencer/abstract_phase_manager.js +151 -98
- package/dest/sequencer/{fee_distribution_phase_manager.d.ts → app_logic_phase_manager.d.ts} +9 -11
- package/dest/sequencer/app_logic_phase_manager.d.ts.map +1 -0
- package/dest/sequencer/app_logic_phase_manager.js +44 -0
- package/dest/sequencer/phase_manager_factory.d.ts +19 -0
- package/dest/sequencer/phase_manager_factory.d.ts.map +1 -0
- package/dest/sequencer/phase_manager_factory.js +51 -0
- package/dest/sequencer/processed_tx.d.ts +4 -4
- package/dest/sequencer/processed_tx.d.ts.map +1 -1
- package/dest/sequencer/processed_tx.js +8 -8
- package/dest/sequencer/public_processor.d.ts +1 -1
- package/dest/sequencer/public_processor.d.ts.map +1 -1
- package/dest/sequencer/public_processor.js +13 -11
- package/dest/sequencer/sequencer.d.ts +3 -3
- package/dest/sequencer/sequencer.d.ts.map +1 -1
- package/dest/sequencer/sequencer.js +23 -16
- package/dest/sequencer/{fee_preparation_phase_manager.d.ts → setup_phase_manager.d.ts} +9 -11
- package/dest/sequencer/setup_phase_manager.d.ts.map +1 -0
- package/dest/sequencer/setup_phase_manager.js +37 -0
- package/dest/sequencer/{application_logic_phase_manager.d.ts → teardown_phase_manager.d.ts} +9 -12
- package/dest/sequencer/teardown_phase_manager.d.ts.map +1 -0
- package/dest/sequencer/teardown_phase_manager.js +36 -0
- package/dest/simulator/index.d.ts +11 -5
- package/dest/simulator/index.d.ts.map +1 -1
- package/dest/simulator/public_executor.d.ts +8 -3
- package/dest/simulator/public_executor.d.ts.map +1 -1
- package/dest/simulator/public_executor.js +64 -11
- package/dest/simulator/public_kernel.d.ts +11 -5
- package/dest/simulator/public_kernel.d.ts.map +1 -1
- package/dest/simulator/public_kernel.js +35 -16
- package/dest/simulator/rollup.js +2 -2
- package/package.json +14 -24
- package/src/block_builder/index.ts +24 -0
- package/src/block_builder/solo_block_builder.ts +726 -0
- package/src/block_builder/types.ts +8 -0
- package/src/client/index.ts +1 -0
- package/src/client/sequencer-client.ts +97 -0
- package/src/config.ts +86 -0
- package/src/global_variable_builder/config.ts +20 -0
- package/src/global_variable_builder/global_builder.ts +95 -0
- package/src/global_variable_builder/index.ts +16 -0
- package/src/global_variable_builder/viem-reader.ts +61 -0
- package/src/index.ts +15 -0
- package/src/mocks/verification_keys.ts +36 -0
- package/src/prover/empty.ts +74 -0
- package/src/prover/index.ts +53 -0
- package/src/publisher/config.ts +41 -0
- package/src/publisher/index.ts +14 -0
- package/src/publisher/l1-publisher.ts +362 -0
- package/src/publisher/viem-tx-sender.ts +235 -0
- package/src/receiver.ts +13 -0
- package/src/sequencer/abstract_phase_manager.ts +489 -0
- package/src/sequencer/app_logic_phase_manager.ts +75 -0
- package/src/sequencer/config.ts +1 -0
- package/src/sequencer/index.ts +2 -0
- package/src/sequencer/phase_manager_factory.ts +122 -0
- package/src/sequencer/processed_tx.ts +94 -0
- package/src/sequencer/public_processor.ts +153 -0
- package/src/sequencer/sequencer.ts +469 -0
- package/src/sequencer/setup_phase_manager.ts +68 -0
- package/src/sequencer/teardown_phase_manager.ts +67 -0
- package/src/simulator/index.ts +57 -0
- package/src/simulator/public_executor.ts +267 -0
- package/src/simulator/public_kernel.ts +84 -0
- package/src/simulator/rollup.ts +76 -0
- package/src/utils.ts +16 -0
- package/dest/sequencer/application_logic_phase_manager.d.ts.map +0 -1
- package/dest/sequencer/application_logic_phase_manager.js +0 -64
- package/dest/sequencer/fee_distribution_phase_manager.d.ts.map +0 -1
- package/dest/sequencer/fee_distribution_phase_manager.js +0 -42
- package/dest/sequencer/fee_preparation_phase_manager.d.ts.map +0 -1
- package/dest/sequencer/fee_preparation_phase_manager.js +0 -43
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ContractDataSource,
|
|
3
|
+
ExtendedContractData,
|
|
4
|
+
L1ToL2MessageSource,
|
|
5
|
+
MerkleTreeId,
|
|
6
|
+
NullifierMembershipWitness,
|
|
7
|
+
Tx,
|
|
8
|
+
UnencryptedL2Log,
|
|
9
|
+
} from '@aztec/circuit-types';
|
|
10
|
+
import {
|
|
11
|
+
AztecAddress,
|
|
12
|
+
ContractClassRegisteredEvent,
|
|
13
|
+
ContractInstanceDeployedEvent,
|
|
14
|
+
EthAddress,
|
|
15
|
+
Fr,
|
|
16
|
+
FunctionSelector,
|
|
17
|
+
L1_TO_L2_MSG_TREE_HEIGHT,
|
|
18
|
+
NULLIFIER_TREE_HEIGHT,
|
|
19
|
+
NullifierLeafPreimage,
|
|
20
|
+
PublicDataTreeLeafPreimage,
|
|
21
|
+
} from '@aztec/circuits.js';
|
|
22
|
+
import { computePublicDataTreeLeafSlot } from '@aztec/circuits.js/hash';
|
|
23
|
+
import { createDebugLogger } from '@aztec/foundation/log';
|
|
24
|
+
import { ClassRegistererAddress } from '@aztec/protocol-contracts/class-registerer';
|
|
25
|
+
import { InstanceDeployerAddress } from '@aztec/protocol-contracts/instance-deployer';
|
|
26
|
+
import { CommitmentsDB, MessageLoadOracleInputs, PublicContractsDB, PublicStateDB } from '@aztec/simulator';
|
|
27
|
+
import { ContractClassPublic, ContractInstanceWithAddress } from '@aztec/types/contracts';
|
|
28
|
+
import { MerkleTreeOperations } from '@aztec/world-state';
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Implements the PublicContractsDB using a ContractDataSource.
|
|
32
|
+
* Progressively records contracts in transaction as they are processed in a block.
|
|
33
|
+
*/
|
|
34
|
+
export class ContractsDataSourcePublicDB implements PublicContractsDB {
|
|
35
|
+
private cache = new Map<string, ExtendedContractData>();
|
|
36
|
+
private instanceCache = new Map<string, ContractInstanceWithAddress>();
|
|
37
|
+
private classCache = new Map<string, ContractClassPublic>();
|
|
38
|
+
|
|
39
|
+
private log = createDebugLogger('aztec:sequencer:contracts-data-source');
|
|
40
|
+
|
|
41
|
+
constructor(private db: ContractDataSource) {}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Add new contracts from a transaction
|
|
45
|
+
* @param tx - The transaction to add contracts from.
|
|
46
|
+
*/
|
|
47
|
+
public addNewContracts(tx: Tx): Promise<void> {
|
|
48
|
+
for (const contract of tx.newContracts) {
|
|
49
|
+
const contractAddress = contract.contractData.contractAddress;
|
|
50
|
+
|
|
51
|
+
if (contractAddress.isZero()) {
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
this.cache.set(contractAddress.toString(), contract);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Extract contract class and instance data from logs and add to cache for this block
|
|
59
|
+
const logs = tx.unencryptedLogs.unrollLogs().map(UnencryptedL2Log.fromBuffer);
|
|
60
|
+
ContractClassRegisteredEvent.fromLogs(logs, ClassRegistererAddress).forEach(e => {
|
|
61
|
+
this.log(`Adding class ${e.contractClassId.toString()} to public execution contract cache`);
|
|
62
|
+
this.classCache.set(e.contractClassId.toString(), e.toContractClassPublic());
|
|
63
|
+
});
|
|
64
|
+
ContractInstanceDeployedEvent.fromLogs(logs, InstanceDeployerAddress).forEach(e => {
|
|
65
|
+
this.log(
|
|
66
|
+
`Adding instance ${e.address.toString()} with class ${e.contractClassId.toString()} to public execution contract cache`,
|
|
67
|
+
);
|
|
68
|
+
this.instanceCache.set(e.address.toString(), e.toContractInstance());
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
return Promise.resolve();
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Removes new contracts added from transactions
|
|
76
|
+
* @param tx - The tx's contracts to be removed
|
|
77
|
+
*/
|
|
78
|
+
public removeNewContracts(tx: Tx): Promise<void> {
|
|
79
|
+
for (const contract of tx.newContracts) {
|
|
80
|
+
const contractAddress = contract.contractData.contractAddress;
|
|
81
|
+
|
|
82
|
+
if (contractAddress.isZero()) {
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
this.cache.delete(contractAddress.toString());
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// TODO(@spalladino): Can this inadvertently delete a valid contract added by another tx?
|
|
90
|
+
// Let's say we have two txs adding the same contract on the same block. If the 2nd one reverts,
|
|
91
|
+
// wouldn't that accidentally remove the contract added on the first one?
|
|
92
|
+
const logs = tx.unencryptedLogs.unrollLogs().map(UnencryptedL2Log.fromBuffer);
|
|
93
|
+
ContractClassRegisteredEvent.fromLogs(logs, ClassRegistererAddress).forEach(e =>
|
|
94
|
+
this.classCache.delete(e.contractClassId.toString()),
|
|
95
|
+
);
|
|
96
|
+
ContractInstanceDeployedEvent.fromLogs(logs, InstanceDeployerAddress).forEach(e =>
|
|
97
|
+
this.instanceCache.delete(e.address.toString()),
|
|
98
|
+
);
|
|
99
|
+
return Promise.resolve();
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
async getBytecode(address: AztecAddress, selector: FunctionSelector): Promise<Buffer | undefined> {
|
|
103
|
+
const contract = await this.#getContract(address);
|
|
104
|
+
return contract?.getPublicFunction(selector)?.bytecode;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
async getIsInternal(address: AztecAddress, selector: FunctionSelector): Promise<boolean | undefined> {
|
|
108
|
+
const contract = await this.#getContract(address);
|
|
109
|
+
return contract?.getPublicFunction(selector)?.isInternal;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
async getPortalContractAddress(address: AztecAddress): Promise<EthAddress | undefined> {
|
|
113
|
+
const contract = await this.#getContract(address);
|
|
114
|
+
return contract?.contractData.portalContractAddress;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
async #getContract(address: AztecAddress): Promise<ExtendedContractData | undefined> {
|
|
118
|
+
return (
|
|
119
|
+
this.cache.get(address.toString()) ??
|
|
120
|
+
(await this.#makeExtendedContractDataFor(address)) ??
|
|
121
|
+
(await this.db.getExtendedContractData(address))
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
async #makeExtendedContractDataFor(address: AztecAddress): Promise<ExtendedContractData | undefined> {
|
|
126
|
+
const instance = this.instanceCache.get(address.toString());
|
|
127
|
+
if (!instance) {
|
|
128
|
+
return undefined;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const contractClass =
|
|
132
|
+
this.classCache.get(instance.contractClassId.toString()) ??
|
|
133
|
+
(await this.db.getContractClass(instance.contractClassId));
|
|
134
|
+
if (!contractClass) {
|
|
135
|
+
this.log.warn(
|
|
136
|
+
`Contract class ${instance.contractClassId.toString()} for address ${address.toString()} not found`,
|
|
137
|
+
);
|
|
138
|
+
return undefined;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return ExtendedContractData.fromClassAndInstance(contractClass, instance);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Implements the PublicStateDB using a world-state database.
|
|
147
|
+
*/
|
|
148
|
+
export class WorldStatePublicDB implements PublicStateDB {
|
|
149
|
+
private commitedWriteCache: Map<bigint, Fr> = new Map();
|
|
150
|
+
private uncommitedWriteCache: Map<bigint, Fr> = new Map();
|
|
151
|
+
|
|
152
|
+
constructor(private db: MerkleTreeOperations) {}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Reads a value from public storage, returning zero if none.
|
|
156
|
+
* @param contract - Owner of the storage.
|
|
157
|
+
* @param slot - Slot to read in the contract storage.
|
|
158
|
+
* @returns The current value in the storage slot.
|
|
159
|
+
*/
|
|
160
|
+
public async storageRead(contract: AztecAddress, slot: Fr): Promise<Fr> {
|
|
161
|
+
const leafSlot = computePublicDataTreeLeafSlot(contract, slot).value;
|
|
162
|
+
const uncommited = this.uncommitedWriteCache.get(leafSlot);
|
|
163
|
+
if (uncommited !== undefined) {
|
|
164
|
+
return uncommited;
|
|
165
|
+
}
|
|
166
|
+
const commited = this.commitedWriteCache.get(leafSlot);
|
|
167
|
+
if (commited !== undefined) {
|
|
168
|
+
return commited;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
const lowLeafResult = await this.db.getPreviousValueIndex(MerkleTreeId.PUBLIC_DATA_TREE, leafSlot);
|
|
172
|
+
if (!lowLeafResult || !lowLeafResult.alreadyPresent) {
|
|
173
|
+
return Fr.ZERO;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
const preimage = (await this.db.getLeafPreimage(
|
|
177
|
+
MerkleTreeId.PUBLIC_DATA_TREE,
|
|
178
|
+
lowLeafResult.index,
|
|
179
|
+
)) as PublicDataTreeLeafPreimage;
|
|
180
|
+
|
|
181
|
+
return preimage.value;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Records a write to public storage.
|
|
186
|
+
* @param contract - Owner of the storage.
|
|
187
|
+
* @param slot - Slot to read in the contract storage.
|
|
188
|
+
* @param newValue - The new value to store.
|
|
189
|
+
*/
|
|
190
|
+
public storageWrite(contract: AztecAddress, slot: Fr, newValue: Fr): Promise<void> {
|
|
191
|
+
const index = computePublicDataTreeLeafSlot(contract, slot).value;
|
|
192
|
+
this.uncommitedWriteCache.set(index, newValue);
|
|
193
|
+
return Promise.resolve();
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Commit the pending changes to the DB.
|
|
198
|
+
* @returns Nothing.
|
|
199
|
+
*/
|
|
200
|
+
commit(): Promise<void> {
|
|
201
|
+
for (const [k, v] of this.uncommitedWriteCache) {
|
|
202
|
+
this.commitedWriteCache.set(k, v);
|
|
203
|
+
}
|
|
204
|
+
return this.rollback();
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Rollback the pending changes.
|
|
209
|
+
* @returns Nothing.
|
|
210
|
+
*/
|
|
211
|
+
rollback(): Promise<void> {
|
|
212
|
+
this.uncommitedWriteCache = new Map<bigint, Fr>();
|
|
213
|
+
return Promise.resolve();
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Implements WorldState db using a world state database.
|
|
219
|
+
*/
|
|
220
|
+
export class WorldStateDB implements CommitmentsDB {
|
|
221
|
+
constructor(private db: MerkleTreeOperations, private l1ToL2MessageSource: L1ToL2MessageSource) {}
|
|
222
|
+
|
|
223
|
+
public async getNullifierMembershipWitnessAtLatestBlock(
|
|
224
|
+
nullifier: Fr,
|
|
225
|
+
): Promise<NullifierMembershipWitness | undefined> {
|
|
226
|
+
const index = await this.db.findLeafIndex(MerkleTreeId.NULLIFIER_TREE, nullifier.toBuffer());
|
|
227
|
+
if (!index) {
|
|
228
|
+
return undefined;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
const leafPreimagePromise = this.db.getLeafPreimage(MerkleTreeId.NULLIFIER_TREE, index);
|
|
232
|
+
const siblingPathPromise = this.db.getSiblingPath<typeof NULLIFIER_TREE_HEIGHT>(
|
|
233
|
+
MerkleTreeId.NULLIFIER_TREE,
|
|
234
|
+
BigInt(index),
|
|
235
|
+
);
|
|
236
|
+
|
|
237
|
+
const [leafPreimage, siblingPath] = await Promise.all([leafPreimagePromise, siblingPathPromise]);
|
|
238
|
+
|
|
239
|
+
if (!leafPreimage) {
|
|
240
|
+
return undefined;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
return new NullifierMembershipWitness(BigInt(index), leafPreimage as NullifierLeafPreimage, siblingPath);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
public async getL1ToL2MembershipWitness(
|
|
247
|
+
entryKey: Fr,
|
|
248
|
+
): Promise<MessageLoadOracleInputs<typeof L1_TO_L2_MSG_TREE_HEIGHT>> {
|
|
249
|
+
const index = (await this.db.findLeafIndex(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, entryKey.toBuffer()))!;
|
|
250
|
+
if (index === undefined) {
|
|
251
|
+
throw new Error(`Message ${entryKey.toString()} not found`);
|
|
252
|
+
}
|
|
253
|
+
const siblingPath = await this.db.getSiblingPath<typeof L1_TO_L2_MSG_TREE_HEIGHT>(
|
|
254
|
+
MerkleTreeId.L1_TO_L2_MESSAGE_TREE,
|
|
255
|
+
index,
|
|
256
|
+
);
|
|
257
|
+
return new MessageLoadOracleInputs<typeof L1_TO_L2_MSG_TREE_HEIGHT>(index, siblingPath);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
public async getCommitmentIndex(commitment: Fr): Promise<bigint | undefined> {
|
|
261
|
+
return await this.db.findLeafIndex(MerkleTreeId.NOTE_HASH_TREE, commitment.toBuffer());
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
public async getNullifierIndex(nullifier: Fr): Promise<bigint | undefined> {
|
|
265
|
+
return await this.db.findLeafIndex(MerkleTreeId.NULLIFIER_TREE, nullifier.toBuffer());
|
|
266
|
+
}
|
|
267
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { CircuitSimulationStats } from '@aztec/circuit-types/stats';
|
|
2
|
+
import { PublicKernelCircuitPrivateInputs, PublicKernelCircuitPublicInputs } from '@aztec/circuits.js';
|
|
3
|
+
import { createDebugLogger } from '@aztec/foundation/log';
|
|
4
|
+
import { elapsed } from '@aztec/foundation/timer';
|
|
5
|
+
import {
|
|
6
|
+
executePublicKernelAppLogic,
|
|
7
|
+
executePublicKernelSetup,
|
|
8
|
+
executePublicKernelTeardown,
|
|
9
|
+
} from '@aztec/noir-protocol-circuits-types';
|
|
10
|
+
|
|
11
|
+
import { PublicKernelCircuitSimulator } from './index.js';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Implements the PublicKernelCircuitSimulator.
|
|
15
|
+
*/
|
|
16
|
+
export class RealPublicKernelCircuitSimulator implements PublicKernelCircuitSimulator {
|
|
17
|
+
private log = createDebugLogger('aztec:public-kernel-simulator');
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Simulates the public kernel setup circuit from its inputs.
|
|
21
|
+
* @param input - Inputs to the circuit.
|
|
22
|
+
* @returns The public inputs as outputs of the simulation.
|
|
23
|
+
*/
|
|
24
|
+
public async publicKernelCircuitSetup(
|
|
25
|
+
input: PublicKernelCircuitPrivateInputs,
|
|
26
|
+
): Promise<PublicKernelCircuitPublicInputs> {
|
|
27
|
+
if (!input.previousKernel.publicInputs.needsSetup) {
|
|
28
|
+
throw new Error(`Expected previous kernel inputs to need setup`);
|
|
29
|
+
}
|
|
30
|
+
const [duration, result] = await elapsed(() => executePublicKernelSetup(input));
|
|
31
|
+
this.log(`Simulated public kernel setup circuit`, {
|
|
32
|
+
eventName: 'circuit-simulation',
|
|
33
|
+
circuitName: 'public-kernel-setup',
|
|
34
|
+
duration,
|
|
35
|
+
inputSize: input.toBuffer().length,
|
|
36
|
+
outputSize: result.toBuffer().length,
|
|
37
|
+
} satisfies CircuitSimulationStats);
|
|
38
|
+
return result;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Simulates the public kernel app logic circuit from its inputs.
|
|
43
|
+
* @param input - Inputs to the circuit.
|
|
44
|
+
* @returns The public inputs as outputs of the simulation.
|
|
45
|
+
*/
|
|
46
|
+
public async publicKernelCircuitAppLogic(
|
|
47
|
+
input: PublicKernelCircuitPrivateInputs,
|
|
48
|
+
): Promise<PublicKernelCircuitPublicInputs> {
|
|
49
|
+
if (!input.previousKernel.publicInputs.needsAppLogic) {
|
|
50
|
+
throw new Error(`Expected previous kernel inputs to need app logic`);
|
|
51
|
+
}
|
|
52
|
+
const [duration, result] = await elapsed(() => executePublicKernelAppLogic(input));
|
|
53
|
+
this.log(`Simulated public kernel app logic circuit`, {
|
|
54
|
+
eventName: 'circuit-simulation',
|
|
55
|
+
circuitName: 'public-kernel-app-logic',
|
|
56
|
+
duration,
|
|
57
|
+
inputSize: input.toBuffer().length,
|
|
58
|
+
outputSize: result.toBuffer().length,
|
|
59
|
+
} satisfies CircuitSimulationStats);
|
|
60
|
+
return result;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Simulates the public kernel teardown circuit from its inputs.
|
|
65
|
+
* @param input - Inputs to the circuit.
|
|
66
|
+
* @returns The public inputs as outputs of the simulation.
|
|
67
|
+
*/
|
|
68
|
+
public async publicKernelCircuitTeardown(
|
|
69
|
+
input: PublicKernelCircuitPrivateInputs,
|
|
70
|
+
): Promise<PublicKernelCircuitPublicInputs> {
|
|
71
|
+
if (!input.previousKernel.publicInputs.needsTeardown) {
|
|
72
|
+
throw new Error(`Expected previous kernel inputs to need teardown`);
|
|
73
|
+
}
|
|
74
|
+
const [duration, result] = await elapsed(() => executePublicKernelTeardown(input));
|
|
75
|
+
this.log(`Simulated public kernel teardown circuit`, {
|
|
76
|
+
eventName: 'circuit-simulation',
|
|
77
|
+
circuitName: 'public-kernel-teardown',
|
|
78
|
+
duration,
|
|
79
|
+
inputSize: input.toBuffer().length,
|
|
80
|
+
outputSize: result.toBuffer().length,
|
|
81
|
+
} satisfies CircuitSimulationStats);
|
|
82
|
+
return result;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { CircuitSimulationStats } from '@aztec/circuit-types/stats';
|
|
2
|
+
import {
|
|
3
|
+
BaseOrMergeRollupPublicInputs,
|
|
4
|
+
BaseRollupInputs,
|
|
5
|
+
MergeRollupInputs,
|
|
6
|
+
RootRollupInputs,
|
|
7
|
+
RootRollupPublicInputs,
|
|
8
|
+
} from '@aztec/circuits.js';
|
|
9
|
+
import { createDebugLogger } from '@aztec/foundation/log';
|
|
10
|
+
import { elapsed } from '@aztec/foundation/timer';
|
|
11
|
+
import { executeBaseRollup, executeMergeRollup, executeRootRollup } from '@aztec/noir-protocol-circuits-types';
|
|
12
|
+
|
|
13
|
+
import { RollupSimulator } from './index.js';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Implements the rollup circuit simulator.
|
|
17
|
+
*/
|
|
18
|
+
export class RealRollupCircuitSimulator implements RollupSimulator {
|
|
19
|
+
private log = createDebugLogger('aztec:rollup-simulator');
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Simulates the base rollup circuit from its inputs.
|
|
23
|
+
* @param input - Inputs to the circuit.
|
|
24
|
+
* @returns The public inputs as outputs of the simulation.
|
|
25
|
+
*/
|
|
26
|
+
public async baseRollupCircuit(input: BaseRollupInputs): Promise<BaseOrMergeRollupPublicInputs> {
|
|
27
|
+
const [duration, result] = await elapsed(() => executeBaseRollup(input));
|
|
28
|
+
|
|
29
|
+
this.log(`Simulated base rollup circuit`, {
|
|
30
|
+
eventName: 'circuit-simulation',
|
|
31
|
+
circuitName: 'base-rollup',
|
|
32
|
+
duration,
|
|
33
|
+
inputSize: input.toBuffer().length,
|
|
34
|
+
outputSize: result.toBuffer().length,
|
|
35
|
+
} satisfies CircuitSimulationStats);
|
|
36
|
+
|
|
37
|
+
return Promise.resolve(result);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Simulates the merge rollup circuit from its inputs.
|
|
41
|
+
* @param input - Inputs to the circuit.
|
|
42
|
+
* @returns The public inputs as outputs of the simulation.
|
|
43
|
+
*/
|
|
44
|
+
public async mergeRollupCircuit(input: MergeRollupInputs): Promise<BaseOrMergeRollupPublicInputs> {
|
|
45
|
+
const [duration, result] = await elapsed(() => executeMergeRollup(input));
|
|
46
|
+
|
|
47
|
+
this.log(`Simulated merge rollup circuit`, {
|
|
48
|
+
eventName: 'circuit-simulation',
|
|
49
|
+
circuitName: 'merge-rollup',
|
|
50
|
+
duration,
|
|
51
|
+
inputSize: input.toBuffer().length,
|
|
52
|
+
outputSize: result.toBuffer().length,
|
|
53
|
+
} satisfies CircuitSimulationStats);
|
|
54
|
+
|
|
55
|
+
return result;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Simulates the root rollup circuit from its inputs.
|
|
60
|
+
* @param input - Inputs to the circuit.
|
|
61
|
+
* @returns The public inputs as outputs of the simulation.
|
|
62
|
+
*/
|
|
63
|
+
public async rootRollupCircuit(input: RootRollupInputs): Promise<RootRollupPublicInputs> {
|
|
64
|
+
const [duration, result] = await elapsed(() => executeRootRollup(input));
|
|
65
|
+
|
|
66
|
+
this.log(`Simulated root rollup circuit`, {
|
|
67
|
+
eventName: 'circuit-simulation',
|
|
68
|
+
circuitName: 'root-rollup',
|
|
69
|
+
duration,
|
|
70
|
+
inputSize: input.toBuffer().length,
|
|
71
|
+
outputSize: result.toBuffer().length,
|
|
72
|
+
} satisfies CircuitSimulationStats);
|
|
73
|
+
|
|
74
|
+
return result;
|
|
75
|
+
}
|
|
76
|
+
}
|
package/src/utils.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns a promise that resolves after ms milliseconds, returning "returnValue".
|
|
3
|
+
* @param ms - How many milliseconds to sleep.
|
|
4
|
+
* @param returnValue - The return value of the promise.
|
|
5
|
+
*/
|
|
6
|
+
export function sleep<T>(ms: number, returnValue: T): Promise<T> {
|
|
7
|
+
return new Promise(resolve => setTimeout(() => resolve(returnValue), ms));
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Returns the lowest power of two that is greater of equal to the input.
|
|
12
|
+
* @param num - The input.
|
|
13
|
+
*/
|
|
14
|
+
export function ceilPowerOfTwo(num: number): number {
|
|
15
|
+
return 2 ** Math.ceil(Math.log2(num));
|
|
16
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"application_logic_phase_manager.d.ts","sourceRoot":"","sources":["../../src/sequencer/application_logic_phase_manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,sBAAsB,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,KAAK,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAGjH,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAE1D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,EAAE,2BAA2B,EAAE,MAAM,iCAAiC,CAAC;AAC9E,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,2BAA2B,EAAE,MAAM,qCAAqC,CAAC;AAClF,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C;;GAEG;AACH,qBAAa,4BAA6B,SAAQ,oBAAoB;IAElE,SAAS,CAAC,EAAE,EAAE,oBAAoB;IAClC,SAAS,CAAC,cAAc,EAAE,cAAc;IACxC,SAAS,CAAC,YAAY,EAAE,4BAA4B;IACpD,SAAS,CAAC,YAAY,EAAE,YAAY;IACpC,SAAS,CAAC,eAAe,EAAE,eAAe;IAC1C,SAAS,CAAC,gBAAgB,EAAE,MAAM;IAClC,SAAS,CAAC,iBAAiB,EAAE,2BAA2B;IACxD,SAAS,CAAC,aAAa,EAAE,aAAa;IAEtC,SAAS,CAAC,GAAG;gBATH,EAAE,EAAE,oBAAoB,EACxB,cAAc,EAAE,cAAc,EAC9B,YAAY,EAAE,4BAA4B,EAC1C,YAAY,EAAE,YAAY,EAC1B,eAAe,EAAE,eAAe,EAChC,gBAAgB,EAAE,MAAM,EACxB,iBAAiB,EAAE,2BAA2B,EAC9C,aAAa,EAAE,aAAa,EAE5B,GAAG,8CAAyD;IAKxE,0BAA0B,CAAC,EAAE,EAAE,EAAE,GAAG,iBAAiB,EAAE;IASjD,MAAM,CACV,EAAE,EAAE,EAAE,EACN,0BAA0B,CAAC,EAAE,wBAAwB,EACrD,yBAAyB,CAAC,EAAE,KAAK,GAChC,OAAO,CAAC;QACT;;WAEG;QACH,kBAAkB,CAAC,EAAE,wBAAwB,CAAC;QAC9C;;WAEG;QACH,iBAAiB,CAAC,EAAE,KAAK,CAAC;KAC3B,CAAC;IA2BF,SAAS;IAaH,QAAQ,CAAC,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC;CAWxD"}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { isArrayEmpty } from '@aztec/foundation/collection';
|
|
2
|
-
import { createDebugLogger } from '@aztec/foundation/log';
|
|
3
|
-
import { AbstractPhaseManager } from './abstract_phase_manager.js';
|
|
4
|
-
import { FeeDistributionPhaseManager } from './fee_distribution_phase_manager.js';
|
|
5
|
-
/**
|
|
6
|
-
* The phase manager responsible for performing the fee preparation phase.
|
|
7
|
-
*/
|
|
8
|
-
export class ApplicationLogicPhaseManager extends AbstractPhaseManager {
|
|
9
|
-
constructor(db, publicExecutor, publicKernel, publicProver, globalVariables, historicalHeader, publicContractsDB, publicStateDB, log = createDebugLogger('aztec:sequencer:application-logic')) {
|
|
10
|
-
super(db, publicExecutor, publicKernel, publicProver, globalVariables, historicalHeader);
|
|
11
|
-
this.db = db;
|
|
12
|
-
this.publicExecutor = publicExecutor;
|
|
13
|
-
this.publicKernel = publicKernel;
|
|
14
|
-
this.publicProver = publicProver;
|
|
15
|
-
this.globalVariables = globalVariables;
|
|
16
|
-
this.historicalHeader = historicalHeader;
|
|
17
|
-
this.publicContractsDB = publicContractsDB;
|
|
18
|
-
this.publicStateDB = publicStateDB;
|
|
19
|
-
this.log = log;
|
|
20
|
-
}
|
|
21
|
-
extractEnqueuedPublicCalls(tx) {
|
|
22
|
-
if (!tx.enqueuedPublicFunctionCalls) {
|
|
23
|
-
throw new Error(`Missing preimages for enqueued public calls`);
|
|
24
|
-
}
|
|
25
|
-
// Note: the first enqueued public call is for fee payments
|
|
26
|
-
// TODO(dbanks12): why must these be reversed?
|
|
27
|
-
return tx.enqueuedPublicFunctionCalls.slice().reverse();
|
|
28
|
-
}
|
|
29
|
-
async handle(tx, previousPublicKernelOutput, previousPublicKernelProof) {
|
|
30
|
-
// add new contracts to the contracts db so that their functions may be found and called
|
|
31
|
-
this.log(`Processing tx ${await tx.getTxHash()}`);
|
|
32
|
-
await this.publicContractsDB.addNewContracts(tx);
|
|
33
|
-
if (!isArrayEmpty(tx.data.end.publicCallStack, item => item.isEmpty())) {
|
|
34
|
-
const outputAndProof = this.getKernelOutputAndProof(tx, previousPublicKernelOutput, previousPublicKernelProof);
|
|
35
|
-
this.log(`Executing enqueued public calls for tx ${await tx.getTxHash()}`);
|
|
36
|
-
const [publicKernelOutput, publicKernelProof, newUnencryptedFunctionLogs] = await this.processEnqueuedPublicCalls(this.extractEnqueuedPublicCalls(tx), outputAndProof.publicKernelOutput, outputAndProof.publicKernelProof);
|
|
37
|
-
tx.unencryptedLogs.addFunctionLogs(newUnencryptedFunctionLogs);
|
|
38
|
-
// commit the state updates from this transaction
|
|
39
|
-
await this.publicStateDB.commit();
|
|
40
|
-
return { publicKernelOutput, publicKernelProof };
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
return {
|
|
44
|
-
publicKernelOutput: undefined,
|
|
45
|
-
publicKernelProof: undefined,
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
nextPhase() {
|
|
50
|
-
return new FeeDistributionPhaseManager(this.db, this.publicExecutor, this.publicKernel, this.publicProver, this.globalVariables, this.historicalHeader, this.publicContractsDB, this.publicStateDB);
|
|
51
|
-
}
|
|
52
|
-
async rollback(tx, err) {
|
|
53
|
-
this.log.warn(`Error processing tx ${await tx.getTxHash()}: ${err}`);
|
|
54
|
-
// remove contracts on failure
|
|
55
|
-
await this.publicContractsDB.removeNewContracts(tx);
|
|
56
|
-
// rollback any state updates from this failed transaction
|
|
57
|
-
await this.publicStateDB.rollback();
|
|
58
|
-
return {
|
|
59
|
-
tx,
|
|
60
|
-
error: err instanceof Error ? err : new Error('Unknown error'),
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXBwbGljYXRpb25fbG9naWNfcGhhc2VfbWFuYWdlci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9zZXF1ZW5jZXIvYXBwbGljYXRpb25fbG9naWNfcGhhc2VfbWFuYWdlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFFQSxPQUFPLEVBQUUsWUFBWSxFQUFFLE1BQU0sOEJBQThCLENBQUM7QUFDNUQsT0FBTyxFQUFFLGlCQUFpQixFQUFFLE1BQU0sdUJBQXVCLENBQUM7QUFPMUQsT0FBTyxFQUFFLG9CQUFvQixFQUFFLE1BQU0sNkJBQTZCLENBQUM7QUFDbkUsT0FBTyxFQUFFLDJCQUEyQixFQUFFLE1BQU0scUNBQXFDLENBQUM7QUFHbEY7O0dBRUc7QUFDSCxNQUFNLE9BQU8sNEJBQTZCLFNBQVEsb0JBQW9CO0lBQ3BFLFlBQ1ksRUFBd0IsRUFDeEIsY0FBOEIsRUFDOUIsWUFBMEMsRUFDMUMsWUFBMEIsRUFDMUIsZUFBZ0MsRUFDaEMsZ0JBQXdCLEVBQ3hCLGlCQUE4QyxFQUM5QyxhQUE0QixF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BQUMsRUFBRSxFQUNQLElBQUksQ0FBQyxjQUFjLEVBQ25CLElBQUksQ0FBQyxZQUFZLEVBQ2pCLElBQUksQ0FBQyxZQUFZLEVBQ2pCLElBQUksQ0FBQyxlQUFlLEVBQ3BCLElBQUksQ0FBQyxnQkFBZ0IsRUFDckIsSUFBSSxDQUFDLGlCQUFpQixFQUN0QixJQUFJLENBQUMsYUFBYSxDQUNuQixDQUFDO0lBQ0osQ0FBQztJQUVELEtBQUssQ0FBQyxRQUFRLENBQUMsRUFBTSxFQUFFLEdBQVk7UUFDakMsSUFBSSxDQUFDLEdBQUcsQ0FBQyxJQUFJLENBQUMsdUJBQXVCLE1BQU0sRUFBRSxDQUFDLFNBQVMsRUFBRSxLQUFLLEdBQUcsRUFBRSxDQUFDLENBQUM7UUFDckUsOEJBQThCO1FBQzlCLE1BQU0sSUFBSSxDQUFDLGlCQUFpQixDQUFDLGtCQUFrQixDQUFDLEVBQUUsQ0FBQyxDQUFDO1FBQ3BELDBEQUEwRDtRQUMxRCxNQUFNLElBQUksQ0FBQyxhQUFhLENBQUMsUUFBUSxFQUFFLENBQUM7UUFDcEMsT0FBTztZQUNMLEVBQUU7WUFDRixLQUFLLEVBQUUsR0FBRyxZQUFZLEtBQUssQ0FBQyxDQUFDLENBQUMsR0FBRyxDQUFDLENBQUMsQ0FBQyxJQUFJLEtBQUssQ0FBQyxlQUFlLENBQUM7U0FDL0QsQ0FBQztJQUNKLENBQUM7Q0FDRiJ9
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fee_distribution_phase_manager.d.ts","sourceRoot":"","sources":["../../src/sequencer/fee_distribution_phase_manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,sBAAsB,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,KAAK,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAEjH,OAAO,EAAE,cAAc,EAAE,aA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K,CAAC;KAC3B,CAAC;IAQF,SAAS;IAIH,QAAQ,CAAC,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC;CAOxD"}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { createDebugLogger } from '@aztec/foundation/log';
|
|
2
|
-
import { AbstractPhaseManager } from './abstract_phase_manager.js';
|
|
3
|
-
/**
|
|
4
|
-
* The phase manager responsible for performing the fee preparation phase.
|
|
5
|
-
*/
|
|
6
|
-
export class FeeDistributionPhaseManager extends AbstractPhaseManager {
|
|
7
|
-
constructor(db, publicExecutor, publicKernel, publicProver, globalVariables, historicalHeader, publicContractsDB, publicStateDB, log = createDebugLogger('aztec:sequencer:fee-distribution')) {
|
|
8
|
-
super(db, publicExecutor, publicKernel, publicProver, globalVariables, historicalHeader);
|
|
9
|
-
this.db = db;
|
|
10
|
-
this.publicExecutor = publicExecutor;
|
|
11
|
-
this.publicKernel = publicKernel;
|
|
12
|
-
this.publicProver = publicProver;
|
|
13
|
-
this.globalVariables = globalVariables;
|
|
14
|
-
this.historicalHeader = historicalHeader;
|
|
15
|
-
this.publicContractsDB = publicContractsDB;
|
|
16
|
-
this.publicStateDB = publicStateDB;
|
|
17
|
-
this.log = log;
|
|
18
|
-
}
|
|
19
|
-
// this is a no-op for now
|
|
20
|
-
extractEnqueuedPublicCalls(_tx) {
|
|
21
|
-
return [];
|
|
22
|
-
}
|
|
23
|
-
// this is a no-op for now
|
|
24
|
-
async handle(tx, previousPublicKernelOutput, previousPublicKernelProof) {
|
|
25
|
-
this.log.debug(`Handle ${await tx.getTxHash()} with no-op`);
|
|
26
|
-
return {
|
|
27
|
-
publicKernelOutput: previousPublicKernelOutput,
|
|
28
|
-
publicKernelProof: previousPublicKernelProof,
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
nextPhase() {
|
|
32
|
-
return null;
|
|
33
|
-
}
|
|
34
|
-
async rollback(tx, err) {
|
|
35
|
-
this.log.warn(`Error processing tx ${await tx.getTxHash()}: ${err}`);
|
|
36
|
-
return {
|
|
37
|
-
tx,
|
|
38
|
-
error: err instanceof Error ? err : new Error('Unknown error'),
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmVlX2Rpc3RyaWJ1dGlvbl9waGFzZV9tYW5hZ2VyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3NlcXVlbmNlci9mZWVfZGlzdHJpYnV0aW9uX3BoYXNlX21hbmFnZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBRUEsT0FBTyxFQUFFLGlCQUFpQixFQUFFLE1BQU0sdUJBQXVCLENBQUM7QUFPMUQsT0FBTyxFQUFFLG9CQUFvQixFQUFFLE1BQU0sNkJBQTZCLENBQUM7QUFHbkU7O0dBRUc7QUFDSCxNQUFNLE9BQU8sMkJBQTRCLFNBQVEsb0JBQW9CO0lBQ25FLFlBQ1ksRUFBd0IsRUFDeEIsY0FBOEIsRUFDOUIsWUFBMEMsRUFDMUMsWUFBMEIsRUFDMUIsZUFBZ0MsRUFDaEMsZ0JBQXdCLEVBQ3hCLGlCQUE4QyxFQUM5QyxhQUE0QixFQUU1QixNQUFNLGlCQUFpQixDQUFDLGtDQUFrQyxDQUFDO1FBRXJFLEtBQUssQ0FBQyxFQUFFLEVBQUUsY0FBYyxFQUFFLFlBQVksRUFBRSxZQUFZLEVBQUUsZUFBZSxFQUFFLGdCQUFnQixDQUFDLENBQUM7UUFYL0UsT0FBRSxHQUFGLEVBQUUsQ0FBc0I7UUFDeEIsbUJBQWMsR0FBZCxjQUFjLENBQWdCO1FBQzlCLGlCQUFZLEdBQVosWUFBWSxDQUE4QjtRQUMxQyxpQkFBWSxHQUFaLFlBQVksQ0FBYztRQUMxQixvQkFBZSxHQUFmLGVBQWUsQ0FBaU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E,EAAE,GAAG,iBAAiB,EAAE;IAKlD,MAAM,CACV,EAAE,EAAE,EAAE,EACN,0BAA0B,CAAC,EAAE,wBAAwB,EACrD,yBAAyB,CAAC,EAAE,KAAK,GAChC,OAAO,CAAC;QACT;;WAEG;QACH,kBAAkB,CAAC,EAAE,wBAAwB,CAAC;QAC9C;;WAEG;QACH,iBAAiB,CAAC,EAAE,KAAK,CAAC;KAC3B,CAAC;IAQF,SAAS,IAAI,oBAAoB;IAa3B,QAAQ,CAAC,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC;CAOxD"}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { createDebugLogger } from '@aztec/foundation/log';
|
|
2
|
-
import { AbstractPhaseManager } from './abstract_phase_manager.js';
|
|
3
|
-
import { ApplicationLogicPhaseManager } from './application_logic_phase_manager.js';
|
|
4
|
-
/**
|
|
5
|
-
* The phase manager responsible for performing the fee preparation phase.
|
|
6
|
-
*/
|
|
7
|
-
export class FeePreparationPhaseManager extends AbstractPhaseManager {
|
|
8
|
-
constructor(db, publicExecutor, publicKernel, publicProver, globalVariables, historicalHeader, publicContractsDB, publicStateDB, log = createDebugLogger('aztec:sequencer:fee-preparation')) {
|
|
9
|
-
super(db, publicExecutor, publicKernel, publicProver, globalVariables, historicalHeader);
|
|
10
|
-
this.db = db;
|
|
11
|
-
this.publicExecutor = publicExecutor;
|
|
12
|
-
this.publicKernel = publicKernel;
|
|
13
|
-
this.publicProver = publicProver;
|
|
14
|
-
this.globalVariables = globalVariables;
|
|
15
|
-
this.historicalHeader = historicalHeader;
|
|
16
|
-
this.publicContractsDB = publicContractsDB;
|
|
17
|
-
this.publicStateDB = publicStateDB;
|
|
18
|
-
this.log = log;
|
|
19
|
-
}
|
|
20
|
-
// this is a no-op for now
|
|
21
|
-
extractEnqueuedPublicCalls(_tx) {
|
|
22
|
-
return [];
|
|
23
|
-
}
|
|
24
|
-
// this is a no-op for now
|
|
25
|
-
async handle(tx, previousPublicKernelOutput, previousPublicKernelProof) {
|
|
26
|
-
this.log.debug(`Handle ${await tx.getTxHash()} with no-op`);
|
|
27
|
-
return {
|
|
28
|
-
publicKernelOutput: previousPublicKernelOutput,
|
|
29
|
-
publicKernelProof: previousPublicKernelProof,
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
nextPhase() {
|
|
33
|
-
return new ApplicationLogicPhaseManager(this.db, this.publicExecutor, this.publicKernel, this.publicProver, this.globalVariables, this.historicalHeader, this.publicContractsDB, this.publicStateDB);
|
|
34
|
-
}
|
|
35
|
-
async rollback(tx, err) {
|
|
36
|
-
this.log.warn(`Error processing tx ${await tx.getTxHash()}: ${err}`);
|
|
37
|
-
return {
|
|
38
|
-
tx,
|
|
39
|
-
error: err instanceof Error ? err : new Error('Unknown error'),
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmVlX3ByZXBhcmF0aW9uX3BoYXNlX21hbmFnZXIuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvc2VxdWVuY2VyL2ZlZV9wcmVwYXJhdGlvbl9waGFzZV9tYW5hZ2VyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUVBLE9BQU8sRUFBRSxpQkFBaUIsRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBTzFELE9BQU8sRUFBRSxvQkFBb0IsRUFBRSxNQUFNLDZCQUE2QixDQUFDO0FBQ25FLE9BQU8sRUFBRSw0QkFBNEIsRUFBRSxNQUFNLHNDQUFzQyxDQUFDO0FBR3BGOztHQUVHO0FBQ0gsTUFBTSxPQUFPLDBCQUEyQixTQUFRLG9CQUFvQjtJQUNsRSxZQUNZLEVBQXdCLEVBQ3hCLGNBQThCLEVBQzlCLFlBQTBDLEVBQzFDLFlBQTBCLEVBQzFCLG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