@aztec/p2p 0.0.1-commit.3f296a7d2 → 0.0.1-commit.42ee6df9b
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 +1 -1
- package/dest/client/factory.d.ts.map +1 -1
- package/dest/client/factory.js +5 -4
- package/dest/client/interface.d.ts +9 -2
- package/dest/client/interface.d.ts.map +1 -1
- package/dest/client/p2p_client.d.ts +3 -2
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +21 -8
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.js +14 -3
- package/dest/errors/p2p-service.error.d.ts +9 -0
- package/dest/errors/p2p-service.error.d.ts.map +1 -0
- package/dest/errors/p2p-service.error.js +10 -0
- package/dest/index.d.ts +1 -2
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +0 -1
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool.js +3 -2
- package/dest/mem_pools/index.d.ts +1 -2
- package/dest/mem_pools/index.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_metadata.js +5 -1
- package/dest/services/dummy_service.d.ts +5 -3
- package/dest/services/dummy_service.d.ts.map +1 -1
- package/dest/services/dummy_service.js +5 -1
- package/dest/services/libp2p/libp2p_service.d.ts +11 -3
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +21 -6
- package/dest/services/peer-manager/peer_manager.d.ts +6 -2
- package/dest/services/peer-manager/peer_manager.d.ts.map +1 -1
- package/dest/services/peer-manager/peer_manager.js +18 -6
- package/dest/services/peer-manager/peer_scoring.d.ts +5 -2
- package/dest/services/peer-manager/peer_scoring.d.ts.map +1 -1
- package/dest/services/peer-manager/peer_scoring.js +28 -10
- package/dest/services/reqresp/rate-limiter/rate_limiter.d.ts +5 -4
- package/dest/services/reqresp/rate-limiter/rate_limiter.d.ts.map +1 -1
- package/dest/services/reqresp/rate-limiter/rate_limiter.js +10 -8
- package/dest/services/service.d.ts +5 -2
- package/dest/services/service.d.ts.map +1 -1
- package/dest/services/tx_collection/file_store_tx_source.d.ts +5 -4
- package/dest/services/tx_collection/file_store_tx_source.d.ts.map +1 -1
- package/dest/services/tx_collection/file_store_tx_source.js +39 -29
- package/dest/services/tx_collection/tx_source.d.ts +6 -5
- package/dest/services/tx_collection/tx_source.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_source.js +9 -7
- package/dest/testbench/p2p_client_testbench_worker.js +41 -12
- package/dest/testbench/worker_client_manager.d.ts +1 -1
- package/dest/testbench/worker_client_manager.d.ts.map +1 -1
- package/dest/testbench/worker_client_manager.js +0 -1
- package/package.json +14 -14
- package/src/client/factory.ts +7 -2
- package/src/client/interface.ts +9 -1
- package/src/client/p2p_client.ts +23 -8
- package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +15 -3
- package/src/errors/p2p-service.error.ts +11 -0
- package/src/index.ts +0 -1
- package/src/mem_pools/attestation_pool/attestation_pool.ts +4 -2
- package/src/mem_pools/index.ts +0 -3
- package/src/mem_pools/tx_pool_v2/tx_metadata.ts +7 -1
- package/src/msg_validators/proposal_validator/README.md +1 -1
- package/src/services/dummy_service.ts +7 -2
- package/src/services/libp2p/libp2p_service.ts +29 -9
- package/src/services/peer-manager/peer_manager.ts +21 -6
- package/src/services/peer-manager/peer_scoring.ts +21 -5
- package/src/services/reqresp/rate-limiter/rate_limiter.ts +13 -9
- package/src/services/service.ts +6 -1
- package/src/services/tx_collection/file_store_tx_source.ts +43 -31
- package/src/services/tx_collection/tx_source.ts +8 -7
- package/src/testbench/p2p_client_testbench_worker.ts +40 -9
- package/src/testbench/worker_client_manager.ts +0 -1
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts +0 -125
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.js +0 -596
- package/dest/mem_pools/tx_pool/eviction/eviction_manager.d.ts +0 -32
- package/dest/mem_pools/tx_pool/eviction/eviction_manager.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/eviction/eviction_manager.js +0 -112
- package/dest/mem_pools/tx_pool/eviction/eviction_strategy.d.ts +0 -157
- package/dest/mem_pools/tx_pool/eviction/eviction_strategy.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/eviction/eviction_strategy.js +0 -52
- package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.d.ts +0 -16
- package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.js +0 -123
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.d.ts +0 -17
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.js +0 -84
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.d.ts +0 -19
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.js +0 -78
- package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.d.ts +0 -26
- package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.js +0 -84
- package/dest/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.d.ts +0 -25
- package/dest/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.js +0 -57
- package/dest/mem_pools/tx_pool/index.d.ts +0 -3
- package/dest/mem_pools/tx_pool/index.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/index.js +0 -2
- package/dest/mem_pools/tx_pool/priority.d.ts +0 -12
- package/dest/mem_pools/tx_pool/priority.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/priority.js +0 -15
- package/dest/mem_pools/tx_pool/tx_pool.d.ts +0 -127
- package/dest/mem_pools/tx_pool/tx_pool.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/tx_pool.js +0 -3
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts +0 -7
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.js +0 -402
- package/src/mem_pools/tx_pool/README.md +0 -270
- package/src/mem_pools/tx_pool/aztec_kv_tx_pool.ts +0 -746
- package/src/mem_pools/tx_pool/eviction/eviction_manager.ts +0 -132
- package/src/mem_pools/tx_pool/eviction/eviction_strategy.ts +0 -208
- package/src/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.ts +0 -163
- package/src/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.ts +0 -104
- package/src/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.ts +0 -93
- package/src/mem_pools/tx_pool/eviction/low_priority_eviction_rule.ts +0 -106
- package/src/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.ts +0 -75
- package/src/mem_pools/tx_pool/index.ts +0 -2
- package/src/mem_pools/tx_pool/priority.ts +0 -20
- package/src/mem_pools/tx_pool/tx_pool.ts +0 -141
- package/src/mem_pools/tx_pool/tx_pool_test_suite.ts +0 -321
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { partitionAsync } from '@aztec/foundation/collection';
|
|
1
2
|
import { createLogger } from '@aztec/foundation/log';
|
|
2
3
|
import { Timer } from '@aztec/foundation/timer';
|
|
3
4
|
import { createReadOnlyFileStore } from '@aztec/stdlib/file-store';
|
|
@@ -7,15 +8,17 @@ import { Metrics, getTelemetryClient } from '@aztec/telemetry-client';
|
|
|
7
8
|
fileStore;
|
|
8
9
|
baseUrl;
|
|
9
10
|
basePath;
|
|
11
|
+
txValidator;
|
|
10
12
|
log;
|
|
11
13
|
downloadsSuccess;
|
|
12
14
|
downloadsFailed;
|
|
13
15
|
downloadDuration;
|
|
14
16
|
downloadSize;
|
|
15
|
-
constructor(fileStore, baseUrl, basePath, log, telemetry){
|
|
17
|
+
constructor(fileStore, baseUrl, basePath, txValidator, log, telemetry){
|
|
16
18
|
this.fileStore = fileStore;
|
|
17
19
|
this.baseUrl = baseUrl;
|
|
18
20
|
this.basePath = basePath;
|
|
21
|
+
this.txValidator = txValidator;
|
|
19
22
|
this.log = log;
|
|
20
23
|
const meter = telemetry.getMeter('file-store-tx-source');
|
|
21
24
|
this.downloadsSuccess = meter.createUpDownCounter(Metrics.TX_FILE_STORE_DOWNLOADS_SUCCESS);
|
|
@@ -30,14 +33,14 @@ import { Metrics, getTelemetryClient } from '@aztec/telemetry-client';
|
|
|
30
33
|
* @param log - Optional logger.
|
|
31
34
|
* @param telemetry - Optional telemetry client.
|
|
32
35
|
* @returns The FileStoreTxSource instance, or undefined if creation fails.
|
|
33
|
-
*/ static async create(url, basePath, log = createLogger('p2p:file_store_tx_source'), telemetry = getTelemetryClient()) {
|
|
36
|
+
*/ static async create(url, basePath, txValidator, log = createLogger('p2p:file_store_tx_source'), telemetry = getTelemetryClient()) {
|
|
34
37
|
try {
|
|
35
38
|
const fileStore = await createReadOnlyFileStore(url, log);
|
|
36
39
|
if (!fileStore) {
|
|
37
40
|
log.warn(`Failed to create file store for URL: ${url}`);
|
|
38
41
|
return undefined;
|
|
39
42
|
}
|
|
40
|
-
return new FileStoreTxSource(fileStore, url, basePath, log, telemetry);
|
|
43
|
+
return new FileStoreTxSource(fileStore, url, basePath, txValidator, log, telemetry);
|
|
41
44
|
} catch (err) {
|
|
42
45
|
log.warn(`Error creating file store for URL: ${url}`, {
|
|
43
46
|
error: err
|
|
@@ -49,31 +52,38 @@ import { Metrics, getTelemetryClient } from '@aztec/telemetry-client';
|
|
|
49
52
|
return `file-store:${this.baseUrl}`;
|
|
50
53
|
}
|
|
51
54
|
async getTxsByHash(txHashes) {
|
|
52
|
-
const
|
|
55
|
+
const results = await Promise.all(txHashes.map(async (txHash)=>{
|
|
56
|
+
const path = `${this.basePath}/txs/${txHash.toString()}.bin`;
|
|
57
|
+
const timer = new Timer();
|
|
58
|
+
try {
|
|
59
|
+
const buffer = await this.fileStore.read(path);
|
|
60
|
+
const tx = Tx.fromBuffer(buffer);
|
|
61
|
+
return {
|
|
62
|
+
tx,
|
|
63
|
+
downloadDuration: timer.ms(),
|
|
64
|
+
downloadSize: buffer.length
|
|
65
|
+
};
|
|
66
|
+
} catch {
|
|
67
|
+
this.downloadsFailed.add(1);
|
|
68
|
+
return undefined;
|
|
69
|
+
}
|
|
70
|
+
}));
|
|
71
|
+
const txs = results.filter((tx)=>tx !== undefined);
|
|
72
|
+
const [validTxs, invalidTxs] = await partitionAsync(txs, async ({ tx, downloadDuration, downloadSize })=>{
|
|
73
|
+
const valid = await this.txValidator.validateTx(tx);
|
|
74
|
+
if (valid.result === 'valid') {
|
|
75
|
+
this.downloadsSuccess.add(1);
|
|
76
|
+
this.downloadDuration.record(Math.ceil(downloadDuration));
|
|
77
|
+
this.downloadSize.record(downloadSize);
|
|
78
|
+
return true;
|
|
79
|
+
} else {
|
|
80
|
+
this.downloadsFailed.add(1);
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
});
|
|
53
84
|
return {
|
|
54
|
-
validTxs:
|
|
55
|
-
|
|
56
|
-
const timer = new Timer();
|
|
57
|
-
try {
|
|
58
|
-
const buffer = await this.fileStore.read(path);
|
|
59
|
-
const tx = Tx.fromBuffer(buffer);
|
|
60
|
-
if (await tx.validateTxHash() && txHash.equals(tx.txHash)) {
|
|
61
|
-
this.downloadsSuccess.add(1);
|
|
62
|
-
this.downloadDuration.record(Math.ceil(timer.ms()));
|
|
63
|
-
this.downloadSize.record(buffer.length);
|
|
64
|
-
return tx;
|
|
65
|
-
} else {
|
|
66
|
-
invalidTxHashes.push(tx.txHash.toString());
|
|
67
|
-
this.downloadsFailed.add(1);
|
|
68
|
-
return undefined;
|
|
69
|
-
}
|
|
70
|
-
} catch {
|
|
71
|
-
// Tx not found or error reading - return undefined
|
|
72
|
-
this.downloadsFailed.add(1);
|
|
73
|
-
return undefined;
|
|
74
|
-
}
|
|
75
|
-
}))).filter((tx)=>tx !== undefined),
|
|
76
|
-
invalidTxHashes: invalidTxHashes
|
|
85
|
+
validTxs: validTxs.map(({ tx })=>tx),
|
|
86
|
+
invalidTxHashes: invalidTxs.map(({ tx })=>tx.getTxHash().toString())
|
|
77
87
|
};
|
|
78
88
|
}
|
|
79
89
|
}
|
|
@@ -84,7 +94,7 @@ import { Metrics, getTelemetryClient } from '@aztec/telemetry-client';
|
|
|
84
94
|
* @param log - Optional logger.
|
|
85
95
|
* @param telemetry - Optional telemetry client.
|
|
86
96
|
* @returns Array of successfully created FileStoreTxSource instances.
|
|
87
|
-
*/ export async function createFileStoreTxSources(urls, basePath, log = createLogger('p2p:file_store_tx_source'), telemetry = getTelemetryClient()) {
|
|
88
|
-
const sources = await Promise.all(urls.map((url)=>FileStoreTxSource.create(url, basePath, log, telemetry)));
|
|
97
|
+
*/ export async function createFileStoreTxSources(urls, basePath, txValidator, log = createLogger('p2p:file_store_tx_source'), telemetry = getTelemetryClient()) {
|
|
98
|
+
const sources = await Promise.all(urls.map((url)=>FileStoreTxSource.create(url, basePath, txValidator, log, telemetry)));
|
|
89
99
|
return sources.filter((s)=>s !== undefined);
|
|
90
100
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ChainConfig } from '@aztec/stdlib/config';
|
|
2
2
|
import { type AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
3
|
-
import type { Tx, TxHash } from '@aztec/stdlib/tx';
|
|
3
|
+
import type { Tx, TxHash, TxValidator } from '@aztec/stdlib/tx';
|
|
4
4
|
import { type ComponentsVersions } from '@aztec/stdlib/versioning';
|
|
5
5
|
export type TxSourceCollectionResult = {
|
|
6
6
|
validTxs: Tx[];
|
|
@@ -12,12 +12,13 @@ export interface TxSource {
|
|
|
12
12
|
}
|
|
13
13
|
export declare class NodeRpcTxSource implements TxSource {
|
|
14
14
|
private readonly client;
|
|
15
|
+
private readonly txValidator;
|
|
15
16
|
private readonly info;
|
|
16
|
-
constructor(client: Pick<AztecNode, 'getTxsByHash'>, info: string);
|
|
17
|
-
static fromUrl(nodeUrl: string, versions: ComponentsVersions): NodeRpcTxSource;
|
|
17
|
+
constructor(client: Pick<AztecNode, 'getTxsByHash'>, txValidator: TxValidator, info: string);
|
|
18
|
+
static fromUrl(nodeUrl: string, txValidator: TxValidator, versions: ComponentsVersions): NodeRpcTxSource;
|
|
18
19
|
getInfo(): string;
|
|
19
20
|
getTxsByHash(txHashes: TxHash[]): Promise<TxSourceCollectionResult>;
|
|
20
21
|
private verifyTxs;
|
|
21
22
|
}
|
|
22
|
-
export declare function createNodeRpcTxSources(urls: string[], chainConfig: ChainConfig): NodeRpcTxSource[];
|
|
23
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
23
|
+
export declare function createNodeRpcTxSources(urls: string[], txValidator: TxValidator, chainConfig: ChainConfig): NodeRpcTxSource[];
|
|
24
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHhfc291cmNlLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvc2VydmljZXMvdHhfY29sbGVjdGlvbi90eF9zb3VyY2UudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBRUEsT0FBTyxLQUFLLEVBQUUsV0FBVyxFQUFFLE1BQU0sc0JBQXNCLENBQUM7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U7WUFFYSxTQUFTO0NBZ0J4QjtBQUVELHdCQUFnQixzQkFBc0IsQ0FBQyxJQUFJLEVBQUUsTUFBTSxFQUFFLEVBQUUsV0FBVyxFQUFFLFdBQVcsRUFBRSxXQUFXLEVBQUUsV0FBVyxxQkFHeEcifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tx_source.d.ts","sourceRoot":"","sources":["../../../src/services/tx_collection/tx_source.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,KAAK,SAAS,EAAyB,MAAM,iCAAiC,CAAC;AACxF,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"tx_source.d.ts","sourceRoot":"","sources":["../../../src/services/tx_collection/tx_source.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,KAAK,SAAS,EAAyB,MAAM,iCAAiC,CAAC;AACxF,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,KAAK,kBAAkB,EAAmC,MAAM,0BAA0B,CAAC;AAGpG,MAAM,MAAM,wBAAwB,GAAG;IAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;IAAC,eAAe,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC;AAErF,MAAM,WAAW,QAAQ;IACvB,OAAO,IAAI,MAAM,CAAC;IAClB,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC;CACrE;AAED,qBAAa,eAAgB,YAAW,QAAQ;IAE5C,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,WAAW;IAC5B,OAAO,CAAC,QAAQ,CAAC,IAAI;IAHvB,YACmB,MAAM,EAAE,IAAI,CAAC,SAAS,EAAE,cAAc,CAAC,EACvC,WAAW,EAAE,WAAW,EACxB,IAAI,EAAE,MAAM,EAC3B;IAEJ,OAAc,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,QAAQ,EAAE,kBAAkB,GAAG,eAAe,CAG9G;IAEM,OAAO,WAEb;IAEY,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAE/E;YAEa,SAAS;CAgBxB;AAED,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,qBAGxG"}
|
|
@@ -5,18 +5,20 @@ import { getComponentsVersionsFromConfig } from '@aztec/stdlib/versioning';
|
|
|
5
5
|
import { makeTracedFetch } from '@aztec/telemetry-client';
|
|
6
6
|
export class NodeRpcTxSource {
|
|
7
7
|
client;
|
|
8
|
+
txValidator;
|
|
8
9
|
info;
|
|
9
|
-
constructor(client, info){
|
|
10
|
+
constructor(client, txValidator, info){
|
|
10
11
|
this.client = client;
|
|
12
|
+
this.txValidator = txValidator;
|
|
11
13
|
this.info = info;
|
|
12
14
|
}
|
|
13
|
-
static fromUrl(nodeUrl, versions) {
|
|
15
|
+
static fromUrl(nodeUrl, txValidator, versions) {
|
|
14
16
|
const client = createAztecNodeClient(nodeUrl, versions, makeTracedFetch([
|
|
15
17
|
1,
|
|
16
18
|
2,
|
|
17
19
|
3
|
|
18
20
|
], false));
|
|
19
|
-
return new NodeRpcTxSource(client, nodeUrl);
|
|
21
|
+
return new NodeRpcTxSource(client, txValidator, nodeUrl);
|
|
20
22
|
}
|
|
21
23
|
getInfo() {
|
|
22
24
|
return this.info;
|
|
@@ -29,8 +31,8 @@ export class NodeRpcTxSource {
|
|
|
29
31
|
const validTxs = [];
|
|
30
32
|
const invalidTxHashes = [];
|
|
31
33
|
await Promise.all(txs.map(async (tx)=>{
|
|
32
|
-
const
|
|
33
|
-
if (
|
|
34
|
+
const validation = await this.txValidator.validateTx(tx);
|
|
35
|
+
if (validation.result === 'valid') {
|
|
34
36
|
validTxs.push(tx);
|
|
35
37
|
} else {
|
|
36
38
|
invalidTxHashes.push(tx.getTxHash().toString());
|
|
@@ -42,7 +44,7 @@ export class NodeRpcTxSource {
|
|
|
42
44
|
};
|
|
43
45
|
}
|
|
44
46
|
}
|
|
45
|
-
export function createNodeRpcTxSources(urls, chainConfig) {
|
|
47
|
+
export function createNodeRpcTxSources(urls, txValidator, chainConfig) {
|
|
46
48
|
const versions = getComponentsVersionsFromConfig(chainConfig, protocolContractsHash, getVKTreeRoot());
|
|
47
|
-
return urls.map((url)=>NodeRpcTxSource.fromUrl(url, versions));
|
|
49
|
+
return urls.map((url)=>NodeRpcTxSource.fromUrl(url, txValidator, versions));
|
|
48
50
|
}
|
|
@@ -188,6 +188,35 @@ let workerAttestationPool = null;
|
|
|
188
188
|
let workerConfig = null;
|
|
189
189
|
let workerLogger = null;
|
|
190
190
|
let kvStore = null;
|
|
191
|
+
async function stopWorker() {
|
|
192
|
+
try {
|
|
193
|
+
if (workerClient) {
|
|
194
|
+
await workerClient.stop();
|
|
195
|
+
workerClient = null;
|
|
196
|
+
}
|
|
197
|
+
} catch (e) {
|
|
198
|
+
workerLogger?.error('Error stopping worker client', e);
|
|
199
|
+
}
|
|
200
|
+
try {
|
|
201
|
+
if (kvStore?.close) {
|
|
202
|
+
await kvStore.close();
|
|
203
|
+
kvStore = null;
|
|
204
|
+
}
|
|
205
|
+
} catch (e) {
|
|
206
|
+
workerLogger?.error('Error closing kv store', e);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
function gracefulExit(code = 0) {
|
|
210
|
+
try {
|
|
211
|
+
if (process.connected) {
|
|
212
|
+
process.disconnect();
|
|
213
|
+
}
|
|
214
|
+
} catch {
|
|
215
|
+
// IPC channel already closed
|
|
216
|
+
}
|
|
217
|
+
// Safety fallback if lingering handles prevent the event loop from draining
|
|
218
|
+
setTimeout(()=>process.exit(code), 5000).unref();
|
|
219
|
+
}
|
|
191
220
|
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
192
221
|
process.on('message', async (msg)=>{
|
|
193
222
|
const { type, config: rawConfig, clientIndex } = msg;
|
|
@@ -238,13 +267,8 @@ process.on('message', async (msg)=>{
|
|
|
238
267
|
const cmd = msg;
|
|
239
268
|
switch(cmd.type){
|
|
240
269
|
case 'STOP':
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
}
|
|
244
|
-
if (kvStore?.close) {
|
|
245
|
-
await kvStore.close();
|
|
246
|
-
}
|
|
247
|
-
process.exit(0);
|
|
270
|
+
await stopWorker();
|
|
271
|
+
gracefulExit(0);
|
|
248
272
|
break;
|
|
249
273
|
case 'SEND_TX':
|
|
250
274
|
if (workerClient) {
|
|
@@ -293,10 +317,15 @@ process.on('message', async (msg)=>{
|
|
|
293
317
|
}
|
|
294
318
|
}
|
|
295
319
|
} catch (err) {
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
320
|
+
try {
|
|
321
|
+
process.send({
|
|
322
|
+
type: 'ERROR',
|
|
323
|
+
error: err.message
|
|
324
|
+
});
|
|
325
|
+
} catch {
|
|
326
|
+
// IPC channel may be closed
|
|
327
|
+
}
|
|
328
|
+
await stopWorker();
|
|
329
|
+
gracefulExit(1);
|
|
301
330
|
}
|
|
302
331
|
});
|
|
@@ -95,4 +95,4 @@ declare class WorkerClientManager {
|
|
|
95
95
|
export { WorkerClientManager, testChainConfig };
|
|
96
96
|
export type { DistributionPattern, CollectorType } from './p2p_client_testbench_worker.js';
|
|
97
97
|
export { COLLECTOR_DISPLAY_NAMES } from './p2p_client_testbench_worker.js';
|
|
98
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
98
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoid29ya2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W,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,iBA8CpD;IAED;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAqCxB;;OAEG;IACG,OAAO,kBAgCZ;IAED;;;;;;;;;OASG;IACG,mBAAmB,CAAC,MAAM,EAAE,sBAAsB,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAuEzF;IAED,OAAO,CAAC,iBAAiB;IAkCzB,OAAO,CAAC,kBAAkB;CAiC3B;AAED,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,CAAC;AAChD,YAAY,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAC3F,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC"}
|
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.42ee6df9b",
|
|
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.42ee6df9b",
|
|
71
|
+
"@aztec/epoch-cache": "0.0.1-commit.42ee6df9b",
|
|
72
|
+
"@aztec/ethereum": "0.0.1-commit.42ee6df9b",
|
|
73
|
+
"@aztec/foundation": "0.0.1-commit.42ee6df9b",
|
|
74
|
+
"@aztec/kv-store": "0.0.1-commit.42ee6df9b",
|
|
75
|
+
"@aztec/noir-contracts.js": "0.0.1-commit.42ee6df9b",
|
|
76
|
+
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.42ee6df9b",
|
|
77
|
+
"@aztec/protocol-contracts": "0.0.1-commit.42ee6df9b",
|
|
78
|
+
"@aztec/simulator": "0.0.1-commit.42ee6df9b",
|
|
79
|
+
"@aztec/stdlib": "0.0.1-commit.42ee6df9b",
|
|
80
|
+
"@aztec/telemetry-client": "0.0.1-commit.42ee6df9b",
|
|
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.42ee6df9b",
|
|
108
|
+
"@aztec/world-state": "0.0.1-commit.42ee6df9b",
|
|
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
|
@@ -19,6 +19,7 @@ import type { TxPoolV2 } from '../mem_pools/tx_pool_v2/interfaces.js';
|
|
|
19
19
|
import { AztecKVTxPoolV2 } from '../mem_pools/tx_pool_v2/tx_pool_v2.js';
|
|
20
20
|
import {
|
|
21
21
|
createCheckAllowedSetupCalls,
|
|
22
|
+
createTxValidatorForReqResponseReceivedTxs,
|
|
22
23
|
createTxValidatorForTransactionsEnteringPendingTxPool,
|
|
23
24
|
getDefaultAllowedSetupFunctions,
|
|
24
25
|
} from '../msg_validators/index.js';
|
|
@@ -148,9 +149,12 @@ export async function createP2PClient(
|
|
|
148
149
|
telemetry,
|
|
149
150
|
);
|
|
150
151
|
|
|
152
|
+
const txValidatorForTxCollection = createTxValidatorForReqResponseReceivedTxs(proofVerifier, config);
|
|
151
153
|
const nodeSources = [
|
|
152
|
-
...createNodeRpcTxSources(config.txCollectionNodeRpcUrls, config),
|
|
153
|
-
...(deps.rpcTxProviders ?? []).map(
|
|
154
|
+
...createNodeRpcTxSources(config.txCollectionNodeRpcUrls, txValidatorForTxCollection, config),
|
|
155
|
+
...(deps.rpcTxProviders ?? []).map(
|
|
156
|
+
(node, i) => new NodeRpcTxSource(node, txValidatorForTxCollection, `node-rpc-provider-${i}`),
|
|
157
|
+
),
|
|
154
158
|
...(deps.txCollectionNodeSources ?? []),
|
|
155
159
|
];
|
|
156
160
|
if (nodeSources.length > 0) {
|
|
@@ -162,6 +166,7 @@ export async function createP2PClient(
|
|
|
162
166
|
const fileStoreSources = await createFileStoreTxSources(
|
|
163
167
|
config.txCollectionFileStoreUrls,
|
|
164
168
|
txFileStoreBasePath,
|
|
169
|
+
txValidatorForTxCollection,
|
|
165
170
|
logger.createChild('file-store-tx-source'),
|
|
166
171
|
telemetry,
|
|
167
172
|
);
|
package/src/client/interface.ts
CHANGED
|
@@ -82,7 +82,15 @@ export type P2P = P2PClient & {
|
|
|
82
82
|
*
|
|
83
83
|
* @param handler - A function taking a received checkpoint proposal and producing attestations
|
|
84
84
|
*/
|
|
85
|
-
|
|
85
|
+
registerValidatorCheckpointProposalHandler(callback: P2PCheckpointReceivedCallback): void;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Registers a callback that runs for ALL nodes (not just validators) when a checkpoint proposal is received.
|
|
89
|
+
* Used to set the proposed checkpoint number on the archiver so the sequencer can build on top of it.
|
|
90
|
+
*
|
|
91
|
+
* @param handler - A function taking a received checkpoint proposal
|
|
92
|
+
*/
|
|
93
|
+
registerAllNodesCheckpointProposalHandler(callback: P2PCheckpointReceivedCallback): void;
|
|
86
94
|
|
|
87
95
|
/**
|
|
88
96
|
* Registers a callback invoked when a duplicate proposal is detected (equivocation).
|
package/src/client/p2p_client.ts
CHANGED
|
@@ -357,6 +357,8 @@ export class P2PClient extends WithTracer implements P2P {
|
|
|
357
357
|
// Store our own last-block proposal so we can respond to req/resp requests for it.
|
|
358
358
|
await this.attestationPool.tryAddBlockProposal(blockProposal);
|
|
359
359
|
}
|
|
360
|
+
// Gossipsub doesn't deliver own messages, so fire the all-nodes handler locally
|
|
361
|
+
await this.p2pService.notifyOwnCheckpointProposal(proposal.toCore());
|
|
360
362
|
return this.p2pService.propagate(proposal);
|
|
361
363
|
}
|
|
362
364
|
|
|
@@ -388,8 +390,12 @@ export class P2PClient extends WithTracer implements P2P {
|
|
|
388
390
|
this.p2pService.registerBlockReceivedCallback(handler);
|
|
389
391
|
}
|
|
390
392
|
|
|
391
|
-
public
|
|
392
|
-
this.p2pService.
|
|
393
|
+
public registerValidatorCheckpointProposalHandler(handler: P2PCheckpointReceivedCallback): void {
|
|
394
|
+
this.p2pService.registerValidatorCheckpointReceivedCallback(handler);
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
public registerAllNodesCheckpointProposalHandler(handler: P2PCheckpointReceivedCallback): void {
|
|
398
|
+
this.p2pService.registerAllNodesCheckpointReceivedCallback(handler);
|
|
393
399
|
}
|
|
394
400
|
|
|
395
401
|
public registerDuplicateProposalCallback(callback: (info: DuplicateProposalInfo) => void): void {
|
|
@@ -696,14 +702,23 @@ export class P2PClient extends WithTracer implements P2P {
|
|
|
696
702
|
|
|
697
703
|
/** Checks if the slot has changed and calls prepareForSlot if so. */
|
|
698
704
|
private async maybeCallPrepareForSlot(): Promise<void> {
|
|
699
|
-
// If we have a
|
|
700
|
-
|
|
701
|
-
const
|
|
702
|
-
|
|
705
|
+
// If we have a proposed checkpoint available, we want to prepare the target slot - otherwise we prepare the current slot
|
|
706
|
+
const l2Tips = await this.l2Tips.getL2Tips();
|
|
707
|
+
const hasProposedCheckpoint = l2Tips.proposedCheckpoint.checkpoint.number > l2Tips.checkpointed.checkpoint.number;
|
|
708
|
+
|
|
709
|
+
let slot;
|
|
710
|
+
if (this.epochCache.isProposerPipeliningEnabled() && hasProposedCheckpoint) {
|
|
711
|
+
const { targetSlot } = this.epochCache.getTargetAndNextSlot();
|
|
712
|
+
slot = targetSlot;
|
|
713
|
+
} else {
|
|
714
|
+
const { currentSlot } = this.epochCache.getCurrentAndNextSlot();
|
|
715
|
+
slot = currentSlot;
|
|
716
|
+
}
|
|
717
|
+
if (slot <= this.lastSlotProcessed) {
|
|
703
718
|
return;
|
|
704
719
|
}
|
|
705
|
-
this.lastSlotProcessed =
|
|
706
|
-
await this.txPool.prepareForSlot(
|
|
720
|
+
this.lastSlotProcessed = slot;
|
|
721
|
+
await this.txPool.prepareForSlot(slot);
|
|
707
722
|
}
|
|
708
723
|
|
|
709
724
|
private async startServiceIfSynched() {
|
|
@@ -259,9 +259,20 @@ async function stopClient() {
|
|
|
259
259
|
attestationPool = undefined;
|
|
260
260
|
}
|
|
261
261
|
|
|
262
|
+
function gracefulExit(code: number = 0) {
|
|
263
|
+
try {
|
|
264
|
+
if (process.connected) {
|
|
265
|
+
process.disconnect();
|
|
266
|
+
}
|
|
267
|
+
} catch {
|
|
268
|
+
// IPC channel already closed
|
|
269
|
+
}
|
|
270
|
+
setTimeout(() => process.exit(code), 5000).unref();
|
|
271
|
+
}
|
|
272
|
+
|
|
262
273
|
process.on('disconnect', () => {
|
|
263
274
|
ipcDisconnected = true;
|
|
264
|
-
void stopClient()
|
|
275
|
+
void stopClient();
|
|
265
276
|
});
|
|
266
277
|
|
|
267
278
|
process.on('error', err => {
|
|
@@ -325,7 +336,7 @@ process.on('message', (msg: WorkerCommand) => {
|
|
|
325
336
|
case 'STOP': {
|
|
326
337
|
await stopClient();
|
|
327
338
|
await sendMessage({ type: 'STOPPED', requestId });
|
|
328
|
-
|
|
339
|
+
gracefulExit(0);
|
|
329
340
|
break;
|
|
330
341
|
}
|
|
331
342
|
default: {
|
|
@@ -336,7 +347,8 @@ process.on('message', (msg: WorkerCommand) => {
|
|
|
336
347
|
} catch (err: any) {
|
|
337
348
|
await sendMessage({ type: 'ERROR', requestId, error: err?.message ?? String(err) });
|
|
338
349
|
if (msg.type === 'START') {
|
|
339
|
-
|
|
350
|
+
await stopClient();
|
|
351
|
+
gracefulExit(1);
|
|
340
352
|
}
|
|
341
353
|
}
|
|
342
354
|
})();
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Checkpoint Proposal Received Callback Not Registered Error
|
|
2
|
+
*
|
|
3
|
+
* Error triggered if the allNodesCheckpointReceivedCallback is not registered
|
|
4
|
+
* @category Errors
|
|
5
|
+
*/
|
|
6
|
+
export class CheckpointProposalReceivedCallbackNotRegisteredError extends Error {
|
|
7
|
+
constructor() {
|
|
8
|
+
super('FATAL (allNodesCheckpointReceivedCallback): All nodes should register a checkpoint proposal handler');
|
|
9
|
+
this.name = 'CheckpointProposalReceivedCallbackNotRegisteredError';
|
|
10
|
+
}
|
|
11
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -6,7 +6,6 @@ export * from './client/index.js';
|
|
|
6
6
|
export * from './enr/index.js';
|
|
7
7
|
export * from './config.js';
|
|
8
8
|
export * from './mem_pools/attestation_pool/index.js';
|
|
9
|
-
export * from './mem_pools/tx_pool/index.js';
|
|
10
9
|
export * from './mem_pools/tx_pool_v2/index.js';
|
|
11
10
|
export * from './msg_validators/index.js';
|
|
12
11
|
export * from './services/index.js';
|
|
@@ -278,7 +278,7 @@ export class AttestationPool {
|
|
|
278
278
|
* @returns Result indicating whether the proposal was added and duplicate detection info
|
|
279
279
|
*/
|
|
280
280
|
public async tryAddCheckpointProposal(proposal: CheckpointProposalCore): Promise<TryAddResult> {
|
|
281
|
-
|
|
281
|
+
const result = await this.store.transactionAsync(async () => {
|
|
282
282
|
const proposalId = proposal.archive.toString();
|
|
283
283
|
|
|
284
284
|
// Check if already exists
|
|
@@ -304,6 +304,8 @@ export class AttestationPool {
|
|
|
304
304
|
|
|
305
305
|
return { added: true, alreadyExists: false, count: count + 1 };
|
|
306
306
|
});
|
|
307
|
+
|
|
308
|
+
return result;
|
|
307
309
|
}
|
|
308
310
|
|
|
309
311
|
/** Internal method - must be called within a transaction. */
|
|
@@ -345,7 +347,7 @@ export class AttestationPool {
|
|
|
345
347
|
await this.store.transactionAsync(async () => {
|
|
346
348
|
for (const attestation of attestations) {
|
|
347
349
|
const slotNumber = attestation.payload.header.slotNumber;
|
|
348
|
-
const proposalId = attestation.archive;
|
|
350
|
+
const proposalId = attestation.archive.toString();
|
|
349
351
|
const sender = attestation.getSender();
|
|
350
352
|
|
|
351
353
|
// Skip attestations with invalid signatures
|
package/src/mem_pools/index.ts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
1
|
export { AttestationPool, type AttestationPoolApi } from './attestation_pool/attestation_pool.js';
|
|
2
2
|
export { type MemPools } from './interface.js';
|
|
3
|
-
// Old TxPool exports - kept temporarily for external consumers
|
|
4
|
-
export { type TxPool } from './tx_pool/tx_pool.js';
|
|
5
|
-
// New TxPoolV2 exports
|
|
6
3
|
export { type TxPoolV2, type TxPoolV2Config, type TxPoolV2Events, type AddTxsResult } from './tx_pool_v2/index.js';
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { minBigint } from '@aztec/foundation/bigint';
|
|
1
2
|
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
3
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
4
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
@@ -6,7 +7,6 @@ import { Gas } from '@aztec/stdlib/gas';
|
|
|
6
7
|
import { type Tx, TxHash } from '@aztec/stdlib/tx';
|
|
7
8
|
|
|
8
9
|
import { getFeePayerBalanceDelta } from '../../msg_validators/tx_validator/fee_payer_balance.js';
|
|
9
|
-
import { getTxPriorityFee } from '../tx_pool/priority.js';
|
|
10
10
|
import { type PreAddResult, TxPoolRejectionCode } from './eviction/interfaces.js';
|
|
11
11
|
|
|
12
12
|
/** Validator-compatible data interface, mirroring the subset of PrivateKernelTailCircuitPublicInputs used by validators. */
|
|
@@ -335,3 +335,9 @@ export function stubTxMetaData(
|
|
|
335
335
|
data: stubTxMetaValidationData({ expirationTimestamp }),
|
|
336
336
|
};
|
|
337
337
|
}
|
|
338
|
+
|
|
339
|
+
/** Returns the priority fee for a tx, based on the L2 priority fee capped by the max fee per gas. */
|
|
340
|
+
function getTxPriorityFee(tx: Tx): bigint {
|
|
341
|
+
const { maxPriorityFeesPerGas: priorityFees, maxFeesPerGas } = tx.getGasSettings();
|
|
342
|
+
return minBigint(maxFeesPerGas.feePerL2Gas, priorityFees.feePerL2Gas);
|
|
343
|
+
}
|
|
@@ -53,7 +53,7 @@ Only runs on validator nodes. Non-validator nodes use a default handler that tri
|
|
|
53
53
|
|
|
54
54
|
**Escape hatch**: during escape hatch periods (`isEscapeHatchOpenAtSlot`), re-execution and slashing are both disabled, and the proposal is rejected locally.
|
|
55
55
|
|
|
56
|
-
**Conditional re-execution**: rules 22-24 only run when at least one condition is true: `fishermanMode` enabled, `slashBroadcastedInvalidBlockPenalty > 0
|
|
56
|
+
**Conditional re-execution**: rules 22-24 only run when at least one condition is true: `fishermanMode` enabled, `slashBroadcastedInvalidBlockPenalty > 0`, committee membership, `alwaysReexecuteBlockProposals`, or `blobClient.canUpload()`.
|
|
57
57
|
|
|
58
58
|
**Slashing**: only `state_mismatch` and `failed_txs` trigger on-chain slashing (`OffenseType.BROADCASTED_INVALID_BLOCK_PROPOSAL`, gated by `slashBroadcastedInvalidBlockPenalty > 0`). Unknown errors during re-execution do NOT slash.
|
|
59
59
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
2
|
import type { PeerInfo } from '@aztec/stdlib/interfaces/server';
|
|
3
|
-
import type { Gossipable, PeerErrorSeverity, TopicType } from '@aztec/stdlib/p2p';
|
|
3
|
+
import type { CheckpointProposalCore, Gossipable, PeerErrorSeverity, TopicType } from '@aztec/stdlib/p2p';
|
|
4
4
|
import { Tx, TxHash } from '@aztec/stdlib/tx';
|
|
5
5
|
|
|
6
6
|
import type { PeerId } from '@libp2p/interface';
|
|
@@ -86,7 +86,12 @@ export class DummyP2PService implements P2PService {
|
|
|
86
86
|
/**
|
|
87
87
|
* Register a callback into the validator client for when a checkpoint proposal is received
|
|
88
88
|
*/
|
|
89
|
-
public
|
|
89
|
+
public registerValidatorCheckpointReceivedCallback(_callback: P2PCheckpointReceivedCallback) {}
|
|
90
|
+
public registerAllNodesCheckpointReceivedCallback(_callback: P2PCheckpointReceivedCallback) {}
|
|
91
|
+
|
|
92
|
+
public notifyOwnCheckpointProposal(_checkpoint: CheckpointProposalCore): Promise<void> {
|
|
93
|
+
return Promise.resolve();
|
|
94
|
+
}
|
|
90
95
|
|
|
91
96
|
/**
|
|
92
97
|
* Register a callback for when a duplicate proposal is detected
|