@aztec/txe 0.0.1-commit.5de5ca79e → 0.0.1-commit.6201a7b05
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 +5 -2
- package/dest/oracle/interfaces.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_top_level_context.d.ts +13 -6
- package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_top_level_context.js +45 -22
- package/dest/rpc_translator.d.ts +62 -21
- package/dest/rpc_translator.d.ts.map +1 -1
- package/dest/rpc_translator.js +238 -60
- package/dest/state_machine/archiver.d.ts +1 -1
- package/dest/state_machine/archiver.d.ts.map +1 -1
- package/dest/state_machine/archiver.js +2 -1
- package/dest/state_machine/dummy_p2p_client.d.ts +3 -2
- package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
- package/dest/state_machine/dummy_p2p_client.js +5 -2
- package/dest/state_machine/global_variable_builder.d.ts +9 -4
- package/dest/state_machine/global_variable_builder.d.ts.map +1 -1
- package/dest/state_machine/global_variable_builder.js +9 -3
- package/dest/state_machine/index.d.ts +1 -1
- package/dest/state_machine/index.d.ts.map +1 -1
- package/dest/state_machine/index.js +2 -2
- package/dest/state_machine/mock_epoch_cache.d.ts +2 -1
- package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -1
- package/dest/state_machine/mock_epoch_cache.js +3 -0
- package/dest/txe_session.d.ts +48 -4
- package/dest/txe_session.d.ts.map +1 -1
- package/dest/txe_session.js +76 -20
- package/dest/util/encoding.d.ts +3 -1
- package/dest/util/encoding.d.ts.map +1 -1
- package/dest/util/encoding.js +4 -0
- package/dest/util/txe_public_contract_data_source.d.ts +1 -1
- package/dest/util/txe_public_contract_data_source.d.ts.map +1 -1
- package/dest/util/txe_public_contract_data_source.js +1 -3
- package/package.json +15 -15
- package/src/oracle/interfaces.ts +1 -1
- package/src/oracle/txe_oracle_top_level_context.ts +48 -26
- package/src/rpc_translator.ts +279 -68
- package/src/state_machine/archiver.ts +1 -0
- package/src/state_machine/dummy_p2p_client.ts +6 -2
- package/src/state_machine/global_variable_builder.ts +18 -3
- package/src/state_machine/index.ts +4 -1
- package/src/state_machine/mock_epoch_cache.ts +4 -0
- package/src/txe_session.ts +134 -20
- package/src/util/encoding.ts +5 -0
- package/src/util/txe_public_contract_data_source.ts +0 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/txe",
|
|
3
|
-
"version": "0.0.1-commit.
|
|
3
|
+
"version": "0.0.1-commit.6201a7b05",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": "./dest/index.js",
|
|
6
6
|
"bin": "./dest/bin/index.js",
|
|
@@ -61,20 +61,20 @@
|
|
|
61
61
|
]
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
|
-
"@aztec/accounts": "0.0.1-commit.
|
|
65
|
-
"@aztec/archiver": "0.0.1-commit.
|
|
66
|
-
"@aztec/aztec-node": "0.0.1-commit.
|
|
67
|
-
"@aztec/aztec.js": "0.0.1-commit.
|
|
68
|
-
"@aztec/bb-prover": "0.0.1-commit.
|
|
69
|
-
"@aztec/constants": "0.0.1-commit.
|
|
70
|
-
"@aztec/foundation": "0.0.1-commit.
|
|
71
|
-
"@aztec/key-store": "0.0.1-commit.
|
|
72
|
-
"@aztec/kv-store": "0.0.1-commit.
|
|
73
|
-
"@aztec/protocol-contracts": "0.0.1-commit.
|
|
74
|
-
"@aztec/pxe": "0.0.1-commit.
|
|
75
|
-
"@aztec/simulator": "0.0.1-commit.
|
|
76
|
-
"@aztec/stdlib": "0.0.1-commit.
|
|
77
|
-
"@aztec/world-state": "0.0.1-commit.
|
|
64
|
+
"@aztec/accounts": "0.0.1-commit.6201a7b05",
|
|
65
|
+
"@aztec/archiver": "0.0.1-commit.6201a7b05",
|
|
66
|
+
"@aztec/aztec-node": "0.0.1-commit.6201a7b05",
|
|
67
|
+
"@aztec/aztec.js": "0.0.1-commit.6201a7b05",
|
|
68
|
+
"@aztec/bb-prover": "0.0.1-commit.6201a7b05",
|
|
69
|
+
"@aztec/constants": "0.0.1-commit.6201a7b05",
|
|
70
|
+
"@aztec/foundation": "0.0.1-commit.6201a7b05",
|
|
71
|
+
"@aztec/key-store": "0.0.1-commit.6201a7b05",
|
|
72
|
+
"@aztec/kv-store": "0.0.1-commit.6201a7b05",
|
|
73
|
+
"@aztec/protocol-contracts": "0.0.1-commit.6201a7b05",
|
|
74
|
+
"@aztec/pxe": "0.0.1-commit.6201a7b05",
|
|
75
|
+
"@aztec/simulator": "0.0.1-commit.6201a7b05",
|
|
76
|
+
"@aztec/stdlib": "0.0.1-commit.6201a7b05",
|
|
77
|
+
"@aztec/world-state": "0.0.1-commit.6201a7b05",
|
|
78
78
|
"zod": "^3.23.8"
|
|
79
79
|
},
|
|
80
80
|
"devDependencies": {
|
package/src/oracle/interfaces.ts
CHANGED
|
@@ -68,7 +68,7 @@ export interface ITxeExecutionOracle {
|
|
|
68
68
|
argsHash: Fr,
|
|
69
69
|
isStaticCall: boolean,
|
|
70
70
|
jobId: string,
|
|
71
|
-
): Promise<Fr[]>;
|
|
71
|
+
): Promise<{ returnValues: Fr[]; offchainEffects: Fr[][] }>;
|
|
72
72
|
executeUtilityFunction(
|
|
73
73
|
targetContractAddress: AztecAddress,
|
|
74
74
|
functionSelector: FunctionSelector,
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS,
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
DEFAULT_TEARDOWN_DA_GAS_LIMIT,
|
|
6
|
-
DEFAULT_TEARDOWN_L2_GAS_LIMIT,
|
|
3
|
+
MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT,
|
|
4
|
+
MAX_PROCESSABLE_L2_GAS,
|
|
7
5
|
NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP,
|
|
8
6
|
} from '@aztec/constants';
|
|
9
7
|
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
@@ -12,14 +10,13 @@ import { Fr } from '@aztec/foundation/curves/bn254';
|
|
|
12
10
|
import { LogLevels, type Logger, applyStringFormatting, createLogger } from '@aztec/foundation/log';
|
|
13
11
|
import { TestDateProvider } from '@aztec/foundation/timer';
|
|
14
12
|
import type { KeyStore } from '@aztec/key-store';
|
|
15
|
-
import type { AccessScopes } from '@aztec/pxe/client/lazy';
|
|
16
13
|
import {
|
|
17
14
|
AddressStore,
|
|
15
|
+
CapsuleService,
|
|
18
16
|
CapsuleStore,
|
|
19
17
|
type ContractStore,
|
|
20
|
-
type ContractSyncService,
|
|
21
18
|
NoteStore,
|
|
22
|
-
|
|
19
|
+
ORACLE_VERSION_MAJOR,
|
|
23
20
|
PrivateEventStore,
|
|
24
21
|
RecipientTaggingStore,
|
|
25
22
|
SenderAddressBookStore,
|
|
@@ -57,7 +54,13 @@ import { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
|
57
54
|
import { PublicSimulatorConfig } from '@aztec/stdlib/avm';
|
|
58
55
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
59
56
|
import { type ContractInstanceWithAddress, computePartialAddress } from '@aztec/stdlib/contract';
|
|
60
|
-
import {
|
|
57
|
+
import {
|
|
58
|
+
FALLBACK_TEARDOWN_DA_GAS_LIMIT,
|
|
59
|
+
FALLBACK_TEARDOWN_L2_GAS_LIMIT,
|
|
60
|
+
Gas,
|
|
61
|
+
GasFees,
|
|
62
|
+
GasSettings,
|
|
63
|
+
} from '@aztec/stdlib/gas';
|
|
61
64
|
import { computeCalldataHash, computeProtocolNullifier, siloNullifier } from '@aztec/stdlib/hash';
|
|
62
65
|
import {
|
|
63
66
|
PartialPrivateTailPublicInputsForPublic,
|
|
@@ -112,18 +115,29 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
112
115
|
private version: Fr,
|
|
113
116
|
private chainId: Fr,
|
|
114
117
|
private authwits: Map<string, AuthWitness>,
|
|
115
|
-
private readonly contractSyncService: ContractSyncService,
|
|
116
118
|
) {
|
|
117
119
|
this.logger = createLogger('txe:top_level_context');
|
|
118
120
|
this.logger.debug('Entering Top Level Context');
|
|
119
121
|
}
|
|
120
122
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
+
private contractOracleVersion: { major: number; minor: number } | undefined;
|
|
124
|
+
|
|
125
|
+
assertCompatibleOracleVersion(major: number, minor: number): void {
|
|
126
|
+
if (major !== ORACLE_VERSION_MAJOR) {
|
|
127
|
+
const hint =
|
|
128
|
+
major > ORACLE_VERSION_MAJOR
|
|
129
|
+
? '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.'
|
|
130
|
+
: '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.';
|
|
123
131
|
throw new Error(
|
|
124
|
-
`Incompatible
|
|
132
|
+
`Incompatible aztec cli version: ${hint} See https://docs.aztec.network/errors/8 (expected oracle major version ${ORACLE_VERSION_MAJOR}, got ${major})`,
|
|
125
133
|
);
|
|
126
134
|
}
|
|
135
|
+
this.contractOracleVersion = { major, minor };
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// Prefixed with "nonOracleFunction" as it is not used as an oracle handler.
|
|
139
|
+
nonOracleFunctionGetContractOracleVersion(): { major: number; minor: number } | undefined {
|
|
140
|
+
return this.contractOracleVersion;
|
|
127
141
|
}
|
|
128
142
|
|
|
129
143
|
// This is typically only invoked in private contexts, but it is convenient to also have it in top-level for testing
|
|
@@ -324,7 +338,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
324
338
|
const effectiveScopes = from.isZero() ? [] : [from];
|
|
325
339
|
|
|
326
340
|
// Sync notes before executing private function to discover notes from previous transactions
|
|
327
|
-
const utilityExecutor = async (call: FunctionCall, execScopes:
|
|
341
|
+
const utilityExecutor = async (call: FunctionCall, execScopes: AztecAddress[]) => {
|
|
328
342
|
await this.executeUtilityCall(call, execScopes, jobId);
|
|
329
343
|
};
|
|
330
344
|
|
|
@@ -342,8 +356,8 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
342
356
|
|
|
343
357
|
const callContext = new CallContext(from, targetContractAddress, functionSelector, isStaticCall);
|
|
344
358
|
|
|
345
|
-
const gasLimits = new Gas(
|
|
346
|
-
const teardownGasLimits = new Gas(
|
|
359
|
+
const gasLimits = new Gas(MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT, MAX_PROCESSABLE_L2_GAS);
|
|
360
|
+
const teardownGasLimits = new Gas(FALLBACK_TEARDOWN_DA_GAS_LIMIT, FALLBACK_TEARDOWN_L2_GAS_LIMIT);
|
|
347
361
|
const gasSettings = new GasSettings(gasLimits, teardownGasLimits, GasFees.empty(), GasFees.empty());
|
|
348
362
|
|
|
349
363
|
const txContext = new TxContext(this.chainId, this.version, gasSettings);
|
|
@@ -378,7 +392,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
378
392
|
senderTaggingStore: this.senderTaggingStore,
|
|
379
393
|
recipientTaggingStore: this.recipientTaggingStore,
|
|
380
394
|
senderAddressBookStore: this.senderAddressBookStore,
|
|
381
|
-
|
|
395
|
+
capsuleService: new CapsuleService(this.capsuleStore, effectiveScopes),
|
|
382
396
|
privateEventStore: this.privateEventStore,
|
|
383
397
|
contractSyncService: this.stateMachine.contractSyncService,
|
|
384
398
|
jobId,
|
|
@@ -390,6 +404,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
390
404
|
senderForTags: from,
|
|
391
405
|
simulator,
|
|
392
406
|
messageContextService: this.stateMachine.messageContextService,
|
|
407
|
+
l2TipsStore: this.stateMachine.node,
|
|
393
408
|
});
|
|
394
409
|
|
|
395
410
|
// 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.
|
|
@@ -412,7 +427,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
412
427
|
);
|
|
413
428
|
const publicFunctionsCalldata = await Promise.all(
|
|
414
429
|
publicCallRequests.map(async r => {
|
|
415
|
-
const calldata = await privateExecutionOracle.
|
|
430
|
+
const calldata = await privateExecutionOracle.getHashPreimage(r.calldataHash);
|
|
416
431
|
return new HashedValues(calldata, r.calldataHash);
|
|
417
432
|
}),
|
|
418
433
|
);
|
|
@@ -497,11 +512,17 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
497
512
|
}
|
|
498
513
|
}
|
|
499
514
|
|
|
515
|
+
// Walk the nested private-call tree and collect every offchain effect the transaction emitted.
|
|
516
|
+
// PXE stores these on each `PrivateCallExecutionResult` and they never reach TXE via the
|
|
517
|
+
// `aztec_utl_emitOffchainEffect` foreign-call path (that path only fires at the top-level), so
|
|
518
|
+
// we pull them out here and the RPC wrapper will hand them to `TXESession` for buffering.
|
|
519
|
+
const offchainEffects = collectNested([executionResult], r => r.offchainEffects.map(e => e.data));
|
|
520
|
+
|
|
500
521
|
if (isStaticCall) {
|
|
501
522
|
await checkpoint!.revert();
|
|
502
523
|
|
|
503
524
|
await forkedWorldTrees.close();
|
|
504
|
-
return executionResult.returnValues ?? [];
|
|
525
|
+
return { returnValues: executionResult.returnValues ?? [], offchainEffects };
|
|
505
526
|
}
|
|
506
527
|
|
|
507
528
|
const txEffect = TxEffect.empty();
|
|
@@ -523,7 +544,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
523
544
|
|
|
524
545
|
await forkedWorldTrees.close();
|
|
525
546
|
|
|
526
|
-
return executionResult.returnValues ?? [];
|
|
547
|
+
return { returnValues: executionResult.returnValues ?? [], offchainEffects };
|
|
527
548
|
}
|
|
528
549
|
|
|
529
550
|
async publicCallNewFlow(
|
|
@@ -538,9 +559,9 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
538
559
|
|
|
539
560
|
const blockNumber = await this.getNextBlockNumber();
|
|
540
561
|
|
|
541
|
-
const gasLimits = new Gas(
|
|
562
|
+
const gasLimits = new Gas(MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT, MAX_PROCESSABLE_L2_GAS);
|
|
542
563
|
|
|
543
|
-
const teardownGasLimits = new Gas(
|
|
564
|
+
const teardownGasLimits = new Gas(FALLBACK_TEARDOWN_DA_GAS_LIMIT, FALLBACK_TEARDOWN_L2_GAS_LIMIT);
|
|
544
565
|
|
|
545
566
|
const gasSettings = new GasSettings(gasLimits, teardownGasLimits, GasFees.empty(), GasFees.empty());
|
|
546
567
|
|
|
@@ -702,7 +723,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
702
723
|
},
|
|
703
724
|
blockHeader,
|
|
704
725
|
jobId,
|
|
705
|
-
|
|
726
|
+
await this.keyStore.getAccounts(),
|
|
706
727
|
);
|
|
707
728
|
|
|
708
729
|
const call = FunctionCall.from({
|
|
@@ -716,10 +737,10 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
716
737
|
returnTypes: [],
|
|
717
738
|
});
|
|
718
739
|
|
|
719
|
-
return this.executeUtilityCall(call,
|
|
740
|
+
return this.executeUtilityCall(call, await this.keyStore.getAccounts(), jobId);
|
|
720
741
|
}
|
|
721
742
|
|
|
722
|
-
private async executeUtilityCall(call: FunctionCall, scopes:
|
|
743
|
+
private async executeUtilityCall(call: FunctionCall, scopes: AztecAddress[], jobId: string): Promise<Fr[]> {
|
|
723
744
|
const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(call.to, call.selector);
|
|
724
745
|
if (entryPointArtifact.functionType !== FunctionType.UTILITY) {
|
|
725
746
|
throw new Error(`Cannot run ${entryPointArtifact.functionType} function as utility`);
|
|
@@ -744,10 +765,11 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
744
765
|
aztecNode: this.stateMachine.node,
|
|
745
766
|
recipientTaggingStore: this.recipientTaggingStore,
|
|
746
767
|
senderAddressBookStore: this.senderAddressBookStore,
|
|
747
|
-
|
|
768
|
+
capsuleService: new CapsuleService(this.capsuleStore, scopes),
|
|
748
769
|
privateEventStore: this.privateEventStore,
|
|
749
770
|
messageContextService: this.stateMachine.messageContextService,
|
|
750
|
-
contractSyncService: this.contractSyncService,
|
|
771
|
+
contractSyncService: this.stateMachine.contractSyncService,
|
|
772
|
+
l2TipsStore: this.stateMachine.node,
|
|
751
773
|
jobId,
|
|
752
774
|
scopes,
|
|
753
775
|
});
|