@aztec/p2p 0.0.1-commit.f295ac2 → 0.0.1-commit.fc805bf
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/bootstrap/bootstrap.d.ts +4 -3
- package/dest/bootstrap/bootstrap.d.ts.map +1 -1
- package/dest/bootstrap/bootstrap.js +4 -4
- package/dest/client/factory.d.ts +1 -1
- package/dest/client/factory.d.ts.map +1 -1
- package/dest/client/factory.js +6 -5
- package/dest/client/p2p_client.d.ts +1 -1
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +9 -2
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.d.ts +2 -0
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.d.ts.map +1 -0
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.js +305 -0
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.d.ts +73 -0
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.d.ts.map +1 -0
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.js +8 -0
- package/dest/config.d.ts +8 -2
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +2 -0
- package/dest/mem_pools/instrumentation.d.ts +1 -1
- package/dest/mem_pools/instrumentation.d.ts.map +1 -1
- package/dest/mem_pools/instrumentation.js +2 -2
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts +3 -3
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/eviction/eviction_manager.d.ts +3 -2
- package/dest/mem_pools/tx_pool/eviction/eviction_manager.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/eviction/eviction_strategy.d.ts +3 -2
- package/dest/mem_pools/tx_pool/eviction/eviction_strategy.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.d.ts +3 -3
- package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.js +8 -1
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.d.ts +3 -3
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.js +2 -0
- package/dest/msg_validators/attestation_validator/attestation_validator.d.ts +3 -3
- package/dest/msg_validators/attestation_validator/attestation_validator.d.ts.map +1 -1
- package/dest/msg_validators/attestation_validator/attestation_validator.js +41 -10
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts +3 -3
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts.map +1 -1
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.js +18 -6
- package/dest/msg_validators/clock_tolerance.d.ts +21 -0
- package/dest/msg_validators/clock_tolerance.d.ts.map +1 -0
- package/dest/msg_validators/clock_tolerance.js +37 -0
- package/dest/msg_validators/proposal_validator/proposal_validator.d.ts +3 -3
- package/dest/msg_validators/proposal_validator/proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/proposal_validator.js +55 -31
- package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.d.ts +3 -3
- package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.js +93 -64
- package/dest/msg_validators/tx_validator/archive_cache.d.ts +3 -3
- package/dest/msg_validators/tx_validator/archive_cache.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/archive_cache.js +1 -1
- package/dest/msg_validators/tx_validator/block_header_validator.d.ts +5 -4
- package/dest/msg_validators/tx_validator/block_header_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/block_header_validator.js +3 -2
- package/dest/msg_validators/tx_validator/data_validator.d.ts +3 -1
- package/dest/msg_validators/tx_validator/data_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/data_validator.js +4 -1
- package/dest/msg_validators/tx_validator/double_spend_validator.d.ts +3 -2
- package/dest/msg_validators/tx_validator/double_spend_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/double_spend_validator.js +3 -2
- package/dest/msg_validators/tx_validator/factory.d.ts +8 -3
- package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/factory.js +21 -11
- package/dest/msg_validators/tx_validator/gas_validator.d.ts +3 -2
- package/dest/msg_validators/tx_validator/gas_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/gas_validator.js +3 -2
- package/dest/msg_validators/tx_validator/index.d.ts +2 -1
- package/dest/msg_validators/tx_validator/index.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/index.js +1 -0
- package/dest/msg_validators/tx_validator/metadata_validator.d.ts +3 -2
- package/dest/msg_validators/tx_validator/metadata_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/metadata_validator.js +2 -2
- package/dest/msg_validators/tx_validator/phases_validator.d.ts +3 -2
- package/dest/msg_validators/tx_validator/phases_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/phases_validator.js +3 -3
- package/dest/msg_validators/tx_validator/size_validator.d.ts +8 -0
- package/dest/msg_validators/tx_validator/size_validator.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/size_validator.js +23 -0
- package/dest/msg_validators/tx_validator/timestamp_validator.d.ts +3 -2
- package/dest/msg_validators/tx_validator/timestamp_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/timestamp_validator.js +2 -2
- package/dest/msg_validators/tx_validator/tx_permitted_validator.d.ts +3 -2
- package/dest/msg_validators/tx_validator/tx_permitted_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/tx_permitted_validator.js +2 -2
- package/dest/msg_validators/tx_validator/tx_proof_validator.d.ts +3 -2
- package/dest/msg_validators/tx_validator/tx_proof_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/tx_proof_validator.js +2 -2
- package/dest/services/data_store.d.ts +1 -1
- package/dest/services/data_store.d.ts.map +1 -1
- package/dest/services/data_store.js +10 -6
- package/dest/services/discv5/discV5_service.js +1 -1
- package/dest/services/dummy_service.d.ts +13 -1
- package/dest/services/dummy_service.d.ts.map +1 -1
- package/dest/services/dummy_service.js +39 -0
- package/dest/services/encoding.d.ts +1 -1
- package/dest/services/encoding.d.ts.map +1 -1
- package/dest/services/encoding.js +2 -3
- package/dest/services/libp2p/instrumentation.d.ts +1 -1
- package/dest/services/libp2p/instrumentation.d.ts.map +1 -1
- package/dest/services/libp2p/instrumentation.js +14 -3
- package/dest/services/libp2p/libp2p_service.d.ts +13 -7
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +60 -51
- package/dest/services/peer-manager/metrics.d.ts +2 -2
- package/dest/services/peer-manager/metrics.d.ts.map +1 -1
- package/dest/services/peer-manager/metrics.js +20 -5
- package/dest/services/peer-manager/peer_scoring.d.ts +1 -1
- package/dest/services/peer-manager/peer_scoring.d.ts.map +1 -1
- package/dest/services/peer-manager/peer_scoring.js +8 -2
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts +47 -0
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts.map +1 -0
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.js +566 -0
- package/dest/services/reqresp/batch-tx-requester/config.d.ts +17 -0
- package/dest/services/reqresp/batch-tx-requester/config.d.ts.map +1 -0
- package/dest/services/reqresp/batch-tx-requester/config.js +27 -0
- package/dest/services/reqresp/batch-tx-requester/interface.d.ts +50 -0
- package/dest/services/reqresp/batch-tx-requester/interface.d.ts.map +1 -0
- package/dest/services/reqresp/batch-tx-requester/interface.js +1 -0
- package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts +37 -0
- package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts.map +1 -0
- package/dest/services/reqresp/batch-tx-requester/missing_txs.js +151 -0
- package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts +54 -0
- package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts.map +1 -0
- package/dest/services/reqresp/batch-tx-requester/peer_collection.js +139 -0
- package/dest/services/reqresp/batch-tx-requester/tx_validator.d.ts +20 -0
- package/dest/services/reqresp/batch-tx-requester/tx_validator.d.ts.map +1 -0
- package/dest/services/reqresp/batch-tx-requester/tx_validator.js +21 -0
- package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts +22 -3
- package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts.map +1 -1
- package/dest/services/reqresp/connection-sampler/batch_connection_sampler.js +63 -4
- package/dest/services/reqresp/connection-sampler/connection_sampler.d.ts +2 -1
- package/dest/services/reqresp/connection-sampler/connection_sampler.d.ts.map +1 -1
- package/dest/services/reqresp/connection-sampler/connection_sampler.js +12 -0
- package/dest/services/reqresp/interface.d.ts +5 -3
- package/dest/services/reqresp/interface.d.ts.map +1 -1
- package/dest/services/reqresp/interface.js +2 -2
- package/dest/services/reqresp/metrics.d.ts +6 -5
- package/dest/services/reqresp/metrics.d.ts.map +1 -1
- package/dest/services/reqresp/metrics.js +17 -5
- package/dest/services/reqresp/protocols/block_txs/bitvector.d.ts +5 -1
- package/dest/services/reqresp/protocols/block_txs/bitvector.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/block_txs/bitvector.js +5 -0
- package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts +1 -1
- package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/block_txs/block_txs_handler.js +16 -3
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts +18 -6
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.js +43 -13
- package/dest/services/reqresp/reqresp.d.ts +6 -1
- package/dest/services/reqresp/reqresp.d.ts.map +1 -1
- package/dest/services/reqresp/reqresp.js +58 -22
- package/dest/services/service.d.ts +4 -1
- package/dest/services/service.d.ts.map +1 -1
- package/dest/services/tx_collection/config.d.ts +4 -1
- package/dest/services/tx_collection/config.d.ts.map +1 -1
- package/dest/services/tx_collection/config.js +9 -1
- package/dest/services/tx_collection/fast_tx_collection.d.ts +6 -4
- package/dest/services/tx_collection/fast_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/fast_tx_collection.js +16 -5
- package/dest/services/tx_collection/index.d.ts +2 -1
- package/dest/services/tx_collection/index.d.ts.map +1 -1
- package/dest/services/tx_collection/index.js +1 -0
- package/dest/services/tx_collection/instrumentation.d.ts +1 -1
- package/dest/services/tx_collection/instrumentation.d.ts.map +1 -1
- package/dest/services/tx_collection/instrumentation.js +9 -2
- package/dest/services/tx_collection/proposal_tx_collector.d.ts +48 -0
- package/dest/services/tx_collection/proposal_tx_collector.d.ts.map +1 -0
- package/dest/services/tx_collection/proposal_tx_collector.js +50 -0
- package/dest/services/tx_collection/slow_tx_collection.d.ts +3 -3
- package/dest/services/tx_collection/slow_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_collection.d.ts +8 -8
- package/dest/services/tx_collection/tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_collection.js +5 -5
- package/dest/services/tx_provider.d.ts +3 -3
- package/dest/services/tx_provider.d.ts.map +1 -1
- package/dest/services/tx_provider_instrumentation.d.ts +1 -1
- package/dest/services/tx_provider_instrumentation.d.ts.map +1 -1
- package/dest/services/tx_provider_instrumentation.js +5 -5
- package/dest/test-helpers/index.d.ts +3 -1
- package/dest/test-helpers/index.d.ts.map +1 -1
- package/dest/test-helpers/index.js +2 -0
- package/dest/test-helpers/test_tx_provider.d.ts +40 -0
- package/dest/test-helpers/test_tx_provider.d.ts.map +1 -0
- package/dest/test-helpers/test_tx_provider.js +41 -0
- package/dest/test-helpers/testbench-utils.d.ts +158 -0
- package/dest/test-helpers/testbench-utils.d.ts.map +1 -0
- package/dest/test-helpers/testbench-utils.js +297 -0
- package/dest/testbench/p2p_client_testbench_worker.d.ts +28 -2
- package/dest/testbench/p2p_client_testbench_worker.d.ts.map +1 -1
- package/dest/testbench/p2p_client_testbench_worker.js +212 -133
- package/dest/testbench/worker_client_manager.d.ts +51 -6
- package/dest/testbench/worker_client_manager.d.ts.map +1 -1
- package/dest/testbench/worker_client_manager.js +226 -44
- package/package.json +14 -14
- package/src/bootstrap/bootstrap.ts +7 -4
- package/src/client/factory.ts +6 -10
- package/src/client/p2p_client.ts +14 -7
- package/src/client/test/tx_proposal_collector/README.md +227 -0
- package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +336 -0
- package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.ts +43 -0
- package/src/config.ts +6 -1
- package/src/mem_pools/instrumentation.ts +2 -1
- package/src/mem_pools/tx_pool/aztec_kv_tx_pool.ts +2 -2
- package/src/mem_pools/tx_pool/eviction/eviction_manager.ts +2 -1
- package/src/mem_pools/tx_pool/eviction/eviction_strategy.ts +2 -1
- package/src/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.ts +10 -7
- package/src/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.ts +4 -2
- package/src/msg_validators/attestation_validator/attestation_validator.ts +26 -14
- package/src/msg_validators/attestation_validator/fisherman_attestation_validator.ts +14 -8
- package/src/msg_validators/clock_tolerance.ts +51 -0
- package/src/msg_validators/proposal_validator/proposal_validator.ts +31 -31
- package/src/msg_validators/proposal_validator/proposal_validator_test_suite.ts +91 -67
- package/src/msg_validators/tx_validator/archive_cache.ts +3 -3
- package/src/msg_validators/tx_validator/block_header_validator.ts +6 -5
- package/src/msg_validators/tx_validator/data_validator.ts +6 -2
- package/src/msg_validators/tx_validator/double_spend_validator.ts +4 -3
- package/src/msg_validators/tx_validator/factory.ts +64 -23
- package/src/msg_validators/tx_validator/gas_validator.ts +9 -3
- package/src/msg_validators/tx_validator/index.ts +1 -0
- package/src/msg_validators/tx_validator/metadata_validator.ts +6 -3
- package/src/msg_validators/tx_validator/phases_validator.ts +5 -3
- package/src/msg_validators/tx_validator/size_validator.ts +22 -0
- package/src/msg_validators/tx_validator/timestamp_validator.ts +6 -3
- package/src/msg_validators/tx_validator/tx_permitted_validator.ts +8 -3
- package/src/msg_validators/tx_validator/tx_proof_validator.ts +8 -3
- package/src/services/data_store.ts +10 -7
- package/src/services/discv5/discV5_service.ts +1 -1
- package/src/services/dummy_service.ts +45 -0
- package/src/services/encoding.ts +2 -3
- package/src/services/libp2p/instrumentation.ts +15 -2
- package/src/services/libp2p/libp2p_service.ts +99 -73
- package/src/services/peer-manager/metrics.ts +21 -4
- package/src/services/peer-manager/peer_scoring.ts +4 -1
- package/src/services/reqresp/batch-tx-requester/README.md +305 -0
- package/src/services/reqresp/batch-tx-requester/batch_tx_requester.ts +706 -0
- package/src/services/reqresp/batch-tx-requester/config.ts +40 -0
- package/src/services/reqresp/batch-tx-requester/interface.ts +57 -0
- package/src/services/reqresp/batch-tx-requester/missing_txs.ts +209 -0
- package/src/services/reqresp/batch-tx-requester/peer_collection.ts +205 -0
- package/src/services/reqresp/batch-tx-requester/tx_validator.ts +37 -0
- package/src/services/reqresp/connection-sampler/batch_connection_sampler.ts +65 -4
- package/src/services/reqresp/connection-sampler/connection_sampler.ts +16 -0
- package/src/services/reqresp/interface.ts +5 -2
- package/src/services/reqresp/metrics.ts +34 -9
- package/src/services/reqresp/protocols/block_txs/bitvector.ts +7 -0
- package/src/services/reqresp/protocols/block_txs/block_txs_handler.ts +18 -4
- package/src/services/reqresp/protocols/block_txs/block_txs_reqresp.ts +51 -9
- package/src/services/reqresp/reqresp.ts +66 -19
- package/src/services/service.ts +4 -0
- package/src/services/tx_collection/config.ts +15 -1
- package/src/services/tx_collection/fast_tx_collection.ts +36 -13
- package/src/services/tx_collection/index.ts +5 -0
- package/src/services/tx_collection/instrumentation.ts +11 -2
- package/src/services/tx_collection/proposal_tx_collector.ts +114 -0
- package/src/services/tx_collection/slow_tx_collection.ts +2 -2
- package/src/services/tx_collection/tx_collection.ts +8 -8
- package/src/services/tx_provider.ts +2 -2
- package/src/services/tx_provider_instrumentation.ts +11 -5
- package/src/test-helpers/index.ts +2 -0
- package/src/test-helpers/test_tx_provider.ts +64 -0
- package/src/test-helpers/testbench-utils.ts +374 -0
- package/src/testbench/p2p_client_testbench_worker.ts +321 -126
- package/src/testbench/worker_client_manager.ts +304 -47
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
1
|
import type { ArchiveSource } from '@aztec/p2p';
|
|
2
|
+
import type { BlockHash } from '@aztec/stdlib/block';
|
|
3
3
|
import type { MerkleTreeReadOperations } from '@aztec/stdlib/interfaces/server';
|
|
4
4
|
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
5
5
|
|
|
@@ -14,8 +14,8 @@ export class ArchiveCache implements ArchiveSource {
|
|
|
14
14
|
this.archives = new Map<string, bigint>();
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
public async getArchiveIndices(archives:
|
|
18
|
-
const toCheckDb = archives.filter(n => !this.archives.has(n.toString()));
|
|
17
|
+
public async getArchiveIndices(archives: BlockHash[]): Promise<(bigint | undefined)[]> {
|
|
18
|
+
const toCheckDb = archives.filter(n => !this.archives.has(n.toString())).map(n => n.toFr());
|
|
19
19
|
const dbHits = await this.db.findLeafIndices(MerkleTreeId.ARCHIVE, toCheckDb);
|
|
20
20
|
dbHits.forEach((x, index) => {
|
|
21
21
|
if (x !== undefined) {
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import {
|
|
1
|
+
import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
|
|
2
|
+
import type { BlockHash } from '@aztec/stdlib/block';
|
|
3
3
|
import { type AnyTx, TX_ERROR_BLOCK_HEADER, type TxValidationResult, type TxValidator } from '@aztec/stdlib/tx';
|
|
4
4
|
|
|
5
5
|
export interface ArchiveSource {
|
|
6
|
-
getArchiveIndices: (archives:
|
|
6
|
+
getArchiveIndices: (archives: BlockHash[]) => Promise<(bigint | undefined)[]>;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
export class BlockHeaderTxValidator<T extends AnyTx> implements TxValidator<T> {
|
|
10
|
-
#log
|
|
10
|
+
#log: Logger;
|
|
11
11
|
#archiveSource: ArchiveSource;
|
|
12
12
|
|
|
13
|
-
constructor(archiveSource: ArchiveSource) {
|
|
13
|
+
constructor(archiveSource: ArchiveSource, bindings?: LoggerBindings) {
|
|
14
14
|
this.#archiveSource = archiveSource;
|
|
15
|
+
this.#log = createLogger('p2p:tx_validator:tx_block_header', bindings);
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
async validateTx(tx: T): Promise<TxValidationResult> {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MAX_FR_CALLDATA_TO_ALL_ENQUEUED_CALLS } from '@aztec/constants';
|
|
2
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
2
|
+
import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
|
|
3
3
|
import { computeCalldataHash } from '@aztec/stdlib/hash';
|
|
4
4
|
import {
|
|
5
5
|
TX_ERROR_CALLDATA_COUNT_MISMATCH,
|
|
@@ -16,7 +16,11 @@ import {
|
|
|
16
16
|
} from '@aztec/stdlib/tx';
|
|
17
17
|
|
|
18
18
|
export class DataTxValidator implements TxValidator<Tx> {
|
|
19
|
-
#log
|
|
19
|
+
#log: Logger;
|
|
20
|
+
|
|
21
|
+
constructor(bindings?: LoggerBindings) {
|
|
22
|
+
this.#log = createLogger('p2p:tx_validator:tx_data', bindings);
|
|
23
|
+
}
|
|
20
24
|
|
|
21
25
|
async validateTx(tx: Tx): Promise<TxValidationResult> {
|
|
22
26
|
const reason =
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
1
|
+
import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
|
|
2
2
|
import {
|
|
3
3
|
type AnyTx,
|
|
4
4
|
TX_ERROR_DUPLICATE_NULLIFIER_IN_TX,
|
|
@@ -13,11 +13,12 @@ export interface NullifierSource {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
export class DoubleSpendTxValidator<T extends AnyTx> implements TxValidator<T> {
|
|
16
|
-
#log
|
|
16
|
+
#log: Logger;
|
|
17
17
|
#nullifierSource: NullifierSource;
|
|
18
18
|
|
|
19
|
-
constructor(nullifierSource: NullifierSource) {
|
|
19
|
+
constructor(nullifierSource: NullifierSource, bindings?: LoggerBindings) {
|
|
20
20
|
this.#nullifierSource = nullifierSource;
|
|
21
|
+
this.#log = createLogger('p2p:tx_validator:tx_double_spend', bindings);
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
async validateTx(tx: T): Promise<TxValidationResult> {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
2
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
|
+
import type { LoggerBindings } from '@aztec/foundation/log';
|
|
3
4
|
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
4
|
-
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
5
|
+
import { ProtocolContractAddress, protocolContractsHash } from '@aztec/protocol-contracts';
|
|
5
6
|
import type { ContractDataSource } from '@aztec/stdlib/contract';
|
|
6
7
|
import type { GasFees } from '@aztec/stdlib/gas';
|
|
7
8
|
import type {
|
|
@@ -11,9 +12,10 @@ import type {
|
|
|
11
12
|
} from '@aztec/stdlib/interfaces/server';
|
|
12
13
|
import { PeerErrorSeverity } from '@aztec/stdlib/p2p';
|
|
13
14
|
import { DatabasePublicStateSource, MerkleTreeId } from '@aztec/stdlib/trees';
|
|
14
|
-
import type { Tx, TxValidationResult } from '@aztec/stdlib/tx';
|
|
15
|
+
import type { Tx, TxValidationResult, TxValidator } from '@aztec/stdlib/tx';
|
|
15
16
|
import type { UInt64 } from '@aztec/stdlib/types';
|
|
16
17
|
|
|
18
|
+
import { AggregateTxValidator } from './aggregate_tx_validator.js';
|
|
17
19
|
import { ArchiveCache } from './archive_cache.js';
|
|
18
20
|
import { BlockHeaderTxValidator } from './block_header_validator.js';
|
|
19
21
|
import { DataTxValidator } from './data_validator.js';
|
|
@@ -21,6 +23,7 @@ import { DoubleSpendTxValidator } from './double_spend_validator.js';
|
|
|
21
23
|
import { GasTxValidator } from './gas_validator.js';
|
|
22
24
|
import { MetadataTxValidator } from './metadata_validator.js';
|
|
23
25
|
import { PhasesTxValidator } from './phases_validator.js';
|
|
26
|
+
import { SizeTxValidator } from './size_validator.js';
|
|
24
27
|
import { TimestampTxValidator } from './timestamp_validator.js';
|
|
25
28
|
import { TxPermittedValidator } from './tx_permitted_validator.js';
|
|
26
29
|
import { TxProofValidator } from './tx_proof_validator.js';
|
|
@@ -44,43 +47,53 @@ export function createTxMessageValidators(
|
|
|
44
47
|
proofVerifier: ClientProtocolCircuitVerifier,
|
|
45
48
|
txsPermitted: boolean,
|
|
46
49
|
allowedInSetup: AllowedElement[] = [],
|
|
50
|
+
bindings?: LoggerBindings,
|
|
47
51
|
): Record<string, MessageValidator>[] {
|
|
48
52
|
const merkleTree = worldStateSynchronizer.getCommitted();
|
|
49
53
|
|
|
50
54
|
return [
|
|
51
55
|
{
|
|
52
56
|
txsPermittedValidator: {
|
|
53
|
-
validator: new TxPermittedValidator(txsPermitted),
|
|
57
|
+
validator: new TxPermittedValidator(txsPermitted, bindings),
|
|
54
58
|
severity: PeerErrorSeverity.MidToleranceError,
|
|
55
59
|
},
|
|
56
60
|
dataValidator: {
|
|
57
|
-
validator: new DataTxValidator(),
|
|
61
|
+
validator: new DataTxValidator(bindings),
|
|
58
62
|
severity: PeerErrorSeverity.HighToleranceError,
|
|
59
63
|
},
|
|
60
64
|
metadataValidator: {
|
|
61
|
-
validator: new MetadataTxValidator(
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
validator: new MetadataTxValidator(
|
|
66
|
+
{
|
|
67
|
+
l1ChainId: new Fr(l1ChainId),
|
|
68
|
+
rollupVersion: new Fr(rollupVersion),
|
|
69
|
+
protocolContractsHash,
|
|
70
|
+
vkTreeRoot: getVKTreeRoot(),
|
|
71
|
+
},
|
|
72
|
+
bindings,
|
|
73
|
+
),
|
|
67
74
|
severity: PeerErrorSeverity.HighToleranceError,
|
|
68
75
|
},
|
|
69
76
|
timestampValidator: {
|
|
70
|
-
validator: new TimestampTxValidator<Tx>(
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
77
|
+
validator: new TimestampTxValidator<Tx>(
|
|
78
|
+
{
|
|
79
|
+
timestamp,
|
|
80
|
+
blockNumber,
|
|
81
|
+
},
|
|
82
|
+
bindings,
|
|
83
|
+
),
|
|
74
84
|
severity: PeerErrorSeverity.MidToleranceError,
|
|
75
85
|
},
|
|
76
86
|
doubleSpendValidator: {
|
|
77
|
-
validator: new DoubleSpendTxValidator(
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
87
|
+
validator: new DoubleSpendTxValidator(
|
|
88
|
+
{
|
|
89
|
+
nullifiersExist: async (nullifiers: Buffer[]) => {
|
|
90
|
+
const merkleTree = worldStateSynchronizer.getCommitted();
|
|
91
|
+
const indices = await merkleTree.findLeafIndices(MerkleTreeId.NULLIFIER_TREE, nullifiers);
|
|
92
|
+
return indices.map(index => index !== undefined);
|
|
93
|
+
},
|
|
82
94
|
},
|
|
83
|
-
|
|
95
|
+
bindings,
|
|
96
|
+
),
|
|
84
97
|
severity: PeerErrorSeverity.HighToleranceError,
|
|
85
98
|
},
|
|
86
99
|
gasValidator: {
|
|
@@ -88,23 +101,51 @@ export function createTxMessageValidators(
|
|
|
88
101
|
new DatabasePublicStateSource(merkleTree),
|
|
89
102
|
ProtocolContractAddress.FeeJuice,
|
|
90
103
|
gasFees,
|
|
104
|
+
bindings,
|
|
91
105
|
),
|
|
92
106
|
severity: PeerErrorSeverity.HighToleranceError,
|
|
93
107
|
},
|
|
94
108
|
phasesValidator: {
|
|
95
|
-
validator: new PhasesTxValidator(contractDataSource, allowedInSetup, timestamp),
|
|
109
|
+
validator: new PhasesTxValidator(contractDataSource, allowedInSetup, timestamp, bindings),
|
|
96
110
|
severity: PeerErrorSeverity.MidToleranceError,
|
|
97
111
|
},
|
|
98
112
|
blockHeaderValidator: {
|
|
99
|
-
validator: new BlockHeaderTxValidator(new ArchiveCache(merkleTree)),
|
|
113
|
+
validator: new BlockHeaderTxValidator(new ArchiveCache(merkleTree), bindings),
|
|
100
114
|
severity: PeerErrorSeverity.HighToleranceError,
|
|
101
115
|
},
|
|
102
116
|
},
|
|
103
117
|
{
|
|
104
118
|
proofValidator: {
|
|
105
|
-
validator: new TxProofValidator(proofVerifier),
|
|
119
|
+
validator: new TxProofValidator(proofVerifier, bindings),
|
|
106
120
|
severity: PeerErrorSeverity.MidToleranceError,
|
|
107
121
|
},
|
|
108
122
|
},
|
|
109
123
|
];
|
|
110
124
|
}
|
|
125
|
+
|
|
126
|
+
export function createTxReqRespValidator(
|
|
127
|
+
verifier: ClientProtocolCircuitVerifier,
|
|
128
|
+
{
|
|
129
|
+
l1ChainId,
|
|
130
|
+
rollupVersion,
|
|
131
|
+
}: {
|
|
132
|
+
l1ChainId: number;
|
|
133
|
+
rollupVersion: number;
|
|
134
|
+
},
|
|
135
|
+
bindings?: LoggerBindings,
|
|
136
|
+
): TxValidator {
|
|
137
|
+
return new AggregateTxValidator(
|
|
138
|
+
new MetadataTxValidator(
|
|
139
|
+
{
|
|
140
|
+
l1ChainId: new Fr(l1ChainId),
|
|
141
|
+
rollupVersion: new Fr(rollupVersion),
|
|
142
|
+
protocolContractsHash,
|
|
143
|
+
vkTreeRoot: getVKTreeRoot(),
|
|
144
|
+
},
|
|
145
|
+
bindings,
|
|
146
|
+
),
|
|
147
|
+
new SizeTxValidator(bindings),
|
|
148
|
+
new DataTxValidator(bindings),
|
|
149
|
+
new TxProofValidator(verifier, bindings),
|
|
150
|
+
);
|
|
151
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AVM_MAX_PROCESSABLE_L2_GAS, FIXED_DA_GAS, FIXED_L2_GAS } from '@aztec/constants';
|
|
2
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
2
|
+
import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
|
|
3
3
|
import { computeFeePayerBalanceStorageSlot } from '@aztec/protocol-contracts/fee-juice';
|
|
4
4
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
5
|
import { Gas, GasFees } from '@aztec/stdlib/gas';
|
|
@@ -17,12 +17,18 @@ import {
|
|
|
17
17
|
import { getFeePayerClaimAmount, getTxFeeLimit } from './fee_payer_balance.js';
|
|
18
18
|
|
|
19
19
|
export class GasTxValidator implements TxValidator<Tx> {
|
|
20
|
-
#log
|
|
20
|
+
#log: Logger;
|
|
21
21
|
#publicDataSource: PublicStateSource;
|
|
22
22
|
#feeJuiceAddress: AztecAddress;
|
|
23
23
|
#gasFees: GasFees;
|
|
24
24
|
|
|
25
|
-
constructor(
|
|
25
|
+
constructor(
|
|
26
|
+
publicDataSource: PublicStateSource,
|
|
27
|
+
feeJuiceAddress: AztecAddress,
|
|
28
|
+
gasFees: GasFees,
|
|
29
|
+
bindings?: LoggerBindings,
|
|
30
|
+
) {
|
|
31
|
+
this.#log = createLogger('sequencer:tx_validator:tx_gas', bindings);
|
|
26
32
|
this.#publicDataSource = publicDataSource;
|
|
27
33
|
this.#feeJuiceAddress = feeJuiceAddress;
|
|
28
34
|
this.#gasFees = gasFees;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
2
|
+
import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
|
|
3
3
|
import {
|
|
4
4
|
type AnyTx,
|
|
5
5
|
TX_ERROR_INCORRECT_L1_CHAIN_ID,
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
} from '@aztec/stdlib/tx';
|
|
12
12
|
|
|
13
13
|
export class MetadataTxValidator<T extends AnyTx> implements TxValidator<T> {
|
|
14
|
-
#log
|
|
14
|
+
#log: Logger;
|
|
15
15
|
|
|
16
16
|
constructor(
|
|
17
17
|
private values: {
|
|
@@ -20,7 +20,10 @@ export class MetadataTxValidator<T extends AnyTx> implements TxValidator<T> {
|
|
|
20
20
|
vkTreeRoot: Fr;
|
|
21
21
|
protocolContractsHash: Fr;
|
|
22
22
|
},
|
|
23
|
-
|
|
23
|
+
bindings?: LoggerBindings,
|
|
24
|
+
) {
|
|
25
|
+
this.#log = createLogger('p2p:tx_validator:tx_metadata', bindings);
|
|
26
|
+
}
|
|
24
27
|
|
|
25
28
|
validateTx(tx: T): Promise<TxValidationResult> {
|
|
26
29
|
const errors = [];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
1
|
+
import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
|
|
2
2
|
import { PublicContractsDB, getCallRequestsWithCalldataByPhase } from '@aztec/simulator/server';
|
|
3
3
|
import type { ContractDataSource } from '@aztec/stdlib/contract';
|
|
4
4
|
import type { AllowedElement } from '@aztec/stdlib/interfaces/server';
|
|
@@ -14,15 +14,17 @@ import {
|
|
|
14
14
|
import type { UInt64 } from '@aztec/stdlib/types';
|
|
15
15
|
|
|
16
16
|
export class PhasesTxValidator implements TxValidator<Tx> {
|
|
17
|
-
#log
|
|
17
|
+
#log: Logger;
|
|
18
18
|
private contractsDB: PublicContractsDB;
|
|
19
19
|
|
|
20
20
|
constructor(
|
|
21
21
|
contracts: ContractDataSource,
|
|
22
22
|
private setupAllowList: AllowedElement[],
|
|
23
23
|
private timestamp: UInt64,
|
|
24
|
+
bindings?: LoggerBindings,
|
|
24
25
|
) {
|
|
25
|
-
this
|
|
26
|
+
this.#log = createLogger('sequencer:tx_validator:tx_phases', bindings);
|
|
27
|
+
this.contractsDB = new PublicContractsDB(contracts, bindings);
|
|
26
28
|
}
|
|
27
29
|
|
|
28
30
|
async validateTx(tx: Tx): Promise<TxValidationResult> {
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
|
|
2
|
+
import { MAX_TX_SIZE_KB } from '@aztec/stdlib/p2p';
|
|
3
|
+
import { Tx, type TxValidationResult, type TxValidator } from '@aztec/stdlib/tx';
|
|
4
|
+
|
|
5
|
+
export class SizeTxValidator implements TxValidator<Tx> {
|
|
6
|
+
#log: Logger;
|
|
7
|
+
|
|
8
|
+
constructor(bindings?: LoggerBindings) {
|
|
9
|
+
this.#log = createLogger('p2p:tx_validator:tx_size', bindings);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
validateTx(tx: Tx): Promise<TxValidationResult> {
|
|
13
|
+
const txSize = tx.getSize();
|
|
14
|
+
if (txSize > MAX_TX_SIZE_KB * 1024) {
|
|
15
|
+
this.#log.verbose(
|
|
16
|
+
`Rejecting transaction ${tx.getTxHash().toString()}. Reason: size above size limit. ${txSize}bytes > ${MAX_TX_SIZE_KB}Kb`,
|
|
17
|
+
);
|
|
18
|
+
return Promise.resolve({ result: 'invalid', reason: ['Transaction size above size limit'] });
|
|
19
|
+
}
|
|
20
|
+
return Promise.resolve({ result: 'valid' });
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
2
|
+
import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
|
|
3
3
|
import {
|
|
4
4
|
type AnyTx,
|
|
5
5
|
TX_ERROR_INVALID_INCLUDE_BY_TIMESTAMP,
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
import type { UInt64 } from '@aztec/stdlib/types';
|
|
11
11
|
|
|
12
12
|
export class TimestampTxValidator<T extends AnyTx> implements TxValidator<T> {
|
|
13
|
-
#log
|
|
13
|
+
#log: Logger;
|
|
14
14
|
|
|
15
15
|
constructor(
|
|
16
16
|
private values: {
|
|
@@ -20,7 +20,10 @@ export class TimestampTxValidator<T extends AnyTx> implements TxValidator<T> {
|
|
|
20
20
|
// Block number in which the tx is considered to be included.
|
|
21
21
|
blockNumber: BlockNumber;
|
|
22
22
|
},
|
|
23
|
-
|
|
23
|
+
bindings?: LoggerBindings,
|
|
24
|
+
) {
|
|
25
|
+
this.#log = createLogger('p2p:tx_validator:timestamp', bindings);
|
|
26
|
+
}
|
|
24
27
|
|
|
25
28
|
validateTx(tx: T): Promise<TxValidationResult> {
|
|
26
29
|
const includeByTimestamp = tx.data.includeByTimestamp;
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
1
|
+
import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
|
|
2
2
|
import type { Tx, TxValidationResult, TxValidator } from '@aztec/stdlib/tx';
|
|
3
3
|
|
|
4
4
|
export class TxPermittedValidator implements TxValidator<Tx> {
|
|
5
|
-
#log
|
|
5
|
+
#log: Logger;
|
|
6
6
|
|
|
7
|
-
constructor(
|
|
7
|
+
constructor(
|
|
8
|
+
private permitted: boolean,
|
|
9
|
+
bindings?: LoggerBindings,
|
|
10
|
+
) {
|
|
11
|
+
this.#log = createLogger('p2p:tx_validator:tx_permitted', bindings);
|
|
12
|
+
}
|
|
8
13
|
|
|
9
14
|
validateTx(tx: Tx): Promise<TxValidationResult> {
|
|
10
15
|
if (!this.permitted) {
|
|
@@ -1,11 +1,16 @@
|
|
|
1
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
1
|
+
import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
|
|
2
2
|
import type { ClientProtocolCircuitVerifier } from '@aztec/stdlib/interfaces/server';
|
|
3
3
|
import { TX_ERROR_INVALID_PROOF, Tx, type TxValidationResult, type TxValidator } from '@aztec/stdlib/tx';
|
|
4
4
|
|
|
5
5
|
export class TxProofValidator implements TxValidator<Tx> {
|
|
6
|
-
#log
|
|
6
|
+
#log: Logger;
|
|
7
7
|
|
|
8
|
-
constructor(
|
|
8
|
+
constructor(
|
|
9
|
+
private verifier: ClientProtocolCircuitVerifier,
|
|
10
|
+
bindings?: LoggerBindings,
|
|
11
|
+
) {
|
|
12
|
+
this.#log = createLogger('p2p:tx_validator:proof', bindings);
|
|
13
|
+
}
|
|
9
14
|
|
|
10
15
|
async validateTx(tx: Tx): Promise<TxValidationResult> {
|
|
11
16
|
const result = await this.verifier.verifyProof(tx);
|
|
@@ -24,6 +24,7 @@ class KeyNotFoundError extends Error {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
export class AztecDatastore implements Datastore {
|
|
27
|
+
#db: AztecAsyncKVStore;
|
|
27
28
|
#memoryDatastore: Map<string, MemoryItem>;
|
|
28
29
|
#dbDatastore: AztecAsyncMap<string, Uint8Array>;
|
|
29
30
|
|
|
@@ -32,9 +33,9 @@ export class AztecDatastore implements Datastore {
|
|
|
32
33
|
private maxMemoryItems: number;
|
|
33
34
|
|
|
34
35
|
constructor(db: AztecAsyncKVStore, { maxMemoryItems } = { maxMemoryItems: 50 }) {
|
|
36
|
+
this.#db = db;
|
|
35
37
|
this.#memoryDatastore = new Map();
|
|
36
38
|
this.#dbDatastore = db.openMap('p2p_datastore');
|
|
37
|
-
|
|
38
39
|
this.maxMemoryItems = maxMemoryItems;
|
|
39
40
|
}
|
|
40
41
|
|
|
@@ -106,13 +107,15 @@ export class AztecDatastore implements Datastore {
|
|
|
106
107
|
});
|
|
107
108
|
},
|
|
108
109
|
commit: async () => {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
110
|
+
await this.#db.transactionAsync(async () => {
|
|
111
|
+
for (const op of this.#batchOps) {
|
|
112
|
+
if (op.type === 'put' && op.value) {
|
|
113
|
+
await this.put(op.key, op.value);
|
|
114
|
+
} else if (op.type === 'del') {
|
|
115
|
+
await this.delete(op.key);
|
|
116
|
+
}
|
|
114
117
|
}
|
|
115
|
-
}
|
|
118
|
+
});
|
|
116
119
|
this.#batchOps = []; // Clear operations after commit
|
|
117
120
|
},
|
|
118
121
|
};
|
|
@@ -87,7 +87,7 @@ export class DiscV5Service extends EventEmitter implements PeerDiscoveryService
|
|
|
87
87
|
this.packageVersion,
|
|
88
88
|
));
|
|
89
89
|
|
|
90
|
-
const metricsRegistry = new OtelMetricsAdapter(telemetry);
|
|
90
|
+
const metricsRegistry = new OtelMetricsAdapter(telemetry, this.logger.getBindings());
|
|
91
91
|
this.discv5 = Discv5.create({
|
|
92
92
|
enr: this.enr,
|
|
93
93
|
peerId,
|
|
@@ -8,7 +8,9 @@ import type { ENR } from '@nethermindeth/enr';
|
|
|
8
8
|
import EventEmitter from 'events';
|
|
9
9
|
|
|
10
10
|
import type { PeerManagerInterface } from './peer-manager/interface.js';
|
|
11
|
+
import type { BatchTxRequesterLibP2PService } from './reqresp/batch-tx-requester/interface.js';
|
|
11
12
|
import type { P2PReqRespConfig } from './reqresp/config.js';
|
|
13
|
+
import type { ConnectionSampler } from './reqresp/connection-sampler/connection_sampler.js';
|
|
12
14
|
import { type AuthRequest, StatusMessage } from './reqresp/index.js';
|
|
13
15
|
import type {
|
|
14
16
|
ReqRespInterface,
|
|
@@ -106,6 +108,15 @@ export class DummyP2PService implements P2PService {
|
|
|
106
108
|
return Promise.resolve([]);
|
|
107
109
|
}
|
|
108
110
|
|
|
111
|
+
public sendRequestToPeer(
|
|
112
|
+
_peerId: PeerId,
|
|
113
|
+
_subProtocol: ReqRespSubProtocol,
|
|
114
|
+
_payload: Buffer,
|
|
115
|
+
_dialTimeout?: number,
|
|
116
|
+
): Promise<ReqRespResponse> {
|
|
117
|
+
return Promise.resolve({ status: ReqRespStatus.SUCCESS, data: Buffer.from([]) });
|
|
118
|
+
}
|
|
119
|
+
|
|
109
120
|
/**
|
|
110
121
|
* Returns the ENR of the peer.
|
|
111
122
|
* @returns The ENR of the peer, otherwise undefined.
|
|
@@ -118,6 +129,10 @@ export class DummyP2PService implements P2PService {
|
|
|
118
129
|
return Promise.resolve();
|
|
119
130
|
}
|
|
120
131
|
|
|
132
|
+
validatePropagatedTx(_tx: Tx, _peerId: PeerId): Promise<boolean> {
|
|
133
|
+
return Promise.resolve(true);
|
|
134
|
+
}
|
|
135
|
+
|
|
121
136
|
addReqRespSubProtocol(
|
|
122
137
|
_subProtocol: ReqRespSubProtocol,
|
|
123
138
|
_handler: ReqRespSubProtocolHandler,
|
|
@@ -132,6 +147,27 @@ export class DummyP2PService implements P2PService {
|
|
|
132
147
|
|
|
133
148
|
//this is no-op
|
|
134
149
|
registerThisValidatorAddresses(_address: EthAddress[]): void {}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Get dummy BatchTxRequesterLibP2PService for testing
|
|
153
|
+
*/
|
|
154
|
+
getBatchTxRequesterService(): BatchTxRequesterLibP2PService {
|
|
155
|
+
return {
|
|
156
|
+
reqResp: this, // The dummy service implements ReqRespInterface
|
|
157
|
+
connectionSampler: new DummyReqResp().getConnectionSampler(),
|
|
158
|
+
txValidatorConfig: {
|
|
159
|
+
l1ChainId: 1,
|
|
160
|
+
rollupVersion: 1,
|
|
161
|
+
proofVerifier: {
|
|
162
|
+
verifyProof: () => Promise.resolve({ valid: true, durationMs: 0, totalDurationMs: 0 }),
|
|
163
|
+
stop: () => Promise.resolve(),
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
peerScoring: {
|
|
167
|
+
penalizePeer: (_peerId, _penalty) => {},
|
|
168
|
+
},
|
|
169
|
+
};
|
|
170
|
+
}
|
|
135
171
|
}
|
|
136
172
|
|
|
137
173
|
/**
|
|
@@ -268,6 +304,15 @@ export class DummyReqResp implements ReqRespInterface {
|
|
|
268
304
|
return Promise.resolve({ status: ReqRespStatus.SUCCESS, data: Buffer.from([]) });
|
|
269
305
|
}
|
|
270
306
|
|
|
307
|
+
/**
|
|
308
|
+
* Get dummy connection sampler for testing
|
|
309
|
+
*/
|
|
310
|
+
getConnectionSampler(): Pick<ConnectionSampler, 'getPeerListSortedByConnectionCountAsc'> {
|
|
311
|
+
return {
|
|
312
|
+
getPeerListSortedByConnectionCountAsc: () => [],
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
|
|
271
316
|
addSubProtocol(
|
|
272
317
|
_subProtocol: ReqRespSubProtocol,
|
|
273
318
|
_handler: ReqRespSubProtocolHandler,
|
package/src/services/encoding.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Taken from lodestar: https://github.com/ChainSafe/lodestar
|
|
2
2
|
import { sha256 } from '@aztec/foundation/crypto/sha256';
|
|
3
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
|
-
import { TopicType, getTopicFromString } from '@aztec/stdlib/p2p';
|
|
4
|
+
import { MAX_TX_SIZE_KB, TopicType, getTopicFromString } from '@aztec/stdlib/p2p';
|
|
5
5
|
|
|
6
6
|
import type { RPC } from '@chainsafe/libp2p-gossipsub/message';
|
|
7
7
|
import type { DataTransform } from '@chainsafe/libp2p-gossipsub/types';
|
|
@@ -52,8 +52,7 @@ export function getMsgIdFn(message: Message) {
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
const DefaultMaxSizesKb: Record<TopicType, number> = {
|
|
55
|
-
|
|
56
|
-
[TopicType.tx]: 512,
|
|
55
|
+
[TopicType.tx]: MAX_TX_SIZE_KB,
|
|
57
56
|
// An attestation has roughly 30 fields, which is 1kb, so 5x is plenty
|
|
58
57
|
[TopicType.checkpoint_attestation]: 5,
|
|
59
58
|
// Proposals may carry some tx objects, so we allow a larger size capped at 10mb
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
type ObservableGauge,
|
|
9
9
|
type TelemetryClient,
|
|
10
10
|
type UpDownCounter,
|
|
11
|
+
createUpDownCounterWithDefault,
|
|
11
12
|
} from '@aztec/telemetry-client';
|
|
12
13
|
|
|
13
14
|
import { type RecordableHistogram, createHistogram } from 'node:perf_hooks';
|
|
@@ -29,11 +30,23 @@ export class P2PInstrumentation {
|
|
|
29
30
|
|
|
30
31
|
this.messageValidationDuration = meter.createHistogram(Metrics.P2P_GOSSIP_MESSAGE_VALIDATION_DURATION);
|
|
31
32
|
|
|
32
|
-
this.messagePrevalidationCount =
|
|
33
|
+
this.messagePrevalidationCount = createUpDownCounterWithDefault(
|
|
34
|
+
meter,
|
|
35
|
+
Metrics.P2P_GOSSIP_MESSAGE_PREVALIDATION_COUNT,
|
|
36
|
+
{
|
|
37
|
+
[Attributes.TOPIC_NAME]: [
|
|
38
|
+
TopicType.tx,
|
|
39
|
+
TopicType.block_proposal,
|
|
40
|
+
TopicType.checkpoint_proposal,
|
|
41
|
+
TopicType.checkpoint_attestation,
|
|
42
|
+
],
|
|
43
|
+
[Attributes.OK]: [true, false],
|
|
44
|
+
},
|
|
45
|
+
);
|
|
33
46
|
|
|
34
47
|
this.messageLatency = meter.createHistogram(Metrics.P2P_GOSSIP_MESSAGE_LATENCY);
|
|
35
48
|
|
|
36
|
-
this.txReceivedCount = meter
|
|
49
|
+
this.txReceivedCount = createUpDownCounterWithDefault(meter, Metrics.P2P_GOSSIP_TX_RECEIVED_COUNT);
|
|
37
50
|
|
|
38
51
|
this.aggLatencyMetrics = {
|
|
39
52
|
avg: meter.createObservableGauge(Metrics.P2P_GOSSIP_AGG_MESSAGE_LATENCY_AVG),
|