@aztec/txe 0.0.1-commit.fce3e4f → 0.0.1-commit.ff7989d6c

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 (78) hide show
  1. package/dest/constants.d.ts +3 -0
  2. package/dest/constants.d.ts.map +1 -0
  3. package/dest/constants.js +2 -0
  4. package/dest/index.d.ts +1 -1
  5. package/dest/index.d.ts.map +1 -1
  6. package/dest/index.js +85 -52
  7. package/dest/oracle/interfaces.d.ts +12 -9
  8. package/dest/oracle/interfaces.d.ts.map +1 -1
  9. package/dest/oracle/txe_oracle_public_context.d.ts +7 -7
  10. package/dest/oracle/txe_oracle_public_context.d.ts.map +1 -1
  11. package/dest/oracle/txe_oracle_public_context.js +10 -12
  12. package/dest/oracle/txe_oracle_top_level_context.d.ts +23 -14
  13. package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
  14. package/dest/oracle/txe_oracle_top_level_context.js +177 -79
  15. package/dest/rpc_translator.d.ts +30 -18
  16. package/dest/rpc_translator.d.ts.map +1 -1
  17. package/dest/rpc_translator.js +127 -60
  18. package/dest/state_machine/archiver.d.ts +21 -52
  19. package/dest/state_machine/archiver.d.ts.map +1 -1
  20. package/dest/state_machine/archiver.js +63 -94
  21. package/dest/state_machine/dummy_p2p_client.d.ts +19 -14
  22. package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
  23. package/dest/state_machine/dummy_p2p_client.js +41 -24
  24. package/dest/state_machine/global_variable_builder.d.ts +6 -5
  25. package/dest/state_machine/global_variable_builder.d.ts.map +1 -1
  26. package/dest/state_machine/global_variable_builder.js +13 -1
  27. package/dest/state_machine/index.d.ts +7 -7
  28. package/dest/state_machine/index.d.ts.map +1 -1
  29. package/dest/state_machine/index.js +40 -23
  30. package/dest/state_machine/mock_epoch_cache.d.ts +9 -6
  31. package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -1
  32. package/dest/state_machine/mock_epoch_cache.js +14 -7
  33. package/dest/state_machine/synchronizer.d.ts +3 -2
  34. package/dest/state_machine/synchronizer.d.ts.map +1 -1
  35. package/dest/state_machine/synchronizer.js +5 -4
  36. package/dest/txe_session.d.ts +21 -15
  37. package/dest/txe_session.d.ts.map +1 -1
  38. package/dest/txe_session.js +151 -52
  39. package/dest/util/encoding.d.ts +618 -19
  40. package/dest/util/encoding.d.ts.map +1 -1
  41. package/dest/util/encoding.js +1 -1
  42. package/dest/util/txe_account_store.d.ts +10 -0
  43. package/dest/util/txe_account_store.d.ts.map +1 -0
  44. package/dest/util/{txe_account_data_provider.js → txe_account_store.js} +1 -1
  45. package/dest/util/txe_public_contract_data_source.d.ts +8 -8
  46. package/dest/util/txe_public_contract_data_source.d.ts.map +1 -1
  47. package/dest/util/txe_public_contract_data_source.js +12 -29
  48. package/dest/utils/block_creation.d.ts +21 -6
  49. package/dest/utils/block_creation.d.ts.map +1 -1
  50. package/dest/utils/block_creation.js +38 -4
  51. package/dest/utils/tx_effect_creation.d.ts +3 -3
  52. package/dest/utils/tx_effect_creation.d.ts.map +1 -1
  53. package/dest/utils/tx_effect_creation.js +4 -7
  54. package/package.json +18 -18
  55. package/src/constants.ts +3 -0
  56. package/src/index.ts +97 -60
  57. package/src/oracle/interfaces.ts +11 -8
  58. package/src/oracle/txe_oracle_public_context.ts +12 -19
  59. package/src/oracle/txe_oracle_top_level_context.ts +213 -124
  60. package/src/rpc_translator.ts +156 -60
  61. package/src/state_machine/archiver.ts +59 -114
  62. package/src/state_machine/dummy_p2p_client.ts +57 -32
  63. package/src/state_machine/global_variable_builder.ts +21 -4
  64. package/src/state_machine/index.ts +60 -21
  65. package/src/state_machine/mock_epoch_cache.ts +15 -11
  66. package/src/state_machine/synchronizer.ts +6 -5
  67. package/src/txe_session.ts +207 -100
  68. package/src/util/encoding.ts +1 -1
  69. package/src/util/{txe_account_data_provider.ts → txe_account_store.ts} +1 -1
  70. package/src/util/txe_public_contract_data_source.ts +20 -45
  71. package/src/utils/block_creation.ts +49 -15
  72. package/src/utils/tx_effect_creation.ts +5 -12
  73. package/dest/util/txe_account_data_provider.d.ts +0 -10
  74. package/dest/util/txe_account_data_provider.d.ts.map +0 -1
  75. package/dest/util/txe_contract_data_provider.d.ts +0 -12
  76. package/dest/util/txe_contract_data_provider.d.ts.map +0 -1
  77. package/dest/util/txe_contract_data_provider.js +0 -22
  78. package/src/util/txe_contract_data_provider.ts +0 -36
@@ -2,10 +2,11 @@ import type { ContractArtifact } from '@aztec/aztec.js/abi';
2
2
  import { CompleteAddress } from '@aztec/aztec.js/addresses';
3
3
  import type { ContractInstanceWithAddress } from '@aztec/aztec.js/contracts';
4
4
  import { TxHash } from '@aztec/aztec.js/tx';
5
- import type { Fr } from '@aztec/foundation/fields';
6
- import type { FunctionSelector } from '@aztec/stdlib/abi';
5
+ import { BlockNumber } from '@aztec/foundation/branded-types';
6
+ import type { Fr } from '@aztec/foundation/curves/bn254';
7
+ import type { EventSelector, FunctionSelector } from '@aztec/stdlib/abi';
7
8
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
8
- import type { UInt32, UInt64 } from '@aztec/stdlib/types';
9
+ import type { UInt64 } from '@aztec/stdlib/types';
9
10
 
10
11
  // These interfaces complement the ones defined in PXE, and combined with those contain the full list of oracles used by
11
12
  // aztec-nr. In particular, these include the ones needed to run Brillig code associated to #[external("public")] functions that has
@@ -25,16 +26,16 @@ export interface IAvmExecutionOracle {
25
26
 
26
27
  avmOpcodeAddress(): Promise<AztecAddress>;
27
28
  avmOpcodeSender(): Promise<AztecAddress>;
28
- avmOpcodeBlockNumber(): Promise<UInt32>;
29
+ avmOpcodeBlockNumber(): Promise<BlockNumber>;
29
30
  avmOpcodeTimestamp(): Promise<bigint>;
30
31
  avmOpcodeIsStaticCall(): Promise<boolean>;
31
32
  avmOpcodeChainId(): Promise<Fr>;
32
33
  avmOpcodeVersion(): Promise<Fr>;
33
34
  avmOpcodeEmitNullifier(nullifier: Fr): Promise<void>;
34
35
  avmOpcodeEmitNoteHash(noteHash: Fr): Promise<void>;
35
- avmOpcodeNullifierExists(innerNullifier: Fr, targetAddress: AztecAddress): Promise<boolean>;
36
+ avmOpcodeNullifierExists(siloedNullifier: Fr): Promise<boolean>;
36
37
  avmOpcodeStorageWrite(slot: Fr, value: Fr): Promise<void>;
37
- avmOpcodeStorageRead(slot: Fr): Promise<Fr>;
38
+ avmOpcodeStorageRead(slot: Fr, contractAddress: AztecAddress): Promise<Fr>;
38
39
  }
39
40
 
40
41
  /**
@@ -43,7 +44,8 @@ export interface IAvmExecutionOracle {
43
44
  export interface ITxeExecutionOracle {
44
45
  isTxe: true;
45
46
 
46
- txeGetNextBlockNumber(): Promise<number>;
47
+ txeGetDefaultAddress(): AztecAddress;
48
+ txeGetNextBlockNumber(): Promise<BlockNumber>;
47
49
  txeGetNextBlockTimestamp(): Promise<UInt64>;
48
50
  txeAdvanceBlocksBy(blocks: number): Promise<void>;
49
51
  txeAdvanceTimestampBy(duration: UInt64): void;
@@ -61,6 +63,7 @@ export interface ITxeExecutionOracle {
61
63
  noteHashes: Fr[];
62
64
  nullifiers: Fr[];
63
65
  }>;
66
+ txeGetPrivateEvents(selector: EventSelector, contractAddress: AztecAddress, scope: AztecAddress): Promise<Fr[][]>;
64
67
  txePrivateCallNewFlow(
65
68
  from: AztecAddress,
66
69
  targetContractAddress: AztecAddress,
@@ -69,7 +72,7 @@ export interface ITxeExecutionOracle {
69
72
  argsHash: Fr,
70
73
  isStaticCall: boolean,
71
74
  ): Promise<Fr[]>;
72
- txeSimulateUtilityFunction(
75
+ txeExecuteUtilityFunction(
73
76
  targetContractAddress: AztecAddress,
74
77
  functionSelector: FunctionSelector,
75
78
  args: Fr[],
@@ -1,10 +1,10 @@
1
- import { Fr } from '@aztec/foundation/fields';
1
+ import { BlockNumber } from '@aztec/foundation/branded-types';
2
+ import { Fr } from '@aztec/foundation/curves/bn254';
2
3
  import { type Logger, createLogger } from '@aztec/foundation/log';
3
4
  import { PublicDataWrite } from '@aztec/stdlib/avm';
4
5
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
5
- import { Body, L2Block } from '@aztec/stdlib/block';
6
+ import type { L2Block } from '@aztec/stdlib/block';
6
7
  import { computePublicDataTreeLeafSlot, siloNoteHash, siloNullifier } from '@aztec/stdlib/hash';
7
- import { makeAppendOnlyTreeSnapshot } from '@aztec/stdlib/testing';
8
8
  import {
9
9
  MerkleTreeId,
10
10
  type MerkleTreeWriteOperations,
@@ -12,9 +12,8 @@ import {
12
12
  PublicDataTreeLeafPreimage,
13
13
  } from '@aztec/stdlib/trees';
14
14
  import { GlobalVariables, TxEffect, TxHash } from '@aztec/stdlib/tx';
15
- import type { UInt32 } from '@aztec/stdlib/types';
16
15
 
17
- import { insertTxEffectIntoWorldTrees, makeTXEBlockHeader } from '../utils/block_creation.js';
16
+ import { insertTxEffectIntoWorldTrees, makeTXEBlock } from '../utils/block_creation.js';
18
17
  import type { IAvmExecutionOracle } from './interfaces.js';
19
18
 
20
19
  export class TXEOraclePublicContext implements IAvmExecutionOracle {
@@ -48,7 +47,7 @@ export class TXEOraclePublicContext implements IAvmExecutionOracle {
48
47
  return Promise.resolve(AztecAddress.ZERO); // todo: change?
49
48
  }
50
49
 
51
- avmOpcodeBlockNumber(): Promise<UInt32> {
50
+ avmOpcodeBlockNumber(): Promise<BlockNumber> {
52
51
  return Promise.resolve(this.globalVariables.blockNumber);
53
52
  }
54
53
 
@@ -79,13 +78,11 @@ export class TXEOraclePublicContext implements IAvmExecutionOracle {
79
78
  this.transientUniqueNoteHashes.push(siloedNoteHash);
80
79
  }
81
80
 
82
- async avmOpcodeNullifierExists(innerNullifier: Fr, targetAddress: AztecAddress): Promise<boolean> {
83
- const nullifier = await siloNullifier(targetAddress, innerNullifier!);
84
-
81
+ async avmOpcodeNullifierExists(siloedNullifier: Fr): Promise<boolean> {
85
82
  const treeIndex = (
86
- await this.forkedWorldTrees.findLeafIndices(MerkleTreeId.NULLIFIER_TREE, [nullifier.toBuffer()])
83
+ await this.forkedWorldTrees.findLeafIndices(MerkleTreeId.NULLIFIER_TREE, [siloedNullifier.toBuffer()])
87
84
  )[0];
88
- const transientIndex = this.transientSiloedNullifiers.find(n => n.equals(nullifier));
85
+ const transientIndex = this.transientSiloedNullifiers.find(n => n.equals(siloedNullifier));
89
86
 
90
87
  return treeIndex !== undefined || transientIndex !== undefined;
91
88
  }
@@ -102,8 +99,8 @@ export class TXEOraclePublicContext implements IAvmExecutionOracle {
102
99
  ]);
103
100
  }
104
101
 
105
- async avmOpcodeStorageRead(slot: Fr): Promise<Fr> {
106
- const leafSlot = await computePublicDataTreeLeafSlot(this.contractAddress, slot);
102
+ async avmOpcodeStorageRead(slot: Fr, contractAddress: AztecAddress): Promise<Fr> {
103
+ const leafSlot = await computePublicDataTreeLeafSlot(contractAddress, slot);
107
104
 
108
105
  const lowLeafResult = await this.forkedWorldTrees.getPreviousValueIndex(
109
106
  MerkleTreeId.PUBLIC_DATA_TREE,
@@ -120,7 +117,7 @@ export class TXEOraclePublicContext implements IAvmExecutionOracle {
120
117
  )) as PublicDataTreeLeafPreimage
121
118
  ).leaf.value;
122
119
 
123
- this.logger.debug('AVM storage read', { slot, value });
120
+ this.logger.debug('AVM storage read', { slot, contractAddress, value });
124
121
 
125
122
  return value;
126
123
  }
@@ -133,11 +130,7 @@ export class TXEOraclePublicContext implements IAvmExecutionOracle {
133
130
  const txEffect = this.makeTxEffect();
134
131
  await insertTxEffectIntoWorldTrees(txEffect, this.forkedWorldTrees);
135
132
 
136
- const block = new L2Block(
137
- makeAppendOnlyTreeSnapshot(),
138
- await makeTXEBlockHeader(this.forkedWorldTrees, this.globalVariables),
139
- new Body([txEffect]),
140
- );
133
+ const block = await makeTXEBlock(this.forkedWorldTrees, this.globalVariables, [txEffect]);
141
134
 
142
135
  await this.forkedWorldTrees.close();
143
136