@aztec/p2p 0.0.1-commit.e3c1de76 → 0.0.1-commit.e558bd1c
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/client/factory.d.ts +3 -3
- package/dest/client/factory.d.ts.map +1 -1
- package/dest/client/factory.js +5 -3
- package/dest/client/interface.d.ts +9 -2
- package/dest/client/interface.d.ts.map +1 -1
- package/dest/client/p2p_client.d.ts +7 -4
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +22 -7
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.js +1 -1
- package/dest/config.d.ts +9 -3
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +3 -1
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts +94 -87
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool.js +411 -3
- package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts +2 -2
- package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.js +351 -85
- package/dest/mem_pools/attestation_pool/index.d.ts +2 -3
- package/dest/mem_pools/attestation_pool/index.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/index.js +1 -2
- package/dest/mem_pools/index.d.ts +2 -2
- package/dest/mem_pools/index.d.ts.map +1 -1
- package/dest/mem_pools/index.js +1 -1
- package/dest/mem_pools/interface.d.ts +3 -3
- package/dest/mem_pools/interface.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/archive/index.d.ts +2 -0
- package/dest/mem_pools/tx_pool_v2/archive/index.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/archive/index.js +1 -0
- package/dest/mem_pools/tx_pool_v2/archive/tx_archive.d.ts +43 -0
- package/dest/mem_pools/tx_pool_v2/archive/tx_archive.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/archive/tx_archive.js +103 -0
- package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.d.ts +47 -0
- package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.js +119 -0
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts +17 -0
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.js +90 -0
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts +19 -0
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.js +89 -0
- package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts +10 -0
- package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/index.js +11 -0
- package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts +131 -0
- package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/interfaces.js +17 -0
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.d.ts +15 -0
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.js +63 -0
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.d.ts +17 -0
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.js +91 -0
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts +16 -0
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.js +70 -0
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts +20 -0
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.js +63 -0
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts +15 -0
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.js +19 -0
- package/dest/mem_pools/tx_pool_v2/index.d.ts +5 -0
- package/dest/mem_pools/tx_pool_v2/index.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/index.js +4 -0
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts +197 -0
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/interfaces.js +6 -0
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts +71 -0
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/tx_metadata.js +95 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_bench_metrics.d.ts +26 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_bench_metrics.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_bench_metrics.js +70 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts +99 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.js +332 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts +55 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.js +156 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts +69 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.js +748 -0
- 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/services/dummy_service.d.ts +6 -2
- package/dest/services/dummy_service.d.ts.map +1 -1
- package/dest/services/dummy_service.js +3 -0
- package/dest/services/index.d.ts +2 -1
- package/dest/services/index.d.ts.map +1 -1
- package/dest/services/index.js +1 -0
- package/dest/services/libp2p/libp2p_service.d.ts +74 -33
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +299 -228
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts +4 -4
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.js +8 -8
- package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts +6 -4
- 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 -11
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts +15 -10
- 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 +12 -11
- package/dest/services/service.d.ts +18 -1
- package/dest/services/service.d.ts.map +1 -1
- package/dest/services/tx_collection/config.d.ts +3 -3
- package/dest/services/tx_collection/config.js +3 -3
- package/dest/services/tx_collection/fast_tx_collection.d.ts +4 -5
- package/dest/services/tx_collection/fast_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/fast_tx_collection.js +10 -14
- package/dest/services/tx_collection/index.d.ts +1 -1
- package/dest/services/tx_collection/proposal_tx_collector.d.ts +12 -12
- package/dest/services/tx_collection/proposal_tx_collector.d.ts.map +1 -1
- package/dest/services/tx_collection/proposal_tx_collector.js +4 -5
- package/dest/services/tx_file_store/config.d.ts +18 -0
- package/dest/services/tx_file_store/config.d.ts.map +1 -0
- package/dest/services/tx_file_store/config.js +26 -0
- package/dest/services/tx_file_store/index.d.ts +4 -0
- package/dest/services/tx_file_store/index.d.ts.map +1 -0
- package/dest/services/tx_file_store/index.js +3 -0
- package/dest/services/tx_file_store/instrumentation.d.ts +15 -0
- package/dest/services/tx_file_store/instrumentation.d.ts.map +1 -0
- package/dest/services/tx_file_store/instrumentation.js +29 -0
- package/dest/services/tx_file_store/tx_file_store.d.ts +47 -0
- package/dest/services/tx_file_store/tx_file_store.d.ts.map +1 -0
- package/dest/services/tx_file_store/tx_file_store.js +149 -0
- package/dest/test-helpers/testbench-utils.d.ts +10 -16
- package/dest/test-helpers/testbench-utils.d.ts.map +1 -1
- package/dest/test-helpers/testbench-utils.js +32 -30
- package/dest/testbench/p2p_client_testbench_worker.js +1 -1
- package/package.json +14 -14
- package/src/client/factory.ts +7 -4
- package/src/client/interface.ts +13 -1
- package/src/client/p2p_client.ts +30 -8
- package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +1 -1
- package/src/config.ts +8 -1
- package/src/mem_pools/attestation_pool/attestation_pool.ts +444 -90
- package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +436 -100
- package/src/mem_pools/attestation_pool/index.ts +9 -2
- package/src/mem_pools/index.ts +1 -1
- package/src/mem_pools/interface.ts +2 -2
- package/src/mem_pools/tx_pool_v2/README.md +209 -0
- package/src/mem_pools/tx_pool_v2/archive/index.ts +1 -0
- package/src/mem_pools/tx_pool_v2/archive/tx_archive.ts +120 -0
- package/src/mem_pools/tx_pool_v2/eviction/eviction_manager.ts +147 -0
- package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.ts +118 -0
- package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.ts +111 -0
- package/src/mem_pools/tx_pool_v2/eviction/index.ts +23 -0
- package/src/mem_pools/tx_pool_v2/eviction/interfaces.ts +164 -0
- package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.ts +74 -0
- package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.ts +101 -0
- package/src/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.ts +86 -0
- package/src/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.ts +72 -0
- package/src/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.ts +31 -0
- package/src/mem_pools/tx_pool_v2/index.ts +11 -0
- package/src/mem_pools/tx_pool_v2/interfaces.ts +227 -0
- package/src/mem_pools/tx_pool_v2/tx_metadata.ts +161 -0
- package/src/mem_pools/tx_pool_v2/tx_pool_bench_metrics.ts +77 -0
- package/src/mem_pools/tx_pool_v2/tx_pool_indices.ts +417 -0
- package/src/mem_pools/tx_pool_v2/tx_pool_v2.ts +212 -0
- package/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +882 -0
- package/src/msg_validators/attestation_validator/fisherman_attestation_validator.ts +2 -2
- package/src/services/dummy_service.ts +6 -0
- package/src/services/index.ts +1 -0
- package/src/services/libp2p/libp2p_service.ts +304 -230
- package/src/services/reqresp/batch-tx-requester/README.md +7 -7
- package/src/services/reqresp/batch-tx-requester/batch_tx_requester.ts +11 -11
- package/src/services/reqresp/protocols/block_txs/block_txs_handler.ts +22 -13
- package/src/services/reqresp/protocols/block_txs/block_txs_reqresp.ts +21 -15
- package/src/services/service.ts +20 -0
- package/src/services/tx_collection/config.ts +6 -6
- package/src/services/tx_collection/fast_tx_collection.ts +14 -24
- package/src/services/tx_collection/index.ts +1 -1
- package/src/services/tx_collection/proposal_tx_collector.ts +12 -14
- package/src/services/tx_file_store/config.ts +43 -0
- package/src/services/tx_file_store/index.ts +3 -0
- package/src/services/tx_file_store/instrumentation.ts +36 -0
- package/src/services/tx_file_store/tx_file_store.ts +173 -0
- package/src/test-helpers/testbench-utils.ts +18 -39
- package/src/testbench/p2p_client_testbench_worker.ts +1 -1
- package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts +0 -40
- package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts.map +0 -1
- package/dest/mem_pools/attestation_pool/kv_attestation_pool.js +0 -218
- package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts +0 -31
- package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts.map +0 -1
- package/dest/mem_pools/attestation_pool/memory_attestation_pool.js +0 -180
- package/src/mem_pools/attestation_pool/kv_attestation_pool.ts +0 -320
- package/src/mem_pools/attestation_pool/memory_attestation_pool.ts +0 -264
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/p2p",
|
|
3
|
-
"version": "0.0.1-commit.
|
|
3
|
+
"version": "0.0.1-commit.e558bd1c",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/index.js",
|
|
@@ -67,17 +67,17 @@
|
|
|
67
67
|
]
|
|
68
68
|
},
|
|
69
69
|
"dependencies": {
|
|
70
|
-
"@aztec/constants": "0.0.1-commit.
|
|
71
|
-
"@aztec/epoch-cache": "0.0.1-commit.
|
|
72
|
-
"@aztec/ethereum": "0.0.1-commit.
|
|
73
|
-
"@aztec/foundation": "0.0.1-commit.
|
|
74
|
-
"@aztec/kv-store": "0.0.1-commit.
|
|
75
|
-
"@aztec/noir-contracts.js": "0.0.1-commit.
|
|
76
|
-
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.
|
|
77
|
-
"@aztec/protocol-contracts": "0.0.1-commit.
|
|
78
|
-
"@aztec/simulator": "0.0.1-commit.
|
|
79
|
-
"@aztec/stdlib": "0.0.1-commit.
|
|
80
|
-
"@aztec/telemetry-client": "0.0.1-commit.
|
|
70
|
+
"@aztec/constants": "0.0.1-commit.e558bd1c",
|
|
71
|
+
"@aztec/epoch-cache": "0.0.1-commit.e558bd1c",
|
|
72
|
+
"@aztec/ethereum": "0.0.1-commit.e558bd1c",
|
|
73
|
+
"@aztec/foundation": "0.0.1-commit.e558bd1c",
|
|
74
|
+
"@aztec/kv-store": "0.0.1-commit.e558bd1c",
|
|
75
|
+
"@aztec/noir-contracts.js": "0.0.1-commit.e558bd1c",
|
|
76
|
+
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.e558bd1c",
|
|
77
|
+
"@aztec/protocol-contracts": "0.0.1-commit.e558bd1c",
|
|
78
|
+
"@aztec/simulator": "0.0.1-commit.e558bd1c",
|
|
79
|
+
"@aztec/stdlib": "0.0.1-commit.e558bd1c",
|
|
80
|
+
"@aztec/telemetry-client": "0.0.1-commit.e558bd1c",
|
|
81
81
|
"@chainsafe/libp2p-gossipsub": "13.0.0",
|
|
82
82
|
"@chainsafe/libp2p-noise": "^15.0.0",
|
|
83
83
|
"@chainsafe/libp2p-yamux": "^6.0.2",
|
|
@@ -104,8 +104,8 @@
|
|
|
104
104
|
"xxhash-wasm": "^1.1.0"
|
|
105
105
|
},
|
|
106
106
|
"devDependencies": {
|
|
107
|
-
"@aztec/archiver": "0.0.1-commit.
|
|
108
|
-
"@aztec/world-state": "0.0.1-commit.
|
|
107
|
+
"@aztec/archiver": "0.0.1-commit.e558bd1c",
|
|
108
|
+
"@aztec/world-state": "0.0.1-commit.e558bd1c",
|
|
109
109
|
"@jest/globals": "^30.0.0",
|
|
110
110
|
"@types/jest": "^30.0.0",
|
|
111
111
|
"@types/node": "^22.15.17",
|
package/src/client/factory.ts
CHANGED
|
@@ -13,20 +13,20 @@ import { type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-clien
|
|
|
13
13
|
|
|
14
14
|
import { P2PClient } from '../client/p2p_client.js';
|
|
15
15
|
import type { P2PConfig } from '../config.js';
|
|
16
|
-
import
|
|
17
|
-
import { KvAttestationPool } from '../mem_pools/attestation_pool/kv_attestation_pool.js';
|
|
16
|
+
import { AttestationPool, type AttestationPoolApi } from '../mem_pools/attestation_pool/attestation_pool.js';
|
|
18
17
|
import type { MemPools } from '../mem_pools/interface.js';
|
|
19
18
|
import { AztecKVTxPool, type TxPool } from '../mem_pools/tx_pool/index.js';
|
|
20
19
|
import { DummyP2PService } from '../services/dummy_service.js';
|
|
21
20
|
import { LibP2PService } from '../services/index.js';
|
|
22
21
|
import { TxCollection } from '../services/tx_collection/tx_collection.js';
|
|
23
22
|
import { type TxSource, createNodeRpcTxSources } from '../services/tx_collection/tx_source.js';
|
|
23
|
+
import { TxFileStore } from '../services/tx_file_store/tx_file_store.js';
|
|
24
24
|
import { configureP2PClientAddresses, createLibP2PPeerIdFromPrivateKey, getPeerIdPrivateKey } from '../util.js';
|
|
25
25
|
|
|
26
26
|
export type P2PClientDeps<T extends P2PClientType> = {
|
|
27
27
|
txPool?: TxPool;
|
|
28
28
|
store?: AztecAsyncKVStore;
|
|
29
|
-
attestationPool?:
|
|
29
|
+
attestationPool?: AttestationPoolApi;
|
|
30
30
|
logger?: Logger;
|
|
31
31
|
txCollectionNodeSources?: TxSource[];
|
|
32
32
|
p2pServiceFactory?: (...args: Parameters<(typeof LibP2PService)['new']>) => Promise<LibP2PService<T>>;
|
|
@@ -76,7 +76,7 @@ export async function createP2PClient<T extends P2PClientType>(
|
|
|
76
76
|
maxPendingTxCount: config.maxPendingTxCount,
|
|
77
77
|
archivedTxLimit: config.archivedTxLimit,
|
|
78
78
|
}),
|
|
79
|
-
attestationPool: deps.attestationPool ?? new
|
|
79
|
+
attestationPool: deps.attestationPool ?? new AttestationPool(attestationStore, telemetry),
|
|
80
80
|
};
|
|
81
81
|
|
|
82
82
|
const p2pService = await createP2PService<T>(
|
|
@@ -116,6 +116,8 @@ export async function createP2PClient<T extends P2PClientType>(
|
|
|
116
116
|
logger.createChild('tx-collection'),
|
|
117
117
|
);
|
|
118
118
|
|
|
119
|
+
const txFileStore = await TxFileStore.create(mempools.txPool, config, logger.createChild('tx-file-store'), telemetry);
|
|
120
|
+
|
|
119
121
|
return new P2PClient(
|
|
120
122
|
clientType,
|
|
121
123
|
store,
|
|
@@ -123,6 +125,7 @@ export async function createP2PClient<T extends P2PClientType>(
|
|
|
123
125
|
mempools,
|
|
124
126
|
p2pService,
|
|
125
127
|
txCollection,
|
|
128
|
+
txFileStore,
|
|
126
129
|
config,
|
|
127
130
|
dateProvider,
|
|
128
131
|
telemetry,
|
package/src/client/interface.ts
CHANGED
|
@@ -13,7 +13,11 @@ import type {
|
|
|
13
13
|
ReqRespSubProtocolHandler,
|
|
14
14
|
ReqRespSubProtocolValidators,
|
|
15
15
|
} from '../services/reqresp/interface.js';
|
|
16
|
-
import type {
|
|
16
|
+
import type {
|
|
17
|
+
DuplicateProposalInfo,
|
|
18
|
+
P2PBlockReceivedCallback,
|
|
19
|
+
P2PCheckpointReceivedCallback,
|
|
20
|
+
} from '../services/service.js';
|
|
17
21
|
|
|
18
22
|
/**
|
|
19
23
|
* Enum defining the possible states of the p2p client.
|
|
@@ -78,6 +82,14 @@ export type P2P<T extends P2PClientType = P2PClientType.Full> = P2PApiFull<T> &
|
|
|
78
82
|
*/
|
|
79
83
|
registerCheckpointProposalHandler(callback: P2PCheckpointReceivedCallback): void;
|
|
80
84
|
|
|
85
|
+
/**
|
|
86
|
+
* Registers a callback invoked when a duplicate proposal is detected (equivocation).
|
|
87
|
+
* The callback is triggered on the first duplicate (when count goes from 1 to 2).
|
|
88
|
+
*
|
|
89
|
+
* @param callback - Function called with info about the duplicate proposal
|
|
90
|
+
*/
|
|
91
|
+
registerDuplicateProposalCallback(callback: (info: DuplicateProposalInfo) => void): void;
|
|
92
|
+
|
|
81
93
|
/**
|
|
82
94
|
* Request a list of transactions from another peer by their tx hashes.
|
|
83
95
|
* @param txHashes - Hashes of the txs to query.
|
package/src/client/p2p_client.ts
CHANGED
|
@@ -29,7 +29,7 @@ import type { PeerId } from '@libp2p/interface';
|
|
|
29
29
|
import type { ENR } from '@nethermindeth/enr';
|
|
30
30
|
|
|
31
31
|
import { type P2PConfig, getP2PDefaultConfig } from '../config.js';
|
|
32
|
-
import type {
|
|
32
|
+
import type { AttestationPoolApi } from '../mem_pools/attestation_pool/attestation_pool.js';
|
|
33
33
|
import type { MemPools } from '../mem_pools/interface.js';
|
|
34
34
|
import type { TxPool } from '../mem_pools/tx_pool/index.js';
|
|
35
35
|
import type { AuthRequest, StatusMessage } from '../services/index.js';
|
|
@@ -39,8 +39,14 @@ import {
|
|
|
39
39
|
type ReqRespSubProtocolValidators,
|
|
40
40
|
} from '../services/reqresp/interface.js';
|
|
41
41
|
import { chunkTxHashesRequest } from '../services/reqresp/protocols/tx.js';
|
|
42
|
-
import type {
|
|
42
|
+
import type {
|
|
43
|
+
DuplicateProposalInfo,
|
|
44
|
+
P2PBlockReceivedCallback,
|
|
45
|
+
P2PCheckpointReceivedCallback,
|
|
46
|
+
P2PService,
|
|
47
|
+
} from '../services/service.js';
|
|
43
48
|
import { TxCollection } from '../services/tx_collection/tx_collection.js';
|
|
49
|
+
import type { TxFileStore } from '../services/tx_file_store/tx_file_store.js';
|
|
44
50
|
import { TxProvider } from '../services/tx_provider.js';
|
|
45
51
|
import { type P2P, P2PClientState, type P2PSyncState } from './interface.js';
|
|
46
52
|
|
|
@@ -65,7 +71,7 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
65
71
|
private synchedLatestSlot: AztecAsyncSingleton<bigint>;
|
|
66
72
|
|
|
67
73
|
private txPool: TxPool;
|
|
68
|
-
private attestationPool:
|
|
74
|
+
private attestationPool: AttestationPoolApi;
|
|
69
75
|
|
|
70
76
|
private config: P2PConfig;
|
|
71
77
|
|
|
@@ -90,6 +96,7 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
90
96
|
mempools: MemPools,
|
|
91
97
|
private p2pService: P2PService,
|
|
92
98
|
private txCollection: TxCollection,
|
|
99
|
+
private txFileStore: TxFileStore | undefined,
|
|
93
100
|
config: Partial<P2PConfig> = {},
|
|
94
101
|
private _dateProvider: DateProvider = new DateProvider(),
|
|
95
102
|
private telemetry: TelemetryClient = getTelemetryClient(),
|
|
@@ -274,6 +281,7 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
274
281
|
|
|
275
282
|
this.blockStream!.start();
|
|
276
283
|
await this.txCollection.start();
|
|
284
|
+
this.txFileStore?.start();
|
|
277
285
|
return this.syncPromise;
|
|
278
286
|
}
|
|
279
287
|
|
|
@@ -306,6 +314,8 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
306
314
|
this.log.debug('Stopping p2p client...');
|
|
307
315
|
await tryStop(this.txCollection);
|
|
308
316
|
this.log.debug('Stopped tx collection service');
|
|
317
|
+
await this.txFileStore?.stop();
|
|
318
|
+
this.log.debug('Stopped tx file store');
|
|
309
319
|
await this.p2pService.stop();
|
|
310
320
|
this.log.debug('Stopped p2p service');
|
|
311
321
|
await this.blockStream?.stop();
|
|
@@ -329,7 +339,10 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
329
339
|
public async broadcastProposal(proposal: BlockProposal): Promise<void> {
|
|
330
340
|
this.log.verbose(`Broadcasting proposal for slot ${proposal.slotNumber} to peers`);
|
|
331
341
|
// Store our own proposal so we can respond to req/resp requests for it
|
|
332
|
-
await this.attestationPool.
|
|
342
|
+
const { totalForPosition } = await this.attestationPool.tryAddBlockProposal(proposal);
|
|
343
|
+
if (totalForPosition > 1) {
|
|
344
|
+
throw new Error(`Attempted to broadcast a duplicate block proposal for slot ${proposal.slotNumber}`);
|
|
345
|
+
}
|
|
333
346
|
return this.p2pService.propagate(proposal);
|
|
334
347
|
}
|
|
335
348
|
|
|
@@ -338,8 +351,13 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
338
351
|
[Attributes.BLOCK_ARCHIVE]: proposal.archive.toString(),
|
|
339
352
|
[Attributes.P2P_ID]: (await proposal.p2pMessageLoggingIdentifier()).toString(),
|
|
340
353
|
}))
|
|
341
|
-
public broadcastCheckpointProposal(proposal: CheckpointProposal): Promise<void> {
|
|
354
|
+
public async broadcastCheckpointProposal(proposal: CheckpointProposal): Promise<void> {
|
|
342
355
|
this.log.verbose(`Broadcasting checkpoint proposal for slot ${proposal.slotNumber} to peers`);
|
|
356
|
+
const blockProposal = proposal.getBlockProposal();
|
|
357
|
+
if (blockProposal) {
|
|
358
|
+
// Store our own last-block proposal so we can respond to req/resp requests for it.
|
|
359
|
+
await this.attestationPool.tryAddBlockProposal(blockProposal);
|
|
360
|
+
}
|
|
343
361
|
return this.p2pService.propagate(proposal);
|
|
344
362
|
}
|
|
345
363
|
|
|
@@ -357,8 +375,8 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
357
375
|
: this.attestationPool.getCheckpointAttestationsForSlot(slot));
|
|
358
376
|
}
|
|
359
377
|
|
|
360
|
-
public
|
|
361
|
-
return this.attestationPool.
|
|
378
|
+
public addOwnCheckpointAttestations(attestations: CheckpointAttestation[]): Promise<void> {
|
|
379
|
+
return this.attestationPool.addOwnCheckpointAttestations(attestations);
|
|
362
380
|
}
|
|
363
381
|
|
|
364
382
|
// REVIEW: https://github.com/AztecProtocol/aztec-packages/issues/7963
|
|
@@ -371,6 +389,10 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
371
389
|
this.p2pService.registerCheckpointReceivedCallback(handler);
|
|
372
390
|
}
|
|
373
391
|
|
|
392
|
+
public registerDuplicateProposalCallback(callback: (info: DuplicateProposalInfo) => void): void {
|
|
393
|
+
this.p2pService.registerDuplicateProposalCallback(callback);
|
|
394
|
+
}
|
|
395
|
+
|
|
374
396
|
/**
|
|
375
397
|
* Uses the batched Request Response protocol to request a set of transactions from the network.
|
|
376
398
|
*/
|
|
@@ -735,7 +757,7 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
735
757
|
await this.txPool.deleteTxs(txHashes, { permanently: true });
|
|
736
758
|
await this.txPool.cleanupDeletedMinedTxs(lastBlockNum);
|
|
737
759
|
|
|
738
|
-
await this.attestationPool.
|
|
760
|
+
await this.attestationPool.deleteOlderThan(lastBlockSlot);
|
|
739
761
|
|
|
740
762
|
this.log.debug(`Synched to finalized block ${lastBlockNum} at slot ${lastBlockSlot}`);
|
|
741
763
|
}
|
|
@@ -301,7 +301,7 @@ process.on('message', (msg: WorkerCommand) => {
|
|
|
301
301
|
throw new Error('Attestation pool not initialized');
|
|
302
302
|
}
|
|
303
303
|
const proposal = deserializeBlockProposal(msg.blockProposal);
|
|
304
|
-
await attestationPool.
|
|
304
|
+
await attestationPool.tryAddBlockProposal(proposal);
|
|
305
305
|
await sendMessage({ type: 'BLOCK_PROPOSAL_SET', requestId, archiveRoot: proposal.archive.toString() });
|
|
306
306
|
break;
|
|
307
307
|
}
|
package/src/config.ts
CHANGED
|
@@ -21,11 +21,17 @@ import {
|
|
|
21
21
|
} from './services/reqresp/batch-tx-requester/config.js';
|
|
22
22
|
import { type P2PReqRespConfig, p2pReqRespConfigMappings } from './services/reqresp/config.js';
|
|
23
23
|
import { type TxCollectionConfig, txCollectionConfigMappings } from './services/tx_collection/config.js';
|
|
24
|
+
import { type TxFileStoreConfig, txFileStoreConfigMappings } from './services/tx_file_store/config.js';
|
|
24
25
|
|
|
25
26
|
/**
|
|
26
27
|
* P2P client configuration values.
|
|
27
28
|
*/
|
|
28
|
-
export interface P2PConfig
|
|
29
|
+
export interface P2PConfig
|
|
30
|
+
extends P2PReqRespConfig,
|
|
31
|
+
BatchTxRequesterConfig,
|
|
32
|
+
ChainConfig,
|
|
33
|
+
TxCollectionConfig,
|
|
34
|
+
TxFileStoreConfig {
|
|
29
35
|
/** A flag dictating whether the P2P subsystem should be enabled. */
|
|
30
36
|
p2pEnabled: boolean;
|
|
31
37
|
|
|
@@ -439,6 +445,7 @@ export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
|
|
|
439
445
|
...batchTxRequesterConfigMappings,
|
|
440
446
|
...chainConfigMappings,
|
|
441
447
|
...txCollectionConfigMappings,
|
|
448
|
+
...txFileStoreConfigMappings,
|
|
442
449
|
};
|
|
443
450
|
|
|
444
451
|
/**
|