@aztec/simulator 0.81.0 → 0.82.1-alpha-testnet.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 (138) hide show
  1. package/dest/common/db_interfaces.d.ts +6 -12
  2. package/dest/common/db_interfaces.d.ts.map +1 -1
  3. package/dest/common/db_interfaces.js +1 -1
  4. package/dest/common/debug_fn_name.js +5 -2
  5. package/dest/common/message_load_oracle_inputs.d.ts +4 -0
  6. package/dest/common/message_load_oracle_inputs.d.ts.map +1 -1
  7. package/dest/common/message_load_oracle_inputs.js +9 -0
  8. package/dest/private/acvm/acvm.d.ts +6 -1
  9. package/dest/private/acvm/acvm.d.ts.map +1 -1
  10. package/dest/private/acvm/acvm.js +7 -13
  11. package/dest/private/acvm/deserialize.d.ts +0 -18
  12. package/dest/private/acvm/deserialize.d.ts.map +1 -1
  13. package/dest/private/acvm/deserialize.js +3 -24
  14. package/dest/private/acvm/oracle/oracle.d.ts +34 -34
  15. package/dest/private/acvm/oracle/oracle.d.ts.map +1 -1
  16. package/dest/private/acvm/oracle/oracle.js +116 -82
  17. package/dest/private/acvm/oracle/typed_oracle.d.ts +4 -4
  18. package/dest/private/acvm/oracle/typed_oracle.d.ts.map +1 -1
  19. package/dest/private/acvm/oracle/typed_oracle.js +8 -8
  20. package/dest/private/execution_data_provider.d.ts +3 -9
  21. package/dest/private/execution_data_provider.d.ts.map +1 -1
  22. package/dest/private/hashed_values_cache.d.ts +2 -2
  23. package/dest/private/hashed_values_cache.d.ts.map +1 -1
  24. package/dest/private/hashed_values_cache.js +5 -15
  25. package/dest/private/private_execution.d.ts +2 -2
  26. package/dest/private/private_execution.d.ts.map +1 -1
  27. package/dest/private/private_execution.js +4 -7
  28. package/dest/private/private_execution_oracle.d.ts +9 -37
  29. package/dest/private/private_execution_oracle.d.ts.map +1 -1
  30. package/dest/private/private_execution_oracle.js +32 -92
  31. package/dest/private/providers/acvm_native.d.ts +6 -4
  32. package/dest/private/providers/acvm_native.d.ts.map +1 -1
  33. package/dest/private/providers/acvm_native.js +6 -3
  34. package/dest/private/providers/acvm_wasm.d.ts +6 -7
  35. package/dest/private/providers/acvm_wasm.d.ts.map +1 -1
  36. package/dest/private/providers/acvm_wasm.js +13 -15
  37. package/dest/private/providers/acvm_wasm_with_blobs.d.ts +5 -5
  38. package/dest/private/providers/acvm_wasm_with_blobs.d.ts.map +1 -1
  39. package/dest/private/providers/acvm_wasm_with_blobs.js +7 -9
  40. package/dest/private/providers/circuit_recording/circuit_recorder.d.ts +90 -0
  41. package/dest/private/providers/circuit_recording/circuit_recorder.d.ts.map +1 -0
  42. package/dest/private/providers/circuit_recording/circuit_recorder.js +246 -0
  43. package/dest/private/providers/circuit_recording/simulation_provider_recorder_wrapper.d.ts +18 -0
  44. package/dest/private/providers/circuit_recording/simulation_provider_recorder_wrapper.d.ts.map +1 -0
  45. package/dest/private/providers/circuit_recording/simulation_provider_recorder_wrapper.js +39 -0
  46. package/dest/private/providers/simulation_provider.d.ts +21 -7
  47. package/dest/private/providers/simulation_provider.d.ts.map +1 -1
  48. package/dest/private/simulator.d.ts +3 -2
  49. package/dest/private/simulator.d.ts.map +1 -1
  50. package/dest/private/simulator.js +14 -4
  51. package/dest/private/unconstrained_execution.d.ts +2 -2
  52. package/dest/private/unconstrained_execution.d.ts.map +1 -1
  53. package/dest/private/unconstrained_execution.js +1 -2
  54. package/dest/private/unconstrained_execution_oracle.d.ts +1 -1
  55. package/dest/private/unconstrained_execution_oracle.d.ts.map +1 -1
  56. package/dest/private/unconstrained_execution_oracle.js +3 -3
  57. package/dest/public/avm/avm_simulator.d.ts.map +1 -1
  58. package/dest/public/avm/avm_simulator.js +0 -2
  59. package/dest/public/avm/fixtures/avm_simulation_tester.js +2 -2
  60. package/dest/public/avm/fixtures/index.d.ts +2 -1
  61. package/dest/public/avm/fixtures/index.d.ts.map +1 -1
  62. package/dest/public/avm/fixtures/index.js +7 -12
  63. package/dest/public/avm/fixtures/simple_contract_data_source.d.ts +2 -2
  64. package/dest/public/avm/fixtures/simple_contract_data_source.d.ts.map +1 -1
  65. package/dest/public/avm/fixtures/simple_contract_data_source.js +1 -1
  66. package/dest/public/avm/journal/journal.d.ts +2 -2
  67. package/dest/public/avm/journal/journal.d.ts.map +1 -1
  68. package/dest/public/avm/journal/journal.js +4 -4
  69. package/dest/public/avm/test_utils.js +1 -1
  70. package/dest/public/fixtures/public_tx_simulation_tester.d.ts +2 -2
  71. package/dest/public/fixtures/public_tx_simulation_tester.d.ts.map +1 -1
  72. package/dest/public/fixtures/public_tx_simulation_tester.js +27 -47
  73. package/dest/public/fixtures/utils.d.ts +2 -2
  74. package/dest/public/fixtures/utils.d.ts.map +1 -1
  75. package/dest/public/fixtures/utils.js +18 -22
  76. package/dest/public/index.d.ts +1 -2
  77. package/dest/public/index.d.ts.map +1 -1
  78. package/dest/public/index.js +1 -1
  79. package/dest/public/public_db_sources.d.ts +1 -1
  80. package/dest/public/public_db_sources.d.ts.map +1 -1
  81. package/dest/public/public_db_sources.js +4 -4
  82. package/dest/public/public_processor/public_processor.js +1 -1
  83. package/dest/public/public_tx_simulator/public_tx_context.d.ts +3 -10
  84. package/dest/public/public_tx_simulator/public_tx_context.d.ts.map +1 -1
  85. package/dest/public/public_tx_simulator/public_tx_context.js +4 -22
  86. package/dest/public/public_tx_simulator/public_tx_simulator.d.ts +2 -3
  87. package/dest/public/public_tx_simulator/public_tx_simulator.d.ts.map +1 -1
  88. package/dest/public/public_tx_simulator/public_tx_simulator.js +20 -24
  89. package/dest/public/utils.d.ts +2 -4
  90. package/dest/public/utils.d.ts.map +1 -1
  91. package/dest/public/utils.js +4 -21
  92. package/dest/testing.d.ts +2 -0
  93. package/dest/testing.d.ts.map +1 -0
  94. package/dest/testing.js +1 -0
  95. package/package.json +15 -14
  96. package/src/common/db_interfaces.ts +6 -13
  97. package/src/common/debug_fn_name.ts +5 -5
  98. package/src/common/message_load_oracle_inputs.ts +8 -0
  99. package/src/private/acvm/acvm.ts +8 -24
  100. package/src/private/acvm/deserialize.ts +3 -30
  101. package/src/private/acvm/oracle/oracle.ts +148 -144
  102. package/src/private/acvm/oracle/typed_oracle.ts +12 -14
  103. package/src/private/execution_data_provider.ts +6 -10
  104. package/src/private/hashed_values_cache.ts +6 -14
  105. package/src/private/private_execution.ts +11 -11
  106. package/src/private/private_execution_oracle.ts +39 -138
  107. package/src/private/providers/acvm_native.ts +17 -6
  108. package/src/private/providers/acvm_wasm.ts +27 -20
  109. package/src/private/providers/acvm_wasm_with_blobs.ts +15 -12
  110. package/src/private/providers/circuit_recording/circuit_recorder.ts +283 -0
  111. package/src/private/providers/circuit_recording/simulation_provider_recorder_wrapper.ts +82 -0
  112. package/src/private/providers/simulation_provider.ts +30 -5
  113. package/src/private/simulator.ts +19 -5
  114. package/src/private/unconstrained_execution.ts +8 -4
  115. package/src/private/unconstrained_execution_oracle.ts +3 -6
  116. package/src/public/avm/avm_simulator.ts +0 -2
  117. package/src/public/avm/fixtures/avm_simulation_tester.ts +2 -2
  118. package/src/public/avm/fixtures/index.ts +15 -17
  119. package/src/public/avm/fixtures/simple_contract_data_source.ts +2 -2
  120. package/src/public/avm/journal/journal.ts +7 -7
  121. package/src/public/avm/test_utils.ts +1 -1
  122. package/src/public/fixtures/public_tx_simulation_tester.ts +31 -88
  123. package/src/public/fixtures/utils.ts +28 -26
  124. package/src/public/index.ts +1 -2
  125. package/src/public/public_db_sources.ts +4 -4
  126. package/src/public/public_processor/public_processor.ts +1 -1
  127. package/src/public/public_tx_simulator/public_tx_context.ts +12 -32
  128. package/src/public/public_tx_simulator/public_tx_simulator.ts +24 -30
  129. package/src/public/utils.ts +5 -21
  130. package/src/testing.ts +1 -0
  131. package/dest/public/avm/bytecode_utils.d.ts +0 -5
  132. package/dest/public/avm/bytecode_utils.d.ts.map +0 -1
  133. package/dest/public/avm/bytecode_utils.js +0 -17
  134. package/dest/public/execution.d.ts +0 -108
  135. package/dest/public/execution.d.ts.map +0 -1
  136. package/dest/public/execution.js +0 -9
  137. package/src/public/avm/bytecode_utils.ts +0 -17
  138. package/src/public/execution.ts +0 -140
@@ -1,108 +0,0 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
- /// <reference types="node" resolution-mode="require"/>
3
- import type { Fr } from '@aztec/foundation/fields';
4
- import { type AvmExecutionHints, type ContractStorageRead, type ContractStorageUpdateRequest, type PublicDataUpdateRequest, PublicInnerCallRequest } from '@aztec/stdlib/avm';
5
- import type { SimulationError } from '@aztec/stdlib/errors';
6
- import { Gas } from '@aztec/stdlib/gas';
7
- import type { NoteHash, Nullifier, ReadRequest, TreeLeafReadRequest } from '@aztec/stdlib/kernel';
8
- import type { PublicLog } from '@aztec/stdlib/logs';
9
- import type { L2ToL1Message, ScopedL2ToL1Message } from '@aztec/stdlib/messaging';
10
- import type { PublicExecutionRequest } from '@aztec/stdlib/tx';
11
- export interface PublicSideEffects {
12
- /** The contract storage update requests performed. */
13
- publicDataWrites: PublicDataUpdateRequest[];
14
- /** The new note hashes to be inserted into the note hashes tree. */
15
- noteHashes: NoteHash[];
16
- /** The new nullifiers to be inserted into the nullifier tree. */
17
- nullifiers: Nullifier[];
18
- /** The new l2 to l1 messages generated to be inserted into the messages tree. */
19
- l2ToL1Messages: ScopedL2ToL1Message[];
20
- /** Public logs emitted during execution. */
21
- publicLogs: PublicLog[];
22
- }
23
- export interface EnqueuedPublicCallExecutionResult {
24
- /** How much gas was left after this public execution. */
25
- endGasLeft: Gas;
26
- /** The side effect counter after execution */
27
- endSideEffectCounter: Fr;
28
- /** The return values of the function. */
29
- returnValues: Fr[];
30
- /** Whether the execution reverted. */
31
- reverted: boolean;
32
- /** The revert reason if the execution reverted. */
33
- revertReason?: SimulationError;
34
- }
35
- export interface EnqueuedPublicCallExecutionResultWithSideEffects {
36
- /** How much gas was left after this public execution. */
37
- endGasLeft: Gas;
38
- /** The side effect counter after execution */
39
- endSideEffectCounter: Fr;
40
- /** The return values of the function. */
41
- returnValues: Fr[];
42
- /** Whether the execution reverted. */
43
- reverted: boolean;
44
- /** The revert reason if the execution reverted. */
45
- revertReason?: SimulationError;
46
- /** The public side effects of the function. */
47
- sideEffects: PublicSideEffects;
48
- }
49
- /**
50
- * The public function execution result.
51
- */
52
- export interface PublicFunctionCallResult {
53
- /** The execution request that triggered this result. */
54
- executionRequest: PublicExecutionRequest;
55
- /** The side effect counter at the start of the function call. */
56
- startSideEffectCounter: Fr;
57
- /** The side effect counter after executing this function call */
58
- endSideEffectCounter: Fr;
59
- /** How much gas was available for this public execution. */
60
- startGasLeft: Gas;
61
- /** How much gas was left after this public execution. */
62
- endGasLeft: Gas;
63
- /** Transaction fee set for this tx. */
64
- transactionFee: Fr;
65
- /** Bytecode used for this execution. */
66
- bytecode?: Buffer;
67
- /** Calldata used for this execution. */
68
- calldata: Fr[];
69
- /** The return values of the function. */
70
- returnValues: Fr[];
71
- /** Whether the execution reverted. */
72
- reverted: boolean;
73
- /** The revert reason if the execution reverted. */
74
- revertReason?: SimulationError;
75
- /** The contract storage reads performed by the function. */
76
- contractStorageReads: ContractStorageRead[];
77
- /** The contract storage update requests performed by the function. */
78
- contractStorageUpdateRequests: ContractStorageUpdateRequest[];
79
- /** The new note hashes to be inserted into the note hashes tree. */
80
- noteHashes: NoteHash[];
81
- /** The new l2 to l1 messages generated in this call. */
82
- l2ToL1Messages: L2ToL1Message[];
83
- /** The new nullifiers to be inserted into the nullifier tree. */
84
- nullifiers: Nullifier[];
85
- /** The note hash read requests emitted in this call. */
86
- noteHashReadRequests: TreeLeafReadRequest[];
87
- /** The nullifier read requests emitted in this call. */
88
- nullifierReadRequests: ReadRequest[];
89
- /** The nullifier non existent read requests emitted in this call. */
90
- nullifierNonExistentReadRequests: ReadRequest[];
91
- /** L1 to L2 message read requests emitted in this call. */
92
- l1ToL2MsgReadRequests: TreeLeafReadRequest[];
93
- /**
94
- * The public logs emitted in this call.
95
- * Note: PublicLog has no counter - unsure if this is needed bc this struct is unused
96
- */
97
- publicLogs: PublicLog[];
98
- /** The requests to call public functions made by this call. */
99
- publicCallRequests: PublicInnerCallRequest[];
100
- /** The results of nested calls. */
101
- nestedExecutions: this[];
102
- /** Hints for proving AVM execution. */
103
- avmCircuitHints: AvmExecutionHints;
104
- /** The name of the function that was executed. Only used for logging. */
105
- functionName: string;
106
- }
107
- export declare function resultToPublicCallRequest(result: PublicFunctionCallResult): Promise<PublicInnerCallRequest>;
108
- //# sourceMappingURL=execution.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"execution.d.ts","sourceRoot":"","sources":["../../src/public/execution.ts"],"names":[],"mappings":"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"}
@@ -1,9 +0,0 @@
1
- import { PublicCallStackItemCompressed, PublicInnerCallRequest, RevertCode } from '@aztec/stdlib/avm';
2
- import { Gas } from '@aztec/stdlib/gas';
3
- import { computeVarArgsHash } from '@aztec/stdlib/hash';
4
- export async function resultToPublicCallRequest(result) {
5
- const request = result.executionRequest;
6
- const item = new PublicCallStackItemCompressed(request.callContext.contractAddress, request.callContext, await computeVarArgsHash(request.args), await computeVarArgsHash(result.returnValues), // TODO(@just-mitch): need better mapping from simulator to revert code.
7
- result.reverted ? RevertCode.APP_LOGIC_REVERTED : RevertCode.OK, Gas.from(result.startGasLeft), Gas.from(result.endGasLeft));
8
- return new PublicInnerCallRequest(item, result.startSideEffectCounter.toNumber());
9
- }
@@ -1,17 +0,0 @@
1
- import { Opcode } from './serialization/instruction_serialization.js';
2
-
3
- const AVM_MAGIC_SUFFIX = Buffer.from([
4
- Opcode.MOV_16, // opcode
5
- 0x00, // indirect
6
- ...Buffer.from('18ca', 'hex'), // srcOffset
7
- ...Buffer.from('18ca', 'hex'), // dstOffset
8
- ]);
9
-
10
- export function markBytecodeAsAvm(bytecode: Buffer): Buffer {
11
- return Buffer.concat([bytecode, AVM_MAGIC_SUFFIX]);
12
- }
13
-
14
- export function isAvmBytecode(bytecode: Buffer): boolean {
15
- const magicSize = AVM_MAGIC_SUFFIX.length;
16
- return bytecode.subarray(-magicSize).equals(AVM_MAGIC_SUFFIX);
17
- }
@@ -1,140 +0,0 @@
1
- import type { Fr } from '@aztec/foundation/fields';
2
- import {
3
- type AvmExecutionHints,
4
- type ContractStorageRead,
5
- type ContractStorageUpdateRequest,
6
- PublicCallStackItemCompressed,
7
- type PublicDataUpdateRequest,
8
- PublicInnerCallRequest,
9
- RevertCode,
10
- } from '@aztec/stdlib/avm';
11
- import type { SimulationError } from '@aztec/stdlib/errors';
12
- import { Gas } from '@aztec/stdlib/gas';
13
- import { computeVarArgsHash } from '@aztec/stdlib/hash';
14
- import type { NoteHash, Nullifier, ReadRequest, TreeLeafReadRequest } from '@aztec/stdlib/kernel';
15
- import type { PublicLog } from '@aztec/stdlib/logs';
16
- import type { L2ToL1Message, ScopedL2ToL1Message } from '@aztec/stdlib/messaging';
17
- import type { PublicExecutionRequest } from '@aztec/stdlib/tx';
18
-
19
- export interface PublicSideEffects {
20
- /** The contract storage update requests performed. */
21
- publicDataWrites: PublicDataUpdateRequest[];
22
- /** The new note hashes to be inserted into the note hashes tree. */
23
- noteHashes: NoteHash[];
24
- /** The new nullifiers to be inserted into the nullifier tree. */
25
- nullifiers: Nullifier[];
26
- /** The new l2 to l1 messages generated to be inserted into the messages tree. */
27
- l2ToL1Messages: ScopedL2ToL1Message[];
28
- /** Public logs emitted during execution. */
29
- publicLogs: PublicLog[];
30
- }
31
-
32
- export interface EnqueuedPublicCallExecutionResult {
33
- /** How much gas was left after this public execution. */
34
- endGasLeft: Gas;
35
- /** The side effect counter after execution */
36
- endSideEffectCounter: Fr;
37
-
38
- /** The return values of the function. */
39
- returnValues: Fr[];
40
- /** Whether the execution reverted. */
41
- reverted: boolean;
42
- /** The revert reason if the execution reverted. */
43
- revertReason?: SimulationError;
44
- }
45
-
46
- export interface EnqueuedPublicCallExecutionResultWithSideEffects {
47
- /** How much gas was left after this public execution. */
48
- endGasLeft: Gas;
49
- /** The side effect counter after execution */
50
- endSideEffectCounter: Fr;
51
-
52
- /** The return values of the function. */
53
- returnValues: Fr[];
54
- /** Whether the execution reverted. */
55
- reverted: boolean;
56
- /** The revert reason if the execution reverted. */
57
- revertReason?: SimulationError;
58
-
59
- /** The public side effects of the function. */
60
- sideEffects: PublicSideEffects;
61
- }
62
-
63
- /**
64
- * The public function execution result.
65
- */
66
- export interface PublicFunctionCallResult {
67
- /** The execution request that triggered this result. */
68
- executionRequest: PublicExecutionRequest;
69
-
70
- /** The side effect counter at the start of the function call. */
71
- startSideEffectCounter: Fr;
72
- /** The side effect counter after executing this function call */
73
- endSideEffectCounter: Fr;
74
- /** How much gas was available for this public execution. */
75
- startGasLeft: Gas;
76
- /** How much gas was left after this public execution. */
77
- endGasLeft: Gas;
78
- /** Transaction fee set for this tx. */
79
- transactionFee: Fr;
80
-
81
- /** Bytecode used for this execution. */
82
- bytecode?: Buffer;
83
- /** Calldata used for this execution. */
84
- calldata: Fr[];
85
- /** The return values of the function. */
86
- returnValues: Fr[];
87
- /** Whether the execution reverted. */
88
- reverted: boolean;
89
- /** The revert reason if the execution reverted. */
90
- revertReason?: SimulationError;
91
-
92
- /** The contract storage reads performed by the function. */
93
- contractStorageReads: ContractStorageRead[];
94
- /** The contract storage update requests performed by the function. */
95
- contractStorageUpdateRequests: ContractStorageUpdateRequest[];
96
- /** The new note hashes to be inserted into the note hashes tree. */
97
- noteHashes: NoteHash[];
98
- /** The new l2 to l1 messages generated in this call. */
99
- l2ToL1Messages: L2ToL1Message[];
100
- /** The new nullifiers to be inserted into the nullifier tree. */
101
- nullifiers: Nullifier[];
102
- /** The note hash read requests emitted in this call. */
103
- noteHashReadRequests: TreeLeafReadRequest[];
104
- /** The nullifier read requests emitted in this call. */
105
- nullifierReadRequests: ReadRequest[];
106
- /** The nullifier non existent read requests emitted in this call. */
107
- nullifierNonExistentReadRequests: ReadRequest[];
108
- /** L1 to L2 message read requests emitted in this call. */
109
- l1ToL2MsgReadRequests: TreeLeafReadRequest[];
110
- /**
111
- * The public logs emitted in this call.
112
- * Note: PublicLog has no counter - unsure if this is needed bc this struct is unused
113
- */
114
- publicLogs: PublicLog[];
115
- /** The requests to call public functions made by this call. */
116
- publicCallRequests: PublicInnerCallRequest[];
117
- /** The results of nested calls. */
118
- nestedExecutions: this[];
119
-
120
- /** Hints for proving AVM execution. */
121
- avmCircuitHints: AvmExecutionHints;
122
-
123
- /** The name of the function that was executed. Only used for logging. */
124
- functionName: string;
125
- }
126
-
127
- export async function resultToPublicCallRequest(result: PublicFunctionCallResult) {
128
- const request = result.executionRequest;
129
- const item = new PublicCallStackItemCompressed(
130
- request.callContext.contractAddress,
131
- request.callContext,
132
- await computeVarArgsHash(request.args),
133
- await computeVarArgsHash(result.returnValues),
134
- // TODO(@just-mitch): need better mapping from simulator to revert code.
135
- result.reverted ? RevertCode.APP_LOGIC_REVERTED : RevertCode.OK,
136
- Gas.from(result.startGasLeft),
137
- Gas.from(result.endGasLeft),
138
- );
139
- return new PublicInnerCallRequest(item, result.startSideEffectCounter.toNumber());
140
- }