@aztec/txe 0.0.1-commit.03f7ef2 → 0.0.1-commit.08c5969dc

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 (73) 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/oracle/interfaces.d.ts +3 -3
  5. package/dest/oracle/interfaces.d.ts.map +1 -1
  6. package/dest/oracle/txe_oracle_public_context.d.ts +3 -3
  7. package/dest/oracle/txe_oracle_public_context.d.ts.map +1 -1
  8. package/dest/oracle/txe_oracle_public_context.js +6 -6
  9. package/dest/oracle/txe_oracle_top_level_context.d.ts +17 -14
  10. package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
  11. package/dest/oracle/txe_oracle_top_level_context.js +144 -67
  12. package/dest/rpc_translator.d.ts +19 -13
  13. package/dest/rpc_translator.d.ts.map +1 -1
  14. package/dest/rpc_translator.js +75 -50
  15. package/dest/state_machine/archiver.d.ts +20 -67
  16. package/dest/state_machine/archiver.d.ts.map +1 -1
  17. package/dest/state_machine/archiver.js +59 -178
  18. package/dest/state_machine/dummy_p2p_client.d.ts +16 -12
  19. package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
  20. package/dest/state_machine/dummy_p2p_client.js +32 -20
  21. package/dest/state_machine/global_variable_builder.d.ts +2 -2
  22. package/dest/state_machine/global_variable_builder.d.ts.map +1 -1
  23. package/dest/state_machine/global_variable_builder.js +1 -1
  24. package/dest/state_machine/index.d.ts +6 -6
  25. package/dest/state_machine/index.d.ts.map +1 -1
  26. package/dest/state_machine/index.js +36 -13
  27. package/dest/state_machine/mock_epoch_cache.d.ts +9 -6
  28. package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -1
  29. package/dest/state_machine/mock_epoch_cache.js +14 -7
  30. package/dest/state_machine/synchronizer.d.ts +3 -3
  31. package/dest/state_machine/synchronizer.d.ts.map +1 -1
  32. package/dest/txe_session.d.ts +17 -14
  33. package/dest/txe_session.d.ts.map +1 -1
  34. package/dest/txe_session.js +144 -49
  35. package/dest/util/encoding.d.ts +17 -17
  36. package/dest/util/txe_account_store.d.ts +10 -0
  37. package/dest/util/txe_account_store.d.ts.map +1 -0
  38. package/dest/util/{txe_account_data_provider.js → txe_account_store.js} +1 -1
  39. package/dest/util/txe_contract_store.d.ts +12 -0
  40. package/dest/util/txe_contract_store.d.ts.map +1 -0
  41. package/dest/util/{txe_contract_data_provider.js → txe_contract_store.js} +3 -3
  42. package/dest/util/txe_public_contract_data_source.d.ts +4 -4
  43. package/dest/util/txe_public_contract_data_source.d.ts.map +1 -1
  44. package/dest/util/txe_public_contract_data_source.js +10 -10
  45. package/dest/utils/block_creation.d.ts +4 -4
  46. package/dest/utils/block_creation.d.ts.map +1 -1
  47. package/dest/utils/block_creation.js +18 -5
  48. package/dest/utils/tx_effect_creation.d.ts +2 -3
  49. package/dest/utils/tx_effect_creation.d.ts.map +1 -1
  50. package/dest/utils/tx_effect_creation.js +3 -6
  51. package/package.json +16 -16
  52. package/src/constants.ts +3 -0
  53. package/src/index.ts +1 -1
  54. package/src/oracle/interfaces.ts +2 -2
  55. package/src/oracle/txe_oracle_public_context.ts +6 -8
  56. package/src/oracle/txe_oracle_top_level_context.ts +171 -108
  57. package/src/rpc_translator.ts +78 -52
  58. package/src/state_machine/archiver.ts +54 -220
  59. package/src/state_machine/dummy_p2p_client.ts +45 -26
  60. package/src/state_machine/global_variable_builder.ts +1 -1
  61. package/src/state_machine/index.ts +49 -12
  62. package/src/state_machine/mock_epoch_cache.ts +15 -11
  63. package/src/state_machine/synchronizer.ts +2 -2
  64. package/src/txe_session.ts +188 -109
  65. package/src/util/{txe_account_data_provider.ts → txe_account_store.ts} +1 -1
  66. package/src/util/{txe_contract_data_provider.ts → txe_contract_store.ts} +3 -3
  67. package/src/util/txe_public_contract_data_source.ts +9 -9
  68. package/src/utils/block_creation.ts +19 -16
  69. package/src/utils/tx_effect_creation.ts +3 -11
  70. package/dest/util/txe_account_data_provider.d.ts +0 -10
  71. package/dest/util/txe_account_data_provider.d.ts.map +0 -1
  72. package/dest/util/txe_contract_data_provider.d.ts +0 -12
  73. package/dest/util/txe_contract_data_provider.d.ts.map +0 -1
@@ -4,7 +4,10 @@ import type {
4
4
  ENR,
5
5
  P2P,
6
6
  P2PBlockReceivedCallback,
7
+ P2PCheckpointReceivedCallback,
7
8
  P2PConfig,
9
+ P2PDuplicateAttestationCallback,
10
+ P2PDuplicateProposalCallback,
8
11
  P2PSyncState,
9
12
  PeerId,
10
13
  ReqRespSubProtocol,
@@ -14,14 +17,10 @@ import type {
14
17
  } from '@aztec/p2p';
15
18
  import type { EthAddress, L2BlockStreamEvent, L2Tips } from '@aztec/stdlib/block';
16
19
  import type { PeerInfo } from '@aztec/stdlib/interfaces/server';
17
- import type { BlockAttestation, BlockProposal } from '@aztec/stdlib/p2p';
18
- import type { Tx, TxHash } from '@aztec/stdlib/tx';
20
+ import type { BlockProposal, CheckpointAttestation, CheckpointProposal } from '@aztec/stdlib/p2p';
21
+ import type { BlockHeader, Tx, TxHash } from '@aztec/stdlib/tx';
19
22
 
20
23
  export class DummyP2P implements P2P {
21
- public broadcastAttestations(_attestations: BlockAttestation[]): Promise<void> {
22
- return Promise.resolve();
23
- }
24
-
25
24
  public validate(_txs: Tx[]): Promise<void> {
26
25
  return Promise.resolve();
27
26
  }
@@ -46,10 +45,22 @@ export class DummyP2P implements P2P {
46
45
  throw new Error('DummyP2P does not implement "broadcastProposal"');
47
46
  }
48
47
 
48
+ public broadcastCheckpointProposal(_proposal: CheckpointProposal): Promise<void> {
49
+ throw new Error('DummyP2P does not implement "broadcastCheckpointProposal"');
50
+ }
51
+
52
+ public broadcastCheckpointAttestations(_attestations: CheckpointAttestation[]): Promise<void> {
53
+ throw new Error('DummyP2P does not implement "broadcastCheckpointAttestations"');
54
+ }
55
+
49
56
  public registerBlockProposalHandler(_handler: P2PBlockReceivedCallback): void {
50
57
  throw new Error('DummyP2P does not implement "registerBlockProposalHandler"');
51
58
  }
52
59
 
60
+ public registerCheckpointProposalHandler(_handler: P2PCheckpointReceivedCallback): void {
61
+ throw new Error('DummyP2P does not implement "registerCheckpointProposalHandler"');
62
+ }
63
+
53
64
  public requestTxs(_txHashes: TxHash[]): Promise<(Tx | undefined)[]> {
54
65
  throw new Error('DummyP2P does not implement "requestTxs"');
55
66
  }
@@ -62,8 +73,8 @@ export class DummyP2P implements P2P {
62
73
  throw new Error('DummyP2P does not implement "sendTx"');
63
74
  }
64
75
 
65
- public deleteTxs(_txHashes: TxHash[]): Promise<void> {
66
- throw new Error('DummyP2P does not implement "deleteTxs"');
76
+ public handleFailedExecution(_txHashes: TxHash[]): Promise<void> {
77
+ throw new Error('DummyP2P does not implement "handleFailedExecution"');
67
78
  }
68
79
 
69
80
  public getTxByHashFromPool(_txHash: TxHash): Promise<Tx | undefined> {
@@ -88,6 +99,10 @@ export class DummyP2P implements P2P {
88
99
  throw new Error('DummyP2P does not implement "iteratePendingTxs"');
89
100
  }
90
101
 
102
+ public iterateEligiblePendingTxs(): AsyncIterableIterator<Tx> {
103
+ throw new Error('DummyP2P does not implement "iterateEligiblePendingTxs"');
104
+ }
105
+
91
106
  public getPendingTxCount(): Promise<number> {
92
107
  throw new Error('DummyP2P does not implement "getPendingTxCount"');
93
108
  }
@@ -120,16 +135,12 @@ export class DummyP2P implements P2P {
120
135
  throw new Error('DummyP2P does not implement "getTxsByHash"');
121
136
  }
122
137
 
123
- public getAttestationsForSlot(_slot: SlotNumber, _proposalId?: string): Promise<BlockAttestation[]> {
124
- throw new Error('DummyP2P does not implement "getAttestationForSlot"');
125
- }
126
-
127
- public deleteAttestation(_attestation: BlockAttestation): Promise<void> {
128
- return Promise.resolve();
138
+ public getCheckpointAttestationsForSlot(_slot: SlotNumber, _proposalId?: string): Promise<CheckpointAttestation[]> {
139
+ throw new Error('DummyP2P does not implement "getCheckpointAttestationsForSlot"');
129
140
  }
130
141
 
131
- public addAttestations(_attestations: BlockAttestation[]): Promise<void> {
132
- throw new Error('DummyP2P does not implement "addAttestations"');
142
+ public addOwnCheckpointAttestations(_attestations: CheckpointAttestation[]): Promise<void> {
143
+ throw new Error('DummyP2P does not implement "addOwnCheckpointAttestations"');
133
144
  }
134
145
 
135
146
  public getL2BlockHash(_number: number): Promise<string | undefined> {
@@ -152,14 +163,6 @@ export class DummyP2P implements P2P {
152
163
  throw new Error('DummyP2P does not implement "sync"');
153
164
  }
154
165
 
155
- public requestTxsByHash(_txHashes: TxHash[]): Promise<Tx[]> {
156
- throw new Error('DummyP2P does not implement "requestTxsByHash"');
157
- }
158
-
159
- public getTxs(_filter: 'all' | 'pending' | 'mined'): Promise<Tx[]> {
160
- throw new Error('DummyP2P does not implement "getTxs"');
161
- }
162
-
163
166
  public getTxsByHashFromPool(_txHashes: TxHash[]): Promise<(Tx | undefined)[]> {
164
167
  throw new Error('DummyP2P does not implement "getTxsByHashFromPool"');
165
168
  }
@@ -184,8 +187,12 @@ export class DummyP2P implements P2P {
184
187
  throw new Error('DummyP2P does not implement "getSyncedLatestSlot"');
185
188
  }
186
189
 
187
- markTxsAsNonEvictable(_: TxHash[]): Promise<void> {
188
- throw new Error('DummyP2P does not implement "markTxsAsNonEvictable".');
190
+ protectTxs(_txHashes: TxHash[], _blockHeader: BlockHeader): Promise<TxHash[]> {
191
+ throw new Error('DummyP2P does not implement "protectTxs".');
192
+ }
193
+
194
+ prepareForSlot(_slotNumber: SlotNumber): Promise<void> {
195
+ return Promise.resolve();
189
196
  }
190
197
 
191
198
  addReqRespSubProtocol(
@@ -201,4 +208,16 @@ export class DummyP2P implements P2P {
201
208
 
202
209
  //This is no-op
203
210
  public registerThisValidatorAddresses(_address: EthAddress[]): void {}
211
+
212
+ public registerDuplicateProposalCallback(_callback: P2PDuplicateProposalCallback): void {
213
+ throw new Error('DummyP2P does not implement "registerDuplicateProposalCallback"');
214
+ }
215
+
216
+ public registerDuplicateAttestationCallback(_callback: P2PDuplicateAttestationCallback): void {
217
+ throw new Error('DummyP2P does not implement "registerDuplicateAttestationCallback"');
218
+ }
219
+
220
+ public hasBlockProposalsForSlot(_slot: SlotNumber): Promise<boolean> {
221
+ throw new Error('DummyP2P does not implement "hasBlockProposalsForSlot"');
222
+ }
204
223
  }
@@ -6,7 +6,7 @@ import { makeGlobalVariables } from '@aztec/stdlib/testing';
6
6
  import { type CheckpointGlobalVariables, type GlobalVariableBuilder, GlobalVariables } from '@aztec/stdlib/tx';
7
7
 
8
8
  export class TXEGlobalVariablesBuilder implements GlobalVariableBuilder {
9
- public getCurrentBaseFees(): Promise<GasFees> {
9
+ public getCurrentMinFees(): Promise<GasFees> {
10
10
  return Promise.resolve(new GasFees(0, 0));
11
11
  }
12
12
 
@@ -1,11 +1,13 @@
1
1
  import { type AztecNodeConfig, AztecNodeService } from '@aztec/aztec-node';
2
2
  import { TestCircuitVerifier } from '@aztec/bb-prover/test';
3
+ import { CheckpointNumber } from '@aztec/foundation/branded-types';
4
+ import { Fr } from '@aztec/foundation/curves/bn254';
3
5
  import { createLogger } from '@aztec/foundation/log';
4
- import type { AztecAsyncKVStore } from '@aztec/kv-store';
5
- import { AnchorBlockDataProvider } from '@aztec/pxe/server';
6
+ import { type AnchorBlockStore, type ContractStore, ContractSyncService, type NoteStore } from '@aztec/pxe/server';
6
7
  import { L2Block } from '@aztec/stdlib/block';
7
- import { L1PublishedData, PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
8
+ import { Checkpoint, L1PublishedData, PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
8
9
  import type { AztecNode } from '@aztec/stdlib/interfaces/client';
10
+ import { CheckpointHeader } from '@aztec/stdlib/rollup';
9
11
  import { getPackageVersion } from '@aztec/stdlib/update-checker';
10
12
 
11
13
  import { TXEArchiver } from './archiver.js';
@@ -22,14 +24,17 @@ export class TXEStateMachine {
22
24
  public node: AztecNode,
23
25
  public synchronizer: TXESynchronizer,
24
26
  public archiver: TXEArchiver,
25
- public anchorBlockDataProvider: AnchorBlockDataProvider,
27
+ public anchorBlockStore: AnchorBlockStore,
28
+ public contractSyncService: ContractSyncService,
26
29
  ) {}
27
30
 
28
- public static async create(db: AztecAsyncKVStore) {
29
- const archiver = new TXEArchiver(db);
31
+ public static async create(
32
+ archiver: TXEArchiver,
33
+ anchorBlockStore: AnchorBlockStore,
34
+ contractStore: ContractStore,
35
+ noteStore: NoteStore,
36
+ ) {
30
37
  const synchronizer = await TXESynchronizer.create();
31
- const anchorBlockDataProvider = new AnchorBlockDataProvider(db);
32
-
33
38
  const aztecNodeConfig = {} as AztecNodeConfig;
34
39
 
35
40
  const log = createLogger('txe_node');
@@ -55,11 +60,40 @@ export class TXEStateMachine {
55
60
  log,
56
61
  );
57
62
 
58
- return new this(node, synchronizer, archiver, anchorBlockDataProvider);
63
+ const contractSyncService = new ContractSyncService(
64
+ node,
65
+ contractStore,
66
+ noteStore,
67
+ createLogger('txe:contract_sync'),
68
+ );
69
+
70
+ return new this(node, synchronizer, archiver, anchorBlockStore, contractSyncService);
59
71
  }
60
72
 
61
73
  public async handleL2Block(block: L2Block) {
62
- const checkpoint = block.toCheckpoint();
74
+ // Create a checkpoint from the block manually.
75
+ // TXE uses 1-block-per-checkpoint for testing simplicity, so we can use block number as checkpoint number.
76
+ // This uses the deprecated fromBlockNumber method intentionally for the TXE testing environment.
77
+ const checkpointNumber = CheckpointNumber.fromBlockNumber(block.number);
78
+ const checkpoint = new Checkpoint(
79
+ block.archive,
80
+ CheckpointHeader.from({
81
+ lastArchiveRoot: block.header.lastArchive.root,
82
+ inHash: Fr.ZERO,
83
+ blobsHash: Fr.ZERO,
84
+ blockHeadersHash: Fr.ZERO,
85
+ epochOutHash: Fr.ZERO,
86
+ slotNumber: block.header.globalVariables.slotNumber,
87
+ timestamp: block.header.globalVariables.timestamp,
88
+ coinbase: block.header.globalVariables.coinbase,
89
+ feeRecipient: block.header.globalVariables.feeRecipient,
90
+ gasFees: block.header.globalVariables.gasFees,
91
+ totalManaUsed: block.header.totalManaUsed,
92
+ }),
93
+ [block],
94
+ checkpointNumber,
95
+ );
96
+
63
97
  const publishedCheckpoint = new PublishedCheckpoint(
64
98
  checkpoint,
65
99
  new L1PublishedData(
@@ -69,10 +103,13 @@ export class TXEStateMachine {
69
103
  ),
70
104
  [],
71
105
  );
106
+ // Wipe contract sync cache when anchor block changes (mirrors BlockSynchronizer behavior)
107
+ this.contractSyncService.wipe();
108
+
72
109
  await Promise.all([
73
- this.synchronizer.handleL2Block(block.toL2Block()),
110
+ this.synchronizer.handleL2Block(block),
74
111
  this.archiver.addCheckpoints([publishedCheckpoint], undefined),
75
- this.anchorBlockDataProvider.setHeader(block.getBlockHeader()),
112
+ this.anchorBlockStore.setHeader(block.header),
76
113
  ]);
77
114
  }
78
115
  }
@@ -1,6 +1,7 @@
1
1
  import type { EpochAndSlot, EpochCacheInterface, EpochCommitteeInfo, SlotTag } from '@aztec/epoch-cache';
2
2
  import { EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
3
3
  import { EthAddress } from '@aztec/foundation/eth-address';
4
+ import { EmptyL1RollupConstants, type L1RollupConstants } from '@aztec/stdlib/epoch-helpers';
4
5
 
5
6
  /**
6
7
  * Mock implementation of the EpochCacheInterface used to satisfy dependencies of AztecNodeService.
@@ -12,14 +13,16 @@ export class MockEpochCache implements EpochCacheInterface {
12
13
  committee: undefined,
13
14
  seed: 0n,
14
15
  epoch: EpochNumber.ZERO,
16
+ isEscapeHatchOpen: false,
15
17
  });
16
18
  }
17
19
 
18
- getEpochAndSlotNow(): EpochAndSlot {
20
+ getEpochAndSlotNow(): EpochAndSlot & { nowMs: bigint } {
19
21
  return {
20
22
  epoch: EpochNumber.ZERO,
21
23
  slot: SlotNumber(0),
22
24
  ts: 0n,
25
+ nowMs: 0n,
23
26
  };
24
27
  }
25
28
 
@@ -40,18 +43,15 @@ export class MockEpochCache implements EpochCacheInterface {
40
43
  return 0n;
41
44
  }
42
45
 
43
- getProposerAttesterAddressInCurrentOrNextSlot(): Promise<{
44
- currentProposer: EthAddress | undefined;
45
- nextProposer: EthAddress | undefined;
46
- currentSlot: SlotNumber;
47
- nextSlot: SlotNumber;
48
- }> {
49
- return Promise.resolve({
50
- currentProposer: undefined,
51
- nextProposer: undefined,
46
+ getCurrentAndNextSlot(): { currentSlot: SlotNumber; nextSlot: SlotNumber } {
47
+ return {
52
48
  currentSlot: SlotNumber(0),
53
49
  nextSlot: SlotNumber(0),
54
- });
50
+ };
51
+ }
52
+
53
+ getProposerAttesterAddressInSlot(_slot: SlotNumber): Promise<EthAddress | undefined> {
54
+ return Promise.resolve(undefined);
55
55
  }
56
56
 
57
57
  isInCommittee(_slot: SlotTag, _validator: EthAddress): Promise<boolean> {
@@ -65,4 +65,8 @@ export class MockEpochCache implements EpochCacheInterface {
65
65
  filterInCommittee(_slot: SlotTag, _validators: EthAddress[]): Promise<EthAddress[]> {
66
66
  return Promise.resolve([]);
67
67
  }
68
+
69
+ getL1Constants(): L1RollupConstants {
70
+ return EmptyL1RollupConstants;
71
+ }
68
72
  }
@@ -1,7 +1,7 @@
1
1
  import { NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP } from '@aztec/constants';
2
2
  import { BlockNumber } from '@aztec/foundation/branded-types';
3
3
  import { Fr } from '@aztec/foundation/curves/bn254';
4
- import type { L2BlockNew } from '@aztec/stdlib/block';
4
+ import type { L2Block } from '@aztec/stdlib/block';
5
5
  import type {
6
6
  MerkleTreeReadOperations,
7
7
  MerkleTreeWriteOperations,
@@ -23,7 +23,7 @@ export class TXESynchronizer implements WorldStateSynchronizer {
23
23
  return new this(nativeWorldStateService);
24
24
  }
25
25
 
26
- public async handleL2Block(block: L2BlockNew) {
26
+ public async handleL2Block(block: L2Block) {
27
27
  await this.nativeWorldStateService.handleL2BlockAndMessages(
28
28
  block,
29
29
  Array(NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP).fill(0).map(Fr.zero),