@aztec/p2p 0.0.1-commit.b655e406 → 0.0.1-commit.fce3e4f
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 +1 -1
- package/dest/bootstrap/bootstrap.d.ts.map +1 -1
- package/dest/client/factory.d.ts +1 -1
- package/dest/client/index.d.ts +1 -1
- package/dest/client/interface.d.ts +4 -2
- package/dest/client/interface.d.ts.map +1 -1
- package/dest/client/p2p_client.d.ts +4 -22
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +10 -5
- package/dest/config.d.ts +60 -54
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +11 -1
- package/dest/enr/generate-enr.d.ts +1 -1
- package/dest/enr/index.d.ts +1 -1
- package/dest/errors/attestation-pool.error.d.ts +7 -0
- package/dest/errors/attestation-pool.error.d.ts.map +1 -0
- package/dest/errors/attestation-pool.error.js +12 -0
- package/dest/errors/reqresp.error.d.ts +1 -1
- package/dest/errors/reqresp.error.d.ts.map +1 -1
- package/dest/index.d.ts +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts +28 -6
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.js +33 -32
- package/dest/mem_pools/attestation_pool/index.d.ts +1 -1
- package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts +13 -6
- package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/kv_attestation_pool.js +40 -17
- package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts +11 -6
- package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/memory_attestation_pool.js +30 -8
- package/dest/mem_pools/attestation_pool/mocks.d.ts +224 -3
- 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/index.d.ts +1 -1
- package/dest/mem_pools/instrumentation.d.ts +3 -1
- package/dest/mem_pools/instrumentation.d.ts.map +1 -1
- package/dest/mem_pools/instrumentation.js +11 -2
- package/dest/mem_pools/interface.d.ts +1 -1
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts +1 -36
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/index.d.ts +1 -1
- package/dest/mem_pools/tx_pool/memory_tx_pool.d.ts +1 -1
- package/dest/mem_pools/tx_pool/memory_tx_pool.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/priority.d.ts +1 -1
- package/dest/mem_pools/tx_pool/tx_pool.d.ts +1 -1
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts +1 -1
- package/dest/msg_validators/attestation_validator/attestation_validator.d.ts +4 -3
- package/dest/msg_validators/attestation_validator/attestation_validator.d.ts.map +1 -1
- package/dest/msg_validators/attestation_validator/attestation_validator.js +11 -11
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts +20 -0
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts.map +1 -0
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.js +67 -0
- package/dest/msg_validators/attestation_validator/index.d.ts +2 -1
- package/dest/msg_validators/attestation_validator/index.d.ts.map +1 -1
- package/dest/msg_validators/attestation_validator/index.js +1 -0
- package/dest/msg_validators/block_proposal_validator/block_proposal_validator.d.ts +1 -1
- package/dest/msg_validators/block_proposal_validator/block_proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/block_proposal_validator/block_proposal_validator.js +21 -9
- package/dest/msg_validators/block_proposal_validator/index.d.ts +1 -1
- package/dest/msg_validators/index.d.ts +1 -1
- package/dest/msg_validators/msg_seen_validator/msg_seen_validator.d.ts +1 -1
- package/dest/msg_validators/msg_seen_validator/msg_seen_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts +1 -1
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/allowed_public_setup.d.ts +1 -1
- package/dest/msg_validators/tx_validator/archive_cache.d.ts +1 -1
- package/dest/msg_validators/tx_validator/archive_cache.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/block_header_validator.d.ts +1 -1
- package/dest/msg_validators/tx_validator/block_header_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/data_validator.d.ts +1 -1
- package/dest/msg_validators/tx_validator/data_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/double_spend_validator.d.ts +1 -1
- package/dest/msg_validators/tx_validator/double_spend_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/factory.d.ts +1 -1
- package/dest/msg_validators/tx_validator/gas_validator.d.ts +1 -1
- package/dest/msg_validators/tx_validator/gas_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/index.d.ts +1 -1
- package/dest/msg_validators/tx_validator/metadata_validator.d.ts +1 -1
- package/dest/msg_validators/tx_validator/metadata_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/phases_validator.d.ts +1 -1
- package/dest/msg_validators/tx_validator/phases_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/phases_validator.js +3 -1
- package/dest/msg_validators/tx_validator/test_utils.d.ts +1 -1
- package/dest/msg_validators/tx_validator/timestamp_validator.d.ts +1 -1
- package/dest/msg_validators/tx_validator/timestamp_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/tx_permitted_validator.d.ts +1 -1
- package/dest/msg_validators/tx_validator/tx_permitted_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/tx_proof_validator.d.ts +1 -1
- package/dest/msg_validators/tx_validator/tx_proof_validator.d.ts.map +1 -1
- package/dest/services/data_store.d.ts +1 -1
- package/dest/services/data_store.d.ts.map +1 -1
- package/dest/services/discv5/discV5_service.d.ts +1 -1
- package/dest/services/discv5/discV5_service.d.ts.map +1 -1
- package/dest/services/dummy_service.d.ts +1 -1
- package/dest/services/dummy_service.d.ts.map +1 -1
- package/dest/services/encoding.d.ts +1 -1
- package/dest/services/encoding.d.ts.map +1 -1
- package/dest/services/gossipsub/scoring.d.ts +1 -1
- package/dest/services/index.d.ts +1 -1
- package/dest/services/libp2p/instrumentation.d.ts +3 -1
- package/dest/services/libp2p/instrumentation.d.ts.map +1 -1
- package/dest/services/libp2p/instrumentation.js +9 -2
- package/dest/services/libp2p/libp2p_service.d.ts +11 -67
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +224 -54
- package/dest/services/peer-manager/interface.d.ts +1 -1
- package/dest/services/peer-manager/metrics.d.ts +3 -1
- package/dest/services/peer-manager/metrics.d.ts.map +1 -1
- package/dest/services/peer-manager/metrics.js +11 -0
- package/dest/services/peer-manager/peer_manager.d.ts +1 -32
- package/dest/services/peer-manager/peer_manager.d.ts.map +1 -1
- package/dest/services/peer-manager/peer_manager.js +2 -0
- package/dest/services/peer-manager/peer_scoring.d.ts +7 -2
- package/dest/services/peer-manager/peer_scoring.d.ts.map +1 -1
- package/dest/services/peer-manager/peer_scoring.js +40 -2
- package/dest/services/reqresp/config.d.ts +1 -1
- package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts +1 -1
- package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts.map +1 -1
- package/dest/services/reqresp/connection-sampler/connection_sampler.d.ts +1 -4
- package/dest/services/reqresp/connection-sampler/connection_sampler.d.ts.map +1 -1
- package/dest/services/reqresp/index.d.ts +1 -1
- package/dest/services/reqresp/interface.d.ts +1 -1
- package/dest/services/reqresp/interface.d.ts.map +1 -1
- package/dest/services/reqresp/metrics.d.ts +1 -1
- package/dest/services/reqresp/metrics.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/auth.d.ts +1 -1
- package/dest/services/reqresp/protocols/auth.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/block.d.ts +1 -1
- package/dest/services/reqresp/protocols/block_txs/bitvector.d.ts +1 -1
- package/dest/services/reqresp/protocols/block_txs/bitvector.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts +1 -1
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts +3 -5
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/block_txs/index.d.ts +1 -1
- package/dest/services/reqresp/protocols/goodbye.d.ts +1 -1
- package/dest/services/reqresp/protocols/goodbye.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/index.d.ts +1 -1
- package/dest/services/reqresp/protocols/ping.d.ts +1 -1
- package/dest/services/reqresp/protocols/status.d.ts +2 -2
- package/dest/services/reqresp/protocols/status.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/tx.d.ts +1 -1
- package/dest/services/reqresp/rate-limiter/index.d.ts +1 -1
- package/dest/services/reqresp/rate-limiter/rate_limiter.d.ts +2 -2
- package/dest/services/reqresp/rate-limiter/rate_limiter.d.ts.map +1 -1
- package/dest/services/reqresp/rate-limiter/rate_limits.d.ts +1 -1
- package/dest/services/reqresp/reqresp.d.ts +1 -41
- package/dest/services/reqresp/reqresp.d.ts.map +1 -1
- package/dest/services/reqresp/status.d.ts +2 -2
- package/dest/services/reqresp/status.d.ts.map +1 -1
- package/dest/services/service.d.ts +1 -1
- package/dest/services/tx_collection/config.d.ts +1 -1
- package/dest/services/tx_collection/fast_tx_collection.d.ts +1 -7
- package/dest/services/tx_collection/fast_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/index.d.ts +1 -1
- package/dest/services/tx_collection/instrumentation.d.ts +1 -1
- package/dest/services/tx_collection/instrumentation.d.ts.map +1 -1
- package/dest/services/tx_collection/slow_tx_collection.d.ts +1 -3
- package/dest/services/tx_collection/slow_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/slow_tx_collection.js +2 -1
- package/dest/services/tx_collection/tx_collection.d.ts +1 -2
- package/dest/services/tx_collection/tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_collection_sink.d.ts +3 -3
- package/dest/services/tx_collection/tx_collection_sink.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_source.d.ts +1 -1
- package/dest/services/tx_collection/tx_source.d.ts.map +1 -1
- package/dest/services/tx_provider.d.ts +1 -1
- package/dest/services/tx_provider.d.ts.map +1 -1
- package/dest/services/tx_provider_instrumentation.d.ts +1 -1
- package/dest/services/tx_provider_instrumentation.d.ts.map +1 -1
- package/dest/test-helpers/generate-peer-id-private-keys.d.ts +1 -1
- package/dest/test-helpers/get-ports.d.ts +1 -1
- package/dest/test-helpers/get-ports.d.ts.map +1 -1
- package/dest/test-helpers/index.d.ts +1 -1
- package/dest/test-helpers/make-enrs.d.ts +1 -1
- package/dest/test-helpers/make-test-p2p-clients.d.ts +2 -2
- package/dest/test-helpers/make-test-p2p-clients.d.ts.map +1 -1
- package/dest/test-helpers/mock-pubsub.d.ts +4 -4
- package/dest/test-helpers/mock-pubsub.d.ts.map +1 -1
- package/dest/test-helpers/mock-tx-helpers.d.ts +2 -2
- package/dest/test-helpers/mock-tx-helpers.d.ts.map +1 -1
- package/dest/test-helpers/reqresp-nodes.d.ts +1 -1
- package/dest/test-helpers/reqresp-nodes.d.ts.map +1 -1
- package/dest/testbench/p2p_client_testbench_worker.d.ts +1 -1
- package/dest/testbench/p2p_client_testbench_worker.js +11 -8
- package/dest/testbench/parse_log_file.d.ts +1 -1
- package/dest/testbench/testbench.d.ts +1 -1
- package/dest/testbench/worker_client_manager.d.ts +1 -1
- package/dest/testbench/worker_client_manager.d.ts.map +1 -1
- package/dest/types/index.d.ts +1 -1
- package/dest/util.d.ts +2 -1
- package/dest/util.d.ts.map +1 -1
- package/dest/util.js +11 -2
- package/dest/versioning.d.ts +1 -1
- package/package.json +19 -18
- package/src/client/interface.ts +4 -1
- package/src/client/p2p_client.ts +12 -6
- package/src/config.ts +18 -1
- package/src/errors/attestation-pool.error.ts +13 -0
- package/src/mem_pools/attestation_pool/attestation_pool.ts +29 -5
- package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +45 -32
- package/src/mem_pools/attestation_pool/kv_attestation_pool.ts +65 -23
- package/src/mem_pools/attestation_pool/memory_attestation_pool.ts +50 -16
- package/src/mem_pools/attestation_pool/mocks.ts +1 -1
- package/src/mem_pools/instrumentation.ts +13 -0
- package/src/msg_validators/attestation_validator/attestation_validator.ts +13 -15
- package/src/msg_validators/attestation_validator/fisherman_attestation_validator.ts +91 -0
- package/src/msg_validators/attestation_validator/index.ts +1 -0
- package/src/msg_validators/block_proposal_validator/block_proposal_validator.ts +25 -9
- package/src/msg_validators/tx_validator/phases_validator.ts +3 -1
- package/src/services/libp2p/instrumentation.ts +10 -1
- package/src/services/libp2p/libp2p_service.ts +248 -59
- package/src/services/peer-manager/metrics.ts +10 -0
- package/src/services/peer-manager/peer_manager.ts +2 -0
- package/src/services/peer-manager/peer_scoring.ts +46 -3
- package/src/services/tx_collection/slow_tx_collection.ts +3 -2
- package/src/testbench/p2p_client_testbench_worker.ts +8 -5
- package/src/util.ts +12 -2
package/dest/util.js
CHANGED
|
@@ -3,6 +3,7 @@ import { generateKeyPair, marshalPrivateKey, unmarshalPrivateKey } from '@libp2p
|
|
|
3
3
|
import { createFromPrivKey } from '@libp2p/peer-id-factory';
|
|
4
4
|
import { resolve } from 'dns/promises';
|
|
5
5
|
import { promises as fs } from 'fs';
|
|
6
|
+
import net from 'net';
|
|
6
7
|
import path from 'path';
|
|
7
8
|
const PEER_ID_DATA_DIR_FILE = 'p2p-private-key';
|
|
8
9
|
/**
|
|
@@ -22,9 +23,17 @@ const PEER_ID_DATA_DIR_FILE = 'p2p-private-key';
|
|
|
22
23
|
/**
|
|
23
24
|
* Queries the public IP address of the machine.
|
|
24
25
|
*/ export async function getPublicIp() {
|
|
25
|
-
const resp = await fetch('
|
|
26
|
+
const resp = await fetch('https://checkip.amazonaws.com/');
|
|
26
27
|
const text = await resp.text();
|
|
27
|
-
|
|
28
|
+
const address = text.trim();
|
|
29
|
+
if (!isValidIpAddress(address)) {
|
|
30
|
+
throw new Error(`Received invalid IP address from checkip service: ${address}`);
|
|
31
|
+
}
|
|
32
|
+
return address;
|
|
33
|
+
}
|
|
34
|
+
export function isValidIpAddress(address) {
|
|
35
|
+
const netType = net.isIP(address);
|
|
36
|
+
return netType === 4;
|
|
28
37
|
}
|
|
29
38
|
export async function resolveAddressIfNecessary(address, port) {
|
|
30
39
|
const multiaddrPrefix = addressToMultiAddressType(address);
|
package/dest/versioning.d.ts
CHANGED
|
@@ -9,4 +9,4 @@ export declare function setAztecEnrKey(enr: SignableENR, config: ChainConfig, us
|
|
|
9
9
|
export declare function setAztecClientVersionEnrKey(enr: SignableENR, clientVersion: string): void;
|
|
10
10
|
/** Checks the given value from an ENR record against the expected versions. */
|
|
11
11
|
export declare function checkAztecEnrVersion(enrValue: Buffer, expectedVersions: ComponentsVersions): void;
|
|
12
|
-
//# sourceMappingURL=
|
|
12
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidmVyc2lvbmluZy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL3ZlcnNpb25pbmcudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBR0EsT0FBTyxLQUFLLEVBQUUsV0FBVyxFQUFFLE1BQU0sc0JBQXNCLENBQUM7QUFDeEQsT0FBTyxFQUNMLEtBQUssa0JBQWtCLEVBSXhCLE1BQU0sMEJBQTBCLENBQUM7QUFFbEMsT0FBTyxLQUFLLEVBQUUsV0FBVyxFQUFFLE1BQU0sb0JBQW9CLENBQUM7QUFTdEQscUVBQXFFO0FBQ3JFLHdCQUFnQixXQUFXLENBQUMsTUFBTSxFQUFFLFdBQVcsc0JBRTlDO0FBRUQsaUVBQWlFO0FBQ2pFLHdCQUFnQixjQUFjLENBQUMsR0FBRyxFQUFFLFdBQVcsRUFBRSxNQUFNLEVBQUUsV0FBVyxFQUFFLFNBQVMsVUFBYyxzQkFLNUY7QUFFRCxtREFBbUQ7QUFDbkQsd0JBQWdCLDJCQUEyQixDQUFDLEdBQUcsRUFBRSxXQUFXLEVBQUUsYUFBYSxFQUFFLE1BQU0sUUFJbEY7QUFFRCwrRUFBK0U7QUFDL0Usd0JBQWdCLG9CQUFvQixDQUFDLFFBQVEsRUFBRSxNQUFNLEVBQUUsZ0JBQWdCLEVBQUUsa0JBQWtCLFFBVTFGIn0=
|
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.fce3e4f",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/index.js",
|
|
@@ -19,12 +19,12 @@
|
|
|
19
19
|
"tsconfig": "./tsconfig.json"
|
|
20
20
|
},
|
|
21
21
|
"scripts": {
|
|
22
|
-
"build": "yarn clean &&
|
|
23
|
-
"build:dev": "
|
|
22
|
+
"build": "yarn clean && tsgo -b",
|
|
23
|
+
"build:dev": "tsgo -b --watch",
|
|
24
24
|
"clean": "rm -rf ./dest .tsbuildinfo",
|
|
25
25
|
"test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests --maxWorkers=${JEST_MAX_WORKERS:-8}",
|
|
26
26
|
"start": "node ./dest",
|
|
27
|
-
"start:dev": "
|
|
27
|
+
"start:dev": "concurrently -k \"tsgo -b -w\" \"nodemon --watch dest --exec yarn start\""
|
|
28
28
|
},
|
|
29
29
|
"inherits": [
|
|
30
30
|
"../package.common.json"
|
|
@@ -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.fce3e4f",
|
|
71
|
+
"@aztec/epoch-cache": "0.0.1-commit.fce3e4f",
|
|
72
|
+
"@aztec/ethereum": "0.0.1-commit.fce3e4f",
|
|
73
|
+
"@aztec/foundation": "0.0.1-commit.fce3e4f",
|
|
74
|
+
"@aztec/kv-store": "0.0.1-commit.fce3e4f",
|
|
75
|
+
"@aztec/noir-contracts.js": "0.0.1-commit.fce3e4f",
|
|
76
|
+
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.fce3e4f",
|
|
77
|
+
"@aztec/protocol-contracts": "0.0.1-commit.fce3e4f",
|
|
78
|
+
"@aztec/simulator": "0.0.1-commit.fce3e4f",
|
|
79
|
+
"@aztec/stdlib": "0.0.1-commit.fce3e4f",
|
|
80
|
+
"@aztec/telemetry-client": "0.0.1-commit.fce3e4f",
|
|
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,11 +104,12 @@
|
|
|
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.fce3e4f",
|
|
108
|
+
"@aztec/world-state": "0.0.1-commit.fce3e4f",
|
|
109
109
|
"@jest/globals": "^30.0.0",
|
|
110
110
|
"@types/jest": "^30.0.0",
|
|
111
111
|
"@types/node": "^22.15.17",
|
|
112
|
+
"@typescript/native-preview": "7.0.0-dev.20251126.1",
|
|
112
113
|
"get-port": "^7.1.0",
|
|
113
114
|
"it-drain": "^3.0.5",
|
|
114
115
|
"it-length": "^3.0.6",
|
|
@@ -117,7 +118,7 @@
|
|
|
117
118
|
"ts-node": "^10.9.1",
|
|
118
119
|
"typescript": "^5.3.3",
|
|
119
120
|
"uint8arrays": "^5.0.3",
|
|
120
|
-
"viem": "npm:@
|
|
121
|
+
"viem": "npm:@aztec/viem@2.38.2"
|
|
121
122
|
},
|
|
122
123
|
"files": [
|
|
123
124
|
"dest",
|
package/src/client/interface.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { EthAddress, L2BlockId } from '@aztec/stdlib/block';
|
|
2
2
|
import type { P2PApiFull } from '@aztec/stdlib/interfaces/server';
|
|
3
|
-
import type { BlockProposal, P2PClientType } from '@aztec/stdlib/p2p';
|
|
3
|
+
import type { BlockAttestation, BlockProposal, P2PClientType } from '@aztec/stdlib/p2p';
|
|
4
4
|
import type { Tx, TxHash } from '@aztec/stdlib/tx';
|
|
5
5
|
|
|
6
6
|
import type { PeerId } from '@libp2p/interface';
|
|
@@ -50,6 +50,9 @@ export type P2P<T extends P2PClientType = P2PClientType.Full> = P2PApiFull<T> &
|
|
|
50
50
|
*/
|
|
51
51
|
broadcastProposal(proposal: BlockProposal): Promise<void>;
|
|
52
52
|
|
|
53
|
+
/** Broadcasts block attestations to other peers. */
|
|
54
|
+
broadcastAttestations(attestations: BlockAttestation[]): Promise<void>;
|
|
55
|
+
|
|
53
56
|
/**
|
|
54
57
|
* Registers a callback from the validator client that determines how to behave when
|
|
55
58
|
* foreign block proposals are received
|
package/src/client/p2p_client.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { INITIAL_L2_BLOCK_NUM } from '@aztec/constants';
|
|
2
|
+
import { SlotNumber } from '@aztec/foundation/branded-types';
|
|
2
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
3
4
|
import { DateProvider } from '@aztec/foundation/timer';
|
|
4
5
|
import type { AztecAsyncKVStore, AztecAsyncMap, AztecAsyncSingleton } from '@aztec/kv-store';
|
|
@@ -121,7 +122,7 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
121
122
|
this.log.debug(`Received block proposal from ${sender.toString()}`);
|
|
122
123
|
// TODO(palla/txs): Need to subtract validatorReexecuteDeadlineMs from this deadline (see ValidatorClient.getReexecutionDeadline)
|
|
123
124
|
const constants = this.txCollection.getConstants();
|
|
124
|
-
const nextSlotTimestampSeconds = Number(getTimestampForSlot(block.slotNumber
|
|
125
|
+
const nextSlotTimestampSeconds = Number(getTimestampForSlot(SlotNumber(block.slotNumber + 1), constants));
|
|
125
126
|
const deadline = new Date(nextSlotTimestampSeconds * 1000);
|
|
126
127
|
const parentBlock = await this.l2BlockSource.getBlockHeaderByArchive(block.payload.header.lastArchiveRoot);
|
|
127
128
|
if (!parentBlock) {
|
|
@@ -371,16 +372,21 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
371
372
|
}
|
|
372
373
|
|
|
373
374
|
@trackSpan('p2pClient.broadcastProposal', async proposal => ({
|
|
374
|
-
[Attributes.SLOT_NUMBER]: proposal.slotNumber
|
|
375
|
+
[Attributes.SLOT_NUMBER]: proposal.slotNumber,
|
|
375
376
|
[Attributes.BLOCK_ARCHIVE]: proposal.archive.toString(),
|
|
376
|
-
[Attributes.P2P_ID]: (await proposal.
|
|
377
|
+
[Attributes.P2P_ID]: (await proposal.p2pMessageLoggingIdentifier()).toString(),
|
|
377
378
|
}))
|
|
378
379
|
public broadcastProposal(proposal: BlockProposal): Promise<void> {
|
|
379
|
-
this.log.verbose(`Broadcasting proposal for slot ${proposal.slotNumber
|
|
380
|
+
this.log.verbose(`Broadcasting proposal for slot ${proposal.slotNumber} to peers`);
|
|
380
381
|
return this.p2pService.propagate(proposal);
|
|
381
382
|
}
|
|
382
383
|
|
|
383
|
-
public async
|
|
384
|
+
public async broadcastAttestations(attestations: BlockAttestation[]): Promise<void> {
|
|
385
|
+
this.log.verbose(`Broadcasting ${attestations.length} attestations to peers`);
|
|
386
|
+
await Promise.all(attestations.map(att => this.p2pService.propagate(att)));
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
public async getAttestationsForSlot(slot: SlotNumber, proposalId?: string): Promise<BlockAttestation[]> {
|
|
384
390
|
return (
|
|
385
391
|
(await (proposalId
|
|
386
392
|
? this.attestationPool?.getAttestationsForSlotAndProposal(slot, proposalId)
|
|
@@ -721,7 +727,7 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
721
727
|
);
|
|
722
728
|
|
|
723
729
|
await this.synchedLatestBlockNumber.set(lastBlock.number);
|
|
724
|
-
await this.synchedLatestSlot.set(lastBlock.header.getSlot());
|
|
730
|
+
await this.synchedLatestSlot.set(BigInt(lastBlock.header.getSlot()));
|
|
725
731
|
this.log.verbose(`Synched to latest block ${lastBlock.number}`);
|
|
726
732
|
await this.startServiceIfSynched();
|
|
727
733
|
}
|
package/src/config.ts
CHANGED
|
@@ -164,6 +164,12 @@ export interface P2PConfig extends P2PReqRespConfig, ChainConfig, TxCollectionCo
|
|
|
164
164
|
|
|
165
165
|
/** Whether to delete transactions from the pool after a reorg instead of moving them back to pending. */
|
|
166
166
|
txPoolDeleteTxsAfterReorg: boolean;
|
|
167
|
+
|
|
168
|
+
/** Alters the format of p2p messages to include things like broadcast timestamp FOR TESTING ONLY */
|
|
169
|
+
debugP2PInstrumentMessages: boolean;
|
|
170
|
+
|
|
171
|
+
/** Whether to run in fisherman mode: validates all proposals and attestations but does not broadcast attestations or participate in consensus */
|
|
172
|
+
fishermanMode: boolean;
|
|
167
173
|
}
|
|
168
174
|
|
|
169
175
|
export const DEFAULT_P2P_PORT = 40400;
|
|
@@ -406,7 +412,7 @@ export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
|
|
|
406
412
|
},
|
|
407
413
|
dropTransactionsProbability: {
|
|
408
414
|
env: 'P2P_DROP_TX_CHANCE',
|
|
409
|
-
description: 'The probability that a transaction is discarded. - For testing purposes only',
|
|
415
|
+
description: 'The probability that a transaction is discarded (0 - 1). - For testing purposes only',
|
|
410
416
|
...floatConfigHelper(0),
|
|
411
417
|
},
|
|
412
418
|
disableTransactions: {
|
|
@@ -420,6 +426,17 @@ export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
|
|
|
420
426
|
description: 'Whether to delete transactions from the pool after a reorg instead of moving them back to pending.',
|
|
421
427
|
...booleanConfigHelper(false),
|
|
422
428
|
},
|
|
429
|
+
debugP2PInstrumentMessages: {
|
|
430
|
+
env: 'DEBUG_P2P_INSTRUMENT_MESSAGES',
|
|
431
|
+
description: 'Alters the format of p2p messages to include things like broadcast timestamp FOR TESTING ONLY',
|
|
432
|
+
...booleanConfigHelper(false),
|
|
433
|
+
},
|
|
434
|
+
fishermanMode: {
|
|
435
|
+
env: 'FISHERMAN_MODE',
|
|
436
|
+
description:
|
|
437
|
+
'Whether to run in fisherman mode: validates all proposals and attestations but does not broadcast attestations or participate in consensus.',
|
|
438
|
+
...booleanConfigHelper(false),
|
|
439
|
+
},
|
|
423
440
|
...p2pReqRespConfigMappings,
|
|
424
441
|
...chainConfigMappings,
|
|
425
442
|
...txCollectionConfigMappings,
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export class AttestationPoolError extends Error {
|
|
2
|
+
constructor(message?: string) {
|
|
3
|
+
super(message);
|
|
4
|
+
this.name = 'AttestationPoolError';
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export class ProposalSlotCapExceededError extends AttestationPoolError {
|
|
9
|
+
constructor(message?: string) {
|
|
10
|
+
super(message);
|
|
11
|
+
this.name = 'ProposalSlotCapExceededError';
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { SlotNumber } from '@aztec/foundation/branded-types';
|
|
1
2
|
import type { BlockAttestation, BlockProposal } from '@aztec/stdlib/p2p';
|
|
2
3
|
|
|
3
4
|
/**
|
|
@@ -51,7 +52,7 @@ export interface AttestationPool {
|
|
|
51
52
|
*
|
|
52
53
|
* @param slot - The oldest slot to keep.
|
|
53
54
|
*/
|
|
54
|
-
deleteAttestationsOlderThan(slot:
|
|
55
|
+
deleteAttestationsOlderThan(slot: SlotNumber): Promise<void>;
|
|
55
56
|
|
|
56
57
|
/**
|
|
57
58
|
* Delete Attestations for slot
|
|
@@ -60,7 +61,7 @@ export interface AttestationPool {
|
|
|
60
61
|
*
|
|
61
62
|
* @param slot - The slot to delete.
|
|
62
63
|
*/
|
|
63
|
-
deleteAttestationsForSlot(slot:
|
|
64
|
+
deleteAttestationsForSlot(slot: SlotNumber): Promise<void>;
|
|
64
65
|
|
|
65
66
|
/**
|
|
66
67
|
* Delete Attestations for slot and proposal
|
|
@@ -70,7 +71,7 @@ export interface AttestationPool {
|
|
|
70
71
|
* @param slot - The slot to delete.
|
|
71
72
|
* @param proposalId - The proposal to delete.
|
|
72
73
|
*/
|
|
73
|
-
deleteAttestationsForSlotAndProposal(slot:
|
|
74
|
+
deleteAttestationsForSlotAndProposal(slot: SlotNumber, proposalId: string): Promise<void>;
|
|
74
75
|
|
|
75
76
|
/**
|
|
76
77
|
* Get all Attestations for all proposals for a given slot
|
|
@@ -80,7 +81,7 @@ export interface AttestationPool {
|
|
|
80
81
|
* @param slot - The slot to query
|
|
81
82
|
* @return BlockAttestations
|
|
82
83
|
*/
|
|
83
|
-
getAttestationsForSlot(slot:
|
|
84
|
+
getAttestationsForSlot(slot: SlotNumber): Promise<BlockAttestation[]>;
|
|
84
85
|
|
|
85
86
|
/**
|
|
86
87
|
* Get Attestations for slot and given proposal
|
|
@@ -91,7 +92,7 @@ export interface AttestationPool {
|
|
|
91
92
|
* @param proposalId - The proposal to query
|
|
92
93
|
* @return BlockAttestations
|
|
93
94
|
*/
|
|
94
|
-
getAttestationsForSlotAndProposal(slot:
|
|
95
|
+
getAttestationsForSlotAndProposal(slot: SlotNumber, proposalId: string): Promise<BlockAttestation[]>;
|
|
95
96
|
|
|
96
97
|
/**
|
|
97
98
|
* Check if a specific attestation exists in the pool
|
|
@@ -101,6 +102,29 @@ export interface AttestationPool {
|
|
|
101
102
|
*/
|
|
102
103
|
hasAttestation(attestation: BlockAttestation): Promise<boolean>;
|
|
103
104
|
|
|
105
|
+
/**
|
|
106
|
+
* Returns whether adding this proposal is permitted at current capacity:
|
|
107
|
+
* - True if the proposal already exists, allow overwrite to keep parity with tests.
|
|
108
|
+
* - True if the slot is below the proposal cap.
|
|
109
|
+
* - False if the slot is at/above cap and this would be a new unique proposal.
|
|
110
|
+
*
|
|
111
|
+
* @param block - The block proposal to check
|
|
112
|
+
* @returns True if the proposal can be added (or already exists), false otherwise.
|
|
113
|
+
*/
|
|
114
|
+
canAddProposal(block: BlockProposal): Promise<boolean>;
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Returns whether an attestation would be accepted for (slot, proposalId):
|
|
118
|
+
* - True if the attestation already exists for this sender.
|
|
119
|
+
* - True if the attestation cap for (slot, proposalId) has not been reached.
|
|
120
|
+
* - False if the cap is reached and this attestation would be a new unique entry.
|
|
121
|
+
*
|
|
122
|
+
* @param attestation - The attestation to check
|
|
123
|
+
* @param committeeSize - Committee size for the attestation's slot, implementation may add a small buffer
|
|
124
|
+
* @returns True if the attestation can be added, false otherwise.
|
|
125
|
+
*/
|
|
126
|
+
canAddAttestation(attestation: BlockAttestation, committeeSize: number): Promise<boolean>;
|
|
127
|
+
|
|
104
128
|
/** Returns whether the pool is empty. */
|
|
105
129
|
isEmpty(): Promise<boolean>;
|
|
106
130
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { SlotNumber } from '@aztec/foundation/branded-types';
|
|
1
2
|
import { Secp256k1Signer } from '@aztec/foundation/crypto';
|
|
2
3
|
import { Fr } from '@aztec/foundation/fields';
|
|
3
4
|
import type { BlockAttestation, BlockProposal } from '@aztec/stdlib/p2p';
|
|
@@ -42,7 +43,7 @@ export function describeAttestationPool(getAttestationPool: () => AttestationPoo
|
|
|
42
43
|
|
|
43
44
|
const mockBlockProposal = (signer: Secp256k1Signer, slotNumber: number, archive: Fr = Fr.random()): BlockProposal => {
|
|
44
45
|
const header = makeL2BlockHeader(1, 2, slotNumber);
|
|
45
|
-
const payload = new ConsensusPayload(header.toCheckpointHeader(), archive
|
|
46
|
+
const payload = new ConsensusPayload(header.toCheckpointHeader(), archive);
|
|
46
47
|
|
|
47
48
|
const hash = getHashedSignaturePayloadEthSignedMessage(payload, SignatureDomainSeparator.blockProposal);
|
|
48
49
|
const signature = signer.sign(hash);
|
|
@@ -68,7 +69,10 @@ export function describeAttestationPool(getAttestationPool: () => AttestationPoo
|
|
|
68
69
|
|
|
69
70
|
await ap.addAttestations(attestations);
|
|
70
71
|
|
|
71
|
-
const retrievedAttestations = await ap.getAttestationsForSlotAndProposal(
|
|
72
|
+
const retrievedAttestations = await ap.getAttestationsForSlotAndProposal(
|
|
73
|
+
SlotNumber(slotNumber),
|
|
74
|
+
archive.toString(),
|
|
75
|
+
);
|
|
72
76
|
expect(retrievedAttestations.length).toBe(attestations.length);
|
|
73
77
|
compareAttestations(retrievedAttestations, attestations);
|
|
74
78
|
|
|
@@ -77,7 +81,7 @@ export function describeAttestationPool(getAttestationPool: () => AttestationPoo
|
|
|
77
81
|
expect(await ap.hasAttestation(attestation)).toBe(true);
|
|
78
82
|
}
|
|
79
83
|
|
|
80
|
-
const retrievedAttestationsForSlot = await ap.getAttestationsForSlot(
|
|
84
|
+
const retrievedAttestationsForSlot = await ap.getAttestationsForSlot(SlotNumber(slotNumber));
|
|
81
85
|
expect(retrievedAttestationsForSlot.length).toBe(attestations.length);
|
|
82
86
|
compareAttestations(retrievedAttestationsForSlot, attestations);
|
|
83
87
|
|
|
@@ -85,21 +89,21 @@ export function describeAttestationPool(getAttestationPool: () => AttestationPoo
|
|
|
85
89
|
const newAttestation = mockAttestation(signers[NUMBER_OF_SIGNERS_PER_TEST - 1], slotNumber, archive);
|
|
86
90
|
await ap.addAttestations([newAttestation]);
|
|
87
91
|
const retrievedAttestationsAfterAdd = await ap.getAttestationsForSlotAndProposal(
|
|
88
|
-
|
|
92
|
+
SlotNumber(slotNumber),
|
|
89
93
|
archive.toString(),
|
|
90
94
|
);
|
|
91
95
|
expect(retrievedAttestationsAfterAdd.length).toBe(attestations.length + 1);
|
|
92
96
|
compareAttestations(retrievedAttestationsAfterAdd, [...attestations, newAttestation]);
|
|
93
97
|
expect(await ap.hasAttestation(newAttestation)).toBe(true);
|
|
94
|
-
const retrievedAttestationsForSlotAfterAdd = await ap.getAttestationsForSlot(
|
|
98
|
+
const retrievedAttestationsForSlotAfterAdd = await ap.getAttestationsForSlot(SlotNumber(slotNumber));
|
|
95
99
|
expect(retrievedAttestationsForSlotAfterAdd.length).toBe(attestations.length + 1);
|
|
96
100
|
compareAttestations(retrievedAttestationsForSlotAfterAdd, [...attestations, newAttestation]);
|
|
97
101
|
|
|
98
102
|
// Delete by slot
|
|
99
|
-
await ap.deleteAttestationsForSlot(
|
|
103
|
+
await ap.deleteAttestationsForSlot(SlotNumber(slotNumber));
|
|
100
104
|
|
|
101
105
|
const retreivedAttestationsAfterDelete = await ap.getAttestationsForSlotAndProposal(
|
|
102
|
-
|
|
106
|
+
SlotNumber(slotNumber),
|
|
103
107
|
archive.toString(),
|
|
104
108
|
);
|
|
105
109
|
expect(retreivedAttestationsAfterDelete.length).toBe(0);
|
|
@@ -124,14 +128,17 @@ export function describeAttestationPool(getAttestationPool: () => AttestationPoo
|
|
|
124
128
|
// Add them to store and check we end up with only one
|
|
125
129
|
await ap.addAttestations(attestations);
|
|
126
130
|
|
|
127
|
-
const retreivedAttestations = await ap.getAttestationsForSlotAndProposal(
|
|
131
|
+
const retreivedAttestations = await ap.getAttestationsForSlotAndProposal(
|
|
132
|
+
SlotNumber(slotNumber),
|
|
133
|
+
archive.toString(),
|
|
134
|
+
);
|
|
128
135
|
expect(retreivedAttestations.length).toBe(1);
|
|
129
136
|
expect(retreivedAttestations[0].toBuffer()).toEqual(attestations[0].toBuffer());
|
|
130
137
|
expect(retreivedAttestations[0].getSender()?.toString()).toEqual(signer.address.toString());
|
|
131
138
|
|
|
132
139
|
// Try adding them on another operation and check they are still not duplicated
|
|
133
140
|
await ap.addAttestations([attestations[0]]);
|
|
134
|
-
expect(await ap.getAttestationsForSlotAndProposal(
|
|
141
|
+
expect(await ap.getAttestationsForSlotAndProposal(SlotNumber(slotNumber), archive.toString())).toHaveLength(1);
|
|
135
142
|
});
|
|
136
143
|
|
|
137
144
|
it('should store attestations by differing slot', async () => {
|
|
@@ -144,7 +151,7 @@ export function describeAttestationPool(getAttestationPool: () => AttestationPoo
|
|
|
144
151
|
const slot = attestation.payload.header.slotNumber;
|
|
145
152
|
const archive = attestation.archive.toString();
|
|
146
153
|
|
|
147
|
-
const retreivedAttestations = await ap.getAttestationsForSlotAndProposal(slot
|
|
154
|
+
const retreivedAttestations = await ap.getAttestationsForSlotAndProposal(slot, archive);
|
|
148
155
|
expect(retreivedAttestations.length).toBe(1);
|
|
149
156
|
expect(retreivedAttestations[0].toBuffer()).toEqual(attestation.toBuffer());
|
|
150
157
|
expect(retreivedAttestations[0].payload.header.slotNumber).toEqual(slot);
|
|
@@ -162,7 +169,7 @@ export function describeAttestationPool(getAttestationPool: () => AttestationPoo
|
|
|
162
169
|
const slot = attestation.payload.header.slotNumber;
|
|
163
170
|
const proposalId = attestation.archive.toString();
|
|
164
171
|
|
|
165
|
-
const retreivedAttestations = await ap.getAttestationsForSlotAndProposal(slot
|
|
172
|
+
const retreivedAttestations = await ap.getAttestationsForSlotAndProposal(slot, proposalId);
|
|
166
173
|
expect(retreivedAttestations.length).toBe(1);
|
|
167
174
|
expect(retreivedAttestations[0].toBuffer()).toEqual(attestation.toBuffer());
|
|
168
175
|
expect(retreivedAttestations[0].payload.header.slotNumber).toEqual(slot);
|
|
@@ -177,7 +184,7 @@ export function describeAttestationPool(getAttestationPool: () => AttestationPoo
|
|
|
177
184
|
|
|
178
185
|
await ap.addAttestations(attestations);
|
|
179
186
|
|
|
180
|
-
const retreivedAttestations = await ap.getAttestationsForSlotAndProposal(
|
|
187
|
+
const retreivedAttestations = await ap.getAttestationsForSlotAndProposal(SlotNumber(slotNumber), proposalId);
|
|
181
188
|
expect(retreivedAttestations.length).toBe(NUMBER_OF_SIGNERS_PER_TEST);
|
|
182
189
|
compareAttestations(retreivedAttestations, attestations);
|
|
183
190
|
|
|
@@ -188,7 +195,7 @@ export function describeAttestationPool(getAttestationPool: () => AttestationPoo
|
|
|
188
195
|
|
|
189
196
|
await ap.deleteAttestations(attestations);
|
|
190
197
|
|
|
191
|
-
const gottenAfterDelete = await ap.getAttestationsForSlotAndProposal(
|
|
198
|
+
const gottenAfterDelete = await ap.getAttestationsForSlotAndProposal(SlotNumber(slotNumber), proposalId);
|
|
192
199
|
expect(gottenAfterDelete.length).toBe(0);
|
|
193
200
|
|
|
194
201
|
// Check hasAttestation after deletion
|
|
@@ -205,13 +212,16 @@ export function describeAttestationPool(getAttestationPool: () => AttestationPoo
|
|
|
205
212
|
|
|
206
213
|
await ap.addAttestations(attestations);
|
|
207
214
|
|
|
208
|
-
const retreivedAttestations = await ap.getAttestationsForSlotAndProposal(
|
|
215
|
+
const retreivedAttestations = await ap.getAttestationsForSlotAndProposal(SlotNumber(slotNumber), proposalId);
|
|
209
216
|
expect(retreivedAttestations.length).toBe(NUMBER_OF_SIGNERS_PER_TEST);
|
|
210
217
|
compareAttestations(retreivedAttestations, attestations);
|
|
211
218
|
|
|
212
|
-
await ap.deleteAttestationsForSlot(
|
|
219
|
+
await ap.deleteAttestationsForSlot(SlotNumber(slotNumber));
|
|
213
220
|
|
|
214
|
-
const retreivedAttestationsAfterDelete = await ap.getAttestationsForSlotAndProposal(
|
|
221
|
+
const retreivedAttestationsAfterDelete = await ap.getAttestationsForSlotAndProposal(
|
|
222
|
+
SlotNumber(slotNumber),
|
|
223
|
+
proposalId,
|
|
224
|
+
);
|
|
215
225
|
expect(retreivedAttestationsAfterDelete.length).toBe(0);
|
|
216
226
|
});
|
|
217
227
|
|
|
@@ -229,17 +239,20 @@ export function describeAttestationPool(getAttestationPool: () => AttestationPoo
|
|
|
229
239
|
await ap.addAttestations(attestations);
|
|
230
240
|
await ap.addAttestations(attestations2);
|
|
231
241
|
|
|
232
|
-
const retreivedAttestations = await ap.getAttestationsForSlotAndProposal(
|
|
242
|
+
const retreivedAttestations = await ap.getAttestationsForSlotAndProposal(SlotNumber(slotNumber), proposalId);
|
|
233
243
|
expect(retreivedAttestations.length).toBe(NUMBER_OF_SIGNERS_PER_TEST);
|
|
234
244
|
compareAttestations(retreivedAttestations, attestations);
|
|
235
245
|
|
|
236
|
-
await ap.deleteAttestationsForSlotAndProposal(
|
|
246
|
+
await ap.deleteAttestationsForSlotAndProposal(SlotNumber(slotNumber), proposalId);
|
|
237
247
|
|
|
238
|
-
const retreivedAttestationsAfterDelete = await ap.getAttestationsForSlotAndProposal(
|
|
248
|
+
const retreivedAttestationsAfterDelete = await ap.getAttestationsForSlotAndProposal(
|
|
249
|
+
SlotNumber(slotNumber),
|
|
250
|
+
proposalId,
|
|
251
|
+
);
|
|
239
252
|
expect(retreivedAttestationsAfterDelete.length).toBe(0);
|
|
240
253
|
|
|
241
254
|
const retreivedAttestationsAfterDeleteForOtherProposal = await ap.getAttestationsForSlotAndProposal(
|
|
242
|
-
|
|
255
|
+
SlotNumber(slotNumber),
|
|
243
256
|
proposalId2,
|
|
244
257
|
);
|
|
245
258
|
expect(retreivedAttestationsAfterDeleteForOtherProposal.length).toBe(NUMBER_OF_SIGNERS_PER_TEST);
|
|
@@ -255,22 +268,22 @@ export function describeAttestationPool(getAttestationPool: () => AttestationPoo
|
|
|
255
268
|
|
|
256
269
|
await ap.addAttestations(attestations);
|
|
257
270
|
|
|
258
|
-
const attestationsForSlot1 = await ap.getAttestationsForSlotAndProposal(
|
|
271
|
+
const attestationsForSlot1 = await ap.getAttestationsForSlotAndProposal(SlotNumber(1), proposalId);
|
|
259
272
|
expect(attestationsForSlot1.length).toBe(signers.length);
|
|
260
273
|
|
|
261
274
|
const deleteAttestationsSpy = jest.spyOn(ap, 'deleteAttestationsForSlot');
|
|
262
275
|
|
|
263
|
-
await ap.deleteAttestationsOlderThan(
|
|
276
|
+
await ap.deleteAttestationsOlderThan(SlotNumber(73));
|
|
264
277
|
|
|
265
|
-
const attestationsForSlot1AfterDelete = await ap.getAttestationsForSlotAndProposal(
|
|
278
|
+
const attestationsForSlot1AfterDelete = await ap.getAttestationsForSlotAndProposal(SlotNumber(1), proposalId);
|
|
266
279
|
expect(attestationsForSlot1AfterDelete.length).toBe(0);
|
|
267
280
|
|
|
268
281
|
expect(deleteAttestationsSpy).toHaveBeenCalledTimes(5);
|
|
269
|
-
expect(deleteAttestationsSpy).toHaveBeenCalledWith(
|
|
270
|
-
expect(deleteAttestationsSpy).toHaveBeenCalledWith(
|
|
271
|
-
expect(deleteAttestationsSpy).toHaveBeenCalledWith(
|
|
272
|
-
expect(deleteAttestationsSpy).toHaveBeenCalledWith(
|
|
273
|
-
expect(deleteAttestationsSpy).toHaveBeenCalledWith(
|
|
282
|
+
expect(deleteAttestationsSpy).toHaveBeenCalledWith(SlotNumber(1));
|
|
283
|
+
expect(deleteAttestationsSpy).toHaveBeenCalledWith(SlotNumber(2));
|
|
284
|
+
expect(deleteAttestationsSpy).toHaveBeenCalledWith(SlotNumber(3));
|
|
285
|
+
expect(deleteAttestationsSpy).toHaveBeenCalledWith(SlotNumber(69));
|
|
286
|
+
expect(deleteAttestationsSpy).toHaveBeenCalledWith(SlotNumber(72));
|
|
274
287
|
});
|
|
275
288
|
|
|
276
289
|
describe('BlockProposal in attestation pool', () => {
|
|
@@ -334,7 +347,7 @@ export function describeAttestationPool(getAttestationPool: () => AttestationPoo
|
|
|
334
347
|
const retrievedProposal = await ap.getBlockProposal(proposalId);
|
|
335
348
|
expect(retrievedProposal).toBeDefined();
|
|
336
349
|
expect(retrievedProposal!.toBuffer()).toEqual(proposal2.toBuffer());
|
|
337
|
-
expect(retrievedProposal!.slotNumber
|
|
350
|
+
expect(retrievedProposal!.slotNumber).toBe(SlotNumber(200));
|
|
338
351
|
});
|
|
339
352
|
|
|
340
353
|
it('should delete block proposal when deleting attestations for slot and proposal', async () => {
|
|
@@ -354,7 +367,7 @@ export function describeAttestationPool(getAttestationPool: () => AttestationPoo
|
|
|
354
367
|
expect(await ap.hasBlockProposal(proposalId)).toBe(true);
|
|
355
368
|
|
|
356
369
|
// Delete attestations for slot and proposal
|
|
357
|
-
await ap.deleteAttestationsForSlotAndProposal(
|
|
370
|
+
await ap.deleteAttestationsForSlotAndProposal(SlotNumber(slotNumber), proposalId);
|
|
358
371
|
|
|
359
372
|
// Proposal should be deleted
|
|
360
373
|
retrievedProposal = await ap.getBlockProposal(proposalId);
|
|
@@ -377,7 +390,7 @@ export function describeAttestationPool(getAttestationPool: () => AttestationPoo
|
|
|
377
390
|
expect(await ap.hasBlockProposal(proposal)).toBe(true);
|
|
378
391
|
|
|
379
392
|
// Delete attestations for slot
|
|
380
|
-
await ap.deleteAttestationsForSlot(
|
|
393
|
+
await ap.deleteAttestationsForSlot(SlotNumber(slotNumber));
|
|
381
394
|
|
|
382
395
|
// Proposal should be deleted
|
|
383
396
|
retrievedProposal = await ap.getBlockProposal(proposalId);
|
|
@@ -400,7 +413,7 @@ export function describeAttestationPool(getAttestationPool: () => AttestationPoo
|
|
|
400
413
|
|
|
401
414
|
// Retrieve both proposal and attestations
|
|
402
415
|
const retrievedProposal = await ap.getBlockProposal(proposalId);
|
|
403
|
-
const retrievedAttestations = await ap.getAttestationsForSlotAndProposal(
|
|
416
|
+
const retrievedAttestations = await ap.getAttestationsForSlotAndProposal(SlotNumber(slotNumber), proposalId);
|
|
404
417
|
|
|
405
418
|
expect(retrievedProposal).toBeDefined();
|
|
406
419
|
expect(retrievedProposal).toEqual(proposal);
|