@aztec/pxe 0.0.1-commit.3100065 → 0.0.1-commit.330febf
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/bin/check_oracle_version.js +5 -46
- package/dest/bin/index.d.ts +2 -2
- package/dest/bin/index.d.ts.map +1 -1
- package/dest/bin/index.js +1 -1
- package/dest/bin/oracle_version_helpers.d.ts +8 -39
- package/dest/bin/oracle_version_helpers.d.ts.map +1 -1
- package/dest/bin/oracle_version_helpers.js +10 -239
- package/dest/block_synchronizer/block_synchronizer.d.ts +3 -5
- package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
- package/dest/block_synchronizer/block_synchronizer.js +5 -18
- package/dest/config/package_info.js +1 -1
- package/dest/contract/contract_class_service.d.ts +1 -8
- package/dest/contract/contract_class_service.d.ts.map +1 -1
- package/dest/contract/contract_class_service.js +8 -40
- package/dest/contract/helpers.d.ts +1 -1
- package/dest/contract/helpers.d.ts.map +1 -1
- package/dest/contract/helpers.js +3 -3
- package/dest/contract/skip_sync_contracts.d.ts +11 -0
- package/dest/contract/skip_sync_contracts.d.ts.map +1 -0
- package/dest/contract/skip_sync_contracts.js +18 -0
- package/dest/contract_function_simulator/contract_function_simulator.d.ts +1 -8
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +5 -20
- package/dest/contract_function_simulator/index.d.ts +3 -3
- package/dest/contract_function_simulator/index.d.ts.map +1 -1
- package/dest/contract_function_simulator/index.js +1 -2
- package/dest/contract_function_simulator/noir-structs/resolved_tx.d.ts +7 -9
- package/dest/contract_function_simulator/noir-structs/resolved_tx.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/resolved_tx.js +3 -44
- package/dest/contract_function_simulator/noir-structs/tx_effect_data.d.ts +5 -4
- package/dest/contract_function_simulator/noir-structs/tx_effect_data.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/tx_effect_data.js +2 -2
- package/dest/contract_function_simulator/oracle/oracle_registry.d.ts +4 -3
- package/dest/contract_function_simulator/oracle/oracle_registry.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle_registry.js +15 -6
- package/dest/contract_function_simulator/oracle/oracle_type_mappings.d.ts +87 -35
- package/dest/contract_function_simulator/oracle/oracle_type_mappings.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle_type_mappings.js +297 -287
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +11 -8
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +15 -4
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +168 -53
- package/dest/entrypoints/client/bundle/index.d.ts +2 -1
- package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/index.js +1 -0
- package/dest/entrypoints/client/bundle/utils.d.ts +1 -1
- package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/utils.js +10 -4
- package/dest/entrypoints/client/lazy/index.d.ts +2 -1
- package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/index.js +1 -0
- package/dest/entrypoints/client/lazy/utils.d.ts +1 -1
- package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/utils.js +10 -4
- package/dest/entrypoints/client/store.d.ts +14 -0
- package/dest/entrypoints/client/store.d.ts.map +1 -0
- package/dest/entrypoints/client/store.js +42 -0
- package/dest/entrypoints/server/index.d.ts +2 -1
- package/dest/entrypoints/server/index.d.ts.map +1 -1
- package/dest/entrypoints/server/index.js +1 -0
- package/dest/entrypoints/server/store.d.ts +18 -0
- package/dest/entrypoints/server/store.d.ts.map +1 -0
- package/dest/entrypoints/server/store.js +28 -0
- package/dest/entrypoints/server/utils.d.ts +1 -1
- package/dest/entrypoints/server/utils.d.ts.map +1 -1
- package/dest/entrypoints/server/utils.js +8 -2
- package/dest/events/event_service.d.ts +13 -6
- package/dest/events/event_service.d.ts.map +1 -1
- package/dest/events/event_service.js +13 -13
- package/dest/logs/log_service.d.ts +15 -6
- package/dest/logs/log_service.d.ts.map +1 -1
- package/dest/logs/log_service.js +25 -32
- package/dest/messages/tx_resolver_service.d.ts +18 -7
- package/dest/messages/tx_resolver_service.d.ts.map +1 -1
- package/dest/messages/tx_resolver_service.js +13 -7
- package/dest/node/benchmarked_node.d.ts +20 -0
- package/dest/node/benchmarked_node.d.ts.map +1 -0
- package/dest/node/benchmarked_node.js +94 -0
- package/dest/node/caching_aztec_node.d.ts +24 -0
- package/dest/node/caching_aztec_node.d.ts.map +1 -0
- package/dest/node/caching_aztec_node.js +267 -0
- package/dest/notes/note_service.d.ts +13 -7
- package/dest/notes/note_service.d.ts.map +1 -1
- package/dest/notes/note_service.js +10 -10
- package/dest/oracle_version.d.ts +2 -2
- package/dest/oracle_version.js +5 -5
- package/dest/private_kernel/batch_planner.d.ts +1 -1
- package/dest/private_kernel/batch_planner.d.ts.map +1 -1
- package/dest/private_kernel/batch_planner.js +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.d.ts +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.js +45 -5
- package/dest/pxe.d.ts +1 -1
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +39 -19
- package/dest/storage/contract_store/contract_store.d.ts +1 -1
- package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
- package/dest/storage/contract_store/contract_store.js +2 -2
- package/dest/storage/fact_store/fact_store.d.ts +1 -1
- package/dest/storage/fact_store/fact_store.js +1 -1
- package/dest/storage/fact_store/index.d.ts +2 -2
- package/dest/storage/fact_store/index.d.ts.map +1 -1
- package/dest/storage/fact_store/index.js +1 -1
- package/dest/storage/fact_store/origin_state.d.ts +4 -2
- package/dest/storage/fact_store/origin_state.d.ts.map +1 -1
- package/dest/storage/fact_store/origin_state.js +8 -1
- package/dest/storage/store_identity.d.ts +35 -0
- package/dest/storage/store_identity.d.ts.map +1 -0
- package/dest/storage/store_identity.js +44 -0
- package/dest/storage/tagging_store/sender_tagging_store.d.ts +41 -10
- package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/sender_tagging_store.js +81 -29
- package/dest/tagging/constants.d.ts +10 -1
- package/dest/tagging/constants.d.ts.map +1 -1
- package/dest/tagging/constants.js +19 -0
- package/dest/tagging/get_all_logs_by_tags.d.ts +29 -8
- package/dest/tagging/get_all_logs_by_tags.d.ts.map +1 -1
- package/dest/tagging/get_all_logs_by_tags.js +29 -10
- package/dest/tagging/index.d.ts +3 -3
- package/dest/tagging/index.d.ts.map +1 -1
- package/dest/tagging/index.js +2 -2
- package/dest/tagging/recipient_sync/sync_tagged_private_logs.d.ts +10 -5
- package/dest/tagging/recipient_sync/sync_tagged_private_logs.d.ts.map +1 -1
- package/dest/tagging/recipient_sync/sync_tagged_private_logs.js +69 -38
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +6 -3
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -1
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +23 -38
- package/dest/tagging/sender_sync/utils/classify_pending_txs.d.ts +22 -0
- package/dest/tagging/sender_sync/utils/classify_pending_txs.d.ts.map +1 -0
- package/dest/tagging/sender_sync/utils/classify_pending_txs.js +61 -0
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +15 -5
- 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 +36 -35
- package/dest/tagging/sender_sync/utils/resolve_pending_txs.d.ts +29 -0
- package/dest/tagging/sender_sync/utils/resolve_pending_txs.d.ts.map +1 -0
- package/dest/tagging/sender_sync/utils/resolve_pending_txs.js +41 -0
- package/dest/tagging/sender_sync/utils/test_utils.d.ts +16 -0
- package/dest/tagging/sender_sync/utils/test_utils.d.ts.map +1 -0
- package/dest/tagging/sender_sync/utils/test_utils.js +24 -0
- package/dest/tagging/testing/tag_query_test_utils.d.ts +6 -0
- package/dest/tagging/testing/tag_query_test_utils.d.ts.map +1 -0
- package/dest/tagging/testing/tag_query_test_utils.js +10 -0
- package/package.json +17 -17
- package/src/bin/check_oracle_version.ts +5 -56
- package/src/bin/index.ts +1 -5
- package/src/bin/oracle_version_helpers.ts +11 -292
- package/src/block_synchronizer/block_synchronizer.ts +6 -23
- package/src/config/package_info.ts +1 -1
- package/src/contract/contract_class_service.ts +8 -46
- package/src/contract/helpers.ts +3 -3
- package/src/contract/skip_sync_contracts.ts +23 -0
- package/src/contract_function_simulator/contract_function_simulator.ts +5 -20
- package/src/contract_function_simulator/index.ts +23 -3
- package/src/contract_function_simulator/noir-structs/resolved_tx.ts +11 -45
- package/src/contract_function_simulator/noir-structs/tx_effect_data.ts +4 -3
- package/src/contract_function_simulator/oracle/oracle_registry.ts +12 -8
- package/src/contract_function_simulator/oracle/oracle_type_mappings.ts +301 -198
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +19 -9
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +184 -56
- package/src/entrypoints/client/bundle/index.ts +1 -0
- package/src/entrypoints/client/bundle/utils.ts +15 -3
- package/src/entrypoints/client/lazy/index.ts +1 -0
- package/src/entrypoints/client/lazy/utils.ts +15 -3
- package/src/entrypoints/client/store.ts +54 -0
- package/src/entrypoints/server/index.ts +1 -0
- package/src/entrypoints/server/store.ts +47 -0
- package/src/entrypoints/server/utils.ts +21 -7
- package/src/events/event_service.ts +24 -14
- package/src/logs/log_service.ts +41 -39
- package/src/messages/tx_resolver_service.ts +26 -15
- package/src/node/benchmarked_node.ts +140 -0
- package/src/node/caching_aztec_node.ts +406 -0
- package/src/notes/note_service.ts +20 -14
- package/src/oracle_version.ts +5 -5
- package/src/private_kernel/batch_planner.ts +0 -1
- package/src/private_kernel/private_kernel_execution_prover.ts +90 -4
- package/src/pxe.ts +40 -21
- package/src/storage/contract_store/contract_store.ts +2 -1
- package/src/storage/fact_store/fact_store.ts +1 -1
- package/src/storage/fact_store/index.ts +1 -0
- package/src/storage/fact_store/origin_state.ts +10 -1
- package/src/storage/store_identity.ts +72 -0
- package/src/storage/tagging_store/sender_tagging_store.ts +113 -41
- package/src/tagging/constants.ts +22 -0
- package/src/tagging/get_all_logs_by_tags.ts +47 -11
- package/src/tagging/index.ts +7 -2
- package/src/tagging/recipient_sync/sync_tagged_private_logs.ts +116 -62
- package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +27 -57
- package/src/tagging/sender_sync/utils/classify_pending_txs.ts +91 -0
- package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +46 -40
- package/src/tagging/sender_sync/utils/resolve_pending_txs.ts +64 -0
- package/src/tagging/sender_sync/utils/test_utils.ts +46 -0
- package/src/tagging/testing/tag_query_test_utils.ts +11 -0
- package/dest/contract_function_simulator/aztec_node_read_cache.d.ts +0 -39
- package/dest/contract_function_simulator/aztec_node_read_cache.d.ts.map +0 -1
- package/dest/contract_function_simulator/aztec_node_read_cache.js +0 -60
- package/dest/contract_function_simulator/benchmarked_node.d.ts +0 -9
- package/dest/contract_function_simulator/benchmarked_node.d.ts.map +0 -1
- package/dest/contract_function_simulator/benchmarked_node.js +0 -77
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts +0 -17
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts.map +0 -1
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.js +0 -60
- package/src/contract_function_simulator/aztec_node_read_cache.ts +0 -89
- package/src/contract_function_simulator/benchmarked_node.ts +0 -103
- package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +0 -66
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
|
+
import type { AztecNode } from '@aztec/stdlib/interfaces/server';
|
|
3
|
+
import { type MinedTxReceipt, type TxHash, type TxReceipt, TxStatus } from '@aztec/stdlib/tx';
|
|
4
|
+
|
|
5
|
+
import type { PendingTx } from '../../../storage/tagging_store/sender_tagging_store.js';
|
|
6
|
+
import { classifyPendingTxsFromLogs, classifyPendingTxsFromReceipts } from './classify_pending_txs.js';
|
|
7
|
+
import type { TxInLogs } from './load_and_store_new_tagging_indexes.js';
|
|
8
|
+
|
|
9
|
+
/** What a window's node reads established about each of its pending txs. */
|
|
10
|
+
export type ResolvedPendingTxs = {
|
|
11
|
+
txHashesFinalizedFromLogs: TxHash[];
|
|
12
|
+
txHashesFinalizedFromReceipts: TxHash[];
|
|
13
|
+
txHashesDropped: TxHash[];
|
|
14
|
+
/** Both sources land here: the logs when a surviving tag fell inside the window, a receipt otherwise. */
|
|
15
|
+
receiptsWithExecutionReverted: MinedTxReceipt<{ includeTxEffect: true }>[];
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Resolves a window's pending txs. All of the window's node reads happen here.
|
|
20
|
+
*
|
|
21
|
+
* The logs it is handed settle most txs on their own, as {@link classifyPendingTxsFromLogs} explains. Two groups are
|
|
22
|
+
* left over, and share one further round trip:
|
|
23
|
+
*
|
|
24
|
+
* - txs absent from the logs, whose receipt is what tells whether they are still in the mempool, dropped, or reverted;
|
|
25
|
+
* - txs the logs show as reverted, which only their tx effect resolves.
|
|
26
|
+
*
|
|
27
|
+
* A third round trip is paid only when those receipts reveal a reverted tx, since its effect cannot be requested
|
|
28
|
+
* before its status says it reverted.
|
|
29
|
+
*/
|
|
30
|
+
export async function resolvePendingTxs(
|
|
31
|
+
pendingTxs: PendingTx[],
|
|
32
|
+
txsInLogs: Map<string, TxInLogs>,
|
|
33
|
+
finalizedBlockNumber: BlockNumber,
|
|
34
|
+
aztecNode: AztecNode,
|
|
35
|
+
): Promise<ResolvedPendingTxs> {
|
|
36
|
+
const statusFromLogs = classifyPendingTxsFromLogs(pendingTxs, txsInLogs, finalizedBlockNumber);
|
|
37
|
+
|
|
38
|
+
const [statusOfAbsent, receiptsOfRevertedInLogs] = await Promise.all([
|
|
39
|
+
classifyPendingTxsFromReceipts(statusFromLogs.txHashesAbsent, aztecNode),
|
|
40
|
+
getReceiptsWithEffect(statusFromLogs.txHashesWithExecutionReverted, aztecNode),
|
|
41
|
+
]);
|
|
42
|
+
|
|
43
|
+
const receiptsOfRevertedAbsent = await getReceiptsWithEffect(statusOfAbsent.txHashesWithExecutionReverted, aztecNode);
|
|
44
|
+
|
|
45
|
+
return {
|
|
46
|
+
txHashesFinalizedFromLogs: statusFromLogs.txHashesFinalized,
|
|
47
|
+
txHashesFinalizedFromReceipts: statusOfAbsent.txHashesFinalized,
|
|
48
|
+
txHashesDropped: statusOfAbsent.txHashesDropped,
|
|
49
|
+
// Both groups were judged finalized before this fetch, the first off our own tip and the second off an earlier
|
|
50
|
+
// receipt, so both are confirmed against what the node says now. Finalizing off a reorgeable block would burn
|
|
51
|
+
// the indexes.
|
|
52
|
+
receiptsWithExecutionReverted: [...receiptsOfRevertedInLogs, ...receiptsOfRevertedAbsent].filter(isFinalized),
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function getReceiptsWithEffect(txHashes: TxHash[], aztecNode: AztecNode) {
|
|
57
|
+
return Promise.all(txHashes.map(txHash => aztecNode.getTxReceipt(txHash, { includeTxEffect: true })));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function isFinalized(
|
|
61
|
+
receipt: TxReceipt<{ includeTxEffect: true }>,
|
|
62
|
+
): receipt is MinedTxReceipt<{ includeTxEffect: true }> {
|
|
63
|
+
return receipt.status === TxStatus.FINALIZED;
|
|
64
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { BlockNumber, EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
2
|
+
import { BlockHash } from '@aztec/stdlib/block';
|
|
3
|
+
import type { MinedTxStatus, TxEffect, TxHash } from '@aztec/stdlib/tx';
|
|
4
|
+
import { MinedTxReceipt, TxExecutionResult } from '@aztec/stdlib/tx';
|
|
5
|
+
|
|
6
|
+
import type { PendingTx } from '../../../storage/tagging_store/sender_tagging_store.js';
|
|
7
|
+
import type { TxInLogs } from './load_and_store_new_tagging_indexes.js';
|
|
8
|
+
|
|
9
|
+
/** A tx the store holds as pending, tracked up to the given index. */
|
|
10
|
+
export function pendingTx(txHash: TxHash, highestIndex: number): PendingTx {
|
|
11
|
+
return { txHash: txHash.toString(), highestIndex };
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** One tx as a window's logs show it: the block it was mined in and the tagging indexes its logs carried. */
|
|
15
|
+
export function minedIn(blockNumber: number, taggingIndexes: number[]): TxInLogs {
|
|
16
|
+
return { blockNumber: BlockNumber(blockNumber), taggingIndexes };
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** Builds the tx-hash-keyed map a window's logs would produce. */
|
|
20
|
+
export function txsInLogs(...entries: [TxHash, TxInLogs][]): Map<string, TxInLogs> {
|
|
21
|
+
return new Map(entries.map(([txHash, txInLogs]) => [txHash.toString(), txInLogs]));
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** The receipt of a mined tx, successful and without a tx effect unless stated otherwise. */
|
|
25
|
+
export function minedReceipt(
|
|
26
|
+
txHash: TxHash,
|
|
27
|
+
status: MinedTxStatus,
|
|
28
|
+
blockNumber: number,
|
|
29
|
+
{
|
|
30
|
+
executionResult = TxExecutionResult.SUCCESS,
|
|
31
|
+
txEffect,
|
|
32
|
+
}: { executionResult?: TxExecutionResult; txEffect?: TxEffect } = {},
|
|
33
|
+
): MinedTxReceipt {
|
|
34
|
+
return new MinedTxReceipt(
|
|
35
|
+
txHash,
|
|
36
|
+
status,
|
|
37
|
+
executionResult,
|
|
38
|
+
1n,
|
|
39
|
+
BlockHash.random(),
|
|
40
|
+
BlockNumber(blockNumber),
|
|
41
|
+
SlotNumber(Number(blockNumber)),
|
|
42
|
+
0,
|
|
43
|
+
EpochNumber(1),
|
|
44
|
+
txEffect,
|
|
45
|
+
);
|
|
46
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type AppTaggingSecret, type PrivateLogsQuery, SiloedTag, type TagQuery } from '@aztec/stdlib/logs';
|
|
2
|
+
|
|
3
|
+
/** Computes the siloed tag */
|
|
4
|
+
export function computeSiloedTagForIndex(secret: AppTaggingSecret, index: number): Promise<SiloedTag> {
|
|
5
|
+
return SiloedTag.compute({ extendedSecret: secret, index });
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/** Extracts the bare-tag set from a query */
|
|
9
|
+
export function extractTags(query: PrivateLogsQuery): SiloedTag[] {
|
|
10
|
+
return query.tags.map((entry: TagQuery<SiloedTag>) => (entry instanceof SiloedTag ? entry : entry.tag));
|
|
11
|
+
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
-
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
|
-
import type { BlockHash, BlockParameter } from '@aztec/stdlib/block';
|
|
4
|
-
import type { AztecNode } from '@aztec/stdlib/interfaces/server';
|
|
5
|
-
import type { TxHash } from '@aztec/stdlib/tx';
|
|
6
|
-
/**
|
|
7
|
-
* Per-execution cache for immutable Aztec node reads.
|
|
8
|
-
*/
|
|
9
|
-
export declare class AztecNodeReadCache {
|
|
10
|
-
#private;
|
|
11
|
-
private readonly aztecNode;
|
|
12
|
-
private readonly cache;
|
|
13
|
-
constructor(aztecNode: AztecNode);
|
|
14
|
-
/** Fetches a block without reissuing the same node request. */
|
|
15
|
-
getBlock(block: BlockParameter): Promise<{
|
|
16
|
-
header: import("@aztec/stdlib/tx").BlockHeader;
|
|
17
|
-
archive: import("@aztec/stdlib/trees").AppendOnlyTreeSnapshot;
|
|
18
|
-
hash: BlockHash;
|
|
19
|
-
checkpointNumber: import("@aztec/foundation/branded-types").CheckpointNumber;
|
|
20
|
-
indexWithinCheckpoint: import("@aztec/foundation/branded-types").IndexWithinCheckpoint;
|
|
21
|
-
number: import("@aztec/foundation/branded-types").BlockNumber;
|
|
22
|
-
body?: import("@aztec/stdlib/block").Body | undefined;
|
|
23
|
-
l1?: import("@aztec/stdlib/interfaces/server").L1PublishInfo | undefined;
|
|
24
|
-
attestations?: import("@aztec/stdlib/block").CommitteeAttestation[] | undefined;
|
|
25
|
-
} | undefined>;
|
|
26
|
-
/** Fetches a transaction receipt with its effect attached. */
|
|
27
|
-
getTxReceiptWithEffect(txHash: TxHash): Promise<import("@aztec/stdlib/tx").TxReceipt<{
|
|
28
|
-
readonly includeTxEffect: true;
|
|
29
|
-
}>>;
|
|
30
|
-
/** Fetches an archive-tree witness for a block hash. */
|
|
31
|
-
getBlockHashMembershipWitness(referenceBlock: BlockParameter, blockHash: BlockHash): Promise<import("@aztec/foundation/trees").MembershipWitness<30> | undefined>;
|
|
32
|
-
/** Fetches a public-data-tree witness for a leaf slot. */
|
|
33
|
-
getPublicDataWitness(referenceBlock: BlockParameter, leafSlot: Fr): Promise<import("@aztec/stdlib/trees").PublicDataWitness | undefined>;
|
|
34
|
-
/** Fetches public storage for a single slot. */
|
|
35
|
-
getPublicStorageAt(referenceBlock: BlockParameter, contractAddress: AztecAddress, storageSlot: Fr): Promise<Fr>;
|
|
36
|
-
/** Fetches a contiguous public storage range, reusing cached reads for overlapping slots. */
|
|
37
|
-
getPublicStorageRange(referenceBlock: BlockParameter, contractAddress: AztecAddress, startStorageSlot: Fr, numberOfElements: number): Promise<Fr[]>;
|
|
38
|
-
}
|
|
39
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXp0ZWNfbm9kZV9yZWFkX2NhY2hlLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvY29udHJhY3RfZnVuY3Rpb25fc2ltdWxhdG9yL2F6dGVjX25vZGVfcmVhZF9jYWNoZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsRUFBRSxFQUFFLE1BQU0sZ0NBQWdDLENBQUM7QUFDcEQsT0FBTyxLQUFLLEVBQUUsWUFBWSxFQUFFLE1BQU0sNkJBQTZCLENBQUM7QUFDaEUsT0FBTyxLQUFLLEVBQUUsU0FBUyxFQUFFLGNBQWMsRUFBRSxNQUFNLHFCQUFxQixDQUFDO0FBQ3JFLE9BQU8sS0FBSyxFQUFFLFNBQVMsRUFBRSxNQUFNLGlDQUFpQyxDQUFDO0FBQ2pFLE9BQU8sS0FBSyxFQUFFLE1BQU0sRUFBRSxNQUFNLGtCQUFrQixDQUFDO0FBRS9DOztHQUVHO0FBQ0gscUJBQWEsa0JBQWtCOztJQUdqQixPQUFPLENBQUMsUUFBUSxDQUFDLFNBQVM7SUFGdEMsT0FBTyxDQUFDLFFBQVEsQ0FBQyxLQUFLLENBQXVDO0lBRTdELFlBQTZCLFNBQVMsRUFBRSxTQUFTLEVBQUk7SUFFckQsK0RBQStEO0lBQ3hELFFBQVEsQ0FBQyxLQUFLLEVBQUUsY0FBYzs7Ozs7Ozs7OzttQkFFcEM7SUFFRCw4REFBOEQ7SUFDdkQsc0JBQXNCLENBQUMsTUFBTSxFQUFFLE1BQU07O1FBSTNDO0lBRUQsd0RBQXdEO0lBQ2pELDZCQUE2QixDQUFDLGNBQWMsRUFBRSxjQUFjLEVBQUUsU0FBUyxFQUFFLFNBQVMsZ0ZBS3hGO0lBRUQsMERBQTBEO0lBQ25ELG9CQUFvQixDQUFDLGNBQWMsRUFBRSxjQUFjLEVBQUUsUUFBUSxFQUFFLEVBQUUsd0VBSXZFO0lBRUQsZ0RBQWdEO0lBQ3pDLGtCQUFrQixDQUFDLGNBQWMsRUFBRSxjQUFjLEVBQUUsZUFBZSxFQUFFLFlBQVksRUFBRSxXQUFXLEVBQUUsRUFBRSxlQUt2RztJQUVELDZGQUE2RjtJQUN0RixxQkFBcUIsQ0FDMUIsY0FBYyxFQUFFLGNBQWMsRUFDOUIsZUFBZSxFQUFFLFlBQVksRUFDN0IsZ0JBQWdCLEVBQUUsRUFBRSxFQUNwQixnQkFBZ0IsRUFBRSxNQUFNLGlCQU96QjtDQTJCRiJ9
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"aztec_node_read_cache.d.ts","sourceRoot":"","sources":["../../src/contract_function_simulator/aztec_node_read_cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE/C;;GAEG;AACH,qBAAa,kBAAkB;;IAGjB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAFtC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAuC;IAE7D,YAA6B,SAAS,EAAE,SAAS,EAAI;IAErD,+DAA+D;IACxD,QAAQ,CAAC,KAAK,EAAE,cAAc;;;;;;;;;;mBAEpC;IAED,8DAA8D;IACvD,sBAAsB,CAAC,MAAM,EAAE,MAAM;;QAI3C;IAED,wDAAwD;IACjD,6BAA6B,CAAC,cAAc,EAAE,cAAc,EAAE,SAAS,EAAE,SAAS,gFAKxF;IAED,0DAA0D;IACnD,oBAAoB,CAAC,cAAc,EAAE,cAAc,EAAE,QAAQ,EAAE,EAAE,wEAIvE;IAED,gDAAgD;IACzC,kBAAkB,CAAC,cAAc,EAAE,cAAc,EAAE,eAAe,EAAE,YAAY,EAAE,WAAW,EAAE,EAAE,eAKvG;IAED,6FAA6F;IACtF,qBAAqB,CAC1B,cAAc,EAAE,cAAc,EAC9B,eAAe,EAAE,YAAY,EAC7B,gBAAgB,EAAE,EAAE,EACpB,gBAAgB,EAAE,MAAM,iBAOzB;CA2BF"}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
-
/**
|
|
3
|
-
* Per-execution cache for immutable Aztec node reads.
|
|
4
|
-
*/ export class AztecNodeReadCache {
|
|
5
|
-
aztecNode;
|
|
6
|
-
cache;
|
|
7
|
-
constructor(aztecNode){
|
|
8
|
-
this.aztecNode = aztecNode;
|
|
9
|
-
this.cache = new Map();
|
|
10
|
-
}
|
|
11
|
-
/** Fetches a block without reissuing the same node request. */ getBlock(block) {
|
|
12
|
-
return this.#cachedRead(`block:${this.#keyPart(block)}`, ()=>this.aztecNode.getBlock(block));
|
|
13
|
-
}
|
|
14
|
-
/** Fetches a transaction receipt with its effect attached. */ getTxReceiptWithEffect(txHash) {
|
|
15
|
-
return this.#cachedRead(`tx-receipt-with-effect:${txHash.toString()}`, ()=>this.aztecNode.getTxReceipt(txHash, {
|
|
16
|
-
includeTxEffect: true
|
|
17
|
-
}));
|
|
18
|
-
}
|
|
19
|
-
/** Fetches an archive-tree witness for a block hash. */ getBlockHashMembershipWitness(referenceBlock, blockHash) {
|
|
20
|
-
return this.#cachedRead(`block-hash-membership-witness:${this.#keyPart(referenceBlock)}:${blockHash.toString()}`, ()=>this.aztecNode.getBlockHashMembershipWitness(referenceBlock, blockHash));
|
|
21
|
-
}
|
|
22
|
-
/** Fetches a public-data-tree witness for a leaf slot. */ getPublicDataWitness(referenceBlock, leafSlot) {
|
|
23
|
-
return this.#cachedRead(`public-data-witness:${this.#keyPart(referenceBlock)}:${leafSlot.toString()}`, ()=>this.aztecNode.getPublicDataWitness(referenceBlock, leafSlot));
|
|
24
|
-
}
|
|
25
|
-
/** Fetches public storage for a single slot. */ getPublicStorageAt(referenceBlock, contractAddress, storageSlot) {
|
|
26
|
-
return this.#cachedRead(`public-storage:${this.#keyPart(referenceBlock)}:${contractAddress.toString()}:${storageSlot.toString()}`, ()=>this.aztecNode.getPublicStorageAt(referenceBlock, contractAddress, storageSlot));
|
|
27
|
-
}
|
|
28
|
-
/** Fetches a contiguous public storage range, reusing cached reads for overlapping slots. */ getPublicStorageRange(referenceBlock, contractAddress, startStorageSlot, numberOfElements) {
|
|
29
|
-
const slots = Array(numberOfElements).fill(0).map((_, i)=>new Fr(startStorageSlot.value + BigInt(i)));
|
|
30
|
-
return Promise.all(slots.map((storageSlot)=>this.getPublicStorageAt(referenceBlock, contractAddress, storageSlot)));
|
|
31
|
-
}
|
|
32
|
-
#cachedRead(key, fetch) {
|
|
33
|
-
const cached = this.cache.get(key);
|
|
34
|
-
if (cached) {
|
|
35
|
-
return cached;
|
|
36
|
-
}
|
|
37
|
-
const promise = fetch();
|
|
38
|
-
promise.catch(()=>this.cache.delete(key));
|
|
39
|
-
this.cache.set(key, promise);
|
|
40
|
-
return promise;
|
|
41
|
-
}
|
|
42
|
-
#keyPart(value) {
|
|
43
|
-
if ([
|
|
44
|
-
'string',
|
|
45
|
-
'number',
|
|
46
|
-
'bigint',
|
|
47
|
-
'boolean'
|
|
48
|
-
].includes(typeof value)) {
|
|
49
|
-
return String(value);
|
|
50
|
-
}
|
|
51
|
-
if (value && typeof value === 'object') {
|
|
52
|
-
const toString = value.toString;
|
|
53
|
-
if (toString && toString !== Object.prototype.toString) {
|
|
54
|
-
return toString.call(value);
|
|
55
|
-
}
|
|
56
|
-
return JSON.stringify(value, (_key, nested)=>typeof nested === 'bigint' ? nested.toString() : nested);
|
|
57
|
-
}
|
|
58
|
-
return String(value);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
2
|
-
import type { NodeStats } from '@aztec/stdlib/tx';
|
|
3
|
-
export type BenchmarkedNode = AztecNode & {
|
|
4
|
-
getStats(): NodeStats;
|
|
5
|
-
};
|
|
6
|
-
export declare class BenchmarkedNodeFactory {
|
|
7
|
-
static create(node: AztecNode): BenchmarkedNode;
|
|
8
|
-
}
|
|
9
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmVuY2htYXJrZWRfbm9kZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2NvbnRyYWN0X2Z1bmN0aW9uX3NpbXVsYXRvci9iZW5jaG1hcmtlZF9ub2RlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUNBLE9BQU8sS0FBSyxFQUFFLFNBQVMsRUFBRSxNQUFNLGlDQUFpQyxDQUFDO0FBQ2pFLE9BQU8sS0FBSyxFQUFFLFNBQVMsRUFBa0IsTUFBTSxrQkFBa0IsQ0FBQztBQWlCbEUsTUFBTSxNQUFNLGVBQWUsR0FBRyxTQUFTLEdBQUc7SUFBRSxRQUFRLElBQUksU0FBUyxDQUFBO0NBQUUsQ0FBQztBQUVwRSxxQkFBYSxzQkFBc0I7SUFDakMsTUFBTSxDQUFDLE1BQU0sQ0FBQyxJQUFJLEVBQUUsU0FBUyxHQUFHLGVBQWUsQ0ErRTlDO0NBQ0YifQ==
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"benchmarked_node.d.ts","sourceRoot":"","sources":["../../src/contract_function_simulator/benchmarked_node.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,KAAK,EAAE,SAAS,EAAkB,MAAM,kBAAkB,CAAC;AAiBlE,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG;IAAE,QAAQ,IAAI,SAAS,CAAA;CAAE,CAAC;AAEpE,qBAAa,sBAAsB;IACjC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,SAAS,GAAG,eAAe,CA+E9C;CACF"}
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { Timer } from '@aztec/foundation/timer';
|
|
2
|
-
export class BenchmarkedNodeFactory {
|
|
3
|
-
static create(node) {
|
|
4
|
-
// Per-method call stats
|
|
5
|
-
const perMethod = {};
|
|
6
|
-
// Round trip tracking
|
|
7
|
-
let inFlightCount = 0;
|
|
8
|
-
let currentRoundTripTimer = null;
|
|
9
|
-
let currentRoundTripMethods = [];
|
|
10
|
-
const roundTrips = {
|
|
11
|
-
roundTrips: 0,
|
|
12
|
-
totalBlockingTime: 0,
|
|
13
|
-
roundTripDurations: [],
|
|
14
|
-
roundTripMethods: []
|
|
15
|
-
};
|
|
16
|
-
return new Proxy(node, {
|
|
17
|
-
get (target, prop) {
|
|
18
|
-
if (prop === 'getStats') {
|
|
19
|
-
return ()=>{
|
|
20
|
-
return {
|
|
21
|
-
perMethod,
|
|
22
|
-
roundTrips
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
|
-
} else {
|
|
26
|
-
return function(...args) {
|
|
27
|
-
// Track per-method stats
|
|
28
|
-
if (!perMethod[prop]) {
|
|
29
|
-
perMethod[prop] = {
|
|
30
|
-
times: []
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
// Start of a new round trip batch?
|
|
34
|
-
if (inFlightCount === 0) {
|
|
35
|
-
roundTrips.roundTrips++;
|
|
36
|
-
currentRoundTripTimer = new Timer();
|
|
37
|
-
currentRoundTripMethods = [];
|
|
38
|
-
}
|
|
39
|
-
inFlightCount++;
|
|
40
|
-
currentRoundTripMethods.push(prop);
|
|
41
|
-
const callTimer = new Timer();
|
|
42
|
-
const result = target[prop].apply(target, args);
|
|
43
|
-
// Handle completion - called when the call finishes (after Promise resolves)
|
|
44
|
-
const handleCompletion = ()=>{
|
|
45
|
-
const callTime = callTimer.ms();
|
|
46
|
-
perMethod[prop].times.push(callTime);
|
|
47
|
-
inFlightCount--;
|
|
48
|
-
// End of round trip batch - all concurrent calls completed
|
|
49
|
-
if (inFlightCount === 0 && currentRoundTripTimer) {
|
|
50
|
-
const roundTripTime = currentRoundTripTimer.ms();
|
|
51
|
-
roundTrips.totalBlockingTime += roundTripTime;
|
|
52
|
-
roundTrips.roundTripDurations.push(roundTripTime);
|
|
53
|
-
roundTrips.roundTripMethods.push(currentRoundTripMethods);
|
|
54
|
-
currentRoundTripTimer = null;
|
|
55
|
-
currentRoundTripMethods = [];
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
// If the result is a Promise, chain the completion handler
|
|
59
|
-
if (result && typeof result.then === 'function') {
|
|
60
|
-
return result.then((value)=>{
|
|
61
|
-
handleCompletion();
|
|
62
|
-
return value;
|
|
63
|
-
}, (error)=>{
|
|
64
|
-
handleCompletion();
|
|
65
|
-
throw error;
|
|
66
|
-
});
|
|
67
|
-
} else {
|
|
68
|
-
// Synchronous method - handle completion immediately
|
|
69
|
-
handleCompletion();
|
|
70
|
-
return result;
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { AztecNode } from '@aztec/stdlib/interfaces/server';
|
|
2
|
-
import { TxHash } from '@aztec/stdlib/tx';
|
|
3
|
-
/** Classification of a batch of pending tx hashes by the status change implied by their receipts. */
|
|
4
|
-
export type StatusChange = {
|
|
5
|
-
txHashesToFinalize: TxHash[];
|
|
6
|
-
txHashesToDrop: TxHash[];
|
|
7
|
-
txHashesWithExecutionReverted: TxHash[];
|
|
8
|
-
};
|
|
9
|
-
export declare const EMPTY_STATUS_CHANGE: StatusChange;
|
|
10
|
-
/** Concatenates two status changes field-by-field. */
|
|
11
|
-
export declare function mergeStatusChanges(a: StatusChange, b: StatusChange): StatusChange;
|
|
12
|
-
/**
|
|
13
|
-
* Based on receipts obtained from `aztecNode` returns which pending transactions changed their status to finalized,
|
|
14
|
-
* dropped, or execution-reverted (but mined).
|
|
15
|
-
*/
|
|
16
|
-
export declare function getStatusChangeOfPending(pending: TxHash[], aztecNode: AztecNode): Promise<StatusChange>;
|
|
17
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ2V0X3N0YXR1c19jaGFuZ2Vfb2ZfcGVuZGluZy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vc3JjL3RhZ2dpbmcvc2VuZGVyX3N5bmMvdXRpbHMvZ2V0X3N0YXR1c19jaGFuZ2Vfb2ZfcGVuZGluZy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUNqRSxPQUFPLEVBQUUsTUFBTSxFQUFZLE1BQU0sa0JBQWtCLENBQUM7QUFFcEQscUdBQXFHO0FBQ3JHLE1BQU0sTUFBTSxZQUFZLEdBQUc7SUFDekIsa0JBQWtCLEVBQUUsTUFBTSxFQUFFLENBQUM7SUFDN0IsY0FBYyxFQUFFLE1BQU0sRUFBRSxDQUFDO0lBQ3pCLDZCQUE2QixFQUFFLE1BQU0sRUFBRSxDQUFDO0NBQ3pDLENBQUM7QUFFRixlQUFPLE1BQU0sbUJBQW1CLEVBQUUsWUFJakMsQ0FBQztBQUVGLHNEQUFzRDtBQUN0RCx3QkFBZ0Isa0JBQWtCLENBQUMsQ0FBQyxFQUFFLFlBQVksRUFBRSxDQUFDLEVBQUUsWUFBWSxHQUFHLFlBQVksQ0FNakY7QUFFRDs7O0dBR0c7QUFDSCx3QkFBc0Isd0JBQXdCLENBQUMsT0FBTyxFQUFFLE1BQU0sRUFBRSxFQUFFLFNBQVMsRUFBRSxTQUFTLEdBQUcsT0FBTyxDQUFDLFlBQVksQ0FBQyxDQW9DN0cifQ==
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get_status_change_of_pending.d.ts","sourceRoot":"","sources":["../../../../src/tagging/sender_sync/utils/get_status_change_of_pending.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,MAAM,EAAY,MAAM,kBAAkB,CAAC;AAEpD,qGAAqG;AACrG,MAAM,MAAM,YAAY,GAAG;IACzB,kBAAkB,EAAE,MAAM,EAAE,CAAC;IAC7B,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,6BAA6B,EAAE,MAAM,EAAE,CAAC;CACzC,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,YAIjC,CAAC;AAEF,sDAAsD;AACtD,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,YAAY,GAAG,YAAY,CAMjF;AAED;;;GAGG;AACH,wBAAsB,wBAAwB,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,YAAY,CAAC,CAoC7G"}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { TxStatus } from '@aztec/stdlib/tx';
|
|
2
|
-
export const EMPTY_STATUS_CHANGE = {
|
|
3
|
-
txHashesToFinalize: [],
|
|
4
|
-
txHashesToDrop: [],
|
|
5
|
-
txHashesWithExecutionReverted: []
|
|
6
|
-
};
|
|
7
|
-
/** Concatenates two status changes field-by-field. */ export function mergeStatusChanges(a, b) {
|
|
8
|
-
return {
|
|
9
|
-
txHashesToFinalize: [
|
|
10
|
-
...a.txHashesToFinalize,
|
|
11
|
-
...b.txHashesToFinalize
|
|
12
|
-
],
|
|
13
|
-
txHashesToDrop: [
|
|
14
|
-
...a.txHashesToDrop,
|
|
15
|
-
...b.txHashesToDrop
|
|
16
|
-
],
|
|
17
|
-
txHashesWithExecutionReverted: [
|
|
18
|
-
...a.txHashesWithExecutionReverted,
|
|
19
|
-
...b.txHashesWithExecutionReverted
|
|
20
|
-
]
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Based on receipts obtained from `aztecNode` returns which pending transactions changed their status to finalized,
|
|
25
|
-
* dropped, or execution-reverted (but mined).
|
|
26
|
-
*/ export async function getStatusChangeOfPending(pending, aztecNode) {
|
|
27
|
-
// Get receipts for all pending tx hashes.
|
|
28
|
-
const receipts = await Promise.all(pending.map((pendingTxHash)=>aztecNode.getTxReceipt(pendingTxHash)));
|
|
29
|
-
const txHashesToFinalize = [];
|
|
30
|
-
const txHashesToDrop = [];
|
|
31
|
-
const txHashesWithExecutionReverted = [];
|
|
32
|
-
for(let i = 0; i < receipts.length; i++){
|
|
33
|
-
const receipt = receipts[i];
|
|
34
|
-
const txHash = pending[i];
|
|
35
|
-
if (receipt.status === TxStatus.FINALIZED) {
|
|
36
|
-
// Tx has been included in a block and the corresponding block is finalized
|
|
37
|
-
if (receipt.hasExecutionSucceeded()) {
|
|
38
|
-
// No part of execution reverted - we just finalize all the indexes.
|
|
39
|
-
txHashesToFinalize.push(txHash);
|
|
40
|
-
} else if (receipt.hasExecutionReverted()) {
|
|
41
|
-
// Tx was mined but execution reverted (app logic, teardown, or both). Some logs from the non-revertible
|
|
42
|
-
// phase may still be onchain. We check which tags made it onchain and finalize those; drop the rest.
|
|
43
|
-
txHashesWithExecutionReverted.push(txHash);
|
|
44
|
-
} else {
|
|
45
|
-
// Defensive check - this branch should never be triggered
|
|
46
|
-
throw new Error('Both hasExecutionSucceeded and hasExecutionReverted on the receipt returned false. This should never happen and it implies a bug. Please open an issue.');
|
|
47
|
-
}
|
|
48
|
-
} else if (receipt.isDropped()) {
|
|
49
|
-
// Tx was dropped from the mempool --> we drop the corresponding pending indexes.
|
|
50
|
-
txHashesToDrop.push(txHash);
|
|
51
|
-
} else {
|
|
52
|
-
// Tx is still pending, not yet finalized, or was mined successfully but not yet finalized --> we don't do anything.
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
return {
|
|
56
|
-
txHashesToFinalize,
|
|
57
|
-
txHashesToDrop,
|
|
58
|
-
txHashesWithExecutionReverted
|
|
59
|
-
};
|
|
60
|
-
}
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
-
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
|
-
import type { BlockHash, BlockParameter } from '@aztec/stdlib/block';
|
|
4
|
-
import type { AztecNode } from '@aztec/stdlib/interfaces/server';
|
|
5
|
-
import type { TxHash } from '@aztec/stdlib/tx';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Per-execution cache for immutable Aztec node reads.
|
|
9
|
-
*/
|
|
10
|
-
export class AztecNodeReadCache {
|
|
11
|
-
private readonly cache = new Map<string, Promise<unknown>>();
|
|
12
|
-
|
|
13
|
-
constructor(private readonly aztecNode: AztecNode) {}
|
|
14
|
-
|
|
15
|
-
/** Fetches a block without reissuing the same node request. */
|
|
16
|
-
public getBlock(block: BlockParameter) {
|
|
17
|
-
return this.#cachedRead(`block:${this.#keyPart(block)}`, () => this.aztecNode.getBlock(block));
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/** Fetches a transaction receipt with its effect attached. */
|
|
21
|
-
public getTxReceiptWithEffect(txHash: TxHash) {
|
|
22
|
-
return this.#cachedRead(`tx-receipt-with-effect:${txHash.toString()}`, () =>
|
|
23
|
-
this.aztecNode.getTxReceipt(txHash, { includeTxEffect: true } as const),
|
|
24
|
-
);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/** Fetches an archive-tree witness for a block hash. */
|
|
28
|
-
public getBlockHashMembershipWitness(referenceBlock: BlockParameter, blockHash: BlockHash) {
|
|
29
|
-
return this.#cachedRead(
|
|
30
|
-
`block-hash-membership-witness:${this.#keyPart(referenceBlock)}:${blockHash.toString()}`,
|
|
31
|
-
() => this.aztecNode.getBlockHashMembershipWitness(referenceBlock, blockHash),
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/** Fetches a public-data-tree witness for a leaf slot. */
|
|
36
|
-
public getPublicDataWitness(referenceBlock: BlockParameter, leafSlot: Fr) {
|
|
37
|
-
return this.#cachedRead(`public-data-witness:${this.#keyPart(referenceBlock)}:${leafSlot.toString()}`, () =>
|
|
38
|
-
this.aztecNode.getPublicDataWitness(referenceBlock, leafSlot),
|
|
39
|
-
);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/** Fetches public storage for a single slot. */
|
|
43
|
-
public getPublicStorageAt(referenceBlock: BlockParameter, contractAddress: AztecAddress, storageSlot: Fr) {
|
|
44
|
-
return this.#cachedRead(
|
|
45
|
-
`public-storage:${this.#keyPart(referenceBlock)}:${contractAddress.toString()}:${storageSlot.toString()}`,
|
|
46
|
-
() => this.aztecNode.getPublicStorageAt(referenceBlock, contractAddress, storageSlot),
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/** Fetches a contiguous public storage range, reusing cached reads for overlapping slots. */
|
|
51
|
-
public getPublicStorageRange(
|
|
52
|
-
referenceBlock: BlockParameter,
|
|
53
|
-
contractAddress: AztecAddress,
|
|
54
|
-
startStorageSlot: Fr,
|
|
55
|
-
numberOfElements: number,
|
|
56
|
-
) {
|
|
57
|
-
const slots = Array(numberOfElements)
|
|
58
|
-
.fill(0)
|
|
59
|
-
.map((_, i) => new Fr(startStorageSlot.value + BigInt(i)));
|
|
60
|
-
|
|
61
|
-
return Promise.all(slots.map(storageSlot => this.getPublicStorageAt(referenceBlock, contractAddress, storageSlot)));
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
#cachedRead<T>(key: string, fetch: () => Promise<T>): Promise<T> {
|
|
65
|
-
const cached = this.cache.get(key);
|
|
66
|
-
if (cached) {
|
|
67
|
-
return cached as Promise<T>;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
const promise = fetch();
|
|
71
|
-
promise.catch(() => this.cache.delete(key));
|
|
72
|
-
this.cache.set(key, promise);
|
|
73
|
-
return promise;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
#keyPart(value: unknown): string {
|
|
77
|
-
if (['string', 'number', 'bigint', 'boolean'].includes(typeof value)) {
|
|
78
|
-
return String(value);
|
|
79
|
-
}
|
|
80
|
-
if (value && typeof value === 'object') {
|
|
81
|
-
const toString = (value as { toString?: () => string }).toString;
|
|
82
|
-
if (toString && toString !== Object.prototype.toString) {
|
|
83
|
-
return toString.call(value);
|
|
84
|
-
}
|
|
85
|
-
return JSON.stringify(value, (_key, nested) => (typeof nested === 'bigint' ? nested.toString() : nested));
|
|
86
|
-
}
|
|
87
|
-
return String(value);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import { Timer } from '@aztec/foundation/timer';
|
|
2
|
-
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
3
|
-
import type { NodeStats, RoundTripStats } from '@aztec/stdlib/tx';
|
|
4
|
-
|
|
5
|
-
/*
|
|
6
|
-
* Proxy generator for an AztecNode that tracks the time taken for each RPC call and the number of round trips (actual
|
|
7
|
-
* blocking waits for node responses).
|
|
8
|
-
*
|
|
9
|
-
* A round trip is counted when we transition from 0 to 1 in-flight calls, and ends when all concurrent calls complete.
|
|
10
|
-
* This means parallel calls in Promise.all count as a single round trip.
|
|
11
|
-
*
|
|
12
|
-
* Note that batching of RPC calls in `safe_json_rpc_client.ts` could affect the round trip counts but in places we
|
|
13
|
-
* currently use this information we do not even use HTTP as we have direct access to the Aztec Node instance in TS
|
|
14
|
-
* (i.e. not running against external node) so this is not a problem for now.
|
|
15
|
-
*
|
|
16
|
-
* If you want to use this against external node and the info gets skewed by batching you can set the `maxBatchSize`
|
|
17
|
-
* value in `safe_json_rpc_client.ts` to 1 (the main motivation for batching was to get around parallel http requests
|
|
18
|
-
* limits in web browsers which is not a problem when debugging in node.js).
|
|
19
|
-
*/
|
|
20
|
-
export type BenchmarkedNode = AztecNode & { getStats(): NodeStats };
|
|
21
|
-
|
|
22
|
-
export class BenchmarkedNodeFactory {
|
|
23
|
-
static create(node: AztecNode): BenchmarkedNode {
|
|
24
|
-
// Per-method call stats
|
|
25
|
-
const perMethod: Partial<Record<keyof AztecNode, { times: number[] }>> = {};
|
|
26
|
-
|
|
27
|
-
// Round trip tracking
|
|
28
|
-
let inFlightCount = 0;
|
|
29
|
-
let currentRoundTripTimer: Timer | null = null;
|
|
30
|
-
let currentRoundTripMethods: string[] = [];
|
|
31
|
-
const roundTrips: RoundTripStats = {
|
|
32
|
-
roundTrips: 0,
|
|
33
|
-
totalBlockingTime: 0,
|
|
34
|
-
roundTripDurations: [],
|
|
35
|
-
roundTripMethods: [],
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
return new Proxy(node, {
|
|
39
|
-
get(target, prop: keyof BenchmarkedNode) {
|
|
40
|
-
if (prop === 'getStats') {
|
|
41
|
-
return (): NodeStats => {
|
|
42
|
-
return { perMethod, roundTrips };
|
|
43
|
-
};
|
|
44
|
-
} else {
|
|
45
|
-
return function (...args: any[]) {
|
|
46
|
-
// Track per-method stats
|
|
47
|
-
if (!perMethod[prop]) {
|
|
48
|
-
perMethod[prop] = { times: [] };
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// Start of a new round trip batch?
|
|
52
|
-
if (inFlightCount === 0) {
|
|
53
|
-
roundTrips.roundTrips++;
|
|
54
|
-
currentRoundTripTimer = new Timer();
|
|
55
|
-
currentRoundTripMethods = [];
|
|
56
|
-
}
|
|
57
|
-
inFlightCount++;
|
|
58
|
-
currentRoundTripMethods.push(prop);
|
|
59
|
-
|
|
60
|
-
const callTimer = new Timer();
|
|
61
|
-
const result = (target[prop] as any).apply(target, args);
|
|
62
|
-
|
|
63
|
-
// Handle completion - called when the call finishes (after Promise resolves)
|
|
64
|
-
const handleCompletion = () => {
|
|
65
|
-
const callTime = callTimer.ms();
|
|
66
|
-
perMethod[prop]!.times.push(callTime);
|
|
67
|
-
|
|
68
|
-
inFlightCount--;
|
|
69
|
-
|
|
70
|
-
// End of round trip batch - all concurrent calls completed
|
|
71
|
-
if (inFlightCount === 0 && currentRoundTripTimer) {
|
|
72
|
-
const roundTripTime = currentRoundTripTimer.ms();
|
|
73
|
-
roundTrips.totalBlockingTime += roundTripTime;
|
|
74
|
-
roundTrips.roundTripDurations.push(roundTripTime);
|
|
75
|
-
roundTrips.roundTripMethods.push(currentRoundTripMethods);
|
|
76
|
-
currentRoundTripTimer = null;
|
|
77
|
-
currentRoundTripMethods = [];
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
// If the result is a Promise, chain the completion handler
|
|
82
|
-
if (result && typeof result.then === 'function') {
|
|
83
|
-
return result.then(
|
|
84
|
-
(value: any) => {
|
|
85
|
-
handleCompletion();
|
|
86
|
-
return value;
|
|
87
|
-
},
|
|
88
|
-
(error: any) => {
|
|
89
|
-
handleCompletion();
|
|
90
|
-
throw error;
|
|
91
|
-
},
|
|
92
|
-
);
|
|
93
|
-
} else {
|
|
94
|
-
// Synchronous method - handle completion immediately
|
|
95
|
-
handleCompletion();
|
|
96
|
-
return result;
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
},
|
|
101
|
-
}) as BenchmarkedNode;
|
|
102
|
-
}
|
|
103
|
-
}
|