@aztec/p2p 0.0.1-commit.d3ec352c → 0.0.1-commit.fcb71a6
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 +2 -2
- package/dest/client/factory.d.ts.map +1 -1
- package/dest/client/factory.js +2 -3
- package/dest/client/p2p_client.d.ts +2 -2
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +17 -16
- package/dest/config.d.ts +4 -7
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +8 -11
- package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.js +2 -2
- package/dest/mem_pools/attestation_pool/kv_attestation_pool.js +1 -1
- package/dest/mem_pools/attestation_pool/mocks.d.ts +3 -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/instrumentation.d.ts +7 -1
- package/dest/mem_pools/instrumentation.d.ts.map +1 -1
- package/dest/mem_pools/instrumentation.js +29 -2
- package/dest/mem_pools/interface.d.ts +3 -4
- package/dest/mem_pools/interface.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts +28 -24
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.js +262 -324
- package/dest/mem_pools/tx_pool/eviction/eviction_manager.d.ts +18 -0
- package/dest/mem_pools/tx_pool/eviction/eviction_manager.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool/eviction/eviction_manager.js +56 -0
- package/dest/mem_pools/tx_pool/eviction/eviction_strategy.d.ts +83 -0
- package/dest/mem_pools/tx_pool/eviction/eviction_strategy.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool/eviction/eviction_strategy.js +5 -0
- package/dest/mem_pools/tx_pool/eviction/insufficient_fee_payer_balance_rule.d.ts +15 -0
- package/dest/mem_pools/tx_pool/eviction/insufficient_fee_payer_balance_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool/eviction/insufficient_fee_payer_balance_rule.js +88 -0
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.d.ts +17 -0
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.js +84 -0
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.d.ts +19 -0
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.js +76 -0
- package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.d.ts +26 -0
- package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.js +84 -0
- package/dest/mem_pools/tx_pool/index.d.ts +1 -2
- package/dest/mem_pools/tx_pool/index.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/index.js +0 -1
- package/dest/mem_pools/tx_pool/priority.d.ts +5 -1
- package/dest/mem_pools/tx_pool/priority.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/priority.js +6 -1
- package/dest/mem_pools/tx_pool/tx_pool.d.ts +8 -4
- package/dest/mem_pools/tx_pool/tx_pool.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts +1 -1
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.js +25 -20
- package/dest/msg_validators/attestation_validator/attestation_validator.js +1 -1
- package/dest/msg_validators/block_proposal_validator/block_proposal_validator.js +1 -1
- package/dest/msg_validators/tx_validator/archive_cache.d.ts +2 -2
- package/dest/msg_validators/tx_validator/archive_cache.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/block_header_validator.d.ts +2 -2
- package/dest/msg_validators/tx_validator/block_header_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/factory.d.ts +2 -2
- package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/factory.js +1 -1
- package/dest/msg_validators/tx_validator/metadata_validator.d.ts +2 -2
- package/dest/msg_validators/tx_validator/metadata_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/test_utils.d.ts +2 -2
- package/dest/msg_validators/tx_validator/test_utils.d.ts.map +1 -1
- package/dest/services/encoding.js +1 -1
- package/dest/services/libp2p/libp2p_service.d.ts +4 -4
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +9 -14
- package/dest/services/peer-manager/metrics.d.ts +6 -1
- package/dest/services/peer-manager/metrics.d.ts.map +1 -1
- package/dest/services/peer-manager/metrics.js +17 -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 +4 -2
- package/dest/services/reqresp/interface.d.ts +2 -2
- package/dest/services/reqresp/interface.d.ts.map +1 -1
- package/dest/services/reqresp/interface.js +1 -1
- package/dest/services/reqresp/protocols/auth.d.ts +2 -2
- package/dest/services/reqresp/protocols/auth.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/auth.js +2 -2
- package/dest/services/reqresp/protocols/block.js +1 -1
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts +2 -2
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.js +1 -1
- package/dest/services/reqresp/protocols/tx.d.ts +2 -3
- package/dest/services/reqresp/protocols/tx.d.ts.map +1 -1
- package/dest/services/tx_collection/config.js +1 -1
- package/dest/services/tx_collection/slow_tx_collection.d.ts +3 -3
- package/dest/services/tx_collection/slow_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_collection.d.ts +4 -4
- package/dest/services/tx_collection/tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_collection.js +1 -1
- package/dest/services/tx_provider.d.ts +2 -1
- package/dest/services/tx_provider.d.ts.map +1 -1
- package/dest/services/tx_provider.js +11 -2
- package/dest/services/tx_provider_instrumentation.d.ts +5 -2
- package/dest/services/tx_provider_instrumentation.d.ts.map +1 -1
- package/dest/services/tx_provider_instrumentation.js +14 -1
- package/dest/test-helpers/mock-tx-helpers.js +1 -1
- package/dest/test-helpers/reqresp-nodes.d.ts +2 -2
- package/dest/test-helpers/reqresp-nodes.d.ts.map +1 -1
- package/dest/testbench/p2p_client_testbench_worker.js +1 -0
- package/package.json +14 -14
- package/src/client/factory.ts +5 -10
- package/src/client/p2p_client.ts +26 -31
- package/src/config.ts +10 -16
- package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +2 -2
- package/src/mem_pools/attestation_pool/kv_attestation_pool.ts +1 -1
- package/src/mem_pools/attestation_pool/mocks.ts +2 -2
- package/src/mem_pools/instrumentation.ts +33 -0
- package/src/mem_pools/interface.ts +2 -4
- package/src/mem_pools/tx_pool/README.md +255 -0
- package/src/mem_pools/tx_pool/aztec_kv_tx_pool.ts +309 -369
- package/src/mem_pools/tx_pool/eviction/eviction_manager.ts +71 -0
- package/src/mem_pools/tx_pool/eviction/eviction_strategy.ts +93 -0
- package/src/mem_pools/tx_pool/eviction/insufficient_fee_payer_balance_rule.ts +108 -0
- package/src/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.ts +104 -0
- package/src/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.ts +91 -0
- package/src/mem_pools/tx_pool/eviction/low_priority_eviction_rule.ts +106 -0
- package/src/mem_pools/tx_pool/index.ts +0 -1
- package/src/mem_pools/tx_pool/priority.ts +8 -1
- package/src/mem_pools/tx_pool/tx_pool.ts +8 -3
- package/src/mem_pools/tx_pool/tx_pool_test_suite.ts +18 -13
- package/src/msg_validators/attestation_validator/attestation_validator.ts +1 -1
- package/src/msg_validators/block_proposal_validator/block_proposal_validator.ts +1 -1
- package/src/msg_validators/tx_validator/archive_cache.ts +1 -1
- package/src/msg_validators/tx_validator/block_header_validator.ts +1 -1
- package/src/msg_validators/tx_validator/factory.ts +1 -1
- package/src/msg_validators/tx_validator/metadata_validator.ts +1 -1
- package/src/msg_validators/tx_validator/test_utils.ts +1 -1
- package/src/services/encoding.ts +1 -1
- package/src/services/libp2p/libp2p_service.ts +14 -19
- package/src/services/peer-manager/metrics.ts +22 -0
- package/src/services/peer-manager/peer_manager.ts +4 -2
- package/src/services/reqresp/interface.ts +1 -1
- package/src/services/reqresp/protocols/auth.ts +2 -2
- package/src/services/reqresp/protocols/block.ts +1 -1
- package/src/services/reqresp/protocols/block_txs/block_txs_reqresp.ts +1 -1
- package/src/services/reqresp/protocols/tx.ts +1 -2
- package/src/services/tx_collection/config.ts +1 -1
- package/src/services/tx_collection/slow_tx_collection.ts +2 -2
- package/src/services/tx_collection/tx_collection.ts +4 -4
- package/src/services/tx_provider.ts +17 -2
- package/src/services/tx_provider_instrumentation.ts +19 -2
- package/src/test-helpers/mock-pubsub.ts +1 -1
- package/src/test-helpers/mock-tx-helpers.ts +1 -1
- package/src/test-helpers/reqresp-nodes.ts +1 -1
- package/src/testbench/p2p_client_testbench_worker.ts +2 -1
- package/dest/mem_pools/tx_pool/memory_tx_pool.d.ts +0 -81
- package/dest/mem_pools/tx_pool/memory_tx_pool.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/memory_tx_pool.js +0 -239
- package/src/mem_pools/tx_pool/memory_tx_pool.ts +0 -285
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.fcb71a6",
|
|
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.fcb71a6",
|
|
71
|
+
"@aztec/epoch-cache": "0.0.1-commit.fcb71a6",
|
|
72
|
+
"@aztec/ethereum": "0.0.1-commit.fcb71a6",
|
|
73
|
+
"@aztec/foundation": "0.0.1-commit.fcb71a6",
|
|
74
|
+
"@aztec/kv-store": "0.0.1-commit.fcb71a6",
|
|
75
|
+
"@aztec/noir-contracts.js": "0.0.1-commit.fcb71a6",
|
|
76
|
+
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.fcb71a6",
|
|
77
|
+
"@aztec/protocol-contracts": "0.0.1-commit.fcb71a6",
|
|
78
|
+
"@aztec/simulator": "0.0.1-commit.fcb71a6",
|
|
79
|
+
"@aztec/stdlib": "0.0.1-commit.fcb71a6",
|
|
80
|
+
"@aztec/telemetry-client": "0.0.1-commit.fcb71a6",
|
|
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.fcb71a6",
|
|
108
|
+
"@aztec/world-state": "0.0.1-commit.fcb71a6",
|
|
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
|
@@ -26,7 +26,7 @@ import { configureP2PClientAddresses, createLibP2PPeerIdFromPrivateKey, getPeerI
|
|
|
26
26
|
export type P2PClientDeps<T extends P2PClientType> = {
|
|
27
27
|
txPool?: TxPool;
|
|
28
28
|
store?: AztecAsyncKVStore;
|
|
29
|
-
attestationPool?:
|
|
29
|
+
attestationPool?: AttestationPool;
|
|
30
30
|
logger?: Logger;
|
|
31
31
|
txCollectionNodeSources?: TxSource[];
|
|
32
32
|
p2pServiceFactory?: (...args: Parameters<(typeof LibP2PService)['new']>) => Promise<LibP2PService<T>>;
|
|
@@ -73,19 +73,14 @@ export async function createP2PClient<T extends P2PClientType>(
|
|
|
73
73
|
);
|
|
74
74
|
const l1Constants = await archiver.getL1Constants();
|
|
75
75
|
|
|
76
|
-
const mempools: MemPools
|
|
76
|
+
const mempools: MemPools = {
|
|
77
77
|
txPool:
|
|
78
78
|
deps.txPool ??
|
|
79
79
|
new AztecKVTxPool(store, archive, worldStateSynchronizer, telemetry, {
|
|
80
|
-
|
|
80
|
+
maxPendingTxCount: config.maxPendingTxCount,
|
|
81
81
|
archivedTxLimit: config.archivedTxLimit,
|
|
82
82
|
}),
|
|
83
|
-
attestationPool:
|
|
84
|
-
clientType === P2PClientType.Full
|
|
85
|
-
? ((deps.attestationPool ?? new KvAttestationPool(attestationStore, telemetry)) as T extends P2PClientType.Full
|
|
86
|
-
? AttestationPool
|
|
87
|
-
: undefined)
|
|
88
|
-
: undefined,
|
|
83
|
+
attestationPool: deps.attestationPool ?? new KvAttestationPool(attestationStore, telemetry),
|
|
89
84
|
};
|
|
90
85
|
|
|
91
86
|
const p2pService = await createP2PService<T>(
|
|
@@ -147,7 +142,7 @@ async function createP2PService<T extends P2PClientType>(
|
|
|
147
142
|
epochCache: EpochCacheInterface,
|
|
148
143
|
store: AztecAsyncKVStore,
|
|
149
144
|
peerStore: AztecLMDBStoreV2,
|
|
150
|
-
mempools: MemPools
|
|
145
|
+
mempools: MemPools,
|
|
151
146
|
p2pServiceFactory: P2PClientDeps<T>['p2pServiceFactory'],
|
|
152
147
|
packageVersion: string,
|
|
153
148
|
logger: Logger,
|
package/src/client/p2p_client.ts
CHANGED
|
@@ -5,13 +5,12 @@ import { DateProvider } from '@aztec/foundation/timer';
|
|
|
5
5
|
import type { AztecAsyncKVStore, AztecAsyncMap, AztecAsyncSingleton } from '@aztec/kv-store';
|
|
6
6
|
import type {
|
|
7
7
|
EthAddress,
|
|
8
|
-
L2Block,
|
|
9
8
|
L2BlockId,
|
|
9
|
+
L2BlockNew,
|
|
10
10
|
L2BlockSource,
|
|
11
11
|
L2BlockStream,
|
|
12
12
|
L2BlockStreamEvent,
|
|
13
13
|
L2Tips,
|
|
14
|
-
PublishedL2Block,
|
|
15
14
|
} from '@aztec/stdlib/block';
|
|
16
15
|
import type { ContractDataSource } from '@aztec/stdlib/contract';
|
|
17
16
|
import { getTimestampForSlot } from '@aztec/stdlib/epoch-helpers';
|
|
@@ -70,7 +69,7 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
70
69
|
private synchedLatestSlot: AztecAsyncSingleton<bigint>;
|
|
71
70
|
|
|
72
71
|
private txPool: TxPool;
|
|
73
|
-
private attestationPool:
|
|
72
|
+
private attestationPool: AttestationPool;
|
|
74
73
|
|
|
75
74
|
private config: P2PConfig;
|
|
76
75
|
|
|
@@ -92,7 +91,7 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
92
91
|
_clientType: T,
|
|
93
92
|
private store: AztecAsyncKVStore,
|
|
94
93
|
private l2BlockSource: L2BlockSource & ContractDataSource,
|
|
95
|
-
mempools: MemPools
|
|
94
|
+
mempools: MemPools,
|
|
96
95
|
private p2pService: P2PService,
|
|
97
96
|
private txCollection: TxCollection,
|
|
98
97
|
config: Partial<P2PConfig> = {},
|
|
@@ -104,7 +103,7 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
104
103
|
|
|
105
104
|
this.config = { ...getP2PDefaultConfig(), ...config };
|
|
106
105
|
this.txPool = mempools.txPool;
|
|
107
|
-
this.attestationPool = mempools.attestationPool
|
|
106
|
+
this.attestationPool = mempools.attestationPool;
|
|
108
107
|
|
|
109
108
|
this.txProvider = new TxProvider(
|
|
110
109
|
this.txCollection,
|
|
@@ -217,7 +216,7 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
217
216
|
this.log.debug(`Handling block stream event ${event.type}`);
|
|
218
217
|
switch (event.type) {
|
|
219
218
|
case 'blocks-added':
|
|
220
|
-
await this.handleLatestL2Blocks(event.blocks);
|
|
219
|
+
await this.handleLatestL2Blocks(event.blocks.map(b => b.block.toL2Block()));
|
|
221
220
|
break;
|
|
222
221
|
case 'chain-finalized': {
|
|
223
222
|
// TODO (alexg): I think we can prune the block hashes map here
|
|
@@ -225,7 +224,8 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
225
224
|
const from = BlockNumber((await this.getSyncedFinalizedBlockNum()) + 1);
|
|
226
225
|
const limit = event.block.number - from + 1;
|
|
227
226
|
if (limit > 0) {
|
|
228
|
-
|
|
227
|
+
const oldBlocks = await this.l2BlockSource.getBlocks(from, limit);
|
|
228
|
+
await this.handleFinalizedL2Blocks(oldBlocks.map(b => b.toL2Block()));
|
|
229
229
|
}
|
|
230
230
|
break;
|
|
231
231
|
}
|
|
@@ -282,10 +282,7 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
282
282
|
const syncedProvenBlock = (await this.getSyncedProvenBlockNum()) + 1;
|
|
283
283
|
const syncedFinalizedBlock = (await this.getSyncedFinalizedBlockNum()) + 1;
|
|
284
284
|
|
|
285
|
-
if (
|
|
286
|
-
(await this.txPool.isEmpty()) &&
|
|
287
|
-
(this.attestationPool === undefined || (await this.attestationPool?.isEmpty()))
|
|
288
|
-
) {
|
|
285
|
+
if ((await this.txPool.isEmpty()) && (await this.attestationPool.isEmpty())) {
|
|
289
286
|
// if mempools are empty, we don't care about syncing prior blocks
|
|
290
287
|
this.initBlockStream(BlockNumber(this.latestBlockNumberAtStart));
|
|
291
288
|
this.setCurrentState(P2PClientState.RUNNING);
|
|
@@ -389,19 +386,17 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
389
386
|
}
|
|
390
387
|
|
|
391
388
|
public async getAttestationsForSlot(slot: SlotNumber, proposalId?: string): Promise<BlockAttestation[]> {
|
|
392
|
-
return (
|
|
393
|
-
(
|
|
394
|
-
|
|
395
|
-
: this.attestationPool?.getAttestationsForSlot(slot))) ?? []
|
|
396
|
-
);
|
|
389
|
+
return await (proposalId
|
|
390
|
+
? this.attestationPool.getAttestationsForSlotAndProposal(slot, proposalId)
|
|
391
|
+
: this.attestationPool.getAttestationsForSlot(slot));
|
|
397
392
|
}
|
|
398
393
|
|
|
399
394
|
public addAttestations(attestations: BlockAttestation[]): Promise<void> {
|
|
400
|
-
return this.attestationPool
|
|
395
|
+
return this.attestationPool.addAttestations(attestations);
|
|
401
396
|
}
|
|
402
397
|
|
|
403
398
|
public deleteAttestation(attestation: BlockAttestation): Promise<void> {
|
|
404
|
-
return this.attestationPool
|
|
399
|
+
return this.attestationPool.deleteAttestations([attestation]);
|
|
405
400
|
}
|
|
406
401
|
|
|
407
402
|
// REVIEW: https://github.com/AztecProtocol/aztec-packages/issues/7963
|
|
@@ -697,10 +692,10 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
697
692
|
* @param blocks - A list of existing blocks with txs that the P2P client needs to ensure the tx pool is reconciled with.
|
|
698
693
|
* @returns Empty promise.
|
|
699
694
|
*/
|
|
700
|
-
private async markTxsAsMinedFromBlocks(blocks:
|
|
695
|
+
private async markTxsAsMinedFromBlocks(blocks: L2BlockNew[]): Promise<void> {
|
|
701
696
|
for (const block of blocks) {
|
|
702
697
|
const txHashes = block.body.txEffects.map(txEffect => txEffect.txHash);
|
|
703
|
-
await this.txPool.markAsMined(txHashes, block.
|
|
698
|
+
await this.txPool.markAsMined(txHashes, block.header);
|
|
704
699
|
}
|
|
705
700
|
}
|
|
706
701
|
|
|
@@ -709,21 +704,22 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
709
704
|
* @param blocks - A list of existing blocks with txs that the P2P client needs to ensure the tx pool is reconciled with.
|
|
710
705
|
* @returns Empty promise.
|
|
711
706
|
*/
|
|
712
|
-
private async handleLatestL2Blocks(blocks:
|
|
707
|
+
private async handleLatestL2Blocks(blocks: L2BlockNew[]): Promise<void> {
|
|
713
708
|
if (!blocks.length) {
|
|
714
709
|
return Promise.resolve();
|
|
715
710
|
}
|
|
716
711
|
|
|
717
|
-
await this.markTxsAsMinedFromBlocks(blocks
|
|
718
|
-
await this.
|
|
712
|
+
await this.markTxsAsMinedFromBlocks(blocks);
|
|
713
|
+
await this.txPool.clearNonEvictableTxs();
|
|
714
|
+
await this.startCollectingMissingTxs(blocks);
|
|
719
715
|
|
|
720
|
-
const lastBlock = blocks.at(-1)
|
|
716
|
+
const lastBlock = blocks.at(-1)!;
|
|
721
717
|
|
|
722
718
|
await Promise.all(
|
|
723
719
|
blocks.map(async block =>
|
|
724
720
|
this.setBlockHash({
|
|
725
|
-
number: block.
|
|
726
|
-
hash: await block.
|
|
721
|
+
number: block.number,
|
|
722
|
+
hash: await block.hash().then(h => h.toString()),
|
|
727
723
|
}),
|
|
728
724
|
),
|
|
729
725
|
);
|
|
@@ -735,7 +731,7 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
735
731
|
}
|
|
736
732
|
|
|
737
733
|
/** Request txs for unproven blocks so the prover node has more chances to get them. */
|
|
738
|
-
private async startCollectingMissingTxs(blocks:
|
|
734
|
+
private async startCollectingMissingTxs(blocks: L2BlockNew[]): Promise<void> {
|
|
739
735
|
try {
|
|
740
736
|
// TODO(#15435): If the archiver has lagged behind L1, the reported proven block number may
|
|
741
737
|
// be much lower than the actual one, and it does not update until the pending chain is
|
|
@@ -768,7 +764,7 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
768
764
|
* @param blocks - A list of finalized L2 blocks.
|
|
769
765
|
* @returns Empty promise.
|
|
770
766
|
*/
|
|
771
|
-
private async handleFinalizedL2Blocks(blocks:
|
|
767
|
+
private async handleFinalizedL2Blocks(blocks: L2BlockNew[]): Promise<void> {
|
|
772
768
|
if (!blocks.length) {
|
|
773
769
|
return Promise.resolve();
|
|
774
770
|
}
|
|
@@ -782,7 +778,7 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
782
778
|
await this.txPool.deleteTxs(txHashes, { permanently: true });
|
|
783
779
|
await this.txPool.cleanupDeletedMinedTxs(lastBlockNum);
|
|
784
780
|
|
|
785
|
-
await this.attestationPool
|
|
781
|
+
await this.attestationPool.deleteAttestationsOlderThan(lastBlockSlot);
|
|
786
782
|
|
|
787
783
|
await this.synchedFinalizedBlockNumber.set(lastBlockNum);
|
|
788
784
|
this.log.debug(`Synched to finalized block ${lastBlockNum} at slot ${lastBlockSlot}`);
|
|
@@ -833,8 +829,7 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
833
829
|
this.log.info(`Deleting ${minedTxsFromReorg.length} mined txs from reorg`);
|
|
834
830
|
await this.txPool.deleteTxs(minedTxsFromReorg);
|
|
835
831
|
} else {
|
|
836
|
-
this.
|
|
837
|
-
await this.txPool.markMinedAsPending(minedTxsFromReorg);
|
|
832
|
+
await this.txPool.markMinedAsPending(minedTxsFromReorg, latestBlock);
|
|
838
833
|
}
|
|
839
834
|
|
|
840
835
|
await this.synchedLatestBlockNumber.set(latestBlock);
|
package/src/config.ts
CHANGED
|
@@ -9,9 +9,9 @@ import {
|
|
|
9
9
|
pickConfigMappings,
|
|
10
10
|
secretStringConfigHelper,
|
|
11
11
|
} from '@aztec/foundation/config';
|
|
12
|
-
import { Fr } from '@aztec/foundation/
|
|
12
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
13
13
|
import { type DataStoreConfig, dataConfigMappings } from '@aztec/kv-store/config';
|
|
14
|
-
import { FunctionSelector } from '@aztec/stdlib/abi';
|
|
14
|
+
import { FunctionSelector } from '@aztec/stdlib/abi/function-selector';
|
|
15
15
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
16
16
|
import { type AllowedElement, type ChainConfig, chainConfigMappings } from '@aztec/stdlib/config';
|
|
17
17
|
|
|
@@ -133,11 +133,8 @@ export interface P2PConfig extends P2PReqRespConfig, ChainConfig, TxCollectionCo
|
|
|
133
133
|
/** Which calls are allowed in the public setup phase of a tx. */
|
|
134
134
|
txPublicSetupAllowList: AllowedElement[];
|
|
135
135
|
|
|
136
|
-
/** The maximum
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
/** If the pool is full, it will still accept a few more txs until it reached maxTxPoolOverspillFactor * maxTxPoolSize. Then it will evict */
|
|
140
|
-
txPoolOverflowFactor: number;
|
|
136
|
+
/** The maximum number of pending txs before evicting lower priority txs. */
|
|
137
|
+
maxPendingTxCount: number;
|
|
141
138
|
|
|
142
139
|
/** The node's seen message ID cache size */
|
|
143
140
|
seenMessageCacheSize: number;
|
|
@@ -375,15 +372,12 @@ export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
|
|
|
375
372
|
printDefault: () =>
|
|
376
373
|
'AuthRegistry, FeeJuice.increase_public_balance, Token.increase_public_balance, FPC.prepare_fee',
|
|
377
374
|
},
|
|
378
|
-
|
|
379
|
-
env: '
|
|
380
|
-
description: 'The maximum
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
env: 'P2P_TX_POOL_OVERFLOW_FACTOR',
|
|
385
|
-
description: 'How much the tx pool can overflow before it starts evicting txs. Must be greater than 1',
|
|
386
|
-
...floatConfigHelper(1.1), // 10% overflow
|
|
375
|
+
maxPendingTxCount: {
|
|
376
|
+
env: 'P2P_MAX_PENDING_TX_COUNT',
|
|
377
|
+
description: 'The maximum number of pending txs before evicting lower priority txs.',
|
|
378
|
+
// Worst case scenario: Uncompressed public/private tx is ~ 156kb
|
|
379
|
+
// This implies we are using ~156MB of memory for pending pool
|
|
380
|
+
...numberConfigHelper(1_000),
|
|
387
381
|
},
|
|
388
382
|
seenMessageCacheSize: {
|
|
389
383
|
env: 'P2P_SEEN_MSG_CACHE_SIZE',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SlotNumber } from '@aztec/foundation/branded-types';
|
|
2
|
-
import { Secp256k1Signer } from '@aztec/foundation/crypto';
|
|
3
|
-
import { Fr } from '@aztec/foundation/
|
|
2
|
+
import { Secp256k1Signer } from '@aztec/foundation/crypto/secp256k1-signer';
|
|
3
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
4
|
import type { BlockAttestation, BlockProposal } from '@aztec/stdlib/p2p';
|
|
5
5
|
import {
|
|
6
6
|
BlockProposal as BlockProposalClass,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SlotNumber } from '@aztec/foundation/branded-types';
|
|
2
|
-
import { Fr } from '@aztec/foundation/
|
|
2
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
3
|
import { toArray } from '@aztec/foundation/iterable';
|
|
4
4
|
import { createLogger } from '@aztec/foundation/log';
|
|
5
5
|
import type { AztecAsyncKVStore, AztecAsyncMap, AztecAsyncMultiMap } from '@aztec/kv-store';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Secp256k1Signer } from '@aztec/foundation/crypto';
|
|
2
|
-
import { Fr } from '@aztec/foundation/
|
|
1
|
+
import type { Secp256k1Signer } from '@aztec/foundation/crypto/secp256k1-signer';
|
|
2
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
3
|
import {
|
|
4
4
|
BlockAttestation,
|
|
5
5
|
ConsensusPayload,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Gossipable } from '@aztec/stdlib/p2p';
|
|
2
|
+
import type { Tx } from '@aztec/stdlib/tx';
|
|
2
3
|
import {
|
|
3
4
|
Attributes,
|
|
4
5
|
type BatchObservableResult,
|
|
@@ -22,6 +23,7 @@ type MetricsLabels = {
|
|
|
22
23
|
objectInMempool: MetricsType;
|
|
23
24
|
objectSize: MetricsType;
|
|
24
25
|
itemsAdded: MetricsType;
|
|
26
|
+
itemMinedDelay: MetricsType;
|
|
25
27
|
};
|
|
26
28
|
|
|
27
29
|
/**
|
|
@@ -35,12 +37,14 @@ function getMetricsLabels(name: PoolName): MetricsLabels {
|
|
|
35
37
|
objectInMempool: Metrics.MEMPOOL_TX_COUNT,
|
|
36
38
|
objectSize: Metrics.MEMPOOL_TX_SIZE,
|
|
37
39
|
itemsAdded: Metrics.MEMPOOL_TX_ADDED_COUNT,
|
|
40
|
+
itemMinedDelay: Metrics.MEMPOOL_TX_MINED_DELAY,
|
|
38
41
|
};
|
|
39
42
|
} else if (name === PoolName.ATTESTATION_POOL) {
|
|
40
43
|
return {
|
|
41
44
|
objectInMempool: Metrics.MEMPOOL_ATTESTATIONS_COUNT,
|
|
42
45
|
objectSize: Metrics.MEMPOOL_ATTESTATIONS_SIZE,
|
|
43
46
|
itemsAdded: Metrics.MEMPOOL_ATTESTATIONS_ADDED_COUNT,
|
|
47
|
+
itemMinedDelay: Metrics.MEMPOOL_ATTESTATIONS_MINED_DELAY,
|
|
44
48
|
};
|
|
45
49
|
}
|
|
46
50
|
|
|
@@ -60,12 +64,16 @@ export class PoolInstrumentation<PoolObject extends Gossipable> {
|
|
|
60
64
|
private addObjectCounter: UpDownCounter;
|
|
61
65
|
/** Tracks tx size */
|
|
62
66
|
private objectSize: Histogram;
|
|
67
|
+
/** Track delay between transaction added and evicted */
|
|
68
|
+
private minedDelay: Histogram;
|
|
63
69
|
|
|
64
70
|
private dbMetrics: LmdbMetrics;
|
|
65
71
|
|
|
66
72
|
private defaultAttributes;
|
|
67
73
|
private meter: Meter;
|
|
68
74
|
|
|
75
|
+
private txAddedTimestamp: Map<bigint, number> = new Map<bigint, number>();
|
|
76
|
+
|
|
69
77
|
constructor(
|
|
70
78
|
telemetry: TelemetryClient,
|
|
71
79
|
name: PoolName,
|
|
@@ -98,6 +106,10 @@ export class PoolInstrumentation<PoolObject extends Gossipable> {
|
|
|
98
106
|
description: 'The number of transactions added to the mempool',
|
|
99
107
|
});
|
|
100
108
|
|
|
109
|
+
this.minedDelay = this.meter.createHistogram(metricsLabels.itemMinedDelay, {
|
|
110
|
+
description: 'Delay between transaction added and evicted from the mempool',
|
|
111
|
+
});
|
|
112
|
+
|
|
101
113
|
this.meter.addBatchObservableCallback(this.observeStats, [this.objectsInMempool]);
|
|
102
114
|
}
|
|
103
115
|
|
|
@@ -109,6 +121,27 @@ export class PoolInstrumentation<PoolObject extends Gossipable> {
|
|
|
109
121
|
this.addObjectCounter.add(count);
|
|
110
122
|
}
|
|
111
123
|
|
|
124
|
+
public transactionsAdded(transactions: Tx[]) {
|
|
125
|
+
const timestamp = Date.now();
|
|
126
|
+
for (const transaction of transactions) {
|
|
127
|
+
this.txAddedTimestamp.set(transaction.txHash.toBigInt(), timestamp);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
public transactionsRemoved(hashes: Iterable<bigint> | Iterable<string>) {
|
|
132
|
+
const timestamp = Date.now();
|
|
133
|
+
for (const hash of hashes) {
|
|
134
|
+
const key = BigInt(hash);
|
|
135
|
+
const addedAt = this.txAddedTimestamp.get(key);
|
|
136
|
+
if (addedAt !== undefined) {
|
|
137
|
+
this.txAddedTimestamp.delete(key);
|
|
138
|
+
if (addedAt < timestamp) {
|
|
139
|
+
this.minedDelay.record(timestamp - addedAt);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
112
145
|
private observeStats = async (observer: BatchObservableResult) => {
|
|
113
146
|
const { itemCount } = await this.poolStats();
|
|
114
147
|
if (typeof itemCount === 'number') {
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import type { P2PClientType } from '@aztec/stdlib/p2p';
|
|
2
|
-
|
|
3
1
|
import type { AttestationPool } from './attestation_pool/attestation_pool.js';
|
|
4
2
|
import type { TxPool } from './tx_pool/tx_pool.js';
|
|
5
3
|
|
|
6
4
|
/**
|
|
7
5
|
* A interface the combines all mempools
|
|
8
6
|
*/
|
|
9
|
-
export type MemPools
|
|
7
|
+
export type MemPools = {
|
|
10
8
|
txPool: TxPool;
|
|
11
|
-
attestationPool
|
|
9
|
+
attestationPool: AttestationPool;
|
|
12
10
|
};
|