@aztec/simulator 0.33.0 → 0.34.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/acvm/acvm.js +2 -2
- package/dest/acvm/oracle/oracle.d.ts +1 -1
- package/dest/acvm/oracle/oracle.d.ts.map +1 -1
- package/dest/acvm/oracle/oracle.js +3 -3
- package/dest/avm/avm_execution_environment.d.ts +4 -3
- package/dest/avm/avm_execution_environment.d.ts.map +1 -1
- package/dest/avm/avm_execution_environment.js +8 -7
- package/dest/avm/avm_memory_types.js +5 -5
- package/dest/avm/avm_simulator.js +6 -6
- package/dest/avm/fixtures/index.d.ts.map +1 -1
- package/dest/avm/fixtures/index.js +3 -3
- package/dest/avm/journal/journal.d.ts +14 -13
- package/dest/avm/journal/journal.d.ts.map +1 -1
- package/dest/avm/journal/journal.js +5 -5
- package/dest/avm/journal/trace.d.ts +8 -19
- package/dest/avm/journal/trace.d.ts.map +1 -1
- package/dest/avm/journal/trace.js +48 -116
- package/dest/avm/journal/trace_types.d.ts +23 -4
- package/dest/avm/journal/trace_types.d.ts.map +1 -1
- package/dest/avm/opcodes/accrued_substate.js +2 -2
- package/dest/avm/opcodes/external_calls.d.ts.map +1 -1
- package/dest/avm/opcodes/external_calls.js +20 -5
- package/dest/client/client_execution_context.d.ts +2 -2
- package/dest/client/client_execution_context.d.ts.map +1 -1
- package/dest/client/client_execution_context.js +6 -6
- package/dest/client/private_execution.d.ts +1 -1
- package/dest/client/private_execution.d.ts.map +1 -1
- package/dest/client/private_execution.js +3 -3
- package/dest/client/unconstrained_execution.d.ts +1 -1
- package/dest/client/unconstrained_execution.d.ts.map +1 -1
- package/dest/client/unconstrained_execution.js +2 -2
- package/dest/client/view_data_oracle.d.ts +2 -2
- package/dest/client/view_data_oracle.d.ts.map +1 -1
- package/dest/client/view_data_oracle.js +2 -2
- package/dest/public/executor.d.ts +1 -15
- package/dest/public/executor.d.ts.map +1 -1
- package/dest/public/executor.js +70 -77
- package/dest/public/public_execution_context.d.ts +6 -6
- package/dest/public/public_execution_context.d.ts.map +1 -1
- package/dest/public/public_execution_context.js +8 -12
- package/dest/public/transitional_adaptors.d.ts +32 -0
- package/dest/public/transitional_adaptors.d.ts.map +1 -0
- package/dest/public/transitional_adaptors.js +161 -0
- package/package.json +5 -5
- package/src/acvm/acvm.ts +1 -1
- package/src/acvm/oracle/oracle.ts +2 -2
- package/src/avm/avm_execution_environment.ts +9 -17
- package/src/avm/avm_memory_types.ts +4 -4
- package/src/avm/avm_simulator.ts +5 -5
- package/src/avm/fixtures/index.ts +2 -1
- package/src/avm/journal/journal.ts +24 -17
- package/src/avm/journal/trace.ts +59 -121
- package/src/avm/journal/trace_types.ts +39 -39
- package/src/avm/opcodes/accrued_substate.ts +1 -1
- package/src/avm/opcodes/external_calls.ts +24 -4
- package/src/client/client_execution_context.ts +5 -5
- package/src/client/private_execution.ts +2 -2
- package/src/client/unconstrained_execution.ts +1 -1
- package/src/client/view_data_oracle.ts +1 -1
- package/src/public/executor.ts +82 -87
- package/src/public/public_execution_context.ts +14 -19
- package/src/public/transitional_adaptors.ts +240 -0
- package/dest/avm/temporary_executor_migration.d.ts +0 -27
- package/dest/avm/temporary_executor_migration.d.ts.map +0 -1
- package/dest/avm/temporary_executor_migration.js +0 -94
- package/src/avm/temporary_executor_migration.ts +0 -136
package/src/avm/journal/trace.ts
CHANGED
|
@@ -1,23 +1,28 @@
|
|
|
1
1
|
import { Fr } from '@aztec/foundation/fields';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
type TracedL1toL2MessageCheck,
|
|
5
|
+
type TracedNoteHash,
|
|
6
|
+
type TracedNoteHashCheck,
|
|
7
|
+
type TracedNullifier,
|
|
8
|
+
type TracedNullifierCheck,
|
|
9
|
+
type TracedPublicStorageRead,
|
|
10
|
+
type TracedPublicStorageWrite,
|
|
11
|
+
} from './trace_types.js';
|
|
4
12
|
|
|
5
13
|
export class WorldStateAccessTrace {
|
|
6
14
|
public accessCounter: number;
|
|
7
|
-
//public contractCalls: Array<TracedContractCall> = [];
|
|
8
15
|
|
|
9
|
-
|
|
10
|
-
public
|
|
11
|
-
//public publicStorageWrites: Array<TracedPublicStorageWrite> = [];
|
|
12
|
-
public publicStorageWrites: Map<bigint, Map<bigint, Fr[]>> = new Map();
|
|
16
|
+
public publicStorageReads: TracedPublicStorageRead[] = [];
|
|
17
|
+
public publicStorageWrites: TracedPublicStorageWrite[] = [];
|
|
13
18
|
|
|
14
19
|
public noteHashChecks: TracedNoteHashCheck[] = [];
|
|
15
|
-
|
|
16
|
-
public newNoteHashes: Fr[] = [];
|
|
20
|
+
public newNoteHashes: TracedNoteHash[] = [];
|
|
17
21
|
public nullifierChecks: TracedNullifierCheck[] = [];
|
|
18
|
-
|
|
19
|
-
public newNullifiers: Fr[] = [];
|
|
22
|
+
public newNullifiers: TracedNullifier[] = [];
|
|
20
23
|
public l1ToL2MessageChecks: TracedL1toL2MessageCheck[] = [];
|
|
24
|
+
|
|
25
|
+
//public contractCalls: TracedContractCall[] = [];
|
|
21
26
|
//public archiveChecks: TracedArchiveLeafCheck[] = [];
|
|
22
27
|
|
|
23
28
|
constructor(parentTrace?: WorldStateAccessTrace) {
|
|
@@ -28,76 +33,73 @@ export class WorldStateAccessTrace {
|
|
|
28
33
|
return this.accessCounter;
|
|
29
34
|
}
|
|
30
35
|
|
|
31
|
-
public tracePublicStorageRead(storageAddress: Fr, slot: Fr, value: Fr
|
|
36
|
+
public tracePublicStorageRead(storageAddress: Fr, slot: Fr, value: Fr, exists: boolean) {
|
|
32
37
|
// TODO(4805): check if some threshold is reached for max storage reads
|
|
33
38
|
// (need access to parent length, or trace needs to be initialized with parent's contents)
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
this.journalRead(storageAddress, slot, value);
|
|
39
|
+
const traced: TracedPublicStorageRead = {
|
|
40
|
+
// callPointer: Fr.ZERO,
|
|
41
|
+
storageAddress,
|
|
42
|
+
slot,
|
|
43
|
+
value,
|
|
44
|
+
exists,
|
|
45
|
+
counter: new Fr(this.accessCounter),
|
|
46
|
+
// endLifetime: Fr.ZERO,
|
|
47
|
+
};
|
|
48
|
+
this.publicStorageReads.push(traced);
|
|
45
49
|
this.incrementAccessCounter();
|
|
46
50
|
}
|
|
47
51
|
|
|
48
52
|
public tracePublicStorageWrite(storageAddress: Fr, slot: Fr, value: Fr) {
|
|
49
53
|
// TODO(4805): check if some threshold is reached for max storage writes
|
|
50
54
|
// (need access to parent length, or trace needs to be initialized with parent's contents)
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
this.journalWrite(storageAddress, slot, value);
|
|
55
|
+
const traced: TracedPublicStorageWrite = {
|
|
56
|
+
// callPointer: Fr.ZERO,
|
|
57
|
+
storageAddress,
|
|
58
|
+
slot,
|
|
59
|
+
value,
|
|
60
|
+
counter: new Fr(this.accessCounter),
|
|
61
|
+
// endLifetime: Fr.ZERO,
|
|
62
|
+
};
|
|
63
|
+
this.publicStorageWrites.push(traced);
|
|
61
64
|
this.incrementAccessCounter();
|
|
62
65
|
}
|
|
63
66
|
|
|
64
67
|
public traceNoteHashCheck(storageAddress: Fr, noteHash: Fr, exists: boolean, leafIndex: Fr) {
|
|
65
68
|
const traced: TracedNoteHashCheck = {
|
|
66
|
-
callPointer: Fr.ZERO,
|
|
69
|
+
// callPointer: Fr.ZERO,
|
|
67
70
|
storageAddress,
|
|
68
71
|
noteHash,
|
|
69
72
|
exists,
|
|
70
73
|
counter: new Fr(this.accessCounter),
|
|
71
|
-
endLifetime: Fr.ZERO,
|
|
74
|
+
// endLifetime: Fr.ZERO,
|
|
72
75
|
leafIndex,
|
|
73
76
|
};
|
|
74
77
|
this.noteHashChecks.push(traced);
|
|
75
78
|
this.incrementAccessCounter();
|
|
76
79
|
}
|
|
77
80
|
|
|
78
|
-
public traceNewNoteHash(
|
|
81
|
+
public traceNewNoteHash(storageAddress: Fr, noteHash: Fr) {
|
|
79
82
|
// TODO(4805): check if some threshold is reached for max new note hash
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
this.newNoteHashes.push(noteHash);
|
|
83
|
+
const traced: TracedNoteHash = {
|
|
84
|
+
// callPointer: Fr.ZERO,
|
|
85
|
+
storageAddress,
|
|
86
|
+
noteHash,
|
|
87
|
+
counter: new Fr(this.accessCounter),
|
|
88
|
+
// endLifetime: Fr.ZERO,
|
|
89
|
+
};
|
|
90
|
+
this.newNoteHashes.push(traced);
|
|
89
91
|
this.incrementAccessCounter();
|
|
90
92
|
}
|
|
91
93
|
|
|
92
94
|
public traceNullifierCheck(storageAddress: Fr, nullifier: Fr, exists: boolean, isPending: boolean, leafIndex: Fr) {
|
|
93
95
|
// TODO(4805): check if some threshold is reached for max new nullifier
|
|
94
96
|
const traced: TracedNullifierCheck = {
|
|
95
|
-
callPointer: Fr.ZERO,
|
|
97
|
+
// callPointer: Fr.ZERO,
|
|
96
98
|
storageAddress,
|
|
97
99
|
nullifier,
|
|
98
100
|
exists,
|
|
99
101
|
counter: new Fr(this.accessCounter),
|
|
100
|
-
endLifetime: Fr.ZERO,
|
|
102
|
+
// endLifetime: Fr.ZERO,
|
|
101
103
|
isPending,
|
|
102
104
|
leafIndex,
|
|
103
105
|
};
|
|
@@ -105,17 +107,16 @@ export class WorldStateAccessTrace {
|
|
|
105
107
|
this.incrementAccessCounter();
|
|
106
108
|
}
|
|
107
109
|
|
|
108
|
-
public traceNewNullifier(
|
|
110
|
+
public traceNewNullifier(storageAddress: Fr, nullifier: Fr) {
|
|
109
111
|
// TODO(4805): check if some threshold is reached for max new nullifier
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
this.newNullifiers.push(nullifier);
|
|
112
|
+
const tracedNullifier: TracedNullifier = {
|
|
113
|
+
// callPointer: Fr.ZERO,
|
|
114
|
+
storageAddress,
|
|
115
|
+
nullifier,
|
|
116
|
+
counter: new Fr(this.accessCounter),
|
|
117
|
+
// endLifetime: Fr.ZERO,
|
|
118
|
+
};
|
|
119
|
+
this.newNullifiers.push(tracedNullifier);
|
|
119
120
|
this.incrementAccessCounter();
|
|
120
121
|
}
|
|
121
122
|
|
|
@@ -146,8 +147,8 @@ export class WorldStateAccessTrace {
|
|
|
146
147
|
*/
|
|
147
148
|
public acceptAndMerge(incomingTrace: WorldStateAccessTrace) {
|
|
148
149
|
// Merge storage read and write journals
|
|
149
|
-
|
|
150
|
-
|
|
150
|
+
this.publicStorageReads = this.publicStorageReads.concat(incomingTrace.publicStorageReads);
|
|
151
|
+
this.publicStorageWrites = this.publicStorageWrites.concat(incomingTrace.publicStorageWrites);
|
|
151
152
|
// Merge new note hashes and nullifiers
|
|
152
153
|
this.noteHashChecks = this.noteHashChecks.concat(incomingTrace.noteHashChecks);
|
|
153
154
|
this.newNoteHashes = this.newNoteHashes.concat(incomingTrace.newNoteHashes);
|
|
@@ -157,67 +158,4 @@ export class WorldStateAccessTrace {
|
|
|
157
158
|
// it is assumed that the incoming trace was initialized with this as parent, so accept counter
|
|
158
159
|
this.accessCounter = incomingTrace.accessCounter;
|
|
159
160
|
}
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* We want to keep track of all performed reads in the journal
|
|
163
|
-
* This information is hinted to the avm circuit
|
|
164
|
-
|
|
165
|
-
* @param contractAddress -
|
|
166
|
-
* @param key -
|
|
167
|
-
* @param value -
|
|
168
|
-
*/
|
|
169
|
-
journalUpdate(map: Map<bigint, Map<bigint, Fr[]>>, contractAddress: Fr, key: Fr, value: Fr): void {
|
|
170
|
-
let contractMap = map.get(contractAddress.toBigInt());
|
|
171
|
-
if (!contractMap) {
|
|
172
|
-
contractMap = new Map<bigint, Array<Fr>>();
|
|
173
|
-
map.set(contractAddress.toBigInt(), contractMap);
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
let accessArray = contractMap.get(key.toBigInt());
|
|
177
|
-
if (!accessArray) {
|
|
178
|
-
accessArray = new Array<Fr>();
|
|
179
|
-
contractMap.set(key.toBigInt(), accessArray);
|
|
180
|
-
}
|
|
181
|
-
accessArray.push(value);
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
// Create an instance of journalUpdate that appends to the read array
|
|
185
|
-
private journalRead = this.journalUpdate.bind(this, this.publicStorageReads);
|
|
186
|
-
// Create an instance of journalUpdate that appends to the writes array
|
|
187
|
-
private journalWrite = this.journalUpdate.bind(this, this.publicStorageWrites);
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
/**
|
|
191
|
-
* Merges two contract journalling maps together
|
|
192
|
-
* For read maps, we just append the childMap arrays into the host map arrays, as the order is important
|
|
193
|
-
*
|
|
194
|
-
* @param hostMap - The map to be merged into
|
|
195
|
-
* @param childMap - The map to be merged from
|
|
196
|
-
*/
|
|
197
|
-
function mergeContractJournalMaps(hostMap: Map<bigint, Map<bigint, Fr[]>>, childMap: Map<bigint, Map<bigint, Fr[]>>) {
|
|
198
|
-
for (const [key, value] of childMap) {
|
|
199
|
-
const map1Value = hostMap.get(key);
|
|
200
|
-
if (!map1Value) {
|
|
201
|
-
hostMap.set(key, value);
|
|
202
|
-
} else {
|
|
203
|
-
mergeStorageJournalMaps(map1Value, value);
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
/**
|
|
209
|
-
* Merge two storage journalling maps together (for a particular contract).
|
|
210
|
-
*
|
|
211
|
-
* @param hostMap - The map to be merge into
|
|
212
|
-
* @param childMap - The map to be merged from
|
|
213
|
-
*/
|
|
214
|
-
function mergeStorageJournalMaps(hostMap: Map<bigint, Fr[]>, childMap: Map<bigint, Fr[]>) {
|
|
215
|
-
for (const [key, value] of childMap) {
|
|
216
|
-
const readArr = hostMap.get(key);
|
|
217
|
-
if (!readArr) {
|
|
218
|
-
hostMap.set(key, value);
|
|
219
|
-
} else {
|
|
220
|
-
hostMap.set(key, readArr?.concat(...value));
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
161
|
}
|
|
@@ -6,64 +6,64 @@ import { type Fr } from '@aztec/foundation/fields';
|
|
|
6
6
|
// storageAddress: Fr;
|
|
7
7
|
// endLifetime: Fr;
|
|
8
8
|
//};
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
// callPointer: Fr;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
// endLifetime: Fr;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
// callPointer: Fr;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
// endLifetime: Fr;
|
|
27
|
-
|
|
28
|
-
|
|
9
|
+
|
|
10
|
+
export type TracedPublicStorageRead = {
|
|
11
|
+
// callPointer: Fr;
|
|
12
|
+
storageAddress: Fr;
|
|
13
|
+
exists: boolean;
|
|
14
|
+
slot: Fr;
|
|
15
|
+
value: Fr;
|
|
16
|
+
counter: Fr;
|
|
17
|
+
// endLifetime: Fr;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export type TracedPublicStorageWrite = {
|
|
21
|
+
// callPointer: Fr;
|
|
22
|
+
storageAddress: Fr;
|
|
23
|
+
slot: Fr;
|
|
24
|
+
value: Fr;
|
|
25
|
+
counter: Fr;
|
|
26
|
+
// endLifetime: Fr;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
29
|
export type TracedNoteHashCheck = {
|
|
30
|
-
callPointer: Fr;
|
|
30
|
+
// callPointer: Fr;
|
|
31
31
|
storageAddress: Fr;
|
|
32
32
|
leafIndex: Fr;
|
|
33
33
|
noteHash: Fr;
|
|
34
34
|
exists: boolean;
|
|
35
35
|
counter: Fr;
|
|
36
|
-
endLifetime: Fr;
|
|
36
|
+
// endLifetime: Fr;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export type TracedNoteHash = {
|
|
40
|
+
// callPointer: Fr;
|
|
41
|
+
storageAddress: Fr;
|
|
42
|
+
noteHash: Fr;
|
|
43
|
+
counter: Fr;
|
|
44
|
+
// endLifetime: Fr;
|
|
37
45
|
};
|
|
38
|
-
//
|
|
39
|
-
//export type TracedNoteHash = {
|
|
40
|
-
// callPointer: Fr;
|
|
41
|
-
// storageAddress: Fr;
|
|
42
|
-
// noteHash: Fr;
|
|
43
|
-
// counter: Fr;
|
|
44
|
-
// endLifetime: Fr;
|
|
45
|
-
//};
|
|
46
46
|
|
|
47
47
|
export type TracedNullifierCheck = {
|
|
48
|
-
callPointer: Fr;
|
|
48
|
+
// callPointer: Fr;
|
|
49
49
|
storageAddress: Fr;
|
|
50
50
|
nullifier: Fr;
|
|
51
51
|
exists: boolean;
|
|
52
52
|
counter: Fr;
|
|
53
|
-
endLifetime: Fr;
|
|
53
|
+
// endLifetime: Fr;
|
|
54
54
|
// the fields below are relevant only to the public kernel
|
|
55
55
|
// and are therefore omitted from VM inputs
|
|
56
56
|
isPending: boolean;
|
|
57
57
|
leafIndex: Fr;
|
|
58
58
|
};
|
|
59
59
|
|
|
60
|
-
|
|
61
|
-
//
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
//
|
|
66
|
-
|
|
60
|
+
export type TracedNullifier = {
|
|
61
|
+
// callPointer: Fr;
|
|
62
|
+
storageAddress: Fr;
|
|
63
|
+
nullifier: Fr;
|
|
64
|
+
counter: Fr;
|
|
65
|
+
// endLifetime: Fr;
|
|
66
|
+
};
|
|
67
67
|
|
|
68
68
|
export type TracedL1toL2MessageCheck = {
|
|
69
69
|
//callPointer: Fr;
|
|
@@ -69,7 +69,7 @@ export class EmitNoteHash extends Instruction {
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
const noteHash = memory.get(this.noteHashOffset).toFr();
|
|
72
|
-
context.persistableState.writeNoteHash(noteHash);
|
|
72
|
+
context.persistableState.writeNoteHash(context.environment.storageAddress, noteHash);
|
|
73
73
|
|
|
74
74
|
memory.assert(memoryOperations);
|
|
75
75
|
context.machineState.incrementPc();
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import { FunctionSelector } from '@aztec/circuits.js';
|
|
2
2
|
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
3
3
|
|
|
4
|
+
import { executePublicFunction } from '../../public/executor.js';
|
|
5
|
+
import {
|
|
6
|
+
convertPublicExecutionResult,
|
|
7
|
+
createPublicExecutionContext,
|
|
8
|
+
updateAvmContextFromPublicExecutionResult,
|
|
9
|
+
} from '../../public/transitional_adaptors.js';
|
|
4
10
|
import type { AvmContext } from '../avm_context.js';
|
|
5
11
|
import { gasLeftToGas, sumGas } from '../avm_gas.js';
|
|
6
12
|
import { Field, Uint8 } from '../avm_memory_types.js';
|
|
7
|
-
import {
|
|
13
|
+
import { type AvmContractCallResults } from '../avm_message_call_result.js';
|
|
8
14
|
import { Opcode, OperandType } from '../serialization/instruction_serialization.js';
|
|
9
15
|
import { Addressing } from './addressing_mode.js';
|
|
10
16
|
import { Instruction } from './instruction.js';
|
|
@@ -61,6 +67,7 @@ abstract class ExternalCall extends Instruction {
|
|
|
61
67
|
const totalGas = sumGas(this.gasCost(memoryOperations), allocatedGas);
|
|
62
68
|
context.machineState.consumeGas(totalGas);
|
|
63
69
|
|
|
70
|
+
// TRANSITIONAL: This should be removed once the AVM is fully operational and the public executor is gone.
|
|
64
71
|
const nestedContext = context.createNestedContractCallContext(
|
|
65
72
|
callAddress.toFr(),
|
|
66
73
|
calldata,
|
|
@@ -68,8 +75,21 @@ abstract class ExternalCall extends Instruction {
|
|
|
68
75
|
this.type,
|
|
69
76
|
FunctionSelector.fromField(functionSelector),
|
|
70
77
|
);
|
|
78
|
+
const pxContext = createPublicExecutionContext(nestedContext, calldata);
|
|
79
|
+
const pxResults = await executePublicFunction(pxContext, /*nested=*/ true);
|
|
80
|
+
const nestedCallResults: AvmContractCallResults = convertPublicExecutionResult(pxResults);
|
|
81
|
+
updateAvmContextFromPublicExecutionResult(nestedContext, pxResults);
|
|
82
|
+
const nestedPersistableState = nestedContext.persistableState;
|
|
83
|
+
// const nestedContext = context.createNestedContractCallContext(
|
|
84
|
+
// callAddress.toFr(),
|
|
85
|
+
// calldata,
|
|
86
|
+
// allocatedGas,
|
|
87
|
+
// this.type,
|
|
88
|
+
// FunctionSelector.fromField(functionSelector),
|
|
89
|
+
// );
|
|
90
|
+
// const nestedCallResults: AvmContractCallResults = await new AvmSimulator(nestedContext).execute();
|
|
91
|
+
// const nestedPersistableState = nestedContext.persistableState;
|
|
71
92
|
|
|
72
|
-
const nestedCallResults = await new AvmSimulator(nestedContext).execute();
|
|
73
93
|
const success = !nestedCallResults.reverted;
|
|
74
94
|
|
|
75
95
|
// We only take as much data as was specified in the return size and pad with zeroes if the return data is smaller
|
|
@@ -90,9 +110,9 @@ abstract class ExternalCall extends Instruction {
|
|
|
90
110
|
|
|
91
111
|
// TODO: Should we merge the changes from a nested call in the case of a STATIC call?
|
|
92
112
|
if (success) {
|
|
93
|
-
context.persistableState.acceptNestedCallState(
|
|
113
|
+
context.persistableState.acceptNestedCallState(nestedPersistableState);
|
|
94
114
|
} else {
|
|
95
|
-
context.persistableState.rejectNestedCallState(
|
|
115
|
+
context.persistableState.rejectNestedCallState(nestedPersistableState);
|
|
96
116
|
}
|
|
97
117
|
|
|
98
118
|
memory.assert(memoryOperations);
|
|
@@ -235,7 +235,7 @@ export class ClientExecutionContext extends ViewDataOracle {
|
|
|
235
235
|
offset,
|
|
236
236
|
});
|
|
237
237
|
|
|
238
|
-
this.log(
|
|
238
|
+
this.log.debug(
|
|
239
239
|
`Returning ${notes.length} notes for ${this.callContext.storageContractAddress} at ${storageSlot}: ${notes
|
|
240
240
|
.map(n => `${n.nonce.toString()}:[${n.note.items.map(i => i.toString()).join(',')}]`)
|
|
241
241
|
.join(', ')}`,
|
|
@@ -316,7 +316,7 @@ export class ClientExecutionContext extends ViewDataOracle {
|
|
|
316
316
|
public emitUnencryptedLog(log: UnencryptedL2Log) {
|
|
317
317
|
this.unencryptedLogs.push(log);
|
|
318
318
|
const text = log.toHumanReadable();
|
|
319
|
-
this.log(`Emitted unencrypted log: "${text.length > 100 ? text.slice(0, 100) + '...' : text}"`);
|
|
319
|
+
this.log.verbose(`Emitted unencrypted log: "${text.length > 100 ? text.slice(0, 100) + '...' : text}"`);
|
|
320
320
|
}
|
|
321
321
|
|
|
322
322
|
#checkValidStaticCall(childExecutionResult: ExecutionResult) {
|
|
@@ -349,7 +349,7 @@ export class ClientExecutionContext extends ViewDataOracle {
|
|
|
349
349
|
isStaticCall: boolean,
|
|
350
350
|
isDelegateCall: boolean,
|
|
351
351
|
) {
|
|
352
|
-
this.log(
|
|
352
|
+
this.log.debug(
|
|
353
353
|
`Calling private function ${this.contractAddress}:${functionSelector} from ${this.callContext.storageContractAddress}`,
|
|
354
354
|
);
|
|
355
355
|
|
|
@@ -441,7 +441,7 @@ export class ClientExecutionContext extends ViewDataOracle {
|
|
|
441
441
|
// side-effect counter, that will leak info about how many other private
|
|
442
442
|
// side-effects occurred in the TX. Ultimately the private kernel should
|
|
443
443
|
// just output everything in the proper order without any counters.
|
|
444
|
-
this.log(
|
|
444
|
+
this.log.verbose(
|
|
445
445
|
`Enqueued call to public function (with side-effect counter #${sideEffectCounter}) ${targetContractAddress}:${functionSelector}(${targetArtifact.name})`,
|
|
446
446
|
);
|
|
447
447
|
|
|
@@ -497,7 +497,7 @@ export class ClientExecutionContext extends ViewDataOracle {
|
|
|
497
497
|
throw new Error(`No witness for slot ${storageSlot.toString()}`);
|
|
498
498
|
}
|
|
499
499
|
const value = witness.leafPreimage.value;
|
|
500
|
-
this.log(`Oracle storage read: slot=${storageSlot.toString()} value=${value}`);
|
|
500
|
+
this.log.debug(`Oracle storage read: slot=${storageSlot.toString()} value=${value}`);
|
|
501
501
|
values.push(value);
|
|
502
502
|
}
|
|
503
503
|
return values;
|
|
@@ -22,7 +22,7 @@ export async function executePrivateFunction(
|
|
|
22
22
|
log = createDebugLogger('aztec:simulator:secret_execution'),
|
|
23
23
|
): Promise<ExecutionResult> {
|
|
24
24
|
const functionSelector = functionData.selector;
|
|
25
|
-
log(`Executing external function ${contractAddress}:${functionSelector}(${artifact.name})`);
|
|
25
|
+
log.verbose(`Executing external function ${contractAddress}:${functionSelector}(${artifact.name})`);
|
|
26
26
|
const acir = artifact.bytecode;
|
|
27
27
|
const initialWitness = context.getInitialWitness(artifact);
|
|
28
28
|
const acvmCallback = new Oracle(context);
|
|
@@ -66,7 +66,7 @@ export async function executePrivateFunction(
|
|
|
66
66
|
const nestedExecutions = context.getNestedExecutions();
|
|
67
67
|
const enqueuedPublicFunctionCalls = context.getEnqueuedPublicFunctionCalls();
|
|
68
68
|
|
|
69
|
-
log(`Returning from call to ${contractAddress.toString()}:${functionSelector}`);
|
|
69
|
+
log.debug(`Returning from call to ${contractAddress.toString()}:${functionSelector}`);
|
|
70
70
|
|
|
71
71
|
return {
|
|
72
72
|
acir,
|
|
@@ -23,7 +23,7 @@ export async function executeUnconstrainedFunction(
|
|
|
23
23
|
log = createDebugLogger('aztec:simulator:unconstrained_execution'),
|
|
24
24
|
): Promise<DecodedReturn> {
|
|
25
25
|
const functionSelector = functionData.selector;
|
|
26
|
-
log(`Executing unconstrained function ${contractAddress}:${functionSelector}`);
|
|
26
|
+
log.verbose(`Executing unconstrained function ${contractAddress}:${functionSelector}(${artifact.name})`);
|
|
27
27
|
|
|
28
28
|
const acir = artifact.bytecode;
|
|
29
29
|
const initialWitness = toACVMWitness(0, args);
|
|
@@ -257,7 +257,7 @@ export class ViewDataOracle extends TypedOracle {
|
|
|
257
257
|
const storageSlot = new Fr(startStorageSlot.value + i);
|
|
258
258
|
const value = await this.aztecNode.getPublicStorageAt(this.contractAddress, storageSlot);
|
|
259
259
|
|
|
260
|
-
this.log(`Oracle storage read: slot=${storageSlot.toString()} value=${value}`);
|
|
260
|
+
this.log.debug(`Oracle storage read: slot=${storageSlot.toString()} value=${value}`);
|
|
261
261
|
values.push(value);
|
|
262
262
|
}
|
|
263
263
|
return values;
|