@aztec/p2p 3.0.0-nightly.20251127 → 3.0.0-nightly.20251201.2
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 +1 -1
- package/dest/client/p2p_client.d.ts +3 -22
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +5 -4
- package/dest/config.d.ts +56 -56
- 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 +1 -1
- package/dest/errors/attestation-pool.error.d.ts.map +1 -1
- 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 +7 -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 +9 -8
- package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/kv_attestation_pool.js +19 -20
- package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts +9 -8
- package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/memory_attestation_pool.js +12 -10
- 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 +1 -1
- package/dest/mem_pools/instrumentation.d.ts.map +1 -1
- 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 +1 -1
- 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 +1 -1
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts.map +1 -1
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.js +1 -1
- package/dest/msg_validators/attestation_validator/index.d.ts +1 -1
- 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 +8 -8
- 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/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 +1 -1
- package/dest/services/libp2p/instrumentation.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.d.ts +1 -76
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +14 -13
- package/dest/services/peer-manager/interface.d.ts +1 -1
- package/dest/services/peer-manager/metrics.d.ts +1 -1
- package/dest/services/peer-manager/metrics.d.ts.map +1 -1
- 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_scoring.d.ts +1 -1
- package/dest/services/peer-manager/peer_scoring.d.ts.map +1 -1
- 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 +8 -7
- 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 +1 -1
- package/dest/versioning.d.ts +1 -1
- package/package.json +18 -17
- package/src/client/p2p_client.ts +6 -5
- package/src/mem_pools/attestation_pool/attestation_pool.ts +6 -5
- package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +45 -32
- package/src/mem_pools/attestation_pool/kv_attestation_pool.ts +28 -29
- package/src/mem_pools/attestation_pool/memory_attestation_pool.ts +26 -22
- package/src/mem_pools/attestation_pool/mocks.ts +1 -1
- package/src/msg_validators/attestation_validator/attestation_validator.ts +11 -13
- package/src/msg_validators/attestation_validator/fisherman_attestation_validator.ts +1 -1
- package/src/msg_validators/block_proposal_validator/block_proposal_validator.ts +8 -8
- package/src/services/libp2p/libp2p_service.ts +14 -13
- package/src/services/tx_collection/slow_tx_collection.ts +3 -2
- package/src/testbench/p2p_client_testbench_worker.ts +6 -5
package/dest/types/index.d.ts
CHANGED
|
@@ -31,4 +31,4 @@ export declare enum GossipSubEvent {
|
|
|
31
31
|
*/
|
|
32
32
|
export declare const AZTEC_ENR_KEY = "aztec";
|
|
33
33
|
export declare const AZTEC_ENR_CLIENT_VERSION_KEY = "ver";
|
|
34
|
-
//# sourceMappingURL=
|
|
34
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy90eXBlcy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7cURBRXFEO0FBRXJEOztHQUVHO0FBQ0gsb0JBQVksU0FBUztJQUNuQixVQUFVLG9CQUFvQjtJQUM5QixTQUFTLGlCQUFpQjtJQUMxQixZQUFZLG9CQUFvQjtDQUNqQztBQUVEOztHQUVHO0FBQ0gsb0JBQVksV0FBVztJQUNyQixVQUFVLGVBQWU7SUFDekIsU0FBUyxhQUFhO0lBQ3RCLGlCQUFpQixxQkFBcUI7Q0FDdkM7QUFFRDs7R0FFRztBQUNILG9CQUFZLGNBQWM7SUFDeEIsT0FBTyxzQkFBc0I7Q0FDOUI7QUFFRDs7cURBRXFEO0FBRXJEOztHQUVHO0FBQ0gsZUFBTyxNQUFNLGFBQWEsVUFBVSxDQUFDO0FBQ3JDLGVBQU8sTUFBTSw0QkFBNEIsUUFBUSxDQUFDIn0=
|
package/dest/util.d.ts
CHANGED
|
@@ -58,4 +58,4 @@ export declare function getPeerIdPrivateKey(config: {
|
|
|
58
58
|
* @returns The peer ID.
|
|
59
59
|
*/
|
|
60
60
|
export declare function createLibP2PPeerIdFromPrivateKey(privateKey: string): Promise<PeerId>;
|
|
61
|
-
//# sourceMappingURL=
|
|
61
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbC5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL3V0aWwudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLFdBQVcsRUFBRSxNQUFNLDBCQUEwQixDQUFDO0FBQ3ZELE9BQU8sS0FBSyxFQUFFLE1BQU0sRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBQ3BELE9BQU8sS0FBSyxFQUFFLGlCQUFpQixFQUF1QixNQUFNLGlCQUFpQixDQUFDO0FBQzlFLE9BQU8sS0FBSyxFQUFFLGVBQWUsRUFBRSxNQUFNLHdCQUF3QixDQUFDO0FBRTlELE9BQU8sS0FBSyxFQUFFLFNBQVMsRUFBRSxNQUFNLDZCQUE2QixDQUFDO0FBRTdELE9BQU8sS0FBSyxFQUFFLFFBQVEsRUFBRSxNQUFNLGtCQUFrQixDQUFDO0FBQ2pELE9BQU8sS0FBSyxFQUFFLE1BQU0sRUFBYyxNQUFNLG1CQUFtQixDQUFDO0FBQzVELE9BQU8sS0FBSyxFQUFFLGlCQUFpQixFQUFFLE1BQU0sNEJBQTRCLENBQUM7QUFJcEUsT0FBTyxLQUFLLEVBQUUsTUFBTSxFQUFFLE1BQU0sUUFBUSxDQUFDO0FBSXJDLE9BQU8sS0FBSyxFQUFFLFNBQVMsRUFBRSxNQUFNLGFBQWEsQ0FBQztBQUk3QyxNQUFNLFdBQVcsWUFBYSxTQUFRLElBQUksQ0FBQyxNQUFNLEVBQUUsUUFBUSxHQUFHLE9BQU8sR0FBRyxNQUFNLEdBQUcsUUFBUSxDQUFDO0lBQ3hGLFFBQVEsRUFBRTtRQUNSLE1BQU0sRUFBRSxJQUFJLENBQ1YsU0FBUyxFQUNULGtCQUFrQixHQUFHLHFCQUFxQixHQUFHLFNBQVMsR0FBRyxXQUFXLEdBQUcsK0JBQStCLEdBQUcsUUFBUSxDQUNsSCxHQUFHO1lBQUUsS0FBSyxFQUFFLElBQUksQ0FBQyxTQUFTLENBQUMsT0FBTyxDQUFDLEVBQUUsT0FBTyxDQUFDLENBQUE7U0FBRSxDQUFDO0tBQ2xELENBQUM7Q0FDSDtBQUVELE1BQU0sTUFBTSxVQUFVLEdBQUcsTUFBTSxDQUFDO0lBQzlCLFFBQVEsRUFBRSxRQUFRLENBQUM7SUFDbkIsTUFBTSxFQUFFLFNBQVMsQ0FBQztJQUNsQixVQUFVLEVBQUU7UUFDVixpQkFBaUIsRUFBRSxpQkFBaUIsQ0FBQztLQUN0QyxDQUFDO0NBQ0gsQ0FBQyxDQUFDO0FBRUg7Ozs7Ozs7NkNBTzZDO0FBQzdDLHdCQUFnQixrQkFBa0IsQ0FBQyxPQUFPLEVBQUUsTUFBTSxFQUFFLElBQUksRUFBRSxNQUFNLEVBQUUsUUFBUSxFQUFFLEtBQUssR0FBRyxLQUFLLEdBQUcsTUFBTSxDQU9qRztBQUVEOztHQUVHO0FBQ0gsd0JBQXNCLFdBQVcsSUFBSSxPQUFPLENBQUMsTUFBTSxDQUFDLENBUW5EO0FBRUQsd0JBQWdCLGdCQUFnQixDQUFDLE9BQU8sRUFBRSxNQUFNLEdBQUcsT0FBTyxDQUd6RDtBQUVELHdCQUFzQix5QkFBeUIsQ0FBQyxPQUFPLEVBQUUsTUFBTSxFQUFFLElBQUksRUFBRSxNQUFNLEdBQUcsT0FBTyxDQUFDLE1BQU0sQ0FBQyxDQVc5RjtBQWNELHdCQUFzQiwyQkFBMkIsQ0FDL0MsT0FBTyxFQUFFLFNBQVMsR0FBRyxlQUFlLEdBQ25DLE9BQU8sQ0FBQyxTQUFTLEdBQUcsZUFBZSxDQUFDLENBbUJ0QztBQUVEOzs7Ozs7OztHQVFHO0FBQ0gsd0JBQXNCLG1CQUFtQixDQUN2QyxNQUFNLEVBQUU7SUFBRSxnQkFBZ0IsQ0FBQyxFQUFFLFdBQVcsQ0FBQyxNQUFNLENBQUMsQ0FBQztJQUFDLG9CQUFvQixDQUFDLEVBQUUsTUFBTSxDQUFDO0lBQUMsYUFBYSxDQUFDLEVBQUUsTUFBTSxDQUFBO0NBQUUsRUFDekcsS0FBSyxFQUFFLGlCQUFpQixFQUN4QixNQUFNLEVBQUUsTUFBTSxHQUNiLE9BQU8sQ0FBQyxXQUFXLENBQUMsTUFBTSxDQUFDLENBQUMsQ0EyRDlCO0FBRUQ7Ozs7R0FJRztBQUNILHdCQUFzQixnQ0FBZ0MsQ0FBQyxVQUFVLEVBQUUsTUFBTSxHQUFHLE9BQU8sQ0FBQyxNQUFNLENBQUMsQ0FTMUYifQ==
|
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": "3.0.0-nightly.
|
|
3
|
+
"version": "3.0.0-nightly.20251201.2",
|
|
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": "3.0.0-nightly.
|
|
71
|
-
"@aztec/epoch-cache": "3.0.0-nightly.
|
|
72
|
-
"@aztec/ethereum": "3.0.0-nightly.
|
|
73
|
-
"@aztec/foundation": "3.0.0-nightly.
|
|
74
|
-
"@aztec/kv-store": "3.0.0-nightly.
|
|
75
|
-
"@aztec/noir-contracts.js": "3.0.0-nightly.
|
|
76
|
-
"@aztec/noir-protocol-circuits-types": "3.0.0-nightly.
|
|
77
|
-
"@aztec/protocol-contracts": "3.0.0-nightly.
|
|
78
|
-
"@aztec/simulator": "3.0.0-nightly.
|
|
79
|
-
"@aztec/stdlib": "3.0.0-nightly.
|
|
80
|
-
"@aztec/telemetry-client": "3.0.0-nightly.
|
|
70
|
+
"@aztec/constants": "3.0.0-nightly.20251201.2",
|
|
71
|
+
"@aztec/epoch-cache": "3.0.0-nightly.20251201.2",
|
|
72
|
+
"@aztec/ethereum": "3.0.0-nightly.20251201.2",
|
|
73
|
+
"@aztec/foundation": "3.0.0-nightly.20251201.2",
|
|
74
|
+
"@aztec/kv-store": "3.0.0-nightly.20251201.2",
|
|
75
|
+
"@aztec/noir-contracts.js": "3.0.0-nightly.20251201.2",
|
|
76
|
+
"@aztec/noir-protocol-circuits-types": "3.0.0-nightly.20251201.2",
|
|
77
|
+
"@aztec/protocol-contracts": "3.0.0-nightly.20251201.2",
|
|
78
|
+
"@aztec/simulator": "3.0.0-nightly.20251201.2",
|
|
79
|
+
"@aztec/stdlib": "3.0.0-nightly.20251201.2",
|
|
80
|
+
"@aztec/telemetry-client": "3.0.0-nightly.20251201.2",
|
|
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": "3.0.0-nightly.
|
|
108
|
-
"@aztec/world-state": "3.0.0-nightly.
|
|
107
|
+
"@aztec/archiver": "3.0.0-nightly.20251201.2",
|
|
108
|
+
"@aztec/world-state": "3.0.0-nightly.20251201.2",
|
|
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",
|
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,12 +372,12 @@ 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
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
|
|
|
@@ -385,7 +386,7 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
385
386
|
await Promise.all(attestations.map(att => this.p2pService.propagate(att)));
|
|
386
387
|
}
|
|
387
388
|
|
|
388
|
-
public async getAttestationsForSlot(slot:
|
|
389
|
+
public async getAttestationsForSlot(slot: SlotNumber, proposalId?: string): Promise<BlockAttestation[]> {
|
|
389
390
|
return (
|
|
390
391
|
(await (proposalId
|
|
391
392
|
? this.attestationPool?.getAttestationsForSlotAndProposal(slot, proposalId)
|
|
@@ -726,7 +727,7 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
726
727
|
);
|
|
727
728
|
|
|
728
729
|
await this.synchedLatestBlockNumber.set(lastBlock.number);
|
|
729
|
-
await this.synchedLatestSlot.set(lastBlock.header.getSlot());
|
|
730
|
+
await this.synchedLatestSlot.set(BigInt(lastBlock.header.getSlot()));
|
|
730
731
|
this.log.verbose(`Synched to latest block ${lastBlock.number}`);
|
|
731
732
|
await this.startServiceIfSynched();
|
|
732
733
|
}
|
|
@@ -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
|
|
@@ -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);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { SlotNumber } from '@aztec/foundation/branded-types';
|
|
1
2
|
import { Fr } from '@aztec/foundation/fields';
|
|
2
3
|
import { toArray } from '@aztec/foundation/iterable';
|
|
3
4
|
import { createLogger } from '@aztec/foundation/log';
|
|
@@ -20,7 +21,7 @@ export class KvAttestationPool implements AttestationPool {
|
|
|
20
21
|
/* proposal.payload.archive */ string,
|
|
21
22
|
/* buffer representation of proposal */ Buffer
|
|
22
23
|
>;
|
|
23
|
-
private proposalsForSlot: AztecAsyncMultiMap<
|
|
24
|
+
private proposalsForSlot: AztecAsyncMultiMap<number, string>;
|
|
24
25
|
private attestationsForProposal: AztecAsyncMultiMap<string, string>;
|
|
25
26
|
|
|
26
27
|
constructor(
|
|
@@ -74,7 +75,7 @@ export class KvAttestationPool implements AttestationPool {
|
|
|
74
75
|
|
|
75
76
|
// Skip attestations with invalid signatures
|
|
76
77
|
if (!sender) {
|
|
77
|
-
this.log.warn(`Skipping attestation with invalid signature for slot ${slotNumber
|
|
78
|
+
this.log.warn(`Skipping attestation with invalid signature for slot ${slotNumber}`, {
|
|
78
79
|
signature: attestation.signature.toString(),
|
|
79
80
|
slotNumber,
|
|
80
81
|
proposalId,
|
|
@@ -86,13 +87,13 @@ export class KvAttestationPool implements AttestationPool {
|
|
|
86
87
|
|
|
87
88
|
await this.attestations.set(this.getAttestationKey(slotNumber, proposalId, address), attestation.toBuffer());
|
|
88
89
|
|
|
89
|
-
await this.proposalsForSlot.set(slotNumber
|
|
90
|
+
await this.proposalsForSlot.set(slotNumber, proposalId.toString());
|
|
90
91
|
await this.attestationsForProposal.set(
|
|
91
92
|
this.getProposalKey(slotNumber, proposalId),
|
|
92
93
|
this.getAttestationKey(slotNumber, proposalId, address),
|
|
93
94
|
);
|
|
94
95
|
|
|
95
|
-
this.log.verbose(`Added attestation for slot ${slotNumber
|
|
96
|
+
this.log.verbose(`Added attestation for slot ${slotNumber} from ${address}`, {
|
|
96
97
|
signature: attestation.signature.toString(),
|
|
97
98
|
slotNumber,
|
|
98
99
|
address,
|
|
@@ -102,9 +103,8 @@ export class KvAttestationPool implements AttestationPool {
|
|
|
102
103
|
});
|
|
103
104
|
}
|
|
104
105
|
|
|
105
|
-
public async getAttestationsForSlot(slot:
|
|
106
|
-
const
|
|
107
|
-
const proposalIds = await toArray(this.proposalsForSlot.getValuesAsync(slotFr.toString()));
|
|
106
|
+
public async getAttestationsForSlot(slot: SlotNumber): Promise<BlockAttestation[]> {
|
|
107
|
+
const proposalIds = await toArray(this.proposalsForSlot.getValuesAsync(slot));
|
|
108
108
|
const attestations: BlockAttestation[] = [];
|
|
109
109
|
|
|
110
110
|
for (const proposalId of proposalIds) {
|
|
@@ -114,7 +114,7 @@ export class KvAttestationPool implements AttestationPool {
|
|
|
114
114
|
return attestations;
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
-
public async getAttestationsForSlotAndProposal(slot:
|
|
117
|
+
public async getAttestationsForSlotAndProposal(slot: SlotNumber, proposalId: string): Promise<BlockAttestation[]> {
|
|
118
118
|
const attestationIds = await toArray(
|
|
119
119
|
this.attestationsForProposal.getValuesAsync(this.getProposalKey(slot, proposalId)),
|
|
120
120
|
);
|
|
@@ -136,21 +136,20 @@ export class KvAttestationPool implements AttestationPool {
|
|
|
136
136
|
return attestations;
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
-
public async deleteAttestationsOlderThan(oldestSlot:
|
|
140
|
-
const olderThan = await toArray(this.proposalsForSlot.keysAsync({ end:
|
|
139
|
+
public async deleteAttestationsOlderThan(oldestSlot: SlotNumber): Promise<void> {
|
|
140
|
+
const olderThan = await toArray(this.proposalsForSlot.keysAsync({ end: oldestSlot }));
|
|
141
141
|
for (const oldSlot of olderThan) {
|
|
142
|
-
await this.deleteAttestationsForSlot(
|
|
142
|
+
await this.deleteAttestationsForSlot(SlotNumber(oldSlot));
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
145
|
|
|
146
|
-
public async deleteAttestationsForSlot(slot:
|
|
147
|
-
const slotFr = new Fr(slot);
|
|
146
|
+
public async deleteAttestationsForSlot(slot: SlotNumber): Promise<void> {
|
|
148
147
|
let numberOfAttestations = 0;
|
|
149
148
|
await this.store.transactionAsync(async () => {
|
|
150
|
-
const proposalIds = await toArray(this.proposalsForSlot.getValuesAsync(
|
|
149
|
+
const proposalIds = await toArray(this.proposalsForSlot.getValuesAsync(slot));
|
|
151
150
|
for (const proposalId of proposalIds) {
|
|
152
151
|
const attestations = await toArray(
|
|
153
|
-
this.attestationsForProposal.getValuesAsync(this.getProposalKey(
|
|
152
|
+
this.attestationsForProposal.getValuesAsync(this.getProposalKey(slot, proposalId)),
|
|
154
153
|
);
|
|
155
154
|
|
|
156
155
|
numberOfAttestations += attestations.length;
|
|
@@ -159,17 +158,19 @@ export class KvAttestationPool implements AttestationPool {
|
|
|
159
158
|
}
|
|
160
159
|
|
|
161
160
|
await this.proposals.delete(proposalId);
|
|
162
|
-
await this.attestationsForProposal.delete(this.getProposalKey(
|
|
161
|
+
await this.attestationsForProposal.delete(this.getProposalKey(slot, proposalId));
|
|
163
162
|
}
|
|
164
163
|
|
|
164
|
+
// Delete from proposalsForSlot
|
|
165
|
+
await this.proposalsForSlot.delete(slot);
|
|
166
|
+
|
|
165
167
|
this.log.verbose(`Removed ${numberOfAttestations} attestations for slot ${slot}`);
|
|
166
168
|
});
|
|
167
169
|
}
|
|
168
170
|
|
|
169
|
-
public async deleteAttestationsForSlotAndProposal(slot:
|
|
171
|
+
public async deleteAttestationsForSlotAndProposal(slot: SlotNumber, proposalId: string): Promise<void> {
|
|
170
172
|
let numberOfAttestations = 0;
|
|
171
173
|
await this.store.transactionAsync(async () => {
|
|
172
|
-
const slotString = new Fr(slot).toString();
|
|
173
174
|
const attestations = await toArray(
|
|
174
175
|
this.attestationsForProposal.getValuesAsync(this.getProposalKey(slot, proposalId)),
|
|
175
176
|
);
|
|
@@ -180,8 +181,8 @@ export class KvAttestationPool implements AttestationPool {
|
|
|
180
181
|
}
|
|
181
182
|
|
|
182
183
|
await this.proposals.delete(proposalId);
|
|
183
|
-
await this.proposalsForSlot.deleteValue(
|
|
184
|
-
await this.attestationsForProposal.delete(this.getProposalKey(
|
|
184
|
+
await this.proposalsForSlot.deleteValue(slot, proposalId);
|
|
185
|
+
await this.attestationsForProposal.delete(this.getProposalKey(slot, proposalId));
|
|
185
186
|
|
|
186
187
|
this.log.verbose(`Removed ${numberOfAttestations} attestations for slot ${slot} and proposal ${proposalId}`);
|
|
187
188
|
});
|
|
@@ -196,7 +197,7 @@ export class KvAttestationPool implements AttestationPool {
|
|
|
196
197
|
|
|
197
198
|
// Skip attestations with invalid signatures
|
|
198
199
|
if (!sender) {
|
|
199
|
-
this.log.warn(`Skipping deletion of attestation with invalid signature for slot ${slotNumber
|
|
200
|
+
this.log.warn(`Skipping deletion of attestation with invalid signature for slot ${slotNumber}`);
|
|
200
201
|
continue;
|
|
201
202
|
}
|
|
202
203
|
|
|
@@ -253,7 +254,7 @@ export class KvAttestationPool implements AttestationPool {
|
|
|
253
254
|
|
|
254
255
|
public async addBlockProposal(blockProposal: BlockProposal): Promise<void> {
|
|
255
256
|
await this.store.transactionAsync(async () => {
|
|
256
|
-
const slotKey = blockProposal.slotNumber
|
|
257
|
+
const slotKey = blockProposal.slotNumber;
|
|
257
258
|
const proposalId = blockProposal.archive.toString();
|
|
258
259
|
|
|
259
260
|
if (!(await this.canAddProposal(blockProposal))) {
|
|
@@ -268,21 +269,19 @@ export class KvAttestationPool implements AttestationPool {
|
|
|
268
269
|
});
|
|
269
270
|
}
|
|
270
271
|
|
|
271
|
-
public async hasReachedProposalCap(slot:
|
|
272
|
-
const
|
|
273
|
-
const uniqueProposalCount = await this.proposalsForSlot.getValueCountAsync(slotKey);
|
|
272
|
+
public async hasReachedProposalCap(slot: SlotNumber): Promise<boolean> {
|
|
273
|
+
const uniqueProposalCount = await this.proposalsForSlot.getValueCountAsync(slot);
|
|
274
274
|
return uniqueProposalCount >= MAX_PROPOSALS_PER_SLOT;
|
|
275
275
|
}
|
|
276
276
|
|
|
277
|
-
public async hasReachedAttestationCap(slot:
|
|
277
|
+
public async hasReachedAttestationCap(slot: SlotNumber, proposalId: string, committeeSize: number): Promise<boolean> {
|
|
278
278
|
const limit = committeeSize + ATTESTATION_CAP_BUFFER;
|
|
279
279
|
return (await this.attestationsForProposal.getValueCountAsync(this.getProposalKey(slot, proposalId))) >= limit;
|
|
280
280
|
}
|
|
281
281
|
|
|
282
282
|
public async canAddProposal(block: BlockProposal): Promise<boolean> {
|
|
283
283
|
return (
|
|
284
|
-
(await this.proposals.hasAsync(block.archive.toString())) ||
|
|
285
|
-
!(await this.hasReachedProposalCap(block.slotNumber.toBigInt()))
|
|
284
|
+
(await this.proposals.hasAsync(block.archive.toString())) || !(await this.hasReachedProposalCap(block.slotNumber))
|
|
286
285
|
);
|
|
287
286
|
}
|
|
288
287
|
|
|
@@ -290,7 +289,7 @@ export class KvAttestationPool implements AttestationPool {
|
|
|
290
289
|
return (
|
|
291
290
|
(await this.hasAttestation(attestation)) ||
|
|
292
291
|
!(await this.hasReachedAttestationCap(
|
|
293
|
-
attestation.payload.header.slotNumber
|
|
292
|
+
attestation.payload.header.slotNumber,
|
|
294
293
|
attestation.archive.toString(),
|
|
295
294
|
committeeSize,
|
|
296
295
|
))
|