@aztec/p2p 1.0.0-staging.2 → 1.0.0
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.js +1 -1
- package/dest/client/factory.js +1 -1
- package/dest/client/p2p_client.js +1 -1
- package/dest/config.d.ts +2 -2
- package/dest/config.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts +4 -11
- 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 +10 -17
- package/dest/mem_pools/tx_pool/memory_tx_pool.d.ts +2 -2
- package/dest/mem_pools/tx_pool/memory_tx_pool.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/memory_tx_pool.js +2 -2
- package/dest/mem_pools/tx_pool/tx_pool.d.ts +2 -3
- 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.map +1 -1
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.js +3 -10
- package/dest/msg_validators/tx_validator/factory.d.ts +1 -2
- package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/factory.js +2 -3
- package/dest/msg_validators/tx_validator/metadata_validator.d.ts +0 -2
- package/dest/msg_validators/tx_validator/metadata_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/metadata_validator.js +7 -13
- package/dest/msg_validators/tx_validator/phases_validator.d.ts +2 -3
- package/dest/msg_validators/tx_validator/phases_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/phases_validator.js +4 -4
- package/dest/services/libp2p/instrumentation.d.ts +1 -8
- package/dest/services/libp2p/instrumentation.d.ts.map +1 -1
- package/dest/services/libp2p/instrumentation.js +2 -130
- package/dest/services/libp2p/libp2p_service.d.ts +3 -8
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +14 -34
- 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/reqresp-nodes.d.ts.map +1 -1
- package/dest/test-helpers/reqresp-nodes.js +2 -3
- package/dest/testbench/p2p_client_testbench_worker.js +0 -6
- package/dest/testbench/worker_client_manager.d.ts.map +1 -1
- package/dest/testbench/worker_client_manager.js +1 -2
- package/dest/util.d.ts +2 -3
- package/dest/util.d.ts.map +1 -1
- package/dest/util.js +5 -6
- package/package.json +13 -13
- package/src/bootstrap/bootstrap.ts +1 -1
- package/src/client/factory.ts +1 -1
- package/src/client/p2p_client.ts +1 -1
- package/src/config.ts +1 -2
- package/src/mem_pools/tx_pool/aztec_kv_tx_pool.ts +12 -22
- package/src/mem_pools/tx_pool/memory_tx_pool.ts +3 -3
- package/src/mem_pools/tx_pool/tx_pool.ts +2 -3
- package/src/mem_pools/tx_pool/tx_pool_test_suite.ts +4 -8
- package/src/msg_validators/tx_validator/factory.ts +1 -4
- package/src/msg_validators/tx_validator/metadata_validator.ts +9 -20
- package/src/msg_validators/tx_validator/phases_validator.ts +2 -3
- package/src/services/libp2p/instrumentation.ts +3 -122
- package/src/services/libp2p/libp2p_service.ts +15 -41
- package/src/test-helpers/make-test-p2p-clients.ts +1 -2
- package/src/test-helpers/reqresp-nodes.ts +2 -3
- package/src/testbench/p2p_client_testbench_worker.ts +0 -1
- package/src/testbench/worker_client_manager.ts +1 -2
- package/src/util.ts +7 -8
|
@@ -33,7 +33,7 @@ import { convertToMultiaddr, getPeerIdPrivateKey } from '../util.js';
|
|
|
33
33
|
}
|
|
34
34
|
const listenAddrUdp = multiaddr(convertToMultiaddr(listenAddress, config.p2pBroadcastPort, 'udp'));
|
|
35
35
|
const peerIdPrivateKey = await getPeerIdPrivateKey(config, this.store, this.logger);
|
|
36
|
-
const { enr: ourEnr, peerId } = await createBootnodeENRandPeerId(peerIdPrivateKey
|
|
36
|
+
const { enr: ourEnr, peerId } = await createBootnodeENRandPeerId(peerIdPrivateKey, p2pIp, config.p2pBroadcastPort, config.l1ChainId);
|
|
37
37
|
this.peerId = peerId;
|
|
38
38
|
this.logger.debug(`Starting bootstrap node ${peerId} listening on ${listenAddrUdp.toString()}`);
|
|
39
39
|
const metricsRegistry = new OtelMetricsAdapter(this.telemetry);
|
package/dest/client/factory.js
CHANGED
|
@@ -35,7 +35,7 @@ export const createP2PClient = async (clientType, _config, archiver, proofVerifi
|
|
|
35
35
|
config = await configureP2PClientAddresses(_config);
|
|
36
36
|
// Create peer discovery service
|
|
37
37
|
const peerIdPrivateKey = await getPeerIdPrivateKey(config, store, logger);
|
|
38
|
-
const peerId = await createLibP2PPeerIdFromPrivateKey(peerIdPrivateKey
|
|
38
|
+
const peerId = await createLibP2PPeerIdFromPrivateKey(peerIdPrivateKey);
|
|
39
39
|
const p2pService = await (deps.p2pServiceFactory ?? LibP2PService.new)(clientType, config, peerId, {
|
|
40
40
|
packageVersion,
|
|
41
41
|
mempools,
|
|
@@ -518,7 +518,7 @@ import { P2PClientState } from './interface.js';
|
|
|
518
518
|
*/ async markTxsAsMinedFromBlocks(blocks) {
|
|
519
519
|
for (const block of blocks){
|
|
520
520
|
const txHashes = block.body.txEffects.map((txEffect)=>txEffect.txHash);
|
|
521
|
-
await this.txPool.markAsMined(txHashes, block.
|
|
521
|
+
await this.txPool.markAsMined(txHashes, block.number);
|
|
522
522
|
}
|
|
523
523
|
}
|
|
524
524
|
/**
|
package/dest/config.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ConfigMappingsType
|
|
1
|
+
import { type ConfigMappingsType } from '@aztec/foundation/config';
|
|
2
2
|
import { type DataStoreConfig } from '@aztec/kv-store/config';
|
|
3
3
|
import { type AllowedElement, type ChainConfig } from '@aztec/stdlib/config';
|
|
4
4
|
import { type P2PReqRespConfig } from './services/reqresp/config.js';
|
|
@@ -27,7 +27,7 @@ export interface P2PConfig extends P2PReqRespConfig, ChainConfig {
|
|
|
27
27
|
/** The listen address. */
|
|
28
28
|
listenAddress: string;
|
|
29
29
|
/** An optional peer id private key. If blank, will generate a random key. */
|
|
30
|
-
peerIdPrivateKey?:
|
|
30
|
+
peerIdPrivateKey?: string;
|
|
31
31
|
/** An optional path to store generated peer id private keys. If blank, will default to storing any generated keys in the data directory. */
|
|
32
32
|
peerIdPrivateKeyPath?: string;
|
|
33
33
|
/** A list of bootstrap peers to connect to. */
|
package/dest/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,kBAAkB,
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,kBAAkB,EAQxB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,KAAK,eAAe,EAAsB,MAAM,wBAAwB,CAAC;AAGlF,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,WAAW,EAAuB,MAAM,sBAAsB,CAAC;AAElG,OAAO,EAAE,KAAK,gBAAgB,EAA4B,MAAM,8BAA8B,CAAC;AAE/F;;GAEG;AACH,MAAM,WAAW,SAAU,SAAQ,gBAAgB,EAAE,WAAW;IAC9D,oEAAoE;IACpE,UAAU,EAAE,OAAO,CAAC;IAEpB,yDAAyD;IACzD,oBAAoB,EAAE,MAAM,CAAC;IAE7B,uDAAuD;IACvD,qBAAqB,EAAE,MAAM,CAAC;IAE9B,oEAAoE;IACpE,6BAA6B,EAAE,OAAO,CAAC;IAEvC,qDAAqD;IACrD,mBAAmB,EAAE,MAAM,CAAC;IAE5B,2CAA2C;IAC3C,WAAW,EAAE,MAAM,CAAC;IAEpB,oCAAoC;IACpC,OAAO,EAAE,MAAM,CAAC;IAEhB,6EAA6E;IAC7E,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B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/B,YAAY,EAAE,MAAM,EAAE,CAAC;IAEvB,gGAAgG;IAChG,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAE3B,iEAAiE;IACjE,sBAAsB,EAAE,cAAc,EAAE,CAAC;IAEzC,mGAAmG;IACnG,aAAa,EAAE,MAAM,CAAC;IAEtB,6IAA6I;IAC7I,oBAAoB,EAAE,MAAM,CAAC;IAE7B,4CAA4C;IAC5C,oBAAoB,EAAE,MAAM,CAAC;IAE7B,8DAA8D;IAC9D,yBAAyB,CAAC,EAAE,OAAO,CAAC;CACrC;AAED,eAAO,MAAM,gBAAgB,QAAQ,CAAC;AAEtC,eAAO,MAAM,iBAAiB,EAAE,kBAAkB,CAAC,SAAS,CAmN3D,CAAC;AAEF;;;GAGG;AACH,wBAAgB,mBAAmB,IAAI,SAAS,CAE/C;AAED,wBAAgB,mBAAmB,IAAI,SAAS,CAE/C;AAED;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,IAAI,CAC/B,SAAS,EACP,OAAO,GACP,SAAS,GACT,kBAAkB,GAClB,kBAAkB,GAClB,sBAAsB,GACtB,gBAAgB,GAChB,eAAe,CAClB,GACC,QAAQ,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,GAAG,SAAS,CAAC,CAAC,GAC9C,IAAI,CAAC,eAAe,EAAE,eAAe,GAAG,oBAAoB,CAAC,GAC7D,IAAI,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;AAejC,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uLAGlC,CAAC;AAEF;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,cAAc,EAAE,CAqC9D"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type Logger } from '@aztec/foundation/log';
|
|
2
2
|
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
3
3
|
import type { MerkleTreeReadOperations, WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
|
|
4
|
-
import {
|
|
4
|
+
import { Tx, TxHash } from '@aztec/stdlib/tx';
|
|
5
5
|
import { type TelemetryClient } from '@aztec/telemetry-client';
|
|
6
6
|
import { ArchiveCache } from '../../msg_validators/tx_validator/archive_cache.js';
|
|
7
7
|
import { GasTxValidator } from '../../msg_validators/tx_validator/gas_validator.js';
|
|
@@ -24,14 +24,7 @@ export declare class AztecKVTxPool implements TxPool {
|
|
|
24
24
|
constructor(store: AztecAsyncKVStore, archive: AztecAsyncKVStore, worldStateSynchronizer: WorldStateSynchronizer, telemetry?: TelemetryClient, config?: TxPoolOptions, log?: Logger);
|
|
25
25
|
private countTxs;
|
|
26
26
|
isEmpty(): Promise<boolean>;
|
|
27
|
-
|
|
28
|
-
* Marks transactions as mined in a block and updates the pool state accordingly.
|
|
29
|
-
* Removes the transactions from the pending set and adds them to the mined set.
|
|
30
|
-
* Also evicts any transactions that become invalid after the block is mined.
|
|
31
|
-
* @param txHashes - Array of transaction hashes that were mined
|
|
32
|
-
* @param blockHeader - The header of the block the transactions were mined in
|
|
33
|
-
*/
|
|
34
|
-
markAsMined(txHashes: TxHash[], blockHeader: BlockHeader): Promise<void>;
|
|
27
|
+
markAsMined(txHashes: TxHash[], blockNumber: number): Promise<void>;
|
|
35
28
|
markMinedAsPending(txHashes: TxHash[]): Promise<void>;
|
|
36
29
|
getPendingTxHashes(): Promise<TxHash[]>;
|
|
37
30
|
getMinedTxHashes(): Promise<[TxHash, number][]>;
|
|
@@ -114,10 +107,10 @@ export declare class AztecKVTxPool implements TxPool {
|
|
|
114
107
|
* Eviction criteria includes:
|
|
115
108
|
* - txs with nullifiers that are already included in the mined block
|
|
116
109
|
* - txs with an insufficient fee payer balance
|
|
117
|
-
* - txs with
|
|
110
|
+
* - txs with a max block number lower than the mined block
|
|
118
111
|
*
|
|
119
112
|
* @param minedTxHashes - The tx hashes of the txs mined in the block.
|
|
120
|
-
* @param
|
|
113
|
+
* @param blockNumber - The block number of the mined block.
|
|
121
114
|
* @returns The total number of txs evicted from the pool.
|
|
122
115
|
*/
|
|
123
116
|
private evictInvalidTxsAfterMining;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aztec_kv_tx_pool.d.ts","sourceRoot":"","sources":["../../../src/mem_pools/tx_pool/aztec_kv_tx_pool.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAClE,OAAO,KAAK,EAAE,iBAAiB,EAA0D,MAAM,iBAAiB,CAAC;AAGjH,OAAO,KAAK,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAIxG,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"aztec_kv_tx_pool.d.ts","sourceRoot":"","sources":["../../../src/mem_pools/tx_pool/aztec_kv_tx_pool.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAClE,OAAO,KAAK,EAAE,iBAAiB,EAA0D,MAAM,iBAAiB,CAAC;AAGjH,OAAO,KAAK,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAIxG,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,KAAK,eAAe,EAAsB,MAAM,yBAAyB,CAAC;AAInF,OAAO,EAAE,YAAY,EAAE,MAAM,oDAAoD,CAAC;AAClF,OAAO,EAAE,cAAc,EAAE,MAAM,oDAAoD,CAAC;AAGpF,OAAO,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE1D;;GAEG;AACH,qBAAa,aAAc,YAAW,MAAM;;IAS1C,0GAA0G;IAC1G,oBAAoB,EAAE,MAAM,CAAK;IA0CjC;;;;;;;OAOG;gBAED,KAAK,EAAE,iBAAiB,EACxB,OAAO,EAAE,iBAAiB,EAC1B,sBAAsB,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AGG;IACU,SAAS,IAAI,OAAO,CAAC,EAAE,EAAE,CAAC;IASvC;;;OAGG;IACU,cAAc,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAKzC,YAAY,CAAC,EAAE,aAAa,EAAE,oBAAoB,EAAE,eAAe,EAAE,EAAE,aAAa,GAAG,IAAI;IAwB3F,qBAAqB,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAK/D;;;;OAIG;IACH,SAAS,CAAC,oBAAoB,CAAC,EAAE,EAAE,wBAAwB,GAAG,cAAc;IAI5E;;;;OAIG;IACH,SAAS,CAAC,kBAAkB,CAAC,EAAE,EAAE,wBAAwB,GAAG,YAAY;IAIxE;;;;;OAKG;YACW,kBAAkB;IAoBhC;;;;OAIG;YACW,UAAU;IAiCxB;;;;;;OAMG;YACW,mBAAmB;IA8CjC;;;;;;;;;;OAUG;YACW,0BAA0B;IAwDxC;;;;;OAKG;YACW,yBAAyB;YAqCzB,mBAAmB;YAMnB,sBAAsB;CAMrC"}
|
|
@@ -76,13 +76,7 @@ import { getPendingTxPriority } from './priority.js';
|
|
|
76
76
|
}
|
|
77
77
|
return true;
|
|
78
78
|
}
|
|
79
|
-
|
|
80
|
-
* Marks transactions as mined in a block and updates the pool state accordingly.
|
|
81
|
-
* Removes the transactions from the pending set and adds them to the mined set.
|
|
82
|
-
* Also evicts any transactions that become invalid after the block is mined.
|
|
83
|
-
* @param txHashes - Array of transaction hashes that were mined
|
|
84
|
-
* @param blockHeader - The header of the block the transactions were mined in
|
|
85
|
-
*/ async markAsMined(txHashes, blockHeader) {
|
|
79
|
+
async markAsMined(txHashes, blockNumber) {
|
|
86
80
|
if (txHashes.length === 0) {
|
|
87
81
|
return Promise.resolve();
|
|
88
82
|
}
|
|
@@ -92,7 +86,7 @@ import { getPendingTxPriority } from './priority.js';
|
|
|
92
86
|
let pendingTxSize = await this.#pendingTxSize.getAsync() ?? 0;
|
|
93
87
|
for (const hash of txHashes){
|
|
94
88
|
const key = hash.toString();
|
|
95
|
-
await this.#minedTxHashToBlock.set(key,
|
|
89
|
+
await this.#minedTxHashToBlock.set(key, blockNumber);
|
|
96
90
|
const tx = await this.getPendingTxByHash(hash);
|
|
97
91
|
if (tx) {
|
|
98
92
|
const nullifiers = tx.data.getNonEmptyNullifiers();
|
|
@@ -103,7 +97,7 @@ import { getPendingTxPriority } from './priority.js';
|
|
|
103
97
|
}
|
|
104
98
|
}
|
|
105
99
|
await this.#pendingTxSize.set(pendingTxSize);
|
|
106
|
-
await this.evictInvalidTxsAfterMining(txHashes,
|
|
100
|
+
await this.evictInvalidTxsAfterMining(txHashes, blockNumber, minedNullifiers, minedFeePayers);
|
|
107
101
|
});
|
|
108
102
|
// We update this after the transaction above. This ensures that the non-evictable transactions are not evicted
|
|
109
103
|
// until any that have been mined are marked as such.
|
|
@@ -434,16 +428,15 @@ import { getPendingTxPriority } from './priority.js';
|
|
|
434
428
|
* Eviction criteria includes:
|
|
435
429
|
* - txs with nullifiers that are already included in the mined block
|
|
436
430
|
* - txs with an insufficient fee payer balance
|
|
437
|
-
* - txs with
|
|
431
|
+
* - txs with a max block number lower than the mined block
|
|
438
432
|
*
|
|
439
433
|
* @param minedTxHashes - The tx hashes of the txs mined in the block.
|
|
440
|
-
* @param
|
|
434
|
+
* @param blockNumber - The block number of the mined block.
|
|
441
435
|
* @returns The total number of txs evicted from the pool.
|
|
442
|
-
*/ async evictInvalidTxsAfterMining(minedTxHashes,
|
|
436
|
+
*/ async evictInvalidTxsAfterMining(minedTxHashes, blockNumber, minedNullifiers, minedFeePayers) {
|
|
443
437
|
if (minedTxHashes.length === 0) {
|
|
444
438
|
return 0;
|
|
445
439
|
}
|
|
446
|
-
const { blockNumber, timestamp } = blockHeader.globalVariables;
|
|
447
440
|
// Wait for world state to be synced to at least the mined block number
|
|
448
441
|
await this.#worldStateSynchronizer.syncImmediate(blockNumber);
|
|
449
442
|
const db = this.#worldStateSynchronizer.getCommitted();
|
|
@@ -467,10 +460,10 @@ import { getPendingTxPriority } from './priority.js';
|
|
|
467
460
|
txsToEvict.push(TxHash.fromString(txHash));
|
|
468
461
|
continue;
|
|
469
462
|
}
|
|
470
|
-
// Evict pending txs with
|
|
471
|
-
const
|
|
472
|
-
if (
|
|
473
|
-
this.#log.verbose(`Evicting tx ${txHash} from pool due to
|
|
463
|
+
// Evict pending txs with a max block number less than or equal to the mined block
|
|
464
|
+
const maxBlockNumber = tx.data.rollupValidationRequests.maxBlockNumber;
|
|
465
|
+
if (maxBlockNumber.isSome && maxBlockNumber.value <= blockNumber) {
|
|
466
|
+
this.#log.verbose(`Evicting tx ${txHash} from pool due to an invalid max block number`);
|
|
474
467
|
txsToEvict.push(TxHash.fromString(txHash));
|
|
475
468
|
continue;
|
|
476
469
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Tx, TxHash } from '@aztec/stdlib/tx';
|
|
2
2
|
import { type TelemetryClient } from '@aztec/telemetry-client';
|
|
3
3
|
import type { TxPool, TxPoolOptions } from './tx_pool.js';
|
|
4
4
|
/**
|
|
@@ -20,7 +20,7 @@ export declare class InMemoryTxPool implements TxPool {
|
|
|
20
20
|
constructor(telemetry?: TelemetryClient, log?: import("@aztec/foundation/log").Logger);
|
|
21
21
|
private countTx;
|
|
22
22
|
isEmpty(): Promise<boolean>;
|
|
23
|
-
markAsMined(txHashes: TxHash[],
|
|
23
|
+
markAsMined(txHashes: TxHash[], blockNumber: number): Promise<void>;
|
|
24
24
|
markMinedAsPending(txHashes: TxHash[]): Promise<void>;
|
|
25
25
|
getPendingTxHashes(): Promise<TxHash[]>;
|
|
26
26
|
getMinedTxHashes(): Promise<[TxHash, number][]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory_tx_pool.d.ts","sourceRoot":"","sources":["../../../src/mem_pools/tx_pool/memory_tx_pool.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"memory_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S,CAAC,EAAE,CAAC;IAG7D,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAIvC,mBAAmB,IAAI,OAAO,CAAC,EAAE,GAAG,SAAS,CAAC;IAIrD;;;;OAIG;IACU,MAAM,CAAC,GAAG,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC;IAoB/C;;;;OAIG;IACI,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAWnD;;;OAGG;IACI,SAAS,IAAI,OAAO,CAAC,EAAE,EAAE,CAAC;IAIjC;;;OAGG;IACI,cAAc,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAI1C,YAAY,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI;IAE1C,qBAAqB,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAGlD"}
|
|
@@ -35,10 +35,10 @@ import { getPendingTxPriority } from './priority.js';
|
|
|
35
35
|
isEmpty() {
|
|
36
36
|
return Promise.resolve(this.txs.size === 0);
|
|
37
37
|
}
|
|
38
|
-
markAsMined(txHashes,
|
|
38
|
+
markAsMined(txHashes, blockNumber) {
|
|
39
39
|
const keys = txHashes.map((x)=>x.toBigInt());
|
|
40
40
|
for (const key of keys){
|
|
41
|
-
this.minedTxs.set(key,
|
|
41
|
+
this.minedTxs.set(key, blockNumber);
|
|
42
42
|
this.pendingTxs.delete(key);
|
|
43
43
|
}
|
|
44
44
|
return Promise.resolve();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Tx, TxHash } from '@aztec/stdlib/tx';
|
|
2
2
|
export type TxPoolOptions = {
|
|
3
3
|
maxTxPoolSize?: number;
|
|
4
4
|
txPoolOverflowFactor?: number;
|
|
@@ -41,9 +41,8 @@ export interface TxPool {
|
|
|
41
41
|
/**
|
|
42
42
|
* Marks the set of txs as mined, as opposed to pending.
|
|
43
43
|
* @param txHashes - Hashes of the txs to flag as mined.
|
|
44
|
-
* @param blockHeader - The header of the mined block.
|
|
45
44
|
*/
|
|
46
|
-
markAsMined(txHashes: TxHash[],
|
|
45
|
+
markAsMined(txHashes: TxHash[], blockNumber: number): Promise<void>;
|
|
47
46
|
/**
|
|
48
47
|
* Moves mined txs back to the pending set in the case of a reorg.
|
|
49
48
|
* Note: txs not known by this peer will be ignored.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tx_pool.d.ts","sourceRoot":"","sources":["../../../src/mem_pools/tx_pool/tx_pool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"tx_pool.d.ts","sourceRoot":"","sources":["../../../src/mem_pools/tx_pool/tx_pool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAEnD,MAAM,MAAM,aAAa,GAAG;IAC1B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,MAAM;IACrB;;;;OAIG;IACH,MAAM,CAAC,GAAG,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAEnC;;;;OAIG;IACH,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,EAAE,GAAG,SAAS,CAAC,CAAC;IAErD;;;;OAIG;IACH,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,CAAC,EAAE,GAAG,SAAS,CAAC,EAAE,CAAC,CAAC;IAE9D;;;;OAIG;IACH,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;IAE/C;;;;OAIG;IACH,mBAAmB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test_suite.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAE3C;;;GAGG;AACH,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"tx_pool_test_suite.d.ts","sourceRoot":"","sources":["../../../src/mem_pools/tx_pool/tx_pool_test_suite.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAE3C;;;GAGG;AACH,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,MAAM,QAuKrD"}
|
|
@@ -1,18 +1,11 @@
|
|
|
1
1
|
import { unfreeze } from '@aztec/foundation/types';
|
|
2
2
|
import { GasFees } from '@aztec/stdlib/gas';
|
|
3
3
|
import { mockTx } from '@aztec/stdlib/testing';
|
|
4
|
-
import { BlockHeader, GlobalVariables } from '@aztec/stdlib/tx';
|
|
5
4
|
/**
|
|
6
5
|
* Tests a TxPool implementation.
|
|
7
6
|
* @param getTxPool - Gets a fresh TxPool
|
|
8
7
|
*/ export function describeTxPool(getTxPool) {
|
|
9
8
|
let pool;
|
|
10
|
-
const minedBlockHeader = BlockHeader.empty({
|
|
11
|
-
globalVariables: GlobalVariables.empty({
|
|
12
|
-
blockNumber: 1,
|
|
13
|
-
timestamp: 0n
|
|
14
|
-
})
|
|
15
|
-
});
|
|
16
9
|
beforeEach(()=>{
|
|
17
10
|
pool = getTxPool();
|
|
18
11
|
});
|
|
@@ -50,7 +43,7 @@ import { BlockHeader, GlobalVariables } from '@aztec/stdlib/tx';
|
|
|
50
43
|
]);
|
|
51
44
|
await pool.markAsMined([
|
|
52
45
|
await tx1.getTxHash()
|
|
53
|
-
],
|
|
46
|
+
], 1);
|
|
54
47
|
await expect(pool.getTxByHash(await tx1.getTxHash())).resolves.toEqual(tx1);
|
|
55
48
|
await expect(pool.getTxStatus(await tx1.getTxHash())).resolves.toEqual('mined');
|
|
56
49
|
await expect(pool.getMinedTxHashes()).resolves.toEqual([
|
|
@@ -73,7 +66,7 @@ import { BlockHeader, GlobalVariables } from '@aztec/stdlib/tx';
|
|
|
73
66
|
]);
|
|
74
67
|
await pool.markAsMined([
|
|
75
68
|
await tx1.getTxHash()
|
|
76
|
-
],
|
|
69
|
+
], 1);
|
|
77
70
|
await pool.markMinedAsPending([
|
|
78
71
|
await tx1.getTxHash()
|
|
79
72
|
]);
|
|
@@ -98,7 +91,7 @@ import { BlockHeader, GlobalVariables } from '@aztec/stdlib/tx';
|
|
|
98
91
|
await pool.markAsMined([
|
|
99
92
|
await tx1.getTxHash(),
|
|
100
93
|
someTxHashThatThisPeerDidNotSee
|
|
101
|
-
],
|
|
94
|
+
], 1);
|
|
102
95
|
expect(await pool.getMinedTxHashes()).toEqual(expect.arrayContaining([
|
|
103
96
|
[
|
|
104
97
|
await tx1.getTxHash(),
|
|
@@ -4,12 +4,11 @@ import type { GasFees } from '@aztec/stdlib/gas';
|
|
|
4
4
|
import type { AllowedElement, ClientProtocolCircuitVerifier, WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
|
|
5
5
|
import { PeerErrorSeverity } from '@aztec/stdlib/p2p';
|
|
6
6
|
import type { Tx, TxValidationResult } from '@aztec/stdlib/tx';
|
|
7
|
-
import type { UInt64 } from '@aztec/stdlib/types';
|
|
8
7
|
export interface MessageValidator {
|
|
9
8
|
validator: {
|
|
10
9
|
validateTx(tx: Tx): Promise<TxValidationResult>;
|
|
11
10
|
};
|
|
12
11
|
severity: PeerErrorSeverity;
|
|
13
12
|
}
|
|
14
|
-
export declare function createTxMessageValidators(
|
|
13
|
+
export declare function createTxMessageValidators(blockNumber: number, worldStateSynchronizer: WorldStateSynchronizer, gasFees: GasFees, l1ChainId: number, rollupVersion: number, protocolContractTreeRoot: Fr, contractDataSource: ContractDataSource, proofVerifier: ClientProtocolCircuitVerifier, allowedInSetup?: AllowedElement[]): Record<string, MessageValidator>[];
|
|
15
14
|
//# sourceMappingURL=factory.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../src/msg_validators/tx_validator/factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAG9C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,KAAK,EACV,cAAc,EACd,6BAA6B,EAC7B,sBAAsB,EACvB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEtD,OAAO,KAAK,EAAE,EAAE,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../src/msg_validators/tx_validator/factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAG9C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,KAAK,EACV,cAAc,EACd,6BAA6B,EAC7B,sBAAsB,EACvB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEtD,OAAO,KAAK,EAAE,EAAE,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAW/D,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE;QACT,UAAU,CAAC,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;KACjD,CAAC;IACF,QAAQ,EAAE,iBAAiB,CAAC;CAC7B;AAED,wBAAgB,yBAAyB,CACvC,WAAW,EAAE,MAAM,EACnB,sBAAsB,EAAE,sBAAsB,EAC9C,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,MAAM,EACjB,aAAa,EAAE,MAAM,EACrB,wBAAwB,EAAE,EAAE,EAC5B,kBAAkB,EAAE,kBAAkB,EACtC,aAAa,EAAE,6BAA6B,EAC5C,cAAc,GAAE,cAAc,EAAO,GACpC,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,EAAE,CAqDpC"}
|
|
@@ -11,7 +11,7 @@ import { GasTxValidator } from './gas_validator.js';
|
|
|
11
11
|
import { MetadataTxValidator } from './metadata_validator.js';
|
|
12
12
|
import { PhasesTxValidator } from './phases_validator.js';
|
|
13
13
|
import { TxProofValidator } from './tx_proof_validator.js';
|
|
14
|
-
export function createTxMessageValidators(
|
|
14
|
+
export function createTxMessageValidators(blockNumber, worldStateSynchronizer, gasFees, l1ChainId, rollupVersion, protocolContractTreeRoot, contractDataSource, proofVerifier, allowedInSetup = []) {
|
|
15
15
|
const merkleTree = worldStateSynchronizer.getCommitted();
|
|
16
16
|
return [
|
|
17
17
|
{
|
|
@@ -23,7 +23,6 @@ export function createTxMessageValidators(timestamp, blockNumber, worldStateSync
|
|
|
23
23
|
validator: new MetadataTxValidator({
|
|
24
24
|
l1ChainId: new Fr(l1ChainId),
|
|
25
25
|
rollupVersion: new Fr(rollupVersion),
|
|
26
|
-
timestamp,
|
|
27
26
|
blockNumber,
|
|
28
27
|
protocolContractTreeRoot,
|
|
29
28
|
vkTreeRoot: getVKTreeRoot()
|
|
@@ -45,7 +44,7 @@ export function createTxMessageValidators(timestamp, blockNumber, worldStateSync
|
|
|
45
44
|
severity: PeerErrorSeverity.HighToleranceError
|
|
46
45
|
},
|
|
47
46
|
phasesValidator: {
|
|
48
|
-
validator: new PhasesTxValidator(contractDataSource, allowedInSetup,
|
|
47
|
+
validator: new PhasesTxValidator(contractDataSource, allowedInSetup, blockNumber),
|
|
49
48
|
severity: PeerErrorSeverity.MidToleranceError
|
|
50
49
|
},
|
|
51
50
|
blockHeaderValidator: {
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import type { Fr } from '@aztec/foundation/fields';
|
|
2
2
|
import { type AnyTx, type TxValidationResult, type TxValidator } from '@aztec/stdlib/tx';
|
|
3
|
-
import type { UInt64 } from '@aztec/stdlib/types';
|
|
4
3
|
export declare class MetadataTxValidator<T extends AnyTx> implements TxValidator<T> {
|
|
5
4
|
#private;
|
|
6
5
|
private values;
|
|
7
6
|
constructor(values: {
|
|
8
7
|
l1ChainId: Fr;
|
|
9
8
|
rollupVersion: Fr;
|
|
10
|
-
timestamp: UInt64;
|
|
11
9
|
blockNumber: number;
|
|
12
10
|
vkTreeRoot: Fr;
|
|
13
11
|
protocolContractTreeRoot: Fr;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metadata_validator.d.ts","sourceRoot":"","sources":["../../../src/msg_validators/tx_validator/metadata_validator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAEnD,OAAO,EACL,KAAK,KAAK,EAOV,KAAK,kBAAkB,EACvB,KAAK,WAAW,EACjB,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"metadata_validator.d.ts","sourceRoot":"","sources":["../../../src/msg_validators/tx_validator/metadata_validator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAEnD,OAAO,EACL,KAAK,KAAK,EAOV,KAAK,kBAAkB,EACvB,KAAK,WAAW,EACjB,MAAM,kBAAkB,CAAC;AAE1B,qBAAa,mBAAmB,CAAC,CAAC,SAAS,KAAK,CAAE,YAAW,WAAW,CAAC,CAAC,CAAC;;IAIvE,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE;QACd,SAAS,EAAE,EAAE,CAAC;QACd,aAAa,EAAE,EAAE,CAAC;QAClB,WAAW,EAAE,MAAM,CAAC;QACpB,UAAU,EAAE,EAAE,CAAC;QACf,wBAAwB,EAAE,EAAE,CAAC;KAC9B;IAGG,UAAU,CAAC,EAAE,EAAE,CAAC,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAsFrD"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createLogger } from '@aztec/foundation/log';
|
|
2
|
-
import { TX_ERROR_INCORRECT_L1_CHAIN_ID, TX_ERROR_INCORRECT_PROTOCOL_CONTRACT_TREE_ROOT, TX_ERROR_INCORRECT_ROLLUP_VERSION, TX_ERROR_INCORRECT_VK_TREE_ROOT,
|
|
2
|
+
import { TX_ERROR_INCORRECT_L1_CHAIN_ID, TX_ERROR_INCORRECT_PROTOCOL_CONTRACT_TREE_ROOT, TX_ERROR_INCORRECT_ROLLUP_VERSION, TX_ERROR_INCORRECT_VK_TREE_ROOT, TX_ERROR_INVALID_MAX_BLOCK_NUMBER, Tx } from '@aztec/stdlib/tx';
|
|
3
3
|
export class MetadataTxValidator {
|
|
4
4
|
values;
|
|
5
5
|
#log;
|
|
@@ -15,8 +15,8 @@ export class MetadataTxValidator {
|
|
|
15
15
|
if (!await this.#hasCorrectRollupVersion(tx)) {
|
|
16
16
|
errors.push(TX_ERROR_INCORRECT_ROLLUP_VERSION);
|
|
17
17
|
}
|
|
18
|
-
if (!await this.#
|
|
19
|
-
errors.push(
|
|
18
|
+
if (!await this.#isValidForBlockNumber(tx)) {
|
|
19
|
+
errors.push(TX_ERROR_INVALID_MAX_BLOCK_NUMBER);
|
|
20
20
|
}
|
|
21
21
|
if (!await this.#hasCorrectVkTreeRoot(tx)) {
|
|
22
22
|
errors.push(TX_ERROR_INCORRECT_VK_TREE_ROOT);
|
|
@@ -55,16 +55,10 @@ export class MetadataTxValidator {
|
|
|
55
55
|
return true;
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
-
async #
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
const buildingBlock1 = this.values.blockNumber === 1;
|
|
63
|
-
if (!buildingBlock1 && includeByTimestamp.isSome && includeByTimestamp.value < this.values.timestamp) {
|
|
64
|
-
if (tx.data.constants.historicalHeader.globalVariables.blockNumber === 0) {
|
|
65
|
-
this.#log.warn(`A tx built against a genesis block failed to be included in block 1 which is the only block in which txs built against a genesis block are allowed to be included.`);
|
|
66
|
-
}
|
|
67
|
-
this.#log.verbose(`Rejecting tx ${await Tx.getHash(tx)} for low expiration timestamp. Tx expiration timestamp: ${includeByTimestamp.value}, timestamp: ${this.values.timestamp}.`);
|
|
58
|
+
async #isValidForBlockNumber(tx) {
|
|
59
|
+
const maxBlockNumber = tx.data.rollupValidationRequests.maxBlockNumber;
|
|
60
|
+
if (maxBlockNumber.isSome && maxBlockNumber.value < this.values.blockNumber) {
|
|
61
|
+
this.#log.verbose(`Rejecting tx ${await Tx.getHash(tx)} for low max block number. Tx max block number: ${maxBlockNumber.value}, current block number: ${this.values.blockNumber}.`);
|
|
68
62
|
return false;
|
|
69
63
|
} else {
|
|
70
64
|
return true;
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import type { ContractDataSource } from '@aztec/stdlib/contract';
|
|
2
2
|
import type { AllowedElement } from '@aztec/stdlib/interfaces/server';
|
|
3
3
|
import { Tx, type TxValidationResult, type TxValidator } from '@aztec/stdlib/tx';
|
|
4
|
-
import type { UInt64 } from '@aztec/stdlib/types';
|
|
5
4
|
export declare class PhasesTxValidator implements TxValidator<Tx> {
|
|
6
5
|
#private;
|
|
7
6
|
private setupAllowList;
|
|
8
|
-
private
|
|
7
|
+
private blockNumber;
|
|
9
8
|
private contractsDB;
|
|
10
|
-
constructor(contracts: ContractDataSource, setupAllowList: AllowedElement[],
|
|
9
|
+
constructor(contracts: ContractDataSource, setupAllowList: AllowedElement[], blockNumber: number);
|
|
11
10
|
validateTx(tx: Tx): Promise<TxValidationResult>;
|
|
12
11
|
private isOnAllowList;
|
|
13
12
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"phases_validator.d.ts","sourceRoot":"","sources":["../../../src/msg_validators/tx_validator/phases_validator.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,EAIL,EAAE,EAEF,KAAK,kBAAkB,EACvB,KAAK,WAAW,EACjB,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"phases_validator.d.ts","sourceRoot":"","sources":["../../../src/msg_validators/tx_validator/phases_validator.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,EAIL,EAAE,EAEF,KAAK,kBAAkB,EACvB,KAAK,WAAW,EACjB,MAAM,kBAAkB,CAAC;AAE1B,qBAAa,iBAAkB,YAAW,WAAW,CAAC,EAAE,CAAC;;IAMrD,OAAO,CAAC,cAAc;IACtB,OAAO,CAAC,WAAW;IALrB,OAAO,CAAC,WAAW,CAAoB;gBAGrC,SAAS,EAAE,kBAAkB,EACrB,cAAc,EAAE,cAAc,EAAE,EAChC,WAAW,EAAE,MAAM;IAKvB,UAAU,CAAC,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,kBAAkB,CAAC;YAqCvC,aAAa;CAiD5B"}
|
|
@@ -3,12 +3,12 @@ import { PublicContractsDB, getCallRequestsWithCalldataByPhase } from '@aztec/si
|
|
|
3
3
|
import { TX_ERROR_DURING_VALIDATION, TX_ERROR_SETUP_FUNCTION_NOT_ALLOWED, Tx, TxExecutionPhase } from '@aztec/stdlib/tx';
|
|
4
4
|
export class PhasesTxValidator {
|
|
5
5
|
setupAllowList;
|
|
6
|
-
|
|
6
|
+
blockNumber;
|
|
7
7
|
#log;
|
|
8
8
|
contractsDB;
|
|
9
|
-
constructor(contracts, setupAllowList,
|
|
9
|
+
constructor(contracts, setupAllowList, blockNumber){
|
|
10
10
|
this.setupAllowList = setupAllowList;
|
|
11
|
-
this.
|
|
11
|
+
this.blockNumber = blockNumber;
|
|
12
12
|
this.#log = createLogger('sequencer:tx_validator:tx_phases');
|
|
13
13
|
this.contractsDB = new PublicContractsDB(contracts);
|
|
14
14
|
}
|
|
@@ -71,7 +71,7 @@ export class PhasesTxValidator {
|
|
|
71
71
|
return true;
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
|
-
const contractClass = await this.contractsDB.getContractInstance(contractAddress, this.
|
|
74
|
+
const contractClass = await this.contractsDB.getContractInstance(contractAddress, this.blockNumber);
|
|
75
75
|
if (!contractClass) {
|
|
76
76
|
throw new Error(`Contract not found: ${contractAddress}`);
|
|
77
77
|
}
|
|
@@ -1,18 +1,11 @@
|
|
|
1
1
|
import type { Timer } from '@aztec/foundation/timer';
|
|
2
|
-
import { TopicType } from '@aztec/stdlib/p2p';
|
|
2
|
+
import type { TopicType } from '@aztec/stdlib/p2p';
|
|
3
3
|
import { type TelemetryClient } from '@aztec/telemetry-client';
|
|
4
4
|
export declare class P2PInstrumentation {
|
|
5
5
|
private messageValidationDuration;
|
|
6
6
|
private messagePrevalidationCount;
|
|
7
|
-
private messageLatency;
|
|
8
|
-
private aggLatencyHisto;
|
|
9
|
-
private aggValidationHisto;
|
|
10
|
-
private aggLatencyMetrics;
|
|
11
|
-
private aggValidationMetrics;
|
|
12
7
|
constructor(client: TelemetryClient, name: string);
|
|
13
8
|
recordMessageValidation(topicName: TopicType, timerOrMs: Timer | number): void;
|
|
14
9
|
incMessagePrevalidationStatus(passed: boolean, topicName: TopicType | undefined): void;
|
|
15
|
-
recordMessageLatency(topicName: TopicType, timerOrMs: Timer | number): void;
|
|
16
|
-
private aggregate;
|
|
17
10
|
}
|
|
18
11
|
//# sourceMappingURL=instrumentation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instrumentation.d.ts","sourceRoot":"","sources":["../../../src/services/libp2p/instrumentation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"instrumentation.d.ts","sourceRoot":"","sources":["../../../src/services/libp2p/instrumentation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAIL,KAAK,eAAe,EAGrB,MAAM,yBAAyB,CAAC;AAEjC,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,yBAAyB,CAAY;IAC7C,OAAO,CAAC,yBAAyB,CAAgB;gBAErC,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM;IAe1C,uBAAuB,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,GAAG,MAAM;IAKvE,6BAA6B,CAAC,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,GAAG,SAAS;CAGvF"}
|