@aztec/txe 4.1.0-rc.3 → 4.2.0-nightly.20260319
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 +19 -19
- package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_top_level_context.js +27 -25
- package/dest/rpc_translator.d.ts +84 -82
- package/dest/rpc_translator.d.ts.map +1 -1
- package/dest/rpc_translator.js +237 -149
- 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 +1 -1
- package/dest/txe_session.d.ts.map +1 -1
- package/dest/txe_session.js +7 -4
- 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 +26 -24
- package/src/rpc_translator.ts +262 -168
- package/src/state_machine/index.ts +5 -1
- package/src/state_machine/synchronizer.ts +4 -4
- package/src/txe_session.ts +6 -3
|
@@ -116,7 +116,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
116
116
|
this.logger.debug('Entering Top Level Context');
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
-
|
|
119
|
+
assertCompatibleOracleVersion(version: number): void {
|
|
120
120
|
if (version !== ORACLE_VERSION) {
|
|
121
121
|
throw new Error(
|
|
122
122
|
`Incompatible oracle version. TXE is using version '${ORACLE_VERSION}', but got a request for '${version}'.`,
|
|
@@ -126,12 +126,12 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
126
126
|
|
|
127
127
|
// This is typically only invoked in private contexts, but it is convenient to also have it in top-level for testing
|
|
128
128
|
// setup.
|
|
129
|
-
|
|
129
|
+
getRandomField(): Fr {
|
|
130
130
|
return Fr.random();
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
// We instruct users to debug contracts via this oracle, so it makes sense that they'd expect it to also work in tests
|
|
134
|
-
|
|
134
|
+
log(level: number, message: string, fields: Fr[]): Promise<void> {
|
|
135
135
|
if (!LogLevels[level]) {
|
|
136
136
|
throw new Error(`Invalid log level: ${level}`);
|
|
137
137
|
}
|
|
@@ -141,23 +141,23 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
141
141
|
return Promise.resolve();
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
-
|
|
144
|
+
getDefaultAddress(): AztecAddress {
|
|
145
145
|
return DEFAULT_ADDRESS;
|
|
146
146
|
}
|
|
147
147
|
|
|
148
|
-
async
|
|
148
|
+
async getNextBlockNumber(): Promise<BlockNumber> {
|
|
149
149
|
return BlockNumber((await this.getLastBlockNumber()) + 1);
|
|
150
150
|
}
|
|
151
151
|
|
|
152
|
-
|
|
152
|
+
getNextBlockTimestamp(): Promise<bigint> {
|
|
153
153
|
return Promise.resolve(this.nextBlockTimestamp);
|
|
154
154
|
}
|
|
155
155
|
|
|
156
|
-
async
|
|
156
|
+
async getLastBlockTimestamp() {
|
|
157
157
|
return (await this.stateMachine.node.getBlockHeader('latest'))!.globalVariables.timestamp;
|
|
158
158
|
}
|
|
159
159
|
|
|
160
|
-
async
|
|
160
|
+
async getLastTxEffects() {
|
|
161
161
|
const latestBlockNumber = await this.stateMachine.archiver.getBlockNumber();
|
|
162
162
|
const block = await this.stateMachine.archiver.getBlock(latestBlockNumber);
|
|
163
163
|
|
|
@@ -173,7 +173,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
173
173
|
|
|
174
174
|
async syncContractNonOracleMethod(contractAddress: AztecAddress, scope: AztecAddress, jobId: string) {
|
|
175
175
|
if (contractAddress.equals(DEFAULT_ADDRESS)) {
|
|
176
|
-
this.logger.debug(`Skipping sync in
|
|
176
|
+
this.logger.debug(`Skipping sync in getPrivateEvents because the events correspond to the default address.`);
|
|
177
177
|
return;
|
|
178
178
|
}
|
|
179
179
|
|
|
@@ -190,7 +190,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
190
190
|
);
|
|
191
191
|
}
|
|
192
192
|
|
|
193
|
-
async
|
|
193
|
+
async getPrivateEvents(selector: EventSelector, contractAddress: AztecAddress, scope: AztecAddress) {
|
|
194
194
|
return (
|
|
195
195
|
await this.privateEventStore.getPrivateEvents(selector, {
|
|
196
196
|
contractAddress,
|
|
@@ -201,7 +201,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
201
201
|
).map(e => e.packedEvent);
|
|
202
202
|
}
|
|
203
203
|
|
|
204
|
-
async
|
|
204
|
+
async advanceBlocksBy(blocks: number) {
|
|
205
205
|
this.logger.debug(`time traveling ${blocks} blocks`);
|
|
206
206
|
|
|
207
207
|
for (let i = 0; i < blocks; i++) {
|
|
@@ -209,12 +209,12 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
209
209
|
}
|
|
210
210
|
}
|
|
211
211
|
|
|
212
|
-
|
|
212
|
+
advanceTimestampBy(duration: UInt64) {
|
|
213
213
|
this.logger.debug(`time traveling ${duration} seconds`);
|
|
214
214
|
this.nextBlockTimestamp += duration;
|
|
215
215
|
}
|
|
216
216
|
|
|
217
|
-
async
|
|
217
|
+
async deploy(artifact: ContractArtifact, instance: ContractInstanceWithAddress, secret: Fr) {
|
|
218
218
|
// Emit deployment nullifier
|
|
219
219
|
await this.mineBlock({
|
|
220
220
|
nullifiers: [
|
|
@@ -226,7 +226,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
226
226
|
});
|
|
227
227
|
|
|
228
228
|
if (!secret.equals(Fr.ZERO)) {
|
|
229
|
-
await this.
|
|
229
|
+
await this.addAccount(artifact, instance, secret);
|
|
230
230
|
} else {
|
|
231
231
|
await this.contractStore.addContractInstance(instance);
|
|
232
232
|
await this.contractStore.addContractArtifact(artifact);
|
|
@@ -234,7 +234,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
234
234
|
}
|
|
235
235
|
}
|
|
236
236
|
|
|
237
|
-
async
|
|
237
|
+
async addAccount(artifact: ContractArtifact, instance: ContractInstanceWithAddress, secret: Fr) {
|
|
238
238
|
const partialAddress = await computePartialAddress(instance);
|
|
239
239
|
|
|
240
240
|
this.logger.debug(`Deployed ${artifact.name} at ${instance.address}`);
|
|
@@ -249,7 +249,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
249
249
|
return completeAddress;
|
|
250
250
|
}
|
|
251
251
|
|
|
252
|
-
async
|
|
252
|
+
async createAccount(secret: Fr) {
|
|
253
253
|
// This is a foot gun !
|
|
254
254
|
const completeAddress = await this.keyStore.addAccount(secret, secret);
|
|
255
255
|
await this.accountStore.setAccount(completeAddress.address, completeAddress);
|
|
@@ -259,7 +259,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
259
259
|
return completeAddress;
|
|
260
260
|
}
|
|
261
261
|
|
|
262
|
-
async
|
|
262
|
+
async addAuthWitness(address: AztecAddress, messageHash: Fr) {
|
|
263
263
|
const account = await this.accountStore.getAccount(address);
|
|
264
264
|
const privateKey = await this.keyStore.getMasterSecretKey(account.publicKeys.masterIncomingViewingPublicKey);
|
|
265
265
|
|
|
@@ -272,7 +272,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
272
272
|
}
|
|
273
273
|
|
|
274
274
|
async mineBlock(options: { nullifiers?: Fr[] } = {}) {
|
|
275
|
-
const blockNumber = await this.
|
|
275
|
+
const blockNumber = await this.getNextBlockNumber();
|
|
276
276
|
|
|
277
277
|
const txEffect = TxEffect.empty();
|
|
278
278
|
txEffect.nullifiers = [getSingleTxBlockRequestHash(blockNumber), ...(options.nullifiers ?? [])];
|
|
@@ -296,7 +296,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
296
296
|
await this.stateMachine.handleL2Block(block);
|
|
297
297
|
}
|
|
298
298
|
|
|
299
|
-
async
|
|
299
|
+
async privateCallNewFlow(
|
|
300
300
|
from: AztecAddress,
|
|
301
301
|
targetContractAddress: AztecAddress = AztecAddress.zero(),
|
|
302
302
|
functionSelector: FunctionSelector = FunctionSelector.empty(),
|
|
@@ -336,7 +336,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
336
336
|
effectiveScopes,
|
|
337
337
|
);
|
|
338
338
|
|
|
339
|
-
const blockNumber = await this.
|
|
339
|
+
const blockNumber = await this.getNextBlockNumber();
|
|
340
340
|
|
|
341
341
|
const callContext = new CallContext(from, targetContractAddress, functionSelector, isStaticCall);
|
|
342
342
|
|
|
@@ -387,6 +387,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
387
387
|
// contract would perform, including setting senderForTags.
|
|
388
388
|
senderForTags: from,
|
|
389
389
|
simulator,
|
|
390
|
+
messageContextService: this.stateMachine.messageContextService,
|
|
390
391
|
});
|
|
391
392
|
|
|
392
393
|
// 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 +410,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
409
410
|
);
|
|
410
411
|
const publicFunctionsCalldata = await Promise.all(
|
|
411
412
|
publicCallRequests.map(async r => {
|
|
412
|
-
const calldata = await privateExecutionOracle.
|
|
413
|
+
const calldata = await privateExecutionOracle.loadFromExecutionCache(r.calldataHash);
|
|
413
414
|
return new HashedValues(calldata, r.calldataHash);
|
|
414
415
|
}),
|
|
415
416
|
);
|
|
@@ -523,7 +524,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
523
524
|
return executionResult.returnValues ?? [];
|
|
524
525
|
}
|
|
525
526
|
|
|
526
|
-
async
|
|
527
|
+
async publicCallNewFlow(
|
|
527
528
|
from: AztecAddress,
|
|
528
529
|
targetContractAddress: AztecAddress,
|
|
529
530
|
calldata: Fr[],
|
|
@@ -533,7 +534,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
533
534
|
`Executing public function ${await this.contractStore.getDebugFunctionName(targetContractAddress, FunctionSelector.fromField(calldata[0]))}@${targetContractAddress} isStaticCall=${isStaticCall}`,
|
|
534
535
|
);
|
|
535
536
|
|
|
536
|
-
const blockNumber = await this.
|
|
537
|
+
const blockNumber = await this.getNextBlockNumber();
|
|
537
538
|
|
|
538
539
|
const gasLimits = new Gas(DEFAULT_DA_GAS_LIMIT, DEFAULT_L2_GAS_LIMIT);
|
|
539
540
|
|
|
@@ -678,7 +679,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
678
679
|
return returnValues ?? [];
|
|
679
680
|
}
|
|
680
681
|
|
|
681
|
-
async
|
|
682
|
+
async executeUtilityFunction(
|
|
682
683
|
targetContractAddress: AztecAddress,
|
|
683
684
|
functionSelector: FunctionSelector,
|
|
684
685
|
args: Fr[],
|
|
@@ -743,6 +744,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
743
744
|
senderAddressBookStore: this.senderAddressBookStore,
|
|
744
745
|
capsuleStore: this.capsuleStore,
|
|
745
746
|
privateEventStore: this.privateEventStore,
|
|
747
|
+
messageContextService: this.stateMachine.messageContextService,
|
|
746
748
|
jobId,
|
|
747
749
|
scopes,
|
|
748
750
|
});
|