@aztec/txe 0.0.1-commit.10bd49492 → 0.0.1-commit.11bf3dd6e

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.
Files changed (45) hide show
  1. package/dest/oracle/txe_oracle_top_level_context.d.ts +10 -4
  2. package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
  3. package/dest/oracle/txe_oracle_top_level_context.js +32 -17
  4. package/dest/rpc_translator.d.ts +55 -19
  5. package/dest/rpc_translator.d.ts.map +1 -1
  6. package/dest/rpc_translator.js +170 -47
  7. package/dest/state_machine/archiver.d.ts +1 -1
  8. package/dest/state_machine/archiver.d.ts.map +1 -1
  9. package/dest/state_machine/archiver.js +2 -1
  10. package/dest/state_machine/dummy_p2p_client.d.ts +3 -2
  11. package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
  12. package/dest/state_machine/dummy_p2p_client.js +5 -2
  13. package/dest/state_machine/global_variable_builder.d.ts +9 -4
  14. package/dest/state_machine/global_variable_builder.d.ts.map +1 -1
  15. package/dest/state_machine/global_variable_builder.js +9 -3
  16. package/dest/state_machine/index.d.ts +1 -1
  17. package/dest/state_machine/index.d.ts.map +1 -1
  18. package/dest/state_machine/index.js +2 -2
  19. package/dest/state_machine/mock_epoch_cache.d.ts +18 -3
  20. package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -1
  21. package/dest/state_machine/mock_epoch_cache.js +35 -2
  22. package/dest/state_machine/synchronizer.d.ts +5 -5
  23. package/dest/state_machine/synchronizer.d.ts.map +1 -1
  24. package/dest/state_machine/synchronizer.js +3 -3
  25. package/dest/txe_session.d.ts +4 -3
  26. package/dest/txe_session.d.ts.map +1 -1
  27. package/dest/txe_session.js +21 -12
  28. package/dest/util/encoding.d.ts +71 -1
  29. package/dest/util/encoding.d.ts.map +1 -1
  30. package/dest/util/encoding.js +4 -0
  31. package/dest/util/txe_public_contract_data_source.d.ts +1 -1
  32. package/dest/util/txe_public_contract_data_source.d.ts.map +1 -1
  33. package/dest/util/txe_public_contract_data_source.js +1 -3
  34. package/package.json +15 -15
  35. package/src/oracle/txe_oracle_top_level_context.ts +42 -21
  36. package/src/rpc_translator.ts +200 -45
  37. package/src/state_machine/archiver.ts +1 -0
  38. package/src/state_machine/dummy_p2p_client.ts +6 -2
  39. package/src/state_machine/global_variable_builder.ts +18 -3
  40. package/src/state_machine/index.ts +3 -1
  41. package/src/state_machine/mock_epoch_cache.ts +46 -3
  42. package/src/state_machine/synchronizer.ts +4 -4
  43. package/src/txe_session.ts +23 -10
  44. package/src/util/encoding.ts +5 -0
  45. 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.10bd49492",
3
+ "version": "0.0.1-commit.11bf3dd6e",
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.10bd49492",
65
- "@aztec/archiver": "0.0.1-commit.10bd49492",
66
- "@aztec/aztec-node": "0.0.1-commit.10bd49492",
67
- "@aztec/aztec.js": "0.0.1-commit.10bd49492",
68
- "@aztec/bb-prover": "0.0.1-commit.10bd49492",
69
- "@aztec/constants": "0.0.1-commit.10bd49492",
70
- "@aztec/foundation": "0.0.1-commit.10bd49492",
71
- "@aztec/key-store": "0.0.1-commit.10bd49492",
72
- "@aztec/kv-store": "0.0.1-commit.10bd49492",
73
- "@aztec/protocol-contracts": "0.0.1-commit.10bd49492",
74
- "@aztec/pxe": "0.0.1-commit.10bd49492",
75
- "@aztec/simulator": "0.0.1-commit.10bd49492",
76
- "@aztec/stdlib": "0.0.1-commit.10bd49492",
77
- "@aztec/world-state": "0.0.1-commit.10bd49492",
64
+ "@aztec/accounts": "0.0.1-commit.11bf3dd6e",
65
+ "@aztec/archiver": "0.0.1-commit.11bf3dd6e",
66
+ "@aztec/aztec-node": "0.0.1-commit.11bf3dd6e",
67
+ "@aztec/aztec.js": "0.0.1-commit.11bf3dd6e",
68
+ "@aztec/bb-prover": "0.0.1-commit.11bf3dd6e",
69
+ "@aztec/constants": "0.0.1-commit.11bf3dd6e",
70
+ "@aztec/foundation": "0.0.1-commit.11bf3dd6e",
71
+ "@aztec/key-store": "0.0.1-commit.11bf3dd6e",
72
+ "@aztec/kv-store": "0.0.1-commit.11bf3dd6e",
73
+ "@aztec/protocol-contracts": "0.0.1-commit.11bf3dd6e",
74
+ "@aztec/pxe": "0.0.1-commit.11bf3dd6e",
75
+ "@aztec/simulator": "0.0.1-commit.11bf3dd6e",
76
+ "@aztec/stdlib": "0.0.1-commit.11bf3dd6e",
77
+ "@aztec/world-state": "0.0.1-commit.11bf3dd6e",
78
78
  "zod": "^3.23.8"
79
79
  },
80
80
  "devDependencies": {
@@ -1,9 +1,7 @@
1
1
  import {
2
2
  CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS,
3
- DEFAULT_DA_GAS_LIMIT,
4
- DEFAULT_L2_GAS_LIMIT,
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,13 +10,14 @@ 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,
18
+ type ContractSyncService,
20
19
  NoteStore,
21
- ORACLE_VERSION,
20
+ ORACLE_VERSION_MAJOR,
22
21
  PrivateEventStore,
23
22
  RecipientTaggingStore,
24
23
  SenderAddressBookStore,
@@ -56,7 +55,13 @@ import { AuthWitness } from '@aztec/stdlib/auth-witness';
56
55
  import { PublicSimulatorConfig } from '@aztec/stdlib/avm';
57
56
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
58
57
  import { type ContractInstanceWithAddress, computePartialAddress } from '@aztec/stdlib/contract';
59
- import { Gas, GasFees, GasSettings } from '@aztec/stdlib/gas';
58
+ import {
59
+ FALLBACK_TEARDOWN_DA_GAS_LIMIT,
60
+ FALLBACK_TEARDOWN_L2_GAS_LIMIT,
61
+ Gas,
62
+ GasFees,
63
+ GasSettings,
64
+ } from '@aztec/stdlib/gas';
60
65
  import { computeCalldataHash, computeProtocolNullifier, siloNullifier } from '@aztec/stdlib/hash';
61
66
  import {
62
67
  PartialPrivateTailPublicInputsForPublic,
@@ -111,17 +116,30 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
111
116
  private version: Fr,
112
117
  private chainId: Fr,
113
118
  private authwits: Map<string, AuthWitness>,
119
+ private readonly contractSyncService: ContractSyncService,
114
120
  ) {
115
121
  this.logger = createLogger('txe:top_level_context');
116
122
  this.logger.debug('Entering Top Level Context');
117
123
  }
118
124
 
119
- assertCompatibleOracleVersion(version: number): void {
120
- if (version !== ORACLE_VERSION) {
125
+ private contractOracleVersion: { major: number; minor: number } | undefined;
126
+
127
+ assertCompatibleOracleVersion(major: number, minor: number): void {
128
+ if (major !== ORACLE_VERSION_MAJOR) {
129
+ const hint =
130
+ major > ORACLE_VERSION_MAJOR
131
+ ? '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.'
132
+ : '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
133
  throw new Error(
122
- `Incompatible oracle version. TXE is using version '${ORACLE_VERSION}', but got a request for '${version}'.`,
134
+ `Incompatible aztec cli version: ${hint} See https://docs.aztec.network/errors/8 (expected oracle major version ${ORACLE_VERSION_MAJOR}, got ${major})`,
123
135
  );
124
136
  }
137
+ this.contractOracleVersion = { major, minor };
138
+ }
139
+
140
+ // Prefixed with "nonOracleFunction" as it is not used as an oracle handler.
141
+ nonOracleFunctionGetContractOracleVersion(): { major: number; minor: number } | undefined {
142
+ return this.contractOracleVersion;
125
143
  }
126
144
 
127
145
  // This is typically only invoked in private contexts, but it is convenient to also have it in top-level for testing
@@ -322,7 +340,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
322
340
  const effectiveScopes = from.isZero() ? [] : [from];
323
341
 
324
342
  // Sync notes before executing private function to discover notes from previous transactions
325
- const utilityExecutor = async (call: FunctionCall, execScopes: AccessScopes) => {
343
+ const utilityExecutor = async (call: FunctionCall, execScopes: AztecAddress[]) => {
326
344
  await this.executeUtilityCall(call, execScopes, jobId);
327
345
  };
328
346
 
@@ -340,8 +358,8 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
340
358
 
341
359
  const callContext = new CallContext(from, targetContractAddress, functionSelector, isStaticCall);
342
360
 
343
- const gasLimits = new Gas(DEFAULT_DA_GAS_LIMIT, DEFAULT_L2_GAS_LIMIT);
344
- const teardownGasLimits = new Gas(DEFAULT_TEARDOWN_DA_GAS_LIMIT, DEFAULT_TEARDOWN_L2_GAS_LIMIT);
361
+ const gasLimits = new Gas(MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT, MAX_PROCESSABLE_L2_GAS);
362
+ const teardownGasLimits = new Gas(FALLBACK_TEARDOWN_DA_GAS_LIMIT, FALLBACK_TEARDOWN_L2_GAS_LIMIT);
345
363
  const gasSettings = new GasSettings(gasLimits, teardownGasLimits, GasFees.empty(), GasFees.empty());
346
364
 
347
365
  const txContext = new TxContext(this.chainId, this.version, gasSettings);
@@ -376,7 +394,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
376
394
  senderTaggingStore: this.senderTaggingStore,
377
395
  recipientTaggingStore: this.recipientTaggingStore,
378
396
  senderAddressBookStore: this.senderAddressBookStore,
379
- capsuleStore: this.capsuleStore,
397
+ capsuleService: new CapsuleService(this.capsuleStore, effectiveScopes),
380
398
  privateEventStore: this.privateEventStore,
381
399
  contractSyncService: this.stateMachine.contractSyncService,
382
400
  jobId,
@@ -388,6 +406,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
388
406
  senderForTags: from,
389
407
  simulator,
390
408
  messageContextService: this.stateMachine.messageContextService,
409
+ l2TipsStore: this.stateMachine.node,
391
410
  });
392
411
 
393
412
  // 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.
@@ -410,7 +429,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
410
429
  );
411
430
  const publicFunctionsCalldata = await Promise.all(
412
431
  publicCallRequests.map(async r => {
413
- const calldata = await privateExecutionOracle.loadFromExecutionCache(r.calldataHash);
432
+ const calldata = await privateExecutionOracle.getHashPreimage(r.calldataHash);
414
433
  return new HashedValues(calldata, r.calldataHash);
415
434
  }),
416
435
  );
@@ -536,9 +555,9 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
536
555
 
537
556
  const blockNumber = await this.getNextBlockNumber();
538
557
 
539
- const gasLimits = new Gas(DEFAULT_DA_GAS_LIMIT, DEFAULT_L2_GAS_LIMIT);
558
+ const gasLimits = new Gas(MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT, MAX_PROCESSABLE_L2_GAS);
540
559
 
541
- const teardownGasLimits = new Gas(DEFAULT_TEARDOWN_DA_GAS_LIMIT, DEFAULT_TEARDOWN_L2_GAS_LIMIT);
560
+ const teardownGasLimits = new Gas(FALLBACK_TEARDOWN_DA_GAS_LIMIT, FALLBACK_TEARDOWN_L2_GAS_LIMIT);
542
561
 
543
562
  const gasSettings = new GasSettings(gasLimits, teardownGasLimits, GasFees.empty(), GasFees.empty());
544
563
 
@@ -700,7 +719,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
700
719
  },
701
720
  blockHeader,
702
721
  jobId,
703
- 'ALL_SCOPES',
722
+ await this.keyStore.getAccounts(),
704
723
  );
705
724
 
706
725
  const call = FunctionCall.from({
@@ -714,10 +733,10 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
714
733
  returnTypes: [],
715
734
  });
716
735
 
717
- return this.executeUtilityCall(call, 'ALL_SCOPES', jobId);
736
+ return this.executeUtilityCall(call, await this.keyStore.getAccounts(), jobId);
718
737
  }
719
738
 
720
- private async executeUtilityCall(call: FunctionCall, scopes: AccessScopes, jobId: string): Promise<Fr[]> {
739
+ private async executeUtilityCall(call: FunctionCall, scopes: AztecAddress[], jobId: string): Promise<Fr[]> {
721
740
  const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(call.to, call.selector);
722
741
  if (entryPointArtifact.functionType !== FunctionType.UTILITY) {
723
742
  throw new Error(`Cannot run ${entryPointArtifact.functionType} function as utility`);
@@ -742,9 +761,11 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
742
761
  aztecNode: this.stateMachine.node,
743
762
  recipientTaggingStore: this.recipientTaggingStore,
744
763
  senderAddressBookStore: this.senderAddressBookStore,
745
- capsuleStore: this.capsuleStore,
764
+ capsuleService: new CapsuleService(this.capsuleStore, scopes),
746
765
  privateEventStore: this.privateEventStore,
747
766
  messageContextService: this.stateMachine.messageContextService,
767
+ contractSyncService: this.contractSyncService,
768
+ l2TipsStore: this.stateMachine.node,
748
769
  jobId,
749
770
  scopes,
750
771
  });