@aztec/txe 3.0.0-nightly.20250925 → 3.0.0-nightly.20250927
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/oracle/interfaces.d.ts +51 -0
- package/dest/oracle/interfaces.d.ts.map +1 -0
- package/dest/oracle/interfaces.js +3 -0
- package/dest/oracle/txe_oracle_public_context.d.ts +5 -3
- package/dest/oracle/txe_oracle_public_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_public_context.js +14 -3
- package/dest/oracle/txe_oracle_top_level_context.d.ts +9 -7
- package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_top_level_context.js +24 -24
- package/dest/rpc_translator.d.ts +13 -4
- package/dest/rpc_translator.d.ts.map +1 -1
- package/dest/rpc_translator.js +101 -66
- package/dest/txe_session.d.ts +15 -15
- package/dest/txe_session.d.ts.map +1 -1
- package/dest/txe_session.js +141 -99
- package/dest/utils/tx_effect_creation.d.ts +5 -0
- package/dest/utils/tx_effect_creation.d.ts.map +1 -0
- package/dest/utils/tx_effect_creation.js +16 -0
- package/package.json +15 -15
- package/src/oracle/interfaces.ts +80 -0
- package/src/oracle/txe_oracle_public_context.ts +20 -15
- package/src/oracle/txe_oracle_top_level_context.ts +26 -43
- package/src/rpc_translator.ts +125 -69
- package/src/txe_session.ts +196 -120
- package/src/utils/tx_effect_creation.ts +37 -0
- package/dest/oracle/txe_oracle.d.ts +0 -64
- package/dest/oracle/txe_oracle.d.ts.map +0 -1
- package/dest/oracle/txe_oracle.js +0 -263
- package/dest/oracle/txe_typed_oracle.d.ts +0 -41
- package/dest/oracle/txe_typed_oracle.d.ts.map +0 -1
- package/dest/oracle/txe_typed_oracle.js +0 -89
- package/src/oracle/txe_oracle.ts +0 -419
- package/src/oracle/txe_typed_oracle.ts +0 -147
|
@@ -20,9 +20,9 @@ import {
|
|
|
20
20
|
import {
|
|
21
21
|
ExecutionNoteCache,
|
|
22
22
|
HashedValuesCache,
|
|
23
|
+
type IMiscOracle,
|
|
23
24
|
Oracle,
|
|
24
25
|
PrivateExecutionOracle,
|
|
25
|
-
UtilityContext,
|
|
26
26
|
UtilityExecutionOracle,
|
|
27
27
|
executePrivateFunction,
|
|
28
28
|
generateSimulatedProvingResult,
|
|
@@ -82,11 +82,13 @@ import {
|
|
|
82
82
|
insertTxEffectIntoWorldTrees,
|
|
83
83
|
makeTXEBlockHeader,
|
|
84
84
|
} from '../utils/block_creation.js';
|
|
85
|
-
import {
|
|
85
|
+
import type { ITxeExecutionOracle } from './interfaces.js';
|
|
86
|
+
|
|
87
|
+
export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracle {
|
|
88
|
+
isMisc = true as const;
|
|
89
|
+
isTxe = true as const;
|
|
86
90
|
|
|
87
|
-
export class TXEOracleTopLevelContext extends TXETypedOracle {
|
|
88
91
|
private logger: Logger;
|
|
89
|
-
private authwits: Map<string, AuthWitness> = new Map();
|
|
90
92
|
|
|
91
93
|
constructor(
|
|
92
94
|
private stateMachine: TXEStateMachine,
|
|
@@ -98,14 +100,13 @@ export class TXEOracleTopLevelContext extends TXETypedOracle {
|
|
|
98
100
|
private nextBlockTimestamp: bigint,
|
|
99
101
|
private version: Fr,
|
|
100
102
|
private chainId: Fr,
|
|
103
|
+
private authwits: Map<string, AuthWitness>,
|
|
101
104
|
) {
|
|
102
|
-
super('TXEOracleTopLevelContext');
|
|
103
|
-
|
|
104
105
|
this.logger = createLogger('txe:top_level_context');
|
|
105
106
|
this.logger.debug('Entering Top Level Context');
|
|
106
107
|
}
|
|
107
108
|
|
|
108
|
-
|
|
109
|
+
utilityAssertCompatibleOracleVersion(version: number): void {
|
|
109
110
|
if (version !== ORACLE_VERSION) {
|
|
110
111
|
throw new Error(
|
|
111
112
|
`Incompatible oracle version. TXE is using version '${ORACLE_VERSION}', but got a request for '${version}'.`,
|
|
@@ -115,46 +116,28 @@ export class TXEOracleTopLevelContext extends TXETypedOracle {
|
|
|
115
116
|
|
|
116
117
|
// This is typically only invoked in private contexts, but it is convenient to also have it in top-level for testing
|
|
117
118
|
// setup.
|
|
118
|
-
|
|
119
|
+
utilityGetRandomField(): Fr {
|
|
119
120
|
return Fr.random();
|
|
120
121
|
}
|
|
121
122
|
|
|
122
123
|
// We instruct users to debug contracts via this oracle, so it makes sense that they'd expect it to also work in tests
|
|
123
|
-
|
|
124
|
+
utilityDebugLog(message: string, fields: Fr[]): void {
|
|
124
125
|
this.logger.verbose(`${applyStringFormatting(message, fields)}`, { module: `${this.logger.module}:debug_log` });
|
|
125
126
|
}
|
|
126
127
|
|
|
127
|
-
|
|
128
|
-
override utilityGetUtilityContext(): Promise<UtilityContext> {
|
|
129
|
-
// The zero values for block number, timestamp and contract address are unfortunate sideeffect of use replacing
|
|
130
|
-
// the utilityGetContractAddress, utilityGetBlockNumber, utilityGetTimestamp, utilityGetChainId and
|
|
131
|
-
// utilityGetVersion oracles with utilityGetUtilityContext. Having those values populated does not make sense here
|
|
132
|
-
// as they have no meaning in top level context. OTOH version and chain id also don't really make sense here so
|
|
133
|
-
// think it's fine to learn to live with this tech debt for now.
|
|
134
|
-
return Promise.resolve(
|
|
135
|
-
UtilityContext.from({
|
|
136
|
-
blockNumber: 0,
|
|
137
|
-
timestamp: 0n,
|
|
138
|
-
contractAddress: AztecAddress.zero(),
|
|
139
|
-
version: this.version,
|
|
140
|
-
chainId: this.chainId,
|
|
141
|
-
}),
|
|
142
|
-
);
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
override async txeGetNextBlockNumber(): Promise<number> {
|
|
128
|
+
async txeGetNextBlockNumber(): Promise<number> {
|
|
146
129
|
return (await this.getLastBlockNumber()) + 1;
|
|
147
130
|
}
|
|
148
131
|
|
|
149
|
-
|
|
132
|
+
txeGetNextBlockTimestamp(): Promise<bigint> {
|
|
150
133
|
return Promise.resolve(this.nextBlockTimestamp);
|
|
151
134
|
}
|
|
152
135
|
|
|
153
|
-
|
|
136
|
+
async txeGetLastBlockTimestamp() {
|
|
154
137
|
return (await this.stateMachine.node.getBlockHeader('latest'))!.globalVariables.timestamp;
|
|
155
138
|
}
|
|
156
139
|
|
|
157
|
-
|
|
140
|
+
async txeGetLastTxEffects() {
|
|
158
141
|
const block = await this.stateMachine.archiver.getBlock('latest');
|
|
159
142
|
|
|
160
143
|
if (block!.body.txEffects.length != 1) {
|
|
@@ -167,7 +150,7 @@ export class TXEOracleTopLevelContext extends TXETypedOracle {
|
|
|
167
150
|
return { txHash: txEffects.txHash, noteHashes: txEffects.noteHashes, nullifiers: txEffects.nullifiers };
|
|
168
151
|
}
|
|
169
152
|
|
|
170
|
-
|
|
153
|
+
async txeAdvanceBlocksBy(blocks: number) {
|
|
171
154
|
this.logger.debug(`time traveling ${blocks} blocks`);
|
|
172
155
|
|
|
173
156
|
for (let i = 0; i < blocks; i++) {
|
|
@@ -175,12 +158,12 @@ export class TXEOracleTopLevelContext extends TXETypedOracle {
|
|
|
175
158
|
}
|
|
176
159
|
}
|
|
177
160
|
|
|
178
|
-
|
|
161
|
+
txeAdvanceTimestampBy(duration: UInt64) {
|
|
179
162
|
this.logger.debug(`time traveling ${duration} seconds`);
|
|
180
163
|
this.nextBlockTimestamp += duration;
|
|
181
164
|
}
|
|
182
165
|
|
|
183
|
-
|
|
166
|
+
async txeDeploy(artifact: ContractArtifact, instance: ContractInstanceWithAddress, secret: Fr) {
|
|
184
167
|
// Emit deployment nullifier
|
|
185
168
|
await this.mineBlock({
|
|
186
169
|
nullifiers: [
|
|
@@ -200,7 +183,7 @@ export class TXEOracleTopLevelContext extends TXETypedOracle {
|
|
|
200
183
|
}
|
|
201
184
|
}
|
|
202
185
|
|
|
203
|
-
|
|
186
|
+
async txeAddAccount(artifact: ContractArtifact, instance: ContractInstanceWithAddress, secret: Fr) {
|
|
204
187
|
const partialAddress = await computePartialAddress(instance);
|
|
205
188
|
|
|
206
189
|
this.logger.debug(`Deployed ${artifact.name} at ${instance.address}`);
|
|
@@ -215,7 +198,7 @@ export class TXEOracleTopLevelContext extends TXETypedOracle {
|
|
|
215
198
|
return completeAddress;
|
|
216
199
|
}
|
|
217
200
|
|
|
218
|
-
|
|
201
|
+
async txeCreateAccount(secret: Fr) {
|
|
219
202
|
// This is a footgun !
|
|
220
203
|
const completeAddress = await this.keyStore.addAccount(secret, secret);
|
|
221
204
|
await this.accountDataProvider.setAccount(completeAddress.address, completeAddress);
|
|
@@ -225,7 +208,7 @@ export class TXEOracleTopLevelContext extends TXETypedOracle {
|
|
|
225
208
|
return completeAddress;
|
|
226
209
|
}
|
|
227
210
|
|
|
228
|
-
|
|
211
|
+
async txeAddAuthWitness(address: AztecAddress, messageHash: Fr) {
|
|
229
212
|
const account = await this.accountDataProvider.getAccount(address);
|
|
230
213
|
const privateKey = await this.keyStore.getMasterSecretKey(account.publicKeys.masterIncomingViewingPublicKey);
|
|
231
214
|
|
|
@@ -268,7 +251,7 @@ export class TXEOracleTopLevelContext extends TXETypedOracle {
|
|
|
268
251
|
await this.stateMachine.handleL2Block(block);
|
|
269
252
|
}
|
|
270
253
|
|
|
271
|
-
|
|
254
|
+
async txePrivateCallNewFlow(
|
|
272
255
|
from: AztecAddress,
|
|
273
256
|
targetContractAddress: AztecAddress = AztecAddress.zero(),
|
|
274
257
|
functionSelector: FunctionSelector = FunctionSelector.empty(),
|
|
@@ -320,7 +303,6 @@ export class TXEOracleTopLevelContext extends TXETypedOracle {
|
|
|
320
303
|
HashedValuesCache.create([new HashedValues(args, argsHash)]),
|
|
321
304
|
noteCache,
|
|
322
305
|
this.pxeOracleInterface,
|
|
323
|
-
simulator,
|
|
324
306
|
0,
|
|
325
307
|
1,
|
|
326
308
|
undefined, // log
|
|
@@ -330,6 +312,7 @@ export class TXEOracleTopLevelContext extends TXETypedOracle {
|
|
|
330
312
|
* contract would perform, including setting senderForTags.
|
|
331
313
|
*/
|
|
332
314
|
from,
|
|
315
|
+
simulator,
|
|
333
316
|
);
|
|
334
317
|
|
|
335
318
|
// 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.
|
|
@@ -456,7 +439,7 @@ export class TXEOracleTopLevelContext extends TXETypedOracle {
|
|
|
456
439
|
return executionResult.returnValues ?? [];
|
|
457
440
|
}
|
|
458
441
|
|
|
459
|
-
|
|
442
|
+
async txePublicCallNewFlow(
|
|
460
443
|
from: AztecAddress,
|
|
461
444
|
targetContractAddress: AztecAddress,
|
|
462
445
|
calldata: Fr[],
|
|
@@ -600,7 +583,7 @@ export class TXEOracleTopLevelContext extends TXETypedOracle {
|
|
|
600
583
|
return returnValues ?? [];
|
|
601
584
|
}
|
|
602
585
|
|
|
603
|
-
|
|
586
|
+
async txeSimulateUtilityFunction(
|
|
604
587
|
targetContractAddress: AztecAddress,
|
|
605
588
|
functionSelector: FunctionSelector,
|
|
606
589
|
args: Fr[],
|
|
@@ -650,9 +633,9 @@ export class TXEOracleTopLevelContext extends TXETypedOracle {
|
|
|
650
633
|
}
|
|
651
634
|
}
|
|
652
635
|
|
|
653
|
-
close(): bigint {
|
|
636
|
+
close(): [bigint, Map<string, AuthWitness>] {
|
|
654
637
|
this.logger.debug('Exiting Top Level Context');
|
|
655
|
-
return this.nextBlockTimestamp;
|
|
638
|
+
return [this.nextBlockTimestamp, this.authwits];
|
|
656
639
|
}
|
|
657
640
|
|
|
658
641
|
private async getLastBlockNumber(): Promise<number> {
|