@aztec/sequencer-client 0.24.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.
Files changed (65) hide show
  1. package/dest/block_builder/solo_block_builder.d.ts +9 -9
  2. package/dest/block_builder/solo_block_builder.d.ts.map +1 -1
  3. package/dest/block_builder/solo_block_builder.js +26 -48
  4. package/dest/global_variable_builder/viem-reader.js +2 -2
  5. package/dest/publisher/l1-publisher.d.ts +0 -2
  6. package/dest/publisher/l1-publisher.d.ts.map +1 -1
  7. package/dest/publisher/l1-publisher.js +2 -3
  8. package/dest/publisher/viem-tx-sender.d.ts.map +1 -1
  9. package/dest/publisher/viem-tx-sender.js +6 -10
  10. package/dest/sequencer/abstract_phase_manager.d.ts +18 -25
  11. package/dest/sequencer/abstract_phase_manager.d.ts.map +1 -1
  12. package/dest/sequencer/abstract_phase_manager.js +141 -91
  13. package/dest/sequencer/{fee_distribution_phase_manager.d.ts → app_logic_phase_manager.d.ts} +9 -11
  14. package/dest/sequencer/app_logic_phase_manager.d.ts.map +1 -0
  15. package/dest/sequencer/app_logic_phase_manager.js +44 -0
  16. package/dest/sequencer/phase_manager_factory.d.ts +19 -0
  17. package/dest/sequencer/phase_manager_factory.d.ts.map +1 -0
  18. package/dest/sequencer/phase_manager_factory.js +51 -0
  19. package/dest/sequencer/processed_tx.d.ts +2 -2
  20. package/dest/sequencer/processed_tx.d.ts.map +1 -1
  21. package/dest/sequencer/processed_tx.js +7 -7
  22. package/dest/sequencer/public_processor.d.ts +1 -1
  23. package/dest/sequencer/public_processor.d.ts.map +1 -1
  24. package/dest/sequencer/public_processor.js +13 -11
  25. package/dest/sequencer/sequencer.d.ts +3 -3
  26. package/dest/sequencer/sequencer.d.ts.map +1 -1
  27. package/dest/sequencer/sequencer.js +23 -16
  28. package/dest/sequencer/{fee_preparation_phase_manager.d.ts → setup_phase_manager.d.ts} +9 -11
  29. package/dest/sequencer/setup_phase_manager.d.ts.map +1 -0
  30. package/dest/sequencer/setup_phase_manager.js +37 -0
  31. package/dest/sequencer/{application_logic_phase_manager.d.ts → teardown_phase_manager.d.ts} +9 -12
  32. package/dest/sequencer/teardown_phase_manager.d.ts.map +1 -0
  33. package/dest/sequencer/teardown_phase_manager.js +36 -0
  34. package/dest/simulator/index.d.ts +10 -4
  35. package/dest/simulator/index.d.ts.map +1 -1
  36. package/dest/simulator/public_executor.d.ts +8 -3
  37. package/dest/simulator/public_executor.d.ts.map +1 -1
  38. package/dest/simulator/public_executor.js +64 -11
  39. package/dest/simulator/public_kernel.d.ts +10 -4
  40. package/dest/simulator/public_kernel.d.ts.map +1 -1
  41. package/dest/simulator/public_kernel.js +33 -14
  42. package/package.json +14 -13
  43. package/src/block_builder/solo_block_builder.ts +61 -50
  44. package/src/global_variable_builder/viem-reader.ts +1 -1
  45. package/src/publisher/l1-publisher.ts +1 -4
  46. package/src/publisher/viem-tx-sender.ts +6 -12
  47. package/src/sequencer/abstract_phase_manager.ts +207 -145
  48. package/src/sequencer/app_logic_phase_manager.ts +75 -0
  49. package/src/sequencer/phase_manager_factory.ts +122 -0
  50. package/src/sequencer/processed_tx.ts +12 -13
  51. package/src/sequencer/public_processor.ts +29 -12
  52. package/src/sequencer/sequencer.ts +22 -15
  53. package/src/sequencer/{fee_distribution_phase_manager.ts → setup_phase_manager.ts} +23 -25
  54. package/src/sequencer/teardown_phase_manager.ts +67 -0
  55. package/src/simulator/index.ts +10 -6
  56. package/src/simulator/public_executor.ts +108 -10
  57. package/src/simulator/public_kernel.ts +39 -13
  58. package/dest/sequencer/application_logic_phase_manager.d.ts.map +0 -1
  59. package/dest/sequencer/application_logic_phase_manager.js +0 -64
  60. package/dest/sequencer/fee_distribution_phase_manager.d.ts.map +0 -1
  61. package/dest/sequencer/fee_distribution_phase_manager.js +0 -42
  62. package/dest/sequencer/fee_preparation_phase_manager.d.ts.map +0 -1
  63. package/dest/sequencer/fee_preparation_phase_manager.js +0 -42
  64. package/src/sequencer/application_logic_phase_manager.ts +0 -107
  65. package/src/sequencer/fee_preparation_phase_manager.ts +0 -79
@@ -1,14 +1,30 @@
1
- import { ContractDataSource, ExtendedContractData, L1ToL2MessageSource, MerkleTreeId, Tx } from '@aztec/circuit-types';
1
+ import {
2
+ ContractDataSource,
3
+ ExtendedContractData,
4
+ L1ToL2MessageSource,
5
+ MerkleTreeId,
6
+ NullifierMembershipWitness,
7
+ Tx,
8
+ UnencryptedL2Log,
9
+ } from '@aztec/circuit-types';
2
10
  import {
3
11
  AztecAddress,
12
+ ContractClassRegisteredEvent,
13
+ ContractInstanceDeployedEvent,
4
14
  EthAddress,
5
15
  Fr,
6
16
  FunctionSelector,
7
17
  L1_TO_L2_MSG_TREE_HEIGHT,
18
+ NULLIFIER_TREE_HEIGHT,
19
+ NullifierLeafPreimage,
8
20
  PublicDataTreeLeafPreimage,
9
21
  } from '@aztec/circuits.js';
10
- import { computePublicDataTreeLeafSlot } from '@aztec/circuits.js/abis';
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';
11
26
  import { CommitmentsDB, MessageLoadOracleInputs, PublicContractsDB, PublicStateDB } from '@aztec/simulator';
27
+ import { ContractClassPublic, ContractInstanceWithAddress } from '@aztec/types/contracts';
12
28
  import { MerkleTreeOperations } from '@aztec/world-state';
13
29
 
14
30
  /**
@@ -16,7 +32,11 @@ import { MerkleTreeOperations } from '@aztec/world-state';
16
32
  * Progressively records contracts in transaction as they are processed in a block.
17
33
  */
18
34
  export class ContractsDataSourcePublicDB implements PublicContractsDB {
19
- cache = new Map<string, ExtendedContractData>();
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');
20
40
 
21
41
  constructor(private db: ContractDataSource) {}
22
42
 
@@ -35,6 +55,19 @@ export class ContractsDataSourcePublicDB implements PublicContractsDB {
35
55
  this.cache.set(contractAddress.toString(), contract);
36
56
  }
37
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
+
38
71
  return Promise.resolve();
39
72
  }
40
73
 
@@ -52,6 +85,17 @@ export class ContractsDataSourcePublicDB implements PublicContractsDB {
52
85
 
53
86
  this.cache.delete(contractAddress.toString());
54
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
+ );
55
99
  return Promise.resolve();
56
100
  }
57
101
 
@@ -59,17 +103,42 @@ export class ContractsDataSourcePublicDB implements PublicContractsDB {
59
103
  const contract = await this.#getContract(address);
60
104
  return contract?.getPublicFunction(selector)?.bytecode;
61
105
  }
106
+
62
107
  async getIsInternal(address: AztecAddress, selector: FunctionSelector): Promise<boolean | undefined> {
63
108
  const contract = await this.#getContract(address);
64
109
  return contract?.getPublicFunction(selector)?.isInternal;
65
110
  }
111
+
66
112
  async getPortalContractAddress(address: AztecAddress): Promise<EthAddress | undefined> {
67
113
  const contract = await this.#getContract(address);
68
114
  return contract?.contractData.portalContractAddress;
69
115
  }
70
116
 
71
117
  async #getContract(address: AztecAddress): Promise<ExtendedContractData | undefined> {
72
- return this.cache.get(address.toString()) ?? (await this.db.getExtendedContractData(address));
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);
73
142
  }
74
143
  }
75
144
 
@@ -151,19 +220,48 @@ export class WorldStatePublicDB implements PublicStateDB {
151
220
  export class WorldStateDB implements CommitmentsDB {
152
221
  constructor(private db: MerkleTreeOperations, private l1ToL2MessageSource: L1ToL2MessageSource) {}
153
222
 
154
- public async getL1ToL2Message(messageKey: Fr): Promise<MessageLoadOracleInputs<typeof L1_TO_L2_MSG_TREE_HEIGHT>> {
155
- // todo: #697 - make this one lookup.
156
- const message = await this.l1ToL2MessageSource.getConfirmedL1ToL2Message(messageKey);
157
- const index = (await this.db.findLeafIndex(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, messageKey.toBuffer()))!;
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
+ }
158
253
  const siblingPath = await this.db.getSiblingPath<typeof L1_TO_L2_MSG_TREE_HEIGHT>(
159
254
  MerkleTreeId.L1_TO_L2_MESSAGE_TREE,
160
255
  index,
161
256
  );
162
-
163
- return new MessageLoadOracleInputs<typeof L1_TO_L2_MSG_TREE_HEIGHT>(message, index, siblingPath);
257
+ return new MessageLoadOracleInputs<typeof L1_TO_L2_MSG_TREE_HEIGHT>(index, siblingPath);
164
258
  }
165
259
 
166
260
  public async getCommitmentIndex(commitment: Fr): Promise<bigint | undefined> {
167
261
  return await this.db.findLeafIndex(MerkleTreeId.NOTE_HASH_TREE, commitment.toBuffer());
168
262
  }
263
+
264
+ public async getNullifierIndex(nullifier: Fr): Promise<bigint | undefined> {
265
+ return await this.db.findLeafIndex(MerkleTreeId.NULLIFIER_TREE, nullifier.toBuffer());
266
+ }
169
267
  }
@@ -2,7 +2,11 @@ import { CircuitSimulationStats } from '@aztec/circuit-types/stats';
2
2
  import { PublicKernelCircuitPrivateInputs, PublicKernelCircuitPublicInputs } from '@aztec/circuits.js';
3
3
  import { createDebugLogger } from '@aztec/foundation/log';
4
4
  import { elapsed } from '@aztec/foundation/timer';
5
- import { executePublicKernelAppLogic, executePublicKernelSetup } from '@aztec/noir-protocol-circuits-types';
5
+ import {
6
+ executePublicKernelAppLogic,
7
+ executePublicKernelSetup,
8
+ executePublicKernelTeardown,
9
+ } from '@aztec/noir-protocol-circuits-types';
6
10
 
7
11
  import { PublicKernelCircuitSimulator } from './index.js';
8
12
 
@@ -13,20 +17,20 @@ export class RealPublicKernelCircuitSimulator implements PublicKernelCircuitSimu
13
17
  private log = createDebugLogger('aztec:public-kernel-simulator');
14
18
 
15
19
  /**
16
- * Simulates the public kernel circuit (with a previous private kernel circuit run) from its inputs.
20
+ * Simulates the public kernel setup circuit from its inputs.
17
21
  * @param input - Inputs to the circuit.
18
22
  * @returns The public inputs as outputs of the simulation.
19
23
  */
20
- public async publicKernelCircuitPrivateInput(
24
+ public async publicKernelCircuitSetup(
21
25
  input: PublicKernelCircuitPrivateInputs,
22
26
  ): Promise<PublicKernelCircuitPublicInputs> {
23
- if (!input.previousKernel.publicInputs.isPrivate) {
24
- throw new Error(`Expected private kernel previous inputs`);
27
+ if (!input.previousKernel.publicInputs.needsSetup) {
28
+ throw new Error(`Expected previous kernel inputs to need setup`);
25
29
  }
26
30
  const [duration, result] = await elapsed(() => executePublicKernelSetup(input));
27
- this.log(`Simulated public kernel circuit with private input`, {
31
+ this.log(`Simulated public kernel setup circuit`, {
28
32
  eventName: 'circuit-simulation',
29
- circuitName: 'public-kernel-private-input',
33
+ circuitName: 'public-kernel-setup',
30
34
  duration,
31
35
  inputSize: input.toBuffer().length,
32
36
  outputSize: result.toBuffer().length,
@@ -35,20 +39,42 @@ export class RealPublicKernelCircuitSimulator implements PublicKernelCircuitSimu
35
39
  }
36
40
 
37
41
  /**
38
- * Simulates the public kernel circuit (with no previous public kernel circuit run) from its inputs.
42
+ * Simulates the public kernel app logic circuit from its inputs.
39
43
  * @param input - Inputs to the circuit.
40
44
  * @returns The public inputs as outputs of the simulation.
41
45
  */
42
- public async publicKernelCircuitNonFirstIteration(
46
+ public async publicKernelCircuitAppLogic(
43
47
  input: PublicKernelCircuitPrivateInputs,
44
48
  ): Promise<PublicKernelCircuitPublicInputs> {
45
- if (input.previousKernel.publicInputs.isPrivate) {
46
- throw new Error(`Expected public kernel previous inputs`);
49
+ if (!input.previousKernel.publicInputs.needsAppLogic) {
50
+ throw new Error(`Expected previous kernel inputs to need app logic`);
47
51
  }
48
52
  const [duration, result] = await elapsed(() => executePublicKernelAppLogic(input));
49
- this.log(`Simulated public kernel circuit non-first iteration`, {
53
+ this.log(`Simulated public kernel app logic circuit`, {
50
54
  eventName: 'circuit-simulation',
51
- circuitName: 'public-kernel-non-first-iteration',
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',
52
78
  duration,
53
79
  inputSize: input.toBuffer().length,
54
80
  outputSize: result.toBuffer().length,
@@ -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,+BAA+B,EAAE,MAAM,oBAAoB,CAAC;AAGxH,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,+BAA+B,EAC5D,yBAAyB,CAAC,EAAE,KAAK,GAChC,OAAO,CAAC;QACT;;WAEG;QACH,kBAAkB,CAAC,EAAE,+BAA+B,CAAC;QACrD;;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.publicKernelPublicInput, 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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXBwbGljYXRpb25fbG9naWNfcGhhc2VfbWFuYWdlci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9zZXF1ZW5jZXIvYXBwbGljYXRpb25fbG9naW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ACxD,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,8CAAwD;IAMvE,0BAA0B,CAAC,GAAG,EAAE,EAAE,GAAG,iBAAiB,EAAE;IAKlD,MAAM,CACV,EAAE,EAAE,EAAE,EACN,0BAA0B,CAAC,EAAE,+BAA+B,EAC5D,yBAAyB,CAAC,EAAE,KAAK,GAChC,OAAO,CAAC;QACT;;WAEG;QACH,kBAAkB,CAAC,EAAE,+BAA+B,CAAC;QACrD;;WAEG;QACH,iBAAiB,CAAC,EAAE,KAAK,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 undefined;
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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmVlX2Rpc3RyaWJ1dGlvbl9waGFzZV9tYW5hZ2VyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3NlcXVlbmNlci9mZWVfZGlzdHJpYnV0aW9uX3BoYXNlX21hbmFnZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBRUEsT0FBTyxFQUFFLGlCQUFpQixFQUFFLE1BQU0sdUJBQXVCLENBQUM7QUFPMUQsT0FBTyxFQUFFLG9CQUFvQixFQUFFLE1BQU0sNkJBQTZCLENBQUM7QUFHbkU7O0dBRUc7QUFDSCxNQUFNLE9BQU8sMkJBQTRCLFNBQVEsb0JBQW9CO0lBQ25FLFlBQ1ksRUFBd0IsRUFDeEIsY0FBOEIsRUFDOUIsWUFBMEMsRUFDMUMsWUFBMEIsRUFDMUIsZUFBZ0MsRUFDaEMsZ0JBQXdCLEVBQ3hCLGlCQUE4QyxFQUM5QyxhQUE0QixFQUU1QixNQUFNLGlCQUFpQixDQUFDLGtDQUFrQyxDQUFDO1FBRXJFLEtBQUssQ0FBQyxFQUFFLEVBQUUsY0FBYyxFQUFFLFlBQVksRUFBRSxZQUFZLEVBQUUsZUFBZSxFQUFFLGdCQUFnQixDQUFDLENBQUM7UUFYL0Us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,EAAE,4BAA4B,EAC1C,YAAY,EAAE,YAAY,EAC1B,eAAe,EAAE,eAAe,EAChC,gBAAgB,EAAE,MAAM,EACxB,iBAAiB,EAAE,2BAA2B,EAC9C,aAAa,EAAE,aAAa,EAE5B,GAAG,8CAAuD;IAKtE,0BAA0B,CAAC,GAAG,EAAE,EAAE,GAAG,iBAAiB,EAAE;IAKlD,MAAM,CACV,EAAE,EAAE,EAAE,EACN,0BAA0B,CAAC,EAAE,+BAA+B,EAC5D,yBAAyB,CAAC,EAAE,KAAK,GAChC,OAAO,CAAC;QACT;;WAEG;QACH,kBAAkB,CAAC,EAAE,+BAA+B,CAAC;QACrD;;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,42 +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
- 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 new ApplicationLogicPhaseManager(this.db, this.publicExecutor, this.publicKernel, this.publicProver, this.globalVariables, this.historicalHeader, this.publicContractsDB, this.publicStateDB);
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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmVlX3ByZXBhcmF0aW9uX3BoYXNlX21hbmFnZXIuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvc2VxdWVuY2VyL2ZlZV9wcmVwYXJhdGlvbl9waGFzZV9tYW5hZ2VyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUVBLE9BQU8sRUFBRSxpQkFBaUIsRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBTzFELE9BQU8sRUFBRSxvQkFBb0IsRUFBRSxNQUFNLDZCQUE2QixDQUFDO0FBQ25FLE9BQU8sRUFBRSw0QkFBNEIsRUFBRSxNQUFNLHNDQUFzQyxDQUFDO0FBR3BGOztHQUVHO0FBQ0gsTUFBTSxPQUFPLDBCQUEyQixTQUFRLG9CQUFvQjtJQUNsRSxZQUNZLEVBQXdCLEVBQ3hCLGNBQThCLEVBQzlCLFlBQTBDLEVBQzFDLFlBQTBCLEVBQzFCLGVBQWdDLEVBQ2hDLGdCQUF3QixFQUN4QixpQkFBOEMsRUFDOUMsYUFBNEIsRUFFNUIsTUFBTSxpQkFBaUIsQ0FBQyxpQ0FBaUMsQ0FBQztRQUVwRSxLQUFLLENBQUMsRUFBRSxFQUFFLGNBQWMsRUFBRSxZQ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QUFDLGFBQWEsQ0FDbkIsQ0FBQztJQUNKLENBQUM7SUFFRCxLQUFLLENBQUMsUUFBUSxDQUFDLEVBQU0sRUFBRSxHQUFZO1FBQ2pDLElBQUksQ0FBQyxHQUFHLENBQUMsSUFBSSxDQUFDLHVCQUF1QixNQUFNLEVBQUUsQ0FBQyxTQUFTLEVBQUUsS0FBSyxHQUFHLEVBQUUsQ0FBQyxDQUFDO1FBQ3JFLE9BQU87WUFDTCxFQUFFO1lBQ0YsS0FBSyxFQUFFLEdBQUcsWUFBWSxLQUFLLENBQUMsQ0FBQyxDQUFDLEdBQUcsQ0FBQyxDQUFDLENBQUMsSUFBSSxLQUFLLENBQUMsZUFBZSxDQUFDO1NBQy9ELENBQUM7SUFDSixDQUFDO0NBQ0YifQ==
@@ -1,107 +0,0 @@
1
- import { Tx } from '@aztec/circuit-types';
2
- import { GlobalVariables, Header, Proof, PublicCallRequest, PublicKernelCircuitPublicInputs } from '@aztec/circuits.js';
3
- import { isArrayEmpty } from '@aztec/foundation/collection';
4
- import { createDebugLogger } from '@aztec/foundation/log';
5
- import { PublicExecutor, PublicStateDB } from '@aztec/simulator';
6
- import { MerkleTreeOperations } from '@aztec/world-state';
7
-
8
- import { PublicProver } from '../prover/index.js';
9
- import { PublicKernelCircuitSimulator } from '../simulator/index.js';
10
- import { ContractsDataSourcePublicDB } from '../simulator/public_executor.js';
11
- import { AbstractPhaseManager } from './abstract_phase_manager.js';
12
- import { FeeDistributionPhaseManager } from './fee_distribution_phase_manager.js';
13
- import { FailedTx } from './processed_tx.js';
14
-
15
- /**
16
- * The phase manager responsible for performing the fee preparation phase.
17
- */
18
- export class ApplicationLogicPhaseManager extends AbstractPhaseManager {
19
- constructor(
20
- protected db: MerkleTreeOperations,
21
- protected publicExecutor: PublicExecutor,
22
- protected publicKernel: PublicKernelCircuitSimulator,
23
- protected publicProver: PublicProver,
24
- protected globalVariables: GlobalVariables,
25
- protected historicalHeader: Header,
26
- protected publicContractsDB: ContractsDataSourcePublicDB,
27
- protected publicStateDB: PublicStateDB,
28
-
29
- protected log = createDebugLogger('aztec:sequencer:application-logic'),
30
- ) {
31
- super(db, publicExecutor, publicKernel, publicProver, globalVariables, historicalHeader);
32
- }
33
-
34
- extractEnqueuedPublicCalls(tx: Tx): PublicCallRequest[] {
35
- if (!tx.enqueuedPublicFunctionCalls) {
36
- throw new Error(`Missing preimages for enqueued public calls`);
37
- }
38
- // Note: the first enqueued public call is for fee payments
39
- // TODO(dbanks12): why must these be reversed?
40
- return tx.enqueuedPublicFunctionCalls.slice().reverse();
41
- }
42
-
43
- async handle(
44
- tx: Tx,
45
- previousPublicKernelOutput?: PublicKernelCircuitPublicInputs,
46
- previousPublicKernelProof?: Proof,
47
- ): Promise<{
48
- /**
49
- * the output of the public kernel circuit for this phase
50
- */
51
- publicKernelOutput?: PublicKernelCircuitPublicInputs;
52
- /**
53
- * the proof of the public kernel circuit for this phase
54
- */
55
- publicKernelProof?: Proof;
56
- }> {
57
- // add new contracts to the contracts db so that their functions may be found and called
58
- this.log(`Processing tx ${await tx.getTxHash()}`);
59
- await this.publicContractsDB.addNewContracts(tx);
60
- if (!isArrayEmpty(tx.data.end.publicCallStack, item => item.isEmpty())) {
61
- const outputAndProof = this.getKernelOutputAndProof(tx, previousPublicKernelOutput, previousPublicKernelProof);
62
-
63
- this.log(`Executing enqueued public calls for tx ${await tx.getTxHash()}`);
64
- const [publicKernelOutput, publicKernelProof, newUnencryptedFunctionLogs] = await this.processEnqueuedPublicCalls(
65
- this.extractEnqueuedPublicCalls(tx),
66
- outputAndProof.publicKernelPublicInput,
67
- outputAndProof.publicKernelProof,
68
- );
69
- tx.unencryptedLogs.addFunctionLogs(newUnencryptedFunctionLogs);
70
-
71
- // commit the state updates from this transaction
72
- await this.publicStateDB.commit();
73
-
74
- return { publicKernelOutput, publicKernelProof };
75
- } else {
76
- return {
77
- publicKernelOutput: undefined,
78
- publicKernelProof: undefined,
79
- };
80
- }
81
- }
82
-
83
- nextPhase() {
84
- return new FeeDistributionPhaseManager(
85
- this.db,
86
- this.publicExecutor,
87
- this.publicKernel,
88
- this.publicProver,
89
- this.globalVariables,
90
- this.historicalHeader,
91
- this.publicContractsDB,
92
- this.publicStateDB,
93
- );
94
- }
95
-
96
- async rollback(tx: Tx, err: unknown): Promise<FailedTx> {
97
- this.log.warn(`Error processing tx ${await tx.getTxHash()}: ${err}`);
98
- // remove contracts on failure
99
- await this.publicContractsDB.removeNewContracts(tx);
100
- // rollback any state updates from this failed transaction
101
- await this.publicStateDB.rollback();
102
- return {
103
- tx,
104
- error: err instanceof Error ? err : new Error('Unknown error'),
105
- };
106
- }
107
- }
@@ -1,79 +0,0 @@
1
- import { Tx } from '@aztec/circuit-types';
2
- import { GlobalVariables, Header, Proof, PublicCallRequest, PublicKernelCircuitPublicInputs } from '@aztec/circuits.js';
3
- import { createDebugLogger } from '@aztec/foundation/log';
4
- import { PublicExecutor, PublicStateDB } from '@aztec/simulator';
5
- import { MerkleTreeOperations } from '@aztec/world-state';
6
-
7
- import { PublicProver } from '../prover/index.js';
8
- import { PublicKernelCircuitSimulator } from '../simulator/index.js';
9
- import { ContractsDataSourcePublicDB } from '../simulator/public_executor.js';
10
- import { AbstractPhaseManager } from './abstract_phase_manager.js';
11
- import { ApplicationLogicPhaseManager } from './application_logic_phase_manager.js';
12
- import { FailedTx } from './processed_tx.js';
13
-
14
- /**
15
- * The phase manager responsible for performing the fee preparation phase.
16
- */
17
- export class FeePreparationPhaseManager extends AbstractPhaseManager {
18
- constructor(
19
- protected db: MerkleTreeOperations,
20
- protected publicExecutor: PublicExecutor,
21
- protected publicKernel: PublicKernelCircuitSimulator,
22
- protected publicProver: PublicProver,
23
- protected globalVariables: GlobalVariables,
24
- protected historicalHeader: Header,
25
- protected publicContractsDB: ContractsDataSourcePublicDB,
26
- protected publicStateDB: PublicStateDB,
27
-
28
- protected log = createDebugLogger('aztec:sequencer:fee-preparation'),
29
- ) {
30
- super(db, publicExecutor, publicKernel, publicProver, globalVariables, historicalHeader);
31
- }
32
-
33
- extractEnqueuedPublicCalls(_tx: Tx): PublicCallRequest[] {
34
- return [];
35
- }
36
-
37
- // this is a no-op for now
38
- async handle(
39
- tx: Tx,
40
- previousPublicKernelOutput?: PublicKernelCircuitPublicInputs,
41
- previousPublicKernelProof?: Proof,
42
- ): Promise<{
43
- /**
44
- * the output of the public kernel circuit for this phase
45
- */
46
- publicKernelOutput?: PublicKernelCircuitPublicInputs;
47
- /**
48
- * the proof of the public kernel circuit for this phase
49
- */
50
- publicKernelProof?: Proof;
51
- }> {
52
- this.log.debug(`Handle ${await tx.getTxHash()} with no-op`);
53
- return {
54
- publicKernelOutput: previousPublicKernelOutput,
55
- publicKernelProof: previousPublicKernelProof,
56
- };
57
- }
58
-
59
- nextPhase(): AbstractPhaseManager {
60
- return new ApplicationLogicPhaseManager(
61
- this.db,
62
- this.publicExecutor,
63
- this.publicKernel,
64
- this.publicProver,
65
- this.globalVariables,
66
- this.historicalHeader,
67
- this.publicContractsDB,
68
- this.publicStateDB,
69
- );
70
- }
71
-
72
- async rollback(tx: Tx, err: unknown): Promise<FailedTx> {
73
- this.log.warn(`Error processing tx ${await tx.getTxHash()}: ${err}`);
74
- return {
75
- tx,
76
- error: err instanceof Error ? err : new Error('Unknown error'),
77
- };
78
- }
79
- }