@aztec/txe 4.0.0-devnet.2-patch.4 → 4.0.0-devnet.3-patch.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/index.d.ts +1 -1
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +8 -6
- package/dest/oracle/interfaces.d.ts +29 -28
- package/dest/oracle/interfaces.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_public_context.d.ts +13 -13
- package/dest/oracle/txe_oracle_public_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_public_context.js +12 -12
- package/dest/oracle/txe_oracle_top_level_context.d.ts +23 -22
- package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_top_level_context.js +57 -41
- package/dest/rpc_translator.d.ts +87 -82
- package/dest/rpc_translator.d.ts.map +1 -1
- package/dest/rpc_translator.js +285 -152
- package/dest/state_machine/archiver.d.ts +3 -3
- package/dest/state_machine/archiver.d.ts.map +1 -1
- package/dest/state_machine/archiver.js +5 -7
- package/dest/state_machine/dummy_p2p_client.d.ts +4 -3
- package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
- package/dest/state_machine/dummy_p2p_client.js +4 -1
- package/dest/state_machine/index.d.ts +4 -2
- package/dest/state_machine/index.d.ts.map +1 -1
- package/dest/state_machine/index.js +6 -2
- package/dest/state_machine/synchronizer.d.ts +5 -5
- package/dest/state_machine/synchronizer.d.ts.map +1 -1
- package/dest/state_machine/synchronizer.js +3 -3
- package/dest/txe_session.d.ts +9 -3
- package/dest/txe_session.d.ts.map +1 -1
- package/dest/txe_session.js +33 -17
- package/package.json +15 -15
- package/src/index.ts +8 -5
- package/src/oracle/interfaces.ts +32 -31
- package/src/oracle/txe_oracle_public_context.ts +12 -12
- package/src/oracle/txe_oracle_top_level_context.ts +69 -40
- package/src/rpc_translator.ts +332 -174
- package/src/state_machine/archiver.ts +5 -5
- package/src/state_machine/dummy_p2p_client.ts +6 -2
- package/src/state_machine/index.ts +5 -1
- package/src/state_machine/synchronizer.ts +4 -4
- package/src/txe_session.ts +42 -17
package/src/oracle/interfaces.ts
CHANGED
|
@@ -24,18 +24,18 @@ import type { UInt64 } from '@aztec/stdlib/types';
|
|
|
24
24
|
export interface IAvmExecutionOracle {
|
|
25
25
|
isAvm: true;
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
27
|
+
address(): Promise<AztecAddress>;
|
|
28
|
+
sender(): Promise<AztecAddress>;
|
|
29
|
+
blockNumber(): Promise<BlockNumber>;
|
|
30
|
+
timestamp(): Promise<bigint>;
|
|
31
|
+
isStaticCall(): Promise<boolean>;
|
|
32
|
+
chainId(): Promise<Fr>;
|
|
33
|
+
version(): Promise<Fr>;
|
|
34
|
+
emitNullifier(nullifier: Fr): Promise<void>;
|
|
35
|
+
emitNoteHash(noteHash: Fr): Promise<void>;
|
|
36
|
+
nullifierExists(siloedNullifier: Fr): Promise<boolean>;
|
|
37
|
+
storageWrite(slot: Fr, value: Fr): Promise<void>;
|
|
38
|
+
storageRead(slot: Fr, contractAddress: AztecAddress): Promise<Fr>;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
/**
|
|
@@ -44,43 +44,44 @@ export interface IAvmExecutionOracle {
|
|
|
44
44
|
export interface ITxeExecutionOracle {
|
|
45
45
|
isTxe: true;
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
): Promise<CompleteAddress>;
|
|
59
|
-
txeAddAuthWitness(address: AztecAddress, messageHash: Fr): Promise<void>;
|
|
60
|
-
txeGetLastBlockTimestamp(): Promise<bigint>;
|
|
61
|
-
txeGetLastTxEffects(): Promise<{
|
|
47
|
+
getDefaultAddress(): AztecAddress;
|
|
48
|
+
getNextBlockNumber(): Promise<BlockNumber>;
|
|
49
|
+
getNextBlockTimestamp(): Promise<UInt64>;
|
|
50
|
+
advanceBlocksBy(blocks: number): Promise<void>;
|
|
51
|
+
advanceTimestampBy(duration: UInt64): void;
|
|
52
|
+
deploy(artifact: ContractArtifact, instance: ContractInstanceWithAddress, foreignSecret: Fr): Promise<void>;
|
|
53
|
+
createAccount(secret: Fr): Promise<CompleteAddress>;
|
|
54
|
+
addAccount(artifact: ContractArtifact, instance: ContractInstanceWithAddress, secret: Fr): Promise<CompleteAddress>;
|
|
55
|
+
addAuthWitness(address: AztecAddress, messageHash: Fr): Promise<void>;
|
|
56
|
+
getLastBlockTimestamp(): Promise<bigint>;
|
|
57
|
+
getLastTxEffects(): Promise<{
|
|
62
58
|
txHash: TxHash;
|
|
63
59
|
noteHashes: Fr[];
|
|
64
60
|
nullifiers: Fr[];
|
|
65
61
|
}>;
|
|
66
|
-
|
|
67
|
-
|
|
62
|
+
getPrivateEvents(selector: EventSelector, contractAddress: AztecAddress, scope: AztecAddress): Promise<Fr[][]>;
|
|
63
|
+
privateCallNewFlow(
|
|
68
64
|
from: AztecAddress,
|
|
69
65
|
targetContractAddress: AztecAddress,
|
|
70
66
|
functionSelector: FunctionSelector,
|
|
71
67
|
args: Fr[],
|
|
72
68
|
argsHash: Fr,
|
|
73
69
|
isStaticCall: boolean,
|
|
70
|
+
jobId: string,
|
|
74
71
|
): Promise<Fr[]>;
|
|
75
|
-
|
|
72
|
+
executeUtilityFunction(
|
|
76
73
|
targetContractAddress: AztecAddress,
|
|
77
74
|
functionSelector: FunctionSelector,
|
|
78
75
|
args: Fr[],
|
|
76
|
+
jobId: string,
|
|
79
77
|
): Promise<Fr[]>;
|
|
80
|
-
|
|
78
|
+
publicCallNewFlow(
|
|
81
79
|
from: AztecAddress,
|
|
82
80
|
targetContractAddress: AztecAddress,
|
|
83
81
|
calldata: Fr[],
|
|
84
82
|
isStaticCall: boolean,
|
|
85
83
|
): Promise<Fr[]>;
|
|
84
|
+
// TODO(F-335): Drop this from here as it's not a real oracle handler - it's only called from
|
|
85
|
+
// RPCTranslator::txeGetPrivateEvents and never from Noir.
|
|
86
|
+
syncContractNonOracleMethod(contractAddress: AztecAddress, scope: AztecAddress, jobId: string): Promise<void>;
|
|
86
87
|
}
|
|
@@ -39,46 +39,46 @@ export class TXEOraclePublicContext implements IAvmExecutionOracle {
|
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
address(): Promise<AztecAddress> {
|
|
43
43
|
return Promise.resolve(this.contractAddress);
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
sender(): Promise<AztecAddress> {
|
|
47
47
|
return Promise.resolve(AztecAddress.ZERO); // todo: change?
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
blockNumber(): Promise<BlockNumber> {
|
|
51
51
|
return Promise.resolve(this.globalVariables.blockNumber);
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
timestamp(): Promise<bigint> {
|
|
55
55
|
return Promise.resolve(this.globalVariables.timestamp);
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
|
|
58
|
+
isStaticCall(): Promise<boolean> {
|
|
59
59
|
return Promise.resolve(false);
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
|
|
62
|
+
chainId(): Promise<Fr> {
|
|
63
63
|
return Promise.resolve(this.globalVariables.chainId);
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
|
|
66
|
+
version(): Promise<Fr> {
|
|
67
67
|
return Promise.resolve(this.globalVariables.version);
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
async
|
|
70
|
+
async emitNullifier(nullifier: Fr) {
|
|
71
71
|
const siloedNullifier = await siloNullifier(this.contractAddress, nullifier);
|
|
72
72
|
this.transientSiloedNullifiers.push(siloedNullifier);
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
async
|
|
75
|
+
async emitNoteHash(noteHash: Fr) {
|
|
76
76
|
const siloedNoteHash = await siloNoteHash(this.contractAddress, noteHash);
|
|
77
77
|
// TODO: make the note hash unique - they are only siloed right now
|
|
78
78
|
this.transientUniqueNoteHashes.push(siloedNoteHash);
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
async
|
|
81
|
+
async nullifierExists(siloedNullifier: Fr): Promise<boolean> {
|
|
82
82
|
const treeIndex = (
|
|
83
83
|
await this.forkedWorldTrees.findLeafIndices(MerkleTreeId.NULLIFIER_TREE, [siloedNullifier.toBuffer()])
|
|
84
84
|
)[0];
|
|
@@ -87,7 +87,7 @@ export class TXEOraclePublicContext implements IAvmExecutionOracle {
|
|
|
87
87
|
return treeIndex !== undefined || transientIndex !== undefined;
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
async
|
|
90
|
+
async storageWrite(slot: Fr, value: Fr) {
|
|
91
91
|
this.logger.debug('AVM storage write', { slot, value });
|
|
92
92
|
|
|
93
93
|
const dataWrite = new PublicDataWrite(await computePublicDataTreeLeafSlot(this.contractAddress, slot), value);
|
|
@@ -99,7 +99,7 @@ export class TXEOraclePublicContext implements IAvmExecutionOracle {
|
|
|
99
99
|
]);
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
async
|
|
102
|
+
async storageRead(slot: Fr, contractAddress: AztecAddress): Promise<Fr> {
|
|
103
103
|
const leafSlot = await computePublicDataTreeLeafSlot(contractAddress, slot);
|
|
104
104
|
|
|
105
105
|
const lowLeafResult = await this.forkedWorldTrees.getPreviousValueIndex(
|
|
@@ -12,11 +12,12 @@ import { Fr } from '@aztec/foundation/curves/bn254';
|
|
|
12
12
|
import { LogLevels, type Logger, applyStringFormatting, createLogger } from '@aztec/foundation/log';
|
|
13
13
|
import { TestDateProvider } from '@aztec/foundation/timer';
|
|
14
14
|
import type { KeyStore } from '@aztec/key-store';
|
|
15
|
-
import type { AccessScopes } from '@aztec/pxe/client/lazy';
|
|
16
15
|
import {
|
|
17
16
|
AddressStore,
|
|
17
|
+
CapsuleService,
|
|
18
18
|
CapsuleStore,
|
|
19
19
|
type ContractStore,
|
|
20
|
+
type ContractSyncService,
|
|
20
21
|
NoteStore,
|
|
21
22
|
ORACLE_VERSION,
|
|
22
23
|
PrivateEventStore,
|
|
@@ -107,32 +108,36 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
107
108
|
private senderAddressBookStore: SenderAddressBookStore,
|
|
108
109
|
private capsuleStore: CapsuleStore,
|
|
109
110
|
private privateEventStore: PrivateEventStore,
|
|
110
|
-
private jobId: string,
|
|
111
111
|
private nextBlockTimestamp: bigint,
|
|
112
112
|
private version: Fr,
|
|
113
113
|
private chainId: Fr,
|
|
114
114
|
private authwits: Map<string, AuthWitness>,
|
|
115
|
+
private readonly contractSyncService: ContractSyncService,
|
|
115
116
|
) {
|
|
116
117
|
this.logger = createLogger('txe:top_level_context');
|
|
117
118
|
this.logger.debug('Entering Top Level Context');
|
|
118
119
|
}
|
|
119
120
|
|
|
120
|
-
|
|
121
|
+
assertCompatibleOracleVersion(version: number): void {
|
|
121
122
|
if (version !== ORACLE_VERSION) {
|
|
123
|
+
const hint =
|
|
124
|
+
version > ORACLE_VERSION
|
|
125
|
+
? 'The contract was compiled with a newer version of Aztec.nr than this aztec cli version supports. Upgrade your aztec cli version to a compatible version.'
|
|
126
|
+
: 'The contract was compiled with an older version of Aztec.nr than this aztec cli version supports. Recompile the contract with a compatible version of Aztec.nr.';
|
|
122
127
|
throw new Error(
|
|
123
|
-
`Incompatible
|
|
128
|
+
`Incompatible aztec cli version: ${hint} See https://docs.aztec.network/errors/8 (expected oracle version ${ORACLE_VERSION}, got ${version})`,
|
|
124
129
|
);
|
|
125
130
|
}
|
|
126
131
|
}
|
|
127
132
|
|
|
128
133
|
// This is typically only invoked in private contexts, but it is convenient to also have it in top-level for testing
|
|
129
134
|
// setup.
|
|
130
|
-
|
|
135
|
+
getRandomField(): Fr {
|
|
131
136
|
return Fr.random();
|
|
132
137
|
}
|
|
133
138
|
|
|
134
139
|
// We instruct users to debug contracts via this oracle, so it makes sense that they'd expect it to also work in tests
|
|
135
|
-
|
|
140
|
+
log(level: number, message: string, fields: Fr[]): Promise<void> {
|
|
136
141
|
if (!LogLevels[level]) {
|
|
137
142
|
throw new Error(`Invalid log level: ${level}`);
|
|
138
143
|
}
|
|
@@ -142,23 +147,23 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
142
147
|
return Promise.resolve();
|
|
143
148
|
}
|
|
144
149
|
|
|
145
|
-
|
|
150
|
+
getDefaultAddress(): AztecAddress {
|
|
146
151
|
return DEFAULT_ADDRESS;
|
|
147
152
|
}
|
|
148
153
|
|
|
149
|
-
async
|
|
154
|
+
async getNextBlockNumber(): Promise<BlockNumber> {
|
|
150
155
|
return BlockNumber((await this.getLastBlockNumber()) + 1);
|
|
151
156
|
}
|
|
152
157
|
|
|
153
|
-
|
|
158
|
+
getNextBlockTimestamp(): Promise<bigint> {
|
|
154
159
|
return Promise.resolve(this.nextBlockTimestamp);
|
|
155
160
|
}
|
|
156
161
|
|
|
157
|
-
async
|
|
162
|
+
async getLastBlockTimestamp() {
|
|
158
163
|
return (await this.stateMachine.node.getBlockHeader('latest'))!.globalVariables.timestamp;
|
|
159
164
|
}
|
|
160
165
|
|
|
161
|
-
async
|
|
166
|
+
async getLastTxEffects() {
|
|
162
167
|
const latestBlockNumber = await this.stateMachine.archiver.getBlockNumber();
|
|
163
168
|
const block = await this.stateMachine.archiver.getBlock(latestBlockNumber);
|
|
164
169
|
|
|
@@ -172,7 +177,26 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
172
177
|
return { txHash: txEffects.txHash, noteHashes: txEffects.noteHashes, nullifiers: txEffects.nullifiers };
|
|
173
178
|
}
|
|
174
179
|
|
|
175
|
-
async
|
|
180
|
+
async syncContractNonOracleMethod(contractAddress: AztecAddress, scope: AztecAddress, jobId: string) {
|
|
181
|
+
if (contractAddress.equals(DEFAULT_ADDRESS)) {
|
|
182
|
+
this.logger.debug(`Skipping sync in getPrivateEvents because the events correspond to the default address.`);
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
const blockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
|
|
187
|
+
await this.stateMachine.contractSyncService.ensureContractSynced(
|
|
188
|
+
contractAddress,
|
|
189
|
+
null,
|
|
190
|
+
async (call, execScopes) => {
|
|
191
|
+
await this.executeUtilityCall(call, execScopes, jobId);
|
|
192
|
+
},
|
|
193
|
+
blockHeader,
|
|
194
|
+
jobId,
|
|
195
|
+
[scope],
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
async getPrivateEvents(selector: EventSelector, contractAddress: AztecAddress, scope: AztecAddress) {
|
|
176
200
|
return (
|
|
177
201
|
await this.privateEventStore.getPrivateEvents(selector, {
|
|
178
202
|
contractAddress,
|
|
@@ -183,7 +207,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
183
207
|
).map(e => e.packedEvent);
|
|
184
208
|
}
|
|
185
209
|
|
|
186
|
-
async
|
|
210
|
+
async advanceBlocksBy(blocks: number) {
|
|
187
211
|
this.logger.debug(`time traveling ${blocks} blocks`);
|
|
188
212
|
|
|
189
213
|
for (let i = 0; i < blocks; i++) {
|
|
@@ -191,12 +215,12 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
191
215
|
}
|
|
192
216
|
}
|
|
193
217
|
|
|
194
|
-
|
|
218
|
+
advanceTimestampBy(duration: UInt64) {
|
|
195
219
|
this.logger.debug(`time traveling ${duration} seconds`);
|
|
196
220
|
this.nextBlockTimestamp += duration;
|
|
197
221
|
}
|
|
198
222
|
|
|
199
|
-
async
|
|
223
|
+
async deploy(artifact: ContractArtifact, instance: ContractInstanceWithAddress, secret: Fr) {
|
|
200
224
|
// Emit deployment nullifier
|
|
201
225
|
await this.mineBlock({
|
|
202
226
|
nullifiers: [
|
|
@@ -208,7 +232,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
208
232
|
});
|
|
209
233
|
|
|
210
234
|
if (!secret.equals(Fr.ZERO)) {
|
|
211
|
-
await this.
|
|
235
|
+
await this.addAccount(artifact, instance, secret);
|
|
212
236
|
} else {
|
|
213
237
|
await this.contractStore.addContractInstance(instance);
|
|
214
238
|
await this.contractStore.addContractArtifact(artifact);
|
|
@@ -216,7 +240,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
216
240
|
}
|
|
217
241
|
}
|
|
218
242
|
|
|
219
|
-
async
|
|
243
|
+
async addAccount(artifact: ContractArtifact, instance: ContractInstanceWithAddress, secret: Fr) {
|
|
220
244
|
const partialAddress = await computePartialAddress(instance);
|
|
221
245
|
|
|
222
246
|
this.logger.debug(`Deployed ${artifact.name} at ${instance.address}`);
|
|
@@ -231,7 +255,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
231
255
|
return completeAddress;
|
|
232
256
|
}
|
|
233
257
|
|
|
234
|
-
async
|
|
258
|
+
async createAccount(secret: Fr) {
|
|
235
259
|
// This is a foot gun !
|
|
236
260
|
const completeAddress = await this.keyStore.addAccount(secret, secret);
|
|
237
261
|
await this.accountStore.setAccount(completeAddress.address, completeAddress);
|
|
@@ -241,7 +265,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
241
265
|
return completeAddress;
|
|
242
266
|
}
|
|
243
267
|
|
|
244
|
-
async
|
|
268
|
+
async addAuthWitness(address: AztecAddress, messageHash: Fr) {
|
|
245
269
|
const account = await this.accountStore.getAccount(address);
|
|
246
270
|
const privateKey = await this.keyStore.getMasterSecretKey(account.publicKeys.masterIncomingViewingPublicKey);
|
|
247
271
|
|
|
@@ -254,7 +278,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
254
278
|
}
|
|
255
279
|
|
|
256
280
|
async mineBlock(options: { nullifiers?: Fr[] } = {}) {
|
|
257
|
-
const blockNumber = await this.
|
|
281
|
+
const blockNumber = await this.getNextBlockNumber();
|
|
258
282
|
|
|
259
283
|
const txEffect = TxEffect.empty();
|
|
260
284
|
txEffect.nullifiers = [getSingleTxBlockRequestHash(blockNumber), ...(options.nullifiers ?? [])];
|
|
@@ -278,13 +302,14 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
278
302
|
await this.stateMachine.handleL2Block(block);
|
|
279
303
|
}
|
|
280
304
|
|
|
281
|
-
async
|
|
305
|
+
async privateCallNewFlow(
|
|
282
306
|
from: AztecAddress,
|
|
283
307
|
targetContractAddress: AztecAddress = AztecAddress.zero(),
|
|
284
308
|
functionSelector: FunctionSelector = FunctionSelector.empty(),
|
|
285
309
|
args: Fr[],
|
|
286
310
|
argsHash: Fr = Fr.zero(),
|
|
287
311
|
isStaticCall: boolean = false,
|
|
312
|
+
jobId: string,
|
|
288
313
|
) {
|
|
289
314
|
this.logger.verbose(
|
|
290
315
|
`Executing external function ${await this.contractStore.getDebugFunctionName(targetContractAddress, functionSelector)}@${targetContractAddress} isStaticCall=${isStaticCall}`,
|
|
@@ -303,8 +328,8 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
303
328
|
const effectiveScopes = from.isZero() ? [] : [from];
|
|
304
329
|
|
|
305
330
|
// Sync notes before executing private function to discover notes from previous transactions
|
|
306
|
-
const utilityExecutor = async (call: FunctionCall, execScopes:
|
|
307
|
-
await this.executeUtilityCall(call, execScopes);
|
|
331
|
+
const utilityExecutor = async (call: FunctionCall, execScopes: AztecAddress[]) => {
|
|
332
|
+
await this.executeUtilityCall(call, execScopes, jobId);
|
|
308
333
|
};
|
|
309
334
|
|
|
310
335
|
const blockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
|
|
@@ -313,11 +338,11 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
313
338
|
functionSelector,
|
|
314
339
|
utilityExecutor,
|
|
315
340
|
blockHeader,
|
|
316
|
-
|
|
341
|
+
jobId,
|
|
317
342
|
effectiveScopes,
|
|
318
343
|
);
|
|
319
344
|
|
|
320
|
-
const blockNumber = await this.
|
|
345
|
+
const blockNumber = await this.getNextBlockNumber();
|
|
321
346
|
|
|
322
347
|
const callContext = new CallContext(from, targetContractAddress, functionSelector, isStaticCall);
|
|
323
348
|
|
|
@@ -357,10 +382,10 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
357
382
|
senderTaggingStore: this.senderTaggingStore,
|
|
358
383
|
recipientTaggingStore: this.recipientTaggingStore,
|
|
359
384
|
senderAddressBookStore: this.senderAddressBookStore,
|
|
360
|
-
|
|
385
|
+
capsuleService: new CapsuleService(this.capsuleStore, effectiveScopes),
|
|
361
386
|
privateEventStore: this.privateEventStore,
|
|
362
387
|
contractSyncService: this.stateMachine.contractSyncService,
|
|
363
|
-
jobId
|
|
388
|
+
jobId,
|
|
364
389
|
totalPublicCalldataCount: 0,
|
|
365
390
|
sideEffectCounter: minRevertibleSideEffectCounter,
|
|
366
391
|
scopes: effectiveScopes,
|
|
@@ -368,6 +393,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
368
393
|
// contract would perform, including setting senderForTags.
|
|
369
394
|
senderForTags: from,
|
|
370
395
|
simulator,
|
|
396
|
+
messageContextService: this.stateMachine.messageContextService,
|
|
371
397
|
});
|
|
372
398
|
|
|
373
399
|
// Note: This is a slight modification of simulator.run without any of the checks. Maybe we should modify simulator.run with a boolean value to skip checks.
|
|
@@ -390,7 +416,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
390
416
|
);
|
|
391
417
|
const publicFunctionsCalldata = await Promise.all(
|
|
392
418
|
publicCallRequests.map(async r => {
|
|
393
|
-
const calldata = await privateExecutionOracle.
|
|
419
|
+
const calldata = await privateExecutionOracle.getHashPreimage(r.calldataHash);
|
|
394
420
|
return new HashedValues(calldata, r.calldataHash);
|
|
395
421
|
}),
|
|
396
422
|
);
|
|
@@ -504,7 +530,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
504
530
|
return executionResult.returnValues ?? [];
|
|
505
531
|
}
|
|
506
532
|
|
|
507
|
-
async
|
|
533
|
+
async publicCallNewFlow(
|
|
508
534
|
from: AztecAddress,
|
|
509
535
|
targetContractAddress: AztecAddress,
|
|
510
536
|
calldata: Fr[],
|
|
@@ -514,7 +540,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
514
540
|
`Executing public function ${await this.contractStore.getDebugFunctionName(targetContractAddress, FunctionSelector.fromField(calldata[0]))}@${targetContractAddress} isStaticCall=${isStaticCall}`,
|
|
515
541
|
);
|
|
516
542
|
|
|
517
|
-
const blockNumber = await this.
|
|
543
|
+
const blockNumber = await this.getNextBlockNumber();
|
|
518
544
|
|
|
519
545
|
const gasLimits = new Gas(DEFAULT_DA_GAS_LIMIT, DEFAULT_L2_GAS_LIMIT);
|
|
520
546
|
|
|
@@ -659,10 +685,11 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
659
685
|
return returnValues ?? [];
|
|
660
686
|
}
|
|
661
687
|
|
|
662
|
-
async
|
|
688
|
+
async executeUtilityFunction(
|
|
663
689
|
targetContractAddress: AztecAddress,
|
|
664
690
|
functionSelector: FunctionSelector,
|
|
665
691
|
args: Fr[],
|
|
692
|
+
jobId: string,
|
|
666
693
|
) {
|
|
667
694
|
const artifact = await this.contractStore.getFunctionArtifact(targetContractAddress, functionSelector);
|
|
668
695
|
if (!artifact) {
|
|
@@ -675,11 +702,11 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
675
702
|
targetContractAddress,
|
|
676
703
|
functionSelector,
|
|
677
704
|
async (call, execScopes) => {
|
|
678
|
-
await this.executeUtilityCall(call, execScopes);
|
|
705
|
+
await this.executeUtilityCall(call, execScopes, jobId);
|
|
679
706
|
},
|
|
680
707
|
blockHeader,
|
|
681
|
-
|
|
682
|
-
|
|
708
|
+
jobId,
|
|
709
|
+
await this.keyStore.getAccounts(),
|
|
683
710
|
);
|
|
684
711
|
|
|
685
712
|
const call = FunctionCall.from({
|
|
@@ -693,10 +720,10 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
693
720
|
returnTypes: [],
|
|
694
721
|
});
|
|
695
722
|
|
|
696
|
-
return this.executeUtilityCall(call,
|
|
723
|
+
return this.executeUtilityCall(call, await this.keyStore.getAccounts(), jobId);
|
|
697
724
|
}
|
|
698
725
|
|
|
699
|
-
private async executeUtilityCall(call: FunctionCall, scopes:
|
|
726
|
+
private async executeUtilityCall(call: FunctionCall, scopes: AztecAddress[], jobId: string): Promise<Fr[]> {
|
|
700
727
|
const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(call.to, call.selector);
|
|
701
728
|
if (entryPointArtifact.functionType !== FunctionType.UTILITY) {
|
|
702
729
|
throw new Error(`Cannot run ${entryPointArtifact.functionType} function as utility`);
|
|
@@ -721,9 +748,11 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
721
748
|
aztecNode: this.stateMachine.node,
|
|
722
749
|
recipientTaggingStore: this.recipientTaggingStore,
|
|
723
750
|
senderAddressBookStore: this.senderAddressBookStore,
|
|
724
|
-
|
|
751
|
+
capsuleService: new CapsuleService(this.capsuleStore, scopes),
|
|
725
752
|
privateEventStore: this.privateEventStore,
|
|
726
|
-
|
|
753
|
+
messageContextService: this.stateMachine.messageContextService,
|
|
754
|
+
contractSyncService: this.contractSyncService,
|
|
755
|
+
jobId,
|
|
727
756
|
scopes,
|
|
728
757
|
});
|
|
729
758
|
const acirExecutionResult = await new WASMSimulator()
|
|
@@ -741,10 +770,10 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
741
770
|
);
|
|
742
771
|
});
|
|
743
772
|
|
|
744
|
-
this.logger.verbose(`Utility
|
|
773
|
+
this.logger.verbose(`Utility execution for ${call.to}.${call.selector} completed`);
|
|
745
774
|
return witnessMapToFields(acirExecutionResult.returnWitness);
|
|
746
775
|
} catch (err) {
|
|
747
|
-
throw createSimulationError(err instanceof Error ? err : new Error('Unknown error during utility
|
|
776
|
+
throw createSimulationError(err instanceof Error ? err : new Error('Unknown error during utility execution'));
|
|
748
777
|
}
|
|
749
778
|
}
|
|
750
779
|
|