@aztec-labs/simulator 6.0.0-nightly.20260829

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 (215) hide show
  1. package/README.md +57 -0
  2. package/dest/client.d.ts +6 -0
  3. package/dest/client.d.ts.map +1 -0
  4. package/dest/client.js +3 -0
  5. package/dest/common/errors.d.ts +51 -0
  6. package/dest/common/errors.d.ts.map +1 -0
  7. package/dest/common/errors.js +154 -0
  8. package/dest/common/index.d.ts +3 -0
  9. package/dest/common/index.d.ts.map +1 -0
  10. package/dest/common/index.js +2 -0
  11. package/dest/common/stats/index.d.ts +2 -0
  12. package/dest/common/stats/index.d.ts.map +1 -0
  13. package/dest/common/stats/index.js +1 -0
  14. package/dest/common/stats/stats.d.ts +4 -0
  15. package/dest/common/stats/stats.d.ts.map +1 -0
  16. package/dest/common/stats/stats.js +10 -0
  17. package/dest/private/acvm/acvm.d.ts +43 -0
  18. package/dest/private/acvm/acvm.d.ts.map +1 -0
  19. package/dest/private/acvm/acvm.js +65 -0
  20. package/dest/private/acvm/acvm_types.d.ts +10 -0
  21. package/dest/private/acvm/acvm_types.d.ts.map +1 -0
  22. package/dest/private/acvm/acvm_types.js +3 -0
  23. package/dest/private/acvm/deserialize.d.ts +35 -0
  24. package/dest/private/acvm/deserialize.d.ts.map +1 -0
  25. package/dest/private/acvm/deserialize.js +50 -0
  26. package/dest/private/acvm/index.d.ts +5 -0
  27. package/dest/private/acvm/index.d.ts.map +1 -0
  28. package/dest/private/acvm/index.js +4 -0
  29. package/dest/private/acvm/serialize.d.ts +41 -0
  30. package/dest/private/acvm/serialize.d.ts.map +1 -0
  31. package/dest/private/acvm/serialize.js +99 -0
  32. package/dest/private/acvm_native.d.ts +41 -0
  33. package/dest/private/acvm_native.d.ts.map +1 -0
  34. package/dest/private/acvm_native.js +147 -0
  35. package/dest/private/acvm_wasm.d.ts +16 -0
  36. package/dest/private/acvm_wasm.d.ts.map +1 -0
  37. package/dest/private/acvm_wasm.js +67 -0
  38. package/dest/private/acvm_wasm_with_blobs.d.ts +20 -0
  39. package/dest/private/acvm_wasm_with_blobs.d.ts.map +1 -0
  40. package/dest/private/acvm_wasm_with_blobs.js +35 -0
  41. package/dest/private/circuit_simulator.d.ts +35 -0
  42. package/dest/private/circuit_simulator.d.ts.map +1 -0
  43. package/dest/private/circuit_simulator.js +43 -0
  44. package/dest/private/factory.d.ts +12 -0
  45. package/dest/private/factory.d.ts.map +1 -0
  46. package/dest/private/factory.js +30 -0
  47. package/dest/public/avm/testing/account_proof_fetcher.d.ts +2 -0
  48. package/dest/public/avm/testing/account_proof_fetcher.d.ts.map +1 -0
  49. package/dest/public/avm/testing/account_proof_fetcher.js +152 -0
  50. package/dest/public/avm/testing/base_avm_simulation_tester.d.ts +39 -0
  51. package/dest/public/avm/testing/base_avm_simulation_tester.d.ts.map +1 -0
  52. package/dest/public/avm/testing/base_avm_simulation_tester.js +121 -0
  53. package/dest/public/avm/testing/utils.d.ts +32 -0
  54. package/dest/public/avm/testing/utils.d.ts.map +1 -0
  55. package/dest/public/avm/testing/utils.js +66 -0
  56. package/dest/public/avm_simulator.d.ts +28 -0
  57. package/dest/public/avm_simulator.d.ts.map +1 -0
  58. package/dest/public/avm_simulator.js +4 -0
  59. package/dest/public/avm_simulator_pool.d.ts +84 -0
  60. package/dest/public/avm_simulator_pool.d.ts.map +1 -0
  61. package/dest/public/avm_simulator_pool.js +311 -0
  62. package/dest/public/cdb_ipc_server.d.ts +40 -0
  63. package/dest/public/cdb_ipc_server.d.ts.map +1 -0
  64. package/dest/public/cdb_ipc_server.js +153 -0
  65. package/dest/public/contracts_db_checkpoint.d.ts +16 -0
  66. package/dest/public/contracts_db_checkpoint.d.ts.map +1 -0
  67. package/dest/public/contracts_db_checkpoint.js +30 -0
  68. package/dest/public/db_interfaces.d.ts +68 -0
  69. package/dest/public/db_interfaces.d.ts.map +1 -0
  70. package/dest/public/db_interfaces.js +3 -0
  71. package/dest/public/executor_metrics.d.ts +21 -0
  72. package/dest/public/executor_metrics.d.ts.map +1 -0
  73. package/dest/public/executor_metrics.js +64 -0
  74. package/dest/public/executor_metrics_interface.d.ts +10 -0
  75. package/dest/public/executor_metrics_interface.d.ts.map +1 -0
  76. package/dest/public/executor_metrics_interface.js +1 -0
  77. package/dest/public/fixtures/amm_test.d.ts +10 -0
  78. package/dest/public/fixtures/amm_test.d.ts.map +1 -0
  79. package/dest/public/fixtures/amm_test.js +213 -0
  80. package/dest/public/fixtures/bulk_test.d.ts +6 -0
  81. package/dest/public/fixtures/bulk_test.d.ts.map +1 -0
  82. package/dest/public/fixtures/bulk_test.js +289 -0
  83. package/dest/public/fixtures/custom_bytecode_tester.d.ts +34 -0
  84. package/dest/public/fixtures/custom_bytecode_tester.d.ts.map +1 -0
  85. package/dest/public/fixtures/custom_bytecode_tester.js +53 -0
  86. package/dest/public/fixtures/index.d.ts +10 -0
  87. package/dest/public/fixtures/index.d.ts.map +1 -0
  88. package/dest/public/fixtures/index.js +9 -0
  89. package/dest/public/fixtures/public_processor_test_env.d.ts +30 -0
  90. package/dest/public/fixtures/public_processor_test_env.d.ts.map +1 -0
  91. package/dest/public/fixtures/public_processor_test_env.js +73 -0
  92. package/dest/public/fixtures/public_tx_simulation_tester.d.ts +77 -0
  93. package/dest/public/fixtures/public_tx_simulation_tester.d.ts.map +1 -0
  94. package/dest/public/fixtures/public_tx_simulation_tester.js +176 -0
  95. package/dest/public/fixtures/simple_contract_data_source.d.ts +36 -0
  96. package/dest/public/fixtures/simple_contract_data_source.d.ts.map +1 -0
  97. package/dest/public/fixtures/simple_contract_data_source.js +95 -0
  98. package/dest/public/fixtures/token_test.d.ts +12 -0
  99. package/dest/public/fixtures/token_test.d.ts.map +1 -0
  100. package/dest/public/fixtures/token_test.js +96 -0
  101. package/dest/public/fixtures/utils.d.ts +26 -0
  102. package/dest/public/fixtures/utils.d.ts.map +1 -0
  103. package/dest/public/fixtures/utils.js +170 -0
  104. package/dest/public/fuzzing/avm_fuzzer_simulator.d.ts +65 -0
  105. package/dest/public/fuzzing/avm_fuzzer_simulator.d.ts.map +1 -0
  106. package/dest/public/fuzzing/avm_fuzzer_simulator.js +181 -0
  107. package/dest/public/fuzzing/avm_simulator_bin.d.ts +2 -0
  108. package/dest/public/fuzzing/avm_simulator_bin.d.ts.map +1 -0
  109. package/dest/public/fuzzing/avm_simulator_bin.js +108 -0
  110. package/dest/public/index.d.ts +10 -0
  111. package/dest/public/index.d.ts.map +1 -0
  112. package/dest/public/index.js +6 -0
  113. package/dest/public/public_db_sources.d.ts +83 -0
  114. package/dest/public/public_db_sources.d.ts.map +1 -0
  115. package/dest/public/public_db_sources.js +297 -0
  116. package/dest/public/public_errors.d.ts +12 -0
  117. package/dest/public/public_errors.d.ts.map +1 -0
  118. package/dest/public/public_errors.js +13 -0
  119. package/dest/public/public_processor/guarded_merkle_tree.d.ts +52 -0
  120. package/dest/public/public_processor/guarded_merkle_tree.d.ts.map +1 -0
  121. package/dest/public/public_processor/guarded_merkle_tree.js +116 -0
  122. package/dest/public/public_processor/public_processor.d.ts +71 -0
  123. package/dest/public/public_processor/public_processor.d.ts.map +1 -0
  124. package/dest/public/public_processor/public_processor.js +858 -0
  125. package/dest/public/public_processor/public_processor_metrics.d.ts +30 -0
  126. package/dest/public/public_processor/public_processor_metrics.d.ts.map +1 -0
  127. package/dest/public/public_processor/public_processor_metrics.js +116 -0
  128. package/dest/public/public_tx_simulator/dumping_public_tx_simulator.d.ts +17 -0
  129. package/dest/public/public_tx_simulator/dumping_public_tx_simulator.d.ts.map +1 -0
  130. package/dest/public/public_tx_simulator/dumping_public_tx_simulator.js +39 -0
  131. package/dest/public/public_tx_simulator/factories.d.ts +14 -0
  132. package/dest/public/public_tx_simulator/factories.d.ts.map +1 -0
  133. package/dest/public/public_tx_simulator/factories.js +28 -0
  134. package/dest/public/public_tx_simulator/index.d.ts +6 -0
  135. package/dest/public/public_tx_simulator/index.d.ts.map +1 -0
  136. package/dest/public/public_tx_simulator/index.js +3 -0
  137. package/dest/public/public_tx_simulator/public_tx_simulator.d.ts +53 -0
  138. package/dest/public/public_tx_simulator/public_tx_simulator.d.ts.map +1 -0
  139. package/dest/public/public_tx_simulator/public_tx_simulator.js +127 -0
  140. package/dest/public/public_tx_simulator/public_tx_simulator_base.d.ts +24 -0
  141. package/dest/public/public_tx_simulator/public_tx_simulator_base.d.ts.map +1 -0
  142. package/dest/public/public_tx_simulator/public_tx_simulator_base.js +31 -0
  143. package/dest/public/public_tx_simulator/public_tx_simulator_interface.d.ts +32 -0
  144. package/dest/public/public_tx_simulator/public_tx_simulator_interface.d.ts.map +1 -0
  145. package/dest/public/public_tx_simulator/public_tx_simulator_interface.js +1 -0
  146. package/dest/public/side_effect_errors.d.ts +44 -0
  147. package/dest/public/side_effect_errors.d.ts.map +1 -0
  148. package/dest/public/side_effect_errors.js +75 -0
  149. package/dest/public/test_executor_metrics.d.ts +56 -0
  150. package/dest/public/test_executor_metrics.d.ts.map +1 -0
  151. package/dest/public/test_executor_metrics.js +305 -0
  152. package/dest/public/unique_class_ids.d.ts +37 -0
  153. package/dest/public/unique_class_ids.d.ts.map +1 -0
  154. package/dest/public/unique_class_ids.js +61 -0
  155. package/dest/public/utils.d.ts +3 -0
  156. package/dest/public/utils.d.ts.map +1 -0
  157. package/dest/public/utils.js +18 -0
  158. package/dest/server.d.ts +7 -0
  159. package/dest/server.d.ts.map +1 -0
  160. package/dest/server.js +5 -0
  161. package/package.json +109 -0
  162. package/src/client.ts +5 -0
  163. package/src/common/errors.ts +219 -0
  164. package/src/common/index.ts +2 -0
  165. package/src/common/stats/index.ts +1 -0
  166. package/src/common/stats/stats.ts +20 -0
  167. package/src/private/acvm/acvm.ts +114 -0
  168. package/src/private/acvm/acvm_types.ts +11 -0
  169. package/src/private/acvm/deserialize.ts +58 -0
  170. package/src/private/acvm/index.ts +4 -0
  171. package/src/private/acvm/serialize.ts +123 -0
  172. package/src/private/acvm_native.ts +200 -0
  173. package/src/private/acvm_wasm.ts +80 -0
  174. package/src/private/acvm_wasm_with_blobs.ts +55 -0
  175. package/src/private/circuit_simulator.ts +91 -0
  176. package/src/private/factory.ts +40 -0
  177. package/src/public/avm/testing/account_proof.json +553 -0
  178. package/src/public/avm/testing/account_proof_fetcher.ts +166 -0
  179. package/src/public/avm/testing/base_avm_simulation_tester.ts +162 -0
  180. package/src/public/avm/testing/utils.ts +114 -0
  181. package/src/public/avm_simulator.ts +29 -0
  182. package/src/public/avm_simulator_pool.ts +355 -0
  183. package/src/public/cdb_ipc_server.ts +198 -0
  184. package/src/public/contracts_db_checkpoint.ts +41 -0
  185. package/src/public/db_interfaces.ts +76 -0
  186. package/src/public/executor_metrics.ts +102 -0
  187. package/src/public/executor_metrics_interface.ts +20 -0
  188. package/src/public/fixtures/amm_test.ts +331 -0
  189. package/src/public/fixtures/bulk_test.ts +194 -0
  190. package/src/public/fixtures/custom_bytecode_tester.ts +83 -0
  191. package/src/public/fixtures/index.ts +13 -0
  192. package/src/public/fixtures/public_processor_test_env.ts +88 -0
  193. package/src/public/fixtures/public_tx_simulation_tester.ts +315 -0
  194. package/src/public/fixtures/simple_contract_data_source.ts +122 -0
  195. package/src/public/fixtures/token_test.ts +148 -0
  196. package/src/public/fixtures/utils.ts +269 -0
  197. package/src/public/fuzzing/avm_fuzzer_simulator.ts +302 -0
  198. package/src/public/fuzzing/avm_simulator_bin.ts +156 -0
  199. package/src/public/index.ts +16 -0
  200. package/src/public/public_db_sources.ts +405 -0
  201. package/src/public/public_errors.ts +14 -0
  202. package/src/public/public_processor/guarded_merkle_tree.ts +161 -0
  203. package/src/public/public_processor/public_processor.ts +657 -0
  204. package/src/public/public_processor/public_processor_metrics.ts +138 -0
  205. package/src/public/public_tx_simulator/dumping_public_tx_simulator.ts +66 -0
  206. package/src/public/public_tx_simulator/factories.ts +61 -0
  207. package/src/public/public_tx_simulator/index.ts +8 -0
  208. package/src/public/public_tx_simulator/public_tx_simulator.ts +190 -0
  209. package/src/public/public_tx_simulator/public_tx_simulator_base.ts +37 -0
  210. package/src/public/public_tx_simulator/public_tx_simulator_interface.ts +33 -0
  211. package/src/public/side_effect_errors.ts +96 -0
  212. package/src/public/test_executor_metrics.ts +399 -0
  213. package/src/public/unique_class_ids.ts +79 -0
  214. package/src/public/utils.ts +16 -0
  215. package/src/server.ts +6 -0
@@ -0,0 +1,297 @@
1
+ import { L1_TO_L2_MSG_TREE_LEAF_COUNT, NOTE_HASH_TREE_LEAF_COUNT, NULLIFIER_SUBTREE_HEIGHT, PUBLIC_DATA_SUBTREE_HEIGHT } from '@aztec-labs/constants';
2
+ import { Fr } from '@aztec-labs/foundation/curves/bn254';
3
+ import { createLogger } from '@aztec-labs/foundation/log';
4
+ import { Timer } from '@aztec-labs/foundation/timer';
5
+ import { ContractClassPublishedEvent } from '@aztec-labs/protocol-contracts/class-registry';
6
+ import { ContractInstancePublishedEvent } from '@aztec-labs/protocol-contracts/instance-registry';
7
+ import { PublicDataWrite } from '@aztec-labs/stdlib/avm';
8
+ import { AllContractDeploymentData, computePublicBytecodeCommitment } from '@aztec-labs/stdlib/contract';
9
+ import { computePublicDataTreeLeafSlot } from '@aztec-labs/stdlib/hash';
10
+ import { MerkleTreeId, NullifierLeaf, PublicDataTreeLeaf, getTreeName } from '@aztec-labs/stdlib/trees';
11
+ import { TreeSnapshots } from '@aztec-labs/stdlib/tx';
12
+ import { strict as assert } from 'assert';
13
+ import { ContractsDbCheckpoint } from './contracts_db_checkpoint.js';
14
+ import { L1ToL2MessageIndexOutOfRangeError, NoteHashIndexOutOfRangeError } from './side_effect_errors.js';
15
+ /**
16
+ * Implements the PublicContractsDBInterface using a ContractDataSource.
17
+ * Uses a stack-based checkpoint model for managing contract state.
18
+ */ export class PublicContractsDB {
19
+ dataSource;
20
+ contractStateStack;
21
+ log;
22
+ constructor(dataSource, bindings){
23
+ this.dataSource = dataSource;
24
+ this.contractStateStack = [
25
+ new ContractsDbCheckpoint()
26
+ ];
27
+ this.log = createLogger('simulator:contracts-data-source', bindings);
28
+ }
29
+ /** Parses raw contract deployment data and inserts the resulting contracts into the current checkpoint. */ addContractsFromLogs(contractDeploymentData) {
30
+ const currentState = this.getCurrentState();
31
+ this.addContractClassesFromEvents(ContractClassPublishedEvent.extractContractClassEvents(contractDeploymentData.getContractClassLogs()), currentState);
32
+ this.addContractInstancesFromEvents(ContractInstancePublishedEvent.extractContractInstanceEvents(contractDeploymentData.getPrivateLogs()), currentState);
33
+ }
34
+ addNewContracts(tx) {
35
+ const contractDeploymentData = AllContractDeploymentData.fromTx(tx);
36
+ this.addContractsFromLogs(contractDeploymentData.getNonRevertibleContractDeploymentData());
37
+ this.addContractsFromLogs(contractDeploymentData.getRevertibleContractDeploymentData());
38
+ }
39
+ /** Inserts typed contract instances directly into the current checkpoint. */ addContracts(contractInstances) {
40
+ const currentState = this.getCurrentState();
41
+ for (const instance of contractInstances ?? []){
42
+ currentState.addInstance(instance.address, instance);
43
+ }
44
+ }
45
+ /**
46
+ * Creates a new checkpoint, copying the current state for upcoming modifications,
47
+ * and enabling rollbacks to current state in case of a revert.
48
+ */ createCheckpoint() {
49
+ const currentState = this.getCurrentState();
50
+ const newState = currentState.fork();
51
+ this.contractStateStack.push(newState);
52
+ }
53
+ /**
54
+ * Commits the current checkpoint, accepting its state latest.
55
+ */ commitCheckpoint() {
56
+ if (this.contractStateStack.length <= 1) {
57
+ throw new Error('No checkpoint to commit');
58
+ }
59
+ const topState = this.contractStateStack.pop();
60
+ this.contractStateStack[this.contractStateStack.length - 1] = topState;
61
+ }
62
+ /**
63
+ * Commits the current checkpoint, not erroring if there is no checkpoint
64
+ * to commit. This is useful to do a sanity commit at the end of tx execution,
65
+ * doing nothing if the checkpoint was already reverted, but truly committing
66
+ * otherwise.
67
+ */ commitCheckpointOkIfNone() {
68
+ if (this.contractStateStack.length <= 1) {
69
+ return;
70
+ }
71
+ const topState = this.contractStateStack.pop();
72
+ this.contractStateStack[this.contractStateStack.length - 1] = topState;
73
+ }
74
+ /**
75
+ * Reverts the current checkpoint, discarding its state and rolling back
76
+ * to the state as of the latest checkpoint.
77
+ */ revertCheckpoint() {
78
+ if (this.contractStateStack.length <= 1) {
79
+ throw new Error('No checkpoint to revert');
80
+ }
81
+ this.contractStateStack.pop();
82
+ }
83
+ getCurrentState() {
84
+ return this.contractStateStack[this.contractStateStack.length - 1];
85
+ }
86
+ // TODO(fcarreiro/alvaro): This method currently needs a blockNumber. Since this class
87
+ // is only ever used for a given block, it should be possible to construct it with the
88
+ // block number and then forget about it. However, since this class (and interface) is
89
+ // currently more externally exposed than we'd want to, Facundo preferred to not add it
90
+ // to the constructor right now. If we can make this class more private, we should
91
+ // reconsider this. A litmus test is in how many places we need to initialize with a
92
+ // dummy block number (tests or not) and pass block numbers to `super`.
93
+ // Note: Block number got changed to timestamp so this comment ^ is outdated. Keeping
94
+ // the comment as is as I am not part of the AVM cabal.
95
+ async getContractInstance(address, timestamp) {
96
+ const currentState = this.getCurrentState();
97
+ return currentState.getInstance(address) ?? await this.dataSource.getContract(address, timestamp);
98
+ }
99
+ async getContractClass(contractClassId) {
100
+ const currentState = this.getCurrentState();
101
+ return currentState.getClass(contractClassId) ?? await this.dataSource.getContractClass(contractClassId);
102
+ }
103
+ async getBytecodeCommitment(contractClassId) {
104
+ const currentState = this.getCurrentState();
105
+ const commitment = currentState.getBytecodeCommitment(contractClassId) ?? await this.dataSource.getBytecodeCommitment(contractClassId);
106
+ if (commitment !== undefined) {
107
+ return commitment;
108
+ }
109
+ // Not in the current state or the store, compute it here
110
+ // Get the contract class
111
+ const contractClass = await this.getContractClass(contractClassId);
112
+ if (contractClass === undefined) {
113
+ // cannot compute bytecode commitment if contract class is not found
114
+ return undefined;
115
+ }
116
+ const value = await computePublicBytecodeCommitment(contractClass.packedBytecode);
117
+ // Add to cache (current checkpoint state) so we don't compute again
118
+ currentState.addBytecodeCommitment(contractClassId, value);
119
+ return value;
120
+ }
121
+ async getDebugFunctionName(address, selector) {
122
+ return await this.dataSource.getDebugFunctionName(address, selector);
123
+ }
124
+ addContractClassesFromEvents(contractClassEvents, state) {
125
+ for (const event of contractClassEvents){
126
+ this.log.debug(`Adding class ${event.contractClassId.toString()} to contract state`);
127
+ const contractClass = event.toContractClassPublic();
128
+ state.addClass(event.contractClassId, contractClass);
129
+ }
130
+ }
131
+ addContractInstancesFromEvents(contractInstanceEvents, state) {
132
+ contractInstanceEvents.forEach((e)=>{
133
+ this.log.debug(`Adding instance ${e.address.toString()} with class ${e.contractClassId.toString()} to contract state`);
134
+ state.addInstance(e.address, e.toContractInstance());
135
+ });
136
+ }
137
+ }
138
+ /**
139
+ * A high-level class that provides access to the merkle trees.
140
+ *
141
+ * This class is just a helper wrapper around a merkle db. Anything that you can do with it
142
+ * can also be done directly with the merkle db. This class should NOT be exposed or used
143
+ * outside of `simulator/src/public`.
144
+ *
145
+ * NOTE: This class is currently written in such a way that it would generate the
146
+ * necessary hints if used with a hinting merkle db. This is a bit of a leak of concepts.
147
+ * Eventually we can have everything depend on a config/factory at the TxSimulator level
148
+ * to decide whether to use hints or not (same with tracing, etc).
149
+ */ export class PublicTreesDB {
150
+ db;
151
+ logger;
152
+ constructor(db, bindings){
153
+ this.db = db;
154
+ this.logger = createLogger('simulator:public-trees-db', bindings);
155
+ }
156
+ async storageRead(contract, slot) {
157
+ const timer = new Timer();
158
+ const leafSlot = (await computePublicDataTreeLeafSlot(contract, slot)).toBigInt();
159
+ const lowLeafResult = await this.db.getPreviousValueIndex(MerkleTreeId.PUBLIC_DATA_TREE, leafSlot);
160
+ if (!lowLeafResult) {
161
+ throw new Error('Low leaf not found');
162
+ }
163
+ // TODO: We need this for the hints. See class comment for more details.
164
+ await this.db.getSiblingPath(MerkleTreeId.PUBLIC_DATA_TREE, lowLeafResult.index);
165
+ // Unconditionally fetching the preimage for the hints. Move it to the hinting layer?
166
+ const preimage = await this.db.getLeafPreimage(MerkleTreeId.PUBLIC_DATA_TREE, lowLeafResult.index);
167
+ const result = lowLeafResult.alreadyPresent ? preimage.leaf.value : Fr.ZERO;
168
+ this.logger.debug(`Storage read (contract=${contract}, slot=${slot}, value=${result})`, {
169
+ eventName: 'public-db-access',
170
+ duration: timer.ms(),
171
+ operation: 'storage-read'
172
+ });
173
+ return result;
174
+ }
175
+ async storageWrite(contract, slot, newValue) {
176
+ const timer = new Timer();
177
+ const leafSlot = await computePublicDataTreeLeafSlot(contract, slot);
178
+ const publicDataWrite = new PublicDataWrite(leafSlot, newValue);
179
+ await this.db.sequentialInsert(MerkleTreeId.PUBLIC_DATA_TREE, [
180
+ publicDataWrite.toBuffer()
181
+ ]);
182
+ this.logger.debug(`Storage write (contract=${contract}, slot=${slot}, value=${newValue})`, {
183
+ eventName: 'public-db-access',
184
+ duration: timer.ms(),
185
+ operation: 'storage-write'
186
+ });
187
+ }
188
+ async getL1ToL2LeafValue(leafIndex) {
189
+ const timer = new Timer();
190
+ if (leafIndex > L1_TO_L2_MSG_TREE_LEAF_COUNT) {
191
+ throw new L1ToL2MessageIndexOutOfRangeError(Number(leafIndex));
192
+ }
193
+ const leafValue = await this.db.getLeafValue(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, leafIndex);
194
+ assert(leafValue !== undefined, 'Unexpected null response from l1 to l2 message tree');
195
+ // TODO: We need this for the hints. See class comment for more details.
196
+ await this.db.getSiblingPath(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, leafIndex);
197
+ this.logger.debug(`Fetched L1 to L2 message leaf value (leafIndex=${leafIndex}, value=${leafValue})`, {
198
+ eventName: 'public-db-access',
199
+ duration: timer.ms(),
200
+ operation: 'get-l1-to-l2-message-leaf-value'
201
+ });
202
+ return leafValue;
203
+ }
204
+ async getNoteHash(leafIndex) {
205
+ const timer = new Timer();
206
+ if (leafIndex > NOTE_HASH_TREE_LEAF_COUNT) {
207
+ throw new NoteHashIndexOutOfRangeError(Number(leafIndex));
208
+ }
209
+ const leafValue = await this.db.getLeafValue(MerkleTreeId.NOTE_HASH_TREE, leafIndex);
210
+ assert(leafValue !== undefined, 'Unexpected null response from note hash tree');
211
+ // TODO: We need this for the hints. See class comment for more details.
212
+ await this.db.getSiblingPath(MerkleTreeId.NOTE_HASH_TREE, leafIndex);
213
+ this.logger.debug(`Fetched note hash leaf value (leafIndex=${leafIndex}, value=${leafValue})`, {
214
+ eventName: 'public-db-access',
215
+ duration: timer.ms(),
216
+ operation: 'get-note-hash'
217
+ });
218
+ return leafValue;
219
+ }
220
+ async writeNoteHash(noteHash) {
221
+ const timer = new Timer();
222
+ await this.db.appendLeaves(MerkleTreeId.NOTE_HASH_TREE, [
223
+ noteHash
224
+ ]);
225
+ this.logger.debug(`Wrote note hash (noteHash=${noteHash})`, {
226
+ eventName: 'public-db-access',
227
+ duration: timer.ms(),
228
+ operation: 'write-note-hash'
229
+ });
230
+ }
231
+ async checkNullifierExists(nullifier) {
232
+ const timer = new Timer();
233
+ const lowLeafResult = await this.db.getPreviousValueIndex(MerkleTreeId.NULLIFIER_TREE, nullifier.toBigInt());
234
+ if (!lowLeafResult) {
235
+ throw new Error('Low leaf not found');
236
+ }
237
+ // TODO: We need this for the hints. See class comment for more details.
238
+ await this.db.getSiblingPath(MerkleTreeId.NULLIFIER_TREE, lowLeafResult.index);
239
+ // TODO: We need this for the hints. See class comment for more details.
240
+ await this.db.getLeafPreimage(MerkleTreeId.NULLIFIER_TREE, lowLeafResult.index);
241
+ const exists = lowLeafResult.alreadyPresent;
242
+ this.logger.debug(`Checked nullifier exists (nullifier=${nullifier}, exists=${exists})`, {
243
+ eventName: 'public-db-access',
244
+ duration: timer.ms(),
245
+ operation: 'check-nullifier-exists'
246
+ });
247
+ return exists;
248
+ }
249
+ async writeNullifier(siloedNullifier) {
250
+ const timer = new Timer();
251
+ await this.db.sequentialInsert(MerkleTreeId.NULLIFIER_TREE, [
252
+ siloedNullifier.toBuffer()
253
+ ]);
254
+ this.logger.debug(`Wrote nullifier (nullifier=${siloedNullifier})`, {
255
+ eventName: 'public-db-access',
256
+ duration: timer.ms(),
257
+ operation: 'write-nullifier'
258
+ });
259
+ }
260
+ async padTree(treeId, leavesToInsert) {
261
+ const timer = new Timer();
262
+ switch(treeId){
263
+ // Indexed trees.
264
+ case MerkleTreeId.NULLIFIER_TREE:
265
+ await this.db.batchInsert(treeId, Array(leavesToInsert).fill(NullifierLeaf.empty().toBuffer()), NULLIFIER_SUBTREE_HEIGHT);
266
+ break;
267
+ case MerkleTreeId.PUBLIC_DATA_TREE:
268
+ await this.db.batchInsert(treeId, Array(leavesToInsert).fill(PublicDataTreeLeaf.empty().toBuffer()), PUBLIC_DATA_SUBTREE_HEIGHT);
269
+ break;
270
+ // Append-only trees.
271
+ case MerkleTreeId.L1_TO_L2_MESSAGE_TREE:
272
+ case MerkleTreeId.NOTE_HASH_TREE:
273
+ await this.db.appendLeaves(treeId, Array(leavesToInsert).fill(Fr.ZERO));
274
+ break;
275
+ default:
276
+ throw new Error(`Padding not supported for tree ${treeId}`);
277
+ }
278
+ this.logger.debug(`Padded tree (tree=${getTreeName(treeId)}, leavesToInsert=${leavesToInsert})`, {
279
+ eventName: 'public-db-access',
280
+ duration: timer.ms(),
281
+ operation: 'pad-tree'
282
+ });
283
+ }
284
+ async createCheckpoint() {
285
+ await this.db.createCheckpoint();
286
+ }
287
+ async commitCheckpoint() {
288
+ await this.db.commitCheckpoint();
289
+ }
290
+ async revertCheckpoint() {
291
+ await this.db.revertCheckpoint();
292
+ }
293
+ async getTreeSnapshots() {
294
+ const stateReference = await this.db.getStateReference();
295
+ return new TreeSnapshots(stateReference.l1ToL2MessageTree, stateReference.partial.noteHashTree, stateReference.partial.nullifierTree, stateReference.partial.publicDataTree);
296
+ }
297
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Any known (and checked) error that can be thrown during public execution.
3
+ * Includes AvmExecutionErrors and SideEffectErrors.
4
+ *
5
+ * AvmSimulator catches any checked errors before returning a boolean "reverted".
6
+ * Unchecked errors are generally the result of a bug. They are propagated and
7
+ * ultimately will be the resonsibility of PublicProcessor to handle.
8
+ */
9
+ export declare abstract class CheckedPublicExecutionError extends Error {
10
+ constructor(message: string);
11
+ }
12
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHVibGljX2Vycm9ycy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3B1YmxpYy9wdWJsaWNfZXJyb3JzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOzs7Ozs7O0dBT0c7QUFDSCw4QkFBc0IsMkJBQTRCLFNBQVEsS0FBSztJQUM3RCxZQUFZLE9BQU8sRUFBRSxNQUFNLEVBRzFCO0NBQ0YifQ==
@@ -0,0 +1 @@
1
+ {"version":3,"file":"public_errors.d.ts","sourceRoot":"","sources":["../../src/public/public_errors.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,8BAAsB,2BAA4B,SAAQ,KAAK;IAC7D,YAAY,OAAO,EAAE,MAAM,EAG1B;CACF"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Any known (and checked) error that can be thrown during public execution.
3
+ * Includes AvmExecutionErrors and SideEffectErrors.
4
+ *
5
+ * AvmSimulator catches any checked errors before returning a boolean "reverted".
6
+ * Unchecked errors are generally the result of a bug. They are propagated and
7
+ * ultimately will be the resonsibility of PublicProcessor to handle.
8
+ */ export class CheckedPublicExecutionError extends Error {
9
+ constructor(message){
10
+ super(message);
11
+ this.name = 'CheckedPublicExecutionError';
12
+ }
13
+ }
@@ -0,0 +1,52 @@
1
+ import type { BlockNumber } from '@aztec-labs/foundation/branded-types';
2
+ import type { IndexedTreeLeafPreimage, SiblingPath } from '@aztec-labs/foundation/trees';
3
+ import type { BatchInsertionResult, IndexedTreeId, MerkleTreeId, MerkleTreeLeafType, MerkleTreeWriteOperations, SequentialInsertionResult, TreeHeights, TreeInfo } from '@aztec-labs/stdlib/trees';
4
+ import type { BlockHeader, StateReference } from '@aztec-labs/stdlib/tx';
5
+ import type { WorldStateRevision } from '@aztec-labs/stdlib/world-state';
6
+ /**
7
+ * Wraps an instance of `MerkleTreeWriteOperations` to allow the sequencer to gate access.
8
+ * If transactions execution goes past the deadline, the simulator will continue to execute and update the world state
9
+ * The public processor however requires that the world state remain constant after the deadline in order to finalize the block
10
+ * The public processor provides this implementation of MerkleTreeWriteOperations to the simulator
11
+ */
12
+ export declare class GuardedMerkleTreeOperations implements MerkleTreeWriteOperations {
13
+ private target;
14
+ private isStopped;
15
+ private serialQueue;
16
+ constructor(target: MerkleTreeWriteOperations);
17
+ private guard;
18
+ private guardAndPush;
19
+ getUnderlyingFork(): MerkleTreeWriteOperations;
20
+ stop(): Promise<void>;
21
+ appendLeaves<ID extends MerkleTreeId>(treeId: ID, leaves: MerkleTreeLeafType<ID>[]): Promise<void>;
22
+ updateArchive(header: BlockHeader): Promise<void>;
23
+ batchInsert<TreeHeight extends number, SubtreeSiblingPathHeight extends number, ID extends IndexedTreeId>(treeId: ID, leaves: Buffer[], subtreeHeight: number): Promise<BatchInsertionResult<TreeHeight, SubtreeSiblingPathHeight>>;
24
+ sequentialInsert<TreeHeight extends number, ID extends IndexedTreeId>(treeId: ID, leaves: Buffer[]): Promise<SequentialInsertionResult<TreeHeight>>;
25
+ close(): Promise<void>;
26
+ [Symbol.asyncDispose](): Promise<void>;
27
+ getTreeInfo(treeId: MerkleTreeId): Promise<TreeInfo>;
28
+ getStateReference(): Promise<StateReference>;
29
+ getInitialHeader(): BlockHeader;
30
+ getRevision(): WorldStateRevision;
31
+ getIpcPath(): string;
32
+ getSiblingPath<ID extends MerkleTreeId>(treeId: ID, index: bigint): Promise<SiblingPath<TreeHeights[ID]>>;
33
+ getPreviousValueIndex<ID extends IndexedTreeId>(treeId: ID, value: bigint): Promise<{
34
+ index: bigint;
35
+ alreadyPresent: boolean;
36
+ } | undefined>;
37
+ getLeafPreimage<ID extends IndexedTreeId>(treeId: ID, index: bigint): Promise<IndexedTreeLeafPreimage | undefined>;
38
+ findLeafIndices<ID extends MerkleTreeId>(treeId: ID, values: MerkleTreeLeafType<ID>[]): Promise<(bigint | undefined)[]>;
39
+ findLeafIndicesAfter<ID extends MerkleTreeId>(treeId: ID, values: MerkleTreeLeafType<ID>[], startIndex: bigint): Promise<(bigint | undefined)[]>;
40
+ getLeafValue<ID extends MerkleTreeId>(treeId: ID, index: bigint): Promise<MerkleTreeLeafType<typeof treeId> | undefined>;
41
+ getBlockNumbersForLeafIndices<ID extends MerkleTreeId>(treeId: ID, leafIndices: bigint[]): Promise<(BlockNumber | undefined)[]>;
42
+ createCheckpoint(): Promise<number>;
43
+ commitCheckpoint(): Promise<void>;
44
+ revertCheckpoint(): Promise<void>;
45
+ commitAllCheckpointsTo(depth: number): Promise<void>;
46
+ revertAllCheckpointsTo(depth: number): Promise<void>;
47
+ findSiblingPaths<ID extends MerkleTreeId>(treeId: ID, values: MerkleTreeLeafType<ID>[]): Promise<({
48
+ path: SiblingPath<TreeHeights[ID]>;
49
+ index: bigint;
50
+ } | undefined)[]>;
51
+ }
52
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ3VhcmRlZF9tZXJrbGVfdHJlZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL3B1YmxpYy9wdWJsaWNfcHJvY2Vzc29yL2d1YXJkZWRfbWVya2xlX3RyZWUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsV0FBVyxFQUFFLE1BQU0sc0NBQXNDLENBQUM7QUFFeEUsT0FBTyxLQUFLLEVBQUUsdUJBQXVCLEVBQUUsV0FBVyxFQUFFLE1BQU0sOEJBQThCLENBQUM7QUFDekYsT0FBTyxLQUFLLEVBQ1Ysb0JBQW9CLEVBQ3BCLGFBQWEsRUFDYixZQUFZLEVBQ1osa0JBQWtCLEVBQ2xCLHlCQUF5QixFQUN6Qix5QkFBeUIsRUFDekIsV0FBVyxFQUNYLFFBQVEsRUFDVCxNQU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UFDLElBQUksQ0FBQyxDQUVoQztJQUNELHNCQUFzQixDQUFDLEtBQUssRUFBRSxNQUFNLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxDQUVuRDtJQUNELHNCQUFzQixDQUFDLEtBQUssRUFBRSxNQUFNLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxDQUVuRDtJQUNELGdCQUFnQixDQUFDLEVBQUUsU0FBUyxZQUFZLEVBQ3RDLE1BQU0sRUFBRSxFQUFFLEVBQ1YsTUFBTSxFQUFFLGtCQUFrQixDQUFDLEVBQUUsQ0FBQyxFQUFFLEdBQy9CLE9BQU8sQ0FBQyxDQUFDO1FBQUUsSUFBSSxFQUFFLFdBQVcsQ0FBQyxXQUFXLENBQUMsRUFBRSxDQUFDLENBQUMsQ0FBQztRQUFDLEtBQUssRUFBRSxNQUFNLENBQUE7S0FBRSxHQUFHLFNBQVMsQ0FBQyxFQUFFLENBQUMsQ0FFaEY7Q0FDRiJ9
@@ -0,0 +1 @@
1
+ {"version":3,"file":"guarded_merkle_tree.d.ts","sourceRoot":"","sources":["../../../src/public/public_processor/guarded_merkle_tree.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AAExE,OAAO,KAAK,EAAE,uBAAuB,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AACzF,OAAO,KAAK,EACV,oBAAoB,EACpB,aAAa,EACb,YAAY,EACZ,kBAAkB,EAClB,yBAAyB,EACzB,yBAAyB,EACzB,WAAW,EACX,QAAQ,EACT,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACzE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAEzE;;;;;GAKG;AAEH,qBAAa,2BAA4B,YAAW,yBAAyB;IAI/D,OAAO,CAAC,MAAM;IAH1B,OAAO,CAAC,SAAS,CAAS;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AI,OAAO,CAAC,IAAI,CAAC,CAEhC;IACD,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAEnD;IACD,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAEnD;IACD,gBAAgB,CAAC,EAAE,SAAS,YAAY,EACtC,MAAM,EAAE,EAAE,EACV,MAAM,EAAE,kBAAkB,CAAC,EAAE,CAAC,EAAE,GAC/B,OAAO,CAAC,CAAC;QAAE,IAAI,EAAE,WAAW,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS,CAAC,EAAE,CAAC,CAEhF;CACF"}
@@ -0,0 +1,116 @@
1
+ var _computedKey;
2
+ import { SerialQueue } from '@aztec-labs/foundation/queue';
3
+ _computedKey = Symbol.asyncDispose;
4
+ /**
5
+ * Wraps an instance of `MerkleTreeWriteOperations` to allow the sequencer to gate access.
6
+ * If transactions execution goes past the deadline, the simulator will continue to execute and update the world state
7
+ * The public processor however requires that the world state remain constant after the deadline in order to finalize the block
8
+ * The public processor provides this implementation of MerkleTreeWriteOperations to the simulator
9
+ */ export class GuardedMerkleTreeOperations {
10
+ target;
11
+ isStopped;
12
+ serialQueue;
13
+ constructor(target){
14
+ this.target = target;
15
+ this.isStopped = false;
16
+ this.serialQueue = new SerialQueue();
17
+ this.serialQueue.start();
18
+ }
19
+ guard() {
20
+ if (this.isStopped) {
21
+ throw new Error('Merkle tree access has been stopped');
22
+ }
23
+ }
24
+ // Executes the provided function only if the guard is not stopped.
25
+ guardAndPush(fn) {
26
+ this.guard();
27
+ return this.serialQueue.put(()=>{
28
+ this.guard();
29
+ return fn();
30
+ });
31
+ }
32
+ getUnderlyingFork() {
33
+ return this.target;
34
+ }
35
+ // Stops all further access to the merkle trees via this object
36
+ async stop() {
37
+ await this.serialQueue.put(()=>{
38
+ this.isStopped = true;
39
+ return Promise.resolve();
40
+ });
41
+ return this.serialQueue.end();
42
+ }
43
+ // Proxy all methods to the target
44
+ appendLeaves(treeId, leaves) {
45
+ return this.guardAndPush(()=>this.target.appendLeaves(treeId, leaves));
46
+ }
47
+ updateArchive(header) {
48
+ return this.guardAndPush(()=>this.target.updateArchive(header));
49
+ }
50
+ batchInsert(treeId, leaves, subtreeHeight) {
51
+ return this.guardAndPush(()=>this.target.batchInsert(treeId, leaves, subtreeHeight));
52
+ }
53
+ sequentialInsert(treeId, leaves) {
54
+ return this.guardAndPush(()=>this.target.sequentialInsert(treeId, leaves));
55
+ }
56
+ close() {
57
+ return this.guardAndPush(()=>this.target.close());
58
+ }
59
+ async [_computedKey]() {
60
+ await this.close();
61
+ }
62
+ getTreeInfo(treeId) {
63
+ return this.guardAndPush(()=>this.target.getTreeInfo(treeId));
64
+ }
65
+ getStateReference() {
66
+ return this.guardAndPush(()=>this.target.getStateReference());
67
+ }
68
+ getInitialHeader() {
69
+ return this.target.getInitialHeader();
70
+ }
71
+ getRevision() {
72
+ return this.target.getRevision();
73
+ }
74
+ getIpcPath() {
75
+ return this.target.getIpcPath();
76
+ }
77
+ getSiblingPath(treeId, index) {
78
+ return this.guardAndPush(()=>this.target.getSiblingPath(treeId, index));
79
+ }
80
+ getPreviousValueIndex(treeId, value) {
81
+ return this.guardAndPush(()=>this.target.getPreviousValueIndex(treeId, value));
82
+ }
83
+ getLeafPreimage(treeId, index) {
84
+ return this.guardAndPush(()=>this.target.getLeafPreimage(treeId, index));
85
+ }
86
+ findLeafIndices(treeId, values) {
87
+ return this.guardAndPush(()=>this.target.findLeafIndices(treeId, values));
88
+ }
89
+ findLeafIndicesAfter(treeId, values, startIndex) {
90
+ return this.guardAndPush(()=>this.target.findLeafIndicesAfter(treeId, values, startIndex));
91
+ }
92
+ getLeafValue(treeId, index) {
93
+ return this.guardAndPush(()=>this.target.getLeafValue(treeId, index));
94
+ }
95
+ getBlockNumbersForLeafIndices(treeId, leafIndices) {
96
+ return this.guardAndPush(()=>this.target.getBlockNumbersForLeafIndices(treeId, leafIndices));
97
+ }
98
+ createCheckpoint() {
99
+ return this.guardAndPush(()=>this.target.createCheckpoint());
100
+ }
101
+ commitCheckpoint() {
102
+ return this.guardAndPush(()=>this.target.commitCheckpoint());
103
+ }
104
+ revertCheckpoint() {
105
+ return this.guardAndPush(()=>this.target.revertCheckpoint());
106
+ }
107
+ commitAllCheckpointsTo(depth) {
108
+ return this.guardAndPush(()=>this.target.commitAllCheckpointsTo(depth));
109
+ }
110
+ revertAllCheckpointsTo(depth) {
111
+ return this.guardAndPush(()=>this.target.revertAllCheckpointsTo(depth));
112
+ }
113
+ findSiblingPaths(treeId, values) {
114
+ return this.guardAndPush(()=>this.target.findSiblingPaths(treeId, values));
115
+ }
116
+ }
@@ -0,0 +1,71 @@
1
+ import { type Logger, type LoggerBindings } from '@aztec-labs/foundation/log';
2
+ import { DateProvider } from '@aztec-labs/foundation/timer';
3
+ import { PublicSimulatorConfig } from '@aztec-labs/stdlib/avm';
4
+ import type { ContractDataSource } from '@aztec-labs/stdlib/contract';
5
+ import type { MerkleTreeWriteOperations, PublicProcessorLimits, PublicProcessorValidator, SequencerConfig } from '@aztec-labs/stdlib/interfaces/server';
6
+ import { type DebugLog, type DebugLogStore } from '@aztec-labs/stdlib/logs';
7
+ import { type FailedTx, GlobalVariables, NestedProcessReturnValues, type ProcessedTx, Tx } from '@aztec-labs/stdlib/tx';
8
+ import { type TelemetryClient, type Traceable, type Tracer } from '@aztec-labs/telemetry-client';
9
+ import type { AvmSimulator } from '../avm_simulator.js';
10
+ import { PublicContractsDB } from '../public_db_sources.js';
11
+ import { type PublicTxSimulatorConfig, type PublicTxSimulatorInterface } from '../public_tx_simulator/index.js';
12
+ import { GuardedMerkleTreeOperations } from './guarded_merkle_tree.js';
13
+ /**
14
+ * Creates new instances of PublicProcessor given the provided merkle tree db and contract data source.
15
+ */
16
+ export declare class PublicProcessorFactory {
17
+ private contractDataSource;
18
+ private avmSimulator;
19
+ private dateProvider;
20
+ protected telemetryClient: TelemetryClient;
21
+ private log;
22
+ constructor(contractDataSource: ContractDataSource, avmSimulator: AvmSimulator, dateProvider?: DateProvider, telemetryClient?: TelemetryClient, bindings?: LoggerBindings);
23
+ /**
24
+ * Creates a new instance of a PublicProcessor. The simulator it drives reads contract data from the fork's
25
+ * contracts DB, scoped by the fork id so AVM requests route to the right state.
26
+ *
27
+ * @param globalVariables - The global variables for the block being processed.
28
+ * @param contractsDB - Optional pre-populated contracts DB; a fresh one is constructed if omitted.
29
+ * @returns A new instance of a PublicProcessor.
30
+ */
31
+ create(merkleTree: MerkleTreeWriteOperations, globalVariables: GlobalVariables, config: PublicSimulatorConfig, contractsDB?: PublicContractsDB): PublicProcessor;
32
+ protected createPublicTxSimulator(forkId: number, globalVariables: GlobalVariables, contractsDB: PublicContractsDB, config?: Partial<PublicTxSimulatorConfig>): PublicTxSimulatorInterface;
33
+ }
34
+ /**
35
+ * Converts Txs lifted from the P2P module into ProcessedTx objects by executing
36
+ * any public function calls in them. Txs with private calls only are unaffected.
37
+ */
38
+ export declare class PublicProcessor implements Traceable {
39
+ protected globalVariables: GlobalVariables;
40
+ private guardedMerkleTree;
41
+ protected contractsDB: PublicContractsDB;
42
+ protected publicTxSimulator: PublicTxSimulatorInterface;
43
+ private dateProvider;
44
+ private log;
45
+ private opts;
46
+ private debugLogStore;
47
+ private metrics;
48
+ constructor(globalVariables: GlobalVariables, guardedMerkleTree: GuardedMerkleTreeOperations, contractsDB: PublicContractsDB, publicTxSimulator: PublicTxSimulatorInterface, dateProvider: DateProvider, telemetryClient: TelemetryClient | undefined, log: Logger, opts?: Pick<SequencerConfig, 'fakeProcessingDelayPerTxMs' | 'fakeThrowAfterProcessingTxCount'>, debugLogStore?: DebugLogStore);
49
+ get tracer(): Tracer;
50
+ /**
51
+ * Run each tx through the public circuit and the public kernel circuit if needed.
52
+ * @param txs - Txs to process.
53
+ * @param limits - Limits for processing the txs.
54
+ * @param validator - Pre-process validator and nullifier cache to use for processing the txs.
55
+ * @returns The list of processed txs with their circuit simulation outputs.
56
+ */
57
+ process(txs: Iterable<Tx> | AsyncIterable<Tx>, limits?: PublicProcessorLimits, validator?: PublicProcessorValidator): Promise<[ProcessedTx[], FailedTx[], Tx[], NestedProcessReturnValues[], DebugLog[]]>;
58
+ private checkWorldStateUnchanged;
59
+ private processTx;
60
+ private doTreeInsertionsForPrivateOnlyTx;
61
+ private processTxWithinDeadline;
62
+ private getProcessingSignal;
63
+ private performFeePaymentPublicDataWrite;
64
+ private processPrivateOnlyTx;
65
+ private processTxWithPublicCalls;
66
+ /**
67
+ * Generate the proving request for the AVM circuit.
68
+ */
69
+ private static generateProvingRequest;
70
+ }
71
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHVibGljX3Byb2Nlc3Nvci5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL3B1YmxpYy9wdWJsaWNfcHJvY2Vzc29yL3B1YmxpY19wcm9jZXNzb3IudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBR0EsT0FBTyxFQUFFLEtBQUssTUFBTSxFQUFFLEtBQUssY0FBYyxFQUFnQixNQUFNLDRCQUE0QixDQUFDO0FBRTVGLE9BQU8sRUFBRSxZQUFZLEVBQWtDLE1BQU0sOEJBQThCLENBQUM7QUFPNUYsT0FBTyxFQU1MLHFCQUFxQixFQUN0QixNQUFNLHdCQUF3QixDQUFDO0FBRWhDLE9BQU8sS0FBSyxFQUFFLGtCQUFrQixFQUFFLE1BQU0sNkJBQTZCLENBQUM7QUFHdEUsT0FBTyxLQUFLLEVBQ1YseUJBQXlCLEVBQ3pCLHFCQUFxQixFQUNyQix3QkFBd0IsRUFDeEIsZUFBZSxFQUNoQixNQUFNLHNDQUFzQyxDQUFDO0FBQzlDLE9BQU8sRUFBRSxLQUFLLFFBQVEsRUFBRSxLQUFLLGFBQWEsRUFBcUIsTUFBTSx5Q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