@aztec/p2p 0.0.1-commit.4eabbdb → 0.0.1-commit.5358163d3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/client/factory.d.ts +4 -5
- package/dest/client/factory.d.ts.map +1 -1
- package/dest/client/factory.js +15 -26
- package/dest/client/interface.d.ts +6 -13
- package/dest/client/interface.d.ts.map +1 -1
- package/dest/client/p2p_client.d.ts +5 -13
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +3 -58
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.js +1 -2
- package/dest/config.d.ts +10 -14
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +25 -35
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool.js +5 -1
- package/dest/mem_pools/instrumentation.d.ts +4 -2
- package/dest/mem_pools/instrumentation.d.ts.map +1 -1
- package/dest/mem_pools/instrumentation.js +16 -14
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.js +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.js +2 -0
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.js +2 -2
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts +2 -2
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.js +10 -6
- package/dest/mem_pools/tx_pool_v2/index.d.ts +2 -2
- package/dest/mem_pools/tx_pool_v2/index.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/index.js +1 -1
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts +7 -5
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/interfaces.js +2 -1
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts +26 -4
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_metadata.js +48 -7
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.js +9 -10
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts +2 -2
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.js +3 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts +3 -2
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.js +175 -145
- package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts +2 -1
- package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.d.ts +2 -1
- package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/proposal_validator.d.ts +3 -1
- package/dest/msg_validators/proposal_validator/proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/proposal_validator.js +10 -0
- package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.d.ts +2 -1
- package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.js +166 -0
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts +2 -2
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.js +3 -3
- package/dest/msg_validators/tx_validator/allowed_public_setup.d.ts +2 -1
- package/dest/msg_validators/tx_validator/allowed_public_setup.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/allowed_public_setup.js +25 -10
- package/dest/msg_validators/tx_validator/factory.d.ts +114 -6
- package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/factory.js +219 -58
- package/dest/msg_validators/tx_validator/gas_validator.d.ts +58 -3
- package/dest/msg_validators/tx_validator/gas_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/gas_validator.js +73 -36
- package/dest/msg_validators/tx_validator/index.d.ts +2 -1
- package/dest/msg_validators/tx_validator/index.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/index.js +1 -0
- package/dest/msg_validators/tx_validator/nullifier_cache.d.ts +14 -0
- package/dest/msg_validators/tx_validator/nullifier_cache.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/nullifier_cache.js +24 -0
- package/dest/msg_validators/tx_validator/phases_validator.d.ts +2 -2
- package/dest/msg_validators/tx_validator/phases_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/phases_validator.js +25 -24
- package/dest/services/dummy_service.d.ts +2 -3
- package/dest/services/dummy_service.d.ts.map +1 -1
- package/dest/services/dummy_service.js +1 -4
- package/dest/services/encoding.d.ts +2 -2
- package/dest/services/encoding.d.ts.map +1 -1
- package/dest/services/encoding.js +7 -7
- package/dest/services/libp2p/libp2p_service.d.ts +15 -13
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +72 -83
- 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 +6 -0
- package/dest/services/peer-manager/peer_manager.d.ts +1 -1
- package/dest/services/peer-manager/peer_manager.d.ts.map +1 -1
- package/dest/services/peer-manager/peer_manager.js +2 -1
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts +1 -1
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.js +14 -37
- package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts +17 -11
- package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/peer_collection.js +49 -15
- package/dest/services/reqresp/batch-tx-requester/tx_validator.js +2 -2
- package/dest/services/reqresp/reqresp.d.ts +1 -1
- package/dest/services/reqresp/reqresp.d.ts.map +1 -1
- package/dest/services/reqresp/reqresp.js +2 -1
- package/dest/services/service.d.ts +2 -2
- package/dest/services/service.d.ts.map +1 -1
- package/dest/services/tx_provider.d.ts +3 -3
- package/dest/services/tx_provider.d.ts.map +1 -1
- package/dest/services/tx_provider.js +4 -4
- package/dest/test-helpers/make-test-p2p-clients.d.ts +5 -6
- package/dest/test-helpers/make-test-p2p-clients.d.ts.map +1 -1
- package/dest/test-helpers/make-test-p2p-clients.js +1 -2
- package/dest/test-helpers/mock-pubsub.d.ts +2 -3
- package/dest/test-helpers/mock-pubsub.d.ts.map +1 -1
- package/dest/test-helpers/mock-pubsub.js +2 -2
- package/dest/test-helpers/reqresp-nodes.d.ts +2 -3
- package/dest/test-helpers/reqresp-nodes.d.ts.map +1 -1
- package/dest/test-helpers/reqresp-nodes.js +2 -2
- package/dest/test-helpers/testbench-utils.d.ts +2 -2
- package/dest/test-helpers/testbench-utils.d.ts.map +1 -1
- package/dest/testbench/p2p_client_testbench_worker.js +5 -5
- package/package.json +14 -14
- package/src/client/factory.ts +22 -46
- package/src/client/interface.ts +5 -19
- package/src/client/p2p_client.ts +4 -88
- package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +1 -2
- package/src/config.ts +36 -42
- package/src/mem_pools/attestation_pool/attestation_pool.ts +5 -4
- package/src/mem_pools/instrumentation.ts +17 -13
- package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.ts +1 -1
- package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.ts +3 -0
- package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.ts +2 -2
- package/src/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.ts +10 -6
- package/src/mem_pools/tx_pool_v2/index.ts +1 -1
- package/src/mem_pools/tx_pool_v2/interfaces.ts +7 -4
- package/src/mem_pools/tx_pool_v2/tx_metadata.ts +65 -10
- package/src/mem_pools/tx_pool_v2/tx_pool_indices.ts +11 -11
- package/src/mem_pools/tx_pool_v2/tx_pool_v2.ts +4 -1
- package/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +184 -148
- package/src/msg_validators/proposal_validator/block_proposal_validator.ts +1 -1
- package/src/msg_validators/proposal_validator/checkpoint_proposal_validator.ts +1 -1
- package/src/msg_validators/proposal_validator/proposal_validator.ts +15 -1
- package/src/msg_validators/proposal_validator/proposal_validator_test_suite.ts +144 -1
- package/src/msg_validators/tx_validator/README.md +115 -0
- package/src/msg_validators/tx_validator/aggregate_tx_validator.ts +3 -3
- package/src/msg_validators/tx_validator/allowed_public_setup.ts +27 -13
- package/src/msg_validators/tx_validator/factory.ts +353 -77
- package/src/msg_validators/tx_validator/gas_validator.ts +90 -27
- package/src/msg_validators/tx_validator/index.ts +1 -0
- package/src/msg_validators/tx_validator/nullifier_cache.ts +30 -0
- package/src/msg_validators/tx_validator/phases_validator.ts +25 -29
- package/src/services/dummy_service.ts +1 -5
- package/src/services/encoding.ts +5 -6
- package/src/services/libp2p/libp2p_service.ts +84 -92
- package/src/services/peer-manager/metrics.ts +7 -0
- package/src/services/peer-manager/peer_manager.ts +2 -1
- package/src/services/reqresp/batch-tx-requester/batch_tx_requester.ts +14 -42
- package/src/services/reqresp/batch-tx-requester/peer_collection.ts +63 -24
- package/src/services/reqresp/batch-tx-requester/tx_validator.ts +2 -2
- package/src/services/reqresp/reqresp.ts +3 -1
- package/src/services/service.ts +1 -1
- package/src/services/tx_provider.ts +2 -2
- package/src/test-helpers/make-test-p2p-clients.ts +0 -2
- package/src/test-helpers/mock-pubsub.ts +3 -6
- package/src/test-helpers/reqresp-nodes.ts +2 -5
- package/src/test-helpers/testbench-utils.ts +1 -1
- package/src/testbench/p2p_client_testbench_worker.ts +2 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testbench-utils.d.ts","sourceRoot":"","sources":["../../src/test-helpers/testbench-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAe,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC1E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAC9E,OAAO,KAAK,EACV,aAAa,EACb,qBAAqB,EACrB,kBAAkB,EAClB,sBAAsB,EACvB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,KAAK,WAAW,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAEhE,OAAO,YAAY,MAAM,QAAQ,CAAC;AAElC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mDAAmD,CAAC;AACtF,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AACpG,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wCAAwC,CAAC;AAGtE;;;;GAIG;AACH,qBAAa,cAAe,SAAQ,YAAa,YAAW,QAAQ;IAClE,OAAO,CAAC,SAA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B,IAAI,mBAAmB,CAsB1D;AAED;;GAEG;AACH,wBAAgB,gCAAgC,IAAI,sBAAsB,CAazE;AAED;;GAEG;AACH,eAAO,MAAM,0BAA0B;;;;;;;;;CAGtC,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,mCAAmC,CAAC,OAAO,EAAE,GAAG,GAAG,IAAI,CAItE;AAED;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG,SAAS,GAAG,QAAQ,GAAG,aAAa,CAAC;AAEvE;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,iBAAiB,GAAG,oBAAoB,CAAC;AAErE;;GAEG;AACH,eAAO,MAAM,uBAAuB,EAAE,MAAM,CAAC,aAAa,EAAE,MAAM,CAGjE,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,mBAAmB;IAC9B,kEAAkE;;IAElE,gDAAgD;;IAEhD,8CAA8C;;IAE9C,mCAAmC;;IAEnC,kDAAkD;;IAElD,8BAA8B;;IAE9B,gFAAgF;;IAEhF,oDAAoD;;IAEpD,4CAA4C;;IAE5C,qDAAqD;;IAErD,gEAAgE;;CAExD,CAAC;AAEX;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,EAAE,EAAE,EACZ,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,mBAAmB,EACjC,eAAe,GAAE,MAAU,GAC1B,EAAE,EAAE,CAsBN;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAElE"}
|
|
@@ -13,7 +13,7 @@ import { DateProvider, Timer } from '@aztec/foundation/timer';
|
|
|
13
13
|
import { openTmpStore } from '@aztec/kv-store/lmdb-v2';
|
|
14
14
|
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
15
15
|
import { protocolContractsHash } from '@aztec/protocol-contracts';
|
|
16
|
-
import {
|
|
16
|
+
import { P2PMessage } from '@aztec/stdlib/p2p';
|
|
17
17
|
import { ChonkProof } from '@aztec/stdlib/proofs';
|
|
18
18
|
import { makeAztecAddress, makeBlockHeader, makeBlockProposal, mockTx } from '@aztec/stdlib/testing';
|
|
19
19
|
import { Tx } from '@aztec/stdlib/tx';
|
|
@@ -31,8 +31,8 @@ const txCache = new Map();
|
|
|
31
31
|
class TestLibP2PService extends LibP2PService {
|
|
32
32
|
disableTxValidation;
|
|
33
33
|
gossipMessageCount = 0;
|
|
34
|
-
constructor(
|
|
35
|
-
super(
|
|
34
|
+
constructor(config, node, peerDiscoveryService, reqresp, peerManager, mempools, archiver, epochCache, proofVerifier, worldStateSynchronizer, telemetry, logger = createLogger('p2p:test:libp2p_service'), disableTxValidation = true){
|
|
35
|
+
super(config, node, peerDiscoveryService, reqresp, peerManager, mempools, archiver, epochCache, proofVerifier, worldStateSynchronizer, telemetry, logger);
|
|
36
36
|
this.disableTxValidation = disableTxValidation;
|
|
37
37
|
}
|
|
38
38
|
getGossipMessageCount() {
|
|
@@ -214,8 +214,8 @@ process.on('message', async (msg)=>{
|
|
|
214
214
|
store: kvStore,
|
|
215
215
|
logger: workerLogger
|
|
216
216
|
};
|
|
217
|
-
const client = await createP2PClient(
|
|
218
|
-
const testService = new TestLibP2PService(
|
|
217
|
+
const client = await createP2PClient(config, l2BlockSource, proofVerifier, worldState, epochCache, 'test-p2p-bench-worker', undefined, telemetry, deps);
|
|
218
|
+
const testService = new TestLibP2PService(config, client.p2pService.node, client.p2pService.peerDiscoveryService, client.p2pService.reqresp, client.p2pService.peerManager, client.p2pService.mempools, client.p2pService.archiver, epochCache, proofVerifier, worldState, telemetry, workerLogger, true);
|
|
219
219
|
client.p2pService = testService;
|
|
220
220
|
await client.start();
|
|
221
221
|
for(let i = 0; i < 100; i++){
|
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.5358163d3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/index.js",
|
|
@@ -67,17 +67,17 @@
|
|
|
67
67
|
]
|
|
68
68
|
},
|
|
69
69
|
"dependencies": {
|
|
70
|
-
"@aztec/constants": "0.0.1-commit.
|
|
71
|
-
"@aztec/epoch-cache": "0.0.1-commit.
|
|
72
|
-
"@aztec/ethereum": "0.0.1-commit.
|
|
73
|
-
"@aztec/foundation": "0.0.1-commit.
|
|
74
|
-
"@aztec/kv-store": "0.0.1-commit.
|
|
75
|
-
"@aztec/noir-contracts.js": "0.0.1-commit.
|
|
76
|
-
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.
|
|
77
|
-
"@aztec/protocol-contracts": "0.0.1-commit.
|
|
78
|
-
"@aztec/simulator": "0.0.1-commit.
|
|
79
|
-
"@aztec/stdlib": "0.0.1-commit.
|
|
80
|
-
"@aztec/telemetry-client": "0.0.1-commit.
|
|
70
|
+
"@aztec/constants": "0.0.1-commit.5358163d3",
|
|
71
|
+
"@aztec/epoch-cache": "0.0.1-commit.5358163d3",
|
|
72
|
+
"@aztec/ethereum": "0.0.1-commit.5358163d3",
|
|
73
|
+
"@aztec/foundation": "0.0.1-commit.5358163d3",
|
|
74
|
+
"@aztec/kv-store": "0.0.1-commit.5358163d3",
|
|
75
|
+
"@aztec/noir-contracts.js": "0.0.1-commit.5358163d3",
|
|
76
|
+
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.5358163d3",
|
|
77
|
+
"@aztec/protocol-contracts": "0.0.1-commit.5358163d3",
|
|
78
|
+
"@aztec/simulator": "0.0.1-commit.5358163d3",
|
|
79
|
+
"@aztec/stdlib": "0.0.1-commit.5358163d3",
|
|
80
|
+
"@aztec/telemetry-client": "0.0.1-commit.5358163d3",
|
|
81
81
|
"@chainsafe/libp2p-gossipsub": "13.0.0",
|
|
82
82
|
"@chainsafe/libp2p-noise": "^15.0.0",
|
|
83
83
|
"@chainsafe/libp2p-yamux": "^6.0.2",
|
|
@@ -104,8 +104,8 @@
|
|
|
104
104
|
"xxhash-wasm": "^1.1.0"
|
|
105
105
|
},
|
|
106
106
|
"devDependencies": {
|
|
107
|
-
"@aztec/archiver": "0.0.1-commit.
|
|
108
|
-
"@aztec/world-state": "0.0.1-commit.
|
|
107
|
+
"@aztec/archiver": "0.0.1-commit.5358163d3",
|
|
108
|
+
"@aztec/world-state": "0.0.1-commit.5358163d3",
|
|
109
109
|
"@jest/globals": "^30.0.0",
|
|
110
110
|
"@types/jest": "^30.0.0",
|
|
111
111
|
"@types/node": "^22.15.17",
|
package/src/client/factory.ts
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import type { EpochCacheInterface } from '@aztec/epoch-cache';
|
|
2
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
3
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
3
4
|
import { DateProvider } from '@aztec/foundation/timer';
|
|
4
5
|
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
5
6
|
import type { DataStoreConfig } from '@aztec/kv-store/config';
|
|
6
7
|
import { AztecLMDBStoreV2, createStore } from '@aztec/kv-store/lmdb-v2';
|
|
7
|
-
import type {
|
|
8
|
+
import type { L2BlockSource } from '@aztec/stdlib/block';
|
|
8
9
|
import type { ChainConfig } from '@aztec/stdlib/config';
|
|
9
10
|
import type { ContractDataSource } from '@aztec/stdlib/contract';
|
|
10
11
|
import type { AztecNode, ClientProtocolCircuitVerifier, WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
|
|
11
|
-
import { P2PClientType } from '@aztec/stdlib/p2p';
|
|
12
|
-
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
13
12
|
import { type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-client';
|
|
14
13
|
|
|
15
14
|
import { P2PClient } from '../client/p2p_client.js';
|
|
@@ -17,11 +16,8 @@ import type { P2PConfig } from '../config.js';
|
|
|
17
16
|
import { AttestationPool, type AttestationPoolApi } from '../mem_pools/attestation_pool/attestation_pool.js';
|
|
18
17
|
import type { MemPools } from '../mem_pools/interface.js';
|
|
19
18
|
import type { TxPoolV2 } from '../mem_pools/tx_pool_v2/interfaces.js';
|
|
20
|
-
import type { TxMetaData } from '../mem_pools/tx_pool_v2/tx_metadata.js';
|
|
21
19
|
import { AztecKVTxPoolV2 } from '../mem_pools/tx_pool_v2/tx_pool_v2.js';
|
|
22
|
-
import {
|
|
23
|
-
import { BlockHeaderTxValidator } from '../msg_validators/tx_validator/block_header_validator.js';
|
|
24
|
-
import { DoubleSpendTxValidator } from '../msg_validators/tx_validator/double_spend_validator.js';
|
|
20
|
+
import { createTxValidatorForTransactionsEnteringPendingTxPool } from '../msg_validators/index.js';
|
|
25
21
|
import { DummyP2PService } from '../services/dummy_service.js';
|
|
26
22
|
import { LibP2PService } from '../services/index.js';
|
|
27
23
|
import { createFileStoreTxSources } from '../services/tx_collection/file_store_tx_source.js';
|
|
@@ -30,14 +26,14 @@ import { NodeRpcTxSource, type TxSource, createNodeRpcTxSources } from '../servi
|
|
|
30
26
|
import { TxFileStore } from '../services/tx_file_store/tx_file_store.js';
|
|
31
27
|
import { configureP2PClientAddresses, createLibP2PPeerIdFromPrivateKey, getPeerIdPrivateKey } from '../util.js';
|
|
32
28
|
|
|
33
|
-
export type P2PClientDeps
|
|
29
|
+
export type P2PClientDeps = {
|
|
34
30
|
txPool?: TxPoolV2;
|
|
35
31
|
store?: AztecAsyncKVStore;
|
|
36
32
|
attestationPool?: AttestationPoolApi;
|
|
37
33
|
logger?: Logger;
|
|
38
34
|
txCollectionNodeSources?: TxSource[];
|
|
39
35
|
rpcTxProviders?: AztecNode[];
|
|
40
|
-
p2pServiceFactory?: (...args: Parameters<(typeof LibP2PService)['new']>) => Promise<LibP2PService
|
|
36
|
+
p2pServiceFactory?: (...args: Parameters<(typeof LibP2PService)['new']>) => Promise<LibP2PService>;
|
|
41
37
|
};
|
|
42
38
|
|
|
43
39
|
export const P2P_STORE_NAME = 'p2p';
|
|
@@ -45,8 +41,7 @@ export const P2P_ARCHIVE_STORE_NAME = 'p2p-archive';
|
|
|
45
41
|
export const P2P_PEER_STORE_NAME = 'p2p-peers';
|
|
46
42
|
export const P2P_ATTESTATION_STORE_NAME = 'p2p-attestation';
|
|
47
43
|
|
|
48
|
-
export async function createP2PClient
|
|
49
|
-
clientType: T,
|
|
44
|
+
export async function createP2PClient(
|
|
50
45
|
inputConfig: P2PConfig & DataStoreConfig & ChainConfig,
|
|
51
46
|
archiver: L2BlockSource & ContractDataSource,
|
|
52
47
|
proofVerifier: ClientProtocolCircuitVerifier,
|
|
@@ -55,7 +50,7 @@ export async function createP2PClient<T extends P2PClientType>(
|
|
|
55
50
|
packageVersion: string,
|
|
56
51
|
dateProvider: DateProvider = new DateProvider(),
|
|
57
52
|
telemetry: TelemetryClient = getTelemetryClient(),
|
|
58
|
-
deps: P2PClientDeps
|
|
53
|
+
deps: P2PClientDeps = {},
|
|
59
54
|
) {
|
|
60
55
|
const config = await configureP2PClientAddresses({
|
|
61
56
|
...inputConfig,
|
|
@@ -80,32 +75,6 @@ export async function createP2PClient<T extends P2PClientType>(
|
|
|
80
75
|
const rollupAddress = inputConfig.l1Contracts.rollupAddress.toString().toLowerCase().replace(/^0x/, '');
|
|
81
76
|
const txFileStoreBasePath = `aztec-${inputConfig.l1ChainId}-${inputConfig.rollupVersion}-0x${rollupAddress}`;
|
|
82
77
|
|
|
83
|
-
/** Validator factory for pool re-validation (double-spend + block header only). */
|
|
84
|
-
const createPoolTxValidator = async () => {
|
|
85
|
-
await worldStateSynchronizer.syncImmediate();
|
|
86
|
-
return new AggregateTxValidator<TxMetaData>(
|
|
87
|
-
new DoubleSpendTxValidator<TxMetaData>(
|
|
88
|
-
{
|
|
89
|
-
nullifiersExist: async (nullifiers: Buffer[]) => {
|
|
90
|
-
const merkleTree = worldStateSynchronizer.getCommitted();
|
|
91
|
-
const indices = await merkleTree.findLeafIndices(MerkleTreeId.NULLIFIER_TREE, nullifiers);
|
|
92
|
-
return indices.map(index => index !== undefined);
|
|
93
|
-
},
|
|
94
|
-
},
|
|
95
|
-
bindings,
|
|
96
|
-
),
|
|
97
|
-
new BlockHeaderTxValidator<TxMetaData>(
|
|
98
|
-
{
|
|
99
|
-
getArchiveIndices: (archives: BlockHash[]) => {
|
|
100
|
-
const merkleTree = worldStateSynchronizer.getCommitted();
|
|
101
|
-
return merkleTree.findLeafIndices(MerkleTreeId.ARCHIVE, archives);
|
|
102
|
-
},
|
|
103
|
-
},
|
|
104
|
-
bindings,
|
|
105
|
-
),
|
|
106
|
-
);
|
|
107
|
-
};
|
|
108
|
-
|
|
109
78
|
const txPool =
|
|
110
79
|
deps.txPool ??
|
|
111
80
|
new AztecKVTxPoolV2(
|
|
@@ -114,13 +83,23 @@ export async function createP2PClient<T extends P2PClientType>(
|
|
|
114
83
|
{
|
|
115
84
|
l2BlockSource: archiver,
|
|
116
85
|
worldStateSynchronizer,
|
|
117
|
-
createTxValidator:
|
|
86
|
+
createTxValidator: async () => {
|
|
87
|
+
// We accept transactions if they are not expired by the next slot and block number (checked based on the ExpirationTimestamp field)
|
|
88
|
+
const currentBlockNumber = await archiver.getBlockNumber();
|
|
89
|
+
const { ts: nextSlotTimestamp } = epochCache.getEpochAndSlotInNextL1Slot();
|
|
90
|
+
return createTxValidatorForTransactionsEnteringPendingTxPool(
|
|
91
|
+
worldStateSynchronizer,
|
|
92
|
+
nextSlotTimestamp,
|
|
93
|
+
BlockNumber(currentBlockNumber + 1),
|
|
94
|
+
);
|
|
95
|
+
},
|
|
118
96
|
},
|
|
119
97
|
telemetry,
|
|
120
98
|
{
|
|
121
99
|
maxPendingTxCount: config.maxPendingTxCount,
|
|
122
100
|
archivedTxLimit: config.archivedTxLimit,
|
|
123
101
|
minTxPoolAgeMs: config.minTxPoolAgeMs,
|
|
102
|
+
dropTransactionsProbability: config.dropTransactionsProbability,
|
|
124
103
|
},
|
|
125
104
|
dateProvider,
|
|
126
105
|
);
|
|
@@ -130,9 +109,8 @@ export async function createP2PClient<T extends P2PClientType>(
|
|
|
130
109
|
attestationPool: deps.attestationPool ?? new AttestationPool(attestationStore, telemetry),
|
|
131
110
|
};
|
|
132
111
|
|
|
133
|
-
const p2pService = await createP2PService
|
|
112
|
+
const p2pService = await createP2PService(
|
|
134
113
|
config,
|
|
135
|
-
clientType,
|
|
136
114
|
archiver,
|
|
137
115
|
proofVerifier,
|
|
138
116
|
worldStateSynchronizer,
|
|
@@ -190,7 +168,6 @@ export async function createP2PClient<T extends P2PClientType>(
|
|
|
190
168
|
);
|
|
191
169
|
|
|
192
170
|
return new P2PClient(
|
|
193
|
-
clientType,
|
|
194
171
|
store,
|
|
195
172
|
archiver,
|
|
196
173
|
mempools,
|
|
@@ -204,9 +181,8 @@ export async function createP2PClient<T extends P2PClientType>(
|
|
|
204
181
|
);
|
|
205
182
|
}
|
|
206
183
|
|
|
207
|
-
async function createP2PService
|
|
184
|
+
async function createP2PService(
|
|
208
185
|
config: P2PConfig & DataStoreConfig,
|
|
209
|
-
clientType: T,
|
|
210
186
|
archiver: L2BlockSource & ContractDataSource,
|
|
211
187
|
proofVerifier: ClientProtocolCircuitVerifier,
|
|
212
188
|
worldStateSynchronizer: WorldStateSynchronizer,
|
|
@@ -214,7 +190,7 @@ async function createP2PService<T extends P2PClientType>(
|
|
|
214
190
|
store: AztecAsyncKVStore,
|
|
215
191
|
peerStore: AztecLMDBStoreV2,
|
|
216
192
|
mempools: MemPools,
|
|
217
|
-
p2pServiceFactory: P2PClientDeps
|
|
193
|
+
p2pServiceFactory: P2PClientDeps['p2pServiceFactory'],
|
|
218
194
|
packageVersion: string,
|
|
219
195
|
logger: Logger,
|
|
220
196
|
telemetry: TelemetryClient,
|
|
@@ -230,7 +206,7 @@ async function createP2PService<T extends P2PClientType>(
|
|
|
230
206
|
const peerIdPrivateKey = await getPeerIdPrivateKey(config, store, logger);
|
|
231
207
|
const peerId = await createLibP2PPeerIdFromPrivateKey(peerIdPrivateKey.getValue());
|
|
232
208
|
|
|
233
|
-
const p2pService = await (p2pServiceFactory ?? LibP2PService.new
|
|
209
|
+
const p2pService = await (p2pServiceFactory ?? LibP2PService.new)(config, peerId, {
|
|
234
210
|
packageVersion,
|
|
235
211
|
mempools,
|
|
236
212
|
l2BlockSource: archiver,
|
package/src/client/interface.ts
CHANGED
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
import type { SlotNumber } from '@aztec/foundation/branded-types';
|
|
2
2
|
import type { EthAddress, L2BlockId } from '@aztec/stdlib/block';
|
|
3
|
-
import type { ITxProvider,
|
|
4
|
-
import type {
|
|
5
|
-
BlockProposal,
|
|
6
|
-
CheckpointAttestation,
|
|
7
|
-
CheckpointProposal,
|
|
8
|
-
P2PClientType,
|
|
9
|
-
TopicType,
|
|
10
|
-
} from '@aztec/stdlib/p2p';
|
|
3
|
+
import type { ITxProvider, P2PClient } from '@aztec/stdlib/interfaces/server';
|
|
4
|
+
import type { BlockProposal, CheckpointAttestation, CheckpointProposal, TopicType } from '@aztec/stdlib/p2p';
|
|
11
5
|
import type { BlockHeader, Tx, TxHash } from '@aztec/stdlib/tx';
|
|
12
6
|
|
|
13
7
|
import type { PeerId } from '@libp2p/interface';
|
|
@@ -54,7 +48,7 @@ export interface P2PSyncState {
|
|
|
54
48
|
/**
|
|
55
49
|
* Interface of a P2P client.
|
|
56
50
|
**/
|
|
57
|
-
export type P2P
|
|
51
|
+
export type P2P = P2PClient & {
|
|
58
52
|
/**
|
|
59
53
|
* Broadcasts a block proposal to other peers.
|
|
60
54
|
*
|
|
@@ -140,14 +134,6 @@ export type P2P<T extends P2PClientType = P2PClientType.Full> = P2PApiFull<T> &
|
|
|
140
134
|
*/
|
|
141
135
|
hasTxsInPool(txHashes: TxHash[]): Promise<boolean[]>;
|
|
142
136
|
|
|
143
|
-
/**
|
|
144
|
-
* Returns transactions in the transaction pool by hash, requesting from the network if not found.
|
|
145
|
-
* @param txHashes - Hashes of tx to return.
|
|
146
|
-
* @param pinnedPeerId - An optional peer id that will be used to request the tx from (in addition to other random peers).
|
|
147
|
-
* @returns An array of tx or undefined.
|
|
148
|
-
*/
|
|
149
|
-
getTxsByHash(txHashes: TxHash[], pinnedPeerId: PeerId | undefined): Promise<(Tx | undefined)[]>;
|
|
150
|
-
|
|
151
137
|
/**
|
|
152
138
|
* Returns an archived transaction from the transaction pool by its hash.
|
|
153
139
|
* @param txHash - Hash of tx to return.
|
|
@@ -224,8 +210,8 @@ export type P2P<T extends P2PClientType = P2PClientType.Full> = P2PApiFull<T> &
|
|
|
224
210
|
|
|
225
211
|
updateP2PConfig(config: Partial<P2PConfig>): Promise<void>;
|
|
226
212
|
|
|
227
|
-
/** Validates a set of txs. */
|
|
228
|
-
|
|
213
|
+
/** Validates a set of txs received in a block proposal. */
|
|
214
|
+
validateTxsReceivedInBlockProposal(txs: Tx[]): Promise<void>;
|
|
229
215
|
|
|
230
216
|
/** Clears the db. */
|
|
231
217
|
clear(): Promise<void>;
|
package/src/client/p2p_client.ts
CHANGED
|
@@ -20,13 +20,7 @@ import {
|
|
|
20
20
|
import type { ContractDataSource } from '@aztec/stdlib/contract';
|
|
21
21
|
import { getTimestampForSlot } from '@aztec/stdlib/epoch-helpers';
|
|
22
22
|
import { type PeerInfo, tryStop } from '@aztec/stdlib/interfaces/server';
|
|
23
|
-
import {
|
|
24
|
-
type BlockProposal,
|
|
25
|
-
CheckpointAttestation,
|
|
26
|
-
type CheckpointProposal,
|
|
27
|
-
type P2PClientType,
|
|
28
|
-
type TopicType,
|
|
29
|
-
} from '@aztec/stdlib/p2p';
|
|
23
|
+
import { type BlockProposal, CheckpointAttestation, type CheckpointProposal, type TopicType } from '@aztec/stdlib/p2p';
|
|
30
24
|
import type { BlockHeader, Tx, TxHash } from '@aztec/stdlib/tx';
|
|
31
25
|
import { Attributes, type TelemetryClient, WithTracer, getTelemetryClient, trackSpan } from '@aztec/telemetry-client';
|
|
32
26
|
|
|
@@ -44,7 +38,6 @@ import {
|
|
|
44
38
|
type ReqRespSubProtocolHandler,
|
|
45
39
|
type ReqRespSubProtocolValidators,
|
|
46
40
|
} from '../services/reqresp/interface.js';
|
|
47
|
-
import { chunkTxHashesRequest } from '../services/reqresp/protocols/tx.js';
|
|
48
41
|
import type {
|
|
49
42
|
DuplicateAttestationInfo,
|
|
50
43
|
DuplicateProposalInfo,
|
|
@@ -60,10 +53,7 @@ import { type P2P, P2PClientState, type P2PSyncState } from './interface.js';
|
|
|
60
53
|
/**
|
|
61
54
|
* The P2P client implementation.
|
|
62
55
|
*/
|
|
63
|
-
export class P2PClient
|
|
64
|
-
extends WithTracer
|
|
65
|
-
implements P2P, P2P<P2PClientType.Prover>
|
|
66
|
-
{
|
|
56
|
+
export class P2PClient extends WithTracer implements P2P {
|
|
67
57
|
/** The JS promise that will be running to keep the client's data in sync. Can be interrupted if the client is stopped. */
|
|
68
58
|
private runningPromise!: Promise<void>;
|
|
69
59
|
|
|
@@ -95,7 +85,6 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
95
85
|
private slotMonitor: RunningPromise | undefined;
|
|
96
86
|
|
|
97
87
|
constructor(
|
|
98
|
-
_clientType: T,
|
|
99
88
|
private store: AztecAsyncKVStore,
|
|
100
89
|
private l2BlockSource: L2BlockSource & ContractDataSource,
|
|
101
90
|
mempools: MemPools,
|
|
@@ -433,36 +422,6 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
433
422
|
this.p2pService.registerDuplicateAttestationCallback(callback);
|
|
434
423
|
}
|
|
435
424
|
|
|
436
|
-
/**
|
|
437
|
-
* Uses the batched Request Response protocol to request a set of transactions from the network.
|
|
438
|
-
*/
|
|
439
|
-
private async requestTxsByHash(txHashes: TxHash[], pinnedPeerId: PeerId | undefined): Promise<Tx[]> {
|
|
440
|
-
const timeoutMs = 8000; // Longer timeout for now
|
|
441
|
-
const maxRetryAttempts = 10; // Keep retrying within the timeout
|
|
442
|
-
const requests = chunkTxHashesRequest(txHashes);
|
|
443
|
-
const maxPeers = Math.min(Math.ceil(requests.length / 3), 10);
|
|
444
|
-
|
|
445
|
-
const txBatches = await this.p2pService.sendBatchRequest(
|
|
446
|
-
ReqRespSubProtocol.TX,
|
|
447
|
-
requests,
|
|
448
|
-
pinnedPeerId,
|
|
449
|
-
timeoutMs,
|
|
450
|
-
maxPeers,
|
|
451
|
-
maxRetryAttempts,
|
|
452
|
-
);
|
|
453
|
-
|
|
454
|
-
const txs = txBatches.flat();
|
|
455
|
-
if (txs.length > 0) {
|
|
456
|
-
await this.txPool.addPendingTxs(txs);
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
const txHashesStr = txHashes.map(tx => tx.toString()).join(', ');
|
|
460
|
-
this.log.debug(`Requested txs ${txHashesStr} (${txs.length} / ${txHashes.length}) from peers`);
|
|
461
|
-
|
|
462
|
-
// We return all transactions, even the not found ones to the caller, such they can handle missing items themselves.
|
|
463
|
-
return txs;
|
|
464
|
-
}
|
|
465
|
-
|
|
466
425
|
public async getPendingTxs(limit?: number, after?: TxHash): Promise<Tx[]> {
|
|
467
426
|
if (limit !== undefined && limit <= 0) {
|
|
468
427
|
throw new TypeError('limit must be greater than 0');
|
|
@@ -530,49 +489,6 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
530
489
|
return this.txPool.hasTxs(txHashes);
|
|
531
490
|
}
|
|
532
491
|
|
|
533
|
-
/**
|
|
534
|
-
* Returns transactions in the transaction pool by hash.
|
|
535
|
-
* If a transaction is not in the pool, it will be requested from the network.
|
|
536
|
-
* @param txHashes - Hashes of the transactions to look for.
|
|
537
|
-
* @returns The txs found, or undefined if not found in the order requested.
|
|
538
|
-
*/
|
|
539
|
-
async getTxsByHash(txHashes: TxHash[], pinnedPeerId: PeerId | undefined): Promise<(Tx | undefined)[]> {
|
|
540
|
-
const txs = await Promise.all(txHashes.map(txHash => this.txPool.getTxByHash(txHash)));
|
|
541
|
-
const missingTxHashes = txs
|
|
542
|
-
.map((tx, index) => [tx, index] as const)
|
|
543
|
-
.filter(([tx, _index]) => !tx)
|
|
544
|
-
.map(([_tx, index]) => txHashes[index]);
|
|
545
|
-
|
|
546
|
-
if (missingTxHashes.length === 0) {
|
|
547
|
-
return txs as Tx[];
|
|
548
|
-
}
|
|
549
|
-
|
|
550
|
-
const missingTxs = await this.requestTxsByHash(missingTxHashes, pinnedPeerId);
|
|
551
|
-
// TODO: optimize
|
|
552
|
-
// Merge the found txs in order
|
|
553
|
-
const mergingTxs = txHashes.map(txHash => {
|
|
554
|
-
// Is it in the txs list from the mempool?
|
|
555
|
-
for (const tx of txs) {
|
|
556
|
-
if (tx !== undefined && tx.getTxHash().equals(txHash)) {
|
|
557
|
-
return tx;
|
|
558
|
-
}
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
// Is it in the fetched missing txs?
|
|
562
|
-
// Note: this is an O(n^2) operation, but we expect the number of missing txs to be small.
|
|
563
|
-
for (const tx of missingTxs) {
|
|
564
|
-
if (tx.getTxHash().equals(txHash)) {
|
|
565
|
-
return tx;
|
|
566
|
-
}
|
|
567
|
-
}
|
|
568
|
-
|
|
569
|
-
// Otherwise return undefined
|
|
570
|
-
return undefined;
|
|
571
|
-
});
|
|
572
|
-
|
|
573
|
-
return mergingTxs;
|
|
574
|
-
}
|
|
575
|
-
|
|
576
492
|
/**
|
|
577
493
|
* Returns an archived transaction in the transaction pool by its hash.
|
|
578
494
|
* @param txHash - Hash of the archived transaction to look for.
|
|
@@ -839,8 +755,8 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
839
755
|
this.log.debug(`Moved from state ${P2PClientState[oldState]} to ${P2PClientState[this.currentState]}`);
|
|
840
756
|
}
|
|
841
757
|
|
|
842
|
-
public
|
|
843
|
-
return this.p2pService.
|
|
758
|
+
public validateTxsReceivedInBlockProposal(txs: Tx[]): Promise<void> {
|
|
759
|
+
return this.p2pService.validateTxsReceivedInBlockProposal(txs);
|
|
844
760
|
}
|
|
845
761
|
|
|
846
762
|
/**
|
|
@@ -8,7 +8,7 @@ import { openTmpStore } from '@aztec/kv-store/lmdb-v2';
|
|
|
8
8
|
import type { L2BlockSource } from '@aztec/stdlib/block';
|
|
9
9
|
import type { ContractDataSource } from '@aztec/stdlib/contract';
|
|
10
10
|
import type { ClientProtocolCircuitVerifier } from '@aztec/stdlib/interfaces/server';
|
|
11
|
-
import {
|
|
11
|
+
import { PeerErrorSeverity } from '@aztec/stdlib/p2p';
|
|
12
12
|
import type { Tx, TxValidationResult } from '@aztec/stdlib/tx';
|
|
13
13
|
import { type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-client';
|
|
14
14
|
|
|
@@ -114,7 +114,6 @@ async function startClient(config: P2PConfig, clientIndex: number) {
|
|
|
114
114
|
};
|
|
115
115
|
|
|
116
116
|
client = await createP2PClient(
|
|
117
|
-
P2PClientType.Full,
|
|
118
117
|
config as P2PConfig & DataStoreConfig,
|
|
119
118
|
l2BlockSource as L2BlockSource & ContractDataSource,
|
|
120
119
|
proofVerifier as ClientProtocolCircuitVerifier,
|
package/src/config.ts
CHANGED
|
@@ -38,7 +38,7 @@ export interface P2PConfig
|
|
|
38
38
|
ChainConfig,
|
|
39
39
|
TxCollectionConfig,
|
|
40
40
|
TxFileStoreConfig,
|
|
41
|
-
Pick<SequencerConfig, 'blockDurationMs' | 'expectedBlockProposalsPerSlot'> {
|
|
41
|
+
Pick<SequencerConfig, 'blockDurationMs' | 'expectedBlockProposalsPerSlot' | 'maxTxsPerBlock'> {
|
|
42
42
|
/** A flag dictating whether the P2P subsystem should be enabled. */
|
|
43
43
|
p2pEnabled: boolean;
|
|
44
44
|
|
|
@@ -150,8 +150,8 @@ export interface P2PConfig
|
|
|
150
150
|
/** The maximum possible size of the P2P DB in KB. Overwrites the general dataStoreMapSizeKb. */
|
|
151
151
|
p2pStoreMapSizeKb?: number;
|
|
152
152
|
|
|
153
|
-
/**
|
|
154
|
-
|
|
153
|
+
/** Additional entries to extend the default setup allow list. */
|
|
154
|
+
txPublicSetupAllowListExtend: AllowedElement[];
|
|
155
155
|
|
|
156
156
|
/** The maximum number of pending txs before evicting lower priority txs. */
|
|
157
157
|
maxPendingTxCount: number;
|
|
@@ -173,10 +173,7 @@ export interface P2PConfig
|
|
|
173
173
|
/** Whether transactions are disabled for this node. This means transactions will be rejected at the RPC and P2P layers. */
|
|
174
174
|
disableTransactions: boolean;
|
|
175
175
|
|
|
176
|
-
/**
|
|
177
|
-
dropTransactions: boolean;
|
|
178
|
-
|
|
179
|
-
/** The probability that a transaction is discarded. - For testing purposes only */
|
|
176
|
+
/** The probability that a transaction is discarded (0 = disabled). - For testing purposes only */
|
|
180
177
|
dropTransactionsProbability: number;
|
|
181
178
|
|
|
182
179
|
/** Whether to delete transactions from the pool after a reorg instead of moving them back to pending. */
|
|
@@ -396,12 +393,13 @@ export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
|
|
|
396
393
|
parseEnv: (val: string | undefined) => (val ? +val : undefined),
|
|
397
394
|
description: 'The maximum possible size of the P2P DB in KB. Overwrites the general dataStoreMapSizeKb.',
|
|
398
395
|
},
|
|
399
|
-
|
|
396
|
+
txPublicSetupAllowListExtend: {
|
|
400
397
|
env: 'TX_PUBLIC_SETUP_ALLOWLIST',
|
|
401
398
|
parseEnv: (val: string) => parseAllowList(val),
|
|
402
|
-
description:
|
|
399
|
+
description:
|
|
400
|
+
'Additional entries to extend the default setup allow list. Format: I:address:selector,C:classId:selector',
|
|
403
401
|
printDefault: () =>
|
|
404
|
-
'AuthRegistry, FeeJuice.
|
|
402
|
+
'Default: AuthRegistry._set_authorized, FeeJuice._increase_public_balance, Token._increase_public_balance, Token.transfer_in_public',
|
|
405
403
|
},
|
|
406
404
|
maxPendingTxCount: {
|
|
407
405
|
env: 'P2P_MAX_PENDING_TX_COUNT',
|
|
@@ -430,11 +428,6 @@ export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
|
|
|
430
428
|
description: 'Number of auth attempts to allow before peer is banned. Number is inclusive',
|
|
431
429
|
...numberConfigHelper(3),
|
|
432
430
|
},
|
|
433
|
-
dropTransactions: {
|
|
434
|
-
env: 'P2P_DROP_TX',
|
|
435
|
-
description: 'True to simulate discarding transactions. - For testing purposes only',
|
|
436
|
-
...booleanConfigHelper(false),
|
|
437
|
-
},
|
|
438
431
|
dropTransactionsProbability: {
|
|
439
432
|
env: 'P2P_DROP_TX_CHANCE',
|
|
440
433
|
description: 'The probability that a transaction is discarded (0 - 1). - For testing purposes only',
|
|
@@ -531,11 +524,9 @@ export const bootnodeConfigMappings = pickConfigMappings(
|
|
|
531
524
|
|
|
532
525
|
/**
|
|
533
526
|
* Parses a string to a list of allowed elements.
|
|
534
|
-
* Each
|
|
535
|
-
* `I:${address}`
|
|
536
|
-
* `
|
|
537
|
-
* `C:${classId}`
|
|
538
|
-
* `C:${classId}:${selector}`
|
|
527
|
+
* Each entry is expected to be of one of the following formats:
|
|
528
|
+
* `I:${address}:${selector}` — instance (contract address) with function selector
|
|
529
|
+
* `C:${classId}:${selector}` — class with function selector
|
|
539
530
|
*
|
|
540
531
|
* @param value The string to parse
|
|
541
532
|
* @returns A list of allowed elements
|
|
@@ -548,31 +539,34 @@ export function parseAllowList(value: string): AllowedElement[] {
|
|
|
548
539
|
}
|
|
549
540
|
|
|
550
541
|
for (const val of value.split(',')) {
|
|
551
|
-
const
|
|
552
|
-
|
|
542
|
+
const trimmed = val.trim();
|
|
543
|
+
if (!trimmed) {
|
|
544
|
+
continue;
|
|
545
|
+
}
|
|
546
|
+
const [typeString, identifierString, selectorString] = trimmed.split(':');
|
|
547
|
+
|
|
548
|
+
if (!selectorString) {
|
|
549
|
+
throw new Error(
|
|
550
|
+
`Invalid allow list entry "${trimmed}": selector is required. Expected format: I:address:selector or C:classId:selector`,
|
|
551
|
+
);
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
const selector = FunctionSelector.fromString(selectorString);
|
|
553
555
|
|
|
554
556
|
if (typeString === 'I') {
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
});
|
|
560
|
-
} else {
|
|
561
|
-
entries.push({
|
|
562
|
-
address: AztecAddress.fromString(identifierString),
|
|
563
|
-
});
|
|
564
|
-
}
|
|
557
|
+
entries.push({
|
|
558
|
+
address: AztecAddress.fromString(identifierString),
|
|
559
|
+
selector,
|
|
560
|
+
});
|
|
565
561
|
} else if (typeString === 'C') {
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
});
|
|
575
|
-
}
|
|
562
|
+
entries.push({
|
|
563
|
+
classId: Fr.fromHexString(identifierString),
|
|
564
|
+
selector,
|
|
565
|
+
});
|
|
566
|
+
} else {
|
|
567
|
+
throw new Error(
|
|
568
|
+
`Invalid allow list entry "${trimmed}": unknown type "${typeString}". Expected "I" (instance) or "C" (class).`,
|
|
569
|
+
);
|
|
576
570
|
}
|
|
577
571
|
}
|
|
578
572
|
|
|
@@ -359,11 +359,10 @@ export class AttestationPool {
|
|
|
359
359
|
}
|
|
360
360
|
|
|
361
361
|
const address = sender.toString();
|
|
362
|
+
const ownKey = this.getAttestationKey(slotNumber, proposalId, address);
|
|
362
363
|
|
|
363
|
-
await this.checkpointAttestations.set(
|
|
364
|
-
|
|
365
|
-
attestation.toBuffer(),
|
|
366
|
-
);
|
|
364
|
+
await this.checkpointAttestations.set(ownKey, attestation.toBuffer());
|
|
365
|
+
this.metrics.trackMempoolItemAdded(ownKey);
|
|
367
366
|
|
|
368
367
|
this.log.debug(`Added own checkpoint attestation for slot ${slotNumber} from ${address}`, {
|
|
369
368
|
signature: attestation.signature.toString(),
|
|
@@ -429,6 +428,7 @@ export class AttestationPool {
|
|
|
429
428
|
const attestationEndKey = new Fr(oldestSlot).toString();
|
|
430
429
|
for await (const key of this.checkpointAttestations.keysAsync({ end: attestationEndKey })) {
|
|
431
430
|
await this.checkpointAttestations.delete(key);
|
|
431
|
+
this.metrics.trackMempoolItemRemoved(key);
|
|
432
432
|
numberOfAttestations++;
|
|
433
433
|
}
|
|
434
434
|
|
|
@@ -526,6 +526,7 @@ export class AttestationPool {
|
|
|
526
526
|
|
|
527
527
|
// Add the attestation
|
|
528
528
|
await this.checkpointAttestations.set(key, attestation.toBuffer());
|
|
529
|
+
this.metrics.trackMempoolItemAdded(key);
|
|
529
530
|
|
|
530
531
|
// Track this attestation in the per-signer-per-slot index for duplicate detection
|
|
531
532
|
const slotSignerKey = this.getSlotSignerKey(slotNumber, signerAddress);
|