@aztec/p2p 0.86.0 → 0.87.0
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.map +1 -1
- package/dest/client/factory.d.ts +4 -1
- package/dest/client/factory.d.ts.map +1 -1
- package/dest/client/factory.js +16 -14
- package/dest/client/index.d.ts +1 -0
- package/dest/client/index.d.ts.map +1 -1
- package/dest/client/index.js +1 -0
- package/dest/client/interface.d.ts +155 -0
- package/dest/client/interface.d.ts.map +1 -0
- package/dest/client/interface.js +9 -0
- package/dest/client/p2p_client.d.ts +26 -164
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +185 -114
- package/dest/config.d.ts +5 -6
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +6 -11
- package/dest/enr/generate-enr.d.ts +9 -1
- package/dest/enr/generate-enr.d.ts.map +1 -1
- package/dest/enr/generate-enr.js +24 -2
- package/dest/index.d.ts +1 -0
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -0
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts +2 -0
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.js +4 -4
- package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts +1 -0
- package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/kv_attestation_pool.js +8 -2
- package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts +1 -0
- package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/memory_attestation_pool.js +5 -2
- package/dest/mem_pools/attestation_pool/mocks.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/mocks.js +2 -2
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts +4 -0
- 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 +50 -14
- package/dest/mem_pools/tx_pool/memory_tx_pool.d.ts +3 -0
- package/dest/mem_pools/tx_pool/memory_tx_pool.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/memory_tx_pool.js +9 -0
- package/dest/mem_pools/tx_pool/tx_pool.d.ts +9 -0
- package/dest/mem_pools/tx_pool/tx_pool.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.js +13 -5
- package/dest/msg_validators/attestation_validator/attestation_validator.js +1 -1
- package/dest/msg_validators/block_proposal_validator/block_proposal_validator.js +1 -1
- package/dest/msg_validators/tx_validator/block_header_validator.js +1 -1
- package/dest/msg_validators/tx_validator/data_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/data_validator.js +15 -14
- package/dest/msg_validators/tx_validator/double_spend_validator.d.ts +0 -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 +2 -2
- package/dest/msg_validators/tx_validator/factory.d.ts +14 -0
- package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/factory.js +62 -0
- package/dest/msg_validators/tx_validator/gas_validator.js +3 -3
- package/dest/msg_validators/tx_validator/metadata_validator.d.ts +8 -4
- package/dest/msg_validators/tx_validator/metadata_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/metadata_validator.js +35 -17
- package/dest/msg_validators/tx_validator/phases_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/phases_validator.js +1 -1
- package/dest/msg_validators/tx_validator/tx_proof_validator.js +1 -1
- package/dest/services/discv5/discV5_service.d.ts +2 -2
- package/dest/services/discv5/discV5_service.d.ts.map +1 -1
- package/dest/services/discv5/discV5_service.js +9 -13
- package/dest/services/dummy_service.d.ts +3 -3
- package/dest/services/dummy_service.d.ts.map +1 -1
- package/dest/services/dummy_service.js +6 -1
- package/dest/services/encoding.d.ts +1 -3
- package/dest/services/encoding.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.d.ts +4 -2
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +94 -88
- package/dest/services/peer-manager/metrics.d.ts.map +1 -1
- package/dest/services/peer-manager/peer_manager.d.ts +1 -1
- package/dest/services/peer-manager/peer_manager.d.ts.map +1 -1
- package/dest/services/peer-manager/peer_manager.js +11 -2
- package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts.map +1 -1
- package/dest/services/reqresp/connection-sampler/connection_sampler.d.ts +2 -2
- package/dest/services/reqresp/connection-sampler/connection_sampler.d.ts.map +1 -1
- package/dest/services/reqresp/connection-sampler/connection_sampler.js +41 -21
- package/dest/services/reqresp/interface.d.ts +1 -3
- package/dest/services/reqresp/interface.d.ts.map +1 -1
- package/dest/services/reqresp/metrics.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/goodbye.d.ts +0 -2
- package/dest/services/reqresp/protocols/goodbye.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/goodbye.js +1 -1
- package/dest/services/reqresp/protocols/ping.d.ts +0 -2
- package/dest/services/reqresp/protocols/ping.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/status.d.ts +0 -2
- package/dest/services/reqresp/protocols/status.d.ts.map +1 -1
- package/dest/services/reqresp/rate-limiter/rate_limiter.d.ts.map +1 -1
- package/dest/services/reqresp/reqresp.d.ts +1 -3
- package/dest/services/reqresp/reqresp.d.ts.map +1 -1
- package/dest/services/reqresp/reqresp.js +13 -10
- package/dest/services/service.d.ts +4 -3
- package/dest/services/service.d.ts.map +1 -1
- package/dest/test-helpers/get-ports.d.ts.map +1 -1
- package/dest/test-helpers/make-test-p2p-clients.d.ts.map +1 -1
- package/dest/test-helpers/make-test-p2p-clients.js +2 -2
- package/dest/test-helpers/reqresp-nodes.d.ts.map +1 -1
- package/dest/test-helpers/reqresp-nodes.js +1 -1
- package/dest/testbench/p2p_client_testbench_worker.js +11 -6
- package/dest/testbench/testbench.js +1 -1
- package/dest/testbench/worker_client_manager.d.ts +0 -1
- package/dest/testbench/worker_client_manager.d.ts.map +1 -1
- package/dest/testbench/worker_client_manager.js +2 -2
- package/dest/types/index.d.ts +1 -0
- package/dest/types/index.d.ts.map +1 -1
- package/dest/types/index.js +1 -0
- package/dest/versioning.d.ts +2 -2
- package/dest/versioning.d.ts.map +1 -1
- package/dest/versioning.js +6 -1
- package/package.json +15 -15
- package/src/bootstrap/bootstrap.ts +1 -1
- package/src/client/factory.ts +38 -33
- package/src/client/index.ts +1 -0
- package/src/client/interface.ts +186 -0
- package/src/client/p2p_client.ts +226 -287
- package/src/config.ts +11 -18
- package/src/enr/generate-enr.ts +35 -3
- package/src/index.ts +1 -0
- package/src/mem_pools/attestation_pool/attestation_pool.ts +3 -0
- package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +4 -4
- package/src/mem_pools/attestation_pool/kv_attestation_pool.ts +11 -4
- package/src/mem_pools/attestation_pool/memory_attestation_pool.ts +10 -3
- package/src/mem_pools/attestation_pool/mocks.ts +2 -2
- package/src/mem_pools/tx_pool/aztec_kv_tx_pool.ts +79 -34
- package/src/mem_pools/tx_pool/memory_tx_pool.ts +16 -1
- package/src/mem_pools/tx_pool/tx_pool.ts +12 -0
- package/src/mem_pools/tx_pool/tx_pool_test_suite.ts +9 -3
- package/src/msg_validators/attestation_validator/attestation_validator.ts +1 -1
- package/src/msg_validators/block_proposal_validator/block_proposal_validator.ts +1 -1
- package/src/msg_validators/tx_validator/block_header_validator.ts +1 -1
- package/src/msg_validators/tx_validator/data_validator.ts +24 -18
- package/src/msg_validators/tx_validator/double_spend_validator.ts +2 -2
- package/src/msg_validators/tx_validator/factory.ts +94 -0
- package/src/msg_validators/tx_validator/gas_validator.ts +3 -3
- package/src/msg_validators/tx_validator/metadata_validator.ts +50 -14
- package/src/msg_validators/tx_validator/phases_validator.ts +6 -2
- package/src/msg_validators/tx_validator/tx_proof_validator.ts +1 -1
- package/src/services/discv5/discV5_service.ts +14 -12
- package/src/services/dummy_service.ts +8 -2
- package/src/services/libp2p/libp2p_service.ts +102 -111
- package/src/services/peer-manager/metrics.ts +4 -1
- package/src/services/peer-manager/peer_manager.ts +18 -1
- package/src/services/reqresp/connection-sampler/batch_connection_sampler.ts +5 -1
- package/src/services/reqresp/connection-sampler/connection_sampler.ts +42 -19
- package/src/services/reqresp/metrics.ts +4 -1
- package/src/services/reqresp/protocols/goodbye.ts +1 -1
- package/src/services/reqresp/rate-limiter/rate_limiter.ts +4 -1
- package/src/services/reqresp/reqresp.ts +12 -12
- package/src/services/service.ts +7 -1
- package/src/test-helpers/make-test-p2p-clients.ts +2 -1
- package/src/test-helpers/reqresp-nodes.ts +1 -1
- package/src/testbench/p2p_client_testbench_worker.ts +10 -4
- package/src/testbench/testbench.ts +1 -1
- package/src/testbench/worker_client_manager.ts +2 -2
- package/src/types/index.ts +1 -0
- package/src/versioning.ts +8 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bootstrap.d.ts","sourceRoot":"","sources":["../../src/bootstrap/bootstrap.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EAAsB,KAAK,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAInF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAGhD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAInD;;GAEG;AACH,qBAAa,aAAc,YAAW,eAAe;IAKjD,OAAO,CAAC,KAAK;IACb,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,MAAM;IANhB,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"bootstrap.d.ts","sourceRoot":"","sources":["../../src/bootstrap/bootstrap.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EAAsB,KAAK,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAInF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAGhD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAInD;;GAEG;AACH,qBAAa,aAAc,YAAW,eAAe;IAKjD,OAAO,CAAC,KAAK;IACb,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,MAAM;IANhB,OAAO,CAAC,IAAI,CAAC,CAAiC;IAC9C,OAAO,CAAC,MAAM,CAAC,CAAS;gBAGd,KAAK,EAAE,iBAAiB,EACxB,SAAS,EAAE,eAAe,EAC1B,MAAM,yCAAgC;IAGhD;;;;OAIG;IACU,KAAK,CAAC,MAAM,EAAE,cAAc;IAwEzC;;;OAGG;IACU,IAAI;IAOjB,OAAO,CAAC,iBAAiB;IAMzB,OAAO,CAAC,YAAY;IAMpB;;;OAGG;IACI,SAAS;IAKT,MAAM;IAKN,aAAa;IAKb,eAAe;CAIvB"}
|
package/dest/client/factory.d.ts
CHANGED
|
@@ -17,6 +17,9 @@ type P2PClientDeps<T extends P2PClientType> = {
|
|
|
17
17
|
attestationPool?: T extends P2PClientType.Full ? AttestationPool : undefined;
|
|
18
18
|
logger?: Logger;
|
|
19
19
|
};
|
|
20
|
-
export declare const
|
|
20
|
+
export declare const P2P_STORE_NAME = "p2p";
|
|
21
|
+
export declare const P2P_ARCHIVE_STORE_NAME = "p2p-archive";
|
|
22
|
+
export declare const P2P_PEER_STORE_NAME = "p2p-peers";
|
|
23
|
+
export declare const createP2PClient: <T extends P2PClientType>(clientType: T, _config: P2PConfig & DataStoreConfig, archiver: L2BlockSource & ContractDataSource, proofVerifier: ClientProtocolCircuitVerifier, worldStateSynchronizer: WorldStateSynchronizer, epochCache: EpochCacheInterface, packageVersion: string, telemetry?: TelemetryClient, deps?: P2PClientDeps<T>) => Promise<P2PClient<T>>;
|
|
21
24
|
export {};
|
|
22
25
|
//# sourceMappingURL=factory.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../src/client/factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAClE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAE9D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,KAAK,EAAE,6BAA6B,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAC7G,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,KAAK,eAAe,EAAsB,MAAM,yBAAyB,CAAC;AAEnF,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mDAAmD,CAAC;AAGzF,OAAO,EAAiB,KAAK,MAAM,EAAE,MAAM,+BAA+B,CAAC;AAM3E,KAAK,aAAa,CAAC,CAAC,SAAS,aAAa,IAAI;IAC5C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,iBAAiB,CAAC;IAC1B,eAAe,CAAC,EAAE,CAAC,SAAS,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M,cAAc,QAAQ,CAAC;AACpC,eAAO,MAAM,sBAAsB,gBAAgB,CAAC;AACpD,eAAO,MAAM,mBAAmB,cAAc,CAAC;AAC/C,eAAO,MAAM,eAAe,GAAU,CAAC,SAAS,aAAa,EAC3D,YAAY,CAAC,EACb,SAAS,SAAS,GAAG,eAAe,EACpC,UAAU,aAAa,GAAG,kBAAkB,EAC5C,eAAe,6BAA6B,EAC5C,wBAAwB,sBAAsB,EAC9C,YAAY,mBAAmB,EAC/B,gBAAgB,MAAM,EACtB,YAAW,eAAsC,EACjD,OAAM,aAAa,CAAC,CAAC,CAAM,0BA0D5B,CAAC"}
|
package/dest/client/factory.js
CHANGED
|
@@ -9,14 +9,18 @@ import { DiscV5Service } from '../services/discv5/discV5_service.js';
|
|
|
9
9
|
import { DummyP2PService } from '../services/dummy_service.js';
|
|
10
10
|
import { LibP2PService } from '../services/index.js';
|
|
11
11
|
import { configureP2PClientAddresses, createLibP2PPeerIdFromPrivateKey, getPeerIdPrivateKey } from '../util.js';
|
|
12
|
-
export const
|
|
12
|
+
export const P2P_STORE_NAME = 'p2p';
|
|
13
|
+
export const P2P_ARCHIVE_STORE_NAME = 'p2p-archive';
|
|
14
|
+
export const P2P_PEER_STORE_NAME = 'p2p-peers';
|
|
15
|
+
export const createP2PClient = async (clientType, _config, archiver, proofVerifier, worldStateSynchronizer, epochCache, packageVersion, telemetry = getTelemetryClient(), deps = {})=>{
|
|
13
16
|
let config = {
|
|
14
17
|
..._config,
|
|
15
18
|
dataStoreMapSizeKB: _config.p2pStoreMapSizeKb ?? _config.dataStoreMapSizeKB
|
|
16
19
|
};
|
|
17
20
|
const logger = deps.logger ?? createLogger('p2p');
|
|
18
|
-
const store = deps.store ?? await createStore(
|
|
19
|
-
const archive = await createStore(
|
|
21
|
+
const store = deps.store ?? await createStore(P2P_STORE_NAME, 2, config, createLogger('p2p:lmdb-v2'));
|
|
22
|
+
const archive = await createStore(P2P_ARCHIVE_STORE_NAME, 1, config, createLogger('p2p-archive:lmdb-v2'));
|
|
23
|
+
const peerStore = await createStore(P2P_PEER_STORE_NAME, 1, config, createLogger('p2p-peer:lmdb-v2'));
|
|
20
24
|
const mempools = {
|
|
21
25
|
txPool: deps.txPool ?? new AztecKVTxPool(store, archive, worldStateSynchronizer, telemetry, {
|
|
22
26
|
maxTxPoolSize: config.maxTxPoolSize,
|
|
@@ -24,18 +28,16 @@ export const createP2PClient = async (clientType, _config, archiver, proofVerifi
|
|
|
24
28
|
}),
|
|
25
29
|
attestationPool: clientType === P2PClientType.Full ? deps.attestationPool ?? new InMemoryAttestationPool(telemetry) : undefined
|
|
26
30
|
};
|
|
27
|
-
|
|
28
|
-
if (_config.p2pEnabled) {
|
|
29
|
-
logger.verbose('P2P is enabled. Using LibP2P service.');
|
|
30
|
-
config = await configureP2PClientAddresses(_config);
|
|
31
|
-
// Create peer discovery service
|
|
32
|
-
const peerIdPrivateKey = await getPeerIdPrivateKey(config, store, logger);
|
|
33
|
-
const peerId = await createLibP2PPeerIdFromPrivateKey(peerIdPrivateKey);
|
|
34
|
-
const discoveryService = new DiscV5Service(peerId, config, telemetry, createLogger(`${logger.module}:discv5_service`));
|
|
35
|
-
p2pService = await LibP2PService.new(clientType, config, discoveryService, peerId, mempools, archiver, epochCache, proofVerifier, worldStateSynchronizer, store, telemetry, createLogger(`${logger.module}:libp2p_service`));
|
|
36
|
-
} else {
|
|
31
|
+
if (!_config.p2pEnabled) {
|
|
37
32
|
logger.verbose('P2P is disabled. Using dummy P2P service');
|
|
38
|
-
|
|
33
|
+
return new P2PClient(clientType, store, archiver, mempools, new DummyP2PService(), config, telemetry);
|
|
39
34
|
}
|
|
35
|
+
logger.verbose('P2P is enabled. Using LibP2P service.');
|
|
36
|
+
config = await configureP2PClientAddresses(_config);
|
|
37
|
+
// Create peer discovery service
|
|
38
|
+
const peerIdPrivateKey = await getPeerIdPrivateKey(config, store, logger);
|
|
39
|
+
const peerId = await createLibP2PPeerIdFromPrivateKey(peerIdPrivateKey);
|
|
40
|
+
const discoveryService = new DiscV5Service(peerId, config, packageVersion, telemetry, createLogger(`${logger.module}:discv5_service`));
|
|
41
|
+
const p2pService = await LibP2PService.new(clientType, config, discoveryService, peerId, mempools, archiver, epochCache, proofVerifier, worldStateSynchronizer, peerStore, telemetry, createLogger(`${logger.module}:libp2p_service`));
|
|
40
42
|
return new P2PClient(clientType, store, archiver, mempools, p2pService, config, telemetry);
|
|
41
43
|
};
|
package/dest/client/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC"}
|
package/dest/client/index.js
CHANGED
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import type { L2BlockId } from '@aztec/stdlib/block';
|
|
2
|
+
import type { P2PApi } from '@aztec/stdlib/interfaces/server';
|
|
3
|
+
import { BlockAttestation, type BlockProposal, type P2PClientType } from '@aztec/stdlib/p2p';
|
|
4
|
+
import type { Tx, TxHash } from '@aztec/stdlib/tx';
|
|
5
|
+
import type { ENR } from '@chainsafe/enr';
|
|
6
|
+
import type { P2PConfig } from '../config.js';
|
|
7
|
+
/**
|
|
8
|
+
* Enum defining the possible states of the p2p client.
|
|
9
|
+
*/
|
|
10
|
+
export declare enum P2PClientState {
|
|
11
|
+
IDLE = 0,
|
|
12
|
+
SYNCHING = 1,
|
|
13
|
+
RUNNING = 2,
|
|
14
|
+
STOPPED = 3
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* The synchronization status of the P2P client.
|
|
18
|
+
*/
|
|
19
|
+
export interface P2PSyncState {
|
|
20
|
+
/**
|
|
21
|
+
* The current state of the p2p client.
|
|
22
|
+
*/
|
|
23
|
+
state: P2PClientState;
|
|
24
|
+
/**
|
|
25
|
+
* The block number that the p2p client is synced to.
|
|
26
|
+
*/
|
|
27
|
+
syncedToL2Block: L2BlockId;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Interface of a P2P client.
|
|
31
|
+
**/
|
|
32
|
+
export type P2P<T extends P2PClientType = P2PClientType.Full> = P2PApi<T> & {
|
|
33
|
+
/**
|
|
34
|
+
* Broadcasts a block proposal to other peers.
|
|
35
|
+
*
|
|
36
|
+
* @param proposal - the block proposal
|
|
37
|
+
*/
|
|
38
|
+
broadcastProposal(proposal: BlockProposal): Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* Registers a callback from the validator client that determines how to behave when
|
|
41
|
+
* foreign block proposals are received
|
|
42
|
+
*
|
|
43
|
+
* @param handler - A function taking a received block proposal and producing an attestation
|
|
44
|
+
*/
|
|
45
|
+
registerBlockProposalHandler(handler: (block: BlockProposal) => Promise<BlockAttestation | undefined>): void;
|
|
46
|
+
/**
|
|
47
|
+
* Request a list of transactions from another peer by their tx hashes.
|
|
48
|
+
* @param txHashes - Hashes of the txs to query.
|
|
49
|
+
* @returns A list of transactions or undefined if the transactions are not found.
|
|
50
|
+
*/
|
|
51
|
+
requestTxsByHash(txHashes: TxHash[]): Promise<(Tx | undefined)[]>;
|
|
52
|
+
/**
|
|
53
|
+
* Request a transaction from another peer by its tx hash.
|
|
54
|
+
* @param txHash - Hash of the tx to query.
|
|
55
|
+
*/
|
|
56
|
+
requestTxByHash(txHash: TxHash): Promise<Tx | undefined>;
|
|
57
|
+
/**
|
|
58
|
+
* Verifies the 'tx' and, if valid, adds it to local tx pool and forwards it to other peers.
|
|
59
|
+
* @param tx - The transaction.
|
|
60
|
+
**/
|
|
61
|
+
sendTx(tx: Tx): Promise<void>;
|
|
62
|
+
/**
|
|
63
|
+
* Adds transactions to the pool. Does not send to peers or validate the tx.
|
|
64
|
+
* @param txs - The transactions.
|
|
65
|
+
**/
|
|
66
|
+
addTxs(txs: Tx[]): Promise<void>;
|
|
67
|
+
/**
|
|
68
|
+
* Deletes 'txs' from the pool, given hashes.
|
|
69
|
+
* NOT used if we use sendTx as reconcileTxPool will handle this.
|
|
70
|
+
* @param txHashes - Hashes to check.
|
|
71
|
+
**/
|
|
72
|
+
deleteTxs(txHashes: TxHash[]): Promise<void>;
|
|
73
|
+
/**
|
|
74
|
+
* Returns a transaction in the transaction pool by its hash.
|
|
75
|
+
* @param txHash - Hash of tx to return.
|
|
76
|
+
* @returns A single tx or undefined.
|
|
77
|
+
*/
|
|
78
|
+
getTxByHashFromPool(txHash: TxHash): Promise<Tx | undefined>;
|
|
79
|
+
/**
|
|
80
|
+
* Returns transactions in the transaction pool by hash.
|
|
81
|
+
* @param txHashes - Hashes of txs to return.
|
|
82
|
+
* @returns An array of txs or undefined.
|
|
83
|
+
*/
|
|
84
|
+
getTxsByHashFromPool(txHashes: TxHash[]): Promise<(Tx | undefined)[]>;
|
|
85
|
+
/**
|
|
86
|
+
* Checks if transactions exist in the pool
|
|
87
|
+
* @param txHashes - The hashes of the transactions to check for
|
|
88
|
+
* @returns True or False for each hash
|
|
89
|
+
*/
|
|
90
|
+
hasTxsInPool(txHashes: TxHash[]): Promise<boolean[]>;
|
|
91
|
+
/**
|
|
92
|
+
* Returns a transaction in the transaction pool by its hash, requesting it from the network if it is not found.
|
|
93
|
+
* @param txHash - Hash of tx to return.
|
|
94
|
+
* @returns A single tx or undefined.
|
|
95
|
+
*/
|
|
96
|
+
getTxByHash(txHash: TxHash): Promise<Tx | undefined>;
|
|
97
|
+
/**
|
|
98
|
+
* Returns transactions in the transaction pool by hash, requesting from the network if not found.
|
|
99
|
+
* @param txHashes - Hashes of tx to return.
|
|
100
|
+
* @returns An array of tx or undefined.
|
|
101
|
+
*/
|
|
102
|
+
getTxsByHash(txHashes: TxHash[]): Promise<(Tx | undefined)[]>;
|
|
103
|
+
/**
|
|
104
|
+
* Returns an archived transaction from the transaction pool by its hash.
|
|
105
|
+
* @param txHash - Hash of tx to return.
|
|
106
|
+
* @returns A single tx or undefined.
|
|
107
|
+
*/
|
|
108
|
+
getArchivedTxByHash(txHash: TxHash): Promise<Tx | undefined>;
|
|
109
|
+
/**
|
|
110
|
+
* Returns whether the given tx hash is flagged as pending or mined.
|
|
111
|
+
* @param txHash - Hash of the tx to query.
|
|
112
|
+
* @returns Pending or mined depending on its status, or undefined if not found.
|
|
113
|
+
*/
|
|
114
|
+
getTxStatus(txHash: TxHash): Promise<'pending' | 'mined' | undefined>;
|
|
115
|
+
/** Returns an iterator over pending txs on the mempool. */
|
|
116
|
+
iteratePendingTxs(): AsyncIterableIterator<Tx>;
|
|
117
|
+
/** Returns the number of pending txs in the mempool. */
|
|
118
|
+
getPendingTxCount(): Promise<number>;
|
|
119
|
+
/**
|
|
120
|
+
* Marks transactions as non-evictable in the pool.
|
|
121
|
+
* @param txHashes - Hashes of the transactions to mark as non-evictable.
|
|
122
|
+
*/
|
|
123
|
+
markTxsAsNonEvictable(txHashes: TxHash[]): Promise<void>;
|
|
124
|
+
/**
|
|
125
|
+
* Starts the p2p client.
|
|
126
|
+
* @returns A promise signalling the completion of the block sync.
|
|
127
|
+
*/
|
|
128
|
+
start(): Promise<void>;
|
|
129
|
+
/**
|
|
130
|
+
* Stops the p2p client.
|
|
131
|
+
* @returns A promise signalling the completion of the stop process.
|
|
132
|
+
*/
|
|
133
|
+
stop(): Promise<void>;
|
|
134
|
+
/**
|
|
135
|
+
* Indicates if the p2p client is ready for transaction submission.
|
|
136
|
+
* @returns A boolean flag indicating readiness.
|
|
137
|
+
*/
|
|
138
|
+
isReady(): boolean;
|
|
139
|
+
/**
|
|
140
|
+
* Returns the current status of the p2p client.
|
|
141
|
+
*/
|
|
142
|
+
getStatus(): Promise<P2PSyncState>;
|
|
143
|
+
/**
|
|
144
|
+
* Returns the ENR of this node, if any.
|
|
145
|
+
*/
|
|
146
|
+
getEnr(): ENR | undefined;
|
|
147
|
+
/** Identifies a p2p client. */
|
|
148
|
+
isP2PClient(): true;
|
|
149
|
+
updateP2PConfig(config: Partial<P2PConfig>): Promise<void>;
|
|
150
|
+
/** Validates a set of txs. */
|
|
151
|
+
validate(txs: Tx[]): Promise<void>;
|
|
152
|
+
/** Clears the db. */
|
|
153
|
+
clear(): Promise<void>;
|
|
154
|
+
};
|
|
155
|
+
//# sourceMappingURL=interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../src/client/interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,KAAK,aAAa,EAAE,KAAK,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAC7F,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAE1C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C;;GAEG;AACH,oBAAY,cAAc;IACxB,IAAI,IAAA;IACJ,QAAQ,IAAA;IACR,OAAO,IAAA;IACP,OAAO,IAAA;CACR;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,KAAK,EAAE,cAAc,CAAC;IACtB;;OAEG;IACH,eAAe,EAAE,SAAS,CAAC;CAC5B;AAED;;IAEI;AACJ,MAAM,MAAM,GAAG,CAAC,CAAC,SAAS,aAAa,GAAG,aAAa,CAAC,IAAI,IAAI,MAAM,CAAC,CAAC,CAAC,GAAG;IAC1E;;;;OAIG;IACH,iBAAiB,CAAC,QAAQ,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE1D;;;;;OAKG;IAGH,4BAA4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C,EAAE,GAAG,SAAS,CAAC,CAAC;IAE7D;;;;OAIG;IACH,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,GAAG,OAAO,GAAG,SAAS,CAAC,CAAC;IAEtE,2DAA2D;IAC3D,iBAAiB,IAAI,qBAAqB,CAAC,EAAE,CAAC,CAAC;IAE/C,wDAAwD;IACxD,iBAAiB,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IAErC;;;OAGG;IACH,qBAAqB,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEzD;;;OAGG;IACH,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAEvB;;;OAGG;IACH,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAEtB;;;OAGG;IACH,OAAO,IAAI,OAAO,CAAC;IAEnB;;OAEG;IACH,SAAS,IAAI,OAAO,CAAC,YAAY,CAAC,CAAC;IAEnC;;OAEG;IACH,MAAM,IAAI,GAAG,GAAG,SAAS,CAAC;IAE1B,+BAA+B;IAC/B,WAAW,IAAI,IAAI,CAAC;IAEpB,eAAe,CAAC,MAAM,EAAE,OAAO,CAAC,SAAS,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE3D,8BAA8B;IAC9B,QAAQ,CAAC,GAAG,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEnC,qBAAqB;IACrB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enum defining the possible states of the p2p client.
|
|
3
|
+
*/ export var P2PClientState = /*#__PURE__*/ function(P2PClientState) {
|
|
4
|
+
P2PClientState[P2PClientState["IDLE"] = 0] = "IDLE";
|
|
5
|
+
P2PClientState[P2PClientState["SYNCHING"] = 1] = "SYNCHING";
|
|
6
|
+
P2PClientState[P2PClientState["RUNNING"] = 2] = "RUNNING";
|
|
7
|
+
P2PClientState[P2PClientState["STOPPED"] = 3] = "STOPPED";
|
|
8
|
+
return P2PClientState;
|
|
9
|
+
}({});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
2
|
-
import type {
|
|
2
|
+
import type { L2BlockSource, L2BlockStreamEvent, L2Tips } from '@aztec/stdlib/block';
|
|
3
3
|
import type { ContractDataSource } from '@aztec/stdlib/contract';
|
|
4
|
-
import type {
|
|
4
|
+
import type { PeerInfo } from '@aztec/stdlib/interfaces/server';
|
|
5
5
|
import { BlockAttestation, type BlockProposal, type P2PClientType } from '@aztec/stdlib/p2p';
|
|
6
6
|
import type { Tx, TxHash } from '@aztec/stdlib/tx';
|
|
7
7
|
import { type TelemetryClient, WithTracer } from '@aztec/telemetry-client';
|
|
@@ -9,152 +9,16 @@ import type { ENR } from '@chainsafe/enr';
|
|
|
9
9
|
import { type P2PConfig } from '../config.js';
|
|
10
10
|
import type { MemPools } from '../mem_pools/interface.js';
|
|
11
11
|
import type { P2PService } from '../services/service.js';
|
|
12
|
-
|
|
13
|
-
* Enum defining the possible states of the p2p client.
|
|
14
|
-
*/
|
|
15
|
-
export declare enum P2PClientState {
|
|
16
|
-
IDLE = 0,
|
|
17
|
-
SYNCHING = 1,
|
|
18
|
-
RUNNING = 2,
|
|
19
|
-
STOPPED = 3
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* The synchronization status of the P2P client.
|
|
23
|
-
*/
|
|
24
|
-
export interface P2PSyncState {
|
|
25
|
-
/**
|
|
26
|
-
* The current state of the p2p client.
|
|
27
|
-
*/
|
|
28
|
-
state: P2PClientState;
|
|
29
|
-
/**
|
|
30
|
-
* The block number that the p2p client is synced to.
|
|
31
|
-
*/
|
|
32
|
-
syncedToL2Block: L2BlockId;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Interface of a P2P client.
|
|
36
|
-
**/
|
|
37
|
-
export type P2P<T extends P2PClientType = P2PClientType.Full> = P2PApi<T> & {
|
|
38
|
-
/**
|
|
39
|
-
* Broadcasts a block proposal to other peers.
|
|
40
|
-
*
|
|
41
|
-
* @param proposal - the block proposal
|
|
42
|
-
*/
|
|
43
|
-
broadcastProposal(proposal: BlockProposal): void;
|
|
44
|
-
/**
|
|
45
|
-
* Registers a callback from the validator client that determines how to behave when
|
|
46
|
-
* foreign block proposals are received
|
|
47
|
-
*
|
|
48
|
-
* @param handler - A function taking a received block proposal and producing an attestation
|
|
49
|
-
*/
|
|
50
|
-
registerBlockProposalHandler(handler: (block: BlockProposal) => Promise<BlockAttestation | undefined>): void;
|
|
51
|
-
/**
|
|
52
|
-
* Request a list of transactions from another peer by their tx hashes.
|
|
53
|
-
* @param txHashes - Hashes of the txs to query.
|
|
54
|
-
* @returns A list of transactions or undefined if the transactions are not found.
|
|
55
|
-
*/
|
|
56
|
-
requestTxs(txHashes: TxHash[]): Promise<(Tx | undefined)[]>;
|
|
57
|
-
/**
|
|
58
|
-
* Request a transaction from another peer by its tx hash.
|
|
59
|
-
* @param txHash - Hash of the tx to query.
|
|
60
|
-
*/
|
|
61
|
-
requestTxByHash(txHash: TxHash): Promise<Tx | undefined>;
|
|
62
|
-
/**
|
|
63
|
-
* Verifies the 'tx' and, if valid, adds it to local tx pool and forwards it to other peers.
|
|
64
|
-
* @param tx - The transaction.
|
|
65
|
-
**/
|
|
66
|
-
sendTx(tx: Tx): Promise<void>;
|
|
67
|
-
/**
|
|
68
|
-
* Adds transactions to the pool. Does not send to peers or validate the tx.
|
|
69
|
-
* @param txs - The transactions.
|
|
70
|
-
**/
|
|
71
|
-
addTxs(txs: Tx[]): Promise<void>;
|
|
72
|
-
/**
|
|
73
|
-
* Deletes 'txs' from the pool, given hashes.
|
|
74
|
-
* NOT used if we use sendTx as reconcileTxPool will handle this.
|
|
75
|
-
* @param txHashes - Hashes to check.
|
|
76
|
-
**/
|
|
77
|
-
deleteTxs(txHashes: TxHash[]): Promise<void>;
|
|
78
|
-
/**
|
|
79
|
-
* Returns a transaction in the transaction pool by its hash.
|
|
80
|
-
* @param txHash - Hash of tx to return.
|
|
81
|
-
* @returns A single tx or undefined.
|
|
82
|
-
*/
|
|
83
|
-
getTxByHashFromPool(txHash: TxHash): Promise<Tx | undefined>;
|
|
84
|
-
/**
|
|
85
|
-
* Returns transactions in the transaction pool by hash.
|
|
86
|
-
* @param txHashes - Hashes of txs to return.
|
|
87
|
-
* @returns An array of txs or undefined.
|
|
88
|
-
*/
|
|
89
|
-
getTxsByHashFromPool(txHashes: TxHash[]): Promise<(Tx | undefined)[]>;
|
|
90
|
-
/**
|
|
91
|
-
* Checks if transactions exist in the pool
|
|
92
|
-
* @param txHashes - The hashes of the transactions to check for
|
|
93
|
-
* @returns True or False for each hash
|
|
94
|
-
*/
|
|
95
|
-
hasTxsInPool(txHashes: TxHash[]): Promise<boolean[]>;
|
|
96
|
-
/**
|
|
97
|
-
* Returns a transaction in the transaction pool by its hash, requesting it from the network if it is not found.
|
|
98
|
-
* @param txHash - Hash of tx to return.
|
|
99
|
-
* @returns A single tx or undefined.
|
|
100
|
-
*/
|
|
101
|
-
getTxByHash(txHash: TxHash): Promise<Tx | undefined>;
|
|
102
|
-
/**
|
|
103
|
-
* Returns transactions in the transaction pool by hash, requesting from the network if not found.
|
|
104
|
-
* @param txHashes - Hashes of tx to return.
|
|
105
|
-
* @returns An array of tx or undefined.
|
|
106
|
-
*/
|
|
107
|
-
getTxsByHash(txHashes: TxHash[]): Promise<(Tx | undefined)[]>;
|
|
108
|
-
/**
|
|
109
|
-
* Returns an archived transaction from the transaction pool by its hash.
|
|
110
|
-
* @param txHash - Hash of tx to return.
|
|
111
|
-
* @returns A single tx or undefined.
|
|
112
|
-
*/
|
|
113
|
-
getArchivedTxByHash(txHash: TxHash): Promise<Tx | undefined>;
|
|
114
|
-
/**
|
|
115
|
-
* Returns whether the given tx hash is flagged as pending or mined.
|
|
116
|
-
* @param txHash - Hash of the tx to query.
|
|
117
|
-
* @returns Pending or mined depending on its status, or undefined if not found.
|
|
118
|
-
*/
|
|
119
|
-
getTxStatus(txHash: TxHash): Promise<'pending' | 'mined' | undefined>;
|
|
120
|
-
/** Returns an iterator over pending txs on the mempool. */
|
|
121
|
-
iteratePendingTxs(): AsyncIterableIterator<Tx>;
|
|
122
|
-
/** Returns the number of pending txs in the mempool. */
|
|
123
|
-
getPendingTxCount(): Promise<number>;
|
|
124
|
-
/**
|
|
125
|
-
* Starts the p2p client.
|
|
126
|
-
* @returns A promise signalling the completion of the block sync.
|
|
127
|
-
*/
|
|
128
|
-
start(): Promise<void>;
|
|
129
|
-
/**
|
|
130
|
-
* Stops the p2p client.
|
|
131
|
-
* @returns A promise signalling the completion of the stop process.
|
|
132
|
-
*/
|
|
133
|
-
stop(): Promise<void>;
|
|
134
|
-
/**
|
|
135
|
-
* Indicates if the p2p client is ready for transaction submission.
|
|
136
|
-
* @returns A boolean flag indicating readiness.
|
|
137
|
-
*/
|
|
138
|
-
isReady(): boolean;
|
|
139
|
-
/**
|
|
140
|
-
* Returns the current status of the p2p client.
|
|
141
|
-
*/
|
|
142
|
-
getStatus(): Promise<P2PSyncState>;
|
|
143
|
-
/**
|
|
144
|
-
* Returns the ENR of this node, if any.
|
|
145
|
-
*/
|
|
146
|
-
getEnr(): ENR | undefined;
|
|
147
|
-
/** Identifies a p2p client. */
|
|
148
|
-
isP2PClient(): true;
|
|
149
|
-
updateP2PConfig(config: Partial<P2PConfig>): Promise<void>;
|
|
150
|
-
};
|
|
12
|
+
import { type P2P, type P2PSyncState } from './interface.js';
|
|
151
13
|
/**
|
|
152
14
|
* The P2P client implementation.
|
|
153
15
|
*/
|
|
154
16
|
export declare class P2PClient<T extends P2PClientType = P2PClientType.Full> extends WithTracer implements P2P, P2P<P2PClientType.Prover> {
|
|
155
17
|
#private;
|
|
18
|
+
private store;
|
|
156
19
|
private l2BlockSource;
|
|
157
20
|
private p2pService;
|
|
21
|
+
private telemetry;
|
|
158
22
|
private log;
|
|
159
23
|
/** The JS promise that will be running to keep the client's data in sync. Can be interrupted if the client is stopped. */
|
|
160
24
|
private runningPromise;
|
|
@@ -163,39 +27,39 @@ export declare class P2PClient<T extends P2PClientType = P2PClientType.Full> ext
|
|
|
163
27
|
private syncResolve?;
|
|
164
28
|
private latestBlockNumberAtStart;
|
|
165
29
|
private provenBlockNumberAtStart;
|
|
30
|
+
private finalizedBlockNumberAtStart;
|
|
166
31
|
private synchedBlockHashes;
|
|
167
32
|
private synchedLatestBlockNumber;
|
|
168
33
|
private synchedProvenBlockNumber;
|
|
34
|
+
private synchedFinalizedBlockNumber;
|
|
169
35
|
private synchedLatestSlot;
|
|
170
36
|
private txPool;
|
|
171
37
|
private attestationPool;
|
|
172
|
-
/** How many slots to keep attestations for. */
|
|
173
|
-
private keepAttestationsInPoolFor;
|
|
174
|
-
/** How many slots to keep proven txs for. */
|
|
175
|
-
private keepProvenTxsFor;
|
|
176
|
-
private blockStream;
|
|
177
38
|
private config;
|
|
39
|
+
private blockStream;
|
|
178
40
|
/**
|
|
179
41
|
* In-memory P2P client constructor.
|
|
180
42
|
* @param store - The client's instance of the KV store.
|
|
181
43
|
* @param l2BlockSource - P2P client's source for fetching existing blocks.
|
|
182
44
|
* @param txPool - The client's instance of a transaction pool. Defaults to in-memory implementation.
|
|
183
45
|
* @param p2pService - The concrete instance of p2p networking to use.
|
|
184
|
-
* @param keepProvenTxsFor - How many blocks have to pass after a block is proven before its txs are deleted (zero to delete immediately once proven).
|
|
185
46
|
* @param log - A logger.
|
|
186
47
|
*/
|
|
187
48
|
constructor(_clientType: T, store: AztecAsyncKVStore, l2BlockSource: L2BlockSource & ContractDataSource, mempools: MemPools<T>, p2pService: P2PService, config?: Partial<P2PConfig>, telemetry?: TelemetryClient, log?: import("@aztec/foundation/log").Logger);
|
|
49
|
+
clear(): Promise<void>;
|
|
188
50
|
isP2PClient(): true;
|
|
189
51
|
getPeers(includePending?: boolean): Promise<PeerInfo[]>;
|
|
190
52
|
getL2BlockHash(number: number): Promise<string | undefined>;
|
|
191
53
|
updateP2PConfig(config: Partial<P2PConfig>): Promise<void>;
|
|
192
54
|
getL2Tips(): Promise<L2Tips>;
|
|
193
55
|
handleBlockStreamEvent(event: L2BlockStreamEvent): Promise<void>;
|
|
56
|
+
private setBlockHash;
|
|
194
57
|
/**
|
|
195
58
|
* Starts the P2P client.
|
|
196
59
|
* @returns An empty promise signalling the synching process.
|
|
197
60
|
*/
|
|
198
61
|
start(): Promise<void>;
|
|
62
|
+
private initBlockStream;
|
|
199
63
|
/**
|
|
200
64
|
* Allows consumers to stop the instance of the P2P client.
|
|
201
65
|
* 'ready' will now return 'false' and the running promise that keeps the client synced is interrupted.
|
|
@@ -203,20 +67,10 @@ export declare class P2PClient<T extends P2PClientType = P2PClientType.Full> ext
|
|
|
203
67
|
stop(): Promise<void>;
|
|
204
68
|
/** Triggers a sync to the archiver. Used for testing. */
|
|
205
69
|
sync(): Promise<void>;
|
|
206
|
-
broadcastProposal(proposal: BlockProposal): void
|
|
70
|
+
broadcastProposal(proposal: BlockProposal): Promise<void>;
|
|
207
71
|
getAttestationsForSlot(slot: bigint, proposalId?: string): Promise<BlockAttestation[]>;
|
|
208
72
|
addAttestation(attestation: BlockAttestation): Promise<void>;
|
|
209
73
|
registerBlockProposalHandler(handler: (block: BlockProposal) => Promise<BlockAttestation | undefined>): void;
|
|
210
|
-
/**
|
|
211
|
-
* Requests the transactions with the given hashes from the network.
|
|
212
|
-
*
|
|
213
|
-
* If a transaction can be retrieved, it will be returned, if not an undefined
|
|
214
|
-
* will be returned. In place.
|
|
215
|
-
*
|
|
216
|
-
* @param txHashes - The hashes of the transactions to request.
|
|
217
|
-
* @returns A promise that resolves to an array of transactions or undefined.
|
|
218
|
-
*/
|
|
219
|
-
requestTxs(txHashes: TxHash[]): Promise<(Tx | undefined)[]>;
|
|
220
74
|
/**
|
|
221
75
|
* Uses the Request Response protocol to request a transaction from the network.
|
|
222
76
|
*
|
|
@@ -263,9 +117,9 @@ export declare class P2PClient<T extends P2PClientType = P2PClientType.Full> ext
|
|
|
263
117
|
* Returns transactions in the transaction pool by hash.
|
|
264
118
|
* If a transaction is not in the pool, it will be requested from the network.
|
|
265
119
|
* @param txHashes - Hashes of the transactions to look for.
|
|
266
|
-
* @returns The txs found, not
|
|
120
|
+
* @returns The txs found, or undefined if not found in the order requested.
|
|
267
121
|
*/
|
|
268
|
-
getTxsByHash(txHashes: TxHash[]): Promise<Tx[]>;
|
|
122
|
+
getTxsByHash(txHashes: TxHash[]): Promise<(Tx | undefined)[]>;
|
|
269
123
|
/**
|
|
270
124
|
* Returns an archived transaction in the transaction pool by its hash.
|
|
271
125
|
* @param txHash - Hash of the archived transaction to look for.
|
|
@@ -313,6 +167,7 @@ export declare class P2PClient<T extends P2PClientType = P2PClientType.Full> ext
|
|
|
313
167
|
* @returns Block number of latest proven L2 Block we've synced with.
|
|
314
168
|
*/
|
|
315
169
|
getSyncedProvenBlockNum(): Promise<number>;
|
|
170
|
+
getSyncedFinalizedBlockNum(): Promise<number>;
|
|
316
171
|
/** Returns latest L2 slot for which we have seen an L2 block. */
|
|
317
172
|
getSyncedLatestSlot(): Promise<bigint>;
|
|
318
173
|
/**
|
|
@@ -326,7 +181,6 @@ export declare class P2PClient<T extends P2PClientType = P2PClientType.Full> ext
|
|
|
326
181
|
* @returns Empty promise.
|
|
327
182
|
*/
|
|
328
183
|
private markTxsAsMinedFromBlocks;
|
|
329
|
-
private addAttestationsToPool;
|
|
330
184
|
/**
|
|
331
185
|
* Deletes txs from these blocks.
|
|
332
186
|
* @param blocks - A list of existing blocks with txs that the P2P client needs to ensure the tx pool is reconciled with.
|
|
@@ -339,12 +193,14 @@ export declare class P2PClient<T extends P2PClientType = P2PClientType.Full> ext
|
|
|
339
193
|
* @returns Empty promise.
|
|
340
194
|
*/
|
|
341
195
|
private handleLatestL2Blocks;
|
|
196
|
+
/** Request txs for unproven blocks so the prover node has more chances to get them. */
|
|
197
|
+
private requestMissingTxsFromUnprovenBlocks;
|
|
342
198
|
/**
|
|
343
|
-
* Handles new
|
|
344
|
-
* @param blocks - A list of
|
|
199
|
+
* Handles new finalized blocks by deleting the txs and attestations in them.
|
|
200
|
+
* @param blocks - A list of finalized L2 blocks.
|
|
345
201
|
* @returns Empty promise.
|
|
346
202
|
*/
|
|
347
|
-
private
|
|
203
|
+
private handleFinalizedL2Blocks;
|
|
348
204
|
/**
|
|
349
205
|
* Updates the tx pool after a chain prune.
|
|
350
206
|
* @param latestBlock - The block number the chain was pruned to.
|
|
@@ -356,5 +212,11 @@ export declare class P2PClient<T extends P2PClientType = P2PClientType.Full> ext
|
|
|
356
212
|
* @param newState - New state value.
|
|
357
213
|
*/
|
|
358
214
|
private setCurrentState;
|
|
215
|
+
validate(txs: Tx[]): Promise<void>;
|
|
216
|
+
/**
|
|
217
|
+
* Marks transactions as non-evictable in the pool.
|
|
218
|
+
* @param txHashes - Hashes of the transactions to mark as non-evictable.
|
|
219
|
+
*/
|
|
220
|
+
markTxsAsNonEvictable(txHashes: TxHash[]): Promise<void>;
|
|
359
221
|
}
|
|
360
222
|
//# sourceMappingURL=p2p_client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"p2p_client.d.ts","sourceRoot":"","sources":["../../src/client/p2p_client.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAsC,MAAM,iBAAiB,CAAC;AAC7F,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"p2p_client.d.ts","sourceRoot":"","sources":["../../src/client/p2p_client.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAsC,MAAM,iBAAiB,CAAC;AAC7F,OAAO,KAAK,EAGV,aAAa,EAEb,kBAAkB,EAClB,MAAM,EAEP,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,KAAK,EAAE,Q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