@aztec/txe 4.1.2 → 4.2.0-aztecnr-rc.2
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 +28 -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 +22 -21
- package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_top_level_context.js +33 -27
- package/dest/rpc_translator.d.ts +87 -82
- package/dest/rpc_translator.d.ts.map +1 -1
- package/dest/rpc_translator.js +272 -151
- package/dest/state_machine/index.d.ts +6 -3
- package/dest/state_machine/index.d.ts.map +1 -1
- package/dest/state_machine/index.js +8 -4
- 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 +4 -3
- package/dest/txe_session.d.ts.map +1 -1
- package/dest/txe_session.js +19 -10
- package/package.json +15 -15
- package/src/index.ts +8 -5
- package/src/oracle/interfaces.ts +27 -31
- package/src/oracle/txe_oracle_public_context.ts +12 -12
- package/src/oracle/txe_oracle_top_level_context.ts +34 -25
- package/src/rpc_translator.ts +316 -173
- package/src/state_machine/index.ts +8 -1
- package/src/state_machine/synchronizer.ts +4 -4
- package/src/txe_session.ts +24 -5
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
AddressStore,
|
|
18
18
|
CapsuleStore,
|
|
19
19
|
type ContractStore,
|
|
20
|
+
type ContractSyncService,
|
|
20
21
|
NoteStore,
|
|
21
22
|
ORACLE_VERSION,
|
|
22
23
|
PrivateEventStore,
|
|
@@ -111,27 +112,32 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
111
112
|
private version: Fr,
|
|
112
113
|
private chainId: Fr,
|
|
113
114
|
private authwits: Map<string, AuthWitness>,
|
|
115
|
+
private readonly contractSyncService: ContractSyncService,
|
|
114
116
|
) {
|
|
115
117
|
this.logger = createLogger('txe:top_level_context');
|
|
116
118
|
this.logger.debug('Entering Top Level Context');
|
|
117
119
|
}
|
|
118
120
|
|
|
119
|
-
|
|
121
|
+
assertCompatibleOracleVersion(version: number): void {
|
|
120
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.';
|
|
121
127
|
throw new Error(
|
|
122
|
-
`Incompatible
|
|
128
|
+
`Incompatible aztec cli version: ${hint} See https://docs.aztec.network/errors/8 (expected oracle version ${ORACLE_VERSION}, got ${version})`,
|
|
123
129
|
);
|
|
124
130
|
}
|
|
125
131
|
}
|
|
126
132
|
|
|
127
133
|
// This is typically only invoked in private contexts, but it is convenient to also have it in top-level for testing
|
|
128
134
|
// setup.
|
|
129
|
-
|
|
135
|
+
getRandomField(): Fr {
|
|
130
136
|
return Fr.random();
|
|
131
137
|
}
|
|
132
138
|
|
|
133
139
|
// We instruct users to debug contracts via this oracle, so it makes sense that they'd expect it to also work in tests
|
|
134
|
-
|
|
140
|
+
log(level: number, message: string, fields: Fr[]): Promise<void> {
|
|
135
141
|
if (!LogLevels[level]) {
|
|
136
142
|
throw new Error(`Invalid log level: ${level}`);
|
|
137
143
|
}
|
|
@@ -141,23 +147,23 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
141
147
|
return Promise.resolve();
|
|
142
148
|
}
|
|
143
149
|
|
|
144
|
-
|
|
150
|
+
getDefaultAddress(): AztecAddress {
|
|
145
151
|
return DEFAULT_ADDRESS;
|
|
146
152
|
}
|
|
147
153
|
|
|
148
|
-
async
|
|
154
|
+
async getNextBlockNumber(): Promise<BlockNumber> {
|
|
149
155
|
return BlockNumber((await this.getLastBlockNumber()) + 1);
|
|
150
156
|
}
|
|
151
157
|
|
|
152
|
-
|
|
158
|
+
getNextBlockTimestamp(): Promise<bigint> {
|
|
153
159
|
return Promise.resolve(this.nextBlockTimestamp);
|
|
154
160
|
}
|
|
155
161
|
|
|
156
|
-
async
|
|
162
|
+
async getLastBlockTimestamp() {
|
|
157
163
|
return (await this.stateMachine.node.getBlockHeader('latest'))!.globalVariables.timestamp;
|
|
158
164
|
}
|
|
159
165
|
|
|
160
|
-
async
|
|
166
|
+
async getLastTxEffects() {
|
|
161
167
|
const latestBlockNumber = await this.stateMachine.archiver.getBlockNumber();
|
|
162
168
|
const block = await this.stateMachine.archiver.getBlock(latestBlockNumber);
|
|
163
169
|
|
|
@@ -173,7 +179,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
173
179
|
|
|
174
180
|
async syncContractNonOracleMethod(contractAddress: AztecAddress, scope: AztecAddress, jobId: string) {
|
|
175
181
|
if (contractAddress.equals(DEFAULT_ADDRESS)) {
|
|
176
|
-
this.logger.debug(`Skipping sync in
|
|
182
|
+
this.logger.debug(`Skipping sync in getPrivateEvents because the events correspond to the default address.`);
|
|
177
183
|
return;
|
|
178
184
|
}
|
|
179
185
|
|
|
@@ -190,7 +196,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
190
196
|
);
|
|
191
197
|
}
|
|
192
198
|
|
|
193
|
-
async
|
|
199
|
+
async getPrivateEvents(selector: EventSelector, contractAddress: AztecAddress, scope: AztecAddress) {
|
|
194
200
|
return (
|
|
195
201
|
await this.privateEventStore.getPrivateEvents(selector, {
|
|
196
202
|
contractAddress,
|
|
@@ -201,7 +207,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
201
207
|
).map(e => e.packedEvent);
|
|
202
208
|
}
|
|
203
209
|
|
|
204
|
-
async
|
|
210
|
+
async advanceBlocksBy(blocks: number) {
|
|
205
211
|
this.logger.debug(`time traveling ${blocks} blocks`);
|
|
206
212
|
|
|
207
213
|
for (let i = 0; i < blocks; i++) {
|
|
@@ -209,12 +215,12 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
209
215
|
}
|
|
210
216
|
}
|
|
211
217
|
|
|
212
|
-
|
|
218
|
+
advanceTimestampBy(duration: UInt64) {
|
|
213
219
|
this.logger.debug(`time traveling ${duration} seconds`);
|
|
214
220
|
this.nextBlockTimestamp += duration;
|
|
215
221
|
}
|
|
216
222
|
|
|
217
|
-
async
|
|
223
|
+
async deploy(artifact: ContractArtifact, instance: ContractInstanceWithAddress, secret: Fr) {
|
|
218
224
|
// Emit deployment nullifier
|
|
219
225
|
await this.mineBlock({
|
|
220
226
|
nullifiers: [
|
|
@@ -226,7 +232,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
226
232
|
});
|
|
227
233
|
|
|
228
234
|
if (!secret.equals(Fr.ZERO)) {
|
|
229
|
-
await this.
|
|
235
|
+
await this.addAccount(artifact, instance, secret);
|
|
230
236
|
} else {
|
|
231
237
|
await this.contractStore.addContractInstance(instance);
|
|
232
238
|
await this.contractStore.addContractArtifact(artifact);
|
|
@@ -234,7 +240,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
234
240
|
}
|
|
235
241
|
}
|
|
236
242
|
|
|
237
|
-
async
|
|
243
|
+
async addAccount(artifact: ContractArtifact, instance: ContractInstanceWithAddress, secret: Fr) {
|
|
238
244
|
const partialAddress = await computePartialAddress(instance);
|
|
239
245
|
|
|
240
246
|
this.logger.debug(`Deployed ${artifact.name} at ${instance.address}`);
|
|
@@ -249,7 +255,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
249
255
|
return completeAddress;
|
|
250
256
|
}
|
|
251
257
|
|
|
252
|
-
async
|
|
258
|
+
async createAccount(secret: Fr) {
|
|
253
259
|
// This is a foot gun !
|
|
254
260
|
const completeAddress = await this.keyStore.addAccount(secret, secret);
|
|
255
261
|
await this.accountStore.setAccount(completeAddress.address, completeAddress);
|
|
@@ -259,7 +265,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
259
265
|
return completeAddress;
|
|
260
266
|
}
|
|
261
267
|
|
|
262
|
-
async
|
|
268
|
+
async addAuthWitness(address: AztecAddress, messageHash: Fr) {
|
|
263
269
|
const account = await this.accountStore.getAccount(address);
|
|
264
270
|
const privateKey = await this.keyStore.getMasterSecretKey(account.publicKeys.masterIncomingViewingPublicKey);
|
|
265
271
|
|
|
@@ -272,7 +278,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
272
278
|
}
|
|
273
279
|
|
|
274
280
|
async mineBlock(options: { nullifiers?: Fr[] } = {}) {
|
|
275
|
-
const blockNumber = await this.
|
|
281
|
+
const blockNumber = await this.getNextBlockNumber();
|
|
276
282
|
|
|
277
283
|
const txEffect = TxEffect.empty();
|
|
278
284
|
txEffect.nullifiers = [getSingleTxBlockRequestHash(blockNumber), ...(options.nullifiers ?? [])];
|
|
@@ -296,7 +302,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
296
302
|
await this.stateMachine.handleL2Block(block);
|
|
297
303
|
}
|
|
298
304
|
|
|
299
|
-
async
|
|
305
|
+
async privateCallNewFlow(
|
|
300
306
|
from: AztecAddress,
|
|
301
307
|
targetContractAddress: AztecAddress = AztecAddress.zero(),
|
|
302
308
|
functionSelector: FunctionSelector = FunctionSelector.empty(),
|
|
@@ -336,7 +342,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
336
342
|
effectiveScopes,
|
|
337
343
|
);
|
|
338
344
|
|
|
339
|
-
const blockNumber = await this.
|
|
345
|
+
const blockNumber = await this.getNextBlockNumber();
|
|
340
346
|
|
|
341
347
|
const callContext = new CallContext(from, targetContractAddress, functionSelector, isStaticCall);
|
|
342
348
|
|
|
@@ -387,6 +393,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
387
393
|
// contract would perform, including setting senderForTags.
|
|
388
394
|
senderForTags: from,
|
|
389
395
|
simulator,
|
|
396
|
+
messageContextService: this.stateMachine.messageContextService,
|
|
390
397
|
});
|
|
391
398
|
|
|
392
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.
|
|
@@ -409,7 +416,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
409
416
|
);
|
|
410
417
|
const publicFunctionsCalldata = await Promise.all(
|
|
411
418
|
publicCallRequests.map(async r => {
|
|
412
|
-
const calldata = await privateExecutionOracle.
|
|
419
|
+
const calldata = await privateExecutionOracle.getHashPreimage(r.calldataHash);
|
|
413
420
|
return new HashedValues(calldata, r.calldataHash);
|
|
414
421
|
}),
|
|
415
422
|
);
|
|
@@ -523,7 +530,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
523
530
|
return executionResult.returnValues ?? [];
|
|
524
531
|
}
|
|
525
532
|
|
|
526
|
-
async
|
|
533
|
+
async publicCallNewFlow(
|
|
527
534
|
from: AztecAddress,
|
|
528
535
|
targetContractAddress: AztecAddress,
|
|
529
536
|
calldata: Fr[],
|
|
@@ -533,7 +540,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
533
540
|
`Executing public function ${await this.contractStore.getDebugFunctionName(targetContractAddress, FunctionSelector.fromField(calldata[0]))}@${targetContractAddress} isStaticCall=${isStaticCall}`,
|
|
534
541
|
);
|
|
535
542
|
|
|
536
|
-
const blockNumber = await this.
|
|
543
|
+
const blockNumber = await this.getNextBlockNumber();
|
|
537
544
|
|
|
538
545
|
const gasLimits = new Gas(DEFAULT_DA_GAS_LIMIT, DEFAULT_L2_GAS_LIMIT);
|
|
539
546
|
|
|
@@ -678,7 +685,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
678
685
|
return returnValues ?? [];
|
|
679
686
|
}
|
|
680
687
|
|
|
681
|
-
async
|
|
688
|
+
async executeUtilityFunction(
|
|
682
689
|
targetContractAddress: AztecAddress,
|
|
683
690
|
functionSelector: FunctionSelector,
|
|
684
691
|
args: Fr[],
|
|
@@ -743,6 +750,8 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
743
750
|
senderAddressBookStore: this.senderAddressBookStore,
|
|
744
751
|
capsuleStore: this.capsuleStore,
|
|
745
752
|
privateEventStore: this.privateEventStore,
|
|
753
|
+
messageContextService: this.stateMachine.messageContextService,
|
|
754
|
+
contractSyncService: this.contractSyncService,
|
|
746
755
|
jobId,
|
|
747
756
|
scopes,
|
|
748
757
|
});
|