@aztec/p2p 0.70.0 → 0.72.1
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.map +1 -1
- package/dest/client/factory.js +6 -5
- package/dest/client/p2p_client.d.ts +16 -2
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +22 -12
- package/dest/config.d.ts +3 -0
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +6 -1
- package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts +1 -1
- package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/kv_attestation_pool.js +3 -2
- package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts +1 -1
- package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/memory_attestation_pool.js +3 -2
- package/dest/mem_pools/attestation_pool/mocks.d.ts +2 -1
- package/dest/mem_pools/attestation_pool/mocks.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/mocks.js +1 -1
- package/dest/mem_pools/epoch_proof_quote_pool/memory_epoch_proof_quote_pool.d.ts +1 -1
- package/dest/mem_pools/epoch_proof_quote_pool/memory_epoch_proof_quote_pool.d.ts.map +1 -1
- package/dest/mem_pools/epoch_proof_quote_pool/memory_epoch_proof_quote_pool.js +3 -2
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts +20 -5
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.js +72 -9
- package/dest/mem_pools/tx_pool/memory_tx_pool.d.ts +2 -1
- package/dest/mem_pools/tx_pool/memory_tx_pool.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/memory_tx_pool.js +6 -2
- package/dest/mem_pools/tx_pool/tx_pool.d.ts +6 -0
- package/dest/mem_pools/tx_pool/tx_pool.d.ts.map +1 -1
- package/dest/mocks/index.d.ts +3 -3
- package/dest/mocks/index.d.ts.map +1 -1
- package/dest/mocks/index.js +22 -21
- package/dest/services/discv5/discV5_service.d.ts +1 -1
- package/dest/services/discv5/discV5_service.d.ts.map +1 -1
- package/dest/services/discv5/discV5_service.js +3 -3
- package/dest/services/dummy_service.d.ts +7 -0
- package/dest/services/dummy_service.d.ts.map +1 -1
- package/dest/services/dummy_service.js +10 -1
- package/dest/services/libp2p/libp2p_service.d.ts +17 -13
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +109 -101
- package/dest/services/peer-manager/metrics.d.ts +12 -0
- package/dest/services/peer-manager/metrics.d.ts.map +1 -0
- package/dest/services/peer-manager/metrics.js +26 -0
- package/dest/services/{peer_manager.d.ts → peer-manager/peer_manager.d.ts} +23 -8
- package/dest/services/peer-manager/peer_manager.d.ts.map +1 -0
- package/dest/services/peer-manager/peer_manager.js +392 -0
- package/dest/services/{peer-scoring → peer-manager}/peer_scoring.d.ts +3 -0
- package/dest/services/peer-manager/peer_scoring.d.ts.map +1 -0
- package/dest/services/peer-manager/peer_scoring.js +84 -0
- package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts +45 -0
- package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts.map +1 -0
- package/dest/services/reqresp/connection-sampler/batch_connection_sampler.js +81 -0
- package/dest/services/reqresp/connection-sampler/connection_sampler.d.ts +61 -0
- package/dest/services/reqresp/connection-sampler/connection_sampler.d.ts.map +1 -0
- package/dest/services/reqresp/connection-sampler/connection_sampler.js +175 -0
- package/dest/services/reqresp/interface.d.ts +17 -4
- package/dest/services/reqresp/interface.d.ts.map +1 -1
- package/dest/services/reqresp/interface.js +34 -11
- package/dest/services/reqresp/metrics.d.ts +15 -0
- package/dest/services/reqresp/metrics.d.ts.map +1 -0
- package/dest/services/reqresp/metrics.js +42 -0
- package/dest/services/reqresp/protocols/block.d.ts +4 -0
- package/dest/services/reqresp/protocols/block.d.ts.map +1 -0
- package/dest/services/reqresp/protocols/block.js +9 -0
- package/dest/services/reqresp/protocols/goodbye.d.ts +51 -0
- package/dest/services/reqresp/protocols/goodbye.d.ts.map +1 -0
- package/dest/services/reqresp/protocols/goodbye.js +92 -0
- package/dest/services/reqresp/protocols/index.d.ts +9 -0
- package/dest/services/reqresp/protocols/index.d.ts.map +1 -0
- package/dest/services/reqresp/protocols/index.js +9 -0
- package/dest/services/reqresp/protocols/ping.d.ts +9 -0
- package/dest/services/reqresp/protocols/ping.d.ts.map +1 -0
- package/dest/services/reqresp/protocols/ping.js +9 -0
- package/dest/services/reqresp/{handlers.d.ts → protocols/status.d.ts} +1 -7
- package/dest/services/reqresp/protocols/status.d.ts.map +1 -0
- package/dest/services/reqresp/protocols/status.js +9 -0
- package/dest/services/reqresp/protocols/tx.d.ts +13 -0
- package/dest/services/reqresp/protocols/tx.d.ts.map +1 -0
- package/dest/services/reqresp/protocols/tx.js +23 -0
- package/dest/services/reqresp/rate-limiter/index.d.ts.map +1 -0
- package/dest/services/reqresp/{rate_limiter → rate-limiter}/index.js +1 -1
- package/dest/services/reqresp/{rate_limiter → rate-limiter}/rate_limiter.d.ts +3 -3
- package/dest/services/reqresp/{rate_limiter → rate-limiter}/rate_limiter.d.ts.map +1 -1
- package/dest/services/reqresp/{rate_limiter → rate-limiter}/rate_limiter.js +4 -4
- package/dest/services/reqresp/rate-limiter/rate_limits.d.ts.map +1 -0
- package/dest/services/reqresp/rate-limiter/rate_limits.js +55 -0
- package/dest/services/reqresp/reqresp.d.ts +33 -6
- package/dest/services/reqresp/reqresp.d.ts.map +1 -1
- package/dest/services/reqresp/reqresp.js +414 -249
- package/dest/services/service.d.ts +8 -0
- package/dest/services/service.d.ts.map +1 -1
- package/dest/util.d.ts +4 -0
- package/dest/util.d.ts.map +1 -1
- package/dest/util.js +1 -1
- package/package.json +8 -8
- package/src/client/factory.ts +5 -13
- package/src/client/p2p_client.ts +32 -11
- package/src/config.ts +9 -0
- package/src/mem_pools/attestation_pool/kv_attestation_pool.ts +2 -2
- package/src/mem_pools/attestation_pool/memory_attestation_pool.ts +2 -2
- package/src/mem_pools/attestation_pool/mocks.ts +2 -2
- package/src/mem_pools/epoch_proof_quote_pool/memory_epoch_proof_quote_pool.ts +2 -2
- package/src/mem_pools/tx_pool/aztec_kv_tx_pool.ts +92 -7
- package/src/mem_pools/tx_pool/memory_tx_pool.ts +6 -2
- package/src/mem_pools/tx_pool/tx_pool.ts +7 -0
- package/src/mocks/index.ts +22 -24
- package/src/services/discv5/discV5_service.ts +2 -2
- package/src/services/dummy_service.ts +13 -0
- package/src/services/libp2p/libp2p_service.ts +143 -128
- package/src/services/peer-manager/metrics.ts +41 -0
- package/src/services/{peer_manager.ts → peer-manager/peer_manager.ts} +67 -22
- package/src/services/{peer-scoring → peer-manager}/peer_scoring.ts +16 -3
- package/src/services/reqresp/connection-sampler/batch_connection_sampler.ts +94 -0
- package/src/services/reqresp/connection-sampler/connection_sampler.ts +211 -0
- package/src/services/reqresp/interface.ts +39 -16
- package/src/services/reqresp/metrics.ts +57 -0
- package/src/services/reqresp/protocols/block.ts +15 -0
- package/src/services/reqresp/protocols/goodbye.ts +101 -0
- package/src/services/reqresp/protocols/index.ts +8 -0
- package/src/services/reqresp/protocols/ping.ts +8 -0
- package/src/services/reqresp/{handlers.ts → protocols/status.ts} +0 -9
- package/src/services/reqresp/protocols/tx.ts +29 -0
- package/src/services/reqresp/{rate_limiter → rate-limiter}/rate_limiter.ts +3 -3
- package/src/services/reqresp/{rate_limiter → rate-limiter}/rate_limits.ts +24 -4
- package/src/services/reqresp/reqresp.ts +224 -25
- package/src/services/service.ts +12 -0
- package/src/util.ts +4 -0
- package/dest/services/peer-scoring/peer_scoring.d.ts.map +0 -1
- package/dest/services/peer-scoring/peer_scoring.js +0 -75
- package/dest/services/peer_manager.d.ts.map +0 -1
- package/dest/services/peer_manager.js +0 -358
- package/dest/services/reqresp/handlers.d.ts.map +0 -1
- package/dest/services/reqresp/handlers.js +0 -17
- package/dest/services/reqresp/rate_limiter/index.d.ts.map +0 -1
- package/dest/services/reqresp/rate_limiter/rate_limits.d.ts.map +0 -1
- package/dest/services/reqresp/rate_limiter/rate_limits.js +0 -35
- /package/dest/services/reqresp/{rate_limiter → rate-limiter}/index.d.ts +0 -0
- /package/dest/services/reqresp/{rate_limiter → rate-limiter}/rate_limits.d.ts +0 -0
- /package/src/services/reqresp/{rate_limiter → rate-limiter}/index.ts +0 -0
|
@@ -35,6 +35,14 @@ export interface P2PService {
|
|
|
35
35
|
* @returns The response type, corresponding to the protocol
|
|
36
36
|
*/
|
|
37
37
|
sendRequest<Protocol extends ReqRespSubProtocol>(protocol: Protocol, request: InstanceType<SubProtocolMap[Protocol]['request']>): Promise<InstanceType<SubProtocolMap[Protocol]['response']> | undefined>;
|
|
38
|
+
/**
|
|
39
|
+
* Send a batch of requests to peers, and return the responses
|
|
40
|
+
*
|
|
41
|
+
* @param protocol - The request response protocol to use
|
|
42
|
+
* @param requests - The requests to send to the peers
|
|
43
|
+
* @returns The responses to the requests
|
|
44
|
+
*/
|
|
45
|
+
sendBatchRequest<Protocol extends ReqRespSubProtocol>(protocol: Protocol, requests: InstanceType<SubProtocolMap[Protocol]['request']>[]): Promise<InstanceType<SubProtocolMap[Protocol]['response']>[] | undefined>;
|
|
38
46
|
registerBlockReceivedCallback(callback: (block: BlockProposal) => Promise<BlockAttestation | undefined>): void;
|
|
39
47
|
getEnr(): ENR | undefined;
|
|
40
48
|
getPeers(includePending?: boolean): PeerInfo[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../src/services/service.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAElG,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAA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WAAW,IAAI,GAAG,EAAE,CAAC;IAErB;;OAEG;IACH,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAErC;;;;OAIG;IACH,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;IAEzC;;OAEG;IACH,EAAE,CAAC,KAAK,EAAE,iBAAiB,EAAE,QAAQ,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,IAAI,GAAG,IAAI,CAAC;IACjE,IAAI,CAAC,KAAK,EAAE,iBAAiB,EAAE,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC;IAElD,SAAS,IAAI,kBAAkB,CAAC;IAEhC,MAAM,IAAI,GAAG,GAAG,SAAS,CAAC;CAC3B"}
|
package/dest/util.d.ts
CHANGED
|
@@ -2,11 +2,15 @@ import { type AztecKVStore } from '@aztec/kv-store';
|
|
|
2
2
|
import { type DataStoreConfig } from '@aztec/kv-store/config';
|
|
3
3
|
import type { GossipSub } from '@chainsafe/libp2p-gossipsub';
|
|
4
4
|
import { type PeerId } from '@libp2p/interface';
|
|
5
|
+
import { type ConnectionManager } from '@libp2p/interface-internal';
|
|
5
6
|
import type { Libp2p } from 'libp2p';
|
|
6
7
|
import { type P2PConfig } from './config.js';
|
|
7
8
|
export interface PubSubLibp2p extends Libp2p {
|
|
8
9
|
services: {
|
|
9
10
|
pubsub: GossipSub;
|
|
11
|
+
components: {
|
|
12
|
+
connectionManager: ConnectionManager;
|
|
13
|
+
};
|
|
10
14
|
};
|
|
11
15
|
}
|
|
12
16
|
/**
|
package/dest/util.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAuB,MAAM,iBAAiB,CAAC;AACzE,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAE9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,6B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;;;;;;GAOG;AACH,wBAAsB,mBAAmB,CAAC,MAAM,EAAE;IAAE,gBAAgB,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC,CAiBrH;AAED;;;;GAIG;AACH,wBAAsB,gCAAgC,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAS1F"}
|
package/dest/util.js
CHANGED
|
@@ -148,4 +148,4 @@ export async function createLibP2PPeerIdFromPrivateKey(privateKey) {
|
|
|
148
148
|
const asLibp2pPrivateKey = await unmarshalPrivateKey(new Uint8Array(Buffer.from(privateKey, 'hex')));
|
|
149
149
|
return await createFromPrivKey(asLibp2pPrivateKey);
|
|
150
150
|
}
|
|
151
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
151
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy91dGlsLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUlBLE9BQU8sRUFBRSxlQUFlLEVBQUUsaUJBQWlCLEVBQUUsbUJBQW1CLEVBQUUsTUFBTSxxQkFBcUIsQ0FBQztBQUc5RixPQUFPLEVBQUUsaUJBQWlCLEVBQUUsTUFBTSx5QkFBeUIsQ0FBQztBQUM1RCxPQUFPLEVBQUUsT0FBTyxFQUFFLE1BQU0sY0FBYyxDQUFDO0FBY3ZDOzs7Ozs7OzZDQU82QztBQUM3QyxNQUFNLFVBQVUsa0JBQWtCLENBQUMsT0FBZSxFQUFFLFFBQXVCO0lBQ3pFLE1BQU0sQ0FBQyxJQUFJLEVBQUUsSUFBSSxDQUFDLEdBQUcsZ0JBQWdCLENBQUMsT0FBTyxFQUFFLEtBQUssQ0FBQyxDQUFDO0lBRXRELE1BQU0sZUFBZSxHQUFHLHlCQUF5QixDQUFDLElBQUksQ0F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QUFDLENBQUM7SUFDbEQsQ0FBQztJQUVELE1BQU0sa0JBQWtCLEdBQTRCLE1BQU0sbUJBQW1CLENBQzNFLElBQUksVUFBVSxDQUFDLE1BQU0sQ0FBQyxJQUFJLENBQUMsVUFBVSxFQUFFLEtBQUssQ0FBQyxDQUFDLENBQy9DLENBQUM7SUFDRixPQUFPLE1BQU0saUJBQWlCLENBQUMsa0JBQWtCLENBQUMsQ0FBQztBQUNyRCxDQUFDIn0=
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/p2p",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.72.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/index.js",
|
|
@@ -63,12 +63,12 @@
|
|
|
63
63
|
]
|
|
64
64
|
},
|
|
65
65
|
"dependencies": {
|
|
66
|
-
"@aztec/circuit-types": "0.
|
|
67
|
-
"@aztec/circuits.js": "0.
|
|
68
|
-
"@aztec/epoch-cache": "0.
|
|
69
|
-
"@aztec/foundation": "0.
|
|
70
|
-
"@aztec/kv-store": "0.
|
|
71
|
-
"@aztec/telemetry-client": "0.
|
|
66
|
+
"@aztec/circuit-types": "0.72.1",
|
|
67
|
+
"@aztec/circuits.js": "0.72.1",
|
|
68
|
+
"@aztec/epoch-cache": "0.72.1",
|
|
69
|
+
"@aztec/foundation": "0.72.1",
|
|
70
|
+
"@aztec/kv-store": "0.72.1",
|
|
71
|
+
"@aztec/telemetry-client": "0.72.1",
|
|
72
72
|
"@chainsafe/discv5": "9.0.0",
|
|
73
73
|
"@chainsafe/enr": "3.0.0",
|
|
74
74
|
"@chainsafe/libp2p-gossipsub": "13.0.0",
|
|
@@ -109,7 +109,7 @@
|
|
|
109
109
|
"ts-node": "^10.9.1",
|
|
110
110
|
"typescript": "^5.0.4",
|
|
111
111
|
"uint8arrays": "^5.0.3",
|
|
112
|
-
"viem": "
|
|
112
|
+
"viem": "2.22.8"
|
|
113
113
|
},
|
|
114
114
|
"files": [
|
|
115
115
|
"dest",
|
package/src/client/factory.ts
CHANGED
|
@@ -9,8 +9,7 @@ import { createLogger } from '@aztec/foundation/log';
|
|
|
9
9
|
import { type AztecKVStore } from '@aztec/kv-store';
|
|
10
10
|
import { type DataStoreConfig } from '@aztec/kv-store/config';
|
|
11
11
|
import { createStore } from '@aztec/kv-store/lmdb';
|
|
12
|
-
import { type TelemetryClient } from '@aztec/telemetry-client';
|
|
13
|
-
import { NoopTelemetryClient } from '@aztec/telemetry-client/noop';
|
|
12
|
+
import { type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-client';
|
|
14
13
|
|
|
15
14
|
import { P2PClient } from '../client/p2p_client.js';
|
|
16
15
|
import { type P2PConfig } from '../config.js';
|
|
@@ -39,15 +38,16 @@ export const createP2PClient = async <T extends P2PClientType>(
|
|
|
39
38
|
proofVerifier: ClientProtocolCircuitVerifier,
|
|
40
39
|
worldStateSynchronizer: WorldStateSynchronizer,
|
|
41
40
|
epochCache: EpochCache,
|
|
42
|
-
telemetry: TelemetryClient =
|
|
41
|
+
telemetry: TelemetryClient = getTelemetryClient(),
|
|
43
42
|
deps: P2PClientDeps<T> = {},
|
|
44
43
|
) => {
|
|
45
44
|
let config = { ..._config };
|
|
46
45
|
const logger = createLogger('p2p');
|
|
47
46
|
const store = deps.store ?? (await createStore('p2p', config, createLogger('p2p:lmdb')));
|
|
47
|
+
const archive = await createStore('p2p-archive', config, createLogger('p2p-archive:lmdb'));
|
|
48
48
|
|
|
49
49
|
const mempools: MemPools<T> = {
|
|
50
|
-
txPool: deps.txPool ?? new AztecKVTxPool(store, telemetry),
|
|
50
|
+
txPool: deps.txPool ?? new AztecKVTxPool(store, archive, telemetry, config.archivedTxLimit),
|
|
51
51
|
epochProofQuotePool: deps.epochProofQuotePool ?? new MemoryEpochProofQuotePool(telemetry),
|
|
52
52
|
attestationPool:
|
|
53
53
|
clientType === P2PClientType.Full
|
|
@@ -85,13 +85,5 @@ export const createP2PClient = async <T extends P2PClientType>(
|
|
|
85
85
|
logger.verbose('P2P is disabled. Using dummy P2P service');
|
|
86
86
|
p2pService = new DummyP2PService();
|
|
87
87
|
}
|
|
88
|
-
return new P2PClient(
|
|
89
|
-
clientType,
|
|
90
|
-
store,
|
|
91
|
-
l2BlockSource,
|
|
92
|
-
mempools,
|
|
93
|
-
p2pService,
|
|
94
|
-
config.keepProvenTxsInPoolFor,
|
|
95
|
-
telemetry,
|
|
96
|
-
);
|
|
88
|
+
return new P2PClient(clientType, store, l2BlockSource, mempools, p2pService, config, telemetry);
|
|
97
89
|
};
|
package/src/client/p2p_client.ts
CHANGED
|
@@ -21,18 +21,18 @@ import {
|
|
|
21
21
|
type TelemetryClient,
|
|
22
22
|
TraceableL2BlockStream,
|
|
23
23
|
WithTracer,
|
|
24
|
+
getTelemetryClient,
|
|
24
25
|
trackSpan,
|
|
25
26
|
} from '@aztec/telemetry-client';
|
|
26
|
-
import { NoopTelemetryClient } from '@aztec/telemetry-client/noop';
|
|
27
27
|
|
|
28
28
|
import { type ENR } from '@chainsafe/enr';
|
|
29
29
|
|
|
30
|
-
import {
|
|
30
|
+
import { type P2PConfig, getP2PDefaultConfig } from '../config.js';
|
|
31
31
|
import { type AttestationPool } from '../mem_pools/attestation_pool/attestation_pool.js';
|
|
32
32
|
import { type EpochProofQuotePool } from '../mem_pools/epoch_proof_quote_pool/epoch_proof_quote_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
|
-
import {
|
|
35
|
+
import { ReqRespSubProtocol } from '../services/reqresp/interface.js';
|
|
36
36
|
import type { P2PService } from '../services/service.js';
|
|
37
37
|
|
|
38
38
|
/**
|
|
@@ -135,6 +135,13 @@ export type P2P<T extends P2PClientType = P2PClientType.Full> = P2PApi<T> & {
|
|
|
135
135
|
*/
|
|
136
136
|
getTxByHash(txHash: TxHash): Promise<Tx | undefined>;
|
|
137
137
|
|
|
138
|
+
/**
|
|
139
|
+
* Returns an archived transaction from the transaction pool by its hash.
|
|
140
|
+
* @param txHash - Hash of tx to return.
|
|
141
|
+
* @returns A single tx or undefined.
|
|
142
|
+
*/
|
|
143
|
+
getArchivedTxByHash(txHash: TxHash): Promise<Tx | undefined>;
|
|
144
|
+
|
|
138
145
|
/**
|
|
139
146
|
* Returns whether the given tx hash is flagged as pending or mined.
|
|
140
147
|
* @param txHash - Hash of the tx to query.
|
|
@@ -209,6 +216,8 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
209
216
|
|
|
210
217
|
/** How many slots to keep attestations for. */
|
|
211
218
|
private keepAttestationsInPoolFor: number;
|
|
219
|
+
/** How many slots to keep proven txs for. */
|
|
220
|
+
private keepProvenTxsFor: number;
|
|
212
221
|
|
|
213
222
|
private blockStream;
|
|
214
223
|
|
|
@@ -227,14 +236,17 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
227
236
|
private l2BlockSource: L2BlockSource,
|
|
228
237
|
mempools: MemPools<T>,
|
|
229
238
|
private p2pService: P2PService,
|
|
230
|
-
|
|
231
|
-
telemetry: TelemetryClient =
|
|
239
|
+
config: Partial<P2PConfig> = {},
|
|
240
|
+
telemetry: TelemetryClient = getTelemetryClient(),
|
|
232
241
|
private log = createLogger('p2p'),
|
|
233
242
|
) {
|
|
234
243
|
super(telemetry, 'P2PClient');
|
|
235
244
|
|
|
236
|
-
const { blockCheckIntervalMS, blockRequestBatchSize, keepAttestationsInPoolFor } =
|
|
237
|
-
|
|
245
|
+
const { keepProvenTxsInPoolFor, blockCheckIntervalMS, blockRequestBatchSize, keepAttestationsInPoolFor } = {
|
|
246
|
+
...getP2PDefaultConfig(),
|
|
247
|
+
...config,
|
|
248
|
+
};
|
|
249
|
+
this.keepProvenTxsFor = keepProvenTxsInPoolFor;
|
|
238
250
|
this.keepAttestationsInPoolFor = keepAttestationsInPoolFor;
|
|
239
251
|
|
|
240
252
|
const tracer = telemetry.getTracer('P2PL2BlockStream');
|
|
@@ -432,9 +444,9 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
432
444
|
* @param txHashes - The hashes of the transactions to request.
|
|
433
445
|
* @returns A promise that resolves to an array of transactions or undefined.
|
|
434
446
|
*/
|
|
435
|
-
public requestTxs(txHashes: TxHash[]): Promise<(Tx | undefined)[]> {
|
|
436
|
-
const
|
|
437
|
-
return Promise.
|
|
447
|
+
public async requestTxs(txHashes: TxHash[]): Promise<(Tx | undefined)[]> {
|
|
448
|
+
const res = await this.p2pService.sendBatchRequest(ReqRespSubProtocol.TX, txHashes);
|
|
449
|
+
return Promise.resolve(res ?? []);
|
|
438
450
|
}
|
|
439
451
|
|
|
440
452
|
/**
|
|
@@ -447,7 +459,7 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
447
459
|
* @returns A promise that resolves to a transaction or undefined.
|
|
448
460
|
*/
|
|
449
461
|
public async requestTxByHash(txHash: TxHash): Promise<Tx | undefined> {
|
|
450
|
-
const tx = await this.p2pService.sendRequest(
|
|
462
|
+
const tx = await this.p2pService.sendRequest(ReqRespSubProtocol.TX, txHash);
|
|
451
463
|
|
|
452
464
|
if (tx) {
|
|
453
465
|
this.log.debug(`Received tx ${txHash.toString()} from peer`);
|
|
@@ -523,6 +535,15 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
523
535
|
return this.requestTxByHash(txHash);
|
|
524
536
|
}
|
|
525
537
|
|
|
538
|
+
/**
|
|
539
|
+
* Returns an archived transaction in the transaction pool by its hash.
|
|
540
|
+
* @param txHash - Hash of the archived transaction to look for.
|
|
541
|
+
* @returns A single tx or undefined.
|
|
542
|
+
*/
|
|
543
|
+
getArchivedTxByHash(txHash: TxHash): Promise<Tx | undefined> {
|
|
544
|
+
return Promise.resolve(this.txPool.getArchivedTxByHash(txHash));
|
|
545
|
+
}
|
|
546
|
+
|
|
526
547
|
/**
|
|
527
548
|
* Verifies the 'tx' and, if valid, adds it to local tx pool and forwards it to other peers.
|
|
528
549
|
* @param tx - The tx to verify.
|
package/src/config.ts
CHANGED
|
@@ -154,6 +154,9 @@ export interface P2PConfig extends P2PReqRespConfig {
|
|
|
154
154
|
* The chain id of the L1 chain.
|
|
155
155
|
*/
|
|
156
156
|
l1ChainId: number;
|
|
157
|
+
|
|
158
|
+
/** Limit of transactions to archive in the tx pool. Once the archived tx limit is reached, the oldest archived txs will be purged. */
|
|
159
|
+
archivedTxLimit: number;
|
|
157
160
|
}
|
|
158
161
|
|
|
159
162
|
export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
|
|
@@ -305,6 +308,12 @@ export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
|
|
|
305
308
|
description: 'The number of blocks to fetch in a single batch.',
|
|
306
309
|
...numberConfigHelper(20),
|
|
307
310
|
},
|
|
311
|
+
archivedTxLimit: {
|
|
312
|
+
env: 'P2P_ARCHIVED_TX_LIMIT',
|
|
313
|
+
description:
|
|
314
|
+
'The number of transactions that will be archived. If the limit is set to 0 then archiving will be disabled.',
|
|
315
|
+
...numberConfigHelper(0),
|
|
316
|
+
},
|
|
308
317
|
...p2pReqRespConfigMappings,
|
|
309
318
|
};
|
|
310
319
|
|
|
@@ -2,7 +2,7 @@ import { BlockAttestation } from '@aztec/circuit-types';
|
|
|
2
2
|
import { Fr } from '@aztec/foundation/fields';
|
|
3
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
4
|
import { type AztecKVStore, type AztecMapWithSize, type AztecMultiMap } from '@aztec/kv-store';
|
|
5
|
-
import { type TelemetryClient } from '@aztec/telemetry-client';
|
|
5
|
+
import { type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-client';
|
|
6
6
|
|
|
7
7
|
import { PoolInstrumentation, PoolName } from '../instrumentation.js';
|
|
8
8
|
import { type AttestationPool } from './attestation_pool.js';
|
|
@@ -15,7 +15,7 @@ export class KvAttestationPool implements AttestationPool {
|
|
|
15
15
|
|
|
16
16
|
constructor(
|
|
17
17
|
private store: AztecKVStore,
|
|
18
|
-
telemetry: TelemetryClient,
|
|
18
|
+
telemetry: TelemetryClient = getTelemetryClient(),
|
|
19
19
|
private log = createLogger('aztec:attestation_pool'),
|
|
20
20
|
) {
|
|
21
21
|
this.attestations = store.openMultiMap('attestations');
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type BlockAttestation } from '@aztec/circuit-types';
|
|
2
2
|
import { createLogger } from '@aztec/foundation/log';
|
|
3
|
-
import { type TelemetryClient } from '@aztec/telemetry-client';
|
|
3
|
+
import { type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-client';
|
|
4
4
|
|
|
5
5
|
import { PoolInstrumentation, PoolName } from '../instrumentation.js';
|
|
6
6
|
import { type AttestationPool } from './attestation_pool.js';
|
|
@@ -10,7 +10,7 @@ export class InMemoryAttestationPool implements AttestationPool {
|
|
|
10
10
|
|
|
11
11
|
private attestations: Map</*slot=*/ bigint, Map</*proposalId*/ string, Map</*address=*/ string, BlockAttestation>>>;
|
|
12
12
|
|
|
13
|
-
constructor(telemetry: TelemetryClient, private log = createLogger('p2p:attestation_pool')) {
|
|
13
|
+
constructor(telemetry: TelemetryClient = getTelemetryClient(), private log = createLogger('p2p:attestation_pool')) {
|
|
14
14
|
this.attestations = new Map();
|
|
15
15
|
this.metrics = new PoolInstrumentation(telemetry, PoolName.ATTESTATION_POOL);
|
|
16
16
|
}
|
|
@@ -9,14 +9,14 @@ import { makeHeader } from '@aztec/circuits.js/testing';
|
|
|
9
9
|
import { type Secp256k1Signer } from '@aztec/foundation/crypto';
|
|
10
10
|
import { Fr } from '@aztec/foundation/fields';
|
|
11
11
|
|
|
12
|
-
import { generatePrivateKey, privateKeyToAccount } from 'viem/accounts';
|
|
12
|
+
import { type LocalAccount, generatePrivateKey, privateKeyToAccount } from 'viem/accounts';
|
|
13
13
|
|
|
14
14
|
/** Generate Account
|
|
15
15
|
*
|
|
16
16
|
* Create a random signer
|
|
17
17
|
* @returns A random viem signer
|
|
18
18
|
*/
|
|
19
|
-
export const generateAccount = () => {
|
|
19
|
+
export const generateAccount = (): LocalAccount => {
|
|
20
20
|
const privateKey = generatePrivateKey();
|
|
21
21
|
return privateKeyToAccount(privateKey);
|
|
22
22
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type EpochProofQuote } from '@aztec/circuit-types';
|
|
2
|
-
import { type TelemetryClient } from '@aztec/telemetry-client';
|
|
2
|
+
import { type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-client';
|
|
3
3
|
|
|
4
4
|
import { PoolInstrumentation, PoolName } from '../instrumentation.js';
|
|
5
5
|
import { type EpochProofQuotePool } from './epoch_proof_quote_pool.js';
|
|
@@ -8,7 +8,7 @@ export class MemoryEpochProofQuotePool implements EpochProofQuotePool {
|
|
|
8
8
|
private quotes: Map<bigint, EpochProofQuote[]>;
|
|
9
9
|
private metrics: PoolInstrumentation<EpochProofQuote>;
|
|
10
10
|
|
|
11
|
-
constructor(telemetry: TelemetryClient) {
|
|
11
|
+
constructor(telemetry: TelemetryClient = getTelemetryClient()) {
|
|
12
12
|
this.quotes = new Map();
|
|
13
13
|
this.metrics = new PoolInstrumentation(telemetry, PoolName.EPOCH_PROOF_QUOTE_POOL);
|
|
14
14
|
}
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { Tx, TxHash } from '@aztec/circuit-types';
|
|
2
2
|
import { type TxAddedToPoolStats } from '@aztec/circuit-types/stats';
|
|
3
|
+
import { ClientIvcProof } from '@aztec/circuits.js';
|
|
3
4
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
4
5
|
import { type AztecKVStore, type AztecMap, type AztecMultiMap } from '@aztec/kv-store';
|
|
5
|
-
import { type TelemetryClient } from '@aztec/telemetry-client';
|
|
6
|
+
import { type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-client';
|
|
6
7
|
|
|
7
8
|
import { PoolInstrumentation, PoolName } from '../instrumentation.js';
|
|
8
9
|
import { getPendingTxPriority } from './priority.js';
|
|
9
10
|
import { type TxPool } from './tx_pool.js';
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
|
-
*
|
|
13
|
+
* KV implementation of the Transaction Pool.
|
|
13
14
|
*/
|
|
14
15
|
export class AztecKVTxPool implements TxPool {
|
|
15
16
|
#store: AztecKVStore;
|
|
@@ -23,21 +24,47 @@ export class AztecKVTxPool implements TxPool {
|
|
|
23
24
|
/** Index from tx priority (stored as hex) to its tx hash, filtered by pending txs. */
|
|
24
25
|
#pendingTxPriorityToHash: AztecMultiMap<string, string>;
|
|
25
26
|
|
|
27
|
+
/** KV store for archived txs. */
|
|
28
|
+
#archive: AztecKVStore;
|
|
29
|
+
|
|
30
|
+
/** Archived txs map for future lookup. */
|
|
31
|
+
#archivedTxs: AztecMap<string, Buffer>;
|
|
32
|
+
|
|
33
|
+
/** Indexes of the archived txs by insertion order. */
|
|
34
|
+
#archivedTxIndices: AztecMap<number, string>;
|
|
35
|
+
|
|
36
|
+
/** Number of txs to archive. */
|
|
37
|
+
#archivedTxLimit: number;
|
|
38
|
+
|
|
26
39
|
#log: Logger;
|
|
27
40
|
|
|
28
41
|
#metrics: PoolInstrumentation<Tx>;
|
|
29
42
|
|
|
30
43
|
/**
|
|
31
|
-
* Class constructor for
|
|
32
|
-
* @param store - A KV store.
|
|
44
|
+
* Class constructor for KV TxPool. Initiates our transaction pool as an AztecMap.
|
|
45
|
+
* @param store - A KV store for live txs in the pool.
|
|
46
|
+
* @param archive - A KV store for archived txs.
|
|
47
|
+
* @param telemetry - A telemetry client.
|
|
48
|
+
* @param archivedTxLimit - The number of txs to archive.
|
|
33
49
|
* @param log - A logger.
|
|
34
50
|
*/
|
|
35
|
-
constructor(
|
|
51
|
+
constructor(
|
|
52
|
+
store: AztecKVStore,
|
|
53
|
+
archive: AztecKVStore,
|
|
54
|
+
telemetry: TelemetryClient = getTelemetryClient(),
|
|
55
|
+
archivedTxLimit: number = 0,
|
|
56
|
+
log = createLogger('p2p:tx_pool'),
|
|
57
|
+
) {
|
|
36
58
|
this.#txs = store.openMap('txs');
|
|
37
59
|
this.#minedTxHashToBlock = store.openMap('txHashToBlockMined');
|
|
38
60
|
this.#pendingTxPriorityToHash = store.openMultiMap('pendingTxFeeToHash');
|
|
39
61
|
|
|
62
|
+
this.#archivedTxs = archive.openMap('archivedTxs');
|
|
63
|
+
this.#archivedTxIndices = archive.openMap('archivedTxIndices');
|
|
64
|
+
this.#archivedTxLimit = archivedTxLimit;
|
|
65
|
+
|
|
40
66
|
this.#store = store;
|
|
67
|
+
this.#archive = archive;
|
|
41
68
|
this.#log = log;
|
|
42
69
|
this.#metrics = new PoolInstrumentation(telemetry, PoolName.TX_POOL, () => store.estimateSize());
|
|
43
70
|
}
|
|
@@ -125,6 +152,21 @@ export class AztecKVTxPool implements TxPool {
|
|
|
125
152
|
return undefined;
|
|
126
153
|
}
|
|
127
154
|
|
|
155
|
+
/**
|
|
156
|
+
* Checks if an archived tx exists and returns it.
|
|
157
|
+
* @param txHash - The tx hash.
|
|
158
|
+
* @returns The transaction metadata, if found, 'undefined' otherwise.
|
|
159
|
+
*/
|
|
160
|
+
public getArchivedTxByHash(txHash: TxHash): Tx | undefined {
|
|
161
|
+
const buffer = this.#archivedTxs.get(txHash.toString());
|
|
162
|
+
if (buffer) {
|
|
163
|
+
const tx = Tx.fromBuffer(buffer);
|
|
164
|
+
tx.setTxHash(txHash);
|
|
165
|
+
return tx;
|
|
166
|
+
}
|
|
167
|
+
return undefined;
|
|
168
|
+
}
|
|
169
|
+
|
|
128
170
|
/**
|
|
129
171
|
* Adds a list of transactions to the pool. Duplicates are ignored.
|
|
130
172
|
* @param txs - An array of txs to be added to the pool.
|
|
@@ -158,13 +200,14 @@ export class AztecKVTxPool implements TxPool {
|
|
|
158
200
|
/**
|
|
159
201
|
* Deletes transactions from the pool. Tx hashes that are not present are ignored.
|
|
160
202
|
* @param txHashes - An array of tx hashes to be removed from the tx pool.
|
|
161
|
-
* @returns
|
|
203
|
+
* @returns Empty promise.
|
|
162
204
|
*/
|
|
163
205
|
public deleteTxs(txHashes: TxHash[]): Promise<void> {
|
|
164
206
|
let pendingDeleted = 0;
|
|
165
207
|
let minedDeleted = 0;
|
|
166
208
|
|
|
167
|
-
|
|
209
|
+
const deletedTxs: Tx[] = [];
|
|
210
|
+
const poolDbTx = this.#store.transaction(() => {
|
|
168
211
|
for (const hash of txHashes) {
|
|
169
212
|
const key = hash.toString();
|
|
170
213
|
const tx = this.getTxByHash(hash);
|
|
@@ -180,6 +223,10 @@ export class AztecKVTxPool implements TxPool {
|
|
|
180
223
|
pendingDeleted++;
|
|
181
224
|
}
|
|
182
225
|
|
|
226
|
+
if (this.#archivedTxLimit) {
|
|
227
|
+
deletedTxs.push(tx);
|
|
228
|
+
}
|
|
229
|
+
|
|
183
230
|
void this.#txs.delete(key);
|
|
184
231
|
void this.#minedTxHashToBlock.delete(key);
|
|
185
232
|
}
|
|
@@ -188,6 +235,8 @@ export class AztecKVTxPool implements TxPool {
|
|
|
188
235
|
this.#metrics.recordRemovedObjects(pendingDeleted, 'pending');
|
|
189
236
|
this.#metrics.recordRemovedObjects(minedDeleted, 'mined');
|
|
190
237
|
});
|
|
238
|
+
|
|
239
|
+
return this.#archivedTxLimit ? poolDbTx.then(() => this.archiveTxs(deletedTxs)) : poolDbTx;
|
|
191
240
|
}
|
|
192
241
|
|
|
193
242
|
/**
|
|
@@ -209,4 +258,40 @@ export class AztecKVTxPool implements TxPool {
|
|
|
209
258
|
public getAllTxHashes(): TxHash[] {
|
|
210
259
|
return Array.from(this.#txs.keys()).map(x => TxHash.fromString(x));
|
|
211
260
|
}
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* Archives a list of txs for future reference. The number of archived txs is limited by the specified archivedTxLimit.
|
|
264
|
+
* @param txs - The list of transactions to archive.
|
|
265
|
+
* @returns Empty promise.
|
|
266
|
+
*/
|
|
267
|
+
private archiveTxs(txs: Tx[]): Promise<void> {
|
|
268
|
+
return this.#archive.transaction(() => {
|
|
269
|
+
// calcualte the head and tail indices of the archived txs by insertion order.
|
|
270
|
+
let headIdx = (this.#archivedTxIndices.entries({ limit: 1, reverse: true }).next().value?.[0] ?? -1) + 1;
|
|
271
|
+
let tailIdx = this.#archivedTxIndices.entries({ limit: 1 }).next().value?.[0] ?? 0;
|
|
272
|
+
|
|
273
|
+
for (const tx of txs) {
|
|
274
|
+
while (headIdx - tailIdx >= this.#archivedTxLimit) {
|
|
275
|
+
const txHash = this.#archivedTxIndices.get(tailIdx);
|
|
276
|
+
if (txHash) {
|
|
277
|
+
void this.#archivedTxs.delete(txHash);
|
|
278
|
+
void this.#archivedTxIndices.delete(tailIdx);
|
|
279
|
+
}
|
|
280
|
+
tailIdx++;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
const archivedTx: Tx = new Tx(
|
|
284
|
+
tx.data,
|
|
285
|
+
ClientIvcProof.empty(),
|
|
286
|
+
tx.contractClassLogs,
|
|
287
|
+
tx.enqueuedPublicFunctionCalls,
|
|
288
|
+
tx.publicTeardownFunctionCall,
|
|
289
|
+
);
|
|
290
|
+
const txHash = tx.getTxHash().toString();
|
|
291
|
+
void this.#archivedTxs.set(txHash, archivedTx.toBuffer());
|
|
292
|
+
void this.#archivedTxIndices.set(headIdx, txHash);
|
|
293
|
+
headIdx++;
|
|
294
|
+
}
|
|
295
|
+
});
|
|
296
|
+
}
|
|
212
297
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Tx, TxHash } from '@aztec/circuit-types';
|
|
2
2
|
import { type TxAddedToPoolStats } from '@aztec/circuit-types/stats';
|
|
3
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
|
-
import { type TelemetryClient } from '@aztec/telemetry-client';
|
|
4
|
+
import { type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-client';
|
|
5
5
|
|
|
6
6
|
import { PoolInstrumentation, PoolName } from '../instrumentation.js';
|
|
7
7
|
import { getPendingTxPriority } from './priority.js';
|
|
@@ -24,7 +24,7 @@ export class InMemoryTxPool implements TxPool {
|
|
|
24
24
|
* Class constructor for in-memory TxPool. Initiates our transaction pool as a JS Map.
|
|
25
25
|
* @param log - A logger.
|
|
26
26
|
*/
|
|
27
|
-
constructor(telemetry: TelemetryClient, private log = createLogger('p2p:tx_pool')) {
|
|
27
|
+
constructor(telemetry: TelemetryClient = getTelemetryClient(), private log = createLogger('p2p:tx_pool')) {
|
|
28
28
|
this.txs = new Map<bigint, Tx>();
|
|
29
29
|
this.minedTxs = new Map();
|
|
30
30
|
this.pendingTxs = new Set();
|
|
@@ -100,6 +100,10 @@ export class InMemoryTxPool implements TxPool {
|
|
|
100
100
|
return result === undefined ? undefined : Tx.clone(result);
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
+
public getArchivedTxByHash(): Tx | undefined {
|
|
104
|
+
return undefined;
|
|
105
|
+
}
|
|
106
|
+
|
|
103
107
|
/**
|
|
104
108
|
* Adds a list of transactions to the pool. Duplicates are ignored.
|
|
105
109
|
* @param txs - An array of txs to be added to the pool.
|
|
@@ -17,6 +17,13 @@ export interface TxPool {
|
|
|
17
17
|
*/
|
|
18
18
|
getTxByHash(txHash: TxHash): Tx | undefined;
|
|
19
19
|
|
|
20
|
+
/**
|
|
21
|
+
* Checks if an archived transaction exists in the pool and returns it.
|
|
22
|
+
* @param txHash - The hash of the transaction, used as an ID.
|
|
23
|
+
* @returns The transaction, if found, 'undefined' otherwise.
|
|
24
|
+
*/
|
|
25
|
+
getArchivedTxByHash(txHash: TxHash): Tx | undefined;
|
|
26
|
+
|
|
20
27
|
/**
|
|
21
28
|
* Marks the set of txs as mined, as opposed to pending.
|
|
22
29
|
* @param txHashes - Hashes of the txs to flag as mined.
|