@aztec/txe 0.0.1-commit.b2a5d0dd1 → 0.0.1-commit.b3d3157a

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 (144) hide show
  1. package/dest/ContractClassRegistry-PII7Q556.js +3 -0
  2. package/dest/ContractClassRegistry-PII7Q556.js.map +7 -0
  3. package/dest/ContractInstanceRegistry-3MHLGFNZ.js +3 -0
  4. package/dest/ContractInstanceRegistry-3MHLGFNZ.js.map +7 -0
  5. package/dest/FeeJuice-TQV5AQK7.js +3 -0
  6. package/dest/FeeJuice-TQV5AQK7.js.map +7 -0
  7. package/dest/MultiCallEntrypoint-SBJUIJY7.js +3 -0
  8. package/dest/MultiCallEntrypoint-SBJUIJY7.js.map +7 -0
  9. package/dest/SchnorrAccount-MQXPIZ44.js +3 -0
  10. package/dest/SchnorrAccount-MQXPIZ44.js.map +7 -0
  11. package/dest/bin/check_txe_oracle_version.d.ts +2 -0
  12. package/dest/bin/check_txe_oracle_version.d.ts.map +1 -0
  13. package/dest/bin/check_txe_oracle_version.js +61 -0
  14. package/dest/bin/index.js +3 -30
  15. package/dest/bin/index.js.map +7 -0
  16. package/dest/bin/oracle_test_server.d.ts +3 -0
  17. package/dest/bin/oracle_test_server.d.ts.map +1 -0
  18. package/dest/bin/oracle_test_server.js +41 -0
  19. package/dest/chunk-2FGZE6YL.js +265 -0
  20. package/dest/chunk-2FGZE6YL.js.map +7 -0
  21. package/dest/chunk-6HRVNWJU.js +304 -0
  22. package/dest/chunk-6HRVNWJU.js.map +7 -0
  23. package/dest/chunk-BJVAAXNA.js +3 -0
  24. package/dest/chunk-BJVAAXNA.js.map +7 -0
  25. package/dest/constants.d.ts +5 -1
  26. package/dest/constants.d.ts.map +1 -1
  27. package/dest/constants.js +8 -0
  28. package/dest/dispatcher_pool.d.ts +67 -0
  29. package/dest/dispatcher_pool.d.ts.map +1 -0
  30. package/dest/dispatcher_pool.js +284 -0
  31. package/dest/index.d.ts +185 -7
  32. package/dest/index.d.ts.map +1 -1
  33. package/dest/index.js +70 -190
  34. package/dest/metafile.json +38642 -0
  35. package/dest/msgpackr_fr_extension.d.ts +2 -0
  36. package/dest/msgpackr_fr_extension.d.ts.map +1 -0
  37. package/dest/msgpackr_fr_extension.js +21 -0
  38. package/dest/oracle/interfaces.d.ts +33 -8
  39. package/dest/oracle/interfaces.d.ts.map +1 -1
  40. package/dest/oracle/test-resolver/fixtures.d.ts +43 -0
  41. package/dest/oracle/test-resolver/fixtures.d.ts.map +1 -0
  42. package/dest/oracle/test-resolver/fixtures.js +39 -0
  43. package/dest/oracle/test-resolver/index.d.ts +9 -0
  44. package/dest/oracle/test-resolver/index.d.ts.map +1 -0
  45. package/dest/oracle/test-resolver/index.js +33 -0
  46. package/dest/oracle/test-resolver/resolver.d.ts +34 -0
  47. package/dest/oracle/test-resolver/resolver.d.ts.map +1 -0
  48. package/dest/oracle/test-resolver/resolver.js +114 -0
  49. package/dest/oracle/txe_oracle_public_context.d.ts +26 -2
  50. package/dest/oracle/txe_oracle_public_context.d.ts.map +1 -1
  51. package/dest/oracle/txe_oracle_public_context.js +43 -1
  52. package/dest/oracle/txe_oracle_registry.d.ts +147 -0
  53. package/dest/oracle/txe_oracle_registry.d.ts.map +1 -0
  54. package/dest/oracle/txe_oracle_registry.js +562 -0
  55. package/dest/oracle/txe_oracle_top_level_context.d.ts +27 -13
  56. package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
  57. package/dest/oracle/txe_oracle_top_level_context.js +129 -52
  58. package/dest/oracle/txe_oracle_version.d.ts +17 -0
  59. package/dest/oracle/txe_oracle_version.d.ts.map +1 -0
  60. package/dest/oracle/txe_oracle_version.js +14 -0
  61. package/dest/oracle/txe_private_execution_oracle.d.ts +17 -0
  62. package/dest/oracle/txe_private_execution_oracle.d.ts.map +1 -0
  63. package/dest/oracle/txe_private_execution_oracle.js +15 -0
  64. package/dest/rpc_server.d.ts +14 -0
  65. package/dest/rpc_server.d.ts.map +1 -0
  66. package/dest/rpc_server.js +78 -0
  67. package/dest/rpc_translator.d.ts +96 -266
  68. package/dest/rpc_translator.d.ts.map +1 -1
  69. package/dest/rpc_translator.js +699 -730
  70. package/dest/server.bundle.js +3 -0
  71. package/dest/server.bundle.js.map +7 -0
  72. package/dest/state_machine/archiver.d.ts +4 -3
  73. package/dest/state_machine/archiver.d.ts.map +1 -1
  74. package/dest/state_machine/archiver.js +24 -14
  75. package/dest/state_machine/dummy_p2p_client.d.ts +11 -6
  76. package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
  77. package/dest/state_machine/dummy_p2p_client.js +11 -2
  78. package/dest/state_machine/index.d.ts +4 -2
  79. package/dest/state_machine/index.d.ts.map +1 -1
  80. package/dest/state_machine/index.js +16 -2
  81. package/dest/state_machine/mock_epoch_cache.d.ts +1 -3
  82. package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -1
  83. package/dest/state_machine/mock_epoch_cache.js +0 -6
  84. package/dest/state_machine/synchronizer.js +1 -1
  85. package/dest/txe_session.d.ts +75 -14
  86. package/dest/txe_session.d.ts.map +1 -1
  87. package/dest/txe_session.js +164 -38
  88. package/dest/utils/encoding.d.ts +191 -0
  89. package/dest/utils/encoding.d.ts.map +1 -0
  90. package/dest/{util → utils}/encoding.js +3 -2
  91. package/dest/{util → utils}/expected_failure_error.d.ts +1 -1
  92. package/dest/utils/expected_failure_error.d.ts.map +1 -0
  93. package/dest/{util → utils}/txe_account_store.d.ts +1 -1
  94. package/dest/utils/txe_account_store.d.ts.map +1 -0
  95. package/dest/utils/txe_artifact_resolver.d.ts +37 -0
  96. package/dest/utils/txe_artifact_resolver.d.ts.map +1 -0
  97. package/dest/utils/txe_artifact_resolver.js +161 -0
  98. package/dest/utils/txe_public_contract_data_source.d.ts +20 -0
  99. package/dest/utils/txe_public_contract_data_source.d.ts.map +1 -0
  100. package/dest/worker.bundle.js +3 -0
  101. package/dest/worker.bundle.js.map +7 -0
  102. package/dest/worker.d.ts +2 -0
  103. package/dest/worker.d.ts.map +1 -0
  104. package/dest/worker.js +92 -0
  105. package/package.json +38 -21
  106. package/src/bin/check_txe_oracle_version.ts +70 -0
  107. package/src/bin/index.ts +11 -2
  108. package/src/bin/oracle_test_server.ts +51 -0
  109. package/src/constants.ts +10 -0
  110. package/src/dispatcher_pool.ts +316 -0
  111. package/src/index.ts +97 -227
  112. package/src/msgpackr_fr_extension.ts +23 -0
  113. package/src/oracle/interfaces.ts +29 -7
  114. package/src/oracle/test-resolver/fixtures.ts +84 -0
  115. package/src/oracle/test-resolver/index.ts +45 -0
  116. package/src/oracle/test-resolver/resolver.ts +165 -0
  117. package/src/oracle/txe_oracle_public_context.ts +60 -0
  118. package/src/oracle/txe_oracle_registry.ts +401 -0
  119. package/src/oracle/txe_oracle_top_level_context.ts +157 -62
  120. package/src/oracle/txe_oracle_version.ts +17 -0
  121. package/src/oracle/txe_private_execution_oracle.ts +30 -0
  122. package/src/rpc_server.ts +87 -0
  123. package/src/rpc_translator.ts +774 -1043
  124. package/src/state_machine/archiver.ts +37 -16
  125. package/src/state_machine/dummy_p2p_client.ts +25 -9
  126. package/src/state_machine/index.ts +17 -4
  127. package/src/state_machine/mock_epoch_cache.ts +0 -8
  128. package/src/state_machine/synchronizer.ts +1 -1
  129. package/src/txe_session.ts +269 -39
  130. package/src/{util → utils}/encoding.ts +3 -2
  131. package/src/utils/txe_artifact_resolver.ts +217 -0
  132. package/src/worker.ts +98 -0
  133. package/dest/util/encoding.d.ts +0 -790
  134. package/dest/util/encoding.d.ts.map +0 -1
  135. package/dest/util/expected_failure_error.d.ts.map +0 -1
  136. package/dest/util/txe_account_store.d.ts.map +0 -1
  137. package/dest/util/txe_public_contract_data_source.d.ts +0 -20
  138. package/dest/util/txe_public_contract_data_source.d.ts.map +0 -1
  139. /package/dest/{util → utils}/expected_failure_error.js +0 -0
  140. /package/dest/{util → utils}/txe_account_store.js +0 -0
  141. /package/dest/{util → utils}/txe_public_contract_data_source.js +0 -0
  142. /package/src/{util → utils}/expected_failure_error.ts +0 -0
  143. /package/src/{util → utils}/txe_account_store.ts +0 -0
  144. /package/src/{util → utils}/txe_public_contract_data_source.ts +0 -0
@@ -1,12 +1,20 @@
1
- import { ArchiverDataSourceBase, ArchiverDataStoreUpdater, KVArchiverDataStore } from '@aztec/archiver';
1
+ import { ArchiverDataSourceBase, ArchiverDataStoreUpdater, createArchiverDataStores } from '@aztec/archiver';
2
2
  import { GENESIS_ARCHIVE_ROOT } from '@aztec/constants';
3
3
  import { CheckpointNumber, type EpochNumber, type SlotNumber } from '@aztec/foundation/branded-types';
4
4
  import { Fr } from '@aztec/foundation/curves/bn254';
5
5
  import type { EthAddress } from '@aztec/foundation/eth-address';
6
6
  import type { AztecAsyncKVStore } from '@aztec/kv-store';
7
- import type { CheckpointId, L2BlockId, L2TipId, L2Tips, ValidateCheckpointResult } from '@aztec/stdlib/block';
7
+ import {
8
+ type CheckpointId,
9
+ GENESIS_BLOCK_HEADER_HASH,
10
+ type L2BlockId,
11
+ type L2TipId,
12
+ type L2Tips,
13
+ type ValidateCheckpointResult,
14
+ } from '@aztec/stdlib/block';
8
15
  import type { PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
9
- import type { L1RollupConstants } from '@aztec/stdlib/epoch-helpers';
16
+ import { EmptyL1RollupConstants, type L1RollupConstants } from '@aztec/stdlib/epoch-helpers';
17
+ import { BlockHeader } from '@aztec/stdlib/tx';
10
18
 
11
19
  /**
12
20
  * TXE Archiver implementation.
@@ -14,11 +22,16 @@ import type { L1RollupConstants } from '@aztec/stdlib/epoch-helpers';
14
22
  * without needing any of the extra overhead that the Archiver itself requires (i.e. an L1 client).
15
23
  */
16
24
  export class TXEArchiver extends ArchiverDataSourceBase {
17
- private readonly updater = new ArchiverDataStoreUpdater(this.store);
25
+ private readonly updater = new ArchiverDataStoreUpdater(this.stores);
18
26
 
19
27
  constructor(db: AztecAsyncKVStore) {
20
- const store = new KVArchiverDataStore(db, 9999);
21
- super(store);
28
+ super(
29
+ createArchiverDataStores(db, GENESIS_BLOCK_HEADER_HASH),
30
+ undefined,
31
+ BlockHeader.empty(),
32
+ GENESIS_BLOCK_HEADER_HASH,
33
+ new Fr(GENESIS_ARCHIVE_ROOT),
34
+ );
22
35
  }
23
36
 
24
37
  public async addCheckpoints(checkpoints: PublishedCheckpoint[], result?: ValidateCheckpointResult): Promise<void> {
@@ -34,7 +47,9 @@ export class TXEArchiver extends ArchiverDataSourceBase {
34
47
  }
35
48
 
36
49
  public getL1Constants(): Promise<L1RollupConstants> {
37
- throw new Error('TXE Archiver does not implement "getL1Constants"');
50
+ // The TXE has no L1, so it serves the empty constants (epochDuration=1) used throughout the TXE state machine
51
+ // (see mock_epoch_cache). The node calls this when assembling a mined tx receipt to derive the epoch number.
52
+ return Promise.resolve(EmptyL1RollupConstants);
38
53
  }
39
54
 
40
55
  public getGenesisValues(): Promise<{ genesisArchiveRoot: Fr }> {
@@ -48,20 +63,21 @@ export class TXEArchiver extends ArchiverDataSourceBase {
48
63
  public async getL2Tips(): Promise<L2Tips> {
49
64
  // In TXE there is no possibility of reorgs and no blocks are ever getting proven so we just set 'latest', 'proven'
50
65
  // and 'finalized' to the latest block.
51
- const blockHeader = await this.getBlockHeader('latest');
52
- if (!blockHeader) {
66
+ const latestBlockNumber = await this.stores.blocks.getLatestL2BlockNumber();
67
+ if (latestBlockNumber === 0) {
68
+ throw new Error('L2Tips requested from TXE Archiver but no block found');
69
+ }
70
+ const latestBlockData = await this.stores.blocks.getBlockData({ number: latestBlockNumber });
71
+ if (!latestBlockData) {
53
72
  throw new Error('L2Tips requested from TXE Archiver but no block header found');
54
73
  }
55
74
 
56
- const number = blockHeader.globalVariables.blockNumber;
57
- const hash = (await blockHeader.hash()).toString();
58
- const checkpointedBlock = await this.getCheckpointedBlock(number);
59
- if (!checkpointedBlock) {
60
- throw new Error(`L2Tips requested from TXE Archiver but no checkpointed block found for block number ${number}`);
61
- }
75
+ const number = latestBlockData.header.globalVariables.blockNumber;
76
+ const hash = latestBlockData.blockHash.toString();
77
+
62
78
  // TXE uses 1-block-per-checkpoint for testing simplicity, so we can use block number as checkpoint number.
63
79
  // This uses the deprecated fromBlockNumber method intentionally for the TXE testing environment.
64
- const checkpoint = await this.store.getRangeOfCheckpoints(CheckpointNumber.fromBlockNumber(number), 1);
80
+ const checkpoint = await this.stores.blocks.getRangeOfCheckpoints(CheckpointNumber.fromBlockNumber(number), 1);
65
81
  if (checkpoint.length === 0) {
66
82
  throw new Error(`L2Tips requested from TXE Archiver but no checkpoint found for block number ${number}`);
67
83
  }
@@ -95,4 +111,9 @@ export class TXEArchiver extends ArchiverDataSourceBase {
95
111
  public syncImmediate(): Promise<void> {
96
112
  throw new Error('TXE Archiver does not implement "syncImmediate"');
97
113
  }
114
+
115
+ public getL2ToL1MembershipWitness(): Promise<undefined> {
116
+ // TXE doesn't drive the L2-to-L1 message flow through this archiver.
117
+ return Promise.resolve(undefined);
118
+ }
98
119
  }
@@ -1,9 +1,10 @@
1
- import type { SlotNumber } from '@aztec/foundation/branded-types';
1
+ import type { CheckpointProposalHash, SlotNumber } from '@aztec/foundation/branded-types';
2
2
  import type {
3
3
  AuthRequest,
4
4
  ENR,
5
5
  P2P,
6
6
  P2PBlockReceivedCallback,
7
+ P2PCheckpointAttestationCallback,
7
8
  P2PCheckpointReceivedCallback,
8
9
  P2PConfig,
9
10
  P2PDuplicateAttestationCallback,
@@ -12,12 +13,17 @@ import type {
12
13
  PeerId,
13
14
  ReqRespSubProtocol,
14
15
  ReqRespSubProtocolHandler,
15
- ReqRespSubProtocolValidators,
16
16
  StatusMessage,
17
17
  } from '@aztec/p2p';
18
18
  import type { EthAddress, L2BlockStreamEvent, L2Tips } from '@aztec/stdlib/block';
19
19
  import type { ITxProvider, PeerInfo } from '@aztec/stdlib/interfaces/server';
20
- import type { BlockProposal, CheckpointAttestation, CheckpointProposal, TopicType } from '@aztec/stdlib/p2p';
20
+ import type {
21
+ BlockProposal,
22
+ CheckpointAttestation,
23
+ CheckpointProposal,
24
+ CheckpointProposalCore,
25
+ TopicType,
26
+ } from '@aztec/stdlib/p2p';
21
27
  import type { BlockHeader, Tx, TxHash } from '@aztec/stdlib/tx';
22
28
 
23
29
  export class DummyP2P implements P2P {
@@ -147,7 +153,10 @@ export class DummyP2P implements P2P {
147
153
  throw new Error('DummyP2P does not implement "getTxsByHash"');
148
154
  }
149
155
 
150
- public getCheckpointAttestationsForSlot(_slot: SlotNumber, _proposalId?: string): Promise<CheckpointAttestation[]> {
156
+ public getCheckpointAttestationsForSlot(
157
+ _slot: SlotNumber,
158
+ _proposalPayloadHash?: CheckpointProposalHash,
159
+ ): Promise<CheckpointAttestation[]> {
151
160
  throw new Error('DummyP2P does not implement "getCheckpointAttestationsForSlot"');
152
161
  }
153
162
 
@@ -155,6 +164,13 @@ export class DummyP2P implements P2P {
155
164
  throw new Error('DummyP2P does not implement "addOwnCheckpointAttestations"');
156
165
  }
157
166
 
167
+ public getProposalsForSlot(_slot: SlotNumber): Promise<{
168
+ blockProposals: BlockProposal[];
169
+ checkpointProposals: CheckpointProposalCore[];
170
+ }> {
171
+ return Promise.resolve({ blockProposals: [], checkpointProposals: [] });
172
+ }
173
+
158
174
  public getL2BlockHash(_number: number): Promise<string | undefined> {
159
175
  throw new Error('DummyP2P does not implement "getL2BlockHash"');
160
176
  }
@@ -203,11 +219,7 @@ export class DummyP2P implements P2P {
203
219
  return Promise.resolve();
204
220
  }
205
221
 
206
- addReqRespSubProtocol(
207
- _subProtocol: ReqRespSubProtocol,
208
- _handler: ReqRespSubProtocolHandler,
209
- _validator?: ReqRespSubProtocolValidators[ReqRespSubProtocol],
210
- ): Promise<void> {
222
+ addReqRespSubProtocol(_subProtocol: ReqRespSubProtocol, _handler: ReqRespSubProtocolHandler): Promise<void> {
211
223
  throw new Error('DummyP2P does not implement "addReqRespSubProtocol".');
212
224
  }
213
225
  handleAuthRequestFromPeer(_authRequest: AuthRequest, _peerId: PeerId): Promise<StatusMessage> {
@@ -225,6 +237,10 @@ export class DummyP2P implements P2P {
225
237
  throw new Error('DummyP2P does not implement "registerDuplicateAttestationCallback"');
226
238
  }
227
239
 
240
+ public registerCheckpointAttestationCallback(_callback: P2PCheckpointAttestationCallback): void {
241
+ throw new Error('DummyP2P does not implement "registerCheckpointAttestationCallback"');
242
+ }
243
+
228
244
  public hasBlockProposalsForSlot(_slot: SlotNumber): Promise<boolean> {
229
245
  throw new Error('DummyP2P does not implement "hasBlockProposalsForSlot"');
230
246
  }
@@ -5,11 +5,10 @@ import { Fr } from '@aztec/foundation/curves/bn254';
5
5
  import { createLogger } from '@aztec/foundation/log';
6
6
  import { type AnchorBlockStore, type ContractStore, ContractSyncService, type NoteStore } from '@aztec/pxe/server';
7
7
  import { MessageContextService } from '@aztec/pxe/simulator';
8
- import { L2Block } from '@aztec/stdlib/block';
8
+ import { L2Block, type L2TipsProvider } from '@aztec/stdlib/block';
9
9
  import { Checkpoint, L1PublishedData, PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
10
10
  import type { AztecNode } from '@aztec/stdlib/interfaces/client';
11
11
  import { CheckpointHeader } from '@aztec/stdlib/rollup';
12
- import { getPackageVersion } from '@aztec/stdlib/update-checker';
13
12
 
14
13
  import { TXEArchiver } from './archiver.js';
15
14
  import { DummyP2P } from './dummy_p2p_client.js';
@@ -19,6 +18,9 @@ import { TXESynchronizer } from './synchronizer.js';
19
18
 
20
19
  const VERSION = 1;
21
20
  const CHAIN_ID = 1;
21
+ // Hardcoded so the bundled TXE doesn't try to read stdlib's package.json at a relative path
22
+ // that becomes invalid once bundled
23
+ const PACKAGE_VERSION = 'txe';
22
24
 
23
25
  export class TXEStateMachine {
24
26
  constructor(
@@ -52,13 +54,13 @@ export class TXEStateMachine {
52
54
  undefined,
53
55
  undefined,
54
56
  undefined,
55
- undefined,
57
+ async () => {},
56
58
  VERSION,
57
59
  CHAIN_ID,
58
60
  new TXEGlobalVariablesBuilder(),
59
61
  new TXEFeeProvider(),
60
62
  new MockEpochCache(),
61
- getPackageVersion() ?? '',
63
+ PACKAGE_VERSION,
62
64
  new TestCircuitVerifier(),
63
65
  new TestCircuitVerifier(),
64
66
  undefined,
@@ -77,6 +79,17 @@ export class TXEStateMachine {
77
79
  return new this(node, synchronizer, archiver, anchorBlockStore, contractSyncService, messageContextService);
78
80
  }
79
81
 
82
+ /** Returns an {@link L2TipsProvider} backed by this node's chain tips. */
83
+ public get l2TipsProvider(): L2TipsProvider {
84
+ const node = this.node;
85
+ return {
86
+ getL2Tips: async () => {
87
+ const tips = await node.getChainTips();
88
+ return { ...tips, proposedCheckpoint: tips.checkpointed };
89
+ },
90
+ };
91
+ }
92
+
80
93
  public async handleL2Block(block: L2Block) {
81
94
  // Create a checkpoint from the block manually.
82
95
  // TXE uses 1-block-per-checkpoint for testing simplicity, so we can use block number as checkpoint number.
@@ -55,14 +55,6 @@ export class MockEpochCache implements EpochCacheInterface {
55
55
  return this.getEpochAndSlotInNextL1Slot();
56
56
  }
57
57
 
58
- isProposerPipeliningEnabled(): boolean {
59
- return false;
60
- }
61
-
62
- pipeliningOffset(): number {
63
- return 0;
64
- }
65
-
66
58
  getProposerIndexEncoding(_epoch: EpochNumber, _slot: SlotNumber, _seed: bigint): `0x${string}` {
67
59
  return '0x00';
68
60
  }
@@ -18,7 +18,7 @@ export class TXESynchronizer implements WorldStateSynchronizer {
18
18
  constructor(public nativeWorldStateService: NativeWorldStateService) {}
19
19
 
20
20
  static async create() {
21
- const nativeWorldStateService = await NativeWorldStateService.tmp();
21
+ const nativeWorldStateService = await NativeWorldStateService.ephemeral();
22
22
 
23
23
  return new this(nativeWorldStateService);
24
24
  }