@aztec/txe 0.86.0 → 0.87.0
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/txe_oracle.d.ts +11 -6
- package/dest/oracle/txe_oracle.d.ts.map +1 -1
- package/dest/oracle/txe_oracle.js +209 -38
- package/dest/state_machine/archiver.d.ts +53 -0
- package/dest/state_machine/archiver.d.ts.map +1 -0
- package/dest/state_machine/archiver.js +100 -0
- package/dest/state_machine/dummy_p2p_client.d.ts +48 -0
- package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -0
- package/dest/state_machine/dummy_p2p_client.js +122 -0
- package/dest/state_machine/global_variable_builder.d.ts +23 -0
- package/dest/state_machine/global_variable_builder.d.ts.map +1 -0
- package/dest/state_machine/global_variable_builder.js +29 -0
- package/dest/state_machine/index.d.ts +16 -0
- package/dest/state_machine/index.d.ts.map +1 -0
- package/dest/state_machine/index.js +48 -0
- package/dest/state_machine/synchronizer.d.ts +32 -0
- package/dest/state_machine/synchronizer.d.ts.map +1 -0
- package/dest/state_machine/synchronizer.js +58 -0
- package/dest/txe_service/txe_service.d.ts +12 -3
- package/dest/txe_service/txe_service.d.ts.map +1 -1
- package/dest/txe_service/txe_service.js +221 -37
- package/dest/util/encoding.d.ts +11 -4
- package/dest/util/encoding.d.ts.map +1 -1
- package/dest/util/encoding.js +38 -2
- package/package.json +18 -15
- package/src/oracle/txe_oracle.ts +387 -40
- package/src/state_machine/archiver.ts +132 -0
- package/src/state_machine/dummy_p2p_client.ts +167 -0
- package/src/state_machine/global_variable_builder.ts +55 -0
- package/src/state_machine/index.ts +71 -0
- package/src/state_machine/synchronizer.ts +87 -0
- package/src/txe_service/txe_service.ts +427 -31
- package/src/util/encoding.ts +51 -2
- package/dest/node/txe_node.d.ts +0 -320
- package/dest/node/txe_node.d.ts.map +0 -1
- package/dest/node/txe_node.js +0 -481
- package/src/node/txe_node.ts +0 -703
package/dest/node/txe_node.js
DELETED
|
@@ -1,481 +0,0 @@
|
|
|
1
|
-
import { poseidon2Hash } from '@aztec/foundation/crypto';
|
|
2
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
3
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
4
|
-
import { L2BlockHash } from '@aztec/stdlib/block';
|
|
5
|
-
import { computePublicDataTreeLeafSlot } from '@aztec/stdlib/hash';
|
|
6
|
-
import { TxScopedL2Log } from '@aztec/stdlib/logs';
|
|
7
|
-
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
8
|
-
import { TxHash, TxReceipt } from '@aztec/stdlib/tx';
|
|
9
|
-
export class TXENode {
|
|
10
|
-
blockNumber;
|
|
11
|
-
version;
|
|
12
|
-
chainId;
|
|
13
|
-
nativeWorldStateService;
|
|
14
|
-
baseFork;
|
|
15
|
-
#logsByTags;
|
|
16
|
-
#txEffectsByTxHash;
|
|
17
|
-
#txReceiptsByTxHash;
|
|
18
|
-
#noteIndex;
|
|
19
|
-
#logger;
|
|
20
|
-
constructor(blockNumber, version, chainId, nativeWorldStateService, baseFork){
|
|
21
|
-
this.blockNumber = blockNumber;
|
|
22
|
-
this.version = version;
|
|
23
|
-
this.chainId = chainId;
|
|
24
|
-
this.nativeWorldStateService = nativeWorldStateService;
|
|
25
|
-
this.baseFork = baseFork;
|
|
26
|
-
this.#logsByTags = new Map();
|
|
27
|
-
this.#txEffectsByTxHash = new Map();
|
|
28
|
-
this.#txReceiptsByTxHash = new Map();
|
|
29
|
-
this.#noteIndex = 0;
|
|
30
|
-
this.#logger = createLogger('aztec:txe_node');
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Fetches the current block number.
|
|
34
|
-
* @returns The block number.
|
|
35
|
-
*/ getBlockNumber() {
|
|
36
|
-
return Promise.resolve(this.blockNumber);
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Sets the current block number of the node.
|
|
40
|
-
* @param - The block number to set.
|
|
41
|
-
*/ setBlockNumber(blockNumber) {
|
|
42
|
-
this.blockNumber = blockNumber;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Gets a tx effect.
|
|
46
|
-
* @param txHash - The hash of the tx corresponding to the tx effect.
|
|
47
|
-
* @returns The requested tx effect with block info (or undefined if not found).
|
|
48
|
-
*/ getTxEffect(txHash) {
|
|
49
|
-
const txEffect = this.#txEffectsByTxHash.get(txHash.toString());
|
|
50
|
-
return Promise.resolve(txEffect);
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Processes a tx effect and receipt for a given block number.
|
|
54
|
-
* @param blockNumber - The block number that this tx effect resides.
|
|
55
|
-
* @param txIndexInBlock - The index of the tx in the block.
|
|
56
|
-
* @param txHash - The transaction hash of the transaction.
|
|
57
|
-
* @param effect - The tx effect to set.
|
|
58
|
-
*/ async processTxEffect(blockNumber, txIndexInBlock, txHash, effect) {
|
|
59
|
-
// We are not creating real blocks on which membership proofs can be constructed - we instead define its hash as
|
|
60
|
-
// simply the hash of the block number.
|
|
61
|
-
const blockHash = await poseidon2Hash([
|
|
62
|
-
blockNumber
|
|
63
|
-
]);
|
|
64
|
-
this.#txEffectsByTxHash.set(txHash.toString(), {
|
|
65
|
-
l2BlockHash: blockHash.toString(),
|
|
66
|
-
l2BlockNumber: blockNumber,
|
|
67
|
-
data: effect,
|
|
68
|
-
txIndexInBlock
|
|
69
|
-
});
|
|
70
|
-
// We also set the receipt since we want to be able to serve `getTxReceipt` - we don't care about most values here,
|
|
71
|
-
// but we do need to be able to retrieve the block number of a given txHash.
|
|
72
|
-
this.#txReceiptsByTxHash.set(txHash.toString(), new TxReceipt(txHash, TxReceipt.statusFromRevertCode(effect.revertCode), '', undefined, new L2BlockHash(blockHash.toBuffer()), blockNumber));
|
|
73
|
-
// Store the private logs
|
|
74
|
-
effect.privateLogs.forEach((log, logIndexInTx)=>{
|
|
75
|
-
const tag = log.fields[0];
|
|
76
|
-
this.#logger.verbose(`Found private log with tag ${tag.toString()} in block ${this.getBlockNumber()}`);
|
|
77
|
-
const currentLogs = this.#logsByTags.get(tag.toString()) ?? [];
|
|
78
|
-
const scopedLog = new TxScopedL2Log(new TxHash(new Fr(blockNumber)), this.#noteIndex, logIndexInTx, blockNumber, log);
|
|
79
|
-
currentLogs.push(scopedLog);
|
|
80
|
-
this.#logsByTags.set(tag.toString(), currentLogs);
|
|
81
|
-
});
|
|
82
|
-
this.#noteIndex += effect.privateLogs.length;
|
|
83
|
-
// Store the public logs
|
|
84
|
-
effect.publicLogs.forEach((log, logIndexInTx)=>{
|
|
85
|
-
const tag = log.log[0];
|
|
86
|
-
this.#logger.verbose(`Found public log with tag ${tag.toString()} in block ${this.getBlockNumber()}`);
|
|
87
|
-
const currentLogs = this.#logsByTags.get(tag.toString()) ?? [];
|
|
88
|
-
const scopedLog = new TxScopedL2Log(new TxHash(new Fr(blockNumber)), this.#noteIndex, logIndexInTx, blockNumber, log);
|
|
89
|
-
currentLogs.push(scopedLog);
|
|
90
|
-
this.#logsByTags.set(tag.toString(), currentLogs);
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Gets all logs that match any of the received tags (i.e. logs with their first field equal to a tag).
|
|
95
|
-
* @param tags - The tags to filter the logs by.
|
|
96
|
-
* @returns For each received tag, an array of matching logs and metadata (e.g. tx hash) is returned. An empty
|
|
97
|
-
array implies no logs match that tag.
|
|
98
|
-
*/ getLogsByTags(tags) {
|
|
99
|
-
const logs = tags.map((tag)=>this.#logsByTags.get(tag.toString()) ?? []);
|
|
100
|
-
return Promise.resolve(logs);
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Returns the tips of the L2 chain.
|
|
104
|
-
*/ getL2Tips() {
|
|
105
|
-
throw new Error('TXE Node method getL2Tips not implemented');
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Find the indexes of the given leaves in the given tree.
|
|
109
|
-
* @param blockNumber - The block number at which to get the data or 'latest' for latest data
|
|
110
|
-
* @param treeId - The tree to search in.
|
|
111
|
-
* @param leafValue - The values to search for
|
|
112
|
-
* @returns The indices of leaves and the block metadata of a block in which the leaf was inserted.
|
|
113
|
-
*/ async findLeavesIndexes(blockNumber, treeId, leafValues) {
|
|
114
|
-
// Temporary workaround to be able to respond this query: the trees are currently stored in the TXE oracle, but we
|
|
115
|
-
// hold a reference to them.
|
|
116
|
-
// We should likely migrate this so that the trees are owned by the node.
|
|
117
|
-
if (blockNumber === undefined) {
|
|
118
|
-
throw new Error(`This error should never happen. We are trying to 'findLeavesIndexes' in the TXe node with an undefined block number.`);
|
|
119
|
-
}
|
|
120
|
-
if (blockNumber === await this.getBlockNumber()) {
|
|
121
|
-
throw new Error(`The node is being requested for state that is currently being built (not committed). Note that in the TXe, the blockNumber is not the latest committed block. It's the current pending one.
|
|
122
|
-
Current block number is: ${blockNumber}.`);
|
|
123
|
-
}
|
|
124
|
-
const db = blockNumber === 'latest' ? this.nativeWorldStateService.getCommitted() : this.nativeWorldStateService.getSnapshot(blockNumber);
|
|
125
|
-
const maybeIndices = await db.findLeafIndices(treeId, leafValues.map((x)=>x.toBuffer()));
|
|
126
|
-
// We filter out undefined values
|
|
127
|
-
const indices = maybeIndices.filter((x)=>x !== undefined);
|
|
128
|
-
// Now we find the block numbers for the indices
|
|
129
|
-
const blockNumbers = await db.getBlockNumbersForLeafIndices(treeId, indices);
|
|
130
|
-
// If any of the block numbers are undefined, we throw an error.
|
|
131
|
-
for(let i = 0; i < indices.length; i++){
|
|
132
|
-
if (blockNumbers[i] === undefined) {
|
|
133
|
-
throw new Error(`Block number is undefined for leaf index ${indices[i]} in tree ${MerkleTreeId[treeId]}`);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
// Get unique block numbers in order to optimize num calls to getLeafValue function.
|
|
137
|
-
const uniqueBlockNumbers = [
|
|
138
|
-
...new Set(blockNumbers.filter((x)=>x !== undefined))
|
|
139
|
-
];
|
|
140
|
-
// Now we obtain the block hashes from the archive tree by calling await `committedDb.getLeafValue(treeId, index)`
|
|
141
|
-
// (note that block number corresponds to the leaf index in the archive tree).
|
|
142
|
-
const blockHashes = await Promise.all(uniqueBlockNumbers.map((blockNumber)=>{
|
|
143
|
-
return db.getLeafValue(MerkleTreeId.ARCHIVE, blockNumber);
|
|
144
|
-
}));
|
|
145
|
-
// If any of the block hashes are undefined, we throw an error.
|
|
146
|
-
for(let i = 0; i < uniqueBlockNumbers.length; i++){
|
|
147
|
-
if (blockHashes[i] === undefined) {
|
|
148
|
-
throw new Error(`Block hash is undefined for block number ${uniqueBlockNumbers[i]}`);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
// Create InBlock objects by combining indices, blockNumbers and blockHashes
|
|
152
|
-
return maybeIndices.map((index, i)=>{
|
|
153
|
-
if (index === undefined) {
|
|
154
|
-
return undefined;
|
|
155
|
-
}
|
|
156
|
-
const blockNumber = blockNumbers[i];
|
|
157
|
-
if (blockNumber === undefined) {
|
|
158
|
-
return undefined;
|
|
159
|
-
}
|
|
160
|
-
const blockHashIndex = uniqueBlockNumbers.indexOf(blockNumber);
|
|
161
|
-
const blockHash = blockHashes[blockHashIndex]?.toString();
|
|
162
|
-
if (!blockHash) {
|
|
163
|
-
return undefined;
|
|
164
|
-
}
|
|
165
|
-
return {
|
|
166
|
-
l2BlockNumber: Number(blockNumber),
|
|
167
|
-
l2BlockHash: blockHash,
|
|
168
|
-
data: index
|
|
169
|
-
};
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
/**
|
|
173
|
-
* Returns a sibling path for the given index in the nullifier tree.
|
|
174
|
-
* @param blockNumber - The block number at which to get the data.
|
|
175
|
-
* @param leafIndex - The index of the leaf for which the sibling path is required.
|
|
176
|
-
* @returns The sibling path for the leaf index.
|
|
177
|
-
*/ getNullifierSiblingPath(_blockNumber, _leafIndex) {
|
|
178
|
-
throw new Error('TXE Node method getNullifierSiblingPath not implemented');
|
|
179
|
-
}
|
|
180
|
-
/**
|
|
181
|
-
* Returns a sibling path for the given index in the note hash tree.
|
|
182
|
-
* @param blockNumber - The block number at which to get the data.
|
|
183
|
-
* @param leafIndex - The index of the leaf for which the sibling path is required.
|
|
184
|
-
* @returns The sibling path for the leaf index.
|
|
185
|
-
*/ getNoteHashSiblingPath(_blockNumber, _leafIndex) {
|
|
186
|
-
throw new Error('TXE Node method getNoteHashSiblingPath not implemented');
|
|
187
|
-
}
|
|
188
|
-
/**
|
|
189
|
-
* Returns the index and a sibling path for a leaf in the committed l1 to l2 data tree.
|
|
190
|
-
* @param blockNumber - The block number at which to get the data.
|
|
191
|
-
* @param l1ToL2Message - The l1ToL2Message to get the index / sibling path for.
|
|
192
|
-
* @returns A tuple of the index and the sibling path of the L1ToL2Message (undefined if not found).
|
|
193
|
-
*/ getL1ToL2MessageMembershipWitness(_blockNumber, _l1ToL2Message) {
|
|
194
|
-
throw new Error('TXE Node method getL1ToL2MessageMembershipWitness not implemented');
|
|
195
|
-
}
|
|
196
|
-
/**
|
|
197
|
-
* Returns whether an L1 to L2 message is synced by archiver and if it's ready to be included in a block.
|
|
198
|
-
* @param l1ToL2Message - The L1 to L2 message to check.
|
|
199
|
-
* @returns Whether the message is synced and ready to be included in a block.
|
|
200
|
-
*/ isL1ToL2MessageSynced(_l1ToL2Message) {
|
|
201
|
-
throw new Error('TXE Node method isL1ToL2MessageSynced not implemented');
|
|
202
|
-
}
|
|
203
|
-
/**
|
|
204
|
-
* Returns a membership witness of an l2ToL1Message in an ephemeral l2 to l1 message tree.
|
|
205
|
-
* @dev Membership witness is a consists of the index and the sibling path of the l2ToL1Message.
|
|
206
|
-
* @remarks This tree is considered ephemeral because it is created on-demand by: taking all the l2ToL1 messages
|
|
207
|
-
* in a single block, and then using them to make a variable depth append-only tree with these messages as leaves.
|
|
208
|
-
* The tree is discarded immediately after calculating what we need from it.
|
|
209
|
-
* @param blockNumber - The block number at which to get the data.
|
|
210
|
-
* @param l2ToL1Message - The l2ToL1Message to get the membership witness for.
|
|
211
|
-
* @returns A tuple of the index and the sibling path of the L2ToL1Message.
|
|
212
|
-
*/ getL2ToL1MessageMembershipWitness(_blockNumber, _l2ToL1Message) {
|
|
213
|
-
throw new Error('TXE Node method getL2ToL1MessageMembershipWitness not implemented');
|
|
214
|
-
}
|
|
215
|
-
/**
|
|
216
|
-
* Returns a sibling path for a leaf in the committed historic blocks tree.
|
|
217
|
-
* @param blockNumber - The block number at which to get the data.
|
|
218
|
-
* @param leafIndex - Index of the leaf in the tree.
|
|
219
|
-
* @returns The sibling path.
|
|
220
|
-
*/ getArchiveSiblingPath(_blockNumber, _leafIndex) {
|
|
221
|
-
throw new Error('TXE Node method getArchiveSiblingPath not implemented');
|
|
222
|
-
}
|
|
223
|
-
/**
|
|
224
|
-
* Returns a sibling path for a leaf in the committed public data tree.
|
|
225
|
-
* @param blockNumber - The block number at which to get the data.
|
|
226
|
-
* @param leafIndex - Index of the leaf in the tree.
|
|
227
|
-
* @returns The sibling path.
|
|
228
|
-
*/ getPublicDataSiblingPath(_blockNumber, _leafIndex) {
|
|
229
|
-
throw new Error('TXE Node method getPublicDataSiblingPath not implemented');
|
|
230
|
-
}
|
|
231
|
-
/**
|
|
232
|
-
* Returns a nullifier membership witness for a given nullifier at a given block.
|
|
233
|
-
* @param blockNumber - The block number at which to get the data.
|
|
234
|
-
* @param nullifier - Nullifier we try to find witness for.
|
|
235
|
-
* @returns The nullifier membership witness (if found).
|
|
236
|
-
*/ getNullifierMembershipWitness(_blockNumber, _nullifier) {
|
|
237
|
-
throw new Error('TXE Node method getNullifierMembershipWitness not implemented');
|
|
238
|
-
}
|
|
239
|
-
/**
|
|
240
|
-
* Returns a low nullifier membership witness for a given nullifier at a given block.
|
|
241
|
-
* @param blockNumber - The block number at which to get the data.
|
|
242
|
-
* @param nullifier - Nullifier we try to find the low nullifier witness for.
|
|
243
|
-
* @returns The low nullifier membership witness (if found).
|
|
244
|
-
* @remarks Low nullifier witness can be used to perform a nullifier non-inclusion proof by leveraging the "linked
|
|
245
|
-
* list structure" of leaves and proving that a lower nullifier is pointing to a bigger next value than the nullifier
|
|
246
|
-
* we are trying to prove non-inclusion for.
|
|
247
|
-
*/ getLowNullifierMembershipWitness(_blockNumber, _nullifier) {
|
|
248
|
-
throw new Error('TXE Node method getLowNullifierMembershipWitness not implemented');
|
|
249
|
-
}
|
|
250
|
-
/**
|
|
251
|
-
* Returns a public data tree witness for a given leaf slot at a given block.
|
|
252
|
-
* @param blockNumber - The block number at which to get the data.
|
|
253
|
-
* @param leafSlot - The leaf slot we try to find the witness for.
|
|
254
|
-
* @returns The public data witness (if found).
|
|
255
|
-
* @remarks The witness can be used to compute the current value of the public data tree leaf. If the low leaf preimage corresponds to an
|
|
256
|
-
* "in range" slot, means that the slot doesn't exist and the value is 0. If the low leaf preimage corresponds to the exact slot, the current value
|
|
257
|
-
* is contained in the leaf preimage.
|
|
258
|
-
*/ getPublicDataWitness(_blockNumber, _leafSlot) {
|
|
259
|
-
throw new Error('TXE Node method getPublicDataWitness not implemented');
|
|
260
|
-
}
|
|
261
|
-
/**
|
|
262
|
-
* Get a block specified by its number.
|
|
263
|
-
* @param number - The block number being requested.
|
|
264
|
-
* @returns The requested block.
|
|
265
|
-
*/ getBlock(_number) {
|
|
266
|
-
throw new Error('TXE Node method getBlock not implemented');
|
|
267
|
-
}
|
|
268
|
-
/**
|
|
269
|
-
* Fetches the latest proven block number.
|
|
270
|
-
* @returns The block number.
|
|
271
|
-
*/ getProvenBlockNumber() {
|
|
272
|
-
throw new Error('TXE Node method getProvenBlockNumber not implemented');
|
|
273
|
-
}
|
|
274
|
-
/**
|
|
275
|
-
* Method to determine if the node is ready to accept transactions.
|
|
276
|
-
* @returns - Flag indicating the readiness for tx submission.
|
|
277
|
-
*/ isReady() {
|
|
278
|
-
throw new Error('TXE Node method isReady not implemented');
|
|
279
|
-
}
|
|
280
|
-
/**
|
|
281
|
-
* Method to request blocks. Will attempt to return all requested blocks but will return only those available.
|
|
282
|
-
* @param from - The start of the range of blocks to return.
|
|
283
|
-
* @param limit - The maximum number of blocks to return.
|
|
284
|
-
* @returns The blocks requested.
|
|
285
|
-
*/ getBlocks(_from, _limit) {
|
|
286
|
-
throw new Error('TXE Node method getBlocks not implemented');
|
|
287
|
-
}
|
|
288
|
-
getPublishedBlocks(_from, _limit) {
|
|
289
|
-
throw new Error('TXE Node method getPublishedBlocks not implemented');
|
|
290
|
-
}
|
|
291
|
-
/**
|
|
292
|
-
* Method to fetch the version of the package.
|
|
293
|
-
* @returns The node package version
|
|
294
|
-
*/ getNodeVersion() {
|
|
295
|
-
throw new Error('TXE Node method getNodeVersion not implemented');
|
|
296
|
-
}
|
|
297
|
-
/**
|
|
298
|
-
* Method to fetch the version of the rollup the node is connected to.
|
|
299
|
-
* @returns The rollup version.
|
|
300
|
-
*/ getVersion() {
|
|
301
|
-
return Promise.resolve(this.version);
|
|
302
|
-
}
|
|
303
|
-
/**
|
|
304
|
-
* Method to fetch the chain id of the base-layer for the rollup.
|
|
305
|
-
* @returns The chain id.
|
|
306
|
-
*/ getChainId() {
|
|
307
|
-
return Promise.resolve(this.chainId);
|
|
308
|
-
}
|
|
309
|
-
/**
|
|
310
|
-
* Method to fetch the currently deployed l1 contract addresses.
|
|
311
|
-
* @returns The deployed contract addresses.
|
|
312
|
-
*/ getL1ContractAddresses() {
|
|
313
|
-
throw new Error('TXE Node method getL1ContractAddresses not implemented');
|
|
314
|
-
}
|
|
315
|
-
/**
|
|
316
|
-
* Method to fetch the protocol contract addresses.
|
|
317
|
-
*/ getProtocolContractAddresses() {
|
|
318
|
-
throw new Error('TXE Node method getProtocolContractAddresses not implemented');
|
|
319
|
-
}
|
|
320
|
-
/**
|
|
321
|
-
* Method to add a contract artifact to the database.
|
|
322
|
-
* @param aztecAddress
|
|
323
|
-
* @param artifact
|
|
324
|
-
*/ registerContractFunctionSignatures(_address, _signatures) {
|
|
325
|
-
throw new Error('TXE Node method addContractArtifact not implemented');
|
|
326
|
-
}
|
|
327
|
-
/**
|
|
328
|
-
* Gets public logs based on the provided filter.
|
|
329
|
-
* @param filter - The filter to apply to the logs.
|
|
330
|
-
* @returns The requested logs.
|
|
331
|
-
*/ getPublicLogs(_filter) {
|
|
332
|
-
throw new Error('TXE Node method getPublicLogs not implemented');
|
|
333
|
-
}
|
|
334
|
-
/**
|
|
335
|
-
* Gets contract class logs based on the provided filter.
|
|
336
|
-
* @param filter - The filter to apply to the logs.
|
|
337
|
-
* @returns The requested logs.
|
|
338
|
-
*/ getContractClassLogs(_filter) {
|
|
339
|
-
throw new Error('TXE Node method getContractClassLogs not implemented');
|
|
340
|
-
}
|
|
341
|
-
/**
|
|
342
|
-
* Method to submit a transaction to the p2p pool.
|
|
343
|
-
* @param tx - The transaction to be submitted.
|
|
344
|
-
* @returns Nothing.
|
|
345
|
-
*/ sendTx(_tx) {
|
|
346
|
-
throw new Error('TXE Node method sendTx not implemented');
|
|
347
|
-
}
|
|
348
|
-
/**
|
|
349
|
-
* Fetches a transaction receipt for a given transaction hash. Returns a mined receipt if it was added
|
|
350
|
-
* to the chain, a pending receipt if it's still in the mempool of the connected Aztec node, or a dropped
|
|
351
|
-
* receipt if not found in the connected Aztec node.
|
|
352
|
-
*
|
|
353
|
-
* @param txHash - The transaction hash.
|
|
354
|
-
* @returns A receipt of the transaction.
|
|
355
|
-
*/ getTxReceipt(txHash) {
|
|
356
|
-
const txEffect = this.#txReceiptsByTxHash.get(txHash.toString());
|
|
357
|
-
if (!txEffect) {
|
|
358
|
-
throw new Error('Unknown txHash');
|
|
359
|
-
}
|
|
360
|
-
return Promise.resolve(txEffect);
|
|
361
|
-
}
|
|
362
|
-
/**
|
|
363
|
-
* Method to retrieve pending txs.
|
|
364
|
-
* @returns The pending txs.
|
|
365
|
-
*/ getPendingTxs() {
|
|
366
|
-
throw new Error('TXE Node method getPendingTxs not implemented');
|
|
367
|
-
}
|
|
368
|
-
/**
|
|
369
|
-
* Retrieves the number of pending txs
|
|
370
|
-
* @returns The number of pending txs.
|
|
371
|
-
*/ getPendingTxCount() {
|
|
372
|
-
throw new Error('TXE Node method getPendingTxCount not implemented');
|
|
373
|
-
}
|
|
374
|
-
/**
|
|
375
|
-
* Method to retrieve a single pending tx.
|
|
376
|
-
* @param txHash - The transaction hash to return.
|
|
377
|
-
* @returns The pending tx if it exists.
|
|
378
|
-
*/ getTxByHash(_txHash) {
|
|
379
|
-
throw new Error('TXE Node method getTxByHash not implemented');
|
|
380
|
-
}
|
|
381
|
-
getTxsByHash(_txHashes) {
|
|
382
|
-
throw new Error('TXE Node method getTxByHash not implemented');
|
|
383
|
-
}
|
|
384
|
-
/**
|
|
385
|
-
* Gets the storage value at the given contract storage slot.
|
|
386
|
-
*
|
|
387
|
-
* @remarks The storage slot here refers to the slot as it is defined in Noir not the index in the merkle tree.
|
|
388
|
-
* Aztec's version of `eth_getStorageAt`.
|
|
389
|
-
*
|
|
390
|
-
* @param contract - Address of the contract to query.
|
|
391
|
-
* @param slot - Slot to query.
|
|
392
|
-
* @param blockNumber - The block number at which to get the data or 'latest'.
|
|
393
|
-
* @returns Storage value at the given contract slot.
|
|
394
|
-
*/ async getPublicStorageAt(blockNumber, contract, slot) {
|
|
395
|
-
const db = blockNumber === await this.getBlockNumber() || blockNumber === 'latest' || blockNumber === undefined ? this.baseFork : this.nativeWorldStateService.getSnapshot(blockNumber);
|
|
396
|
-
const leafSlot = await computePublicDataTreeLeafSlot(contract, slot);
|
|
397
|
-
const lowLeafResult = await db.getPreviousValueIndex(MerkleTreeId.PUBLIC_DATA_TREE, leafSlot.toBigInt());
|
|
398
|
-
if (!lowLeafResult || !lowLeafResult.alreadyPresent) {
|
|
399
|
-
return Fr.ZERO;
|
|
400
|
-
}
|
|
401
|
-
const preimage = await db.getLeafPreimage(MerkleTreeId.PUBLIC_DATA_TREE, lowLeafResult.index);
|
|
402
|
-
return preimage.leaf.value;
|
|
403
|
-
}
|
|
404
|
-
/**
|
|
405
|
-
* Returns the currently committed block header.
|
|
406
|
-
* @returns The current committed block header.
|
|
407
|
-
*/ getBlockHeader(_blockNumber) {
|
|
408
|
-
throw new Error('TXE Node method getBlockHeader not implemented');
|
|
409
|
-
}
|
|
410
|
-
/**
|
|
411
|
-
* Simulates the public part of a transaction with the current state.
|
|
412
|
-
* This currently just checks that the transaction execution succeeds.
|
|
413
|
-
* @param tx - The transaction to simulate.
|
|
414
|
-
**/ simulatePublicCalls(_tx, _enforceFeePayment = false) {
|
|
415
|
-
throw new Error('TXE Node method simulatePublicCalls not implemented');
|
|
416
|
-
}
|
|
417
|
-
/**
|
|
418
|
-
* Returns true if the transaction is valid for inclusion at the current state. Valid transactions can be
|
|
419
|
-
* made invalid by *other* transactions if e.g. they emit the same nullifiers, or come become invalid
|
|
420
|
-
* due to e.g. the max_block_number property.
|
|
421
|
-
* @param tx - The transaction to validate for correctness.
|
|
422
|
-
* @param isSimulation - True if the transaction is a simulated one without generated proofs. (Optional)
|
|
423
|
-
*/ isValidTx(_tx) {
|
|
424
|
-
throw new Error('TXE Node method isValidTx not implemented');
|
|
425
|
-
}
|
|
426
|
-
/**
|
|
427
|
-
* Updates the configuration of this node.
|
|
428
|
-
* @param config - Updated configuration to be merged with the current one.
|
|
429
|
-
*/ setConfig(_config) {
|
|
430
|
-
throw new Error('TXE Node method setConfig not implemented');
|
|
431
|
-
}
|
|
432
|
-
/**
|
|
433
|
-
* Returns a registered contract class given its id.
|
|
434
|
-
* @param id - Id of the contract class.
|
|
435
|
-
*/ getContractClass(_id) {
|
|
436
|
-
throw new Error('TXE Node method getContractClass not implemented');
|
|
437
|
-
}
|
|
438
|
-
/**
|
|
439
|
-
* Returns a publicly deployed contract instance given its address.
|
|
440
|
-
* @param address - Address of the deployed contract.
|
|
441
|
-
*/ getContract(_address) {
|
|
442
|
-
throw new Error('TXE Node method getContract not implemented');
|
|
443
|
-
}
|
|
444
|
-
/** Forces the next block to be built bypassing all time and pending checks. Useful for testing. */ flushTxs() {
|
|
445
|
-
throw new Error('TXE Node method flushTxs not implemented');
|
|
446
|
-
}
|
|
447
|
-
/**
|
|
448
|
-
* Returns the ENR of this node for peer discovery, if available.
|
|
449
|
-
*/ getEncodedEnr() {
|
|
450
|
-
throw new Error('TXE Node method getEncodedEnr not implemented');
|
|
451
|
-
}
|
|
452
|
-
/**
|
|
453
|
-
* Method to fetch the current base fees.
|
|
454
|
-
* @returns The current base fees.
|
|
455
|
-
*/ getCurrentBaseFees() {
|
|
456
|
-
throw new Error('TXE Node method getCurrentBaseFees not implemented');
|
|
457
|
-
}
|
|
458
|
-
/**
|
|
459
|
-
* Retrieves all private logs from up to `limit` blocks, starting from the block number `from`.
|
|
460
|
-
* @param from - The block number from which to begin retrieving logs.
|
|
461
|
-
* @param limit - The maximum number of blocks to retrieve logs from.
|
|
462
|
-
* @returns An array of private logs from the specified range of blocks.
|
|
463
|
-
*/ getPrivateLogs(_from, _limit) {
|
|
464
|
-
throw new Error('TXE Node method getPrivateLogs not implemented');
|
|
465
|
-
}
|
|
466
|
-
/**
|
|
467
|
-
* Returns the information about the server's node. Includes current Node version, compatible Noir version,
|
|
468
|
-
* L1 chain identifier, protocol version, and L1 address of the rollup contract.
|
|
469
|
-
* @returns - The node information.
|
|
470
|
-
*/ getNodeInfo() {
|
|
471
|
-
throw new Error('TXE Node method getNodeInfo not implemented');
|
|
472
|
-
}
|
|
473
|
-
/**
|
|
474
|
-
* Returns the sync status of the node's world state
|
|
475
|
-
*/ getWorldStateSyncStatus() {
|
|
476
|
-
throw new Error('TXE Node method getWorldStateSyncStatus not implemented');
|
|
477
|
-
}
|
|
478
|
-
getValidatorsStats() {
|
|
479
|
-
throw new Error('TXE Node method getValidatorsStats not implemented');
|
|
480
|
-
}
|
|
481
|
-
}
|