@aztec/pxe 0.0.1-commit.3895657bc → 0.0.1-commit.3e3d0c9cd
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/contract_function_simulator/contract_function_simulator.d.ts +9 -3
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +17 -3
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +5 -5
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -1
- package/dest/contract_function_simulator/execution_tagging_index_cache.js +17 -9
- package/dest/contract_function_simulator/index.d.ts +2 -1
- package/dest/contract_function_simulator/index.d.ts.map +1 -1
- package/dest/contract_function_simulator/index.js +1 -0
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +2 -3
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/event_validation_request.js +5 -4
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +1 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.js +1 -3
- package/dest/contract_function_simulator/noir-structs/message_tx_context.d.ts +16 -0
- package/dest/contract_function_simulator/noir-structs/message_tx_context.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/message_tx_context.js +57 -0
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +2 -4
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/note_validation_request.js +3 -5
- package/dest/contract_function_simulator/oracle/interfaces.d.ts +13 -9
- package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts +9 -0
- package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.js +43 -0
- package/dest/contract_function_simulator/oracle/oracle.d.ts +6 -6
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.js +21 -15
- package/dest/contract_function_simulator/oracle/private_execution.js +4 -2
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +8 -30
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +7 -37
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +19 -7
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +60 -7
- package/dest/messages/message_context_service.d.ts +17 -0
- package/dest/messages/message_context_service.d.ts.map +1 -0
- package/dest/messages/message_context_service.js +36 -0
- package/dest/oracle_version.d.ts +2 -2
- package/dest/oracle_version.js +2 -2
- package/dest/pxe.d.ts +6 -3
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +27 -17
- package/dest/storage/metadata.d.ts +1 -1
- package/dest/storage/metadata.js +1 -1
- package/dest/storage/tagging_store/sender_tagging_store.d.ts +26 -25
- package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/sender_tagging_store.js +141 -115
- package/dest/tagging/index.d.ts +2 -2
- package/dest/tagging/index.d.ts.map +1 -1
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +1 -1
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -1
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +10 -1
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts +4 -3
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts.map +1 -1
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.js +20 -10
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +2 -1
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -1
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.js +24 -11
- package/package.json +16 -16
- package/src/contract_function_simulator/contract_function_simulator.ts +25 -3
- package/src/contract_function_simulator/execution_tagging_index_cache.ts +16 -11
- package/src/contract_function_simulator/index.ts +1 -0
- package/src/contract_function_simulator/noir-structs/event_validation_request.ts +8 -5
- package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +1 -4
- package/src/contract_function_simulator/noir-structs/message_tx_context.ts +55 -0
- package/src/contract_function_simulator/noir-structs/note_validation_request.ts +3 -6
- package/src/contract_function_simulator/oracle/interfaces.ts +16 -17
- package/src/contract_function_simulator/oracle/legacy_oracle_mappings.ts +142 -0
- package/src/contract_function_simulator/oracle/oracle.ts +30 -40
- package/src/contract_function_simulator/oracle/private_execution.ts +3 -3
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +9 -53
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +90 -9
- package/src/messages/message_context_service.ts +45 -0
- package/src/oracle_version.ts +2 -2
- package/src/pxe.ts +45 -16
- package/src/storage/metadata.ts +1 -1
- package/src/storage/tagging_store/sender_tagging_store.ts +182 -135
- package/src/tagging/index.ts +1 -1
- package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +19 -1
- package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +26 -11
- package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +19 -9
|
@@ -62,11 +62,29 @@ export async function syncSenderTaggingIndexes(
|
|
|
62
62
|
break;
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
const { txHashesToFinalize, txHashesToDrop } = await getStatusChangeOfPending(
|
|
65
|
+
const { txHashesToFinalize, txHashesToDrop, txHashesWithExecutionReverted } = await getStatusChangeOfPending(
|
|
66
|
+
pendingTxHashes,
|
|
67
|
+
aztecNode,
|
|
68
|
+
);
|
|
66
69
|
|
|
67
70
|
await taggingStore.dropPendingIndexes(txHashesToDrop, jobId);
|
|
68
71
|
await taggingStore.finalizePendingIndexes(txHashesToFinalize, jobId);
|
|
69
72
|
|
|
73
|
+
if (txHashesWithExecutionReverted.length > 0) {
|
|
74
|
+
const indexedTxEffects = await Promise.all(
|
|
75
|
+
txHashesWithExecutionReverted.map(txHash => aztecNode.getTxEffect(txHash)),
|
|
76
|
+
);
|
|
77
|
+
for (const indexedTxEffect of indexedTxEffects) {
|
|
78
|
+
if (indexedTxEffect === undefined) {
|
|
79
|
+
throw new Error(
|
|
80
|
+
'TxEffect not found for execution-reverted tx. This is either a bug or a reorg has occurred.',
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
await taggingStore.finalizePendingIndexesOfAPartiallyRevertedTx(indexedTxEffect.data, jobId);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
70
88
|
// We check if the finalized index has been updated.
|
|
71
89
|
newFinalizedIndex = await taggingStore.getLastFinalizedIndex(secret, jobId);
|
|
72
90
|
if (previousFinalizedIndex !== newFinalizedIndex) {
|
|
@@ -2,35 +2,50 @@ import type { AztecNode } from '@aztec/stdlib/interfaces/server';
|
|
|
2
2
|
import { TxHash, TxStatus } from '@aztec/stdlib/tx';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* Based on receipts obtained from `aztecNode` returns which pending transactions changed their status to finalized
|
|
6
|
-
* dropped.
|
|
5
|
+
* Based on receipts obtained from `aztecNode` returns which pending transactions changed their status to finalized,
|
|
6
|
+
* dropped, or execution-reverted (but mined).
|
|
7
7
|
*/
|
|
8
8
|
export async function getStatusChangeOfPending(
|
|
9
9
|
pending: TxHash[],
|
|
10
10
|
aztecNode: AztecNode,
|
|
11
|
-
): Promise<{
|
|
11
|
+
): Promise<{
|
|
12
|
+
txHashesToFinalize: TxHash[];
|
|
13
|
+
txHashesToDrop: TxHash[];
|
|
14
|
+
txHashesWithExecutionReverted: TxHash[];
|
|
15
|
+
}> {
|
|
12
16
|
// Get receipts for all pending tx hashes.
|
|
13
17
|
const receipts = await Promise.all(pending.map(pendingTxHash => aztecNode.getTxReceipt(pendingTxHash)));
|
|
14
18
|
|
|
15
19
|
const txHashesToFinalize: TxHash[] = [];
|
|
16
20
|
const txHashesToDrop: TxHash[] = [];
|
|
21
|
+
const txHashesWithExecutionReverted: TxHash[] = [];
|
|
17
22
|
|
|
18
23
|
for (let i = 0; i < receipts.length; i++) {
|
|
19
24
|
const receipt = receipts[i];
|
|
20
25
|
const txHash = pending[i];
|
|
21
26
|
|
|
22
|
-
if (receipt.status === TxStatus.FINALIZED
|
|
23
|
-
// Tx has been included in a block and the corresponding block is finalized
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
if (receipt.status === TxStatus.FINALIZED) {
|
|
28
|
+
// Tx has been included in a block and the corresponding block is finalized
|
|
29
|
+
if (receipt.hasExecutionSucceeded()) {
|
|
30
|
+
// No part of execution reverted - we just finalize all the indexes.
|
|
31
|
+
txHashesToFinalize.push(txHash);
|
|
32
|
+
} else if (receipt.hasExecutionReverted()) {
|
|
33
|
+
// Tx was mined but execution reverted (app logic, teardown, or both). Some logs from the non-revertible
|
|
34
|
+
// phase may still be onchain. We check which tags made it onchain and finalize those; drop the rest.
|
|
35
|
+
txHashesWithExecutionReverted.push(txHash);
|
|
36
|
+
} else {
|
|
37
|
+
// Defensive check - this branch should never be triggered
|
|
38
|
+
throw new Error(
|
|
39
|
+
'Both hasExecutionSucceeded and hasExecutionReverted on the receipt returned false. This should never happen and it implies a bug. Please open an issue.',
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
} else if (receipt.isDropped()) {
|
|
43
|
+
// Tx was dropped from the mempool --> we drop the corresponding pending indexes.
|
|
29
44
|
txHashesToDrop.push(txHash);
|
|
30
45
|
} else {
|
|
31
46
|
// Tx is still pending, not yet finalized, or was mined successfully but not yet finalized --> we don't do anything.
|
|
32
47
|
}
|
|
33
48
|
}
|
|
34
49
|
|
|
35
|
-
return { txHashesToFinalize, txHashesToDrop };
|
|
50
|
+
return { txHashesToFinalize, txHashesToDrop, txHashesWithExecutionReverted };
|
|
36
51
|
}
|
|
@@ -16,6 +16,7 @@ import { getAllPrivateLogsByTags } from '../../get_all_logs_by_tags.js';
|
|
|
16
16
|
* @param end - The ending index (exclusive) of the window to process.
|
|
17
17
|
* @param aztecNode - The Aztec node instance to query for logs.
|
|
18
18
|
* @param taggingStore - The data provider to store pending indexes.
|
|
19
|
+
* @param anchorBlockHash - Hash of a block to use as reference block when querying node.
|
|
19
20
|
* @param jobId - Job identifier, used to keep writes in-memory until they can be persisted in a data integrity
|
|
20
21
|
* preserving way.
|
|
21
22
|
*/
|
|
@@ -34,12 +35,13 @@ export async function loadAndStoreNewTaggingIndexes(
|
|
|
34
35
|
);
|
|
35
36
|
|
|
36
37
|
const txsForTags = await getTxsContainingTags(siloedTagsForWindow, aztecNode, anchorBlockHash);
|
|
37
|
-
const
|
|
38
|
+
const txIndexesMap = getTxIndexesMap(txsForTags, start, siloedTagsForWindow.length);
|
|
38
39
|
|
|
39
|
-
// Now we iterate over the map,
|
|
40
|
-
for (const [txHashStr,
|
|
40
|
+
// Now we iterate over the map, construct the tagging index ranges and store them in the db.
|
|
41
|
+
for (const [txHashStr, indexes] of txIndexesMap.entries()) {
|
|
41
42
|
const txHash = TxHash.fromString(txHashStr);
|
|
42
|
-
|
|
43
|
+
const ranges = [{ extendedSecret, lowestIndex: Math.min(...indexes), highestIndex: Math.max(...indexes) }];
|
|
44
|
+
await taggingStore.storePendingIndexes(ranges, txHash, jobId);
|
|
43
45
|
}
|
|
44
46
|
}
|
|
45
47
|
|
|
@@ -56,20 +58,28 @@ async function getTxsContainingTags(
|
|
|
56
58
|
return allLogs.map(logs => logs.map(log => log.txHash));
|
|
57
59
|
}
|
|
58
60
|
|
|
59
|
-
// Returns a map of txHash to
|
|
60
|
-
function
|
|
61
|
+
// Returns a map of txHash to all indexes for that txHash.
|
|
62
|
+
function getTxIndexesMap(txHashesForTags: TxHash[][], start: number, count: number): Map<string, number[]> {
|
|
61
63
|
if (txHashesForTags.length !== count) {
|
|
62
64
|
throw new Error(`Number of tx hashes arrays does not match number of tags. ${txHashesForTags.length} !== ${count}`);
|
|
63
65
|
}
|
|
64
66
|
|
|
65
|
-
const
|
|
67
|
+
const indexesMap = new Map<string, number[]>();
|
|
68
|
+
// Iterate over indexes
|
|
66
69
|
for (let i = 0; i < txHashesForTags.length; i++) {
|
|
67
70
|
const taggingIndex = start + i;
|
|
68
71
|
const txHashesForTag = txHashesForTags[i];
|
|
72
|
+
// iterate over tx hashes that used that index (tag)
|
|
69
73
|
for (const txHash of txHashesForTag) {
|
|
70
74
|
const key = txHash.toString();
|
|
71
|
-
|
|
75
|
+
const existing = indexesMap.get(key);
|
|
76
|
+
// Add the index to the tx's indexes
|
|
77
|
+
if (existing) {
|
|
78
|
+
existing.push(taggingIndex);
|
|
79
|
+
} else {
|
|
80
|
+
indexesMap.set(key, [taggingIndex]);
|
|
81
|
+
}
|
|
72
82
|
}
|
|
73
83
|
}
|
|
74
|
-
return
|
|
84
|
+
return indexesMap;
|
|
75
85
|
}
|